View Javadoc
1 /*** 2 * $Header: /cvsroot/ebxmlrr/jaxr/src/com/sun/xml/registry/client/browser/graph/JBGraphPanel.java,v 1.1 2003/08/24 22:14:56 farrukh_najmi Exp $ 3 */ 4 package com.sun.xml.registry.client.browser.graph; 5 6 import com.jgraph.JGraph; 7 import com.jgraph.graph.*; 8 import com.jgraph.event.*; 9 10 import javax.xml.registry.*; 11 import javax.xml.registry.infomodel.*; 12 13 import java.util.*; 14 import java.net.*; 15 import java.awt.*; 16 import java.awt.event.*; 17 import javax.swing.*; 18 19 import com.sun.xml.registry.client.browser.*; 20 21 /*** 22 * Panel to show RegistryObjects as a Graph 23 * 24 * @author <a href="mailto:Farrukh.Najmi@Sun.COM">Farrukh S. Najmi</a> 25 */ 26 public class JBGraphPanel extends JBPanel { 27 28 // The width of this component in pixel 29 private static final int panelWidth = 1600; 30 31 // The height of this component in pixel 32 private static final int panelHeight = 2000; 33 34 public JBGraphPanel() { 35 setLayout(new BorderLayout()); 36 } 37 38 public static void browseObject(Window parent, RegistryObject ro, boolean editable) { 39 JBGraph graph = new JBGraph(new JBGraphModel()); 40 graph.addRegistryObject(ro, new Rectangle(200, 200, 50, 50), true); 41 JBEditorDialog dialog = JBEditorDialog.showObjectDetails(parent, graph, false, editable); 42 } 43 44 public static void browseObjects(Window parent, Collection objs, boolean editable) { 45 JBGraph graph = new JBGraph(new JBGraphModel()); 46 47 int x = 200; 48 int y = 200; 49 Iterator iter = objs.iterator(); 50 while (iter.hasNext()) { 51 RegistryObject ro = (RegistryObject)iter.next(); 52 x += 100; 53 y += 100; 54 graph.addRegistryObject(ro, new Rectangle(x, y, 50, 50), true); 55 } 56 57 JBGraph.circleLayout(graph); 58 59 JBEditorDialog dialog = JBEditorDialog.showObjectDetails(parent, graph, false, editable); 60 } 61 62 public void setModel(Object obj) throws JAXRException { 63 if (!(obj instanceof JBGraph)) { 64 throw new InvalidRequestException("Expecting a JBGRaph. Got a " + obj.getClass().getName()); 65 } 66 super.setModel(obj); 67 68 JBGraph graph = (JBGraph)obj; 69 JScrollPane graphSP = new JScrollPane(graph); //(new JGraph()); 70 71 // Construct Panel 72 // 73 // Add a ToolBar 74 add(graph.getToolBar(), BorderLayout.NORTH); 75 76 add(graphSP, BorderLayout.CENTER); 77 } 78 79 /*** 80 * Sets whether this dialog is read-only or editable. 81 */ 82 public void setEditable(boolean editable) { 83 ((JBGraph)model).setEditable(editable); 84 } 85 86 /*** 87 * Tells whether this dialog is read-only or editable. 88 */ 89 public boolean isEditable() { 90 return ((JBGraph)model).isEditable(); 91 } 92 }

This page was automatically generated by Maven