com.partnersoft.v3x.geometry.single
Class Line

java.lang.Object
  extended by com.partnersoft.v3x.geometry.single.Line
All Implemented Interfaces:
java.io.Serializable

public class Line
extends java.lang.Object
implements java.io.Serializable

A float-precision line class.

See Also:
Serialized Form

Field Summary
 float x1
           
 float x2
           
 float y1
           
 float y2
           
 
Constructor Summary
Line()
           
Line(float x1, float y1, float x2, float y2)
           
 
Method Summary
 boolean clipToRectangle(Rectangle rectangle)
          Clip this line to rectangle.
 boolean equals(Line nother)
           
 boolean equals(java.lang.Object nother)
           
 float getLength()
           
 float getSlope()
           
 float getX1()
           
 float getX2()
           
 float getY1()
           
 float getY2()
           
 boolean isDegenerate()
           
 boolean isHorizontal()
           
 boolean isVertical()
           
 void setToMatch(Line nother)
           
 void setX1(float newX)
           
 void setX2(float newX)
           
 void setY1(float newY)
           
 void setY2(float newY)
           
 float solveForX(float y)
          Finds the x for the given y.
 float solveForY(float x)
          Finds the y for the given x.
 void sortBottomToTop()
          Makes it run from bottom to top (so y1 <= y2)
 void sortLeftToRight()
          Makes it run from left to right (so x1 <= x2)
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

x1

public float x1

y1

public float y1

x2

public float x2

y2

public float y2
Constructor Detail

Line

public Line()

Line

public Line(float x1,
            float y1,
            float x2,
            float y2)
Method Detail

getX1

public float getX1()

setX1

public void setX1(float newX)

getY1

public float getY1()

setY1

public void setY1(float newY)

getX2

public float getX2()

setX2

public void setX2(float newX)

getY2

public float getY2()

setY2

public void setY2(float newY)

setToMatch

public void setToMatch(Line nother)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isDegenerate

public boolean isDegenerate()

isVertical

public boolean isVertical()

isHorizontal

public boolean isHorizontal()

getSlope

public float getSlope()

getLength

public float getLength()

equals

public boolean equals(Line nother)

equals

public boolean equals(java.lang.Object nother)
Overrides:
equals in class java.lang.Object

solveForX

public float solveForX(float y)
Finds the x for the given y.


solveForY

public float solveForY(float x)
Finds the y for the given x.


sortLeftToRight

public void sortLeftToRight()
Makes it run from left to right (so x1 <= x2)


sortBottomToTop

public void sortBottomToTop()
Makes it run from bottom to top (so y1 <= y2)


clipToRectangle

public boolean clipToRectangle(Rectangle rectangle)
Clip this line to rectangle. Returns false if the line does not intersect the rectangle, and leaves x and y in an indeterminate state.