net.sourceforge.toscanaj.model.diagram
Class DiagramLine

java.lang.Object
  extended bynet.sourceforge.toscanaj.model.diagram.DiagramLine
All Implemented Interfaces:
XMLizable

public class DiagramLine
extends java.lang.Object
implements XMLizable

This encapsulates all information about a line in a diagram. This is just the information which nodes the line connects.


Field Summary
static java.lang.String DIAGRAM_LINE_ELEMENT_NAME
           
static java.lang.String FROM_NODE_ATTRIBUTE_NAME
           
static java.lang.String TO_NODE_ATTRIBUTE_NAME
           
 
Constructor Summary
DiagramLine(DiagramNode fromNode, DiagramNode toNode, Diagram2D diagram)
          Initialises a line between the given nodes.
DiagramLine(org.jdom.Element element, Diagram2D diagram)
           
 
Method Summary
 double calculateDistance(java.awt.geom.Point2D point)
          Returns the distance of the given point to the line.
 DiagramNode getFromNode()
          Returns the starting node in a Diagram in which DiagramLine object will be connecting.
 java.awt.geom.Point2D getFromPosition()
          Returns coordinates of first node in a Diagram in which DiagramLine object will be connecting.
 double getLength()
          Returns the length of this line.
 DiagramNode getToNode()
          Returns the end node in a Diagram in which DiagramLine object will be connecting.
 java.awt.geom.Point2D getToPosition()
          Returns coordinates of second node in a Diagram in which DiagramLine object will be connecting.
 void readXML(org.jdom.Element elem)
          Read this element as the content of elem.
 void setFromPoint(DiagramNode fromNode)
          Sets the fromPoint to a node in a Diagram.
 void setToPoint(DiagramNode toNode)
          Sets the toPoint at the position of a node on a Diagram
 org.jdom.Element toXML()
          Write this element as the content of elem.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DIAGRAM_LINE_ELEMENT_NAME

public static final java.lang.String DIAGRAM_LINE_ELEMENT_NAME
See Also:
Constant Field Values

FROM_NODE_ATTRIBUTE_NAME

public static final java.lang.String FROM_NODE_ATTRIBUTE_NAME
See Also:
Constant Field Values

TO_NODE_ATTRIBUTE_NAME

public static final java.lang.String TO_NODE_ATTRIBUTE_NAME
See Also:
Constant Field Values
Constructor Detail

DiagramLine

public DiagramLine(DiagramNode fromNode,
                   DiagramNode toNode,
                   Diagram2D diagram)
Initialises a line between the given nodes.


DiagramLine

public DiagramLine(org.jdom.Element element,
                   Diagram2D diagram)
            throws XMLSyntaxError
Method Detail

toXML

public org.jdom.Element toXML()
Description copied from interface: XMLizable
Write this element as the content of elem.

Specified by:
toXML in interface XMLizable

readXML

public void readXML(org.jdom.Element elem)
             throws XMLSyntaxError
Description copied from interface: XMLizable
Read this element as the content of elem.

Specified by:
readXML in interface XMLizable
Throws:
XMLSyntaxError

getFromNode

public DiagramNode getFromNode()
Returns the starting node in a Diagram in which DiagramLine object will be connecting.


getToNode

public DiagramNode getToNode()
Returns the end node in a Diagram in which DiagramLine object will be connecting.


getFromPosition

public java.awt.geom.Point2D getFromPosition()
Returns coordinates of first node in a Diagram in which DiagramLine object will be connecting. This is just a convenienced method to not having to get the node and then its position.


getToPosition

public java.awt.geom.Point2D getToPosition()
Returns coordinates of second node in a Diagram in which DiagramLine object will be connecting. This is just a convenienced method to not having to get the node and then its position.


setFromPoint

public void setFromPoint(DiagramNode fromNode)
Sets the fromPoint to a node in a Diagram.


setToPoint

public void setToPoint(DiagramNode toNode)
Sets the toPoint at the position of a node on a Diagram


getLength

public double getLength()
Returns the length of this line.


calculateDistance

public double calculateDistance(java.awt.geom.Point2D point)
Returns the distance of the given point to the line. Note that the line has ends, a point which is further not to the side of the line will have its distance determined by its distance to the closer end point.



The ToscanaJ project