Thread: [Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Persistence.java,NONE,1.1 Surface.jav
Status: Pre-Alpha
Brought to you by:
henryml
|
From: Michael L. <he...@us...> - 2006-04-05 09:36:21
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8178/src/net/sourceforge/bprocessor/model Modified Files: Surface.java Geometry.java Space.java Project.java Plane.java Added Files: Persistence.java Log Message: A large amount of changes because of the CVS outage at sourceforge. Element-modelling now completet Index: Surface.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Surface.java,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -d -r1.85 -r1.86 *** Surface.java 25 Mar 2006 18:08:32 -0000 1.85 --- Surface.java 5 Apr 2006 09:35:58 -0000 1.86 *************** *** 299,304 **** * class="net.sourceforge.bprocessor.model.Surface" */ ! public Set getHoles() { ! return holes; } --- 299,308 ---- * class="net.sourceforge.bprocessor.model.Surface" */ ! public Collection getHoles() { ! if (holes == null) { ! return Space.EMPTY; ! } else { ! return holes; ! } } *************** *** 345,349 **** } surface.setEdges(edges); ! mesh.add(surface); return surface; } --- 349,353 ---- } surface.setEdges(edges); ! mesh.insert(surface); return surface; } *************** *** 454,458 **** facemap[i] = new Surface(newEdges); e2s.put(b, facemap[i]); ! getOwner().add(facemap[i]); } sides.add(facemap[i]); --- 458,462 ---- facemap[i] = new Surface(newEdges); e2s.put(b, facemap[i]); ! getOwner().insert(facemap[i]); } sides.add(facemap[i]); *************** *** 465,469 **** } top = new Surface(newEdges); ! getOwner().add(top); } --- 469,473 ---- } top = new Surface(newEdges); ! getOwner().insert(top); } *************** *** 959,968 **** if (isInner()) { res.add(new Attribute("Exterior", getExterior(), false)); ! } else { ! if (holes != null) { ! Iterator iterElems = holes.iterator(); ! while (iterElems.hasNext()) { ! res.add(new Attribute("Hole", iterElems.next(), false)); ! } } } --- 963,971 ---- if (isInner()) { res.add(new Attribute("Exterior", getExterior(), false)); ! } ! if (holes != null) { ! Iterator iterElems = holes.iterator(); ! while (iterElems.hasNext()) { ! res.add(new Attribute("Hole", iterElems.next(), false)); } } Index: Plane.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Plane.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Plane.java 17 Mar 2006 09:30:34 -0000 1.16 --- Plane.java 5 Apr 2006 09:35:58 -0000 1.17 *************** *** 36,39 **** --- 36,48 ---- private double d; + /** X component in a double-array */ + public static final int X = 0; + + /** Y component in a double-array */ + public static final int Y = 1; + + /** Z component in a double-array */ + public static final int Z = 2; + /** *************** *** 204,207 **** --- 213,277 ---- return intersection(p0, p1); } + + + /** + * Return X, Y or Z based on + * which of the coefficients a, b and c are the largest + * @return Index indicating the largest coefficient + */ + public int largestCoefficient() { + int result = X; + double coefficient = Math.abs(a); + + if (Math.abs(b) > coefficient) { + result = Y; + coefficient = Math.abs(b); + }; + + if (Math.abs(c) > coefficient) { + result = Z; + coefficient = Math.abs(c); + }; + + return result; + } + + /** + * An appropriate origin is chosen as the + * crossing between an axis depending on the + * largest coefficient + * @return The origin + */ + public Vertex origin() { + double[] vector = new double[3]; + double[] values = getDoublev(); + vector[X] = 0; + vector[Y] = 0; + vector[Z] = 0; + int index = largestCoefficient(); + vector[index] = -d / values[index]; + return new Vertex(vector[X], vector[Y], vector[Z]); + } + + /** + * Project a vector into this plane + * @param vector The vector to project + * @return The projected vector + */ + public Vertex project(Vertex vector) { + double t = a * vector.getX() + b * vector.getY() + c * vector.getZ(); + Vertex n = new Vertex(t * a, t * b, t * c); + return vector.minus(n); + } + + /** + * Un-project a vector from this plane + * @param vector Vector + * @return The un-projected vector + */ + public Vertex unProject(Vertex vector) { + Vertex n = new Vertex(a, b, c); + return vector.add(n); + } /** Index: Project.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Project.java,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -d -r1.53 -r1.54 *** Project.java 30 Mar 2006 08:03:45 -0000 1.53 --- Project.java 5 Apr 2006 09:35:58 -0000 1.54 *************** *** 18,23 **** import java.util.Stack; ! import net.sourceforge.bprocessor.model.xml.Bprocessor; ! import net.sourceforge.bprocessor.model.xml.PersistenceManager; import org.apache.log4j.Logger; --- 18,22 ---- import java.util.Stack; ! import net.sourceforge.bprocessor.model.xml.Bmodel; import org.apache.log4j.Logger; *************** *** 42,51 **** private Space world; ! /** The spaces */ ! private HashMap spaces = new HashMap(); ! /** The space id */ ! private long spaceId; ! ! /** The domains */ private HashMap cameras = new HashMap(); --- 41,45 ---- private Space world; ! /** The cameras */ private HashMap cameras = new HashMap(); *************** *** 78,82 **** /** The current state */ ! private Bprocessor currentState; /** --- 72,76 ---- /** The current state */ ! private Bmodel currentState; /** *************** *** 101,105 **** addCams(); observers = new LinkedList(); ! world = new Space("Void", Space.FUNCTIONAL); constraints = new LinkedList(); } --- 95,99 ---- addCams(); observers = new LinkedList(); ! world = new Space("World", Space.FUNCTIONAL, true); constraints = new LinkedList(); } *************** *** 114,117 **** --- 108,119 ---- /** + * Set the world + * @param world The world + */ + public void setWorld(Space world) { + this.world = world; + } + + /** * Add observer * @param observer The observer *************** *** 146,150 **** */ public void clear() { - spaces.clear(); world.clear(); this.setActiveSpace(null); --- 148,151 ---- *************** *** 301,307 **** */ public void add(Space space) { ! space.setId(new Long(spaceId++)); ! spaces.put(space.getId(), space); ! changed(this); } --- 302,306 ---- */ public void add(Space space) { ! world.add(space); } *************** *** 312,316 **** public Collection getConstructionSpaces() { Collection result = new HashSet(); ! Iterator iter = spaces.values().iterator(); while (iter.hasNext()) { Space current = (Space) iter.next(); --- 311,315 ---- public Collection getConstructionSpaces() { Collection result = new HashSet(); ! Iterator iter = world.getElements().iterator(); while (iter.hasNext()) { Space current = (Space) iter.next(); *************** *** 327,331 **** */ public Collection getSpaces() { ! return spaces.values(); } --- 326,330 ---- */ public Collection getSpaces() { ! return world.getElements(); } *************** *** 371,392 **** */ public void remove(Space space) { ! Set surfaces = space.getEnvelope(); ! if (surfaces != null) { ! Iterator surfIt = surfaces.iterator(); ! while (surfIt.hasNext()) { ! Surface surface = (Surface)surfIt.next(); ! Space back = surface.getBackDomain(); ! if (back == space) { ! surface.setBackDomain(null); ! } else { ! Space front = surface.getFrontDomain(); ! if (front == space) { ! surface.setFrontDomain(null); ! } ! } ! } ! } ! spaces.remove(space.getId()); ! space.setId(null); } --- 370,374 ---- */ public void remove(Space space) { ! world.remove(space); } *************** *** 406,410 **** public Collection getFunctionalSpaces() { Collection result = new HashSet(); ! Iterator iter = spaces.values().iterator(); while (iter.hasNext()) { Space current = (Space) iter.next(); --- 388,392 ---- public Collection getFunctionalSpaces() { Collection result = new HashSet(); ! Iterator iter = world.getElements().iterator(); while (iter.hasNext()) { Space current = (Space) iter.next(); *************** *** 647,651 **** undoStack.push(currentState); } ! currentState = PersistenceManager.externalize(); } --- 629,633 ---- undoStack.push(currentState); } ! currentState = Persistence.externalize(); } *************** *** 674,680 **** redoStack.push(currentState); } ! currentState = (Bprocessor) undoStack.pop(); clear(); ! PersistenceManager.internalize(currentState); } } --- 656,662 ---- redoStack.push(currentState); } ! currentState = (Bmodel) undoStack.pop(); clear(); ! Persistence.internalize(currentState); } } *************** *** 688,694 **** undoStack.push(currentState); } ! currentState = (Bprocessor) redoStack.pop(); clear(); ! PersistenceManager.internalize(currentState); } } --- 670,676 ---- undoStack.push(currentState); } ! currentState = (Bmodel) redoStack.pop(); clear(); ! Persistence.internalize(currentState); } } *************** *** 717,721 **** */ public void saveAs(File file) throws Exception { ! PersistenceManager.save(file); makeClean(); resetHistory(); --- 699,703 ---- */ public void saveAs(File file) throws Exception { ! Persistence.save(file); makeClean(); resetHistory(); *************** *** 730,734 **** */ public void save() throws Exception { ! PersistenceManager.save(new File(getSavePath())); makeClean(); resetHistory(); --- 712,716 ---- */ public void save() throws Exception { ! Persistence.save(new File(getSavePath())); makeClean(); resetHistory(); *************** *** 744,748 **** Selection.primary().clear(); clear(); ! PersistenceManager.load(file); makeClean(); resetHistory(); --- 726,730 ---- Selection.primary().clear(); clear(); ! Persistence.load(file); makeClean(); resetHistory(); Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** Space.java 25 Mar 2006 18:08:32 -0000 1.23 --- Space.java 5 Apr 2006 09:35:58 -0000 1.24 *************** *** 32,35 **** --- 32,38 ---- private static final long serialVersionUID = 1L; + /** An empty collection */ + protected static final Collection EMPTY = new LinkedList(); + /** Construction Type */ public static final int CONSTRUCTION = 0; *************** *** 46,54 **** /** The envelope (a set of surfaces) */ private Set envelope; /** The elements (a list of spaces) */ ! private List elements; /** The vertices */ private HashMap vertices; - /** The next vertex id */ private long nextVertexId; --- 49,71 ---- /** The envelope (a set of surfaces) */ private Set envelope; + + /** + * The next boolean specifies wether or not + * this space can contain other spaces. + * FIXME Should probably be handled by a class + * hierarchy + */ + private boolean container; + + /** The empty space in this space (also called void) */ + protected Space empty; + /** The elements (a list of spaces) */ ! private HashMap elements; ! /** The next element id */ ! private long nextElementId; ! /** The vertices */ private HashMap vertices; /** The next vertex id */ private long nextVertexId; *************** *** 56,60 **** /** The edges */ private HashMap edges; - /** The next edge id */ private long nextEdgeId; --- 73,76 ---- *************** *** 62,68 **** /** The surfaces */ private HashMap surfaces; - /** The next surface id */ private long nextSurfaceId; /** The modellor */ private Modellor modellor; --- 78,85 ---- /** The surfaces */ private HashMap surfaces; /** The next surface id */ private long nextSurfaceId; + + /** The modellor */ private Modellor modellor; *************** *** 81,93 **** * @param name The name * @param type The type */ ! public Space(String name, int type) { super(); setName(name); setType(type); description = new Description(""); ! vertices = new HashMap(); ! edges = new HashMap(); ! surfaces = new HashMap(); } --- 98,118 ---- * @param name The name * @param type The type + * @param container The container flag */ ! public Space(String name, int type, boolean container) { super(); setName(name); setType(type); + this.container = container; description = new Description(""); ! envelope = new HashSet(); ! if (container) { ! vertices = new HashMap(); ! edges = new HashMap(); ! surfaces = new HashMap(); ! elements = new HashMap(); ! empty = new Space("Void", FUNCTIONAL, false); ! this.add(empty); ! } } *************** *** 98,102 **** */ public static Space createConstructionSpace(String name) { ! return new Space(name, Space.CONSTRUCTION); } --- 123,127 ---- */ public static Space createConstructionSpace(String name) { ! return new Space(name, Space.CONSTRUCTION, true); } *************** *** 107,111 **** */ public static Space createFunctionalSpace(String name) { ! return new Space(name, Space.FUNCTIONAL); } --- 132,136 ---- */ public static Space createFunctionalSpace(String name) { ! return new Space(name, Space.FUNCTIONAL, true); } *************** *** 127,130 **** --- 152,171 ---- /** + * + * @return isContainer + */ + public boolean isContainer() { + return container; + } + + /** + * + * @param container isContainer + */ + public void setContainer(boolean container) { + this.container = container; + } + + /** * Get the name * @return The name *************** *** 142,145 **** --- 183,208 ---- this.name = name; } + + /** + * Sets the space serving as empty + * @param element Space + */ + public void setEmpty(Space element) { + if (empty != null) { + remove(empty); + } + empty = element; + if (empty != null) { + add(empty); + } + } + + /** + * Gets the space serving as empty + * @return Empty + */ + public Space getEmpty() { + return empty; + } *************** *** 166,175 **** */ public void clear() { ! vertices.clear(); ! nextVertexId = 0; ! edges.clear(); ! nextEdgeId = 0; ! surfaces.clear(); ! nextSurfaceId = 0; } --- 229,244 ---- */ public void clear() { ! if (container) { ! vertices.clear(); ! nextVertexId = 0; ! edges.clear(); ! nextEdgeId = 0; ! surfaces.clear(); ! nextSurfaceId = 0; ! elements.clear(); ! nextElementId = 0; ! empty = new Space("Void", FUNCTIONAL, false); ! this.add(empty); ! } } *************** *** 179,186 **** */ public void add(Vertex vertex) { ! Long id = new Long(nextVertexId++); ! vertex.setId(id); ! vertices.put(id, vertex); ! vertex.setOwner(this); } --- 248,259 ---- */ public void add(Vertex vertex) { ! if (container) { ! Long id = new Long(nextVertexId++); ! vertex.setId(id); ! vertices.put(id, vertex); ! vertex.setOwner(this); ! } else { ! throw new Error("adding vertex to non-container " + this); ! } } *************** *** 226,230 **** */ public Collection getVertices() { ! return vertices.values(); } --- 299,307 ---- */ public Collection getVertices() { ! if (container) { ! return vertices.values(); ! } else { ! return EMPTY; ! } } *************** *** 243,250 **** */ public void add(Edge edge) { ! Long id = new Long(nextEdgeId++); ! edge.setId(id); ! edges.put(id, edge); ! edge.setOwner(this); } --- 320,331 ---- */ public void add(Edge edge) { ! if (container) { ! Long id = new Long(nextEdgeId++); ! edge.setId(id); ! edges.put(id, edge); ! edge.setOwner(this); ! } else { ! throw new Error("adding edge to non-container " + this); ! } } *************** *** 366,370 **** edges1.addAll(edges2); Surface surface = new Surface(edges1); ! add(surface); if (s1.getExterior() != null) { s1.getExterior().addHole(surface); --- 447,451 ---- edges1.addAll(edges2); Surface surface = new Surface(edges1); ! insert(surface); if (s1.getExterior() != null) { s1.getExterior().addHole(surface); *************** *** 398,402 **** */ public Collection getEdges() { ! return edges.values(); } --- 479,487 ---- */ public Collection getEdges() { ! if (container) { ! return edges.values(); ! } else { ! return EMPTY; ! } } *************** *** 415,422 **** */ public void add(Surface surface) { ! Long id = new Long(nextSurfaceId++); ! surface.setId(id); ! surfaces.put(id, surface); ! surface.setOwner(this); } --- 500,511 ---- */ public void add(Surface surface) { ! if (container) { ! Long id = new Long(nextSurfaceId++); ! surface.setId(id); ! surfaces.put(id, surface); ! surface.setOwner(this); ! } else { ! throw new Error("adding surface to non-container " + this); ! } } *************** *** 452,455 **** --- 541,546 ---- public Surface insert(Surface surface) { add(surface); + surface.setBackDomain(empty); + surface.setFrontDomain(empty); return surface; } *************** *** 477,481 **** */ public Collection getSurfaces() { ! return surfaces.values(); } --- 568,576 ---- */ public Collection getSurfaces() { ! if (container) { ! return surfaces.values(); ! } else { ! return EMPTY; ! } } *************** *** 578,584 **** */ public void addSurface(Surface surface) { - if (envelope == null) { - envelope = new HashSet(); - } envelope.add(surface); changed(); --- 673,676 ---- *************** *** 590,599 **** */ public void removeSurface(Surface surface) { ! if (envelope != null) { ! envelope.remove(surface); ! changed(); ! } else { ! throw new Error("removing " + surface + " from " + this + " with no envelope"); ! } } --- 682,687 ---- */ public void removeSurface(Surface surface) { ! envelope.remove(surface); ! changed(); } *************** *** 603,610 **** */ public void add(Space element) { ! if (elements == null) { ! elements = new LinkedList(); } - elements.add(element); } --- 691,701 ---- */ public void add(Space element) { ! if (container) { ! Long id = new Long(nextElementId++); ! element.setId(id); ! elements.put(id, element); ! } else { ! throw new Error("adding element to non-container " + this); } } *************** *** 614,620 **** */ public void remove(Space element) { ! elements.remove(element); } /** --- 705,740 ---- */ public void remove(Space element) { ! Set surfaces = element.getEnvelope(); ! if (surfaces != null) { ! Iterator iter = surfaces.iterator(); ! while (iter.hasNext()) { ! Surface current = (Surface)iter.next(); ! Space back = current.getBackDomain(); ! if (back == element) { ! current.setBackDomain(null); ! } else { ! Space front = current.getFrontDomain(); ! if (front == element) { ! current.setFrontDomain(null); ! } ! } ! } ! } ! ! elements.remove(element.getId()); ! element.setId(null); } + /** + * Get elements + * @return Elements + */ + public Collection getElements() { + if (container) { + return elements.values(); + } else { + return EMPTY; + } + } /** Index: Geometry.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Geometry.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Geometry.java 30 Mar 2006 08:03:45 -0000 1.18 --- Geometry.java 5 Apr 2006 09:35:58 -0000 1.19 *************** *** 263,267 **** if (clockwise.angle(vertex.system()) < 0) { ! mesh.add(clockwise); holeAnalysis(clockwise); surfaces.add(clockwise); --- 263,267 ---- if (clockwise.angle(vertex.system()) < 0) { ! mesh.insert(clockwise); holeAnalysis(clockwise); surfaces.add(clockwise); *************** *** 274,278 **** if (counterclockwise != null) { if (counterclockwise.angle(vertex.system()) > 0) { ! mesh.add(counterclockwise); holeAnalysis(counterclockwise); surfaces.add(counterclockwise); --- 274,278 ---- if (counterclockwise != null) { if (counterclockwise.angle(vertex.system()) > 0) { ! mesh.insert(counterclockwise); holeAnalysis(counterclockwise); surfaces.add(counterclockwise); *************** *** 612,615 **** --- 612,633 ---- /** + * Test if exterior contains interior + * @param exterior The exterior surface + * @param interior The interior surface + * @return True if exterior contains interior + */ + public static boolean contains(Surface exterior, Surface interior) { + if (interior == null) { + return false; + } else { + if (interior.getExterior() == exterior) { + return true; + } else { + return contains(exterior, interior.getExterior()); + } + } + } + + /** * See if surface has become a hole in a surface in * the project. *************** *** 617,629 **** */ public static void holeAnalysis(Surface surface) { ! Collection surfaces = surface.getOwner().getSurfaces(); ! Iterator iter = surfaces.iterator(); ! while (iter.hasNext()) { ! Surface current = (Surface) iter.next(); ! if (current != surface) { ! if (current.surrounds(surface)) { ! current.addHole(surface); ! } else if (surface.surrounds(current)) { ! surface.addHole(current); } } --- 635,706 ---- */ public static void holeAnalysis(Surface surface) { ! Set exteriors = new HashSet(); ! Set interiors = new HashSet(); ! ! { ! Collection surfaces = surface.getOwner().getSurfaces(); ! Iterator iter = surfaces.iterator(); ! while (iter.hasNext()) { ! Surface current = (Surface) iter.next(); ! if (current != surface) { ! if (current.surrounds(surface)) { ! exteriors.add(current); ! } else if (surface.surrounds(current)) { ! interiors.add(current); ! } ! } ! } ! } ! ! Surface exterior = null; ! { ! // Find exterior ! // The exterior is the surface among the candidates that does not ! // contain any of the other candidates. ! Iterator iter = exteriors.iterator(); ! search: ! while (iter.hasNext()) { ! Surface candidate = (Surface) iter.next(); ! Iterator inner = exteriors.iterator(); ! check: ! { ! while (inner.hasNext()) { ! Surface current = (Surface) inner.next(); ! if (current != candidate) { ! if (contains(candidate, current)) { ! // Discard current candidate and look at the next ! break check; ! } ! } ! } ! // Acecpt current candidate and break the search. ! exterior = candidate; ! break search; ! } ! } ! } ! if (exterior != null) { ! Project.info(exterior + " contains " + surface); ! exterior.addHole(surface); ! ! } ! { ! // Find interior ! if (exterior == null) { ! Iterator iter = interiors.iterator(); ! while (iter.hasNext()) { ! Surface candidate = (Surface) iter.next(); ! if (candidate.getExterior() == null) { ! surface.addHole(candidate); ! } ! } ! } else { ! Iterator iter = interiors.iterator(); ! while (iter.hasNext()) { ! Surface candidate = (Surface) iter.next(); ! if (candidate.getExterior() == exterior) { ! exterior.removeHole(candidate); ! surface.addHole(candidate); ! } } } --- NEW FILE: Persistence.java --- //--------------------------------------------------------------------------------- // $Id: Persistence.java,v 1.1 2006/04/05 09:35:58 henryml Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.model; import net.sourceforge.bprocessor.model.xml.Bmodel; import net.sourceforge.bprocessor.model.xml.EdgeType; import net.sourceforge.bprocessor.model.xml.EntityType; import net.sourceforge.bprocessor.model.xml.SpaceType; import net.sourceforge.bprocessor.model.xml.SurfaceType; import net.sourceforge.bprocessor.model.xml.VertexType; import net.sourceforge.bprocessor.model.xml.impl.BmodelImpl; import net.sourceforge.bprocessor.model.xml.impl.EdgeImpl; import net.sourceforge.bprocessor.model.xml.impl.SpaceImpl; import net.sourceforge.bprocessor.model.xml.impl.SurfaceImpl; import net.sourceforge.bprocessor.model.xml.impl.VertexImpl; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; import java.util.Map.Entry; import javax.xml.bind.JAXBContext; import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; import org.apache.log4j.Logger; /** * This class persist the model from/to an XML document */ public class Persistence { /** The logger */ private static Logger log = Logger.getLogger(Persistence.class); /** Mapper counter */ private static long counter; /** * Constructor */ private Persistence() { } /** * This method internalizes a b-processor document * @param document XML */ public static void internalize(Bmodel document) { HashMap mapper = new HashMap(); Collection xmls = new LinkedList(); Space world = internalizeSpace((SpaceType) document.getSpace().iterator().next(), mapper, xmls); { Iterator iter = xmls.iterator(); while (iter.hasNext()) { EntityType external = (EntityType) iter.next(); Object object = mapper.get(new Long(external.getId())); internalizeReferences(object, external, mapper); } } Project.getInstance().setWorld(world); Project.getInstance().setActiveSpace((Space) get(document.getActive(), mapper)); } /** * This method loads the Bmodel document from a file * @param file The input file * @exception Exception Thrown if an exception occurs */ public static void load(File file) throws Exception { FileInputStream fis = new FileInputStream(file); Bmodel bp = loadFile(fis); internalize(bp); fis.close(); } /** * This method loads the Bmodel document from a file * @param is The input stream * @return The Bmodel document * @exception Exception Thrown if an exception occurs */ private static Bmodel loadFile(InputStream is) throws Exception { JAXBContext jc = JAXBContext.newInstance("net.sourceforge.bprocessor.model.xml"); Unmarshaller u = jc.createUnmarshaller(); return (Bmodel)u.unmarshal(is); } /** * * @param xml The SpaceType * @param mapper The mapper * @param xmls The xmls * @return The Space */ private static Space internalizeSpace(SpaceType xml, Map mapper, Collection xmls) { String name = xml.getName(); Collection elements = new LinkedList(); int type = xml.getType(); long empty = xml.getVoidref(); ... [truncated message content] |