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.
|
acceptedAttribute, component, hidden, label, mygraph, style
attributes, attributesBeingRemoved, id
Constructor and Description |
---|
GraphicEdge(String id,
GraphicNode from,
GraphicNode to,
boolean dir,
HashMap<String,Object> attributes)
New graphic edge.
|
Modifier and Type | Method and Description |
---|---|
protected void |
attributeChanged(AbstractElement.AttributeChangeEvent event,
String attribute,
Object oldValue,
Object newValue)
Handle the "ui.class", "label", "ui.style", etc. attributes.
|
protected void |
countSameEdges(ArrayList<GraphicEdge> edgeList)
Count the number of identical edges between the two nodes of this edge
and create or update the edge group.
|
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.
|
<T extends Node> |
getNode0()
First node of the edge.
|
<T extends Node> |
getNode1()
Second node of the edge.
|
<T extends 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 ?).
|
<T extends Node> |
getSourceNode()
Start node.
|
<T extends 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() |
addAttribute, getComponent, getLabel, getStyle, myGraph, nullAttributesAreErrors, setComponent
addAttributes, changeAttribute, clearAttributes, clearAttributesWithNoEvent, getArray, getAttribute, getAttribute, getAttributeCount, getAttributeKeyIterator, getAttributeKeySet, getEachAttributeKey, getFirstAttributeOf, getFirstAttributeOf, getHash, getId, getIndex, getLabel, getNumber, getVector, hasArray, hasAttribute, hasAttribute, hasHash, hasLabel, hasNumber, hasVector, removeAttribute, setAttribute, setIndex, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addAttribute, addAttributes, changeAttribute, clearAttributes, getArray, getAttribute, getAttribute, getAttributeCount, getAttributeKeyIterator, getAttributeKeySet, getEachAttributeKey, getFirstAttributeOf, getFirstAttributeOf, getHash, getId, getIndex, getLabel, getNumber, getVector, hasArray, hasAttribute, hasAttribute, hasHash, hasLabel, hasNumber, hasVector, removeAttribute, setAttribute
public GraphicNode from
public GraphicNode to
public boolean directed
public int multi
public GraphicEdge.EdgeGroup group
public double[] ctrl
public GraphicEdge(String id, GraphicNode from, GraphicNode to, boolean dir, HashMap<String,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.protected void attributeChanged(AbstractElement.AttributeChangeEvent event, String attribute, Object oldValue, Object newValue)
GraphicElement
attributeChanged
in class GraphicElement
event
- The type of event among ADD, CHANGE and REMOVE.attribute
- The attribute name that changed.oldValue
- The old value of the attribute, null if the attribute was
added.newValue
- The new value of the attribute, null if the attribute is about
to be removed.protected void countSameEdges(ArrayList<GraphicEdge> edgeList)
edgeList
- The actual set of edges between two nodes (see the
connectivity in the graphic graph).public void removed()
GraphicElement
removed
in class GraphicElement
public <T extends Node> T 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.
This method is implicitly generic and return something which extends Node. The return type is the one of the left part of the assignment. For example, in the following call :
ExtendedNode n = edge.getNode0();the method will return an ExtendedNode. If no left part exists, method will just return a Node.
getNode0
in interface Edge
Edge.getNode1()
,
Edge.getSourceNode()
public <T extends Node> T 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.
This method is implicitly generic and return something which extends Node. The return type is the one of the left part of the assignment. For example, in the following call :
ExtendedNode n = edge.getNode1();the method will return an ExtendedNode. If no left part exists, method will just return a Node.
getNode1
in interface Edge
Edge.getNode0()
,
Edge.getTargetNode()
public GraphicEdge.EdgeGroup getGroup()
public <T extends Node> T getOpposite(Node node)
Edge
Return null if the given node is not at any end of the edge.
This method is implicitly generic and return something which extends Node. The return type is the one of the left part of the assignment. For example, in the following call :
ExtendedNode n = edge.getOppositeNode((ExtendedNode) m);the method will return an ExtendedNode. If no left part exists, method will just return a Node.
getOpposite
in interface Edge
node
- The node we search the opposite of.public <T extends Node> T 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.
This method is implicitly generic and return something which extends Node. The return type is the one of the left part of the assignment. For example, in the following call :
ExtendedNode n = edge.getSourceNode();the method will return an ExtendedNode. If no left part exists, method will just return a Node.
getSourceNode
in interface Edge
Edge.getNode0()
,
Edge.getTargetNode()
public <T extends Node> T 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.
This method is implicitly generic and return something which extends Node. The return type is the one of the left part of the assignment. For example, in the following call :
ExtendedNode n = edge.getTargetNode();the method will return an ExtendedNode. If no left part exists, method will just return a Node.
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()
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses