Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| http://www.jpicedt.org
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## jpicedt.graphic
Class PicPoint

    java.lang.Object
      java.awt.geom.Point2D
          java.awt.geom.Point2D.Double
              jpicedt.graphic.PicPoint

All Implemented Interfaces:
  Cloneable

Direct Known Subclasses:
  PicVector

public class PicPoint
extends Point2D.Double
implements Cloneable

Enhancement of Point2D.Double with convenient formatting methods and constructors.

Since:
  jpicedt 1.0
Version:
  $Id: PicPoint.java,v 1.12.2.1 2007/09/02 11:56:17 reynal Exp $
Author:
  Sylvain Reynal

Nested Class Summary
`static class` | `PicPoint.XComparator` a comparator b/w PicPoint for X-axis ordering
`static class` | `PicPoint.YComparator` a comparator b/w PicPoint for Y-axis ordering

Nested classes inherited from class java.awt.geom.Point2D
`Point2D.Double, Point2D.Float`

Field Summary
`static PicPoint.XComparator` | `X_COMPARATOR`
`static PicPoint.YComparator` | `Y_COMPARATOR`

Fields inherited from class java.awt.geom.Point2D.Double
`x, y`

Constructor Summary
`PicPoint()` Construct a (0,0) point.
`PicPoint(double[] f)` Construct a point from the first two elements of the given array.
`PicPoint(double x, double y)` Construct (x,y)
`PicPoint(float[] f)` Construct a point from the first two elements of the given array.
`PicPoint(Number x, Number y)` Construct a point from the given pair of Number (using their double value).
`PicPoint(Point2D p)` Clone the given point.
`PicPoint(Point2D p1, Point2D p2, double ratio)` Construct a new PicPoint "p" located on the line joining p1 with p2, so that (p1,p) = ratio * (p1,p2)
`PicPoint(String str)` Construct a point by parsing a String similar to that given by the `toString()` method, ie `(x,y)`.

Method Summary
`void` | `apply(AffineTransform at)` Apply the given AffineTransform to the coordinates of this point
`Object` | `clone()` Creates and returns a deep copy of this PicPoint.
`static void` | `main(String[] args)` validation tests
`PicPoint` | `middle(PicPoint other)` Translate this point to the middle of the segment made of [this,other].
`PicPoint` | `project(PicPoint p1, PicPoint p2)` Project this point onto the line joining p1 and p2.
`PicPoint` | `project(PicPoint p1, PicPoint p2, PicPoint dir)` Project this point onto the line joining p1 and p2.
`PicPoint` | `rotate(PicPoint ptOrg, double angle)` Apply a rotation of center ptOrg and the given angle in radians to this PicPoint Current implementation arranges for a very fast code if angle is Math.PI, Math.PI/2 or -Math.PI/2.
`PicPoint` | `scale(double ptOrgX, double ptOrgY, double s)` Apply a scaling transform to this point.
`PicPoint` | `scale(double ptOrgX, double ptOrgY, double sx, double sy)` Apply a scaling transform to this point.
`PicPoint` | `scale(PicPoint ptOrg, double s)` Apply a scaling transform to this point.
`PicPoint` | `scale(PicPoint ptOrg, double sx, double sy)` Apply a scaling transform to this point.
`void` | `setCoordinates(double x, double y)` Set the coordinates of this point from the given pair
`PicPoint` | `setCoordinates(PicPoint pt)` Set the coordinates of this point from the given point.
`PicPoint` | `shear(PicPoint ptOrg, double shx, double shy)` Apply a shearing transform of given parameters wrt to the given origin, to this PicPoint
`PicPoint` | `symmetry(PicPoint center)` Apply a central-symmetry wrt the given point
`static PicPoint` | `symmetry(PicPoint center, PicPoint src)` Return a new PicPoint obtained by applying a central-symmetry with the given center to the given src point.
`double[]` | `toDoubleArray(double[] f)` Return a two-element array filled with x and y ; if f is null, a new array is allocated ; otherwise, the given array is directly modified and returned for convenience.
`float[]` | `toFloatArray(float[] f)` Return a two-element array filled with x and y ; if f is null, a new array is allocated ; otherwise, the given array is directly modified and returned for convenience.
`PicPoint` | `toMm(double unitLength)` Convert a PicPoint with coordinates expressed in the given unitlenth (expressed in mm), to a new PicPoint in mm coordinates.
`PicPoint` | `toMm(double xUnit, double yUnit)` Convert a PicPoint with coordinate expressed in the given unitlenths along X- and Y-axis (the latter being expressed in mm) to a new PicPoint in mm coordinate.
`String` | `toString()` Return a "(x,y)" string representing this point.
`PicPoint` | `translate(double dx, double dy)` translates this point by (dx,dy)
`PicPoint` | `translate(PicPoint p)` translates this point by (p.x, p.y), ie the given point is considered as a translation vector.
`PicPoint` | `translate(PicPoint p, double a)` translates this point by a*(p.x, p.y), ie the given point is considered as a translation vector scaled by the given double. This method proves a useful when one wants to minimize object creation, since it avoids cloning a given PicPoint, scaling it by "a", then passing it to the translate(PicPoint) method.
`PicPoint` | `translate(PicPoint p1, PicPoint p2)` translates this point by (p2.x-p1.x, p2.y-p2.y), ie the given point is considered as a translation vector build from the two given points.
`PicPoint` | `translate(PicPoint p1, PicPoint p2, double a)` translates this point by a*(p2.x-p1.x, p2.y-p2.y), ie the given point is considered as a translation vector build from the two given points, then scaled by the given double.

