Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.maryanovsky.gwtutils.client.geom
Class Point

    java.lang.Object
      com.maryanovsky.gwtutils.client.geom.Point

All Implemented Interfaces:
  PointView

    public final class Point

extends Object
implements PointView

A two dimensional point, with integer coordinates.

Author:
  Maryanovsky Alexander

Constructor Summary
`Point()` Creates a new Point at 0,0.
`Point(int x, int y)` Creates a new `Point` with the specified coordinates.
`Point(PointView point)` Creates a new `Point` at the same coordinates as the specified one.
`Point(SizeView size)` Creates a new `Point` with the X coordinate at the width of the specified size and the Y coordinate at the height of the specified size.

Method Summary
`boolean` | `equals(int x, int y)` Returns whether the specified coordinates are the same as this point's.
`boolean` | `equals(Object o)` Returns whether this `Point` is the same as the specified one.
`boolean` | `equals(PointView point)` Returns whether this `Point` is the same as the specified one.
`double` | `getDistanceFrom(PointView point)` Returns the distance from this point to the specified one.
`double` | `getDistanceFromOrigin()` Returns the distance from this point to 0,0.
`PointView` | `getDistancePoint(PointView point)` Returns the distance from this point to the specified one, as a `PointView`.
`Point` | `getDistancePoint(PointView point, Point reusable)` Returns the distance from this point to the specified one, as a `Point`.
`SizeView` | `getDistanceSize(PointView point)` Returns the distance from this point to the specified one, as a `SizeView`.
`Size` | `getDistanceSize(PointView point, Size reusable)` Returns the distance from this point to the specified one in the same manner as getDistanceSize(PointView).
`static Point` | `getMidPoint(PointView point1, PointView point2, Point reusable)` Returns the mid-point between the two specified points.
`PointView` | `getOpposite()` Returns the point opposite to this one.
`Point` | `getOpposite(Point reusable)` Returns the point opposite to this one.
`int` | `getX()` Returns the X coordinate.
`int` | `getY()` Returns the Y coordinate.
`int` | `hashCode()` Returns the hashcode of this object.
`static Point` | `make(int x, int y, Point point)` Returns a `Point` with the specified coordinates.
`Point` | `moveBy(int dx, int dy)` Moves this point by the specified offsets.
`Point` | `moveBy(PointView point)` Moves this point by the offsets specified by the given point.
`Point` | `moveBy(SizeView size)` Moves this point by the offsets specified by the given size.
`Point` | `multiplyBy(double coefficient)` Multiples the X and Y coordinates of this point by the specified coefficient.
`Point` | `reflect(Point point)` Reflects this point relative to the specified one.
`Point` | `roundDownToGrid(int cellWidth, int cellHeight)` Moves this point to the nearest location with smaller X and Y coordinates which is on a grid where each cell is of the specified size.
`Point` | `roundDownToGrid(SizeView cellSize)` Moves this point to the nearest location with smaller X and Y coordinates which is on a grid of the specified size.
`Point` | `roundUpToGrid(int cellWidth, int cellHeight)` Moves the point to the nearest location with greater X and Y coordinates which is on a grid where each cell is of the specified size.
`Point` | `roundUpToGrid(Size cellSize)` Moves the point to the nearest location with greater X and Y coordinates which is on a grid where each cell is of the specified size.
`Point` | `set(int x, int y)` Sets both coordinates.
`Point` | `set(PointView point)` Sets both coordinates.
`Point` | `setX(int x)` Sets the X coordinate.
`Point` | `setY(int y)` Sets the Y coordinate.
`String` | `toString()` Returns a textual representation of this point.

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

Constructor Detail

### Point

    public Point(int x,
                 int y)

  Creates a new `Point` with the specified coordinates.

### Point

    public Point()

  Creates a new Point at 0,0.

### Point

    public Point(SizeView size)

  Creates a new `Point` with the X coordinate at the width of the specified size and the Y coordinate at the height of the specified size.

### Point

    public Point(PointView point)

  Creates a new `Point` at the same coordinates as the specified one.

Method Detail

### make

    public static Point make(int x,
                             int y,
                             Point point)

  Returns a `Point` with the specified coordinates. If the given `Point` is not `null`, it is reused and returned.

### set

    public Point set(int x,
                     int y)

  Sets both coordinates.

  Returns:
    `this`.

### set

    public Point set(PointView point)

  Sets both coordinates.

  Returns:
    `this`.

### moveBy

    public Point moveBy(int dx,
                        int dy)

  Moves this point by the specified offsets.

  Returns:
    `this`.

