y.layout
Class DefaultEdgeLayout

java.lang.Object
  |
  +--y.layout.DefaultEdgeLayout
All Implemented Interfaces:
EdgeLayout

public class DefaultEdgeLayout
extends Object
implements EdgeLayout

This class is a default implementation of the EdgeLayout interface.


Constructor Summary
DefaultEdgeLayout()
          Creates a new DefaultEdgeLayout.
DefaultEdgeLayout(EdgeLayout layout)
          Creates a new DefaultEdgeLayout which is the copy of another EdgeLayout.
 
Method Summary
 void addPoint(double x, double y)
          Adds a control point to the end of the control point sequence.
 void clearPoints()
          Remove all control points from this edge layout.
 YPoint getPoint(int index)
          Returns the control point at position index of the sequence.
 YPoint getSourcePoint()
          Returns the relative coordinates of the first endpoint of this layout that is associated with the source node of the edge.
 YPoint getTargetPoint()
          Returns the relative coordinates of the second endpoint of this layout that is associated with the target node of the edge.
 int pointCount()
          Returns the number of control points of the edge.
 void setPoint(int index, double x, double y)
          Sets the coordinates of the control point at position index of the sequence.
 void setSourcePoint(YPoint point)
          Sets the relative coordinates of the first endpoint of this layout that is associated with the source node of the edge.
 void setTargetPoint(YPoint point)
          Sets the relative coordinates of the second endpoint of this layout that is associated with the target node of the edge.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultEdgeLayout

public DefaultEdgeLayout()
Creates a new DefaultEdgeLayout.


DefaultEdgeLayout

public DefaultEdgeLayout(EdgeLayout layout)
Creates a new DefaultEdgeLayout which is the copy of another EdgeLayout.

Parameters:
layout - another edge layout
Method Detail

pointCount

public int pointCount()
Description copied from interface: EdgeLayout
Returns the number of control points of the edge.

Specified by:
pointCount in interface EdgeLayout
Returns:
the number of control points

getPoint

public YPoint getPoint(int index)
Description copied from interface: EdgeLayout
Returns the control point at position index of the sequence.

Specified by:
getPoint in interface EdgeLayout
Parameters:
index - position of the control point in the control point sequence.
Returns:
the absolute coordinates the the control point at the given index
See Also:
EdgeLayout.setPoint(int, double, double)

setPoint

public void setPoint(int index,
                     double x,
                     double y)
Description copied from interface: EdgeLayout
Sets the coordinates of the control point at position index of the sequence. The coordinates of the control points The first control point in the sequence has index 0 and the last control point has index pointCount() - 1.

Specified by:
setPoint in interface EdgeLayout
Parameters:
index - position of the control point in the control point sequence.
x - absolute x-coordinate of the control point at the given index.
y - absolute y-coordinate of the control point at the given index.

addPoint

public void addPoint(double x,
                     double y)
Description copied from interface: EdgeLayout
Adds a control point to the end of the control point sequence.

Specified by:
addPoint in interface EdgeLayout
Parameters:
x - the absolute x-coordinate of the control point.
y - the absolute y-coordinate of the control point.

clearPoints

public void clearPoints()
Description copied from interface: EdgeLayout
Remove all control points from this edge layout.

Specified by:
clearPoints in interface EdgeLayout

getSourcePoint

public YPoint getSourcePoint()
Description copied from interface: EdgeLayout
Returns the relative coordinates of the first endpoint of this layout that is associated with the source node of the edge. The returned coordinates are relative to the center location of the source node of the edge. To obtain the absolute coordinate of the endpoint it is therefore necessary to add the center coordinate of the source node layout to the returned value.

Specified by:
getSourcePoint in interface EdgeLayout
Returns:
the relative coordinates of the source point.
See Also:
LayoutGraph.getCenterX(Node), LayoutGraph.getCenterY(Node), NodeLayout.getX(), NodeLayout.getWidth()

getTargetPoint

public YPoint getTargetPoint()
Description copied from interface: EdgeLayout
Returns the relative coordinates of the second endpoint of this layout that is associated with the target node of the edge. The returned coordinates are relative to the center location of the target node of the edge. To obtain the absolute coordinate of the endpoint it is therefore necessary to add the center coordinate of the target node layout to the returned value.

Specified by:
getTargetPoint in interface EdgeLayout
Returns:
the relative coordinates of the target point.
See Also:
LayoutGraph.getCenterX(Node), LayoutGraph.getCenterY(Node), NodeLayout.getX(), NodeLayout.getWidth()

setSourcePoint

public void setSourcePoint(YPoint point)
Description copied from interface: EdgeLayout
Sets the relative coordinates of the first endpoint of this layout that is associated with the source node of the edge. The given coordinates must be relative to the center location of the source node of the edge.

Specified by:
setSourcePoint in interface EdgeLayout
Parameters:
point - the relative coordinates of the source point.
See Also:
EdgeLayout.getTargetPoint()

setTargetPoint

public void setTargetPoint(YPoint point)
Description copied from interface: EdgeLayout
Sets the relative coordinates of the second endpoint of this layout that is associated with the target node of the edge. The given coordinates must be relative to the center location of the target node of the edge.

Specified by:
setTargetPoint in interface EdgeLayout
Parameters:
point - the relative coordinates of the source point.
See Also:
EdgeLayout.getTargetPoint()

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

2003