[graphl-cvs] graphl/src/org/mediavirus/graphl GraphlPane.java GraphlPanel.java
Status: Pre-Alpha
Brought to you by:
flo1
From: Flo L. <fl...@us...> - 2005-09-05 15:46:48
|
Update of /cvsroot/graphl/graphl/src/org/mediavirus/graphl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14883/src/org/mediavirus/graphl Modified Files: GraphlPane.java GraphlPanel.java Log Message: added methods to access filtered and unfiltered versions of the graph in GraphlPane Index: GraphlPanel.java =================================================================== RCS file: /cvsroot/graphl/graphl/src/org/mediavirus/graphl/GraphlPanel.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** GraphlPanel.java 17 Aug 2005 15:52:51 -0000 1.23 --- GraphlPanel.java 5 Sep 2005 15:46:38 -0000 1.24 *************** *** 44,48 **** GraphlPane graphPane; GraphlManipulator gui; - Graph graph; JCheckBox layoutBox; --- 44,47 ---- *************** *** 56,68 **** public GraphlPanel(){ ! graph = new RDFGraph(); initialize(); } public GraphlPanel(Graph graph) { ! this.graph = graph; initialize(); } protected void initialize() { --- 55,99 ---- public GraphlPanel(){ ! graphPane = new GraphlPane(); ! initGraphlPane(); initialize(); } public GraphlPanel(Graph graph) { ! graphPane = new GraphlPane(graph); ! initGraphlPane(); initialize(); } + private void initGraphlPane() { + graphPane.setEnabled(true); + graphPane.addManipulator(new GraphlManipulator()); + graphPane.addManipulator(new DefaultNodeManipulator()); + graphPane.getFilteredGraph().addGraphListener(this); + graphPane.addKeyListener(this); + graphPane.addMouseWheelListener(new MouseWheelListener () { + public void mouseWheelMoved(MouseWheelEvent e) { + //invert the rotation to create standard scroll-zoom + //behaviour (scroll up=zoom in, scroll down=zoom out) + int wheelRotation = e.getWheelRotation() * -1; + int sliderValue = getZoomSlider().getValue(); + //ignore scrolling in invariant directions at extreme values + if ((wheelRotation < 0 && getZoomSlider().getValue() == getZoomSlider().getMinimum()) + ||(wheelRotation > 0 && getZoomSlider().getValue() == getZoomSlider().getMaximum())) { + return; + } + sliderValue += wheelRotation * e.getScrollAmount() * WHEEL_ZOOM_FACTOR; + if(sliderValue < getZoomSlider().getMinimum()) { + sliderValue = getZoomSlider().getMinimum(); + } + if(sliderValue > getZoomSlider().getMaximum()) { + sliderValue = getZoomSlider().getMaximum(); + } + getZoomSlider().setValue(sliderValue); + } + }); + + } + protected void initialize() { *************** *** 200,230 **** public GraphlPane getGraphPane() { if (graphPane == null) { - graphPane = new GraphlPane(graph); - graphPane.setEnabled(true); - graphPane.addManipulator(new GraphlManipulator()); - graphPane.addManipulator(new DefaultNodeManipulator()); - graphPane.getGraph().addGraphListener(this); - graphPane.addKeyListener(this); - graphPane.addMouseWheelListener(new MouseWheelListener () { - public void mouseWheelMoved(MouseWheelEvent e) { - //invert the rotation to create standard scroll-zoom - //behaviour (scroll up=zoom in, scroll down=zoom out) - int wheelRotation = e.getWheelRotation() * -1; - int sliderValue = getZoomSlider().getValue(); - //ignore scrolling in invariant directions at extreme values - if ((wheelRotation < 0 && getZoomSlider().getValue() == getZoomSlider().getMinimum()) - ||(wheelRotation > 0 && getZoomSlider().getValue() == getZoomSlider().getMaximum())) { - return; - } - sliderValue += wheelRotation * e.getScrollAmount() * WHEEL_ZOOM_FACTOR; - if(sliderValue < getZoomSlider().getMinimum()) { - sliderValue = getZoomSlider().getMinimum(); - } - if(sliderValue > getZoomSlider().getMaximum()) { - sliderValue = getZoomSlider().getMaximum(); - } - getZoomSlider().setValue(sliderValue); - } - }); } return graphPane; --- 231,234 ---- *************** *** 243,249 **** } ! // TODO (1) fix access and casting public RDFGraph getGraph() { ! return (RDFGraph)((FilteredGraph) graphPane.getGraph()).getSource(); } --- 247,254 ---- } ! // TODO (1) fix access and casting. DEP: #1 ! // TODO (1, 4h) #1 rewrite all load, save,... operations for new global graph paradigm public RDFGraph getGraph() { ! return (RDFGraph)((FilteredGraph) graphPane.getFilteredGraph()).getSource(); } *************** *** 281,288 **** edges.addAll(node.getEdgesFrom()); edges.addAll(node.getEdgesTo()); ! ((DefaultGraph)graphPane.getGraph()).deleteElements(Collections.singleton(node),edges); } ! ((DefaultGraph)graphPane.getGraph()).deleteElements(null,graphPane.getSelection().getSelectedEdges()); } --- 286,293 ---- edges.addAll(node.getEdgesFrom()); edges.addAll(node.getEdgesTo()); ! ((DefaultGraph)graphPane.getSourceGraph()).deleteElements(Collections.singleton(node),edges); } ! ((DefaultGraph)graphPane.getSourceGraph()).deleteElements(null,graphPane.getSelection().getSelectedEdges()); } Index: GraphlPane.java =================================================================== RCS file: /cvsroot/graphl/graphl/src/org/mediavirus/graphl/GraphlPane.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** GraphlPane.java 17 Aug 2005 15:52:51 -0000 1.19 --- GraphlPane.java 5 Sep 2005 15:46:38 -0000 1.20 *************** *** 36,39 **** --- 36,40 ---- import org.mediavirus.graphl.graph.GraphListener; import org.mediavirus.graphl.graph.Node; + import org.mediavirus.graphl.graph.filter.FilteredGraph; import org.mediavirus.graphl.graph.rdf.RDFGraph; import org.mediavirus.graphl.interaction.Manipulator; *************** *** 76,80 **** /** The graph being visualized. */ ! protected Graph graph; /** The listener for the graph. */ protected GraphListener graphListener; --- 77,81 ---- /** The graph being visualized. */ ! protected FilteredGraph filteredGraph; /** The listener for the graph. */ protected GraphListener graphListener; *************** *** 99,105 **** public GraphlPane(Graph graph) { super(null); graphListener=new GraphHandler(); manipulators=new ArrayList(); - setGraph(graph); enableEvents(MouseEvent.MOUSE_EVENT_MASK | MouseEvent.MOUSE_MOTION_EVENT_MASK | KeyEvent.KEY_EVENT_MASK | FocusEvent.FOCUS_EVENT_MASK | ComponentEvent.COMPONENT_EVENT_MASK); setBackground(Color.white); --- 100,106 ---- public GraphlPane(Graph graph) { super(null); + setSourceGraph(graph); graphListener=new GraphHandler(); manipulators=new ArrayList(); enableEvents(MouseEvent.MOUSE_EVENT_MASK | MouseEvent.MOUSE_MOTION_EVENT_MASK | KeyEvent.KEY_EVENT_MASK | FocusEvent.FOCUS_EVENT_MASK | ComponentEvent.COMPONENT_EVENT_MASK); setBackground(Color.white); *************** *** 108,112 **** updateTransform(); ! layouter = new Layouter(new GraphlLayoutStrategy(getGraph(), getFacetRegistry())); startLayouter(); //setupDefaultPainters(); --- 109,113 ---- updateTransform(); ! layouter = new Layouter(new GraphlLayoutStrategy(getFilteredGraph(), getFacetRegistry())); startLayouter(); //setupDefaultPainters(); *************** *** 123,127 **** public void setFacetRegistry(FacetRegistry registry) { this.facetRegistry = registry; ! registry.updateFacets(graph); repaint(); } --- 124,128 ---- public void setFacetRegistry(FacetRegistry registry) { this.facetRegistry = registry; ! registry.updateFacets(filteredGraph); repaint(); } *************** *** 215,220 **** // } ! 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 --- 216,221 ---- // } ! if (filteredGraph!=null) ! synchronized (filteredGraph) { // this is the main rendering loop //TODO (2, 1h) we have to store zMin somewhere (GraphView?) and get it here to save 1 loop *************** *** 225,229 **** curZ = nextZ; nextZ = Integer.MAX_VALUE; ! iterator=graph.getEdges().iterator(); while (iterator.hasNext()) { Edge edge=(Edge)iterator.next(); --- 226,230 ---- curZ = nextZ; nextZ = Integer.MAX_VALUE; ! iterator=filteredGraph.getEdges().iterator(); while (iterator.hasNext()) { Edge edge=(Edge)iterator.next(); *************** *** 239,243 **** } } ! iterator=graph.getNodes().iterator(); while (iterator.hasNext()) { Node node=(Node)iterator.next(); --- 240,244 ---- } } ! iterator=filteredGraph.getNodes().iterator(); while (iterator.hasNext()) { Node node=(Node)iterator.next(); *************** *** 307,311 **** public void graphContentsChanged(Graph graph) { ! facetRegistry.updateFacets(graph); } --- 308,315 ---- public void graphContentsChanged(Graph graph) { ! if (graph == filteredGraph) { ! updateSettingsFromGraph(getSourceGraph()); ! facetRegistry.updateFacets(getSourceGraph()); ! } } *************** *** 330,334 **** } ! // we have to update all nodes' facets, because new nodes may have changed // an existing node's type // TODO (2) implement node and edge change notification in GraphListener --- 334,338 ---- } ! // we have to update all nodes' facets, because new nodes may have changed // an existing node's type // TODO (2) implement node and edge change notification in GraphListener *************** *** 386,391 **** * @return the current graph */ ! public Graph getGraph() { ! return graph; } /** --- 390,399 ---- * @return the current graph */ ! public FilteredGraph getFilteredGraph() { ! return filteredGraph; ! } ! ! public Graph getSourceGraph() { ! return filteredGraph.getSource(); } /** *************** *** 394,400 **** * @param graph the new graph */ ! public void setGraph(Graph graph) { ! ! Graph oldGraph = this.graph; if (oldGraph != null) { oldGraph.removeGraphListener(graphListener); --- 402,416 ---- * @param graph the new graph */ ! public void setSourceGraph(Graph graph) { ! if (filteredGraph == null) { ! filteredGraph = new FilteredGraph(graph); ! filteredGraph.addGraphListener(graphListener); ! filteredGraph.addGraphListener(this); ! } ! else { ! filteredGraph.setSource(graph); ! } ! selection = new DefaultSelectionModel(filteredGraph); ! /*Graph oldGraph = filteredGraph.getSource(); if (oldGraph != null) { oldGraph.removeGraphListener(graphListener); *************** *** 402,415 **** } ! this.graph = graph; if (graph != null) { graph.addGraphListener(graphListener); graph.addGraphListener(this); ! } repaint(); ! selection = new DefaultSelectionModel(graph); ! firePropertyChange("graph",oldGraph,graph); //graph.addGraphListener(this); } --- 418,443 ---- } ! this.filteredGraph = graph; if (graph != null) { graph.addGraphListener(graphListener); graph.addGraphListener(this); ! }*/ repaint(); ! //selection = new DefaultSelectionModel(graph); ! //firePropertyChange("graph",oldGraph,graph); //graph.addGraphListener(this); + } + + public void updateSettingsFromGraph(Graph graph) { + configurations.clear(); + + for (Iterator nodes = graph.getNodes().iterator(); nodes.hasNext();) { + Node node = (Node) nodes.next(); + if (node.hasType(NS.graphl + "Configuration")) { + configurations.add(node); + node.setProperty(NS.graphl + "active","false"); + } + } } *************** *** 422,427 **** */ public Node getNodeAtPoint(Point point) { ! synchronized (graph) { ! List nodes=graph.getNodes(); ListIterator iterator=nodes.listIterator(nodes.size()); while (iterator.hasPrevious()) { --- 450,455 ---- */ public Node getNodeAtPoint(Point point) { ! synchronized (filteredGraph) { ! List nodes=filteredGraph.getNodes(); ListIterator iterator=nodes.listIterator(nodes.size()); while (iterator.hasPrevious()) { *************** *** 441,448 **** */ public Set getNodesInRectangle(Rectangle rectangle) { ! synchronized (graph) { Set nodesInRectangle=new HashSet(); Rectangle nodeRectangle=new Rectangle(); ! Iterator nodes=graph.getNodes().iterator(); while (nodes.hasNext()) { Node node=(Node)nodes.next(); --- 469,476 ---- */ public Set getNodesInRectangle(Rectangle rectangle) { ! synchronized (filteredGraph) { Set nodesInRectangle=new HashSet(); Rectangle nodeRectangle=new Rectangle(); ! Iterator nodes=filteredGraph.getNodes().iterator(); while (nodes.hasNext()) { Node node=(Node)nodes.next(); *************** *** 463,468 **** Edge nearestEdge=null; double minDistance=4; ! synchronized (graph) { ! List edges=graph.getEdges(); ListIterator iterator=edges.listIterator(edges.size()); while (iterator.hasPrevious()) { --- 491,496 ---- Edge nearestEdge=null; double minDistance=4; ! synchronized (filteredGraph) { ! List edges=filteredGraph.getEdges(); ListIterator iterator=edges.listIterator(edges.size()); while (iterator.hasPrevious()) { *************** *** 767,795 **** } - private Graph settingsGraph = null; /** A List with all configuration nodes in the settings graph */ private List configurations = new ArrayList(); private Node currentConfiguration = null; - - public void setConfigurationGraph(Graph settingsGraph) { - - this.settingsGraph = settingsGraph; - - Node defaultConfiguration = null; - - 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"); - } - } - - } - - public Graph getConfigurationGraph() { - return settingsGraph; - } public Collection getConfigurations() { --- 795,802 ---- *************** *** 806,814 **** } 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(); } /** --- 813,821 ---- } currentConfiguration = configuration; ! setFacetRegistry(new GraphFacetRegistry(getSourceGraph(),configuration)); setVocabularies(configuration.getFirstNeighbour(NS.graphl + "vocabularies",true)); configuration.setProperty(NS.graphl + "active","true"); setComment(configuration.getProperty(NS.graphl + "comment")); ! filteredGraph.notifyLayoutUpdated(); } /** *************** *** 830,832 **** --- 837,840 ---- return centerXF; } + } |