|
@@ -1,16 +1,13 @@
|
|
package de.tu_darmstadt.informatik.tk.scopviz.graphs;
|
|
package de.tu_darmstadt.informatik.tk.scopviz.graphs;
|
|
-
|
|
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.LinkedList;
|
|
import java.util.LinkedList;
|
|
-
|
|
|
|
import org.graphstream.graph.Edge;
|
|
import org.graphstream.graph.Edge;
|
|
import org.graphstream.graph.Element;
|
|
import org.graphstream.graph.Element;
|
|
import org.graphstream.graph.Node;
|
|
import org.graphstream.graph.Node;
|
|
import org.graphstream.ui.swingViewer.ViewPanel;
|
|
import org.graphstream.ui.swingViewer.ViewPanel;
|
|
import org.graphstream.ui.view.Viewer;
|
|
import org.graphstream.ui.view.Viewer;
|
|
import org.graphstream.ui.view.ViewerPipe;
|
|
import org.graphstream.ui.view.ViewerPipe;
|
|
-
|
|
|
|
import de.tu_darmstadt.informatik.tk.scopviz.debug.Debug;
|
|
import de.tu_darmstadt.informatik.tk.scopviz.debug.Debug;
|
|
import de.tu_darmstadt.informatik.tk.scopviz.main.CreationMode;
|
|
import de.tu_darmstadt.informatik.tk.scopviz.main.CreationMode;
|
|
import de.tu_darmstadt.informatik.tk.scopviz.main.Layer;
|
|
import de.tu_darmstadt.informatik.tk.scopviz.main.Layer;
|
|
@@ -19,7 +16,6 @@ import de.tu_darmstadt.informatik.tk.scopviz.ui.GraphDisplayManager;
|
|
import de.tu_darmstadt.informatik.tk.scopviz.ui.PropertiesManager;
|
|
import de.tu_darmstadt.informatik.tk.scopviz.ui.PropertiesManager;
|
|
import de.tu_darmstadt.informatik.tk.scopviz.ui.StylesheetManager;
|
|
import de.tu_darmstadt.informatik.tk.scopviz.ui.StylesheetManager;
|
|
import de.tu_darmstadt.informatik.tk.scopviz.ui.handlers.MyMouseManager;
|
|
import de.tu_darmstadt.informatik.tk.scopviz.ui.handlers.MyMouseManager;
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Interface between GUI and internal Graph representation. Manages internal
|
|
* Interface between GUI and internal Graph representation. Manages internal
|
|
* representation of the Graph to accommodate creation and deletion of nodes and
|
|
* representation of the Graph to accommodate creation and deletion of nodes and
|
|
@@ -30,41 +26,27 @@ import de.tu_darmstadt.informatik.tk.scopviz.ui.handlers.MyMouseManager;
|
|
*
|
|
*
|
|
*/
|
|
*/
|
|
public class GraphManager {
|
|
public class GraphManager {
|
|
-
|
|
|
|
/** String for the processing enabled type of node. */
|
|
/** String for the processing enabled type of node. */
|
|
public static final String UI_CLASS_PROCESSING_ENABLED = "procEn";
|
|
public static final String UI_CLASS_PROCESSING_ENABLED = "procEn";
|
|
-
|
|
|
|
/** The Graph this instance of GraphManager manages. */
|
|
/** The Graph this instance of GraphManager manages. */
|
|
protected MyGraph g;
|
|
protected MyGraph g;
|
|
-
|
|
|
|
- /**
|
|
|
|
- * The Subgraph to add new Nodes and Edges to if the current Graph is a
|
|
|
|
- * composite.
|
|
|
|
- */
|
|
|
|
- protected MyGraph graphToAddTo;
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* The Stylesheet for this Graph, excluding parts that can be set by
|
|
* The Stylesheet for this Graph, excluding parts that can be set by
|
|
* NodeGraphics.
|
|
* NodeGraphics.
|
|
*/
|
|
*/
|
|
protected String stylesheet = "";
|
|
protected String stylesheet = "";
|
|
-
|
|
|
|
/** The last Node that was deleted. */
|
|
/** The last Node that was deleted. */
|
|
protected Node deletedNode;
|
|
protected Node deletedNode;
|
|
/** The last Edge that was deleted. */
|
|
/** The last Edge that was deleted. */
|
|
protected LinkedList<Edge> deletedEdges = new LinkedList<>();
|
|
protected LinkedList<Edge> deletedEdges = new LinkedList<>();
|
|
-
|
|
|
|
/** The currently selected Node, mutually exclusive with selectedEdgeID. */
|
|
/** The currently selected Node, mutually exclusive with selectedEdgeID. */
|
|
protected String selectedNodeID = null;
|
|
protected String selectedNodeID = null;
|
|
/** The currently selected Edge, mutually exclusive with selectedNodeID. */
|
|
/** The currently selected Edge, mutually exclusive with selectedNodeID. */
|
|
protected String selectedEdgeID = null;
|
|
protected String selectedEdgeID = null;
|
|
-
|
|
|
|
/** The ViewPanel the Graph is drawn in. */
|
|
/** The ViewPanel the Graph is drawn in. */
|
|
protected ViewPanel view;
|
|
protected ViewPanel view;
|
|
-
|
|
|
|
/** The Path on Disk the Graph will be saved to. */
|
|
/** The Path on Disk the Graph will be saved to. */
|
|
protected String currentPath;
|
|
protected String currentPath;
|
|
-
|
|
|
|
/** The Viewer the Graph provides, grants Access to Camera Manipulation. */
|
|
/** The Viewer the Graph provides, grants Access to Camera Manipulation. */
|
|
protected Viewer viewer;
|
|
protected Viewer viewer;
|
|
/**
|
|
/**
|
|
@@ -72,12 +54,10 @@ public class GraphManager {
|
|
* graphic Representation.
|
|
* graphic Representation.
|
|
*/
|
|
*/
|
|
protected ViewerPipe fromViewer;
|
|
protected ViewerPipe fromViewer;
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* The Id of the Node that was last clicked.
|
|
* The Id of the Node that was last clicked.
|
|
*/
|
|
*/
|
|
protected String lastClickedID;
|
|
protected String lastClickedID;
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Creates a new Manager for the given graph.
|
|
* Creates a new Manager for the given graph.
|
|
*
|
|
*
|
|
@@ -86,16 +66,14 @@ public class GraphManager {
|
|
*/
|
|
*/
|
|
public GraphManager(MyGraph graph) {
|
|
public GraphManager(MyGraph graph) {
|
|
g = graph;
|
|
g = graph;
|
|
- graphToAddTo = graph;
|
|
|
|
- viewer = new Viewer(g, Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
|
|
|
|
|
|
+ /* Viewer */ viewer = new Viewer(g, Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
|
|
view = viewer.addDefaultView(false);
|
|
view = viewer.addDefaultView(false);
|
|
viewer.setCloseFramePolicy(Viewer.CloseFramePolicy.EXIT);
|
|
viewer.setCloseFramePolicy(Viewer.CloseFramePolicy.EXIT);
|
|
- fromViewer = viewer.newViewerPipe();
|
|
|
|
|
|
+ /* ViewerPipe */fromViewer = viewer.newViewerPipe();
|
|
view.setMouseManager(new MyMouseManager(this));
|
|
view.setMouseManager(new MyMouseManager(this));
|
|
fromViewer.addSink(graph);
|
|
fromViewer.addSink(graph);
|
|
fromViewer.removeElementSink(graph);
|
|
fromViewer.removeElementSink(graph);
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Deletes the Node corresponding to the given ID from the Graph. The
|
|
* Deletes the Node corresponding to the given ID from the Graph. The
|
|
* referenced Graph is modified directly. Will throw an
|
|
* referenced Graph is modified directly. Will throw an
|
|
@@ -112,11 +90,8 @@ public class GraphManager {
|
|
// and need the Node to still be in the Graph
|
|
// and need the Node to still be in the Graph
|
|
deleteEdgesOfNode(id);
|
|
deleteEdgesOfNode(id);
|
|
deletedNode = g.removeNode(id);
|
|
deletedNode = g.removeNode(id);
|
|
- if (graphToAddTo != g) {
|
|
|
|
- graphToAddTo.removeNode(id);
|
|
|
|
- }
|
|
|
|
|
|
+ GraphHelper.propagateElementDeletion(g, deletedNode);
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Deletes the Edge corresponding to the given ID from the Graph. The
|
|
* Deletes the Edge corresponding to the given ID from the Graph. The
|
|
* referenced Graph is modified directly. Will throw an
|
|
* referenced Graph is modified directly. Will throw an
|
|
@@ -130,11 +105,8 @@ public class GraphManager {
|
|
deletedEdges.removeAll(deletedEdges);
|
|
deletedEdges.removeAll(deletedEdges);
|
|
deletedNode = null;
|
|
deletedNode = null;
|
|
deletedEdges.add(g.removeEdge(id));
|
|
deletedEdges.add(g.removeEdge(id));
|
|
- if (graphToAddTo != g) {
|
|
|
|
- graphToAddTo.removeEdge(id);
|
|
|
|
- }
|
|
|
|
|
|
+ GraphHelper.propagateElementDeletion(g, deletedEdges);
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Deletes all Edges connected to the given Node. The referenced Graph is
|
|
* Deletes all Edges connected to the given Node. The referenced Graph is
|
|
* modified directly. Will throw an ElementNotFoundException if the Node is
|
|
* modified directly. Will throw an ElementNotFoundException if the Node is
|
|
@@ -150,19 +122,15 @@ public class GraphManager {
|
|
deletedNode = null;
|
|
deletedNode = null;
|
|
Edge[] temp = new Edge[0];
|
|
Edge[] temp = new Edge[0];
|
|
temp = g.getEdgeSet().toArray(temp);
|
|
temp = g.getEdgeSet().toArray(temp);
|
|
-
|
|
|
|
for (Edge e : temp) {
|
|
for (Edge e : temp) {
|
|
if (e.getSourceNode().equals(node) || e.getTargetNode().equals(node)) {
|
|
if (e.getSourceNode().equals(node) || e.getTargetNode().equals(node)) {
|
|
// adds the Edge to the list of deleted Edges and remove sit
|
|
// adds the Edge to the list of deleted Edges and remove sit
|
|
// from the Graph
|
|
// from the Graph
|
|
deletedEdges.add(g.removeEdge(e));
|
|
deletedEdges.add(g.removeEdge(e));
|
|
- if (graphToAddTo != g) {
|
|
|
|
- graphToAddTo.removeEdge(e);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ GraphHelper.propagateElementDeletion(g, deletedEdges);
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Undoes the last deleting operation on the given Graph. Deleting
|
|
* Undoes the last deleting operation on the given Graph. Deleting
|
|
* operations are: deleteNode, deleteEdge and deleteEdgesOfNode. Only undoes
|
|
* operations are: deleteNode, deleteEdge and deleteEdgesOfNode. Only undoes
|
|
@@ -171,6 +139,7 @@ public class GraphManager {
|
|
*/
|
|
*/
|
|
public void undelete() {
|
|
public void undelete() {
|
|
String newId = "";
|
|
String newId = "";
|
|
|
|
+ // System.out.println("test-undel");
|
|
HashMap<String, Object> attributes = new HashMap<String, Object>();
|
|
HashMap<String, Object> attributes = new HashMap<String, Object>();
|
|
if (deletedNode != null) {
|
|
if (deletedNode != null) {
|
|
for (String s : deletedNode.getAttributeKeySet()) {
|
|
for (String s : deletedNode.getAttributeKeySet()) {
|
|
@@ -179,12 +148,7 @@ public class GraphManager {
|
|
newId = Main.getInstance().getUnusedID();
|
|
newId = Main.getInstance().getUnusedID();
|
|
g.addNode(newId);
|
|
g.addNode(newId);
|
|
g.getNode(newId).addAttributes(attributes);
|
|
g.getNode(newId).addAttributes(attributes);
|
|
- if (graphToAddTo != g) {
|
|
|
|
- graphToAddTo.addNode(newId);
|
|
|
|
- graphToAddTo.getNode(newId).addAttributes(attributes);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
for (Edge e : deletedEdges) {
|
|
for (Edge e : deletedEdges) {
|
|
String sourceId = null;
|
|
String sourceId = null;
|
|
String targetId = null;
|
|
String targetId = null;
|
|
@@ -199,19 +163,13 @@ public class GraphManager {
|
|
} else {
|
|
} else {
|
|
sourceId = e.getSourceNode().getId();
|
|
sourceId = e.getSourceNode().getId();
|
|
targetId = e.getTargetNode().getId();
|
|
targetId = e.getTargetNode().getId();
|
|
-
|
|
|
|
}
|
|
}
|
|
g.addEdge(id, sourceId, targetId);
|
|
g.addEdge(id, sourceId, targetId);
|
|
g.getEdge(id).addAttributes(attributes);
|
|
g.getEdge(id).addAttributes(attributes);
|
|
- if (graphToAddTo != g) {
|
|
|
|
- graphToAddTo.addEdge(id, sourceId, targetId);
|
|
|
|
- graphToAddTo.getEdge(id).addAttributes(attributes);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
deletedEdges = new LinkedList<>();
|
|
deletedEdges = new LinkedList<>();
|
|
deletedNode = null;
|
|
deletedNode = null;
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* returns a View of the Graph. The View lives in the Swing Thread and the
|
|
* returns a View of the Graph. The View lives in the Swing Thread and the
|
|
* Graph in the Main thread.
|
|
* Graph in the Main thread.
|
|
@@ -222,7 +180,6 @@ public class GraphManager {
|
|
public ViewPanel getView() {
|
|
public ViewPanel getView() {
|
|
return view;
|
|
return view;
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Returns the ID of the currently selected Node.
|
|
* Returns the ID of the currently selected Node.
|
|
*
|
|
*
|
|
@@ -231,7 +188,6 @@ public class GraphManager {
|
|
public String getSelectedNodeID() {
|
|
public String getSelectedNodeID() {
|
|
return selectedNodeID;
|
|
return selectedNodeID;
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Returns the ID of the currently selected Edge.
|
|
* Returns the ID of the currently selected Edge.
|
|
*
|
|
*
|
|
@@ -240,7 +196,6 @@ public class GraphManager {
|
|
public String getSelectedEdgeID() {
|
|
public String getSelectedEdgeID() {
|
|
return selectedEdgeID;
|
|
return selectedEdgeID;
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Selects the Node with the given ID, resets Edge selection.
|
|
* Selects the Node with the given ID, resets Edge selection.
|
|
*
|
|
*
|
|
@@ -251,7 +206,6 @@ public class GraphManager {
|
|
if (nodeID != null && g.getNode(nodeID) != null) {
|
|
if (nodeID != null && g.getNode(nodeID) != null) {
|
|
deselect();
|
|
deselect();
|
|
this.selectedNodeID = nodeID;
|
|
this.selectedNodeID = nodeID;
|
|
-
|
|
|
|
Node n = g.getNode(nodeID);
|
|
Node n = g.getNode(nodeID);
|
|
// set selected node color to red
|
|
// set selected node color to red
|
|
if (!hasClass(n, UI_CLASS_PROCESSING_ENABLED)
|
|
if (!hasClass(n, UI_CLASS_PROCESSING_ENABLED)
|
|
@@ -261,7 +215,6 @@ public class GraphManager {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Selects the Edge with the given ID, resets Node selection.
|
|
* Selects the Edge with the given ID, resets Node selection.
|
|
*
|
|
*
|
|
@@ -272,12 +225,10 @@ public class GraphManager {
|
|
if (edgeID != null && g.getEdge(edgeID) != null) {
|
|
if (edgeID != null && g.getEdge(edgeID) != null) {
|
|
deselect();
|
|
deselect();
|
|
this.selectedEdgeID = edgeID;
|
|
this.selectedEdgeID = edgeID;
|
|
-
|
|
|
|
addClass(edgeID, "selected");
|
|
addClass(edgeID, "selected");
|
|
PropertiesManager.setItemsProperties();
|
|
PropertiesManager.setItemsProperties();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Deselect any currently selected nodes or edges.
|
|
* Deselect any currently selected nodes or edges.
|
|
*/
|
|
*/
|
|
@@ -301,7 +252,6 @@ public class GraphManager {
|
|
this.selectedNodeID = null;
|
|
this.selectedNodeID = null;
|
|
this.selectedEdgeID = null;
|
|
this.selectedEdgeID = null;
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Returns a reference to the Graph object managed by this visualizer.
|
|
* Returns a reference to the Graph object managed by this visualizer.
|
|
*
|
|
*
|
|
@@ -310,21 +260,18 @@ public class GraphManager {
|
|
public MyGraph getGraph() {
|
|
public MyGraph getGraph() {
|
|
return g;
|
|
return g;
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Zooms in the view of the graph by 5 percent.
|
|
* Zooms in the view of the graph by 5 percent.
|
|
*/
|
|
*/
|
|
public void zoomIn() {
|
|
public void zoomIn() {
|
|
zoom(-0.05);
|
|
zoom(-0.05);
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Zooms out the view of the graph by 5 percent.
|
|
* Zooms out the view of the graph by 5 percent.
|
|
*/
|
|
*/
|
|
public void zoomOut() {
|
|
public void zoomOut() {
|
|
zoom(0.05);
|
|
zoom(0.05);
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Zooms the view by the given Amount, positive values zoom out, negative
|
|
* Zooms the view by the given Amount, positive values zoom out, negative
|
|
* values zoom in.
|
|
* values zoom in.
|
|
@@ -336,7 +283,6 @@ public class GraphManager {
|
|
public void zoom(double amount) {
|
|
public void zoom(double amount) {
|
|
view.getCamera().setViewPercent(view.getCamera().getViewPercent() * (1 + amount));
|
|
view.getCamera().setViewPercent(view.getCamera().getViewPercent() * (1 + amount));
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Pumps the Pipe from the graphical Representation to the underlying Graph,
|
|
* Pumps the Pipe from the graphical Representation to the underlying Graph,
|
|
* propagating all Changes made.
|
|
* propagating all Changes made.
|
|
@@ -344,12 +290,10 @@ public class GraphManager {
|
|
public void pumpIt() {
|
|
public void pumpIt() {
|
|
fromViewer.pump();
|
|
fromViewer.pump();
|
|
}
|
|
}
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public String toString() {
|
|
public String toString() {
|
|
return "Visualizer for Graph \"" + g.getId() + "\"";
|
|
return "Visualizer for Graph \"" + g.getId() + "\"";
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Returns the current Save Path on Disk for the Graph.
|
|
* Returns the current Save Path on Disk for the Graph.
|
|
*
|
|
*
|
|
@@ -358,7 +302,6 @@ public class GraphManager {
|
|
public String getCurrentPath() {
|
|
public String getCurrentPath() {
|
|
return currentPath;
|
|
return currentPath;
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Sets the Save Path.
|
|
* Sets the Save Path.
|
|
*
|
|
*
|
|
@@ -368,7 +311,6 @@ public class GraphManager {
|
|
public void setCurrentPath(String currentPath) {
|
|
public void setCurrentPath(String currentPath) {
|
|
this.currentPath = currentPath;
|
|
this.currentPath = currentPath;
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Adds a <b>Copy</b> of the given Edge to the graph. The Copy retains the
|
|
* Adds a <b>Copy</b> of the given Edge to the graph. The Copy retains the
|
|
* ID and all attributes.
|
|
* ID and all attributes.
|
|
@@ -378,26 +320,12 @@ public class GraphManager {
|
|
*/
|
|
*/
|
|
public void addEdge(Edge e) {
|
|
public void addEdge(Edge e) {
|
|
HashMap<String, Object> attributes = new HashMap<>();
|
|
HashMap<String, Object> attributes = new HashMap<>();
|
|
-
|
|
|
|
for (String s : e.getAttributeKeySet()) {
|
|
for (String s : e.getAttributeKeySet()) {
|
|
attributes.put(s, e.getAttribute(s));
|
|
attributes.put(s, e.getAttribute(s));
|
|
}
|
|
}
|
|
-
|
|
|
|
- Node sourceNode = e.getSourceNode();
|
|
|
|
- Node targetNode = e.getTargetNode();
|
|
|
|
-
|
|
|
|
- if (graphToAddTo.getNode(sourceNode.getId()) != null && graphToAddTo.getNode(targetNode.getId()) != null) {
|
|
|
|
- g.addEdge(e.getId(), (Node) e.getSourceNode(), (Node) e.getTargetNode());
|
|
|
|
- g.getEdge(e.getId()).addAttributes(attributes);
|
|
|
|
- if (graphToAddTo != g) {
|
|
|
|
- graphToAddTo.addEdge(e.getId(), (Node) e.getSourceNode(), (Node) e.getTargetNode());
|
|
|
|
- graphToAddTo.getEdge(e.getId()).addAttributes(attributes);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- Debug.out("Trying to create an Edge where both nodes do not belong to the same subgraph!", 2);
|
|
|
|
- }
|
|
|
|
|
|
+ g.addEdge(e.getId(), (Node) e.getSourceNode(), (Node) e.getTargetNode());
|
|
|
|
+ g.getEdge(e.getId()).addAttributes(attributes);
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Adds a <b>Copy</b> of the given Node to the graph. The Copy retains the
|
|
* Adds a <b>Copy</b> of the given Node to the graph. The Copy retains the
|
|
* ID and all attributes.
|
|
* ID and all attributes.
|
|
@@ -407,54 +335,56 @@ public class GraphManager {
|
|
*/
|
|
*/
|
|
public void addNode(Node n) {
|
|
public void addNode(Node n) {
|
|
HashMap<String, Object> attributes = new HashMap<>();
|
|
HashMap<String, Object> attributes = new HashMap<>();
|
|
-
|
|
|
|
for (String s : n.getAttributeKeySet()) {
|
|
for (String s : n.getAttributeKeySet()) {
|
|
- attributes.put(s, n.getAttribute(s));
|
|
|
|
|
|
+ attributes.put(s, deletedNode.getAttribute(s));
|
|
}
|
|
}
|
|
g.addNode(n.getId());
|
|
g.addNode(n.getId());
|
|
g.getNode(n.getId()).addAttributes(attributes);
|
|
g.getNode(n.getId()).addAttributes(attributes);
|
|
- if (graphToAddTo != g) {
|
|
|
|
- graphToAddTo.addNode(n.getId());
|
|
|
|
- graphToAddTo.getNode(n.getId()).addAttributes(attributes);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Returns the smallest X Coordinate of any Node in the Graph.
|
|
* Returns the smallest X Coordinate of any Node in the Graph.
|
|
*
|
|
*
|
|
* @return the smallest X Coordinate in the Graph
|
|
* @return the smallest X Coordinate in the Graph
|
|
|
|
+ * @deprecated Use
|
|
|
|
+ * {@link de.tu_darmstadt.informatik.tk.scopviz.graphs.MyGraph#getMinX()}
|
|
|
|
+ * instead
|
|
*/
|
|
*/
|
|
public double getMinX() {
|
|
public double getMinX() {
|
|
return g.getMinX();
|
|
return g.getMinX();
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Returns the biggest X Coordinate of any Node in the Graph.
|
|
* Returns the biggest X Coordinate of any Node in the Graph.
|
|
*
|
|
*
|
|
* @return the biggest X Coordinate in the Graph
|
|
* @return the biggest X Coordinate in the Graph
|
|
|
|
+ * @deprecated Use
|
|
|
|
+ * {@link de.tu_darmstadt.informatik.tk.scopviz.graphs.MyGraph#getMaxX()}
|
|
|
|
+ * instead
|
|
*/
|
|
*/
|
|
public double getMaxX() {
|
|
public double getMaxX() {
|
|
return g.getMaxX();
|
|
return g.getMaxX();
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Returns the smallest Y Coordinate of any Node in the Graph.
|
|
* Returns the smallest Y Coordinate of any Node in the Graph.
|
|
*
|
|
*
|
|
* @return the smallest Y Coordinate in the Graph
|
|
* @return the smallest Y Coordinate in the Graph
|
|
|
|
+ * @deprecated Use
|
|
|
|
+ * {@link de.tu_darmstadt.informatik.tk.scopviz.graphs.MyGraph#getMinY()}
|
|
|
|
+ * instead
|
|
*/
|
|
*/
|
|
public double getMinY() {
|
|
public double getMinY() {
|
|
return g.getMinY();
|
|
return g.getMinY();
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Returns the biggest Y Coordinate of any Node in the Graph.
|
|
* Returns the biggest Y Coordinate of any Node in the Graph.
|
|
*
|
|
*
|
|
* @return the biggest Y Coordinate in the Graph
|
|
* @return the biggest Y Coordinate in the Graph
|
|
|
|
+ * @deprecated Use
|
|
|
|
+ * {@link de.tu_darmstadt.informatik.tk.scopviz.graphs.MyGraph#getMaxY()}
|
|
|
|
+ * instead
|
|
*/
|
|
*/
|
|
public double getMaxY() {
|
|
public double getMaxY() {
|
|
return g.getMaxY();
|
|
return g.getMaxY();
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Returns the Stylesheet used by the Graph.
|
|
* Returns the Stylesheet used by the Graph.
|
|
*
|
|
*
|
|
@@ -463,7 +393,6 @@ public class GraphManager {
|
|
public String getStylesheet() {
|
|
public String getStylesheet() {
|
|
return stylesheet;
|
|
return stylesheet;
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Sets the Stylesheet to be used by the Graph.
|
|
* Sets the Stylesheet to be used by the Graph.
|
|
*
|
|
*
|
|
@@ -479,7 +408,6 @@ public class GraphManager {
|
|
.concat(StylesheetManager.getLayerStyle((Layer) g.getAttribute("layer")));
|
|
.concat(StylesheetManager.getLayerStyle((Layer) g.getAttribute("layer")));
|
|
g.addAttribute("ui.stylesheet", completeStylesheet);
|
|
g.addAttribute("ui.stylesheet", completeStylesheet);
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* adds the given listener to the underlying graph the listener will be
|
|
* adds the given listener to the underlying graph the listener will be
|
|
* notified, when an Edge is added.
|
|
* notified, when an Edge is added.
|
|
@@ -490,7 +418,6 @@ public class GraphManager {
|
|
public void addEdgeCreatedListener(EdgeCreatedListener e) {
|
|
public void addEdgeCreatedListener(EdgeCreatedListener e) {
|
|
((MyGraph) g).addEdgeCreatedListener(e);
|
|
((MyGraph) g).addEdgeCreatedListener(e);
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* adds the given listener to the underlying graph the listener will be
|
|
* adds the given listener to the underlying graph the listener will be
|
|
* notified, when a Node is added.
|
|
* notified, when a Node is added.
|
|
@@ -501,14 +428,12 @@ public class GraphManager {
|
|
public void addNodeCreatedListener(NodeCreatedListener n) {
|
|
public void addNodeCreatedListener(NodeCreatedListener n) {
|
|
((MyGraph) g).addNodeCreatedListener(n);
|
|
((MyGraph) g).addNodeCreatedListener(n);
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Updates the Stylesheet, causing any changes to it to come into effect.
|
|
* Updates the Stylesheet, causing any changes to it to come into effect.
|
|
*/
|
|
*/
|
|
public void updateStylesheet() {
|
|
public void updateStylesheet() {
|
|
setStylesheet(this.stylesheet);
|
|
setStylesheet(this.stylesheet);
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Sets typeofNode as the ui.class of all Nodes.
|
|
* Sets typeofNode as the ui.class of all Nodes.
|
|
*
|
|
*
|
|
@@ -521,7 +446,6 @@ public class GraphManager {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Create Edges based on CreateMode.
|
|
* Create Edges based on CreateMode.
|
|
*
|
|
*
|
|
@@ -547,7 +471,6 @@ public class GraphManager {
|
|
}
|
|
}
|
|
PropertiesManager.setItemsProperties();
|
|
PropertiesManager.setItemsProperties();
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* creates a edge between two nodes.
|
|
* creates a edge between two nodes.
|
|
*
|
|
*
|
|
@@ -562,30 +485,16 @@ public class GraphManager {
|
|
if (getGraph().getNode(from).hasEdgeBetween(to))
|
|
if (getGraph().getNode(from).hasEdgeBetween(to))
|
|
return false;
|
|
return false;
|
|
String newID = Main.getInstance().getUnusedID();
|
|
String newID = Main.getInstance().getUnusedID();
|
|
- boolean isDirected = (Main.getInstance().getCreationMode() == CreationMode.CREATE_DIRECTED_EDGE);
|
|
|
|
-
|
|
|
|
- if (graphToAddTo.getNode(from) != null && graphToAddTo.getNode(to) != null) {
|
|
|
|
- g.addEdge(newID, from, to, isDirected);
|
|
|
|
- if (graphToAddTo != g) {
|
|
|
|
- graphToAddTo.addEdge(newID, from, to, isDirected);
|
|
|
|
- }
|
|
|
|
|
|
+ if (Main.getInstance().getCreationMode() == CreationMode.CREATE_DIRECTED_EDGE) {
|
|
|
|
+ getGraph().addEdge(newID, from, to, true);
|
|
|
|
+ Debug.out("Created an directed edge with Id " + newID + " between " + from + " and " + to);
|
|
} else {
|
|
} else {
|
|
- Debug.out("Trying to create an Edge where both nodes do not belong to the same subgraph!", 2);
|
|
|
|
|
|
+ getGraph().addEdge(newID, from, to);
|
|
|
|
+ Debug.out("Created an undirected edge with Id " + newID + " between " + from + " and " + to);
|
|
}
|
|
}
|
|
- /*
|
|
|
|
- * if (Main.getInstance().getCreationMode() ==
|
|
|
|
- * CreationMode.CREATE_DIRECTED_EDGE) { getGraph().addEdge(newID, from,
|
|
|
|
- * to, true); Debug.out("Created an directed edge with Id " + newID +
|
|
|
|
- * " between " + from + " and " + to); } else {
|
|
|
|
- * getGraph().addEdge(newID, from, to);
|
|
|
|
- * Debug.out("Created an undirected edge with Id " + newID + " between "
|
|
|
|
- * + from + " and " + to); }
|
|
|
|
- */
|
|
|
|
selectEdge(newID);
|
|
selectEdge(newID);
|
|
-
|
|
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Selects a Node as the starting point for creating a new Edge.
|
|
* Selects a Node as the starting point for creating a new Edge.
|
|
*
|
|
*
|
|
@@ -600,9 +509,8 @@ public class GraphManager {
|
|
}
|
|
}
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
- * Reset the Selection of the Node after Edge has been successfully created.
|
|
|
|
|
|
+ * Reset the Selection of the Node after Edge has been suddenly created.
|
|
*
|
|
*
|
|
* @param nodeID
|
|
* @param nodeID
|
|
* the Id of the node to deselect.
|
|
* the Id of the node to deselect.
|
|
@@ -617,7 +525,6 @@ public class GraphManager {
|
|
n.changeAttribute("ui.style", "fill-color: #000000; size: 15px;");
|
|
n.changeAttribute("ui.style", "fill-color: #000000; size: 15px;");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Resets the selction of the Node for Edge selection
|
|
* Resets the selction of the Node for Edge selection
|
|
*/
|
|
*/
|
|
@@ -626,7 +533,6 @@ public class GraphManager {
|
|
deselectNodesAfterEdgeCreation(lastClickedID);
|
|
deselectNodesAfterEdgeCreation(lastClickedID);
|
|
lastClickedID = null;
|
|
lastClickedID = null;
|
|
}
|
|
}
|
|
-
|
|
|
|
protected boolean addClass(String id, String className) {
|
|
protected boolean addClass(String id, String className) {
|
|
Element e = getGraph().getEdge(id);
|
|
Element e = getGraph().getEdge(id);
|
|
if (e == null)
|
|
if (e == null)
|
|
@@ -639,12 +545,10 @@ public class GraphManager {
|
|
else if (!(eClass.equals(className) || eClass.startsWith(className.concat(", "))
|
|
else if (!(eClass.equals(className) || eClass.startsWith(className.concat(", "))
|
|
|| eClass.contains(", ".concat(className))))
|
|
|| eClass.contains(", ".concat(className))))
|
|
eClass = className.concat(", ").concat(eClass);
|
|
eClass = className.concat(", ").concat(eClass);
|
|
-
|
|
|
|
e.addAttribute("ui.class", eClass);
|
|
e.addAttribute("ui.class", eClass);
|
|
Debug.out("added " + className + ": " + eClass);
|
|
Debug.out("added " + className + ": " + eClass);
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
-
|
|
|
|
protected boolean removeClass(String id, String className) {
|
|
protected boolean removeClass(String id, String className) {
|
|
Element e = getGraph().getEdge(id);
|
|
Element e = getGraph().getEdge(id);
|
|
if (e == null)
|
|
if (e == null)
|
|
@@ -656,12 +560,10 @@ public class GraphManager {
|
|
eClass = "";
|
|
eClass = "";
|
|
else
|
|
else
|
|
eClass = eClass.replace(className.concat(", "), "").replace(", ".concat(className), "");
|
|
eClass = eClass.replace(className.concat(", "), "").replace(", ".concat(className), "");
|
|
-
|
|
|
|
e.addAttribute("ui.class", eClass);
|
|
e.addAttribute("ui.class", eClass);
|
|
Debug.out("removed " + className + ": " + eClass);
|
|
Debug.out("removed " + className + ": " + eClass);
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
-
|
|
|
|
protected boolean toggleClass(String id, String className) {
|
|
protected boolean toggleClass(String id, String className) {
|
|
Element e = getGraph().getEdge(id);
|
|
Element e = getGraph().getEdge(id);
|
|
if (e == null)
|
|
if (e == null)
|
|
@@ -674,7 +576,6 @@ public class GraphManager {
|
|
return addClass(id, className);
|
|
return addClass(id, className);
|
|
return removeClass(id, className);
|
|
return removeClass(id, className);
|
|
}
|
|
}
|
|
-
|
|
|
|
protected boolean hasClass(String id, String className) {
|
|
protected boolean hasClass(String id, String className) {
|
|
Element e = getGraph().getEdge(id);
|
|
Element e = getGraph().getEdge(id);
|
|
if (e == null)
|
|
if (e == null)
|
|
@@ -685,7 +586,6 @@ public class GraphManager {
|
|
return (eClass != null && (eClass.equals(className) || eClass.startsWith(className.concat(", "))
|
|
return (eClass != null && (eClass.equals(className) || eClass.startsWith(className.concat(", "))
|
|
|| eClass.contains(", ".concat(className))));
|
|
|| eClass.contains(", ".concat(className))));
|
|
}
|
|
}
|
|
-
|
|
|
|
protected boolean hasClass(Edge e, String className) {
|
|
protected boolean hasClass(Edge e, String className) {
|
|
if (e == null)
|
|
if (e == null)
|
|
return false;
|
|
return false;
|
|
@@ -693,7 +593,6 @@ public class GraphManager {
|
|
return (eClass != null && (eClass.equals(className) || eClass.startsWith(className.concat(", "))
|
|
return (eClass != null && (eClass.equals(className) || eClass.startsWith(className.concat(", "))
|
|
|| eClass.contains(", ".concat(className))));
|
|
|| eClass.contains(", ".concat(className))));
|
|
}
|
|
}
|
|
-
|
|
|
|
protected boolean hasClass(Node n, String className) {
|
|
protected boolean hasClass(Node n, String className) {
|
|
if (n == null)
|
|
if (n == null)
|
|
return false;
|
|
return false;
|
|
@@ -707,4 +606,4 @@ public class GraphManager {
|
|
*/
|
|
*/
|
|
return (nClass != null && nClass.contains(className));
|
|
return (nClass != null && nClass.contains(className));
|
|
}
|
|
}
|
|
-}
|
|
|
|
|
|
+}
|