|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gishur.graph.gui.FloatPoint
Class representing a point with float
coordinates.
Field Summary | |
static float |
IDENTICAL
The minimal distance between two points which allows to say that they are 'different'. |
float |
x
The coordinates. |
float |
y
The coordinates. |
Fields inherited from interface gishur.core.ControlledCloneable |
DEEP, FLAT |
Constructor Summary | |
FloatPoint()
Empty constructor setting the coordinate to 0,0 . |
|
FloatPoint(double x,
double y)
Constructor accepting two double numbers as coordinates.
|
|
FloatPoint(float x,
float y)
Constructor accepting two float numbers as coordinates. |
|
FloatPoint(FloatPoint fp1,
FloatPoint fp2)
Creates a new FloatPoint which lies on the middle point of the
line between fp1 and fp2 . |
|
FloatPoint(int xc,
int yc)
Constructor accepting two int numbers as coordinates.
|
|
FloatPoint(java.awt.Point p)
Constructor accepting a java.awt.Point as argument. |
Method Summary | |
java.lang.Object |
clone()
Creates a new object of the same class as this object. |
java.lang.Object |
clone(java.util.Hashtable h,
int level)
Clones this object. |
static FloatPoint |
copy(FloatPoint fp)
Creates a new FloatPoint with fp 's coordinates. |
boolean |
equals(float x,
float y)
Interprets x and y as coordinates and checks, if
they differ less than IDENTICAL from this points
coordinates. |
boolean |
equals(java.lang.Object o)
Checks, if two FloatPoints are equal, i.e. |
float |
norm()
Returns the length of this point's coordinate vector as a
float number. |
void |
normalize()
Normalizes the coordinate vector. |
java.awt.Point |
point()
Returns this FloatPoint's coordinates casted to a java.awt.Point .
|
void |
set(float x,
float y)
Sets this FloatPoint's coordinates to the specified values. |
void |
setLength(float length)
Sets the length of the coordinate vector (keeping the angle unchanged), e.g. |
void |
setPolar(float angle,
float length)
Sets the point to the specified polar coordinates. |
java.lang.String |
toString()
Overrides the java.lang.Object.toString() -method. |
java.lang.String |
toString(boolean brackets)
Same as toString() , but with optional brackets around. |
void |
transform(double m00,
double m01,
double m02,
double m10,
double m11,
double m12)
Transforms this FloatPoint by the given affine
transformation matrix. |
void |
translatePolar(float angle,
float length)
Translates the point by the vector represeted by angle and length . |
Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final float IDENTICAL
public float x
public float y
Constructor Detail |
public FloatPoint()
0,0
.public FloatPoint(float x, float y)
float
numbers as coordinates.x
- the x-coordinatey
- the y-coordinatepublic FloatPoint(double x, double y)
double
numbers as coordinates.
Note that the doubles
will be casted down to floats
,
which will cause a possible loss of data.x
- the x-coordinatey
- the y-coordinatepublic FloatPoint(int xc, int yc)
int
numbers as coordinates.
The ints
will be casted up to floats
, that is possible without a loss
of data.x
- the x-coordinatey
- the y-coordinatepublic FloatPoint(java.awt.Point p)
java.awt.Point
as argument. The Point
's
(int
) coordinates will be casted to floats
and will become the
FloatPoint's
new coordinates.x
- the x-coordinatey
- the y-coordinatepublic FloatPoint(FloatPoint fp1, FloatPoint fp2)
FloatPoint
which lies on the middle point of the
line between fp1
and fp2
.fp1,fp2
- two FloatPoints
Method Detail |
public static FloatPoint copy(FloatPoint fp)
FloatPoint
with fp
's coordinates.fp
- the FloatPoint
to copyFloatPoint
with the same coordinatespublic java.lang.String toString()
java.lang.Object.toString()
-method.toString
in class java.lang.Object
x,y
public java.lang.String toString(boolean brackets)
toString()
, but with optional brackets around.brackets
- if true
a String
of the form
(x,y)
will be returned, otherwise a String
like x,y
public boolean equals(java.lang.Object o)
FloatPoints
are equal, i.e. o==this
,
or their coordinates differ less than IDENTICAL
. If o==null
,
or o
is no FloatPoint
, false
will be returned.
Overrides java.lang.Object.equals(Object)
.equals
in class java.lang.Object
o
- the object to check for equality with this
true
, if o==this
,
or their coordinates differ less than IDENTICAL
public boolean equals(float x, float y)
x
and y
as coordinates and checks, if
they differ less than IDENTICAL
from this
points
coordinates.x,y
- two float
coordinatestrue
, if
they differ less than IDENTICAL
from this
points
coordinates, false
otherwisepublic java.awt.Point point()
FloatPoint's
coordinates casted to a java.awt.Point
.
Note that this causes a loss of precision, as a Point's
coordinates are ints
.java.awt.Point
public void set(float x, float y)
this
FloatPoint's
coordinates to the specified values.x,y
- the new coordinate valuespublic void setPolar(float angle, float length)
angle
- the angle between polar coordinates vector and the x-axisthe
- length of the polar coordinates vectorpublic void setLength(float length)
setLength(1)
normalizes the vector.
If the coordinates are 0,0
, the method returns effectiveless.length
- the new length of the coordinates vectorpublic void translatePolar(float angle, float length)
angle
and length
.angle
- the angle of the translation vectorlength
- the length of the translation vectorpublic void normalize()
public float norm()
this
point's coordinate vector as a
float
number.public void transform(double m00, double m01, double m02, double m10, double m11, double m12)
this
FloatPoint
by the given affine
transformation matrix.m00,m01,m02
- first row of the transformation matrixm10,m11,m12
- second row of the transformation matrixpublic java.lang.Object clone()
clone
in interface Cloneable
clone
in class java.lang.Object
this
object.public java.lang.Object clone(java.util.Hashtable h, int level)
this
object. According to the parameter level
,
this
object will be cloned down to level
levels.
That means, the object will be cloned. If level==-1(==DEEP)
,
every object, which can be reached by traversing the references beginning
with /this object will be cloned if possible. This recursion
stopps, if there are no more object to clone, or no reachable object implements
Cloneable. If level==0(==FLAT)
, no object contained by this
object will be cloned. Only the references will be
maintained. If level>=1
, the recursion will stopp after cloning
level
generations (or earlier if e.g. no more contained objects
are cloneable).
The recursive cloning stopps, if there's a ring
structure. In this case, all Objects implementing Cloneable
are cloned,
and connected proper, so that even ring structures are cloned as rings.
- Specified by:
clone
in interface ControlledCloneable
- Parameters:
h
- Hastable which containes all objects already cloned (with their original objects
as keys), to avoid multiple cloning of the same object (if h==null
a new Hashtable will be created - you can use null
to start a clone recursion)level
- indicates how many generations should be cloned recursive at most- Returns:
- the cloned Object
- Throws:
InternalError
- - if the Object could not be cloned properly
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |