org.openjump.core.graph.pirolProject
Class PirolPoint

java.lang.Object
  extended by org.openjump.core.apitools.comparisonandsorting.Sortable
      extended by org.openjump.core.graph.pirolProject.PirolPoint
All Implemented Interfaces:
java.lang.Comparable
Direct Known Subclasses:
CorrelationDataPair

public class PirolPoint
extends Sortable

Base class for objects that describe an n-dimensional point. There are derived classes e.g. to suit the requirements of a triangulation or an interpolation. Offers methods e.g. to determine distances between different punkt objects or to mark and unmark punkt objects. punkt objects implement Sortable and have a choseable natural order (implement Comparable), so they can be sorted with the tools from the Java Collection Framework.

Version:
$Rev: 2509 $
Author:
Ole Rahn

FH Osnabrück - University of Applied Sciences Osnabrück,
Project: PIROL (2005),
Subproject: Daten- und Wissensmanagement
See Also:
de.fhOsnabrueck.jump.pirol.utilities.PirolEdge, modified: [sstein]: 16.Feb.2009 changed logger-entries to comments

Field Summary
protected  double[] coordinates
           
protected  int dimension
           
protected  int index
           
protected  boolean marked
           
static PirolPoint NULLPUNKT
           
protected  boolean scaled
           
protected  ScaleChanger scaler
           
 
Fields inherited from class org.openjump.core.apitools.comparisonandsorting.Sortable
sortFor
 
Constructor Summary
PirolPoint()
          For classLoaders
PirolPoint(double[] coords)
           
PirolPoint(double[] coords, int index)
           
PirolPoint(double[] coords, int index, ScaleChanger scaler)
           
PirolPoint(double[] coords, int index, ScaleChanger scaler, boolean prescaled)
           
 
Method Summary
static PirolPoint clone(PirolPoint pkt)
          Method to create a deep copy of the given punkt object, that doesn't share any references with the original
 PirolPoint clonePunkt()
          Method to create a deep copy of the calling punkt object, that doesn't share any references with the original
 int compareTo(java.lang.Object arg0)
           
static PirolPoint createVector(PirolPoint from, PirolPoint to)
          creates a punkt object that represents a vector (x,y(,z)) that shows the direction that leads from point "from" to point "to".
static double distanceBetween(PirolPoint p1, PirolPoint p2)
          calculates the distance of point p1 to the other point p2.
 double distanceTo(PirolPoint p)
          calculates the distance of this point to the other point.
 boolean equals(java.lang.Object obj)
           
 double getCoordinate(int nr)
          get the nr-th coordinate.
 double[] getCoordinates()
           
 int getDimension()
           
 int getIndex()
           
 int getSortFor()
           
 double getX()
          get 0-th coordinate
 double getY()
          get 1-st coordinate
 double getZ()
          get 2-nd coordinate
 boolean isMarked()
          check if marked was set or not
 boolean liegtAuf(PirolPoint p)
           
 void scale()
           
 void setCoordinate(double newCoord, int nr)
          set the nr-th coordinate.
 void setCoordinates(double[] coordinates)
           
 void setIndex(int index)
           
 void setMarked(boolean marked)
          set boolean flag of the object, to e.g. mark if this point was already passed or whatever.
 void setScaler(ScaleChanger scaler)
           
 void setSortFor(int sortFor)
           
 void setX(double val)
          set the 0-th coordinate
 void setY(double val)
          set the 1-st coordinate
 void setZ(double val)
          set the 2-nd coordinate
 com.vividsolutions.jts.geom.Coordinate toCoordinate()
           
static com.vividsolutions.jts.geom.Coordinate toCoordinate(PirolPoint p)
           
 java.lang.String toString()
           
 void unScale()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

coordinates

protected double[] coordinates

dimension

protected int dimension

index

protected int index

NULLPUNKT

public static final PirolPoint NULLPUNKT

scaler

protected ScaleChanger scaler

scaled

protected boolean scaled

marked

protected boolean marked
Constructor Detail

PirolPoint

public PirolPoint()
For classLoaders


PirolPoint

public PirolPoint(double[] coords)

PirolPoint

public PirolPoint(double[] coords,
                  int index)

PirolPoint

public PirolPoint(double[] coords,
                  int index,
                  ScaleChanger scaler,
                  boolean prescaled)

PirolPoint

public PirolPoint(double[] coords,
                  int index,
                  ScaleChanger scaler)
Method Detail

createVector

public static PirolPoint createVector(PirolPoint from,
                                      PirolPoint to)
creates a punkt object that represents a vector (x,y(,z)) that shows the direction that leads from point "from" to point "to".

Parameters:
from - source points of the vector
to - destination point of the vector
Returns:
a vector from from to to ;-)

clone

public static PirolPoint clone(PirolPoint pkt)
Method to create a deep copy of the given punkt object, that doesn't share any references with the original

Parameters:
pkt - the punkt object to clone
Returns:
copy of the given punkt object
Since:
1.15

clonePunkt

public PirolPoint clonePunkt()
Method to create a deep copy of the calling punkt object, that doesn't share any references with the original

Returns:
copy of the punkt object
Since:
1.15

isMarked

public boolean isMarked()
check if marked was set or not

Returns:
true, if marked is true

setMarked

public void setMarked(boolean marked)
set boolean flag of the object, to e.g. mark if this point was already passed or whatever.

Parameters:
marked - boolean value to set the internal flag to

liegtAuf

public boolean liegtAuf(PirolPoint p)

equals

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

getSortFor

public int getSortFor()
Specified by:
getSortFor in class Sortable

setSortFor

public void setSortFor(int sortFor)
Specified by:
setSortFor in class Sortable

setScaler

public void setScaler(ScaleChanger scaler)

scale

public void scale()
           throws java.lang.RuntimeException
Throws:
java.lang.RuntimeException

unScale

public void unScale()
             throws java.lang.RuntimeException
Throws:
java.lang.RuntimeException

getCoordinates

public double[] getCoordinates()

setCoordinates

public void setCoordinates(double[] coordinates)

getIndex

public int getIndex()

setIndex

public void setIndex(int index)

getDimension

public int getDimension()

getCoordinate

public double getCoordinate(int nr)
                     throws java.lang.RuntimeException
get the nr-th coordinate. This method is used within getX(), getY(), getZ().

Returns:
the nr-th coordinate
Throws:
java.lang.RuntimeException - if the point has less coordniates than nr or if nr is less than zero

setCoordinate

public void setCoordinate(double newCoord,
                          int nr)
set the nr-th coordinate. This method is used within setX(), setY(), setZ().

Parameters:
newCoord - new Coordinate
nr - number of coordinate to set

getX

public double getX()
            throws java.lang.RuntimeException
get 0-th coordinate

Returns:
0-th coordinate
Throws:
java.lang.RuntimeException

getY

public double getY()
            throws java.lang.RuntimeException
get 1-st coordinate

Returns:
1-st coordinate
Throws:
java.lang.RuntimeException

getZ

public double getZ()
            throws java.lang.RuntimeException
get 2-nd coordinate

Returns:
2-nd coordinate
Throws:
java.lang.RuntimeException

setX

public void setX(double val)
set the 0-th coordinate

Parameters:
val - 0-th coordinate

setY

public void setY(double val)
set the 1-st coordinate

Parameters:
val - 1-st coordinate

setZ

public void setZ(double val)
set the 2-nd coordinate

Parameters:
val - 2-nd coordinate

distanceTo

public double distanceTo(PirolPoint p)
                  throws java.lang.RuntimeException
calculates the distance of this point to the other point. The distance will be calculated in as many dimensions as both points have. If the two points have a different amount of coordinates, this will happen: int checkDim = Math.min(this.dimension, p.getDimension());

Parameters:
p - the other point
Returns:
distance between the two points
Throws:
java.lang.RuntimeException

distanceBetween

public static double distanceBetween(PirolPoint p1,
                                     PirolPoint p2)
                              throws java.lang.RuntimeException
calculates the distance of point p1 to the other point p2. The distance will be calculated in as many dimensions as both points have. If the two points have a different amount of coordinates, this will happen: int checkDim = Math.min(this.dimension, p.getDimension());

Parameters:
p1 - one point
p2 - the other point
Returns:
distance between the two points
Throws:
java.lang.RuntimeException

toString

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

compareTo

public int compareTo(java.lang.Object arg0)
Specified by:
compareTo in interface java.lang.Comparable
Specified by:
compareTo in class Sortable

toCoordinate

public com.vividsolutions.jts.geom.Coordinate toCoordinate()
                                                    throws java.lang.RuntimeException
Throws:
java.lang.RuntimeException

toCoordinate

public static com.vividsolutions.jts.geom.Coordinate toCoordinate(PirolPoint p)
                                                           throws java.lang.RuntimeException
Throws:
java.lang.RuntimeException