net.sf.latexdraw.glib.models.impl
Class LPoint

java.lang.Object
  extended by java.awt.geom.Point2D
      extended by java.awt.geom.Point2D.Double
          extended by net.sf.latexdraw.glib.models.impl.LPoint
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, IPoint

 class LPoint
extends java.awt.geom.Point2D.Double
implements IPoint

Defines a model of a point. This model must be used only to define other models. It is not a shape. See the LDot class for the shape.

This file is part of LaTeXDraw.
Copyright (c) 2005-2012 Arnaud BLOUIN

LaTeXDraw is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
LaTeXDraw is distributed without any warranty; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

02/13/2008

Since:
3.0
Version:
3.0
Author:
Arnaud BLOUIN

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.geom.Point2D
java.awt.geom.Point2D.Double, java.awt.geom.Point2D.Float
 
Field Summary
private static long serialVersionUID
           
 
Fields inherited from class java.awt.geom.Point2D.Double
x, y
 
Constructor Summary
protected LPoint()
          Creates a Point2D with coordinates (0, 0).
protected LPoint(double x, double y)
          Creates a Point2D with the specified coordinates.
protected LPoint(IPoint pt)
          Creates a point from a IPoint
 
Method Summary
 IPoint centralSymmetry(IPoint centre)
          Gets a point by central symmetry.
 double computeAngle(IPoint pt)
          Computes the angle of the given point where the calling point is used as the gravity centre.
 double computeRotationAngle(IPoint pt1, IPoint pt2)
          Computes the angle of rotation between two points where the calling point is used as the gravity centre.
 double distance(IPoint pt)
           
 boolean equals(IPoint p, double gap)
          Allows to know if the point p is equal to the current point considering a gap.
 IPoint getMiddlePoint(IPoint p)
           
 IPoint horizontalSymmetry(IPoint origin)
          Returns horizontally the point.
 IPoint rotatePoint(IPoint gravityC, double theta)
          Rotates a point with as reference another point.
 void setPoint(double newX, double newY)
          Sets the coordinates of the point.
 void setPoint(IPoint pt)
          Changes the coordinates of the point.
 void setPoint2D(java.awt.geom.Point2D pt)
          Defines the current point using the given point.
 void setX(double newX)
          Sets the X coordinate of the point.
 void setY(double newY)
          Sets the Y coordinate of the point.
 java.awt.geom.Point2D.Double toPoint2D()
           
 void translate(double tx, double ty)
          Translates the point.
 IPoint verticalSymmetry(IPoint origin)
          Returns vertically the point.
 IPoint zoom(double zoomLevel)
          Creates a new point zoomed using the calling points.
 
Methods inherited from class java.awt.geom.Point2D.Double
getX, getY, setLocation, toString
 
Methods inherited from class java.awt.geom.Point2D
clone, distance, distance, distance, distanceSq, distanceSq, distanceSq, equals, hashCode, setLocation
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.latexdraw.glib.models.interfaces.IPoint
distance, getX, getY
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

LPoint

protected LPoint()
Creates a Point2D with coordinates (0, 0).


LPoint

protected LPoint(IPoint pt)
Creates a point from a IPoint

Parameters:
pt - The IPoint, if null the default value (0,0) will be used.

LPoint

protected LPoint(double x,
                 double y)
Creates a Point2D with the specified coordinates.

Parameters:
x - The X-coordinate to set.
y - The Y-coordinate to set.
Method Detail

computeAngle

public double computeAngle(IPoint pt)
Description copied from interface: IPoint
Computes the angle of the given point where the calling point is used as the gravity centre.

Specified by:
computeAngle in interface IPoint
Parameters:
pt - The point used to compute the angle.
Returns:
The angle or NaN if the given point is not valid.

zoom

public IPoint zoom(double zoomLevel)
Description copied from interface: IPoint
Creates a new point zoomed using the calling points.

Specified by:
zoom in interface IPoint
Parameters:
zoomLevel - The zoom level.
Returns:
The zoomed point.

