public Polyline2D getPolyline2D() { Polyline2D pol = new Polyline2D( xpoints, ypoints, npoints ); pol.addPoint( xpoints[0], ypoints[0]); return pol; }
/** * Constructs and initializes a <code>Polyline2D</code> from the specified * parameters. * @param xpoints an array of <i>x</i> coordinates * @param ypoints an array of <i>y</i> coordinates * @param npoints the total number of points in the <code>Polyline2D</code> * @exception NegativeArraySizeException if the value of * <code>npoints</code> is negative. * @exception IndexOutOfBoundsException if <code>npoints</code> is * greater than the length of <code>xpoints</code> * or the length of <code>ypoints</code>. * @exception NullPointerException if <code>xpoints</code> or * <code>ypoints</code> is <code>null</code>. */ public Polyline2D(int[] xpoints, int[] ypoints, int npoints) { if (npoints > xpoints.length || npoints > ypoints.length) { throw new IndexOutOfBoundsException("npoints > xpoints.length || npoints > ypoints.length"); } this.npoints = npoints; this.xpoints = new float[npoints]; this.ypoints = new float[npoints]; for (int i = 0; i < npoints; i++) { this.xpoints[i] = xpoints[i]; this.ypoints[i] = ypoints[i]; } calculatePath(); }
/** * Tests if the interior of this <code>Polygon</code> intersects the * interior of a specified <code>Rectangle2D</code>. * @param r a specified <code>Rectangle2D</code> * @return <code>true</code> if this <code>Polygon</code> and the * interior of the specified <code>Rectangle2D</code> * intersect each other; <code>false</code> * otherwise. */ public boolean intersects(Rectangle2D r) { return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight()); }
_ypts[k] = scaleY * ( vpY + yOffset + mr.elementAt( k*2+2 ) ); Polyline2D pol = new Polyline2D(_xpts, _ypts, count); paintWithPen(penObject, pol, g2d);
public void addPoint(Point2D p) { addPoint((float)p.getX(), (float)p.getY()); }
/** * Tests if the interior of this <code>Polygon</code> intersects the * interior of a specified set of rectangular coordinates. * @param x the x coordinate of the specified rectangular * shape's top-left corner * @param y the y coordinate of the specified rectangular * shape's top-left corner * @param w the width of the specified rectangular shape * @param h the height of the specified rectangular shape * @return <code>true</code> if the interior of this * <code>Polygon</code> and the interior of the * specified set of rectangular * coordinates intersect each other; * <code>false</code> otherwise. */ public boolean intersects(double x, double y, double w, double h) { if (npoints <= 0 || !bounds.intersects(x, y, w, h)) { return false; } updateComputingPath(); return closedPath.intersects(x, y, w, h); }
/** * Appends the specified coordinates to this <code>Polyline2D</code>. * <p> * If an operation that calculates the bounding box of this * <code>Polyline2D</code> has already been performed, such as * <code>getBounds</code> or <code>contains</code>, then this * method updates the bounding box. * @param x the specified x coordinate * @param y the specified y coordinate * @see java.awt.Polygon#getBounds * @see java.awt.Polygon#contains(double,double) */ public void addPoint(float x, float y) { if (npoints == xpoints.length) { float[] tmp; tmp = new float[npoints * 2]; System.arraycopy(xpoints, 0, tmp, 0, npoints); xpoints = tmp; tmp = new float[npoints * 2]; System.arraycopy(ypoints, 0, tmp, 0, npoints); ypoints = tmp; } xpoints[npoints] = x; ypoints[npoints] = y; npoints++; updatePath(x, y); }
_ypts[k] = scaleY * ( vpY + yOffset + mr.elementAt( k*2+2 ) ); Polyline2D pol = new Polyline2D(_xpts, _ypts, count); paintWithPen(penObject, pol, g2d);
public void addPoint(Point2D p) { addPoint((float)p.getX(), (float)p.getY()); }
/** * Tests if the interior of this <code>Polygon</code> intersects the * interior of a specified set of rectangular coordinates. * @param x the x coordinate of the specified rectangular * shape's top-left corner * @param y the y coordinate of the specified rectangular * shape's top-left corner * @param w the width of the specified rectangular shape * @param h the height of the specified rectangular shape * @return <code>true</code> if the interior of this * <code>Polygon</code> and the interior of the * specified set of rectangular * coordinates intersect each other; * <code>false</code> otherwise. */ public boolean intersects(double x, double y, double w, double h) { if (npoints <= 0 || !bounds.intersects(x, y, w, h)) { return false; } updateComputingPath(); return closedPath.intersects(x, y, w, h); }
/** * Appends the specified coordinates to this <code>Polyline2D</code>. * <p> * If an operation that calculates the bounding box of this * <code>Polyline2D</code> has already been performed, such as * <code>getBounds</code> or <code>contains</code>, then this * method updates the bounding box. * @param x the specified x coordinate * @param y the specified y coordinate * @see java.awt.Polygon#getBounds * @see java.awt.Polygon#contains(double,double) */ public void addPoint(float x, float y) { if (npoints == xpoints.length) { float[] tmp; tmp = new float[npoints * 2]; System.arraycopy(xpoints, 0, tmp, 0, npoints); xpoints = tmp; tmp = new float[npoints * 2]; System.arraycopy(ypoints, 0, tmp, 0, npoints); ypoints = tmp; } xpoints[npoints] = x; ypoints[npoints] = y; npoints++; updatePath(x, y); }
public Object clone() { Polyline2D pol = new Polyline2D(); for (int i = 0; i < npoints; i++) { pol.addPoint(xpoints[i], ypoints[i]); } return pol; }
_ypts[i] = readShort( is ); Polyline2D pol = new Polyline2D(_xpts, _ypts, count); paintWithPen(penObject, pol);
/** * Constructs and initializes a <code>Polyline2D</code> from the specified * parameters. * @param xpoints an array of <i>x</i> coordinates * @param ypoints an array of <i>y</i> coordinates * @param npoints the total number of points in the <code>Polyline2D</code> * @exception NegativeArraySizeException if the value of * <code>npoints</code> is negative. * @exception IndexOutOfBoundsException if <code>npoints</code> is * greater than the length of <code>xpoints</code> * or the length of <code>ypoints</code>. * @exception NullPointerException if <code>xpoints</code> or * <code>ypoints</code> is <code>null</code>. */ public Polyline2D(int[] xpoints, int[] ypoints, int npoints) { if (npoints > xpoints.length || npoints > ypoints.length) { throw new IndexOutOfBoundsException("npoints > xpoints.length || npoints > ypoints.length"); } this.npoints = npoints; this.xpoints = new float[npoints]; this.ypoints = new float[npoints]; for (int i = 0; i < npoints; i++) { this.xpoints[i] = xpoints[i]; this.ypoints[i] = ypoints[i]; } calculatePath(); }
/** * Tests if the interior of this <code>Polygon</code> intersects the * interior of a specified <code>Rectangle2D</code>. * @param r a specified <code>Rectangle2D</code> * @return <code>true</code> if this <code>Polygon</code> and the * interior of the specified <code>Rectangle2D</code> * intersect each other; <code>false</code> * otherwise. */ public boolean intersects(Rectangle2D r) { return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight()); }
public void addPoint(Point2D p) { addPoint((float)p.getX(), (float)p.getY()); }
/** * Tests if the interior of this <code>Polygon</code> intersects the * interior of a specified set of rectangular coordinates. * @param x the x coordinate of the specified rectangular * shape's top-left corner * @param y the y coordinate of the specified rectangular * shape's top-left corner * @param w the width of the specified rectangular shape * @param h the height of the specified rectangular shape * @return <code>true</code> if the interior of this * <code>Polygon</code> and the interior of the * specified set of rectangular * coordinates intersect each other; * <code>false</code> otherwise. */ public boolean intersects(double x, double y, double w, double h) { if (npoints <= 0 || !bounds.intersects(x, y, w, h)) { return false; } updateComputingPath(); return closedPath.intersects(x, y, w, h); }
/** * Appends the specified coordinates to this <code>Polyline2D</code>. * <p> * If an operation that calculates the bounding box of this * <code>Polyline2D</code> has already been performed, such as * <code>getBounds</code> or <code>contains</code>, then this * method updates the bounding box. * @param x the specified x coordinate * @param y the specified y coordinate * @see java.awt.Polygon#getBounds * @see java.awt.Polygon#contains(double,double) */ public void addPoint(float x, float y) { if (npoints == xpoints.length) { float[] tmp; tmp = new float[npoints * 2]; System.arraycopy(xpoints, 0, tmp, 0, npoints); xpoints = tmp; tmp = new float[npoints * 2]; System.arraycopy(ypoints, 0, tmp, 0, npoints); ypoints = tmp; } xpoints[npoints] = x; ypoints[npoints] = y; npoints++; updatePath(x, y); }
public Polyline2D getPolyline2D() { Polyline2D pol = new Polyline2D( xpoints, ypoints, npoints ); pol.addPoint( xpoints[0], ypoints[0]); return pol; }
_ypts[i] = readShort( is ); Polyline2D pol = new Polyline2D(_xpts, _ypts, count); paintWithPen(penObject, pol);