Search this API

y.view
Class Graph2D

java.lang.Object
  extended by y.base.Graph
      extended by y.layout.LayoutGraph
          extended by y.view.Graph2D
All Implemented Interfaces:
GraphInterface, GraphLayout

public class Graph2D
extends LayoutGraph

This class represents a graph with additional 2D support. It can be displayed within a Graph2DView. The visual representation of nodes and edges are encapsulated in so called realizer objects. A node in this graph has a NodeRealizer object associated with it and an edge in this graph has a EdgeRealizer object associated with it.

All geometric or visual changes that are performed to this graph result in an attribute or type change of an associated realizer. If nodes or edges get newly created in this graph then a default node or edge realizer will be automatically associated with these elements. To change the default appearance of edges or nodes one can assign different default realizers to the graph by using the methods setDefaultEdgeRealizer(EdgeRealizer) and setDefaultNodeRealizer(NodeRealizer).

 

Nested Class Summary
static interface Graph2D.BackupRealizersHandler
          Implementations of this interface are responsible for backing up the node and edge realizer of a Graph2D.
 
Field Summary
static int REVERSE_ALL
          Feature flag for adjusting all visual features when reversing an edge.
static int REVERSE_ARROWS
          Feature flag for reversing arrows after reversing an edge.
static int REVERSE_EDGE_LABELS
          Feature flag for adjusting edge label model parameters after reversing an edge.
static int REVERSE_NODE_PORTS
          Feature flag for reversing node port bindings after reversing an edge.
static int REVERSE_NONE
          Feature flag for adjusting no visual features when reversing an edge.
static int REVERSE_PATH
          Feature flag for reversing the geometry of an edge path after reversing an edge.
 
Fields inherited from class y.base.Graph
AFTER, BEFORE
 
Constructor Summary
Graph2D()
          Constructs an empty Graph2D.
Graph2D(Graph2D graph)
          Copy constructor of Graph2D.
Graph2D(Graph2D graph, YCursor nodeSubset)
          Creates a copy of the given subgraph.
 
Method Summary
 void addDrawable(Drawable d)
          Adds a drawable to this graph.
 void addGraph2DListener(Graph2DListener listener)
          Adds the given Graph2DListener to this graph.
 void addGraph2DSelectionListener(Graph2DSelectionListener listener)
          Adds the given Graph2DSelectionListener to this graph.
 void backupRealizers()
          A method that supports undoability of the changes performed on node and edge realizers.
 void backupRealizers(EdgeCursor ec)
          A method that supports undoability of the changes performed on the edge realizers associated with the given edges.
 void backupRealizers(NodeCursor nc)
          A method that supports undoability of the changes performed on the node realizers associated with the given nodes.
 BendCursor bends()
          Returns a bend cursor over all bends in this graph.
 void changeEdge(Edge e, Node newSource, Edge sourceReference, int sourceD, Node newTarget, Edge targetReference, int targetD)
          Redefines an edge's end points and fires corresponding notification events to inform registered listeners.
 void changeEdge(Edge e, Node newSource, Node newTarget)
          Redefines an edge's end points and fires corresponding notification events to inform registered listeners.
 Graph createCopy()
          Creates a copy of this graph.
 Edge createEdge(Node v, Edge e1, Node w, Edge e2, int d1, int d2)
          Creates a new edge in this graph to be ordered before or after a given edge.
 Edge createEdge(Node v, Edge e1, Node w, Edge e2, int d1, int d2, EdgeRealizer r)
          Creates a new edge in this graph that is bound to the given edge realizer and ordered before or after a given edge.
 Edge createEdge(Node v, Node w)
          Creates a new edge from node v to node w.
 Edge createEdge(Node v, Node w, EdgeRealizer r)
          Creates a new edge from node v to node w.
 Graph createGraph()
          Creates an empty view of the same type as this graph.
protected  GraphCopier.CopyFactory createGraphCopyFactory()
          Creates and returns a new instance of Graph2DCopyFactory.HierarchicGraph2DCopyFactory