computeRotationAngle

public double computeRotationAngle(IPoint pt1,
                                   IPoint pt2)
Description copied from interface: IPoint
Computes the angle of rotation between two points where the calling point is used as the gravity centre.

Specified by:
computeRotationAngle in interface IPoint
Parameters:
pt1 - The first point.
pt2 - The second point.
Returns:
The rotation point or NaN if one of the given point is not valid.

centralSymmetry

public IPoint centralSymmetry(IPoint centre)
Description copied from interface: IPoint
Gets a point by central symmetry.

Specified by:
centralSymmetry in interface IPoint
Parameters:
centre - The centre of the symmetry.
Returns:
The resulting point.

rotatePoint

public IPoint rotatePoint(IPoint gravityC,
                          double theta)
Description copied from interface: IPoint
Rotates a point with as reference another point.

Specified by:
rotatePoint in interface IPoint
Parameters:
gravityC - The point of reference.
theta - The angle of rotation in radian.
Returns:
The rotated point.

equals

public boolean equals(IPoint p,
                      double gap)
Description copied from interface: IPoint
Allows to know if the point p is equal to the current point considering a gap.

Specified by:
equals in interface IPoint
Parameters:
p - The point to compare.
gap - The approximation gap.
Returns:
True if they are equals considering the gap.

getMiddlePoint

public IPoint getMiddlePoint(IPoint p)
Specified by:
getMiddlePoint in interface IPoint
Parameters:
p - The second point.
Returns:
The middle point of the current and given points.

translate

public void translate(double tx,
                      double ty)
Description copied from interface: IPoint
Translates the point. If one of the given coordinate is not valid (NaN, infinite,...), then the translation does not occur.

Specified by:
translate in interface IPoint
Parameters:
tx - The X translation.
ty - The Y translation.

horizontalSymmetry

public IPoint horizontalSymmetry(IPoint origin)
Description copied from interface: IPoint
Returns horizontally the point.

Specified by:
horizontalSymmetry in interface IPoint
Parameters:
origin - The location of the horizontal axe.
Returns:
the computed point or null is the given point is not valid or if a problem occurs.

verticalSymmetry

public IPoint verticalSymmetry(IPoint origin)
Description copied from interface: IPoint
Returns vertically the point.

Specified by:
verticalSymmetry in interface IPoint
Parameters:
origin - The location of the vertical axe.
Returns:
the computed point or null is the given point is not valid or if a problem occurs.

setPoint

public void setPoint(double newX,
                     double newY)
Description copied from interface: IPoint
Sets the coordinates of the point.

Specified by:
setPoint in interface IPoint
Parameters:
newX - The new X coordinate. Must be valid (not equal too NaN,...).
newY - The new Y coordinate. Must be valid (not equal too NaN,...).

setX

public void setX(double newX)
Description copied from interface: IPoint
Sets the X coordinate of the point.

Specified by:
setX in interface IPoint
Parameters:
newX - The new X coordinate. Must be valid (not equal too NaN,...).

setY

public void setY(double newY)
Description copied from interface: IPoint
Sets the Y coordinate of the point.

Specified by:
setY in interface IPoint
Parameters:
newY - The new Y coordinate. Must be valid (not equal too NaN,...).

setPoint

public void setPoint(IPoint pt)
Description copied from interface: IPoint
Changes the coordinates of the point.

Specified by:
setPoint in interface IPoint
Parameters:
pt - The new position.

distance

public double distance(IPoint pt)
Specified by:
distance in interface IPoint
Parameters:
pt - The second point.
Returns:
The distance between the two points.

toPoint2D

public java.awt.geom.Point2D.Double toPoint2D()
Specified by:
toPoint2D in interface IPoint
Returns:
A Point2D.Double point equivalent to the current point.

setPoint2D

public void setPoint2D(java.awt.geom.Point2D pt)
Description copied from interface: IPoint
Defines the current point using the given point.

Specified by:
setPoint2D in interface IPoint
Parameters:
pt - The point 2D to copy.