fdda.graphics.java2d
Class LineSegment

java.lang.Object
  |
  +--fdda.graphics.java2d.Component
        |
        +--fdda.graphics.java2d.LineSegment
All Implemented Interfaces:
Cloneable, Component

public class LineSegment
extends Component

A LineSegment is a segment of a line, bordered either by a point or by a node. The coordinates are the coordinates of the start point.

Author:
Jörg Rüdenauer

Field Summary
 
Fields inherited from class fdda.graphics.java2d.Component
COLOR_NORMAL, COLOR_SELECTED, dirtyShape, selected, shape, x, y
 
Fields inherited from interface fdda.graphics.Component
SEL_ALL, SEL_EQUALS, SEL_MOVABLES, SEL_NOTHING
 
Constructor Summary
LineSegment(double startX, double startY, double endX, double endY)
          Constructor
 
Method Summary
protected  void calcShape()
          Recalculates the shape.
 Object clone()
          Clones the component
 void draw(Graphics2D graphContext)
          Draws the component, using the given graphics.
 double getEndX()
          Returns the x coordinate of the end point
 double getEndY()
          Returns the y coordinate of the end point
 double getLength()
          Returns the length of the segment
 boolean isMovable()
          Returns false.
 void move(double x, double y)
          Moves both start and end point.
 void moveIn(double x, double y)
          Moves the start point.
 void moveOut(double x, double y)
          Moves the end point.
 int selectableWith()
          Returns SEL_EQUALS
 void setEndXY(double x, double y)
          Resets the end point.
 void setXY(double x, double y)
          Sets the coordinates of the component (or of its most prominent point).
 Object visit(ComponentVisitor visitor)
          Calls visitLineSegment according to visitor pattern.
 
Methods inherited from class fdda.graphics.java2d.Component
deselect, getGraphicalSystem, getShape, getX, getY, isSelected, recalculateShape, select, setGraphicalSystem
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LineSegment

public LineSegment(double startX,
                   double startY,
                   double endX,
                   double endY)
Constructor

Parameters:
startX - x coordinate of start point
startY - y coordinate of start point
endX - x coordinate of end point
endY - y coordinate of end point
Method Detail

clone

public Object clone()
Description copied from interface: Component
Clones the component

Specified by:
clone in interface Component
Overrides:
clone in class Component
Returns:
the clone

draw

public void draw(Graphics2D graphContext)
Description copied from class: Component
Draws the component, using the given graphics. The graphics should have the same attributes (color, pen, etc.) after the call as before the call.

Specified by:
draw in class Component
Parameters:
graphContext - the graphics

getEndX

public double getEndX()
Returns the x coordinate of the end point

Returns:
the x coordinate of the end point

getEndY

public double getEndY()
Returns the y coordinate of the end point

Returns:
the y coordinate of the end point

getLength

public double getLength()
Returns the length of the segment

Returns:
the length of the segment

move

public void move(double x,
                 double y)
Moves both start and end point.

Parameters:
x - offset for move in x direction
y - offset for move in y direction
See Also:
Component.move(double, double)

moveIn

public void moveIn(double x,
                   double y)
Moves the start point.

Parameters:
x - offset for x coordinate
y - offset for y coordinate

moveOut

public void moveOut(double x,
                    double y)
Moves the end point.

Parameters:
x - offset for x coordinate
y - offset for y coordinate

setXY

public void setXY(double x,
                  double y)
Description copied from interface: Component
Sets the coordinates of the component (or of its most prominent point).

Specified by:
setXY in interface Component
Overrides:
setXY in class Component
Parameters:
x - the x coordinate
y - the y coordinate

setEndXY

public void setEndXY(double x,
                     double y)
Resets the end point.

Parameters:
x - the new x coordinate of the end point
y - the new y coordinate of the end point

calcShape

protected void calcShape()
Description copied from class: Component
Recalculates the shape. Is called by getShape if the flag dirtyShape is set. Must unset the flag after calculation.

Specified by:
calcShape in class Component

isMovable

public boolean isMovable()
Returns false.

Returns:
true, iff the user can move the component
See Also:
Component.isMovable()

selectableWith

public int selectableWith()
Returns SEL_EQUALS

Returns:
constant indicating the selection class
See Also:
Component.selectableWith()

visit

public Object visit(ComponentVisitor visitor)
Calls visitLineSegment according to visitor pattern.

Parameters:
visitor - the visitor
Returns:
specific to subclass
See Also:
Component.visit(fdda.graphics.ComponentVisitor)


API documentation for FDDA version 0.9. Generated on 17/02/2004 14:12.