protected  LabelLayoutFactory createLabelFactory()
          Creates a new label layout factory for this graph.
 Node createNode()
          Creates a new node.
 Node createNode(double x, double y)
          Creates a new node with center location (x,y).
 Node createNode(double x, double y, double w, double h, java.lang.String label)
          Creates a new node with center location (x,y), dimension (w,h) and the given label text.
 Node createNode(double x, double y, java.lang.String label)
          Creates a new node with center location (x,y) and the given label text.
 Node createNode(NodeRealizer r)
          Creates a new node in this graph.
 YCursor drawables()
          Returns a cursor iterating over all Drawables known to this graph.
 void fireGraph2DEvent(java.lang.Object subject, java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)
          Fires a Graph2DEvent
 void fireGraph2DSelectionEvent(java.lang.Object subject)
          Fires a GraphSelectionEvent for the given subject
 void fitGraph2DView()
          Invokes fitContent() on the current view, if the current view is of type Graph2DView.
 Graph2D.BackupRealizersHandler getBackupRealizersHandler()
          Returns the handler for backupRealizer method calls.
 java.awt.Rectangle getBoundingBox()
          Returns the bounding box of this graph.
 java.awt.Rectangle getBoundingBox(byte layer)
          Returns the bounding box of all graph objects residing in the specified layer.
 double getCenterX(Node v)
          Returns the center x-coordinate of the given node.
 double getCenterY(Node v)
          Returns the center y-coordinate of the given node.
 View getCurrentView()
          Returns the current view.
 EdgeRealizer getDefaultEdgeRealizer()
          Returns the default edge realizer.
 NodeRealizer getDefaultNodeRealizer()
          Returns the default node realizer.
 Edge getFeature(EdgeLabelLayout labelLayout)
          Returns the node which is described by a given label layout.
 Node getFeature(NodeLabelLayout labelLayout)
          Returns the node which is described by a given label layout.
 java.util.Iterator getGraph2DListeners()
          Returns an iterator that grants access to all registered Graph2DListeners
 java.util.Iterator getGraph2DSelectionListeners()
          Returns an iterator that grants access to all registered Graph2DSelectionListeners
 double getHeight(Node v)
          Returns the height of the given node.
 HierarchyManager getHierarchyManager()
          Returns the HierarchyManager instance that manages this graph, or null if the graph is not part of any graph hierarchy.
 HitInfo getHitInfo(double x, double y)
          Deprecated. Use HitInfo's various constructors directly for control over the hit test order.
 HitInfo getHitInfo(double x, double y, boolean firstHitOnly)
          Deprecated. Use HitInfo's various constructors directly for control over the hit test order.
 EdgeLabelLayout[] getLabelLayout(Edge edge)
          Returns EdgeLabelLayout objects which describe the layouts of the labels that belong to the given edge.
 NodeLabelLayout[] getLabelLayout(Node node)
          Returns NodeLabelLayout objects which describe the layouts of the labels that belong to the given node.
 java.lang.String getLabelText(Edge e)
          Returns the label text for the given edge.
 java.lang.String getLabelText(Node v)
          Returns the label text for the given node.
 EdgeLayout getLayout(Edge edge)
          Returns the layout information for an edge in the drawing.
 NodeLayout getLayout(Node node)
          Returns the layout information for a node in the drawing.
 EdgeRealizer getRealizer(Edge e)
          Returns the edge realizer that is bound to the given edge.
 NodeRealizer getRealizer(Node v)
          Returns the node realizer that is bound to the given node.
 java.net.URL getURL()
          Returns the URL associated with this graph.
 YCursor getViews()
          Returns a cursor iterating through all registered views.
 double getWidth(Node v)
          Returns the width of the given node.
 double getX(Node v)
          Returns the upper left x-coordinate of the given node.
 double getY(Node v)
          Returns the upper left y-coordinate of the given node.
 boolean isSelected(Bend bend)
          Returns the selection state of the given bend.
 boolean isSelected(Edge e)
          Returns the selection state of the given edge.
 boolean isSelected(Node v)
          Returns the selection state of the given node.
 boolean isSelected(NodePort port)
          Returns the selection state of the given node port.
 boolean isSelected(YLabel label)
          Returns the selection state of the given label.
 boolean isSelectionEmpty()
          Returns true iff neither edges nor nodes nor bends nor labels nor node ports in this graph are selected.
 boolean isSelectionSingleton()
          Returns true if and only if exactly one node or one bend is selected and false otherwise.
 void moveBends(BendCursor bc, double dx, double dy)
          Moves the given bends by (dx,dy).
 void moveNodes(NodeCursor nc, double dx, double dy)
          Moves the given nodes by (dx,dy).
 void registerView(View v)
          Adds this view to the set of views that display this graph.
 void removeDrawable(Drawable d)
          Removes the given drawable from this graph.
 void removeGraph2DListener(Graph2DListener listener)
          Removes the given Graph2DListener from this graph.
 void removeGraph2DSelectionListener(Graph2DSelectionListener listener)
          Removes the given Graph2DSelectionListener from this graph.
 void removeSelection()
          Removes all selected objects from this graph.
 void removeView(View v)
          Removes this view from the set of views that display this graph.
 void reverseEdge(Edge edge, int featureMask)
          Reverses the given edge and adjusts its geometry and visual features accordingly.
 void selectAllNodesAndBends(boolean s)
          Sets the selection state for all nodes and bends.
 void selectBoxContent(double x, double y, double width, double height)
          Selects the graph objects in a rectangle defined by the given arguments.
 void selectBoxContent(java.awt.Rectangle r)
          Selects the graph objects in given rectangle.
 BendCursor selectedBends()
          Returns a bend cursor for all momentarily selected bends in this graph.
 EdgeCursor selectedEdges()
          Returns an edge cursor for all momentarily selected edges in this graph.
 YCursor selectedLabels()
          Returns a YCursor for all momentarily selected labels in this graph.
 NodeCursor selectedNodes()
          Returns a node cursor for all momentarily selected nodes in this graph.
 void setBackupRealizersHandler(Graph2D.BackupRealizersHandler brh)
          Sets the delegate class that is responsible for acting upon calls to the methods backupRealizers(EdgeCursor) and backupRealizers(NodeCursor).
 void setBendsSelected(BendCursor bc, boolean s)
          Sets the selection state for the given bends.
 void setBendsSelected(Edge e, boolean s)
          Sets the selection state for the bends given by the edge.
 void setBendsSelected(EdgeCursor ec, boolean s)
          Sets the selection state for the bends given by the edges.
 void setCenter(Node v, double x, double y)
          Sets the center coordinates of the given node.
 void setCurrentView(View view)
          Sets the current view.
 void setDefaultEdgeRealizer(EdgeRealizer r)
          Sets the default edge realizer.
 void setDefaultNodeRealizer(NodeRealizer r)
          Sets the default node realizer.
 void setHierarchyManager(HierarchyManager hierarchyManager)
          Sets the HierarchyManager instance that manages this graph.
 void setLabelText(Edge e, java.lang.String text)
          Sets the given label text for the given edge.
 void setLabelText(Node v, java.lang.String text)
          Sets the given label text for the given node.
 void setLayerAll(byte layer)
          Sets the layer for all bound node and edge realizers of this graph.
 java.awt.Rectangle setLocation(double x, double y)
          Moves the entire graph to some location.
 void setLocation(Node v, double x, double y)
          Sets the upper left coordinates of the given node.
 void setRealizer(Edge e, EdgeRealizer r)
          Sets the edge realizer for the given edge.
 void setRealizer(Node v, NodeRealizer r)
          Sets the node realizer for the given node.
 void setSelected(Bend bend, boolean s)
          Sets the selected state for the given bend.
 void setSelected(Edge e, boolean s)
          Sets the selected state for the given edge.
 void setSelected(EdgeCursor edges, boolean s)
          Sets the selection state for the given edges.
 void setSelected(Node v, boolean s)
          Sets the selection state for the given node.
 void setSelected(NodeCursor nodes, boolean s)
          Sets the selection state for the given nodes.
 void setSelected(NodePort port, boolean s)
          Sets the selected state for the given node port.
 void setSelected(YLabel label, boolean s)
          Sets the selected state for the given label.
 void setSize(Node v, double w, double h)
          Sets the size of the given node.
 void setURL(java.net.URL url)
          Sets the URL of this Graph2D.
 void unselectAll()
          Deselects all nodes, edges, bends, labels, and node ports in this graph.
 void unselectBends()
          Deselects all bends in this graph.
 void unselectEdges()
          Deselects all edges in this graph.
 void unselectLabels()
          Deselects all labels in this graph.
 void unselectNodePorts()
          Deselects all node ports in this graph.
 void unselectNodes()
          Deselects all nodes in this graph.
 void updateViews()
          Calls updateView on all registered views.
 void updateViews(double x, double y, double w, double h)
          Calls View.updateView(double, double, double, double) on all registered views.
 
