[Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/treeview GenericTreeView.java, 1.129, 1.
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2007-12-10 18:45:05
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv10171/src/net/sourceforge/bprocessor/gui/treeview Modified Files: GenericTreeView.java SpaceTreeView.java Log Message: Cleanup Index: GenericTreeView.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview/GenericTreeView.java,v retrieving revision 1.129 retrieving revision 1.130 diff -C2 -d -r1.129 -r1.130 *** GenericTreeView.java 10 Dec 2007 13:47:34 -0000 1.129 --- GenericTreeView.java 10 Dec 2007 18:45:06 -0000 1.130 *************** *** 18,27 **** import java.util.Enumeration; import java.util.HashSet; - import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Set; - import java.util.Stack; - import java.awt.event.ActionEvent; --- 18,24 ---- *************** *** 454,469 **** /** * Constructor for ContainerNode ! * @param object User collection to put in * @param label The label for the container node * @param sort Sort the children? */ ! public ContainerNode(Object label, Collection< ? extends Entity> object, boolean sort) { super(label); ! this.content = object; this.sort = sort; } /** ! * @return Display String */ public String toString() { --- 451,466 ---- /** * Constructor for ContainerNode ! * @param content User collection to put in * @param label The label for the container node * @param sort Sort the children? */ ! public ContainerNode(Object label, Collection< ? extends Entity> content, boolean sort) { super(label); ! this.content = content; this.sort = sort; } /** ! * {@inheritDoc} */ public String toString() { *************** *** 474,480 **** } } /** ! * Always not be leaf ! * @return answer */ public boolean isLeaf() { --- 471,477 ---- } } + /** ! * {@inheritDoc} */ public boolean isLeaf() { *************** *** 483,488 **** /** ! * Return icon ! * @return Icon */ public ImageIcon icon() { --- 480,484 ---- /** ! * {@inheritDoc} */ public ImageIcon icon() { *************** *** 519,546 **** */ public void update(Object object) { ! if (object instanceof Collection) { ! content = (Collection) object; ! Set<Entity> elements = new HashSet<Entity>(); ! elements.addAll(content); ! Set<GenericNode> children = new HashSet<GenericNode>(); ! Enumeration enumeration = this.children(); ! while (enumeration.hasMoreElements()) { ! GenericNode node = (GenericNode)enumeration.nextElement(); ! Entity entity = (Entity)node.getUserObject(); ! if (elements.contains(entity)) { ! node.update(entity); ! elements.remove(entity); ! } else { ! children.add(node); ! } ! } ! if (elements.size() > 0) { ! this.insertChildren(elements); ! } ! if (children.size() > 0) { ! this.removeChildren(children); } ! } else { ! log.warn(userObject + " were called with " + object + " and not a collection"); } } --- 515,538 ---- */ public void update(Object object) { ! content = (Collection) object; ! Set<Entity> elements = new HashSet<Entity>(); ! elements.addAll(content); ! Set<GenericNode> children = new HashSet<GenericNode>(); ! Enumeration enumeration = this.children(); ! while (enumeration.hasMoreElements()) { ! GenericNode node = (GenericNode)enumeration.nextElement(); ! Entity entity = (Entity)node.getUserObject(); ! if (elements.contains(entity)) { ! node.update(entity); ! elements.remove(entity); ! } else { ! children.add(node); } ! } ! if (elements.size() > 0) { ! this.insertChildren(elements); ! } ! if (children.size() > 0) { ! this.removeChildren(children); } } *************** *** 558,566 **** int i = 0; for (Entity current : sorted) { - if (current == null) { - log.error("There is a consistency problem cause " + getUserObject() + - " hold null objects"); - continue; - } this.add(nodeFor(current)); ins[i] = this.getChildCount() - 1; --- 550,553 ---- *************** *** 640,644 **** } else { Set surfaces = space.getEnvelope(); ! add(new SurfaceContainer("Envelope", surfaces)); } } --- 627,631 ---- } else { Set surfaces = space.getEnvelope(); ! add(new SurfaceContainer("Envelope", surfaces, false)); } } *************** *** 650,657 **** private void makeContainerContent(Space space) { Set surfaces = space.getEnvelope(); ! add(new SurfaceContainer("Envelope", surfaces)); String lvlstr = Space.levelToString(space.getLevel() + 1); add(new ElementContainer(lvlstr + "s", space.getElements())); ! add(new GeometryContainer("Geometry", space)); ContainerNode cn = new ConstructorContainer("Constructors", space.getConstructors()); add(cn); --- 637,644 ---- private void makeContainerContent(Space space) { Set surfaces = space.getEnvelope(); ! add(new SurfaceContainer("Envelope", surfaces, false)); String lvlstr = Space.levelToString(space.getLevel() + 1); add(new ElementContainer(lvlstr + "s", space.getElements())); ! add(new GeometryNode("Geometry", space)); ContainerNode cn = new ConstructorContainer("Constructors", space.getConstructors()); add(cn); *************** *** 667,671 **** private void makeInstanceContent(Space space) { Set surfaces = space.getEnvelope(); ! add(new SurfaceContainer("Envelope", surfaces)); SpaceNode proto = new SpaceNode(space.getProto()); add(proto); --- 654,658 ---- private void makeInstanceContent(Space space) { Set surfaces = space.getEnvelope(); ! add(new SurfaceContainer("Envelope", surfaces, false)); SpaceNode proto = new SpaceNode(space.getProto()); add(proto); *************** *** 725,729 **** } else { removeAllChildren(); ! add(new SurfaceContainer("Surfaces", s.getEnvelope())); model.nodeStructureChanged(this); } --- 712,716 ---- } else { removeAllChildren(); ! add(new SurfaceContainer("Envelope", s.getEnvelope(), false)); model.nodeStructureChanged(this); } *************** *** 909,915 **** * @param name The name * @param surfaces The surfaces */ ! public SurfaceContainer(String name, Collection surfaces) { ! super(name, surfaces, true); insertChildren(surfaces); } --- 896,903 ---- * @param name The name * @param surfaces The surfaces + * @param sort boolean */ ! public SurfaceContainer(String name, Collection surfaces, boolean sort) { ! super(name, surfaces, sort); insertChildren(surfaces); } *************** *** 958,964 **** /** ! * Geometry Container */ ! public class GeometryContainer extends ContainerNode { /** * Constructor --- 946,952 ---- /** ! * Geometry Node */ ! public class GeometryNode extends GenericNode { /** * Constructor *************** *** 966,972 **** * @param space The space */ ! public GeometryContainer(String name, Space space) { ! super(name, null, false); ! add(new SurfaceContainer("Surfaces", space.getSurfaces())); add(new EdgeContainer("Edges", space.getEdges(), true)); add(new VertexContainer("Vertices", space.getVertices(), true)); --- 954,960 ---- * @param space The space */ ! public GeometryNode(String name, Space space) { ! super(name); ! add(new SurfaceContainer("Surfaces", space.getSurfaces(), true)); add(new EdgeContainer("Edges", space.getEdges(), true)); add(new VertexContainer("Vertices", space.getVertices(), true)); *************** *** 974,989 **** /** ! * Update the node with the given object ! * @param o The object */ public void update(Object o) { ! if (o instanceof Space) { ! Space s = (Space)o; ! ((SurfaceContainer)this.getChildAt(0)).update(s.getSurfaces()); ! ((EdgeContainer)this.getChildAt(1)).update(s.getEdges()); ! ((VertexContainer)this.getChildAt(2)).update(s.getVertices()); ! } else { ! log.warn("Expected a Space but found a " + o); ! } } } --- 962,979 ---- /** ! * {@inheritDoc} */ public void update(Object o) { ! Space space = (Space)o; ! updateChild(0, space.getSurfaces()); ! updateChild(1, space.getEdges()); ! updateChild(2, space.getVertices()); ! } ! ! /** ! * {@inheritDoc} ! */ ! public ImageIcon icon() { ! return genericgroupicon; } } *************** *** 1143,1146 **** --- 1133,1137 ---- public ComponentContainer(String name, Collection<Component> content) { super(name, content, false); + insertChildren(content); } *************** *** 1217,1221 **** public CameraNode(Camera c) { super(c, c.getClipplanes(), true); ! update(c); } --- 1208,1212 ---- public CameraNode(Camera c) { super(c, c.getClipplanes(), true); ! insertChildren(c.getClipplanes()); } *************** *** 1225,1237 **** */ public void update(Object o) { ! if (o instanceof Camera) { ! userObject = o; ! if (o == updated) { ! model.nodeChanged(this); ! } ! super.update(((Camera)o).getClipplanes()); ! } else { ! log.warn("Were a " + o + " not a Camera"); } } } --- 1216,1224 ---- */ public void update(Object o) { ! userObject = o; ! if (o == updated) { ! model.nodeChanged(this); } + super.update(((Camera)o).getClipplanes()); } } *************** *** 1338,1342 **** public ConstraintContainer(String name, Collection constraints) { super(name, constraints, true); ! update(constraints); } } --- 1325,1329 ---- public ConstraintContainer(String name, Collection constraints) { super(name, constraints, true); ! insertChildren(constraints); } } *************** *** 1353,1410 **** public RelationContainer(List<Relation> relations) { super("Relations", relations, true); ! update(relations); ! } ! } ! ! /** ! * TransformationContainer ! */ ! public class TransformationContainer extends ContainerNode { ! /** ! * Constructor for ConstraintContainer ! * @param name The name ! * @param transforms The constraints ! */ ! public TransformationContainer(String name, Stack transforms) { ! super(name, transforms, false); ! update(transforms); ! } ! ! /** ! * Update the node with the given object ! * @param o The object ! */ ! public void update(Object o) { ! if (o instanceof Stack) { ! content = (Stack) o; ! if (((Stack)o).size() != this.getChildCount()) { ! this.removeAllChildren(); ! LinkedList elem = new LinkedList(); ! Iterator iter = ((Stack)o).iterator(); ! while (iter.hasNext()) { ! elem.add(iter.next()); ! } ! this.insertChildren(elem); ! model.nodeStructureChanged(this); ! } ! } else { ! log.warn(userObject + " were called with " + o + " and not a list"); ! } ! } ! ! /** ! * Insert the given object into the node ! * @param elem the elements ! */ ! public void insertChildren(Collection elem) { ! int[] ins = new int[elem.size()]; ! int i = 0; ! Iterator iter = elem.iterator(); ! while (iter.hasNext()) { ! this.add(new EntityNode(iter.next())); ! ins[i] = this.getChildCount() - 1; ! i++; ! } ! model.nodesWereInserted(this, ins); } } --- 1340,1344 ---- public RelationContainer(List<Relation> relations) { super("Relations", relations, true); ! insertChildren(relations); } } Index: SpaceTreeView.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/treeview/SpaceTreeView.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** SpaceTreeView.java 19 Nov 2007 09:27:00 -0000 1.28 --- SpaceTreeView.java 10 Dec 2007 18:45:06 -0000 1.29 *************** *** 33,37 **** root.removeAllChildren(); root.add(new ProjectNode(p)); ! root.add(new GeometryContainer("Geometry", p.world())); root.add(new ConstraintContainer("Constraints", p.getConstraints())); root.add(new MaterialContainer("Materials", p.getMaterials(), true)); --- 33,37 ---- root.removeAllChildren(); root.add(new ProjectNode(p)); ! root.add(new GeometryNode("Geometry", p.world())); root.add(new ConstraintContainer("Constraints", p.getConstraints())); root.add(new MaterialContainer("Materials", p.getMaterials(), true)); *************** *** 48,51 **** --- 48,52 ---- */ public void update() { + long t0 = System.currentTimeMillis(); try { Project p = Project.getInstance(); *************** *** 61,64 **** --- 62,66 ---- "the root which resulted in a exception: " + e.getMessage()); } + long t1 = System.currentTimeMillis(); } } |