/[fenfire]/fenfire/org/fenfire/structure/Canvas2D.java
ViewVC logotype

Diff of /fenfire/org/fenfire/structure/Canvas2D.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by tjl, Thu Aug 21 18:31:02 2003 UTC revision 1.3 by tjl, Thu Aug 21 19:23:59 2003 UTC
# Line 16  public class Canvas2D { Line 16  public class Canvas2D {
16      ConstGraph constGraph;      ConstGraph constGraph;
17      Graph graph;      Graph graph;
18    
19      public Canvas2D(ConstGraph g) {      private Canvas2D(ConstGraph g) {
         if(g instanceof Graph)  
             this.graph = (Graph)g;  
20          this.constGraph = g;          this.constGraph = g;
21      }      }
22    
23        private Canvas2D(Graph g) {
24            this.graph = g;
25            this.constGraph = g;
26        }
27    
28        /** Copy the iterator into a set, then return an iterator
29         * into the set.
30         * XXX Generalize into utility routine
31         */
32        private Iterator copyIterator(Iterator it) {
33            Set s = new HashSet();
34            while(it.hasNext()) s.add(it.next());
35            return s.iterator();
36        }
37    
38        /** Create a new Canvas2D.
39         */
40        static public Canvas2D create(ConstGraph g) {
41            return new Canvas2D(g);
42        }
43        static public Canvas2D create(Graph g) {
44            return new Canvas2D(g);
45        }
46    
47    
48      /** Return true if the given node is a canvas.      /** Return true if the given node is a canvas.
49       */       */
50      public boolean isCanvas(Object node) {      public boolean isCanvas(Object node) {
# Line 79  public class Canvas2D { Line 102  public class Canvas2D {
102          graph.set1_11X(node, CANVAS2D.y, Nodes.getStringLiteral(""+y) );          graph.set1_11X(node, CANVAS2D.y, Nodes.getStringLiteral(""+y) );
103      }      }
104    
105        /** Remove the node from the canvas and remove the coordinates.
106         */
107        public void removeNode(Object node) {
108            Object canvas = graph.find1_X11(CANVAS2D.contains, node);
109            graph.rm_111(canvas, CANVAS2D.contains, node);
110        }
111    
112        /** Delete a canvas, and all nodes' placements within it.
113         */
114        public void deleteCanvas(Object canvas) {
115            Iterator it = copyIterator(getNodesOn(canvas));
116            while(it.hasNext())
117                removeNode(it.next());
118            graph.rm_111(canvas, RDF.type, CANVAS2D.Canvas);
119        }
120    
121    
122  }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26