Methods inherited from class y.layout.LayoutGraph
getCenter, getEdgeLabelLayout, getEdgeLayout, getEdgeList, getLocation, getNodeLabelLayout, getNodeLayout, getPath, getPathList, getPointList, getPoints, getRectangle, getSize, getSourcePointAbs, getSourcePointRel, getTargetPointAbs, getTargetPointRel, moveBy, setCenter, setEndPointsAbs, setLocation, setPath, setPath, setPoints, setPoints, setSize, setSourcePointAbs, setSourcePointRel, setTargetPointAbs, setTargetPointRel
 
Methods inherited from class y.base.Graph
addDataProvider, addGraphListener, changeEdge, clear, contains, contains, containsEdge, createEdgeMap, createNodeMap, disposeEdgeMap, disposeNodeMap, E, edgeCount, edgeObjects, edges, fireGraphEvent, firePostEvent, firePostEvent, firePreEvent, firePreEvent, firstEdge, firstNode, firstOutEdge, getDataProvider, getDataProviderKeys, getEdgeArray, getGraphCopyFactory, getGraphListeners, getNodeArray, getRegisteredEdgeMaps, getRegisteredNodeMaps, getSource, getTarget, hasListeners, hide, hide, isEmpty, lastEdge, lastNode, moveSubGraph, moveToFirst, moveToFirst, moveToLast, moveToLast, N, nodeCount, nodeObjects, nodes, printNodeSlotSize, reInsertEdge, reInsertNode, removeDataProvider, removeEdge, removeGraphListener, removeNode, reverseEdge, setGraphCopyFactory, sortEdges, sortEdges, sortNodes, toString, unhide, unhide
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

REVERSE_NONE

public static final int REVERSE_NONE
Feature flag for adjusting no visual features when reversing an edge.

See Also:
reverseEdge(y.base.Edge, int), Constant Field Values

REVERSE_PATH

public static final int REVERSE_PATH
Feature flag for reversing the geometry of an edge path after reversing an edge.

See Also:
reverseEdge(y.base.Edge, int), Constant Field Values

REVERSE_EDGE_LABELS

public static final int REVERSE_EDGE_LABELS
Feature flag for adjusting edge label model parameters after reversing an edge.

See Also:
reverseEdge(y.base.Edge, int), Constant Field Values

REVERSE_NODE_PORTS

public static final int REVERSE_NODE_PORTS
Feature flag for reversing node port bindings after reversing an edge. I.e. if this flag is set, the former source node port will become the new target node port and vice versa.

See Also:
reverseEdge(y.base.Edge, int), Constant Field Values

REVERSE_ARROWS

public static final int REVERSE_ARROWS
Feature flag for reversing arrows after reversing an edge. I.e. if this flag is set, the former source arrow will become the new target arrow and vice versa.

See Also:
reverseEdge(y.base.Edge, int), Constant Field Values

