Thread: [graphl-cvs] graphl/src/org/mediavirus/graphl GraphlApplication.java GraphlPane.java GraphlApplet.ja
Status: Pre-Alpha
Brought to you by:
flo1
From: Flo L. <fl...@us...> - 2004-10-14 13:03:51
|
Update of /cvsroot/graphl/graphl/src/org/mediavirus/graphl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12051/src/org/mediavirus/graphl Modified Files: GraphlApplication.java GraphlPane.java GraphlApplet.java GraphlPanel.java Log Message: - FEATURE: added z-index support for painting nodes & edges - FEATURE: BoxNodePainter draws rounded rectangles - FEATURE: Font for boxnodepainter is configurable - FEATURE: labelcolor of edgepainter is configurable - FEATURE: added utility functions for namespace compression/expansion - REFACTOR: moved layouter to graphpane - BUG: removed value property from graphelements - BUG: stopping layouter when displaying contextmenus etc. - BUG: fixed panning after startup - removed obsolete commented-out code Index: GraphlPanel.java =================================================================== RCS file: /cvsroot/graphl/graphl/src/org/mediavirus/graphl/GraphlPanel.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** GraphlPanel.java 4 Oct 2004 10:21:04 -0000 1.14 --- GraphlPanel.java 14 Oct 2004 13:03:04 -0000 1.15 *************** *** 27,32 **** import org.mediavirus.graphl.gui.GenericDialog; import org.mediavirus.graphl.interaction.GraphlManipulator; - import org.mediavirus.graphl.layout.GraphlLayoutStrategy; - import org.mediavirus.graphl.layout.Layouter; import org.mediavirus.graphl.painter.EdgePainter; import org.mediavirus.graphl.painter.NodePainter; --- 27,30 ---- *************** *** 53,58 **** JCheckBox layoutBox; - Layouter layouter; - private JSlider zoomSlider; private JComboBox nodePainterMenu; --- 51,54 ---- *************** *** 65,73 **** private JButton edgePainterConfigureButton = null; private JButton jButton = null; public GraphlPanel(){ initialize(); - - layouter = new Layouter(new GraphlLayoutStrategy(graphPane.getGraph(), graphPane.getFacetRegistry())); - layouter.start(); } --- 61,67 ---- private JButton edgePainterConfigureButton = null; private JButton jButton = null; + public GraphlPanel(){ initialize(); } *************** *** 80,83 **** --- 74,79 ---- add(getTopPanel(), BorderLayout.NORTH); + getTopPanel().setVisible(false); + } *************** *** 204,211 **** public void actionPerformed(ActionEvent e) { if (layoutBox.isSelected()) { ! layouter.start(); } else { ! layouter.stop(); } } --- 200,207 ---- public void actionPerformed(ActionEvent e) { if (layoutBox.isSelected()) { ! graphPane.startLayouter(); } else { ! graphPane.stopLayouter(); } } *************** *** 219,223 **** } ! private GraphlPane getGraphPane() { if (graphPane == null) { graphPane = new GraphlPane(); --- 215,219 ---- } ! public GraphlPane getGraphPane() { if (graphPane == null) { graphPane = new GraphlPane(); *************** *** 295,299 **** return edgePainterMenu; } ! public boolean nodeRemove(Node n) { return true; --- 291,295 ---- return edgePainterMenu; } ! public boolean nodeRemove(Node n) { return true; *************** *** 308,324 **** } - public void stopLayout() { - layouter.stop(); - } - - public void resumeLayout(){ - if (layoutBox.isSelected()) { - layouter.start(); - } - else { - layouter.stop(); - } - } - public RDFGraph getGraph() { return (RDFGraph) graphPane.getGraph(); --- 304,307 ---- Index: GraphlApplet.java =================================================================== RCS file: /cvsroot/graphl/graphl/src/org/mediavirus/graphl/GraphlApplet.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** GraphlApplet.java 4 Oct 2004 10:21:03 -0000 1.7 --- GraphlApplet.java 14 Oct 2004 13:03:04 -0000 1.8 *************** *** 206,210 **** super.start(); ! mainPanel.resumeLayout(); } --- 206,210 ---- super.start(); ! mainPanel.getGraphPane().resumeLayouter(); } *************** *** 215,219 **** super.stop(); ! mainPanel.stopLayout(); } --- 215,219 ---- super.stop(); ! mainPanel.getGraphPane().stopLayouter(); } Index: GraphlApplication.java =================================================================== RCS file: /cvsroot/graphl/graphl/src/org/mediavirus/graphl/GraphlApplication.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** GraphlApplication.java 5 Oct 2004 07:54:20 -0000 1.9 --- GraphlApplication.java 14 Oct 2004 13:03:04 -0000 1.10 *************** *** 46,49 **** --- 46,51 ---- */ public class GraphlApplication extends JFrame { + + public static final String DEFAULT_FILE = null; GraphlPanel mainPanel; *************** *** 252,256 **** } ! mainPanel.stopLayout(); mainPanel.getGraph().clear(); mainPanel.getGraph().resetDirty(); --- 254,258 ---- } ! mainPanel.getGraphPane().pauseLayouter(); mainPanel.getGraph().clear(); mainPanel.getGraph().resetDirty(); *************** *** 259,263 **** setTitle("Graphl - untitled"); ! mainPanel.resumeLayout(); } /** --- 261,265 ---- setTitle("Graphl - untitled"); ! mainPanel.getGraphPane().resumeLayouter(); } /** *************** *** 355,377 **** if (option == JFileChooser.APPROVE_OPTION) { - if (chooser.getSelectedFile() != null){ - currentFile = chooser.getSelectedFile(); - } - - mainPanel.stopLayout(); ! mainPanel.getGraph().clear(); ! try { ! mainPanel.getGraph().readFromFile(chooser.getSelectedFile().getAbsolutePath()); ! setTitle("Graphl - " + chooser.getSelectedFile().getName()); ! } catch (IOException ioex) { ioex.printStackTrace(); JOptionPane.showMessageDialog(this, "Error while loading file:\n" + ioex.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } ! finally { ! mainPanel.resumeLayout(); ! } } } --- 357,388 ---- if (option == JFileChooser.APPROVE_OPTION) { ! try { ! loadFile(chooser.getSelectedFile()); ! } catch (IOException ioex) { ioex.printStackTrace(); JOptionPane.showMessageDialog(this, "Error while loading file:\n" + ioex.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } ! ! } ! } ! ! public void loadFile(File f) throws IOException { ! try { ! if (f != null){ ! ! mainPanel.getGraphPane().pauseLayouter(); ! mainPanel.getGraph().clear(); ! ! mainPanel.getGraph().readFromFile(f.getAbsolutePath()); ! setTitle("Graphl - " + f.getName()); ! currentFile = f; ! } } + finally { + mainPanel.getGraphPane().resumeLayouter(); + } + } *************** *** 399,403 **** int[] pos = {0,0}; boolean decorations = true; ! String filename = System.getProperty("user.dir") + "/graphs/default.rdf"; String configfile = System.getProperty("user.dir") + "/config/config.rdf"; --- 410,414 ---- int[] pos = {0,0}; boolean decorations = true; ! String filename = System.getProperty("user.dir") + DEFAULT_FILE; String configfile = System.getProperty("user.dir") + "/config/config.rdf"; *************** *** 433,438 **** try { app.loadSettings(configfile); ! app.mainPanel.getGraph().readFromFile(filename); ! app.setTitle("Graphl - default.rdf"); } catch (IOException ioex) { --- 444,450 ---- try { app.loadSettings(configfile); ! if (filename != null) { ! app.loadFile(new File(filename)); ! } } catch (IOException ioex) { *************** *** 449,453 **** System.out.println("usage:"); System.out.println("graphl [size=<width>,<height>] [pos=<x>,<y>] [decorations={on|off}]\n" + ! " [settings=<filename.rdf>] [<filename.rdf>]"); System.out.println("-------------------------------------------------------------------"); if (exit) System.exit(0); --- 461,465 ---- System.out.println("usage:"); System.out.println("graphl [size=<width>,<height>] [pos=<x>,<y>] [decorations={on|off}]\n" + ! " [config=<filename.rdf>] [<filename.rdf>]"); System.out.println("-------------------------------------------------------------------"); if (exit) System.exit(0); Index: GraphlPane.java =================================================================== RCS file: /cvsroot/graphl/graphl/src/org/mediavirus/graphl/GraphlPane.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** GraphlPane.java 4 Oct 2004 10:21:03 -0000 1.12 --- GraphlPane.java 14 Oct 2004 13:03:04 -0000 1.13 *************** *** 40,57 **** import org.mediavirus.graphl.graph.rdf.RDFGraph; import org.mediavirus.graphl.interaction.Manipulator; ! import org.mediavirus.graphl.layout.AbsoluteNodeLayouter; ! import org.mediavirus.graphl.layout.NeutralEdgeLayouter; ! import org.mediavirus.graphl.layout.RepulsionNodeLayouter; ! import org.mediavirus.graphl.layout.SortedNodeLayouter; ! import org.mediavirus.graphl.layout.SpringEdgeLayouter; ! import org.mediavirus.graphl.layout.UnconstrainedNodeLayouter; ! import org.mediavirus.graphl.painter.BoxNodePainter; import org.mediavirus.graphl.painter.EdgePainter; - import org.mediavirus.graphl.painter.ImageNodePainter; - import org.mediavirus.graphl.painter.InvisibleEdgePainter; - import org.mediavirus.graphl.painter.InvisibleNodePainter; - import org.mediavirus.graphl.painter.ManhattanEdgePainter; import org.mediavirus.graphl.painter.NodePainter; - import org.mediavirus.graphl.painter.StraightLineEdgePainter; import org.mediavirus.graphl.selection.DefaultSelectionModel; import org.mediavirus.graphl.selection.SelectionModel; --- 40,47 ---- import org.mediavirus.graphl.graph.rdf.RDFGraph; import org.mediavirus.graphl.interaction.Manipulator; ! import org.mediavirus.graphl.layout.GraphlLayoutStrategy; ! import org.mediavirus.graphl.layout.Layouter; import org.mediavirus.graphl.painter.EdgePainter; import org.mediavirus.graphl.painter.NodePainter; import org.mediavirus.graphl.selection.DefaultSelectionModel; import org.mediavirus.graphl.selection.SelectionModel; *************** *** 71,78 **** private boolean autoRegisterTypes = true; AffineTransform transform = null; AffineTransform translationXF = null; AffineTransform scaleXF = null; ! private Point2D.Double translationPoint; FacetRegistry facetRegistry = new SimpleFacetRegistry(); --- 61,70 ---- private boolean autoRegisterTypes = true; + Layouter layouter; + AffineTransform transform = null; AffineTransform translationXF = null; AffineTransform scaleXF = null; ! private Point2D translationPoint = new Point2D.Double(0,0); FacetRegistry facetRegistry = new SimpleFacetRegistry(); *************** *** 82,86 **** protected Graph graph; /** The listener for the graph. */ ! protected GraphListener graphListner; /** The map of node positions. */ protected Map nodePositions; --- 74,78 ---- protected Graph graph; /** The listener for the graph. */ ! protected GraphListener graphListener; /** The map of node positions. */ protected Map nodePositions; *************** *** 89,96 **** /** The map of rigestered manipulators keyed by their name. */ protected Map manipulatorsByName; - private NodePainter defaultNodePainter; protected SelectionModel selection; /** * Creates a graph pane. --- 81,89 ---- /** The map of rigestered manipulators keyed by their name. */ protected Map manipulatorsByName; protected SelectionModel selection; + private boolean layouterRunning; + /** * Creates a graph pane. *************** *** 100,104 **** public GraphlPane(Graph graph) { super(null); ! graphListner=new GraphHandler(); nodePositions=new HashMap(); manipulators=new ArrayList(); --- 93,97 ---- public GraphlPane(Graph graph) { super(null); ! graphListener=new GraphHandler(); nodePositions=new HashMap(); manipulators=new ArrayList(); *************** *** 108,112 **** setBackground(Color.white); ToolTipManager.sharedInstance().registerComponent(this); - defaultNodePainter = new BoxNodePainter(); updateTransform(); --- 101,104 ---- *************** *** 114,119 **** graph.addGraphListener(this); ! setupDefaultPainters(); ! } public GraphlPane() { --- 106,113 ---- graph.addGraphListener(this); ! layouter = new Layouter(new GraphlLayoutStrategy(getGraph(), getFacetRegistry())); ! startLayouter(); ! //setupDefaultPainters(); ! } public GraphlPane() { *************** *** 145,174 **** */ ! private void setupDefaultPainters() { ! ! // register the available painter classes (for user selection) ! facetRegistry.registerEdgePainter(new StraightLineEdgePainter()); ! facetRegistry.registerEdgePainter(new ManhattanEdgePainter()); ! facetRegistry.registerEdgePainter(new InvisibleEdgePainter()); ! ! facetRegistry.registerNodePainter(new BoxNodePainter()); ! facetRegistry.registerNodePainter(new ImageNodePainter()); ! facetRegistry.registerNodePainter(new InvisibleNodePainter()); ! ! facetRegistry.registerEdgeLayouter(new SpringEdgeLayouter()); ! facetRegistry.registerEdgeLayouter(new NeutralEdgeLayouter()); ! ! facetRegistry.registerNodeLayouter(new UnconstrainedNodeLayouter()); ! facetRegistry.registerNodeLayouter(new RepulsionNodeLayouter()); ! facetRegistry.registerNodeLayouter(new AbsoluteNodeLayouter()); ! facetRegistry.registerNodeLayouter(new SortedNodeLayouter()); ! ! // set default painters ! facetRegistry.setDefaultEdgePainter(new StraightLineEdgePainter()); ! facetRegistry.setDefaultNodePainter(new BoxNodePainter()); ! facetRegistry.setDefaultEdgeLayouter(new SpringEdgeLayouter()); ! facetRegistry.setDefaultNodeLayouter(new RepulsionNodeLayouter()); ! ! } private void updateTransform() { --- 139,168 ---- */ ! // private void setupDefaultPainters() { ! // ! // // register the available painter classes (for user selection) ! // facetRegistry.registerEdgePainter(new StraightLineEdgePainter()); ! // facetRegistry.registerEdgePainter(new ManhattanEdgePainter()); ! // facetRegistry.registerEdgePainter(new InvisibleEdgePainter()); ! // ! // facetRegistry.registerNodePainter(new BoxNodePainter()); ! // facetRegistry.registerNodePainter(new ImageNodePainter()); ! // facetRegistry.registerNodePainter(new InvisibleNodePainter()); ! // ! // facetRegistry.registerEdgeLayouter(new SpringEdgeLayouter()); ! // facetRegistry.registerEdgeLayouter(new NeutralEdgeLayouter()); ! // ! // facetRegistry.registerNodeLayouter(new UnconstrainedNodeLayouter()); ! // facetRegistry.registerNodeLayouter(new RepulsionNodeLayouter()); ! // facetRegistry.registerNodeLayouter(new AbsoluteNodeLayouter()); ! // facetRegistry.registerNodeLayouter(new SortedNodeLayouter()); ! // ! // // set default painters ! // facetRegistry.setDefaultEdgePainter(new StraightLineEdgePainter()); ! // facetRegistry.setDefaultNodePainter(new BoxNodePainter()); ! // facetRegistry.setDefaultEdgeLayouter(new SpringEdgeLayouter()); ! // facetRegistry.setDefaultNodeLayouter(new RepulsionNodeLayouter()); ! // ! // } private void updateTransform() { *************** *** 206,229 **** if (graph!=null) synchronized (graph) { Rectangle bounds=new Rectangle(); ! long edgesStart=System.currentTimeMillis(); ! Iterator iterator=graph.getEdges().iterator(); ! while (iterator.hasNext()) { ! Edge edge=(Edge)iterator.next(); ! getEdgeScreenBounds(edge,bounds); ! if (clipRectangle.intersects(bounds)) ! paintEdge(g2,edge); ! } ! long edgesDur=System.currentTimeMillis()-edgesStart; ! long nodesStart=System.currentTimeMillis(); ! iterator=graph.getNodes().iterator(); ! while (iterator.hasNext()) { ! Node node=(Node)iterator.next(); ! getNodeScreenBounds(node,bounds); ! if (clipRectangle.intersects(bounds)) ! paintNode(g2,node); } for (int i=0;i<manipulators.size();i++) ((Manipulator)manipulators.get(i)).paint(g2); } } --- 200,245 ---- if (graph!=null) synchronized (graph) { + // this is the main rendering loop + //TODO (2, 1h) we have to store zMin somewhere (GraphView?) and get it here to save 1 loop + int nextZ = 0, curZ = 0; Rectangle bounds=new Rectangle(); ! Iterator iterator; ! long renderStartTime=System.currentTimeMillis(); ! while (nextZ < Integer.MAX_VALUE) { ! curZ = nextZ; ! nextZ = Integer.MAX_VALUE; ! iterator=graph.getEdges().iterator(); ! while (iterator.hasNext()) { ! Edge edge=(Edge)iterator.next(); ! int z = edge.getZIndex(); ! if (z == curZ) { ! getEdgeScreenBounds(edge,bounds); ! if (clipRectangle.intersects(bounds)) { ! paintEdge(g2,edge); ! } ! } ! else if (z>curZ && z<nextZ){ ! nextZ = z; ! } ! } ! iterator=graph.getNodes().iterator(); ! while (iterator.hasNext()) { ! Node node=(Node)iterator.next(); ! int z = node.getZIndex(); ! if (z == curZ) { ! getNodeScreenBounds(node,bounds); ! if (clipRectangle.intersects(bounds)) { ! paintNode(g2,node); ! } ! } ! else if (z>curZ && z<nextZ){ ! nextZ = z; ! } ! } ! // System.out.println("curZ: " + curZ + " nextZ: " + nextZ + " dur: " + (System.currentTimeMillis()-renderStartTime)); } for (int i=0;i<manipulators.size();i++) ((Manipulator)manipulators.get(i)).paint(g2); + //long renderDuration = System.currentTimeMillis()-renderStartTime; } } *************** *** 402,409 **** Graph oldGraph = this.graph; if (this.graph!=null) ! this.graph.removeGraphListener(graphListner); this.graph=graph; if (this.graph!=null) ! this.graph.addGraphListener(graphListner); nodePositions.clear(); repaint(); --- 418,425 ---- Graph oldGraph = this.graph; if (this.graph!=null) ! this.graph.removeGraphListener(graphListener); this.graph=graph; if (this.graph!=null) ! this.graph.addGraphListener(graphListener); nodePositions.clear(); repaint(); *************** *** 437,447 **** /** - * @return - */ - private NodePainter getDefaultNodePainter() { - return defaultNodePainter; - } - - /** * Returns the node at given point, or <code>null</code> if there is no such node. * --- 453,456 ---- *************** *** 778,780 **** --- 787,825 ---- } + /** + * @return Returns the layouter. + */ + public Layouter getLayouter() { + return layouter; + } + + public void startLayouter() { + if (layouter != null) { + layouter.start(); + layouterRunning = true; + } + } + + public void stopLayouter() { + if (layouter != null) { + layouter.stop(); + layouterRunning = false; + } + } + + public void pauseLayouter() { + if (layouterRunning && layouter != null) { + layouter.stop(); + } + } + + public void resumeLayouter() { + if (layouterRunning && layouter != null) { + layouter.start(); + } + } + + public boolean isLayouterRunning() { + return layouterRunning; + } } |
From: Flo L. <fl...@us...> - 2005-08-17 15:53:32
|
Update of /cvsroot/graphl/graphl/src/org/mediavirus/graphl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16461/src/org/mediavirus/graphl Modified Files: GraphlApplication.java GraphlPane.java GraphlApplet.java GraphlPanel.java Log Message: - FEATURE: added navigator thread for update-exhibition, disabled in normal operation - FEATURE: started implementation of filtering architecture - FEATURE: creating new node opens type context menu - CODE: added NS calss for easier namespace referencing in code Index: GraphlPanel.java =================================================================== RCS file: /cvsroot/graphl/graphl/src/org/mediavirus/graphl/GraphlPanel.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** GraphlPanel.java 11 Jan 2005 13:26:43 -0000 1.22 --- GraphlPanel.java 17 Aug 2005 15:52:51 -0000 1.23 *************** *** 25,28 **** --- 25,29 ---- import org.mediavirus.graphl.graph.*; + import org.mediavirus.graphl.graph.filter.FilteredGraph; import org.mediavirus.graphl.graph.rdf.RDFGraph; import org.mediavirus.graphl.interaction.DefaultNodeManipulator; *************** *** 43,46 **** --- 44,48 ---- GraphlPane graphPane; GraphlManipulator gui; + Graph graph; JCheckBox layoutBox; *************** *** 54,57 **** --- 56,65 ---- public GraphlPanel(){ + graph = new RDFGraph(); + initialize(); + } + + public GraphlPanel(Graph graph) { + this.graph = graph; initialize(); } *************** *** 192,196 **** public GraphlPane getGraphPane() { if (graphPane == null) { ! graphPane = new GraphlPane(); graphPane.setEnabled(true); graphPane.addManipulator(new GraphlManipulator()); --- 200,204 ---- public GraphlPane getGraphPane() { if (graphPane == null) { ! graphPane = new GraphlPane(graph); graphPane.setEnabled(true); graphPane.addManipulator(new GraphlManipulator()); *************** *** 235,240 **** } public RDFGraph getGraph() { ! return (RDFGraph) graphPane.getGraph(); } --- 243,249 ---- } + // TODO (1) fix access and casting public RDFGraph getGraph() { ! return (RDFGraph)((FilteredGraph) graphPane.getGraph()).getSource(); } Index: GraphlApplet.java =================================================================== RCS file: /cvsroot/graphl/graphl/src/org/mediavirus/graphl/GraphlApplet.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** GraphlApplet.java 29 Dec 2004 14:31:33 -0000 1.9 --- GraphlApplet.java 17 Aug 2005 15:52:51 -0000 1.10 *************** *** 26,29 **** --- 26,30 ---- import org.mediavirus.graphl.graph.Node; import org.mediavirus.graphl.graph.rdf.RDFGraph; + import org.mediavirus.graphl.vocabulary.NS; *************** *** 134,138 **** for (Iterator settings = mainPanel.graphPane.getConfigurations().iterator(); settings.hasNext();) { Node node = (Node) settings.next(); ! if ((i == 0) || node.getProperty("http://www.mediavirus.org/graphl#default","").equalsIgnoreCase("true")) { defaultSettings = node; } --- 135,139 ---- for (Iterator settings = mainPanel.graphPane.getConfigurations().iterator(); settings.hasNext();) { Node node = (Node) settings.next(); ! if ((i == 0) || node.getProperty(NS.graphl + "default","").equalsIgnoreCase("true")) { defaultSettings = node; } Index: GraphlApplication.java =================================================================== RCS file: /cvsroot/graphl/graphl/src/org/mediavirus/graphl/GraphlApplication.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** GraphlApplication.java 11 Jan 2005 13:26:43 -0000 1.18 --- GraphlApplication.java 17 Aug 2005 15:52:51 -0000 1.19 *************** *** 12,15 **** --- 12,16 ---- import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; + import java.awt.geom.Point2D; import java.io.File; import java.io.FileOutputStream; *************** *** 17,21 **** --- 18,24 ---- import java.net.MalformedURLException; import java.net.URL; + import java.util.ArrayList; import java.util.Iterator; + import java.util.List; import javax.swing.ButtonGroup; *************** *** 30,33 **** --- 33,38 ---- import org.mediavirus.graphl.graph.Node; + import org.mediavirus.graphl.graph.filter.FilteredGraph; + import org.mediavirus.graphl.graph.filter.TestFilter; import org.mediavirus.graphl.graph.rdf.RDFGraph; import org.mediavirus.graphl.gui.GenericDialog; *************** *** 37,40 **** --- 42,46 ---- import org.mediavirus.graphl.vocabulary.FOAF; import org.mediavirus.graphl.vocabulary.Graphl; + import org.mediavirus.graphl.vocabulary.NS; import org.mediavirus.graphl.vocabulary.RDF; import org.mediavirus.graphl.vocabulary.RDFS; *************** *** 90,94 **** }); ! mainPanel = new GraphlPanel(); this.getContentPane().setLayout(new BorderLayout()); --- 96,102 ---- }); ! FilteredGraph fgraph = new FilteredGraph(new RDFGraph()); ! fgraph.addFilter(new TestFilter()); ! mainPanel = new GraphlPanel(fgraph); this.getContentPane().setLayout(new BorderLayout()); *************** *** 440,444 **** } ! protected class SettingsAdapter implements ActionListener { private Node node; --- 448,452 ---- } ! protected class SettingsAdapter implements ActionListener { private Node node; *************** *** 472,476 **** public void loadSettings(String filename) throws IOException { ! RDFGraph settingsGraph = new RDFGraph(); settingsGraph.readFromFile(filename); mainPanel.graphPane.setConfigurationGraph(settingsGraph); --- 480,485 ---- public void loadSettings(String filename) throws IOException { ! // TODO (1) fix this to properly access graph. think about GraphlPanel vs. GraphlApplication features ! RDFGraph settingsGraph = (RDFGraph)((FilteredGraph)mainPanel.graphPane.getGraph()).getSource(); settingsGraph.readFromFile(filename); mainPanel.graphPane.setConfigurationGraph(settingsGraph); *************** *** 483,496 **** for (Iterator settings = mainPanel.graphPane.getConfigurations().iterator(); settings.hasNext();) { Node node = (Node) settings.next(); ! JRadioButtonMenuItem item = new JRadioButtonMenuItem(node.getProperty("http://www.mediavirus.org/graphl#name","<unnamed>")); ! item.addActionListener(new SettingsAdapter(node)); ! item.setFont(menuFont); ! configConfigurationMenu.add(item); ! settingsGroup.add(item); ! if ((i == 0) || node.getProperty("http://www.mediavirus.org/graphl#default","").equalsIgnoreCase("true")) { ! defaultItem = item; ! defaultSettings = node; ! } ! i++; } --- 492,507 ---- for (Iterator settings = mainPanel.graphPane.getConfigurations().iterator(); settings.hasNext();) { Node node = (Node) settings.next(); ! if (! node.getProperty(NS.graphl + "public","true").equalsIgnoreCase("false")){ ! JRadioButtonMenuItem item = new JRadioButtonMenuItem(node.getProperty(NS.graphl + "name","<unnamed>")); ! item.addActionListener(new SettingsAdapter(node)); ! item.setFont(menuFont); ! configConfigurationMenu.add(item); ! settingsGroup.add(item); ! if ((i == 0) || node.getProperty(NS.graphl + "default","").equalsIgnoreCase("true")) { ! defaultItem = item; ! defaultSettings = node; ! } ! i++; ! } } *************** *** 583,586 **** --- 594,599 ---- app.scheduleRefresh(refresh * 1000); } + + //app.startNavigator(); } } *************** *** 591,594 **** --- 604,697 ---- /** + * + */ + private void startNavigator() { + Thread navigator = new Thread(){ + int counter = 0; + int zoomValue = 26; + int zoomStart = 25; + int zoomInc = 0; + + double tX=0, tY=0; + + long starttime = 0; + + List persons = new ArrayList(200); + + public void run() { + try { + List nodes = mainPanel.graphPane.graph.getNodes(); + for (Iterator iter = nodes.iterator(); iter.hasNext();) { + Node node = (Node) iter.next(); + if (("http://xmlns.com/foaf/0.1/Person".equals(node.getType()))) { + persons.add(node); + } + } + while(true) { + counter++; + + if (zoomValue >= 80) zoomInc = 0; + if (zoomValue <= 25) zoomInc = 0; + if (zoomInc != 0) { + zoomValue = zoomStart + (int)(((System.currentTimeMillis()-starttime) / 400.0) * zoomInc); + } + mainPanel.getZoomSlider().setValue(zoomValue); + Point2D pos = mainPanel.graphPane.getTranslation(); + mainPanel.graphPane.setTranslation((pos.getX()+(tX*((zoomValue-25)/55.0)-pos.getX())/30), (pos.getY()+(tY*((zoomValue-25)/55.0)-pos.getY())/30)); + + if (counter == 36000) System.exit(0); + + if ((counter % 400 == 150) || (counter % 400 == 230) || (counter % 400 == 310)) { + Node p = (Node)persons.get((int)(Math.random() * persons.size())); + //System.out.println(p.getProperty("http://xmlns.com/foaf/0.1/name","<null>")); + tX = -p.getCenterX(); + tY = -p.getCenterY(); + } + if (counter % 400 == 150) { + starttime = System.currentTimeMillis(); + zoomValue = 26; + zoomStart = 26; + zoomInc = 2; + } + if (counter % 400 == 0) { + starttime = System.currentTimeMillis(); + zoomValue = 79; + zoomStart = 79; + zoomInc = -4; + } + if ((counter > 30 ) && (counter % 400 == 30)) { + Node first = null; + for (Iterator settings = mainPanel.graphPane.getConfigurations().iterator(); settings.hasNext();) { + Node node = (Node) settings.next(); + if (! node.getProperty(NS.graphl + "public","true").equalsIgnoreCase("false")){ + if (first == null) first = node; + if (node.getProperty(NS.graphl + "active","").equalsIgnoreCase("true")) { + if (settings.hasNext()) { + node = (Node) settings.next(); + } + else { + node = first; + } + if (node != null) { + mainPanel.graphPane.setConfiguration(node); + break; + } + } + } + } + } + sleep(200); + } + } + catch (InterruptedException iex) { + System.out.println("navigator: interrupted"); + } + } + }; + navigator.start(); + + } + + /** * Controls the visibility of the menu bar. * @param visible The new visibility setting. Index: GraphlPane.java =================================================================== RCS file: /cvsroot/graphl/graphl/src/org/mediavirus/graphl/GraphlPane.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** GraphlPane.java 11 Jan 2005 13:26:43 -0000 1.18 --- GraphlPane.java 17 Aug 2005 15:52:51 -0000 1.19 *************** *** 47,50 **** --- 47,51 ---- import org.mediavirus.graphl.view.GraphFacetRegistry; import org.mediavirus.graphl.view.SimpleFacetRegistry; + import org.mediavirus.graphl.vocabulary.NS; import org.mediavirus.graphl.vocabulary.SimpleVocabularyRegistry; import org.mediavirus.graphl.vocabulary.VocabularyRegistry; *************** *** 88,91 **** --- 89,95 ---- Edge hoverEdge = null; + String comment = null; + + /** * Creates a graph pane. *************** *** 124,127 **** --- 128,145 ---- /** + * @return Returns the comment. + */ + public String getComment() { + return comment; + } + + /** + * @param comment The comment to set. + */ + public void setComment(String comment) { + this.comment = comment; + } + + /** * @return The VocabularyRegistry. */ *************** *** 180,188 **** public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; ! g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); if (transform != null) { g2.transform(transform); } - long renderStartTime=System.currentTimeMillis(); Rectangle clipRectangle=g.getClipBounds(); --- 198,206 ---- public void paintComponent(Graphics g) { Graphics2D g2 = (Graphics2D) g; ! g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); ! if (transform != null) { g2.transform(transform); } long renderStartTime=System.currentTimeMillis(); Rectangle clipRectangle=g.getClipBounds(); *************** *** 191,195 **** g.fillRect(clipRectangle.x,clipRectangle.y,clipRectangle.width,clipRectangle.height); g.setColor(oldColor); ! if (graph!=null) synchronized (graph) { // this is the main rendering loop --- 209,219 ---- g.fillRect(clipRectangle.x,clipRectangle.y,clipRectangle.width,clipRectangle.height); g.setColor(oldColor); ! ! // if (comment != null) { ! // g2.setFont(Font.decode("Dialog-10")); ! // g2.drawString("fooo", 0, 20); ! // } ! ! if (graph!=null) synchronized (graph) { // this is the main rendering loop *************** *** 371,389 **** */ public void setGraph(Graph graph) { Graph oldGraph = this.graph; ! if (this.graph!=null) { ! this.graph.removeGraphListener(graphListener); ! this.graph.removeGraphListener(this); } ! this.graph=graph; ! if (this.graph!=null) { ! this.graph.addGraphListener(graphListener); ! this.graph.addGraphListener(this); } repaint(); selection = new DefaultSelectionModel(graph); ! firePropertyChange("graph",oldGraph,this.graph); ! graph.addGraphListener(this); } --- 395,415 ---- */ public void setGraph(Graph graph) { + Graph oldGraph = this.graph; ! if (oldGraph != null) { ! oldGraph.removeGraphListener(graphListener); ! oldGraph.removeGraphListener(this); } ! ! this.graph = graph; ! if (graph != null) { ! graph.addGraphListener(graphListener); ! graph.addGraphListener(this); } repaint(); selection = new DefaultSelectionModel(graph); ! firePropertyChange("graph",oldGraph,graph); ! //graph.addGraphListener(this); } *************** *** 402,406 **** Node node=(Node)iterator.previous(); NodePainter nodePainter = node.getCurrentPainter(); ! if (nodePainter.isInNode(this,node,point)) return node; } --- 428,432 ---- Node node=(Node)iterator.previous(); NodePainter nodePainter = node.getCurrentPainter(); ! if (nodePainter != null && nodePainter.isInNode(this,node,point)) return node; } *************** *** 443,450 **** Edge edge=(Edge)iterator.previous(); EdgePainter edgePainter=getPainterForEdge(edge); ! double distance=edgePainter.screenDistanceFromEdge(this,edge,point); ! if (distance<minDistance) { ! minDistance=distance; ! nearestEdge=edge; } } --- 469,478 ---- Edge edge=(Edge)iterator.previous(); EdgePainter edgePainter=getPainterForEdge(edge); ! if (edgePainter != null) { ! double distance=edgePainter.screenDistanceFromEdge(this,edge,point); ! if (distance<minDistance) { ! minDistance=distance; ! nearestEdge=edge; ! } } } *************** *** 470,474 **** */ public void getNodeScreenBounds(Node node,Rectangle nodeScreenRectangle) { ! node.getCurrentPainter().getNodeScreenBounds(this,node,nodeScreenRectangle); } /** --- 498,503 ---- */ public void getNodeScreenBounds(Node node,Rectangle nodeScreenRectangle) { ! if (node.getCurrentPainter() != null) ! node.getCurrentPainter().getNodeScreenBounds(this,node,nodeScreenRectangle); } /** *************** *** 489,493 **** */ public void getEdgeScreenBounds(Edge edge,Rectangle edgeScreenRectangle) { ! edge.getCurrentPainter().getEdgeScreenBounds(this,edge,edgeScreenRectangle); } /** --- 518,523 ---- */ public void getEdgeScreenBounds(Edge edge,Rectangle edgeScreenRectangle) { ! if (edge.getCurrentPainter() != null) ! edge.getCurrentPainter().getEdgeScreenBounds(this,edge,edgeScreenRectangle); } /** *************** *** 751,757 **** for (Iterator nodes = settingsGraph.getNodes().iterator(); nodes.hasNext();) { Node node = (Node) nodes.next(); ! if (node.hasType("http://www.mediavirus.org/graphl#Configuration")) { configurations.add(node); ! node.setProperty("http://www.mediavirus.org/graphl#active","false"); } } --- 781,787 ---- for (Iterator nodes = settingsGraph.getNodes().iterator(); nodes.hasNext();) { Node node = (Node) nodes.next(); ! if (node.hasType(NS.graphl + "Configuration")) { configurations.add(node); ! node.setProperty(NS.graphl + "active","false"); } } *************** *** 773,782 **** public void setConfiguration(Node configuration){ if (currentConfiguration != null) { ! currentConfiguration.setProperty("http://www.mediavirus.org/graphl#active","false"); } currentConfiguration = configuration; setFacetRegistry(new GraphFacetRegistry(settingsGraph,configuration)); ! setVocabularies(configuration.getFirstNeighbour("http://www.mediavirus.org/graphl#vocabularies",true)); ! configuration.setProperty("http://www.mediavirus.org/graphl#active","true"); } /** --- 803,814 ---- public void setConfiguration(Node configuration){ if (currentConfiguration != null) { ! currentConfiguration.setProperty(NS.graphl + "active","false"); } currentConfiguration = configuration; setFacetRegistry(new GraphFacetRegistry(settingsGraph,configuration)); ! setVocabularies(configuration.getFirstNeighbour(NS.graphl + "vocabularies",true)); ! configuration.setProperty(NS.graphl + "active","true"); ! setComment(configuration.getProperty(NS.graphl + "comment")); ! graph.notifyLayoutUpdated(); } /** *************** *** 792,794 **** --- 824,832 ---- return hoverEdge; } + /** + * @return Returns the centerXF. + */ + public AffineTransform getCenter() { + return centerXF; + } } |