View Javadoc
1 /*** 2 * $Header: /cvsroot/ebxmlrr/jaxr/src/com/sun/xml/registry/client/browser/graph/JBGraphCell.java,v 1.12 2003/08/10 09:36:08 doballve 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 javax.swing.*; 17 18 import com.sun.xml.registry.client.browser.*; 19 20 /*** 21 * The model for a vertex in the JAXR Browser's Registry Object Graph. 22 * Each cell represents a RegistryObject in the graph. 23 * 24 * 25 * @author <a href="mailto:Farrukh.Najmi@Sun.COM">Farrukh S. Najmi</a> 26 */ 27 public class JBGraphCell extends DefaultGraphCell { 28 29 RegistryObject registryObject = null; 30 31 private JBGraphCell() { 32 } 33 34 public JBGraphCell(RegistryObject ro, boolean createIcon) { 35 super(getLabel(ro)); 36 //super((ro.getClass().getName()).substring((ro.getClass().getName()).lastIndexOf('.')+1, (ro.getClass().getName()).length()-4)); 37 38 String objectType = (ro.getClass().getName()).substring((ro.getClass().getName()).lastIndexOf('.')+1, (ro.getClass().getName()).length()-4); 39 try { 40 objectType = ro.getObjectType().getValue(); 41 } 42 catch (Exception e) { 43 //e.printStackTrace(); 44 } 45 46 this.registryObject = ro; 47 48 //Rectangle bounds = new Rectangle(50, 50); 49 //GraphConstants.setBounds(attributes, bounds); 50 GraphConstants.setOpaque(attributes, false); 51 GraphConstants.setBorderColor(attributes, Color.black); 52 GraphConstants.setAutoSize(attributes, true); 53 //GraphConstants.setBorder(attributes, BorderFactory.createRaisedBevelBorder()); 54 GraphConstants.setFontStyle(attributes, Font.BOLD); 55 56 /* 57 Color bg = Color.blue; 58 if (ro instanceof javax.xml.registry.infomodel.RegistryEntry) { 59 bg = Color.red; 60 } 61 62 GraphConstants.setBackground(attributes, bg.brighter()); 63 GraphConstants.setForeground(attributes, Color.white); 64 */ 65 66 // Create Ports 67 int u = GraphConstants.PERCENT; 68 69 // Floating Center Port (Child 0 is Default) 70 DefaultPort port = new DefaultPort("Center"); 71 add(port); 72 73 if (createIcon) { 74 ImageIcon icon = getIcon(objectType); 75 76 if (icon != null) { 77 GraphConstants.setIcon(attributes, (ImageIcon) icon); 78 } 79 } 80 81 } 82 83 private ImageIcon getIcon(String objectType) { 84 ImageIcon icon = null; 85 String resourceName = "icons/" + objectType + ".gif"; 86 URL url = this.getClass().getClassLoader().getResource(resourceName); 87 88 if (url != null) { 89 icon = new ImageIcon(url); 90 } 91 else { 92 if (!objectType.equals("ExtrinsicObject")) { 93 icon = getIcon("ExtrinsicObject"); 94 } 95 } 96 97 return icon; 98 } 99 100 private static String getLabel(RegistryObject ro) { 101 String label = ""; 102 103 try { 104 Connection connection = RegistryBrowser.getInstance().getClient().getConnection(); 105 RegistryService service = connection.getRegistryService(); 106 int registryLevel = service.getCapabilityProfile().getCapabilityLevel(); 107 108 if (ro != null) { 109 if (ro instanceof User) { 110 label = RegistryBrowser.getUserName((User)ro, registryLevel); 111 } 112 else { 113 label = RegistryBrowser.getName(ro); 114 } 115 116 if ((label == null) || (label.length() == 0)) { 117 if (ro instanceof Concept) { 118 label = ((Concept)ro).getValue(); 119 } 120 else if (ro instanceof Classification) { 121 label = ((Classification)ro).getValue(); 122 } 123 124 } 125 } 126 127 128 } 129 catch (JAXRException e) { 130 e.printStackTrace(); 131 } 132 133 return label; 134 } 135 136 137 RegistryObject getRegistryObject() { 138 return registryObject; 139 } 140 141 }

This page was automatically generated by Maven