REVERSE_ALL

public static final int REVERSE_ALL
Feature flag for adjusting all visual features when reversing an edge.

See Also:
reverseEdge(y.base.Edge, int), Constant Field Values
Constructor Detail

Graph2D

public Graph2D()
Constructs an empty Graph2D.


Graph2D

public Graph2D(Graph2D graph)
Copy constructor of Graph2D.


Graph2D

public Graph2D(Graph2D graph,
               YCursor nodeSubset)
Creates a copy of the given subgraph.

Method Detail

createGraphCopyFactory

protected GraphCopier.CopyFactory createGraphCopyFactory()
Creates and returns a new instance of Graph2DCopyFactory.HierarchicGraph2DCopyFactory

Specified by:
createGraphCopyFactory in class LayoutGraph
Returns:
the factory that copies all elements of the graph

createCopy

public Graph createCopy()
Creates a copy of this graph. The returned graph can safely be cast to Graph2D.

Overrides:
createCopy in class Graph
Returns:
a copy of this graph.

createGraph

public Graph createGraph()
Creates an empty view of the same type as this graph. Thus the returned graph can safely be cast to Graph2D.

Overrides:
createGraph in class Graph
Returns:
an empty Graph2D.

changeEdge

public void changeEdge(Edge e,
                       Node newSource,
                       Edge sourceReference,
                       int sourceD,
                       Node newTarget,
                       Edge targetReference,
                       int targetD)
Description copied from class: Graph
Redefines an edge's end points and fires corresponding notification events to inform registered listeners. Edge e has source node v := sourceReference.source() or v := newSource, if sourceReference == null and target node w := targetReference.target() or w := newTarget, if targetReference == null.

Edge e is inserted in such a way that an iteration over the edges at v returns e and an iteration over the edges at w returns e

Overrides:
changeEdge in class Graph
Parameters:
e - The edge to be changed.
newSource - The new source node.
sourceReference - Reference edge for insertion at the new source node.
sourceD - One of the object insertion specifiers Graph.BEFORE or Graph.AFTER.
newTarget - The new target node.
targetReference - Reference edge for insertion at the new target node.
targetD - One of the object insertion specifiers Graph.BEFORE or Graph.AFTER.

changeEdge

public void changeEdge(Edge e,
                       Node newSource,
                       Node newTarget)
Description copied from class: Graph
Redefines an edge's end points and fires corresponding notification events to inform registered listeners.

The edge is appended to the lists of incoming and outgoing edges at the given source node and target node, respectively.

Overrides:
changeEdge in class Graph
Parameters:
e - The edge to be changed.
newSource - The new source node of the given edge.
newTarget - The new target node of the given edge.

reverseEdge

public void reverseEdge(Edge edge,
                        int featureMask)
Reverses the given edge and adjusts its geometry and visual features accordingly.

Note, if REVERSE_NODE_PORTS is not set, this method explicitly removes current node port bindings .

Note, this method constitutes both a structural and a visual change. This means client code needs to explicitly call Graph.firePreEvent() and backupRealizers(y.base.EdgeCursor) before and Graph.firePostEvent() after reversing edges to properly support undo/redo.

Calls Graph.reverseEdge(y.base.Edge) for the required structural reversal of the given edge. This means that the former method's GraphEvent.POST_EDGE_CHANGE event is fired before any visual adjustments are applied by this method.

Parameters:
edge - the edge to reverse.
featureMask - a bit wise combination of the feature flags that specifies the visual features to adjust.
See Also:
Graph.reverseEdge(y.base.Edge), REVERSE_NONE, REVERSE_PATH, REVERSE_EDGE_LABELS, REVERSE_NODE_PORTS, REVERSE_ARROWS, REVERSE_ALL

setHierarchyManager

public void setHierarchyManager(HierarchyManager hierarchyManager)
Sets the HierarchyManager instance that manages this graph. This method will be invoked by HierarchyManager whenever this graph gets part of its hierarchy. There should be no need for users to set the HierarchyManager directly.


getHierarchyManager

public HierarchyManager getHierarchyManager()
Returns the HierarchyManager instance that manages this graph, or null if the graph is not part of any graph hierarchy.


createEdge

public Edge createEdge(Node v,
                       Node w)
Creates a new edge from node v to node w.

A copy of the default edge realizer will be bound to the newly created edge.

Overrides:
createEdge in class Graph
Parameters:
v - The source node of the edge.
w - The target node of the edge.
Returns:
the newly created edge.
See Also:
createEdge(y.base.Node, y.base.Node, EdgeRealizer), getDefaultEdgeRealizer()

createEdge

public Edge createEdge(Node v,
                       Node w,
                       EdgeRealizer r)
Creates a new edge from node v to node w. The given edge realizer will be bound to the new edge.

Parameters:
v - the source node of the edge
w - the target node of the edge
r - the edge realizer that will be bound to the new edge.
Returns:
newly created edge.

createEdge

public Edge createEdge(Node v,
                       Edge e1,
                       Node w,
                       Edge e2,
                       int d1,
                       int d2)
Creates a new edge in this graph to be ordered before or after a given edge. The new edge e has source node v and target node w, i.e., e = (v, w).

The new edge e is inserted in such a way that an iteration over the edges at node v returns e

and an iteration over the edges at w returns e

