/** * Constructs and initializes a <code>Polygon2D</code> from the specified * Polygon. * @param pol the Polygon * @exception NullPointerException pol is <code>null</code>. */ public Polygon2D(Polygon pol) { if (pol == null) { throw new IndexOutOfBoundsException("null Polygon"); } this.npoints = pol.npoints; this.xpoints = new float[pol.npoints]; this.ypoints = new float[pol.npoints]; for (int i = 0; i < pol.npoints; i++) { xpoints[i] = pol.xpoints[i]; ypoints[i] = pol.ypoints[i]; } calculatePath(); }
/** * Constructs and initializes a <code>Polygon2D</code> from the specified * Polygon. * @param pol the Polygon * @exception NullPointerException pol is <code>null</code>. */ public Polygon2D(Polygon pol) { if (pol == null) { throw new IndexOutOfBoundsException("null Polygon"); } this.npoints = pol.npoints; this.xpoints = new float[pol.npoints]; this.ypoints = new float[pol.npoints]; for (int i = 0; i < pol.npoints; i++) { xpoints[i] = pol.xpoints[i]; ypoints[i] = pol.ypoints[i]; } calculatePath(); }
/** * Constructs and initializes a <code>Polygon2D</code> from the specified * Polygon. * @param pol the Polygon * @exception NullPointerException pol is <code>null</code>. */ public Polygon2D(Polygon pol) { if (pol == null) { throw new IndexOutOfBoundsException("null Polygon"); } this.npoints = pol.npoints; this.xpoints = new float[pol.npoints]; this.ypoints = new float[pol.npoints]; for (int i = 0; i < pol.npoints; i++) { xpoints[i] = pol.xpoints[i]; ypoints[i] = pol.ypoints[i]; } calculatePath(); }
/** * Constructs and initializes a <code>Polygon2D</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>Polygon2D</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 Polygon2D(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(); }
/** * Constructs and initializes a <code>Polygon2D</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>Polygon2D</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 Polygon2D(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(); }
/** * Constructs and initializes a <code>Polygon2D</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>Polygon2D</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 Polygon2D(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(); }
/** * Constructs and initializes a <code>Polygon2D</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>Polygon2D</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 Polygon2D(float[] xpoints, float[] 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]; System.arraycopy(xpoints, 0, this.xpoints, 0, npoints); System.arraycopy(ypoints, 0, this.ypoints, 0, npoints); calculatePath(); }
/** * Constructs and initializes a <code>Polygon2D</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>Polygon2D</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 Polygon2D(float[] xpoints, float[] 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]; System.arraycopy(xpoints, 0, this.xpoints, 0, npoints); System.arraycopy(ypoints, 0, this.ypoints, 0, npoints); calculatePath(); }
/** * Constructs and initializes a <code>Polygon2D</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>Polygon2D</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 Polygon2D(float[] xpoints, float[] 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]; System.arraycopy(xpoints, 0, this.xpoints, 0, npoints); System.arraycopy(ypoints, 0, this.ypoints, 0, npoints); calculatePath(); }
/** * Constructs and initializes a <code>Polygon2D</code> from the specified * Rectangle2D. * @param rec the Rectangle2D * @exception NullPointerException rec is <code>null</code>. */ public Polygon2D(Rectangle2D rec) { if (rec == null) { throw new IndexOutOfBoundsException("null Rectangle"); } npoints = 4; xpoints = new float[4]; ypoints = new float[4]; xpoints[0] = (float)rec.getMinX(); ypoints[0] = (float)rec.getMinY(); xpoints[1] = (float)rec.getMaxX(); ypoints[1] = (float)rec.getMinY(); xpoints[2] = (float)rec.getMaxX(); ypoints[2] = (float)rec.getMaxY(); xpoints[3] = (float)rec.getMinX(); ypoints[3] = (float)rec.getMaxY(); calculatePath(); }
/** * Constructs and initializes a <code>Polygon2D</code> from the specified * Rectangle2D. * @param rec the Rectangle2D * @exception NullPointerException rec is <code>null</code>. */ public Polygon2D(Rectangle2D rec) { if (rec == null) { throw new IndexOutOfBoundsException("null Rectangle"); } npoints = 4; xpoints = new float[4]; ypoints = new float[4]; xpoints[0] = (float)rec.getMinX(); ypoints[0] = (float)rec.getMinY(); xpoints[1] = (float)rec.getMaxX(); ypoints[1] = (float)rec.getMinY(); xpoints[2] = (float)rec.getMaxX(); ypoints[2] = (float)rec.getMaxY(); xpoints[3] = (float)rec.getMinX(); ypoints[3] = (float)rec.getMaxY(); calculatePath(); }
/** * Constructs and initializes a <code>Polygon2D</code> from the specified * Rectangle2D. * @param rec the Rectangle2D * @exception NullPointerException rec is <code>null</code>. */ public Polygon2D(Rectangle2D rec) { if (rec == null) { throw new IndexOutOfBoundsException("null Rectangle"); } npoints = 4; xpoints = new float[4]; ypoints = new float[4]; xpoints[0] = (float)rec.getMinX(); ypoints[0] = (float)rec.getMinY(); xpoints[1] = (float)rec.getMaxX(); ypoints[1] = (float)rec.getMinY(); xpoints[2] = (float)rec.getMaxX(); ypoints[2] = (float)rec.getMaxY(); xpoints[3] = (float)rec.getMinX(); ypoints[3] = (float)rec.getMaxY(); calculatePath(); }