Thread: [Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Space.java, 1.201, 1.202 Persistence
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2007-11-06 18:26:56
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv7199/src/net/sourceforge/bprocessor/model Modified Files: Space.java Persistence.java Log Message: Removed transformations from a space and removed all of its uses through space. Added a anchor to space to be used with instances. Changed the display code to use that. Added try catch clause arround display.draw to be able to continue using the tool even if the display method throws exceptions Index: Persistence.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Persistence.java,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** Persistence.java 5 Nov 2007 12:26:22 -0000 1.52 --- Persistence.java 6 Nov 2007 18:26:55 -0000 1.53 *************** *** 78,82 **** import java.io.InputStream; import java.io.OutputStream; - import java.util.ArrayList; import java.util.Collection; import java.util.Collections; --- 78,81 ---- *************** *** 338,352 **** }*/ { - Iterator iter = xml.getTransforms().iterator(); - ArrayList trans = new ArrayList(); - while (iter.hasNext()) { - TransformType current = (TransformType) iter.next(); - trans.add(internalizeTransformation(current, new HashSet())); - } - for (int i = trans.size() - 1; i >= 0; i--) { - space.addTransform((Transform)trans.get(i)); - } - } - { Iterator iter = xml.getConstructor().iterator(); while (iter.hasNext()) { --- 337,340 ---- *************** *** 992,1002 **** } { - Iterator iter = space.getTransformations().stack().iterator(); - while (iter.hasNext()) { - Transform t = (Transform)iter.next(); - xml.getTransforms().add(externalizeTransformation(t, new HashMap())); - } - } - { if (space.getModellor() != null) { xml.setModellor(externalizeModellor(space.getModellor(), map)); --- 980,983 ---- Index: Space.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Space.java,v retrieving revision 1.201 retrieving revision 1.202 diff -C2 -d -r1.201 -r1.202 *** Space.java 6 Nov 2007 15:29:02 -0000 1.201 --- Space.java 6 Nov 2007 18:26:54 -0000 1.202 *************** *** 124,130 **** private long nextConstructorId; - /** The transformation */ - private TransformStack transform; - /** The modellor */ private Modellor modellor; --- 124,127 ---- *************** *** 140,143 **** --- 137,143 ---- private LinkedHashMap<String, Object> ownParameters = new LinkedHashMap<String, Object>(); + + /** A anchor for instances */ + private CoordinateSystem anchor; /** *************** *** 178,182 **** super(); envelope = new HashSet<Surface>(); - transform = new TransformStack(); initializeContainers(); } --- 178,181 ---- *************** *** 216,220 **** description = new Description(""); envelope = new HashSet<Surface>(); - transform = new TransformStack(); if (container) { initializeContainers(); --- 215,218 ---- *************** *** 285,319 **** /** - * Get transformation - * @return transformations - */ - public TransformStack getTransformations() { - return transform; - } - - /** - * Add transformation - * @param transform Transform - */ - public void addTransform(Transform transform) { - this.transform.insert(transform); - } - - /** - * push transformation - * @param transform Transform - */ - public void pushTransform(Transform transform) { - this.transform.push(transform); - } - - /** - * pop transformation - */ - public void popTransform() { - this.transform.pop(); - } - - /** * Set proto * @param space Space --- 283,286 ---- *************** *** 321,324 **** --- 288,296 ---- public void setProto(Space space) { this.proto = space; + if (proto != null) { + this.anchor = Project.getInstance().getActiveCoordinateSystem().copy(); + } else { + this.anchor = null; + } } *************** *** 453,456 **** --- 425,430 ---- constructors.put(id, c); c.setOwner(this); + } else if (isInstance()) { + proto.add(c); } else { throw new Error("adding constructor to non-container " + this); *************** *** 463,470 **** */ public void remove(Constructor c) { ! if (c.getId() != null && c != Project.getInstance().getActiveCoordinateSystem()) { ! constructors.remove(c.getId()); ! c.setId(null); ! c.setOwner(null); } } --- 437,448 ---- */ public void remove(Constructor c) { ! if (container) { ! if (c.getId() != null && c != Project.getInstance().getActiveCoordinateSystem()) { ! constructors.remove(c.getId()); ! c.setId(null); ! c.setOwner(null); ! } ! } else if (isInstance()) { ! proto.remove(c); } } *************** *** 547,553 **** */ public void remove(Vertex vertex) { ! vertices.remove(vertex.getId()); ! vertex.setId(null); ! vertex.setOwner(null); } --- 525,535 ---- */ public void remove(Vertex vertex) { ! if (container) { ! vertices.remove(vertex.getId()); ! vertex.setId(null); ! vertex.setOwner(null); ! } else if (isInstance()) { ! proto.remove(vertex); ! } } *************** *** 635,641 **** */ public void remove(Edge edge) { ! edges.remove(edge.getId()); ! edge.setId(null); ! edge.setOwner(null); } --- 617,627 ---- */ public void remove(Edge edge) { ! if (container) { ! edges.remove(edge.getId()); ! edge.setId(null); ! edge.setOwner(null); ! } else if (isInstance()) { ! proto.remove(edge); ! } } *************** *** 772,778 **** */ public void remove(Surface surface) { ! surfaces.remove(surface.getId()); ! surface.setId(null); ! surface.setOwner(null); } --- 758,768 ---- */ public void remove(Surface surface) { ! if (container) { ! surfaces.remove(surface.getId()); ! surface.setId(null); ! surface.setOwner(null); ! } else if (isInstance()) { ! proto.remove(surface); ! } } *************** *** 1093,1121 **** */ public void remove(Space element) { ! Set surfs = element.getEnvelope(); ! element.setEnvelope(new HashSet<Surface>()); ! if (surfs != null) { ! Iterator iter = surfs.iterator(); ! while (iter.hasNext()) { ! Surface current = (Surface)iter.next(); ! Space back = current.getBackDomain(); ! Space front = current.getFrontDomain(); ! if (back == element) { ! current.setBackDomain(empty); } ! if (front == element) { ! current.setFrontDomain(empty); } } ! } ! if (element != null) { ! Space superSpace = findElement(element); ! if (superSpace != null) { ! superSpace.elements.remove(element.getId()); ! element.setId(null); } ! } ! if (element.getModellor() != null) { ! element.getModellor().delete(); } } --- 1083,1115 ---- */ public void remove(Space element) { ! if (container) { ! Set surfs = element.getEnvelope(); ! element.setEnvelope(new HashSet<Surface>()); ! if (surfs != null) { ! Iterator iter = surfs.iterator(); ! while (iter.hasNext()) { ! Surface current = (Surface)iter.next(); ! Space back = current.getBackDomain(); ! Space front = current.getFrontDomain(); ! if (back == element) { ! current.setBackDomain(empty); ! } ! if (front == element) { ! current.setFrontDomain(empty); ! } } ! } ! if (element != null) { ! Space superSpace = findElement(element); ! if (superSpace != null) { ! superSpace.elements.remove(element.getId()); ! element.setId(null); } } ! if (element.getModellor() != null) { ! element.getModellor().delete(); } ! } else if (isInstance()) { ! proto.remove(element); } } *************** *** 1337,1345 **** } } - Iterator iter = getTransformations().stack().iterator(); - while (iter.hasNext()) { - Transform current = (Transform) iter.next(); - res.add(new Attribute(current.getGeneralName(), current)); - } return res; } --- 1331,1334 ---- *************** *** 1448,1457 **** result.addAll(s.collect()); } ! if (isUnion() && !getConstructors().isEmpty()) { ! result.add(getConstructors().iterator().next().center()); ! } else { ! if (container) { ! result.addAll(collectInterior()); ! } } return result; --- 1437,1445 ---- result.addAll(s.collect()); } ! if (isInstance()) { ! result.add(anchor.center()); ! } ! if (container) { ! result.addAll(collectInterior()); } return result; *************** *** 2222,2241 **** */ public void removeProtected(Surface surface) { ! if (surface.getOwner() == this) { ! if (surface.protect()) { ! Space back = surface.getBackDomain(); ! if (back != null) { ! back.removeSurface(surface); } ! Space front = surface.getFrontDomain(); ! if (front != null) { ! front.removeSurface(surface); } - remove(surface); - surface.protect(false); - } - for (Edge edge : surface.getEdges()) { - removeProtected(edge); } } } --- 2210,2233 ---- */ public void removeProtected(Surface surface) { ! if (container) { ! if (surface.getOwner() == this) { ! if (surface.protect()) { ! Space back = surface.getBackDomain(); ! if (back != null) { ! back.removeSurface(surface); ! } ! Space front = surface.getFrontDomain(); ! if (front != null) { ! front.removeSurface(surface); ! } ! remove(surface); ! surface.protect(false); } ! for (Edge edge : surface.getEdges()) { ! removeProtected(edge); } } + } else if (isInstance()) { + proto.remove(surface); } } *************** *** 2246,2256 **** */ public void removeProtected(Edge edge) { ! if (edge.getOwner() == this) { ! if (edge.protect()) { ! remove(edge); ! edge.protect(false); } ! removeProtected(edge.from); ! removeProtected(edge.to); } } --- 2238,2252 ---- */ public void removeProtected(Edge edge) { ! if (container) { ! if (edge.getOwner() == this) { ! if (edge.protect()) { ! remove(edge); ! edge.protect(false); ! } ! removeProtected(edge.from); ! removeProtected(edge.to); } ! } else if (isInstance()) { ! proto.remove(edge); } } *************** *** 2261,2269 **** */ public void removeProtected(Vertex vertex) { ! if (vertex.getOwner() == this) { ! if (vertex.protect()) { ! remove(vertex); ! vertex.protect(false); } } } --- 2257,2269 ---- */ public void removeProtected(Vertex vertex) { ! if (container) { ! if (vertex.getOwner() == this) { ! if (vertex.protect()) { ! remove(vertex); ! vertex.protect(false); ! } } + } else if (isInstance()) { + proto.remove(vertex); } } *************** *** 2298,2307 **** */ public void addProtected(Surface surface) { ! for (Edge edge : surface.getEdges()) { ! addProtected(edge); ! } ! if (surface.getOwner() == null) { ! surface.protect(true); ! add(surface); } } --- 2298,2311 ---- */ public void addProtected(Surface surface) { ! if (container) { ! for (Edge edge : surface.getEdges()) { ! addProtected(edge); ! } ! if (surface.getOwner() == null) { ! surface.protect(true); ! add(surface); ! } ! } else if (isInstance()) { ! proto.addProtected(surface); } } *************** *** 2312,2320 **** */ public void addProtected(Edge edge) { ! addProtected(edge.from); ! addProtected(edge.to); ! if (edge.getOwner() == null) { ! edge.protect(true); ! add(edge); } } --- 2316,2328 ---- */ public void addProtected(Edge edge) { ! if (container) { ! addProtected(edge.from); ! addProtected(edge.to); ! if (edge.getOwner() == null) { ! edge.protect(true); ! add(edge); ! } ! } else if (isInstance()) { ! proto.addProtected(edge); } } *************** *** 2325,2331 **** */ public void addProtected(Vertex vertex) { ! if (vertex.getOwner() == null) { ! vertex.protect(true); ! add(vertex); } } --- 2333,2343 ---- */ public void addProtected(Vertex vertex) { ! if (container) { ! if (vertex.getOwner() == null) { ! vertex.protect(true); ! add(vertex); ! } ! } else if (isInstance()) { ! proto.addProtected(vertex); } } *************** *** 2993,2995 **** --- 3005,3022 ---- } } + + /** + * Getter for anchor + * @return The anchor + */ + public CoordinateSystem getInstanceAnchor() { + if (isInstance()) { + if (anchor == null) { + anchor = Project.getInstance().getActiveCoordinateSystem().copy(); + } + return anchor; + } else { + return null; + } + } } |