|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.base.Graph y.layout.LayoutGraph y.view.Graph2D
public class Graph2D
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.
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 |
---|
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. |
Edge |
createEdge(Node v,
Edge e1,
Node w,
Edge e2,
int d1,
int d2,
EdgeRealizer r)
Creates a new edge with given realizer in this graph. |
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 in this graph. |
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 |
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,
String label)
Creates a new node with center location (x,y) , dimension
(w,h) and given label text. |
Node |
createNode(double x,
double y,
String label)
Creates a new node with center location (x,y) and
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(Object subject,
String name,
Object oldValue,
Object newValue)
Fires a Graph2DEvent |
void |
fireGraph2DSelectionEvent(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. |
Rectangle |
getBoundingBox()
Returns the bounding box of this graph. |
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 that will be bound to newly created edges. |
NodeRealizer |
getDefaultNodeRealizer()
Returns the default node realizer that will be bound to newly created nodes. |
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. |
Iterator |
getGraph2DListeners()
Returns an iterator that grants access to all registered Graph2DListeners |
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. |
String |
getLabelText(Edge e)
Returns the label text for the given edge. |
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 EdgeRealizer bound to the given edge. |
NodeRealizer |
getRealizer(Node v)
Returns the NodeRealizer bound to the given node. |
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 |
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(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,
String text)
Sets the given label text for the given edge. |
void |
setLabelText(Node v,
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. |
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 EdgeRealizer for the given edge. |
void |
setRealizer(Node v,
NodeRealizer r)
Sets the NodeRealizer 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(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 java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Graph2D()
public Graph2D(Graph2D graph)
public Graph2D(Graph2D graph, YCursor nodeSubset)
Method Detail |
---|
protected GraphCopier.CopyFactory createGraphCopyFactory()
Graph2DCopyFactory.HierarchicGraph2DCopyFactory
createGraphCopyFactory
in class LayoutGraph
public Graph createCopy()
Graph2D
.
createCopy
in class Graph
public Graph createGraph()
Graph2D
.
createGraph
in class Graph
Graph2D
.public void changeEdge(Edge e, Node newSource, Edge sourceReference, int sourceD, Node newTarget, Edge targetReference, int targetD)
Graph
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
.
e
is inserted in such a way that an iteration over the edges
at v
returns e
sourceReference
, if sourceD == AFTER
sourceReference
, if sourceD == BEFORE
,
w
returns e
targetReference
, if targetD == AFTER
targetReference
, if targetD == BEFORE
.
changeEdge
in class Graph
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
.public void changeEdge(Edge e, Node newSource, Node newTarget)
Graph
changeEdge
in class Graph
e
- The edge to be changed.newSource
- The new source node of the given edge.newTarget
- The new target node of the given edge.public void setHierarchyManager(HierarchyManager hierarchyManager)
public HierarchyManager getHierarchyManager()
null
if the graph is not part of any graph hierarchy.
public Edge createEdge(Node v, Node w)
v
to node w
.
The default edge realizer will be bound to the newly created edge.
createEdge
in class Graph
v
- The source node of the edge.w
- The target node of the edge.
public Edge createEdge(Node v, Node w, EdgeRealizer r)
v
- the source node of the edgew
- the target node of the edger
- an EdgeRealizer associated with the create edge.
public Edge createEdge(Node v, Edge e1, Node w, Edge e2, int d1, int d2)
d1 == AFTER (d1 == BEFORE)
and an iteration over the edges at w return e after (before)
e2 if d2 == AFTER (d2 == BEFORE)
.
createEdge
in class Graph
v
- the source node of the edgee1
- an edge with source node vw
- the target node of the edgee2
- an edge with target node wd1
- one of the object insertion specifiers BEFORE or AFTERd2
- one of the object insertion specifiers BEFORE or AFTER
public Edge createEdge(Node v, Edge e1, Node w, Edge e2, int d1, int d2, EdgeRealizer r)
public Node createNode()
createNode
in class Graph
public Node createNode(double x, double y)
(x,y)
.
The default node realizer defines all other properties of this
node.
public Node createNode(double x, double y, String label)
(x,y)
and
given label text.
The default node realizer defines all other properties of this
node.
public Node createNode(double x, double y, double w, double h, String label)
(x,y)
, dimension
(w,h)
and given label text.
The default node realizer defines all other properties of this
node.
public Node createNode(NodeRealizer r)
r
- a NodeRealizer associated with the create node
public Rectangle getBoundingBox()
getBoundingBox
in interface GraphLayout
getBoundingBox
in class LayoutGraph
public Rectangle getBoundingBox(byte layer)
public void setLayerAll(byte layer)
public Rectangle setLocation(double x, double y)
public BendCursor bends()
public void setDefaultNodeRealizer(NodeRealizer r)
public void setDefaultEdgeRealizer(EdgeRealizer r)
public NodeRealizer getDefaultNodeRealizer()
public EdgeRealizer getDefaultEdgeRealizer()
public NodeRealizer getRealizer(Node v)
public EdgeRealizer getRealizer(Edge e)
public void setRealizer(Node v, NodeRealizer r)
public void setRealizer(Edge e, EdgeRealizer r)
public NodeLayout getLayout(Node node)
getLayout
in class LayoutGraph
node
- a node in the drawing.
node
.public EdgeLayout getLayout(Edge edge)
getLayout
in class LayoutGraph
edge
- a edge in the drawing.
edge
.public NodeLabelLayout[] getLabelLayout(Node node)
NodeLabelLayout
objects
which describe the layouts
of the labels that belong to the given node.
getLabelLayout
in class LayoutGraph
node
- a node in the drawing.
node
.public EdgeLabelLayout[] getLabelLayout(Edge edge)
EdgeLabelLayout
objects
which describe the layouts
of the labels that belong to the given edge.
getLabelLayout
in class LayoutGraph
edge
- an edge in the drawing.
edge
.public Node getFeature(NodeLabelLayout labelLayout)
getFeature
in class LayoutGraph
public Edge getFeature(EdgeLabelLayout labelLayout)
getFeature
in class LayoutGraph
public boolean isSelectionEmpty()
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.
public boolean isSelectionSingleton()
true
if and only if exactly one node or one bend is
selected and false
otherwise.
true
if and only if exactly one node or one bend is
selected and false
otherwise.public NodeCursor selectedNodes()
Calls isSelected(y.base.Node)
to determine the selection state
of a node.
public EdgeCursor selectedEdges()
Calls isSelected(y.base.Edge)
to determine the selection state
of an edge.
public YCursor selectedLabels()
YLabel
s.
Calls isSelected(YLabel)
to determine the selection state of
a label.
public BendCursor selectedBends()
Calls isSelected(Bend)
to determine the selection state of a bend.
public void unselectAll()
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.
public void unselectNodes()
Calls setSelected(y.base.Node, boolean)
to change the selection
state of a node.
public void unselectEdges()
Calls setSelected(y.base.Edge, boolean)
to change the selection
state of a node.
public void unselectBends()
Calls setSelected(Bend, boolean)
to change the selection state
of a bend.
public void unselectLabels()
Calls setSelected(YLabel, boolean)
to change the selection state
of a label.
public void unselectNodePorts()
public void moveNodes(NodeCursor nc, double dx, double dy)
(dx,dy)
.
public void moveBends(BendCursor bc, double dx, double dy)
(dx,dy)
.
public void removeSelection()
Calls isSelected(y.base.Edge)
, isSelected(y.base.Node)
,
isSelected(YLabel)
, or isSelected(Bend)
to determine
the selection state of an element.
public void selectBoxContent(Rectangle r)
public void selectBoxContent(double x, double y, double width, double height)
public HitInfo getHitInfo(double x, double y, boolean firstHitOnly)
HitInfo
's various constructors directly
for control over the hit test order.
firstHitOnly
- determines if search should be abandoned after
the first hit object was found.public HitInfo getHitInfo(double x, double y)
HitInfo
's various constructors directly
for control over the hit test order.
public void setLabelText(Node v, String text)
public String getLabelText(Node v)
public void setLabelText(Edge e, String text)
public String getLabelText(Edge e)
public void setSelected(Edge e, boolean s)
public void setSelected(YLabel label, boolean s)
public void setSelected(Bend bend, boolean s)
public void setSelected(NodePort port, boolean s)
public void setSelected(EdgeCursor edges, boolean s)
Calls setSelected(y.base.Edge, boolean)
to change the selection
state of an edge.
public void setSelected(Node v, boolean s)
public void setSelected(NodeCursor nodes, boolean s)
Calls setSelected(y.base.Node, boolean)
to change the selection
state of a node.
public void setBendsSelected(BendCursor bc, boolean s)
Calls setSelected(Bend, boolean)
to change the selection state
of a bend.
public void setBendsSelected(Edge e, boolean s)
public void setBendsSelected(EdgeCursor ec, boolean s)
public void selectAllNodesAndBends(boolean s)
public boolean isSelected(Edge e)
public boolean isSelected(YLabel label)
public boolean isSelected(Bend bend)
public boolean isSelected(NodePort port)
public boolean isSelected(Node v)
public double getCenterX(Node v)
getCenterX
in class LayoutGraph
public double getCenterY(Node v)
getCenterY
in class LayoutGraph
public double getX(Node v)
getX
in class LayoutGraph
public double getY(Node v)
getY
in class LayoutGraph
public double getWidth(Node v)
getWidth
in class LayoutGraph
public double getHeight(Node v)
getHeight
in class LayoutGraph
public void setCenter(Node v, double x, double y)
setCenter
in class LayoutGraph
public void setSize(Node v, double w, double h)
setSize
in class LayoutGraph
public void setLocation(Node v, double x, double y)
setLocation
in class LayoutGraph
public void setURL(URL url)
public URL getURL()
setURL(URL url)
public void addDrawable(Drawable d)
public YCursor drawables()
public void removeDrawable(Drawable d)
public YCursor getViews()
public View getCurrentView()
public void setCurrentView(View view)
public void registerView(View v)
public void removeView(View v)
public void updateViews()
updateView
on all registered views.
public void updateViews(double x, double y, double w, double h)
View.updateView(double, double, double, double)
on all registered views.
x
- the upper left corner of the rectangular area to be updated in world coordinatesy
- the upper left corner of the rectangular area to be updated in world coordinatesw
- the width of the rectangular area to be updated in world coordinatesh
- the height of the rectangular area to be updated in world coordinatesView.updateView(double, double, double, double)
public void fitGraph2DView()
fitContent()
on the current view,
if the current view is of type Graph2DView
.
Otherwise no action is performed.
public void setBackupRealizersHandler(Graph2D.BackupRealizersHandler brh)
backupRealizers(EdgeCursor)
and
backupRealizers(NodeCursor)
.
By default no such handler is set.
public Graph2D.BackupRealizersHandler getBackupRealizersHandler()
null
will be returned.
public void backupRealizers()
public void backupRealizers(EdgeCursor ec)
Graph2D.BackupRealizersHandler
that has been registered
to this graph.
setBackupRealizersHandler(y.view.Graph2D.BackupRealizersHandler)
public void backupRealizers(NodeCursor nc)
Graph2D.BackupRealizersHandler
that has been registered
to this graph.
setBackupRealizersHandler(y.view.Graph2D.BackupRealizersHandler)
public void addGraph2DSelectionListener(Graph2DSelectionListener listener)
public void removeGraph2DSelectionListener(Graph2DSelectionListener listener)
public Iterator getGraph2DSelectionListeners()
public void fireGraph2DSelectionEvent(Object subject)
public void addGraph2DListener(Graph2DListener listener)
Subject type | Property name |
---|---|
NodeLabel | text |
EdgeLabel | text |
Node | realizer |
Edge | realizer |
public void removeGraph2DListener(Graph2DListener listener)
public Iterator getGraph2DListeners()
public void fireGraph2DEvent(Object subject, String name, Object oldValue, Object newValue)
|
© Copyright 2000-2013, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |