/** * Determines whether the specified {@link Point} is inside this * <code>Polygon</code>. * @param p the specified <code>Point</code> to be tested * @return <code>true</code> if the <code>Polygon</code> contains the * <code>Point</code>; <code>false</code> otherwise. * @see #contains(double, double) * */ public boolean contains(Point p) { return contains(p.x, p.y); }
/** * Returns an iterator object that iterates along the boundary of * the <code>Shape</code> and provides access to the geometry of the * outline of the <code>Shape</code>. Only SEG_MOVETO, SEG_LINETO, and * SEG_CLOSE point types are returned by the iterator. * Since polygons are already flat, the <code>flatness</code> parameter * is ignored. An optional <code>AffineTransform</code> can be specified * in which case the coordinates returned in the iteration are transformed * accordingly. * @param at an optional <code>AffineTransform</code> to be applied to the * coordinates as they are returned in the iteration, or * <code>null</code> if untransformed coordinates are desired * @param flatness the maximum amount that the control points * for a given curve can vary from colinear before a subdivided * curve is replaced by a straight line connecting the * endpoints. Since polygons are already flat the * <code>flatness</code> parameter is ignored. * @return a <code>PathIterator</code> object that provides access to the * <code>Shape</code> object's geometry. * */ @Override public PathIterator getPathIterator(AffineTransform at, double flatness) { return getPathIterator(at); }
/** * Resets this <code>Polygon</code> object to an empty polygon. * The coordinate arrays and the data in them are left untouched * but the number of points is reset to zero to mark the old * vertex data as invalid and to start accumulating new vertex * data at the beginning. * All internally-cached data relating to the old vertices * are discarded. * Note that since the coordinate arrays from before the reset * are reused, creating a new empty <code>Polygon</code> might * be more memory efficient than resetting the current one if * the number of vertices in the new polygon data is significantly * smaller than the number of vertices in the data from before the * reset. * @see java.awt.Polygon#invalidate * */ public void reset() { npoints = 0; invalidate(); }
public void add(Point2D p) { addPoint(p.getX(), p.getY()); }
/** * {@inheritDoc} * */ @Override public boolean intersects(Rectangle2D r) { return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight()); }
/** * Gets the bounding box of this <code>Polygon</code>. * The bounding box is the smallest {@link Rectangle} whose * sides are parallel to the x and y axes of the * coordinate space, and can completely contain the <code>Polygon</code>. * @return a <code>Rectangle</code> that defines the bounds of this * <code>Polygon</code>. * */ @Override public Rectangle getBounds() { return getBounds2D().getBounds(); }
/** * Determines whether the specified coordinates are inside this * <code>Polygon</code>. * <p> * @param x the specified X coordinate to be tested * @param y the specified Y coordinate to be tested * @return {@code true} if this {@code Polygon} contains * the specified coordinates {@code (x,y)}; * {@code false} otherwise. * @see #contains(double, double) * */ public boolean contains(int x, int y) { return contains((double) x, (double) y); }
/** * {@inheritDoc} * */ @Override public boolean contains(Point2D p) { return contains(p.getX(), p.getY()); }
/** * {@inheritDoc} * */ @Override public boolean contains(Rectangle2D r) { return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight()); }