org.shapelogic.polygon
Class CLine

java.lang.Object
  extended by org.shapelogic.polygon.CLine
All Implemented Interfaces:
java.lang.Comparable<ILine2D>, GeometricShape2D, ILine2D, PointReplacable<CLine>

public class CLine
extends java.lang.Object
implements ILine2D, PointReplacable<CLine>

Class for line. Works for both double and int based points. Can be used for both undirected and directed lines I think this is made to be immutable, but points are not. But in order to have the sort work for lines I have to assume that the points in it are not moving.

Author:
Sami Badawi

Constructor Summary
CLine(IPoint2D p1, IPoint2D p2)
           
 
Method Summary
 double angle()
          Should return numbers in the range 0 to PI.
 int compareTo(ILine2D that)
           
 double distance()
           
 boolean equals(java.lang.Object that)
           
static java.util.List<CLine> filterHorizontal(java.util.Collection<CLine> inputLines)
           
static java.util.List<CLine> filterVertical(java.util.Collection<CLine> inputLines)
           
 IPoint2D getCenter()
           
 double getDiameter()
           
 IPoint2D getEnd()
           
 IPoint2D getStart()
           
 int hashCode()
           
 boolean isHorizontal()
           
 boolean isLineOrdered()
          Check if the points in this line is ordered alphabetically
 boolean isPoint()
           
 boolean isVertical()
           
 CLine lineStartingAtPoint(IPoint2D point)
           
static CLine makeUnordered(IPoint2D p1, IPoint2D p2)
           
 CLine oppositeDirectionLine()
           
 CLine orderedLine()
          Just order the points in this line alphabetically.
 IPoint2D relativePoint()
           
 CLine replacePointsInMap(java.util.Map<IPoint2D,IPoint2D> pointReplacementMap, AnnotatedShapeImplementation annotatedShape)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CLine

public CLine(IPoint2D p1,
             IPoint2D p2)
Method Detail

makeUnordered

public static CLine makeUnordered(IPoint2D p1,
                                  IPoint2D p2)

getEnd

public IPoint2D getEnd()
Specified by:
getEnd in interface ILine2D

getStart

public IPoint2D getStart()
Specified by:
getStart in interface ILine2D

compareTo

public int compareTo(ILine2D that)
Specified by:
compareTo in interface java.lang.Comparable<ILine2D>

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

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

relativePoint

public IPoint2D relativePoint()

angle

public double angle()
Should return numbers in the range 0 to PI.

Returns:
the angle in redians

isVertical

public boolean isVertical()

isHorizontal

public boolean isHorizontal()

isPoint

public boolean isPoint()

distance

public double distance()

toString

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

filterHorizontal

public static java.util.List<CLine> filterHorizontal(java.util.Collection<CLine> inputLines)

filterVertical

public static java.util.List<CLine> filterVertical(java.util.Collection<CLine> inputLines)

replacePointsInMap

public CLine replacePointsInMap(java.util.Map<IPoint2D,IPoint2D> pointReplacementMap,
                                AnnotatedShapeImplementation annotatedShape)
Specified by:
replacePointsInMap in interface PointReplacable<CLine>

orderedLine

public CLine orderedLine()
Just order the points in this line alphabetically.


isLineOrdered

public boolean isLineOrdered()
Check if the points in this line is ordered alphabetically


getCenter

public IPoint2D getCenter()
Specified by:
getCenter in interface GeometricShape2D

getDiameter

public double getDiameter()
Specified by:
getDiameter in interface GeometricShape2D

lineStartingAtPoint

public CLine lineStartingAtPoint(IPoint2D point)

oppositeDirectionLine

public CLine oppositeDirectionLine()


Copyright © 2009. All Rights Reserved.