Methods inherited from class java.awt.geom.Point2D.Double
`getX, getY, setLocation`

Methods inherited from class java.awt.geom.Point2D
`distance, distance, distance, distanceSq, distanceSq, distanceSq, equals, hashCode, setLocation`

Methods inherited from class java.lang.Object
`finalize, getClass, notify, notifyAll, wait, wait, wait`

Field Detail

### X_COMPARATOR

    public static final PicPoint.XComparator X_COMPARATOR

### Y_COMPARATOR

    public static final PicPoint.YComparator Y_COMPARATOR

Constructor Detail

### PicPoint

    public PicPoint()

  Construct a (0,0) point.

### PicPoint

    public PicPoint(Point2D p)

  Clone the given point.

### PicPoint

    public PicPoint(Point2D p1,
                    Point2D p2,
                    double ratio)

  Construct a new PicPoint "p" located on the line joining p1 with p2, so that (p1,p) = ratio * (p1,p2)

Parameters:
  `ratio` - any double, positive or not.

### PicPoint

    public PicPoint(double x,
                    double y)

  Construct (x,y)

### PicPoint

    public PicPoint(Number x,
                    Number y)

  Construct a point from the given pair of Number (using their double value).

### PicPoint

    public PicPoint(float[] f)

  Construct a point from the first two elements of the given array.

### PicPoint

    public PicPoint(double[] f)

  Construct a point from the first two elements of the given array.

### PicPoint

    public PicPoint(String str)
             throws NumberFormatException

  Construct a point by parsing a String similar to that given by the `toString()` method, ie `(x,y)`.

Since:
  jpicedt 1.3.3

Method Detail

### clone

    public Object clone()

  Creates and returns a deep copy of this PicPoint.

### setCoordinates

    public PicPoint setCoordinates(PicPoint pt)

  Set the coordinates of this point from the given point.

  Returns:
    this for convenience

### setCoordinates

    public void setCoordinates(double x,
                               double y)

  Set the coordinates of this point from the given pair

### toFloatArray

    public float[] toFloatArray(float[] f)

  Return a two-element array filled with x and y ; if f is null, a new array is allocated ; otherwise, the given array is directly modified and returned for convenience.

### toDoubleArray

    public double[] toDoubleArray(double[] f)

  Return a two-element array filled with x and y ; if f is null, a new array is allocated ; otherwise, the given array is directly modified and returned for convenience.

### toString

    public String toString()

  Return a "(x,y)" string representing this point. The returned String in turn may be fed to the PicPoint(String) constructor.

### toMm

    public PicPoint toMm(double unitLength)

  Convert a PicPoint with coordinates expressed in the given unitlenth (expressed in mm), to a new PicPoint in mm coordinates.

  Parameters:
    `unitLength` - In mm

### toMm

    public PicPoint toMm(double xUnit,
                         double yUnit)

  Convert a PicPoint with coordinate expressed in the given unitlenths along X- and Y-axis (the latter being expressed in mm) to a new PicPoint in mm coordinate.

  Parameters:
    `xUnit` - unilength along the X-axis expressed in mm
    `yUnit` - unilength along the Y-axis expressed in mm

### translate

    public PicPoint translate(double dx,
                              double dy)

  translates this point by (dx,dy)

  Returns:
    this for convenience

