com.jfimagine.jfgraph.geom
Class LabelLine

java.lang.Object
  |
  +--com.jfimagine.jfgraph.geom.LineSeg
        |
        +--com.jfimagine.jfgraph.geom.LabelLine
All Implemented Interfaces:
java.lang.Cloneable

public class LabelLine
extends LineSeg

LabelLine class. A class used to represent a line to describe the size of shapes.

Attention: Here we used a clockwise quadrant system. And the first quadrant is under right bottom corner.

Version:
$Revision: 1.1 $
Author:
CookieMaker

Field Summary
 int CTRL_POINT_LEN
          A default minimum length of each ctrl point to end point of label line.
 
Constructor Summary
LabelLine()
          Constructor for LabelLine.
LabelLine(double x1, double y1, double x2, double y2)
          Constructor for LabelLine.
LabelLine(JFPoint startPoint, JFPoint endPoint)
          Constructor for LabelLine.
LabelLine(LabelLine line)
          Constructor for LabelLine.
 
Method Summary
 java.lang.Object clone()
          Creates a new object of the same class and with the same contents as this object.
 boolean contains(double x, double y, double pickOffset)
          Test if a point(x, y coordinates for instead) is on this line.
 boolean equals(java.lang.Object obj)
          Determines whether or not two objects are equal.
 void flipBy(double baseY)
          Reverse this line by a y coordinate.
 Rect getBounds()
          Get the bounds of this line segment.
 boolean getCtrl1Direction()
          1)Get the direction that the vector from start point to control point1 compares to the vector from start point to end point. 2)False if counter-clockwise, true if clockwise. 3)If ctrl1Direction is under counter-clockwise, then: ctrl2 is under clockwise, ctrl3 is under counter-clockwise, ctrl4 is under clockwise. 4)If reverse or mirror this label line, each direction will be !
 double getCtrl1Len()
          Get the length of control point1 to start point.
 double getCtrl2Len()
          Get the length of control point2 to start point.
 double getCtrl3Len()
          Get the length of control point3 to end point.
 double getCtrl4Len()
          Get the length of control point4 to end point.
 JFPoint getCtrlPoint1()
          Get the coordinates of control point1.
 JFPoint getCtrlPoint2()
          Get the coordinates of control point2.
 JFPoint getCtrlPoint3()
          Get the coordinates of control point3.
 JFPoint getCtrlPoint4()
          Get the coordinates of control point4.
 int hashCode()
          Returns the hashcode for this Object.
 boolean intersects(double x1, double y1, double x2, double y2)
          Tests if the specified line segment intersects this LabelLine.
 boolean intersects(Rect rect)
          Tests if the specified rectangle intersects the interior of this LineSeg.
 void mirrorBy(double baseX)
          Mirror this line by a x coordinate.
 void setCtrl1Direction(boolean direction)
          Set the direction that the vector from start point to control point1 compares to the vector from start point to end point.
 void setCtrl1Len(double len)
          Set the length of control point1 to start point.
 void setCtrl2Len(double len)
          Set the length of control point2 to start point.
 void setCtrl3Len(double len)
          Set the length of control point3 to end point.
 void setCtrl4Len(double len)
          Set the length of control point4 to end point.
 void setCtrlPoint1(double x, double y)
          Set the coordinates of control point1.
 void setCtrlPoint1(JFPoint pnt)
          Set the coordinates of control point1.
 void setCtrlPoint2(double x, double y)
          Set the coordinates of control point2.
 void setCtrlPoint2(JFPoint pnt)
          Set the coordinates of control point2.
 void setCtrlPoint3(double x, double y)
          Set the coordinates of control point3.
 void setCtrlPoint3(JFPoint pnt)
          Set the coordinates of control point3.
 void setCtrlPoint4(double x, double y)
          Set the coordinates of control point4.
 void setCtrlPoint4(JFPoint pnt)
          Set the coordinates of control point4.
 void setValue(LabelLine line)
          Set a label line's value by a new label line.
 java.lang.String toString()
          Convert this object to String
 
Methods inherited from class com.jfimagine.jfgraph.geom.LineSeg
closeTo, contains, contains, contains, distance, distance, flipBy, getCenter, getLength, getLength, getLength, getPoint1, getPoint2, getSlope, getSlope, getSlope, getSlope, getX1, getX2, getY1, getY2, intersects, intersects, intersectsAt, intersectsAt, mirrorBy, moveBy, rotateBy, rotateBy, rotateBy, sameLinePoints, sameLinePoints, scaleBy, scaleBy, scaleBy, scaleBy, setPoint1, setPoint1, setPoint2, setPoint2, setValue, setValue, setValue, setX1, setX2, setY1, setY2, uprightFoot, uprightFoot
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CTRL_POINT_LEN

public final int CTRL_POINT_LEN
A default minimum length of each ctrl point to end point of label line. For a label line, it will has four control points, two for start point, and the other two for end point.

See Also:
Constant Field Values
Constructor Detail

LabelLine

public LabelLine()
Constructor for LabelLine.


LabelLine

public LabelLine(double x1,
                 double y1,
                 double x2,
                 double y2)
Constructor for LabelLine.


LabelLine

public LabelLine(JFPoint startPoint,
                 JFPoint endPoint)
Constructor for LabelLine.

Parameters:
startPoint - The first endpoint.
endPoint - The second endpoint.

LabelLine

public LabelLine(LabelLine line)
Constructor for LabelLine.

Method Detail

getCtrl1Direction

public boolean getCtrl1Direction()
1)Get the direction that the vector from start point to control point1 compares to the vector from start point to end point. 2)False if counter-clockwise, true if clockwise. 3)If ctrl1Direction is under counter-clockwise, then: ctrl2 is under clockwise, ctrl3 is under counter-clockwise, ctrl4 is under clockwise. 4)If reverse or mirror this label line, each direction will be !Direction(true to false, false to true).

Returns:
The direction.

setCtrl1Direction

public void setCtrl1Direction(boolean direction)
Set the direction that the vector from start point to control point1 compares to the vector from start point to end point.

Parameters:
direction - A new direction.

getCtrl1Len

public double getCtrl1Len()
Get the length of control point1 to start point.

Returns:
the lengh of ctrl point1 to start point

setCtrl1Len

public void setCtrl1Len(double len)
Set the length of control point1 to start point.

Parameters:
len - the lengh of ctrl point1 to start point

getCtrlPoint1

public JFPoint getCtrlPoint1()
Get the coordinates of control point1.

Returns:
The coordinates of control point1.

setCtrlPoint1

public void setCtrlPoint1(JFPoint pnt)
Set the coordinates of control point1.

Parameters:
pnt - A new coordinates of control point1.

setCtrlPoint1

public void setCtrlPoint1(double x,
                          double y)
Set the coordinates of control point1.


getCtrl2Len

public double getCtrl2Len()
Get the length of control point2 to start point.

Returns:
the lengh of ctrl point3 to start point

setCtrl2Len

public void setCtrl2Len(double len)
Set the length of control point2 to start point.

Parameters:
len - the lengh of ctrl point3 to start point

getCtrlPoint2

public JFPoint getCtrlPoint2()
Get the coordinates of control point2.

Returns:
The coordinates of control point2.

setCtrlPoint2

public void setCtrlPoint2(JFPoint pnt)
Set the coordinates of control point2.

Parameters:
pnt - A new coordinates of control point2.

setCtrlPoint2

public void setCtrlPoint2(double x,
                          double y)
Set the coordinates of control point2.


getCtrl3Len

public double getCtrl3Len()
Get the length of control point3 to end point.

Returns:
the lengh of ctrl point3 to end point.

setCtrl3Len

public void setCtrl3Len(double len)
Set the length of control point3 to end point.

Parameters:
len - the lengh of ctrl point3 to end point.

getCtrlPoint3

public JFPoint getCtrlPoint3()
Get the coordinates of control point3.

Returns:
The coordinates of control point3.

setCtrlPoint3

public void setCtrlPoint3(JFPoint pnt)
Set the coordinates of control point3.

Parameters:
pnt - A new coordinates of control point3.

setCtrlPoint3

public void setCtrlPoint3(double x,
                          double y)
Set the coordinates of control point3.


getCtrl4Len

public double getCtrl4Len()
Get the length of control point4 to end point.

Returns:
the lengh of ctrl point4 to end point.

setCtrl4Len

public void setCtrl4Len(double len)
Set the length of control point4 to end point.

Parameters:
len - the lengh of ctrl point4 to end point.

getCtrlPoint4

public JFPoint getCtrlPoint4()
Get the coordinates of control point4.

Returns:
The coordinates of control point4.

setCtrlPoint4

public void setCtrlPoint4(JFPoint pnt)
Set the coordinates of control point4.

Parameters:
pnt - A new coordinates of control point4.

setCtrlPoint4

public void setCtrlPoint4(double x,
                          double y)
Set the coordinates of control point4.


setValue

public void setValue(LabelLine line)
Set a label line's value by a new label line.

Parameters:
line - A new label line.

getBounds

public Rect getBounds()
Get the bounds of this line segment.

Overrides:
getBounds in class LineSeg
Returns:
The bounds rectangle.

mirrorBy

public void mirrorBy(double baseX)
Mirror this line by a x coordinate. We make a left-right mirror here.

Overrides:
mirrorBy in class LineSeg
Parameters:
baseX - A mirror base x coordinate.

flipBy

public void flipBy(double baseY)
Reverse this line by a y coordinate. We make a up-down flip here.

Overrides:
flipBy in class LineSeg
Parameters:
baseY - A flip base y coordinate.

contains

public boolean contains(double x,
                        double y,
                        double pickOffset)
Test if a point(x, y coordinates for instead) is on this line. Here we used an analog offset for 'pick' this line.

Overrides:
contains in class LineSeg
Parameters:
x - X coordinate of this point.
y - Y coordinate of this point.
Returns:
True if the point is on this line, false otherwise.

intersects

public boolean intersects(double x1,
                          double y1,
                          double x2,
                          double y2)
Tests if the specified line segment intersects this LabelLine.

Overrides:
intersects in class LineSeg
Returns:
true if the specified line segment intersects the this LabelLine; false otherwise.

intersects

public boolean intersects(Rect rect)
Tests if the specified rectangle intersects the interior of this LineSeg.

Overrides:
intersects in class LineSeg
Parameters:
rect - the specified Rect to test for intersection with the interior of this LineSeg
Returns:
true if the specified Rect intersects the interior of this LineSeg; false otherwise.

toString

public java.lang.String toString()
Convert this object to String

Overrides:
toString in class LineSeg
Returns:
An string represents the content of the object

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Creates a new object of the same class and with the same contents as this object.

Overrides:
clone in class LineSeg
Returns:
A clone of this instance.
java.lang.CloneNotSupportedException

hashCode

public int hashCode()
Returns the hashcode for this Object.

Overrides:
hashCode in class LineSeg
Returns:
hash code for this Point2D.

equals

public boolean equals(java.lang.Object obj)
Determines whether or not two objects are equal.

Overrides:
equals in class LineSeg
Parameters:
obj - an object to be compared with this object
Returns:
true if the object to be compared is an instance of Port and has the same values; false otherwise.


Copyright 2004 ~ 2005 JingFei International Cooperation LTD. All Rights Reserved.