/** * Gets the point coordinate of a control point. */ public Point2D.Double getPoint(int index, int coord) { return path.get(index).getControlPoint(coord); }
public Point2D.Double getOutermostPoint() { return path.get(path.indexOfOutermostNode()).getControlPoint(0); }
/** * Gets the node count. */ public int getNodeCount() { return path.size(); }
/** * Returns a point on the edge of the bezier path which crosses the line * from the center of the bezier path to the specified point. * If no edge crosses the line, the nearest C0 control point is returned. */ public Point2D.Double chop(Point2D.Double p) { return Geom.chop(this, p); }
@Override public Rectangle2D.Double getBounds() { Rectangle2D.Double bounds = path.getBounds2D(); return bounds; }
/** * Translates the vertices of the <code>Polygon</code> by * <code>deltaX</code> along the x axis and by * <code>deltaY</code> along the y axis. * @param deltaX the amount to translate along the X axis * @param deltaY the amount to translate along the Y axis * */ @Override public void translate(double deltaX, double deltaY) { translate((float) deltaX, (float) deltaY); }
@Override public PathIterator getPathIterator(AffineTransform at) { return new PolygonPathIteratorFloat(this, at); } }
/** * Removes the Point2D.Double at the specified index. */ protected void removeAllNodes() { path.clear(); }
/** * Sets the size of this <code>Dimension2DDouble</code> object to the specified size. * This method is included for completeness, to parallel the * <code>setSize</code> method defined by <code>Component</code>. * @param d the new size for this <code>Dimension2DDouble</code> object * @see Dimension2DDouble#getSize * @see java.awt.Component#setSize * @since JDK1.1 */ public void setSize(Dimension2DDouble d) { setSize(d.width, d.height); }
/** * 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); }
@Override public PathIterator getPathIterator(AffineTransform at) { return new PolygonPathIteratorDouble(this, at); } }
/** * Normalizes the input vector and returns it. */ private static Point2D.Double v2Normalize(Point2D.Double v) { double len = v2Length(v); if (len != 0.0) { v.x /= len; v.y /= len; } return v; }
/** * Convenience method for getting the point coordinate of * the first control point of the specified node. */ public Point2D.Double getPoint(int index) { return path.get(index).getControlPoint(0); }
/** * Adds a node to the path. * <p> * This is a convenience method for adding a node with three control points * C0, C1 and C2, and a mask. * * @param ctrlMask An or-combination of C0_MASK,C1_MASK and C2_MASK. * @param c0 The coordinates of the C0 control point. * @param c1 The coordinates of the C1 control point. * @param c2 The coordinates of the C2 control point. */ public void add(int ctrlMask, Point2D.Double c0, Point2D.Double c1, Point2D.Double c2) { add(new Node(ctrlMask, c0, c1, c2)); }