From: parinda <par...@ya...> - 2003-11-26 17:32:39
|
Here is my simple application creating the graph from raphMLFile ************************************ package test.edu.uci.ics.jung.algorithms.cluster; import edu.uci.ics.jung.graph.Graph; import edu.uci.ics.jung.algorithms.cluster.BicomponentClusterer; import edu.uci.ics.jung.algorithms.cluster.ClusterSet; import edu.uci.ics.jung.io.GraphMLFile; import edu.uci.ics.jung.utils.StringInputStream; import javax.swing.JFrame; //import edu.uci.ics.jung.io.PajekNetFile; import edu.uci.ics.jung.visualization.GraphDraw; /** * @author Scott White */ public class TestBicomponentClusterer2 { public TestBicomponentClusterer2(){ } static GraphDraw gd;// Added by Parinda static Graph graph; //Added by Parinda public static void main(String[] args) { TestBicomponentClusterer2 t = new TestBicomponentClusterer2(); t.testExtract1(); } public static void testExtract1() { StringBuffer buffer= new StringBuffer(); buffer.append("<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n"); buffer.append("<graph edgedefault=\"undirected\">\n"); buffer.append("<node id=\"1\"/>\n"); buffer.append("<node id=\"2\"/>\n"); buffer.append("<node id=\"3\"/>\n"); buffer.append("<node id=\"4\"/>\n"); buffer.append("<node id=\"5\"/>\n"); buffer.append("<node id=\"6\"/>\n"); buffer.append("<edge source=\"1\" target=\"2\"/>\n"); buffer.append("<edge source=\"1\" target=\"6\"/>\n"); buffer.append("<edge source=\"1\" target=\"4\"/>\n"); buffer.append("<edge source=\"1\" target=\"5\"/>\n"); buffer.append("<edge source=\"2\" target=\"6\"/>\n"); buffer.append("<edge source=\"4\" target=\"5\"/>\n"); buffer.append("<edge source=\"3\" target=\"4\"/>\n"); buffer.append("</graph>\n"); GraphMLFile graphmlFile = new GraphMLFile(); // graph = graphmlFile.load(new StringInputStream(buffer.toString())); graph = graphmlFile.load("C:/graph library/jung/test/edu/uci/ics/jung/algorithms/cluster/datafile.graphml"); //BicomponentClusterer finder = new BicomponentClusterer(); //ClusterSet bicomponents = finder.extract(graph); //Assert.assertEquals(bicomponents.size(),2); JFrame jf = new JFrame(); gd = new GraphDraw(graph); jf.getContentPane().add(gd); jf.setDefaultCloseOperationJFrame.EXIT_ON_CLOSE); jf.pack(); jf.show(); } } *************************************** *************************************** here is the file datafile.graphml <?xml version="1.0" encoding="iso-8859-1" ?> <graph edgedefault="undirected"> <node id="1"/> <node id="2"/> <node id="3"/> <node id="4"/> <edge source="1" target="2"/> <edge source="1" target="3"/> <edge source="1" target="4"/> <edge source="4" target="2"/> </graph> *************************************** *************************************** and Here is the first part of error messages it gives: java.lang.NullPointerException at sun.awt.font.FontDesignMetrics.stringWidth(FontDesignMetrics.java:281 ) at edu.uci.ics.jung.visualization.graphdraw.SettableRenderer.paintVertex (SettableRenderer.java:238) at edu.uci.ics.jung.visualization.VisualizationViewer.paintComponent(Vis ualizationViewer.java:290) at javax.swing.JComponent.paint(JComponent.java:808) at javax.swing.JComponent.paintChildren(JComponent.java:647) at javax.swing.JComponent.paint(JComponent.java:817) at javax.swing.JComponent.paintChildren(JComponent.java:647) at javax.swing.JComponent.paint(JComponent.java:817) at javax.swing.JComponent.paintChildren(JComponent.java:647) at javax.swing.JComponent.paint(JComponent.java:817) at javax.swing.JLayeredPane.paint(JLayeredPane.java:557) at javax.swing.JComponent.paintChildren(JComponent.java:647) at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4794) at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4740) at javax.swing.JComponent.paint(JComponent.java:798) at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:21) at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java: 60) at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:97 ) at java.awt.Container.paint(Container.java:1312) at sun.awt.RepaintArea.paint(RepaintArea.java:177) at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:260) at java.awt.Component.dispatchEventImpl(Component.java:3678) at java.awt.Container.dispatchEventImpl(Container.java:1627) at java.awt.Window.dispatchEventImpl(Window.java:1606) at java.awt.Component.dispatchEvent(Component.java:3477) at java.awt.EventQueue.dispatchEvent(EventQueue.java:456) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh read.java:201) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre ad.java:151) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137) at java.awt.EventDispatchThread.run(EventDispatchThread.java:100) java.lang.NullPointerException at sun.awt.font.FontDesignMetrics.stringWidth(FontDesignMetrics.java:281 ) at edu.uci.ics.jung.visualization.graphdraw.SettableRenderer.paintVertex (SettableRenderer.java:238) at edu.uci.ics.jung.visualization.VisualizationViewer.paintComponent(Vis ualizationViewer.java:290) at javax.swing.JComponent.paint(JComponent.java:808) at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4787) at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4740) at javax.swing.JComponent._paintImmediately(JComponent.java:4685) at javax.swing.JComponent.paintImmediately(JComponent.java:4488) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410) at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(System EventQueueUtilities.java:117) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178) at java.awt.EventQueue.dispatchEvent(EventQueue.java:454) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh read.java:201) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre ad.java:151) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137) at java.awt.EventDispatchThread.run(EventDispatchThread.java:100) java.lang.NullPointerException at sun.awt.font.FontDesignMetrics.stringWidth(FontDesignMetrics.java:281 ) at edu.uci.ics.jung.visualization.graphdraw.SettableRenderer.paintVertex (SettableRenderer.java:238) at edu.uci.ics.jung.visualization.VisualizationViewer.paintComponent(Vis ualizationViewer.java:290) at javax.swing.JComponent.paint(JComponent.java:808) at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4787) at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4740) at javax.swing.JComponent._paintImmediately(JComponent.java:4685) at javax.swing.JComponent.paintImmediately(JComponent.java:4488) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410) at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(System EventQueueUtilities.java:117) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178) at java.awt.EventQueue.dispatchEvent(EventQueue.java:454) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh read.java:201) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre ad.java:151) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137) at java.awt.EventDispatchThread.run(EventDispatchThread.java:100) java.lang.NullPointerException at sun.awt.font.FontDesignMetrics.stringWidth(FontDesignMetrics.java:281 ) at edu.uci.ics.jung.visualization.graphdraw.SettableRenderer.paintVertex (SettableRenderer.java:238) at edu.uci.ics.jung.visualization.VisualizationViewer.paintComponent(Vis ualizationViewer.java:290) at javax.swing.JComponent.paint(JComponent.java:808) at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4787) at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4740) at javax.swing.JComponent._paintImmediately(JComponent.java:4685) at javax.swing.JComponent.paintImmediately(JComponent.java:4488) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410) at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(System EventQueueUtilities.java:117) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178) at java.awt.EventQueue.dispatchEvent(EventQueue.java:454) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh read.java:201) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre ad.java:151) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137) at java.awt.EventDispatchThread.run(EventDispatchThread.java:100) java.lang.NullPointerException at sun.awt.font.FontDesignMetrics.stringWidth(FontDesignMetrics.java:281 ) at edu.uci.ics.jung.visualization.graphdraw.SettableRenderer.paintVertex (SettableRenderer.java:238) at edu.uci.ics.jung.visualization.VisualizationViewer.paintComponent(Vis ualizationViewer.java:290) at javax.swing.JComponent.paint(JComponent.java:808) at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4787) at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4740) at javax.swing.JComponent._paintImmediately(JComponent.java:4685) at javax.swing.JComponent.paintImmediately(JComponent.java:4488) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410) at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(System EventQueueUtilities.java:117) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178) at java.awt.EventQueue.dispatchEvent(EventQueue.java:454) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh read.java:201) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre ad.java:151) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137) at java.awt.EventDispatchThread.run(EventDispatchThread.java:100) java.lang.NullPointerException at sun.awt.font.FontDesignMetrics.stringWidth(FontDesignMetrics.java:281 ) at edu.uci.ics.jung.visualization.graphdraw.SettableRenderer.paintVertex (SettableRenderer.java:238) at edu.uci.ics.jung.visualization.VisualizationViewer.paintComponent(Vis ualizationViewer.java:290) at javax.swing.JComponent.paint(JComponent.java:808) at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4787) --- Yan-Biao Boey <yb...@uc...> wrote: > Glad to hear that you got it running. You would have > to write you own > program to convert your database data to the Pajek > format in order to have > them read by JUNG. You can refer to the sample > graphs in samples.datasets > for the format. The Pajek files are all those with a > ".net" extension. > > The Pajek web page is at > http://vlado.fmf.uni-lj.si/pub/networks/pajek/. I > believe the manual has a good description of what a > Pajek file format > should look like. > > Biao > > > At 07:19 AM 11/25/2003, parinda wrote: > >Hey Bio, > >It's running now. It was my mistake. I was trying > >Samples.graph.SimpleGraphDraw but it should be > >"samples.graph.SimpleGraphDraw".Thanks for your > help. > >By the way I am very new to graph Drawing.In the > >documentation of JUNG they are saying that the > graph > >should be read from the PajekNetfile. Is there > anyway > >I can build a graph based on data in my database? > > > >===== > > > > > >__________________________________ > >Do you Yahoo!? > >Free Pop-Up Blocker - Get it now > >http://companion.yahoo.com/ > ===== __________________________________ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/ |