### moveBy

    public Point moveBy(PointView point)

  Moves this point by the offsets specified by the given point.

  Returns:
    `this`.

### moveBy

    public Point moveBy(SizeView size)

  Moves this point by the offsets specified by the given size.

  Returns:
    `this`.

### multiplyBy

    public Point multiplyBy(double coefficient)

  Multiples the X and Y coordinates of this point by the specified coefficient.

  Returns:
    `this`.

### getDistanceFromOrigin

    public double getDistanceFromOrigin()

  Returns the distance from this point to 0,0.

  Specified by:
    `getDistanceFromOrigin` in interface `PointView`

### getDistanceFrom

    public double getDistanceFrom(PointView point)

  Returns the distance from this point to the specified one.

  Specified by:
    `getDistanceFrom` in interface `PointView`

### getDistancePoint

    public PointView getDistancePoint(PointView point)

  Returns the distance from this point to the specified one, as a `PointView`.

  Specified by:
    `getDistancePoint` in interface `PointView`

### getDistancePoint

    public Point getDistancePoint(PointView point,
                                  Point reusable)

  Returns the distance from this point to the specified one, as a `Point`. If the specified 2nd point is not `null`, it is reused and returned.

  Specified by:
    `getDistancePoint` in interface `PointView`

### getDistanceSize

    public SizeView getDistanceSize(PointView point)

  Returns the distance from this point to the specified one, as a `SizeView`. Note that this may differ from getDistancePoint(PointView) because the dimensions of a `SizeView` are always non-negative.

  Specified by:
    `getDistanceSize` in interface `PointView`

### getDistanceSize

    public Size getDistanceSize(PointView point,
                                Size reusable)

  Returns the distance from this point to the specified one in the same manner as getDistanceSize(PointView). If the specified 2nd point is not `null`, it is reused and returned.

  Specified by:
    `getDistanceSize` in interface `PointView`

### getOpposite

    public PointView getOpposite()

  Returns the point opposite to this one.

  Specified by:
    `getOpposite` in interface `PointView`

### getOpposite

    public Point getOpposite(Point reusable)

  Returns the point opposite to this one. If the specified reusable point is not `null`, it is reused and returned.

  Specified by:
    `getOpposite` in interface `PointView`

### roundDownToGrid

    public Point roundDownToGrid(int cellWidth,
                                 int cellHeight)

  Moves this point to the nearest location with smaller X and Y coordinates which is on a grid where each cell is of the specified size.

  Returns:
    `this`.

### roundDownToGrid

    public Point roundDownToGrid(SizeView cellSize)

  Moves this point to the nearest location with smaller X and Y coordinates which is on a grid of the specified size.

  Returns:
    `this`.

### roundUpToGrid

    public Point roundUpToGrid(int cellWidth,
                               int cellHeight)

  Moves the point to the nearest location with greater X and Y coordinates which is on a grid where each cell is of the specified size.

  Returns:
    `this`.

### roundUpToGrid

    public Point roundUpToGrid(Size cellSize)

  Moves the point to the nearest location with greater X and Y coordinates which is on a grid where each cell is of the specified size.

  Returns:
    `this`.

### reflect

    public Point reflect(Point point)

  Reflects this point relative to the specified one.

  Returns:
    `this`.

### getMidPoint

    public static Point getMidPoint(PointView point1,
                                    PointView point2,
                                    Point reusable)

  Returns the mid-point between the two specified points. If the midpoint is not an integer, one of the near integer points is returned. If the specified reusable point is not `null`, it is reused and returned.

### getX

    public int getX()

  Returns the X coordinate.

  Specified by:
    `getX` in interface `PointView`

### setX

    public Point setX(int x)

  Sets the X coordinate.

  Returns:
    `this`.

### getY

    public int getY()

  Returns the Y coordinate.

  Specified by:
    `getY` in interface `PointView`

### setY

    public Point setY(int y)

  Sets the Y coordinate.

  Returns:
    `this`.

### equals

    public boolean equals(int x,
                          int y)

  Returns whether the specified coordinates are the same as this point's.

  Specified by:
    `equals` in interface `PointView`

### equals

    public boolean equals(PointView point)

  Returns whether this `Point` is the same as the specified one.

### equals

    public boolean equals(Object o)

  Returns whether this `Point` is the same as the specified one.

  Overrides:
    `equals` in class `Object`

### hashCode

    public int hashCode()

  Returns the hashcode of this object.

  Overrides:
    `hashCode` in class `Object`

### toString

    public String toString()

  Returns a textual representation of this point.

  Overrides:
    `toString` in class `Object`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD