|
||||||||||
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
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
Graph2D.setDefaultEdgeRealizer(EdgeRealizer)
and
Graph2D.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, listeners |
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. |
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. |
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. |
protected void |
fireGraph2DEvent(Object subject,
String name,
Object oldValue,
Object newValue)
Fires a Graph2DEvent |
protected 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-coord of the given node. |
double |
getCenterY(Node v)
Returns the center y-coord 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. |
HitInfo |
getHitInfo(double x,
double y)
Returns hit info containing only the first hit object that was found. |
HitInfo |
getHitInfo(double x,
double y,
boolean firstHitOnly)
Returns objects that are hit on position (x,y). |
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 associatioed 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-coord of the given node. |
double |
getY(Node v)
Returns the upper left y-coord of the given node. |
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 |
isSelectionEmpty()
Returns true iff neither edge nor node nor bend in this
graph is selected. |
boolean |
isSelectionSingleton()
Returns true if and only if exactly one object is selected. |
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. |
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 Graph2D.backupRealizers(EdgeCursor) and
Graph2D.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 coords 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 |
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 coords 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(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 |
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()
Unselects all nodes, edges and bends in this graph. |
void |
unselectBends()
Unselects all bends in this graph. |
void |
unselectEdges()
Unselects all edges in this graph. |
void |
unselectNodes()
Unselects all nodes in this graph. |
void |
updateViews()
Calls updateView 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 |
public Graph createCopy()
Graph2D.
- Overrides:
createCopy
in class Graph
- Returns:
- a copy of this graph.
public Graph createGraph()
Graph2D.
- Overrides:
createGraph
in class Graph
- Returns:
- an empty
Graph2D
.
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 edgew
- 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)
.
Precondition: Edge e1 must have source node v and edge e2 must have target node w
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 AFTERpublic 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()
If this graph is empty a rectangle with negative width and height will be returned.
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 edge nor node nor bend in this
graph is selected.
public boolean isSelectionSingleton()
true
if and only if exactly one object is selected.
public NodeCursor selectedNodes()
public EdgeCursor selectedEdges()
public BendCursor selectedBends()
public void unselectAll()
public void unselectNodes()
public void unselectEdges()
public void unselectBends()
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()
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)
firstHitOnly
- determines if search should be abandoned after
the first hit object was found.
If nothing's hit, null will be returned.public HitInfo getHitInfo(double x, double y)
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(EdgeCursor edges, boolean s)
public void setSelected(Node v, boolean s)
public void setSelected(NodeCursor nodes, boolean s)
public void setBendsSelected(BendCursor bc, boolean s)
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(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()
Graph2D.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 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)
Graph2D.backupRealizers(EdgeCursor)
and
Graph2D.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.
Graph2D.setBackupRealizersHandler(y.view.Graph2D.BackupRealizersHandler)
public void backupRealizers(NodeCursor nc)
Graph2D.BackupRealizersHandler
that has been registered
to this graph.
Graph2D.setBackupRealizersHandler(y.view.Graph2D.BackupRealizersHandler)
public void addGraph2DSelectionListener(Graph2DSelectionListener listener)
public void removeGraph2DSelectionListener(Graph2DSelectionListener listener)
public Iterator getGraph2DSelectionListeners()
protected 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()
protected void fireGraph2DEvent(Object subject, String name, Object oldValue, Object newValue)
|
© Copyright 2000-2003, yWorks GmbH. All rights reserved. 2003 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |