java.awt.geom

Class Point2D

Implemented Interfaces:
Cloneable
Known Direct Subclasses:
Point, Point2D.Double, Point2D.Float

public abstract class Point2D
extends Object
implements Cloneable

The Point2D class defines a point representing a location in (x, y) coordinate space.

This class is only the abstract superclass for all objects that store a 2D coordinate. The actual storage representation of the coordinates is left to the subclass.

Nested Class Summary

static class
Point2D.Double
The Double class defines a point specified in double precision.
static class
Point2D.Float
The Float class defines a point specified in float precision.

Constructor Summary

Point2D()
This is an abstract class that cannot be instantiated directly.

Method Summary

Object
clone()
Creates a new object of the same class and with the same contents as this object.
double
distance(double PX, double PY)
Returns the distance from this Point2D to a specified point.
static double
distance(double X1, double Y1, double X2, double Y2)
Returns the distance between two points.
double
distance(Point2D pt)
Returns the distance from this Point2D to a specified Point2D.
double
distanceSq(double PX, double PY)
Returns the square of the distance from this Point2D to a specified point.
static double
distanceSq(double X1, double Y1, double X2, double Y2)
Returns the square of the distance between two points.
double
distanceSq(Point2D pt)
Returns the square of the distance from this Point2D to a specified Point2D.
boolean
equals(Object obj)
Determines whether or not two points are equal.
abstract double
getX()
Returns the X coordinate of this Point2D in double precision.
abstract double
getY()
Returns the Y coordinate of this Point2D in double precision.
int
hashCode()
Returns the hashcode for this Point2D.
abstract void
setLocation(double x, double y)
Sets the location of this Point2D to the specified double coordinates.
void
setLocation(Point2D p)
Sets the location of this Point2D to the same coordinates as the specified Point2D object.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

Point2D

protected Point2D()
This is an abstract class that cannot be instantiated directly. Type-specific implementation subclasses are available for instantiation and provide a number of formats for storing the information necessary to satisfy the various accessor methods below.

Method Details

clone

public Object clone()
Creates a new object of the same class and with the same contents as this object.
Overrides:
clone in interface Object
Returns:
a clone of this instance.
Since:
1.2
See Also:
Cloneable
Usages and Demos :