A copy of the default edge realizer will be bound to the newly created edge.

Overrides:
createEdge in class Graph
Precondition:
Edge e1 must have source node v and edge e2 must have target node w.
Parameters:
v - The source node of the edge.
e1 - An edge with source node v.
w - The target node of the edge.
e2 - An edge with target node w.
d1 - One of the object insertion specifiers Graph.BEFORE or Graph.AFTER.
d2 - One of the object insertion specifiers Graph.BEFORE or Graph.AFTER.
Returns:
The newly created edge.
See Also:
createEdge(y.base.Node, y.base.Edge, y.base.Node, y.base.Edge, int, int, EdgeRealizer), getDefaultEdgeRealizer()

createEdge

public Edge createEdge(Node v,
                       Edge e1,
                       Node w,
                       Edge e2,
                       int d1,
                       int d2,
                       EdgeRealizer r)
Creates a new edge in this graph that is bound to the given edge realizer and ordered before or after a given edge. The new edge e has source node v and target node w, i.e., e = (v, w).

The new edge e is inserted in such a way that an iteration over the edges at node v returns e

and an iteration over the edges at w returns e

All other edge creation methods of this graph will eventually call this method.

Precondition:
Edge e1 must have source node v and edge e2 must have target node w.
Parameters:
v - The source node of the edge.
e1 - An edge with source node v.
w - The target node of the edge.
e2 - An edge with target node w.
d1 - One of the object insertion specifiers Graph.BEFORE or Graph.AFTER.
d2 - One of the object insertion specifiers Graph.BEFORE or Graph.AFTER.
r - The edge realizer that will be bound to the new edge.
Returns:
The newly created edge.

createNode

public Node createNode()
Creates a new node.

A copy of the default node realizer will be bound to the new node.

Overrides:
createNode in class Graph
Returns:
the newly created node.
See Also:
createNode(NodeRealizer), getDefaultNodeRealizer()

createNode

public Node createNode(double x,
                       double y)
Creates a new node with center location (x,y). The default node realizer defines all other properties of this node.

Parameters:
x - the X-coordinate of the node's center.
y - the Y-coordinate of the node's center.
Returns:
the newly created node.
See Also:
createNode(NodeRealizer), getDefaultNodeRealizer()

createNode

public Node createNode(double x,
                       double y,
                       java.lang.String label)
Creates a new node with center location (x,y) and the given label text. The default node realizer defines all other properties of this node.

Parameters:
x - the X-coordinate of the node's center.
y - the Y-coordinate of the node's center.
label - the node's initial label text.
Returns:
the newly created node.
See Also:
createNode(NodeRealizer), getDefaultNodeRealizer()

createNode

public Node createNode(double x,
                       double y,
                       double w,
                       double h,
                       java.lang.String label)
Creates a new node with center location (x,y), dimension (w,h) and the given label text. The default node realizer defines all other properties of this node.

Parameters:
x - the X-coordinate of the node's center.
y - the Y-coordinate of the node's center.
w - the width of the node.
h - the height of the node.
label - the node's initial label text.
Returns:
the newly created node.
See Also:
createNode(NodeRealizer), getDefaultNodeRealizer()

createNode

public Node createNode(NodeRealizer r)
Creates a new node in this graph. The given node realizer will be bound to the new node.

Parameters:
r - the node realizer that will be bound to the new node.
Returns:
newly created Node object

getBoundingBox

public java.awt.Rectangle getBoundingBox()
Returns the bounding box of this graph. The bounding box of a Graph2D is the smallest rectangle that contains all visual representation of the graph given by its edge and node realizers.

If this graph is empty a rectangle with negative width and height will be returned.

Specified by:
getBoundingBox in interface GraphLayout
Overrides:
getBoundingBox in class LayoutGraph
Returns:
the bounds of the graph

getBoundingBox

public java.awt.Rectangle getBoundingBox(byte layer)
Returns the bounding box of all graph objects residing in the specified layer.


setLayerAll

public void setLayerAll(byte layer)
Sets the layer for all bound node and edge realizers of this graph.


setLocation

public java.awt.Rectangle setLocation(double x,
                                      double y)
Moves the entire graph to some location. This method moves all realizer coordinates in such a way that the resulting bounding box of this graph has upper left coordinates (x,y).

Returns:
resulting bounding box of this graph

bends

public BendCursor bends()
Returns a bend cursor over all bends in this graph.

Returns:
BendCursor over all bends in this graph

setDefaultNodeRealizer

public void setDefaultNodeRealizer(NodeRealizer r)
Sets the default node realizer. A copy of this realizer will be bound to a newly created node if no other realizer is given explicitly.

See Also:
getDefaultNodeRealizer()

setDefaultEdgeRealizer

public void setDefaultEdgeRealizer(EdgeRealizer r)
Sets the default edge realizer. A copy of this realizer will be bound to a newly created edge if no other realizer is given explicitly.

See Also:
getDefaultEdgeRealizer()

getDefaultNodeRealizer

public NodeRealizer getDefaultNodeRealizer()
Returns the default node realizer. A copy of this realizer will be bound to a newly created node if no other realizer is given explicitly.

See Also:
setDefaultNodeRealizer(NodeRealizer)

getDefaultEdgeRealizer

public EdgeRealizer getDefaultEdgeRealizer()
Returns the default edge realizer. A copy of this realizer will be bound to a newly created edge if no other realizer is given explicitly.

See Also:
setDefaultEdgeRealizer(EdgeRealizer)

getRealizer

public NodeRealizer getRealizer(Node v)
Returns the node realizer that is bound to the given node.

See Also:
setRealizer(y.base.Node, NodeRealizer)

getRealizer

public EdgeRealizer getRealizer(Edge e)
Returns the edge realizer that is bound to the given edge.

See Also:
setRealizer(y.base.Edge, EdgeRealizer)

setRealizer

public void setRealizer(Node v,
                        NodeRealizer r)
Sets the node realizer for the given node.

See Also:
getRealizer(y.base.Node)

setRealizer

public void setRealizer(Edge e,
                        EdgeRealizer r)
Sets the edge realizer for the given edge.

See Also:
getRealizer(y.base.Edge)

getLayout

public NodeLayout getLayout(Node node)
Returns the layout information for a node in the drawing.

Specified by:
getLayout in class LayoutGraph
Parameters:
node - a node in the drawing.
Returns:
the layout information for node.

getLayout

public EdgeLayout getLayout(Edge edge)
Returns the layout information for an edge in the drawing.

Specified by:
getLayout in class LayoutGraph
Parameters:
edge - a edge in the drawing.
Returns:
the layout information for edge.

getLabelLayout

public NodeLabelLayout[] getLabelLayout(Node node)
Returns NodeLabelLayout objects which describe the layouts of the labels that belong to the given node.

Specified by:
getLabelLayout in class LayoutGraph
Parameters:
node - a node in the drawing.
Returns:
the node label layout information for node.

getLabelLayout

public EdgeLabelLayout[] getLabelLayout(Edge edge)
Returns EdgeLabelLayout objects which describe the layouts of the labels that belong to the given edge.

Specified by:
getLabelLayout in class LayoutGraph
Parameters:
edge - an edge in the drawing.
Returns:
the edge label layout information for edge.

getFeature

public Node getFeature(NodeLabelLayout labelLayout)
Returns the node which is described by a given label layout.

Specified by:
getFeature in class LayoutGraph
Parameters:
labelLayout - the label's layout information
Returns:
the node that owns the label

getFeature

public Edge getFeature(EdgeLabelLayout labelLayout)
Returns the node which is described by a given label layout.

Specified by:
getFeature in class LayoutGraph
Parameters:
labelLayout - the label's layout information
Returns:
the edge that owns the label

isSelectionEmpty

public boolean isSelectionEmpty()
Returns true iff neither edges nor nodes nor bends nor labels nor node ports in this graph are selected.

Calls isSelected(y.base.Edge), isSelected(y.base.Node), isSelected(YLabel), or isSelected(Bend) to determine the selection state of an element.


isSelectionSingleton

public boolean isSelectionSingleton()
Returns true if and only if exactly one node or one bend is selected and false otherwise.

Returns:
true if and only if exactly one node or one bend is selected and false otherwise.

selectedNodes

public NodeCursor selectedNodes()
Returns a node cursor for all momentarily selected nodes in this graph.

Calls isSelected(y.base.Node) to determine the selection state of a node.


selectedEdges

public EdgeCursor selectedEdges()
Returns an edge cursor for all momentarily selected edges in this graph.

Calls isSelected(y.base.Edge) to determine the selection state of an edge.


selectedLabels

public YCursor selectedLabels()
Returns a YCursor for all momentarily selected labels in this graph. The elements can all be safely cast to YLabels.

Calls isSelected(YLabel) to determine the selection state of a label.


selectedBends

public BendCursor selectedBends()
Returns a bend cursor for all momentarily selected bends in this graph.

Calls isSelected(Bend) to determine the selection state of a bend.


unselectAll

public void unselectAll()
Deselects all nodes, edges, bends, labels, and node ports in this graph.

Calls setSelected(y.base.Node, boolean), setSelected(y.base.Edge, boolean), setSelected(YLabel, boolean), or setSelected(Bend, boolean) to change the selection state of an element.


unselectNodes

public void unselectNodes()
Deselects all nodes in this graph.

Calls setSelected(y.base.Node, boolean) to change the selection state of a node.


unselectEdges

public void unselectEdges()
Deselects all edges in this graph.

Calls setSelected(y.base.Edge, boolean) to change the selection state of a node.


unselectBends

public void unselectBends()
Deselects all bends in this graph.

Calls setSelected(Bend, boolean) to change the selection state of a bend.


unselectLabels

public void unselectLabels()
Deselects all labels in this graph.

Calls setSelected(YLabel, boolean) to change the selection state of a label.


unselectNodePorts

public void unselectNodePorts()
Deselects all node ports in this graph.


moveNodes

public void moveNodes(NodeCursor nc,
                      double dx,
                      double dy)
Moves the given nodes by (dx,dy).


moveBends

public void moveBends(BendCursor bc,
                      double dx,
                      double dy)
Moves the given bends by (dx,dy).


removeSelection

public void removeSelection()
Removes all selected objects from this graph.

Calls isSelected(y.base.Edge), isSelected(y.base.Node), isSelected(YLabel), or isSelected(Bend) to determine the selection state of an element.


selectBoxContent

public void selectBoxContent(java.awt.Rectangle r)
Selects the graph objects in given rectangle. Formerly selected things will not be deselected.


