Class Point
- java.lang.Object
-
- org.jungrapht.visualization.layout.model.Point
-
public class Point extends Object
Simple, immutable Point class used for Graph layout. Included to reduce dependency on awt classes- Author:
- Tom Nelson
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPoint(double x, double y)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Pointadd(double dx, double dy)Pointadd(Point other)static PointcentroidOf(Collection<Point> points)doubledistance(Point other)doubledistanceSquared(double ox, double oy)doubledistanceSquared(Point other)booleanequals(Object o)Compare with another object for equalityinthashCode()booleaninside(double minX, double minY, double maxX, double maxY)booleaninside(Circle c)booleaninside(Rectangle r)doublelength()Pointmultiply(double factor)static Pointof(double x, double y)StringtoString()
-
-
-
Field Detail
-
x
public final double x
x coordinate
-
y
public final double y
y coordinate
-
ORIGIN
public static final Point ORIGIN
Point at location (0,0)
-
-
Method Detail
-
of
public static Point of(double x, double y)
- Parameters:
x- coordinatey- coordinate- Returns:
- a new Point with the passed coordinates
-
centroidOf
public static Point centroidOf(Collection<Point> points)
- Parameters:
points- a collection ofPointto consider- Returns:
- the centroid of the
Pointcollection
-
add
public Point add(Point other)
- Parameters:
other- the Point with values to add- Returns:
- a new Point with the sum of this Point and other Point's values
-
multiply
public Point multiply(double factor)
- Parameters:
factor- the value to multiply- Returns:
- a new Point with the sum of this Point and other Point's values
-
add
public Point add(double dx, double dy)
- Parameters:
dx- change in xdy- change in y- Returns:
- a new Point with the sum of this Point and the passed values
-
distanceSquared
public double distanceSquared(Point other)
- Parameters:
other- the Point to measure against- Returns:
- the square of the distance between this Point and the passed Point
-
distanceSquared
public double distanceSquared(double ox, double oy)- Parameters:
ox- coordinate of another locationoy- coordinate of another location- Returns:
- the square of the distance between this Point and the passed location
-
inside
public boolean inside(Circle c)
- Parameters:
c- a Circle to compare against- Returns:
- true if this Point is within the passed Circle, false otherwise
-
inside
public boolean inside(Rectangle r)
- Parameters:
r- a Rectangle to compare against- Returns:
- true if this Point is inside the passed Rectangle, false otherwise
-
inside
public boolean inside(double minX, double minY, double maxX, double maxY)- Parameters:
minX- min coordinate of a rectangular spaceminY- min coordinate of a rectangular spacemaxX- max coordinate of a rectangular spacemaxY- max coordinate of a rectangular space- Returns:
- true if this Point is within the passed rectangular space, false otherwise
-
length
public double length()
- Returns:
- the distance between this Point and the origin.
-
distance
public double distance(Point other)
- Parameters:
other- a Point to consider- Returns:
- the distance between this Point and the passed Point
-
equals
public boolean equals(Object o)
Compare with another object for equality
-
hashCode
public int hashCode()
-
-