View More Examples of clone()
   1: 
   2: import java.awt.geom.Point2D;
   3: 
   4:         ...
   5: 
   6:     protected Point2D ref;
   7: 
   8:         ...
   9:     public Marker(GraphicsNode markerNode, Point2D ref, double orient){
  10: 
  11:         ...
  12:     public Point2D getRef(){
  13:         return (Point2D)ref.clone();

View Full Code Here
   1:     private ZRectangle rect;
   2:     private Point2D pt;
   3:     private int            all_button_mask   = (MouseEvent.BUTTON1_MASK |
   4:         ...
   5:         this.node = node;
   6:         pt = new Point2D.Double();
   7:     }
   8:         ...
   9:             path.screenToGlobal(pt);
  10:             pressObjPt = (Point2D)pt.clone();

View Full Code Here
   1:     private ZEllipse ellipse;
   2:     private Point2D pt;
   3:     private int     all_button_mask   = (MouseEvent.BUTTON1_MASK |
   4:         ...
   5:         this.node = node;
   6:         pt = new Point2D.Double();
   7:     }
   8:         ...
   9:             path.screenToGlobal(pt);
  10:             pressObjPt = (Point2D)pt.clone();

View Full Code Here
   1: import java.awt.Graphics2D;
   2: import java.awt.geom.Point2D;
   3: public class Mass {
   4:         ...
   5:     private Point2D position;
   6:         ...
   7:     private Point2D accel;
   8:     public Mass() {
   9:         ...
  10:     public final Point2D getAccel() {
  11:         return (Point2D) accel.clone();

View Full Code Here
   1: import java.awt.RenderingHints;
   2: import java.awt.geom.Point2D;
   3: import java.awt.geom.Rectangle2D;
   4:         ...
   5: 
   6:     public Point2D getPoint2D(Point2D srcPoint, Point2D destPoint)
   7:     {
   8:         ...
   9:         if (destPoint == null)
  10:             return (Point2D)srcPoint.clone();

View Full Code Here

distance

public double distance(double PX,
                       double PY)
Returns the distance from this Point2D to a specified point.
Parameters:
Returns:
the distance between this Point2D and a specified point.
Usages and Demos :

View More Examples of distance(double PX,double PY)
   1:     public void showCoordinates(VideoPanel vidPanel) {
   2:       Point2D p = getWorldPosition(vidPanel);
   3:       track.xField.setValue(p.getX());
   4:         ...
   5:       track.yField.setValue(p.getY());
   6:       track.magField.setValue(p.distance(0, 0));
   7:       double theta = Math.atan2(p.getY(), p.getX());
   8:         ...
   9:     
  10:     void setPosition(Point2D point) {
  11:       this.x = point.getX();        

View Full Code Here
   1: 
   2:   public Point2D getWorldPosition(int n, TrackerPanel trackerPanel) {
   3:     PositionStep step = (PositionStep)getStep(n);
   4:         ...
   5: 
   6:   public Point2D getWorldVelocity(int n, TrackerPanel trackerPanel) {
   7:     ImageCoordSystem coords = trackerPanel.getCoords();
   8:         ...
   9:       double worldY = coords.imageToWorldYComponent(n, imageX, imageY) / dt;
  10:       return new Point2D.Double(worldX, worldY);
  11:     }
  12:         ...
  13:       y.append(t, pt.getY());
  14:       mag.append(t, pt.distance(0, 0));

View Full Code Here

distance

public static double distance(double X1,
                              double Y1,
                              double X2,
                              double Y2)
Returns the distance between two points.
Parameters:
Returns:
the distance between the two sets of specified coordinates.
Usages and Demos :

View More Examples of distance(double X1,double Y1,double X2,double Y2)
   1: 
   2: import java.awt.geom.Point2D;
   3: import java.awt.Point;
   4:         ...
   5:     this.typeRoute = typeRoute;
   6:     int l = (int)((echelle * (int)Point2D.distance(p1.x, p1.y, p2.x, p2.y)) * 100);
   7:     length = ((double)l)/100;
   8:   }

View Full Code Here
   1: import java.awt.geom.Line2D;
   2: import java.awt.geom.Point2D;
   3: import java.awt.geom.*;
   4:         ...
   5:     
   6:     double length = Point2D.distance(p1x,p1y,p2x,p2y);
   7: 
   8: 
   9:     double dx0 = p1x-p2x;

View Full Code Here
   1: import java.awt.geom.Line2D;
   2: import java.awt.geom.Point2D;
   3: import java.awt.geom.*;
   4:         ...
   5:     
   6:     double length = Point2D.distance(p1x,p1y,p2x,p2y);
   7: 
   8: 
   9:     double dx0 = p1x-p2x;

View Full Code Here
   1: import java.awt.geom.Line2D;
   2: import java.awt.geom.Point2D;
   3: import java.awt.geom.*;
   4:         ...
   5:     
   6:     double length = Point2D.distance(p1x,p1y,p2x,p2y);
   7: 
   8: 
   9:     double dx0 = p1x-p2x;

View Full Code Here
   1: 
   2: import java.awt.geom.Point2D;
   3: import java.awt.image.ColorModel;
   4:         ...
   5:     this.cyclic = cyclic;
   6:     length = Point2D.distance(x1, y1, x2, y2);
   7:   }
   8:     
   9:   public ColorModel getColorModel() 

View Full Code Here

distance

public double distance(Point2D pt)
Returns the distance from this Point2D to a specified Point2D.
Parameters:
pt - the specified Point2D
Returns:
the distance between this Point2D and the specified Point2D.
Usages and Demos :

View More Examples of distance(Point2D pt)
   1: import java.awt.geom.NoninvertibleTransformException;
   2: import java.awt.geom.Point2D;
   3: import java.awt.font.*;
   4:         ...
   5:   {
   6:     String lenStr = Double.toString(p0.distance(p1));
   7:     double ang = Math.toDegrees(
   8:         ...
   9:     paint(text,
  10:           viewport.toViewPoint(new Point2D.Double(p0.x, p0.y)),
  11:         ...
  12:           viewport.toViewPoint(new Point2D.Double(p1.x, p1.y)), viewport,

View Full Code Here
   1: 
   2: import java.awt.geom.Point2D;
   3: import java.awt.geom.Rectangle2D;
   4:         ...
   5:     
   6:     public Circle2D(Point2D pt1, Point2D pt2, Point2D pt3) {
   7:         
   8:         ...
   9:             this.y= 0.5*(pt1.getY() + pt2.getY());
  10:             this.radius= pt1.distance(this.getCenter());
  11:             return this.radius;
  12:         ...
  13: 
  14:         this.radius= pt1.distance(this.getCenter());

View Full Code Here
   1: import java.awt.geom.NoninvertibleTransformException;
   2: import java.awt.geom.Point2D;
   3: 
   4:         ...
   5:             foci((LineString) lineA, (LineString) lineB, viewport);
   6:         Point2D a = viewport.toViewPoint(foci[0]);
   7:         ...
   8:         Point2D b = viewport.toViewPoint(foci[1]);
   9:         Point2D center =
  10:         ...
  11:         try {
  12:             g.draw(toShape(center, a.distance(b) + (HEIGHT * 2), HEIGHT));

View Full Code Here
   1: import java.awt.Graphics2D;
   2: import java.awt.geom.Point2D;
   3: import java.awt.geom.Rectangle2D;
   4:         ...
   5:         translate(context, bounds, null);
   6:         Point2D P1,P2;
   7:         if (horizontal) {
   8:         ...
   9:             final double center = bounds.getCenterY();
  10:             P1 = new Point2D.Double(bounds.getMinX(), center);
  11:             P2 = new Point2D.Double(bounds.getMaxX(), center);
  12:         ...
  13:                                units.convert(P2.getY(), mapUnitY));
  14:                 logicalLength = P1.distance(P2);

View Full Code Here

distanceSq

public double distanceSq(double PX,
                         double PY)
Returns the square of the distance from this Point2D to a specified point.
Parameters:
Returns:
the square of the distance between this Point2D and the specified point.

distanceSq

public static double distanceSq(double X1,
                                double Y1,
                                double X2,
                                double Y2)
Returns the square of the distance between two points.
Parameters:
Returns:
the square of the distance between the two sets of specified coordinates.
Usages and Demos :

View More Examples of distanceSq(double X1,double Y1,double X2,double Y2)
   1: import java.awt.Image;
   2: import java.awt.geom.Point2D;
   3: import java.io.File;
   4:         ...
   5:         } else {
   6:             returnvalue = Point2D.distanceSq(pos1X, pos1Y, pos2X, pos2Y);
   7:             if(MathHelper.doubleEqual(returnvalue,0)){returnvalue=0;}            
   8:             return returnvalue;
   9:         }

View Full Code Here

distanceSq

public double distanceSq(Point2D pt)
Returns the square of the distance from this Point2D to a specified Point2D.
Parameters:
pt - the specified Point2D
Returns:
the square of the distance between this Point2D to a specified Point2D.
Usages and Demos :

View More Examples of distanceSq(Point2D pt)
   1: import java.awt.geom.Line2D;
   2: import java.awt.geom.Point2D;
   3: import java.awt.geom.Rectangle2D;
   4:         ...
   5: 
   6:     private final transient Point2D.Double jFirstPoint = new Point2D.Double();
   7:     private final transient Point2D.Double jLastPoint  = new Point2D.Double();
   8:         ...
   9:         } else {
  10:             return P1.distanceSq(P2);
  11:         }
  12:         ...
  13:                 final Point2D projected = Geometry.nearestColinearPoint(pathLine, ptRef);
  14:                 final double distanceSq = ptRef.distanceSq(projected);

View Full Code Here

equals

public boolean equals(Object obj)
Determines whether or not two points are equal. Two instances of Point2D are equal if the values of their x and y member fields, representing their position in the coordinate space, are the same.
Overrides:
equals in interface Object
Parameters:
obj - an object to be compared with this Point2D
Returns:
true if the object to be compared is an instance of Point2D and has the same values; false otherwise.
Since:
1.2

getX

public abstract double getX()
Returns the X coordinate of this Point2D in double precision.
Returns:
the X coordinate of this Point2D.
Since:
1.2
Usages and Demos :

View More Examples of getX()
   1: import java.awt.geom.PathIterator;
   2: import java.awt.geom.Point2D;
   3: import java.awt.geom.Rectangle2D;
   4:         ...
   5:     static AffineTransform IDENTITY_XFORM = new AffineTransform();
   6:     static Point2D aPoint = new Point2D.Double();
   7:     static ArrayList segList = new ArrayList();
   8:         ...
   9:     public static void awtToSWT(Rectangle2D aRect, Rectangle sRect) {
  10:         sRect.x = (int)(aRect.getX()+0.5);
  11:         sRect.y = (int)(aRect.getY()+0.5);
  12:         ...
  13:                 case PathIterator.SEG_CLOSE:
  14:                     segList.add(new Point2D.Double(aPoint.getX(),aPoint.getY()));

View Full Code Here
   1: import java.awt.geom.NoninvertibleTransformException;
   2: import java.awt.geom.Point2D;
   3: import java.awt.font.*;
   4:         ...
   5:     paint(text,
   6:           viewport.toViewPoint(new Point2D.Double(p0.x, p0.y)),
   7:         ...
   8:           viewport.toViewPoint(new Point2D.Double(p1.x, p1.y)), viewport,
   9:           graphics);
  10:         ...
  11: 
  12:     Point2D mid = new Point2D.Float( (float) ((p0.getX() + p1.getX()) / 2),

View Full Code Here
   1: import java.awt.geom.NoninvertibleTransformException;
   2: import java.awt.geom.Point2D;
   3: 
   4:         ...
   5: 
   6:     protected void paint(Point2D p0, Point2D p1, Viewport viewport,
   7:         Graphics2D graphics) throws NoninvertibleTransformException {
   8:         ...
   9:     {
  10:       Point2D mid = new Point2D.Float( (float) ((p0.getX() + p1.getX()) / 2),
  11:                                        (float) ((p0.getY() + p1.getY()) / 2) );
  12:         ...
  13:         Point2D finTip2 = fin(mid, p0, finLength, -finAngle);
  14:         arrowhead.moveTo((float) finTip1.getX(), (float) finTip1.getY());

View Full Code Here
   1: import java.awt.geom.Line2D;
   2: import java.awt.geom.Point2D;
   3: 
   4:         ...
   5:     public double getArea(){
   6:         Point2D p[] = this.getPoints();
   7:         return Math.abs((0.5 * 
   8:         ...
   9:                     (((p[0].getX() - p[1].getX()) * (p[0].getY() + p[1].getY())) + 
  10:         ...
  11:                      ((p[1].getX() - p[2].getX()) * (p[1].getY() + p[2].getY())) + 

View Full Code Here
   1: import java.awt.Rectangle;
   2: import java.awt.geom.Point2D;
   3: import java.awt.geom.Rectangle2D;
   4:         ...
   5: 
   6:     public Point2D mapDestPoint(final Point2D destPt) {
   7:         ...
   8:         Point2D result = new Point2D.Double(destPt.getX()+0.5, destPt.getY()+0.5);
   9:         try {
  10:         ...
  11:         }
  12:         result.setLocation(result.getX()-0.5, result.getY()-0.5);

View Full Code Here

getY

public abstract double getY()
Returns the Y coordinate of this Point2D in double precision.
Returns:
the Y coordinate of this Point2D.
Since:
1.2
Usages and Demos :

View More Examples of getY()
   1: import java.awt.geom.GeneralPath;
   2: import java.awt.geom.Point2D;
   3: 
   4:         ...
   5: 
   6:     protected Shape createLineEnd(int size, int style, Point2D src, Point2D dst)
   7:     {
   8:         ...
   9:         return super.createLineEnd(size, style, new Point2D.Double(dst.getX(), src.getY()), dst);
  10:     }
  11:         ...
  12:             Point2D startPoint = p[0];
  13:             view.sharedPath.moveTo((float) startPoint.getX(), (float) startPoint.getY());

View Full Code Here
   1: import java.awt.geom.PathIterator;
   2: import java.awt.geom.Point2D;
   3: import java.awt.geom.Rectangle2D;
   4:         ...
   5:     static AffineTransform IDENTITY_XFORM = new AffineTransform();
   6:     static Point2D aPoint = new Point2D.Double();
   7:     static ArrayList segList = new ArrayList();
   8:         ...
   9:     public static void transform(Rectangle2D rect, AffineTransform at) {
  10:         pts[1] = rect.getY();
  11:         ...
  12:         pts[3] = rect.getY();

View Full Code Here
   1: import java.awt.geom.Line2D;
   2: import java.awt.geom.Point2D;
   3: 
   4:         ...
   5:     public double getArea(){
   6:         Point2D p[] = this.getPoints();
   7:         return Math.abs((0.5 * 
   8:         ...
   9:                     (((p[0].getX() - p[1].getX()) * (p[0].getY() + p[1].getY())) + 
  10:         ...
  11:                      ((p[1].getX() - p[2].getX()) * (p[1].getY() + p[2].getY())) + 

View Full Code Here
   1: import java.awt.Rectangle;
   2: import java.awt.geom.Point2D;
   3: import java.awt.geom.Rectangle2D;
   4:         ...
   5: 
   6:     public Point2D mapDestPoint(final Point2D destPt) {
   7:         ...
   8:         Point2D result = new Point2D.Double(destPt.getX()+0.5, destPt.getY()+0.5);
   9:         try {
  10:         ...
  11:         }
  12:         result.setLocation(result.getX()-0.5, result.getY()-0.5);

View Full Code Here
   1:     public double getY() {
   2:         return getPoint2d().getY();
   3:     }
   4:         ...
   5:     
   6:     public Point2D toPoint2D() {
   7:         ...
   8:         return new Point2D.Double(getX(), getY());
   9:     }
  10:         ...
  11:     
  12:     public XContourPoint cloneAt(Point2D a_point) {

View Full Code Here

hashCode

public int hashCode()
Returns the hashcode for this Point2D.
Overrides:
hashCode in interface Object
Returns:
a hash code for this Point2D.

setLocation

public abstract void setLocation(double x,
                                 double y)
Sets the location of this Point2D to the specified double coordinates.
Parameters:
Since:
1.2
Usages and Demos :

View More Examples of setLocation(double x,double y)
   1: import java.awt.geom.Line2D;
   2: import java.awt.geom.Point2D;
   3: import java.awt.geom.Rectangle2D;
   4:         ...
   5:         Rectangle2D r= new Rectangle2D.Double(10.0,80.0,10.0,10.0);
   6:         Point2D pa = new Point2D.Double(0.0, 100.0);
   7:         Point2D pb = new Point2D.Double(23.423188405797102, 78.11304347826088);
   8:         ...
   9:         
  10:         pa.setLocation(1.0,0.0);
  11:         ...
  12:         pb.setLocation(1.0,1.0);

View Full Code Here
   1: import java.awt.geom.PathIterator;
   2: import java.awt.geom.Point2D;
   3: import java.awt.geom.Rectangle2D;
   4:         ...
   5:     static AffineTransform IDENTITY_XFORM = new AffineTransform();
   6:     static Point2D aPoint = new Point2D.Double();
   7:     static ArrayList segList = new ArrayList();
   8:         ...
   9:         segList.clear();
  10:         aPoint.setLocation(0,0);
  11:         
  12:         ...
  13:                 case PathIterator.SEG_MOVETO:
  14:                     aPoint.setLocation(pts[0],pts[1]);

View Full Code Here
   1: 
   2: import java.awt.geom.Point2D;
   3: import java.awt.geom.Rectangle2D;
   4:         ...
   5:     
   6:     public static Point2D getCentroid(
   7:         ...
   8:         ItemRegistry registry, Iterator iter, Point2D p)
   9:     {
  10:         ...
  11:         }
  12:         p.setLocation(cx, cy);

View Full Code Here
   1: import java.awt.geom.Ellipse2D;
   2: import java.awt.geom.Point2D;
   3: import java.awt.geom.Rectangle2D;
   4:         ...
   5: 
   6:     public void getConnection (Point2D p) {
   7:         if (!_polygonValid) {
   8:         ...
   9:         }
  10:         p.setLocation(_originX + _length, _originY);
  11:         AffineTransform at = new AffineTransform();
  12:         ...
  13: 
  14:     public void getOrigin (Point2D p) {

View Full Code Here
   1: 
   2: import java.awt.geom.Point2D;
   3: import java.awt.geom.Rectangle2D;
   4:         ...
   5:     
   6:     public static Point2D getCentroid(Iterator iter, Point2D p) {
   7:         double cx = 0, cy = 0;
   8:         ...
   9:         }
  10:         p.setLocation(cx, cy);
  11:         return p;

View Full Code Here

setLocation

public void setLocation(Point2D p)
Sets the location of this Point2D to the same coordinates as the specified Point2D object.
Parameters:
p - the specified Point2D the which to set this Point2D
Since:
1.2
Usages and Demos :

View More Examples of setLocation(Point2D p)
   1:     private ZPolyline polyline;
   2:     private Point2D pt;
   3:     private int            all_button_mask   = (MouseEvent.BUTTON1_MASK |
   4:         ...
   5:         this.node = node;
   6:         pt = new Point2D.Double();
   7:     }
   8:         ...
   9: 
  10:             pt.setLocation(e.getX(), e.getY());
  11:             path.screenToGlobal(pt);
  12:         ...
  13:             ZSceneGraphPath path = e.getPath();
  14:             pt.setLocation(e.getX(), e.getY());

View Full Code Here
   1:     private ZRectangle rect;
   2:     private Point2D pt;
   3:     private int            all_button_mask   = (MouseEvent.BUTTON1_MASK |
   4:         ...
   5:         this.node = node;
   6:         pt = new Point2D.Double();
   7:     }
   8:         ...
   9: 
  10:             pt.setLocation(e.getX(), e.getY());
  11:             path.screenToGlobal(pt);
  12:         ...
  13:             pressObjPt = (Point2D)pt.clone();

View Full Code Here
   1:     private ZEllipse ellipse;
   2:     private Point2D pt;
   3:     private int     all_button_mask   = (MouseEvent.BUTTON1_MASK |
   4:         ...
   5:         this.node = node;
   6:         pt = new Point2D.Double();
   7:     }
   8:         ...
   9: 
  10:             pt.setLocation(e.getX(), e.getY());
  11:             path.screenToGlobal(pt);
  12:         ...
  13:             pressObjPt = (Point2D)pt.clone();

View Full Code Here
   1:     if (scale) {
   2:         Point2D pt1 = new Point2D.Double();
   3: 
   4:         ...
   5:         ZNode node;
   6:         Point2D center = bounds.getCenter2D();
   7:         for (Iterator i=selection.iterator(); i.hasNext();) {
   8:         ...
   9:         node = (ZNode)i.next();
  10:         pt1.setLocation(center);
  11:         node.globalToLocal(pt1);

View Full Code Here
   1: import java.awt.Graphics2D;
   2: import java.awt.geom.Point2D;
   3: public class Mass {
   4:         ...
   5:     private Point2D position;
   6:         ...
   7:     private Point2D accel;
   8:     public Mass() {
   9:         ...
  10:     protected void setPosition(Point2D position) {
  11:         this.position.setLocation(position);

View Full Code Here