selectBoxContent

public void selectBoxContent(double x,
                             double y,
                             double width,
                             double height)
Selects the graph objects in a rectangle defined by the given arguments. Formerly selected things will not be deselected.


getHitInfo

public HitInfo getHitInfo(double x,
                          double y,
                          boolean firstHitOnly)
Deprecated. Use HitInfo's various constructors directly for control over the hit test order.

Returns objects that are hit on position (x,y).

Parameters:
firstHitOnly - determines if search should be abandoned after the first hit object was found.

getHitInfo

public HitInfo getHitInfo(double x,
                          double y)
Deprecated. Use HitInfo's various constructors directly for control over the hit test order.

Returns hit info containing only the first hit object that was found.


setLabelText

public void setLabelText(Node v,
                         java.lang.String text)
Sets the given label text for the given node.


getLabelText

public java.lang.String getLabelText(Node v)
Returns the label text for the given node.


setLabelText

public void setLabelText(Edge e,
                         java.lang.String text)
Sets the given label text for the given edge.


getLabelText

public java.lang.String getLabelText(Edge e)
Returns the label text for the given edge.


setSelected

public void setSelected(Edge e,
                        boolean s)
Sets the selected state for the given edge.


setSelected

public void setSelected(YLabel label,
                        boolean s)
Sets the selected state for the given label.


setSelected

public void setSelected(Bend bend,
                        boolean s)
Sets the selected state for the given bend.


setSelected

public void setSelected(NodePort port,
                        boolean s)
Sets the selected state for the given node port.


setSelected

public void setSelected(EdgeCursor edges,
                        boolean s)
Sets the selection state for the given edges.

Calls setSelected(y.base.Edge, boolean) to change the selection state of an edge.


setSelected

public void setSelected(Node v,
                        boolean s)
Sets the selection state for the given node.


setSelected

public void setSelected(NodeCursor nodes,
                        boolean s)
Sets the selection state for the given nodes.

Calls setSelected(y.base.Node, boolean) to change the selection state of a node.


setBendsSelected

public void setBendsSelected(BendCursor bc,
                             boolean s)
Sets the selection state for the given bends.

Calls setSelected(Bend, boolean) to change the selection state of a bend.


setBendsSelected

public void setBendsSelected(Edge e,
                             boolean s)
Sets the selection state for the bends given by the edge.


setBendsSelected

public void setBendsSelected(EdgeCursor ec,
                             boolean s)
Sets the selection state for the bends given by the edges.


selectAllNodesAndBends

public void selectAllNodesAndBends(boolean s)
Sets the selection state for all nodes and bends.


isSelected

public boolean isSelected(Edge e)
Returns the selection state of the given edge.


isSelected

public boolean isSelected(YLabel label)
Returns the selection state of the given label.


isSelected

public boolean isSelected(Bend bend)
Returns the selection state of the given bend.


isSelected

public boolean isSelected(NodePort port)
Returns the selection state of the given node port.


isSelected

public boolean isSelected(Node v)
Returns the selection state of the given node.


getCenterX

public double getCenterX(Node v)
Returns the center x-coordinate of the given node.

Overrides:
getCenterX in class LayoutGraph
Parameters:
v - the node
Returns:
the x-value of the node's center coordinate
See Also:
getX(y.base.Node)

getCenterY

public double getCenterY(Node v)
Returns the center y-coordinate of the given node.

Overrides:
getCenterY in class LayoutGraph
Parameters:
v - the node
Returns:
the y-value of the node's center coordinate
See Also:
getY(y.base.Node)

getX

public double getX(Node v)
Returns the upper left x-coordinate of the given node.

Overrides:
getX in class LayoutGraph
Parameters:
v - the node
Returns:
the x-value of the node's upper-left corner
See Also:
getCenterX(y.base.Node)

getY

public double getY(Node v)
Returns the upper left y-coordinate of the given node.

Overrides:
getY in class LayoutGraph
Parameters:
v - the node
Returns:
the y-value of the node's upper-left corner
See Also:
getCenterY(y.base.Node)

getWidth

public double getWidth(Node v)
Returns the width of the given node.

Overrides:
getWidth in class LayoutGraph
Parameters:
v - the node
Returns:
the width of the node
See Also:
NodeLayout.getWidth()

getHeight

public double getHeight(Node v)
Returns the height of the given node.

Overrides:
getHeight in class LayoutGraph
Parameters:
v - the node
Returns:
the height of the node
See Also:
NodeLayout.getHeight()

setCenter

public void setCenter(Node v,
                      double x,
                      double y)
Sets the center coordinates of the given node.

Overrides:
setCenter in class LayoutGraph
Parameters:
v - the node
x - the new x-coordinate of the node's center
y - the new y-coordinate of the node's center
See Also:
setLocation(y.base.Node, double, double)

setSize

public void setSize(Node v,
                    double w,
                    double h)
Sets the size of the given node.

Overrides:
setSize in class LayoutGraph
Parameters:
v - the node
w - the new width of the node
h - the new height of the node
See Also:
NodeLayout.setSize(double, double)

setLocation

public void setLocation(Node v,
                        double x,
                        double y)
Sets the upper left coordinates of the given node.

Overrides:
setLocation in class LayoutGraph
Parameters:
v - the node
x - the new x-coordinate of the upper-left corner
y - the new y-coordinate of the upper-left corner
See Also:
setCenter(y.base.Node, double, double)

setURL

public void setURL(java.net.URL url)
Sets the URL of this Graph2D. The URL specifies the physical location to or from where this graph was loaded or stored. The URL should always denote the last location from where this model was loaded or stored. This method fires a Graph2DEvent with the property name "URL".


getURL

public java.net.URL getURL()
Returns the URL associated with this graph.

See Also:
setURL(URL url)

addDrawable

public void addDrawable(Drawable d)
Adds a drawable to this graph. Drawables serve as additional visual elements that part of this graph.


drawables

public YCursor drawables()
Returns a cursor iterating over all Drawables known to this graph.


removeDrawable

public void removeDrawable(Drawable d)
Removes the given drawable from this graph.


getViews

public YCursor getViews()
Returns a cursor iterating through all registered views.


getCurrentView

public View getCurrentView()
Returns the current view. If not set, returns the first view in list.


setCurrentView

public void setCurrentView(View view)
Sets the current view.
Precondition: The view has be registered in this graph.


registerView

public void registerView(View v)
Adds this view to the set of views that display this graph.


removeView

public void removeView(View v)
Removes this view from the set of views that display this graph.


updateViews

public void updateViews()
Calls updateView on all registered views.


updateViews

public void updateViews(double x,
                        double y,
                        double w,
                        double h)
Calls View.updateView(double, double, double, double) on all registered views.

Parameters:
x - the upper left corner of the rectangular area to be updated in world coordinates
y - the upper left corner of the rectangular area to be updated in world coordinates
w - the width of the rectangular area to be updated in world coordinates
h - the height of the rectangular area to be updated in world coordinates
See Also:
View.updateView(double, double, double, double)

fitGraph2DView

public void fitGraph2DView()
Invokes fitContent() on the current view, if the current view is of type Graph2DView. Otherwise no action is performed.


setBackupRealizersHandler

public void setBackupRealizersHandler(Graph2D.BackupRealizersHandler brh)
Sets the delegate class that is responsible for acting upon calls to the methods backupRealizers(EdgeCursor) and backupRealizers(NodeCursor).

By default no such handler is set.


getBackupRealizersHandler

public Graph2D.BackupRealizersHandler getBackupRealizersHandler()
Returns the handler for backupRealizer method calls. If no such handler is set then null will be returned.


backupRealizers

public void backupRealizers()
A method that supports undoability of the changes performed on node and edge realizers. Subclasses that want undoability should backup all edge and node realizers upon a call to this method. Calling this method signals that (some of) the realizers will change in a further unspecified way. By default this method calls backupRealizers for all edges and nodes in the graph.


backupRealizers

public void backupRealizers(EdgeCursor ec)
A method that supports undoability of the changes performed on the edge realizers associated with the given edges. Calls to this method will be delegated to the Graph2D.BackupRealizersHandler that has been registered to this graph.

See Also:
setBackupRealizersHandler(y.view.Graph2D.BackupRealizersHandler)

backupRealizers

public void backupRealizers(NodeCursor nc)
A method that supports undoability of the changes performed on the node realizers associated with the given nodes. Calls to this method will be delegated to the Graph2D.BackupRealizersHandler that has been registered to this graph.

See Also:
setBackupRealizersHandler(y.view.Graph2D.BackupRealizersHandler)

addGraph2DSelectionListener

public void addGraph2DSelectionListener(Graph2DSelectionListener listener)
Adds the given Graph2DSelectionListener to this graph.


removeGraph2DSelectionListener

public void removeGraph2DSelectionListener(Graph2DSelectionListener listener)
Removes the given Graph2DSelectionListener from this graph.


getGraph2DSelectionListeners

public java.util.Iterator getGraph2DSelectionListeners()
Returns an iterator that grants access to all registered Graph2DSelectionListeners


fireGraph2DSelectionEvent

public void fireGraph2DSelectionEvent(java.lang.Object subject)
Fires a GraphSelectionEvent for the given subject


addGraph2DListener

public void addGraph2DListener(Graph2DListener listener)
Adds the given Graph2DListener to this graph. The following property changes on Graph2D will be delivered to the registered listeners:

Subject typeProperty name
NodeLabeltext
EdgeLabeltext
Noderealizer
Edgerealizer


removeGraph2DListener

public void removeGraph2DListener(Graph2DListener listener)
Removes the given Graph2DListener from this graph.


getGraph2DListeners

public java.util.Iterator getGraph2DListeners()
Returns an iterator that grants access to all registered Graph2DListeners


fireGraph2DEvent

public void fireGraph2DEvent(java.lang.Object subject,
                             java.lang.String name,
                             java.lang.Object oldValue,
                             java.lang.Object newValue)
Fires a Graph2DEvent


createLabelFactory

protected LabelLayoutFactory createLabelFactory()
Creates a new label layout factory for this graph.

Note that this method is for internal use only. If you want to create, remove or add labels to your Graph2D instance, please use the corresponding methods of classes NodeRealizer and EdgeRealizer.

Specified by:
createLabelFactory in class LayoutGraph
Returns:
the label layout factory.

© Copyright 2000-2022,
yWorks GmbH.
All rights reserved.