1
2
3
4
5
6
7 package com.vikash.firsttool.UI;
8 import org.jgraph.graph.*;
9 import java.util.*;
10 import java.awt.geom.*;
11 import java.awt.Color;
12
13 import com.vikash.firsttool.Diagram.ToolGraph;
14 import com.vikash.firsttool.ProfileImpl.*;
15 /***
16 *
17 * @author studajb
18 */
19 public class ToolGraphLayoutCache extends GraphLayoutCache{
20 Set localattributes=new HashSet();
21 ToolGraph graph;
22 /*** Creates a new instance of ToolGraphLayoutCache */
23 public ToolGraphLayoutCache(GraphModel model,CellViewFactory factory,boolean partial,ToolGraph graph) {
24 super(model,factory,partial);
25 this.graph=graph;
26 localattributes.add(GraphConstants.BACKGROUND);
27 localattributes.add(GraphConstants.BORDERCOLOR);
28 localattributes.add(GraphConstants.BORDER);
29 localattributes.add(GraphConstants.FONT);
30 localattributes.add(GraphConstants.LINECOLOR);
31 localattributes.add(GraphConstants.BOUNDS);
32 localattributes.add(GraphConstants.SIZE);
33 localattributes.add(GraphConstants.POINTS);
34 localattributes.add(GraphConstants.ROUTING);
35 this.setLocalAttributes(localattributes);
36
37 }
38 public void cellVisible(Object cell, boolean visible,Rectangle2D bounds) {
39 DefaultGraphCell node=(DefaultGraphCell)cell;
40 org.jgraph.graph.AttributeMap map=node.getAttributes();
41
42 int x=(int)bounds.getX();
43 int y=(int)bounds.getY();
44
45 int width=(int)bounds.getWidth();
46 int height=(int)bounds.getHeight();
47 if (node instanceof RectangleGraphCell) {
48 if(width==0 || height==0)
49 GraphConstants.setBounds(map,new Rectangle2D.Double(x,y,150,80));
50 else
51 GraphConstants.setBounds(map,new Rectangle2D.Double(x,y,width,height));
52
53 GraphConstants.setBorderColor(map, Color.black);
54
55 }
56 else if (node instanceof EllipseCell) {
57 if(width==0 || height==0)
58 GraphConstants.setBounds(map, new Rectangle2D.Double(x,y,150,80));
59 else
60 GraphConstants.setBounds(map,new Rectangle2D.Double(x,y,width,height));
61
62 GraphConstants.setBorderColor(map, Color.black);
63
64 }
65 else if (node instanceof IconGraphCell) {
66 if(width==0 || height==0)
67 GraphConstants.setBounds(map,new Rectangle2D.Double(x,y,150,150));
68 else
69 GraphConstants.setBounds(map,new Rectangle2D.Double(x,y,width,height));
70
71 }
72
73 this.editCell(node, map);
74 super.setVisible(cell, visible);
75
76 }
77
78
79
80 }