### translate

    public PicPoint translate(PicPoint p)

  translates this point by (p.x, p.y), ie the given point is considered as a translation vector.

  Returns:
    this for convenience

### translate

    public PicPoint translate(PicPoint p1,
                              PicPoint p2)

  translates this point by (p2.x-p1.x, p2.y-p2.y), ie the given point is considered as a translation vector build from the two given points.

  Returns:
    this for convenience

### translate

    public PicPoint translate(PicPoint p,
                              double a)

  translates this point by a*(p.x, p.y), ie the given point is considered as a translation vector scaled by the given double.
  This method proves a useful when one wants to minimize object creation, since it avoids cloning a given PicPoint, scaling it by "a", then passing it to the translate(PicPoint) method.

  Returns:
    this for convenience

### translate

    public PicPoint translate(PicPoint p1,
                              PicPoint p2,
                              double a)

  translates this point by a*(p2.x-p1.x, p2.y-p2.y), ie the given point is considered as a translation vector build from the two given points, then scaled by the given double. This method proves a useful when one wants to minimize object creation.

  Returns:
    this for convenience

### symmetry

    public PicPoint symmetry(PicPoint center)

  Apply a central-symmetry wrt the given point

  Returns:
    this for convenience

### symmetry

    public static PicPoint symmetry(PicPoint center,
                                    PicPoint src)

  Return a new PicPoint obtained by applying a central-symmetry with the given center to the given src point. If src==null, it is allocated and returned for convenience.

### scale

    public PicPoint scale(PicPoint ptOrg,
                          double sx,
                          double sy)

  Apply a scaling transform to this point.

  Parameters:
    `sx` - Scaling factors along the X-axis
    `sy` - Scaling factors along the Y-axis
    `ptOrg` - transformation centre
  Returns:
    this for convenience

### scale

    public PicPoint scale(PicPoint ptOrg,
                          double s)

  Apply a scaling transform to this point.

  Parameters:
    `s` - Scaling factors along the X- and Y- axis
    `ptOrg` - transformation centre
  Returns:
    this for convenience

### scale

    public PicPoint scale(double ptOrgX,
                          double ptOrgY,
                          double s)

  Apply a scaling transform to this point.

  Parameters:
    `s` - Scaling factors along the X- and Y- axis
    `ptOrgX` - X-coord of transformation centre
    `ptOrgY` - Y-coord of transformation centre
  Returns:
    this for convenience

### scale

    public PicPoint scale(double ptOrgX,
                          double ptOrgY,
                          double sx,
                          double sy)

  Apply a scaling transform to this point.

  Parameters:
    `sx` - Scaling factors along the X-axis
    `sy` - Scaling factors along the Y-axis
    `ptOrgX` - X-coord of transformation centre
    `ptOrgY` - Y-coord of transformation centre
  Returns:
    this for convenience

### rotate

    public PicPoint rotate(PicPoint ptOrg,
                           double angle)

  Apply a rotation of center ptOrg and the given angle in radians to this PicPoint Current implementation arranges for a very fast code if angle is Math.PI, Math.PI/2 or -Math.PI/2.

  Returns:
    this for convenience

### shear

    public PicPoint shear(PicPoint ptOrg,
                          double shx,
                          double shy)

  Apply a shearing transform of given parameters wrt to the given origin, to this PicPoint

  Returns:
    this for convenience

### middle

    public PicPoint middle(PicPoint other)

  Translate this point to the middle of the segment made of [this,other].

  Returns:
    this for convenience [SR:pending] refactor method name to "midpoint"

### project

    public PicPoint project(PicPoint p1,
                            PicPoint p2)

  Project this point onto the line joining p1 and p2. Projectiong is orthogonal. Does nothing it p1==p2.

  Returns:
    this for convenience.

### project

    public PicPoint project(PicPoint p1,
                            PicPoint p2,
                            PicPoint dir)

  Project this point onto the line joining p1 and p2. Projection is along the given vector. Does nothing it p1==p2 or if "dir" is null, or if dir is parallel to the (p1,p2) line.

  Parameters:
    `dir` - a vector indicating the projection axis
  Returns:
    this for convenience.

### main

    public static void main(String[] args)

  validation tests

### apply

    public void apply(AffineTransform at)

  Apply the given AffineTransform to the coordinates of this point

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| http://www.jpicedt.org
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Submit a bug : syd@jpicedt.org