[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...> - 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; + } } |