public class GraphicEdge extends GraphicElement implements Edge
The graphic edge defines its source and target node as well as a direction, a string label and a style from the style sheet.
GraphicGraph
Modifier and Type | Class and Description |
---|---|
class |
GraphicEdge.EdgeGroup
An edge group contains the set of edges between two given nodes.
|
GraphicElement.SwingElementRenderer
AbstractElement.AttributeChangeEvent
Modifier and Type | Field and Description |
---|---|
double[] |
ctrl
Control points for curved edges or polylines.
|
boolean |
directed
Is the edge directed ?.
|
GraphicNode |
from
The first node.
|
GraphicEdge.EdgeGroup |
group
If non null, this gives the number of edges between the two same nodes.
|
int |
multi
In case of a multi-graph this is the index of the edge between to and from.
|
GraphicNode |
to
The second node.
|
component, hidden, label, style
Constructor and Description |
---|
GraphicEdge(java.lang.String id,
GraphicNode from,
GraphicNode to,
boolean dir,
java.util.HashMap<java.lang.String,java.lang.Object> attributes)
New graphic edge.
|
Modifier and Type | Method and Description |
---|---|
double[] |
getControlPoints()
Control points for curved edges or polylines.
|
GraphicEdge.EdgeGroup |
getGroup()
If there are several edges between two nodes, this edge pertains to a group.
|
int |
getMultiIndex()
This edge is the i-th between the two same nodes.
|
Node |
getNode0()
First node of the edge.
|
Node |
getNode1()
Second node of the edge.
|
Node |
getOpposite(Node node)
When knowing one node and one edge of this node, this method return the node
at the other end of the edge.
|
Selector.Type |
getSelectorType()
Type of selector for the graphic element (Node, Edge, Sprite ?).
|
Node |
getSourceNode()
Start node.
|
Node |
getTargetNode()
End node.
|
double |
getX()
Abscissa of the element, always in GU (graph units).
|
double |
getY()
Ordinate of the element, always in GU (graph units).
|
double |
getZ()
Depth of the element, always in GU (graph units).
|
boolean |
isCurve()
True if the the edge defines control points to draw a curve or polyline.
|
boolean |
isDirected()
Is the edge directed ?.
|
boolean |
isLoop()
Does the source and target of this edge identify the same node ?.
|
void |
move(double x,
double y,
double z)
Try to force the element to move at the give location in graph units (GU).
|
GraphicNode |
otherNode(GraphicNode n)
Obtain the node that is not "n" attached to this edge.
|
void |
removed()
The graphic element was removed from the graphic graph, clean up.
|
void |
setControlPoints(double[] points)
Change the control points array for this edge.
|
void |
setDirected(boolean on) |
void |
switchDirection() |
getComponent, getLabel, getStyle, myGraph, setAttribute, setComponent
attributeKeys, clearAttributes, getAttribute, getAttribute, getAttributeCount, getFirstAttributeOf, getFirstAttributeOf, getId, getIndex, hasAttribute, hasAttribute, removeAttribute, toString
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
attributeKeys, clearAttributes, getArray, getAttribute, getAttribute, getAttributeCount, getFirstAttributeOf, getFirstAttributeOf, getId, getIndex, getLabel, getMap, getNumber, getVector, hasArray, hasAttribute, hasAttribute, hasLabel, hasMap, hasNumber, hasVector, removeAttribute, setAttribute, setAttributes
public GraphicNode from
public GraphicNode to
public boolean directed
public int multi
public GraphicEdge.EdgeGroup group
public double[] ctrl
public GraphicEdge(java.lang.String id, GraphicNode from, GraphicNode to, boolean dir, java.util.HashMap<java.lang.String,java.lang.Object> attributes)
id
- The edge unique identifier.from
- The source node.to
- The target node.dir
- True if the edge is directed in the direction from-to.attributes
- A set of initial attributes.public Selector.Type getSelectorType()
GraphicElement
getSelectorType
in class GraphicElement
public GraphicNode otherNode(GraphicNode n)
n
- One of the node of this edge.public double getX()
GraphicElement
getX
in class GraphicElement
public double getY()
GraphicElement
getY
in class GraphicElement
public double getZ()
GraphicElement
getZ
in class GraphicElement
public double[] getControlPoints()
public boolean isCurve()
public void setControlPoints(double[] points)
points
- The new set of points. See the getControlPoints()
method
for an explanation on the organisation of this array.getControlPoints()
public int getMultiIndex()
public void move(double x, double y, double z)
GraphicElement
move
in class GraphicElement
x
- The new X.y
- The new Y.z
- the new Z.public void removed()
GraphicElement
public Node getNode0()
Edge
This is equivalent to the Edge.getSourceNode()
method, but may be clearer
in the source code if the graph you are using is not directed.
getNode0
in interface Edge
Edge.getNode1()
,
Edge.getSourceNode()
public Node getNode1()
Edge
This is equivalent to the Edge.getTargetNode()
method, but may be clearer
in the source code if the graph you are using is not directed.
getNode1
in interface Edge
Edge.getNode0()
,
Edge.getTargetNode()
public GraphicEdge.EdgeGroup getGroup()
public Node getOpposite(Node node)
Edge
Return null if the given node is not at any end of the edge.
getOpposite
in interface Edge
node
- The node we search the opposite of.public Node getSourceNode()
Edge
When the edge is directed this is the source node, in this case you can get
the opposite node using Edge.getTargetNode()
. This is equivalent to the
Edge.getNode0()
method but may be clearer in the source code if the graph
you are using is directed.
getSourceNode
in interface Edge
Edge.getNode0()
,
Edge.getTargetNode()
public Node getTargetNode()
Edge
When the edge is directed this is the target node, in this case you can get
the opposite node using Edge.getSourceNode()
. This is equivalent to the
Edge.getNode1()
method but may be clearer in the source code if the graph
you are using is directed.
getTargetNode
in interface Edge
Edge.getNode1()
,
Edge.getSourceNode()
public boolean isDirected()
Edge
isDirected
in interface Edge
public boolean isLoop()
Edge
public void setDirected(boolean on)
public void switchDirection()