/** * 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(); }
/** * 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(); }
/** * 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(); }
/** * 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(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+1]; // make space for one more to close the polyline this.ypoints = new float[npoints+1]; // make space for one more to close the polyline System.arraycopy(xpoints, 0, this.xpoints, 0, npoints); System.arraycopy(ypoints, 0, this.ypoints, 0, npoints); calculatePath(); }
/** * 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(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+1]; // make space for one more to close the polyline this.ypoints = new float[npoints+1]; // make space for one more to close the polyline System.arraycopy(xpoints, 0, this.xpoints, 0, npoints); System.arraycopy(ypoints, 0, this.ypoints, 0, npoints); calculatePath(); }
/** * 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(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+1]; // make space for one more to close the polyline this.ypoints = new float[npoints+1]; // make space for one more to close the polyline System.arraycopy(xpoints, 0, this.xpoints, 0, npoints); System.arraycopy(ypoints, 0, this.ypoints, 0, npoints); calculatePath(); }
public Polyline2D(Line2D line) { npoints = 2; xpoints = new float[2]; ypoints = new float[2]; xpoints[0] = (float)line.getX1(); xpoints[1] = (float)line.getX2(); ypoints[0] = (float)line.getY1(); ypoints[1] = (float)line.getY2(); calculatePath(); }
public Polyline2D(Line2D line) { npoints = 2; xpoints = new float[2]; ypoints = new float[2]; xpoints[0] = (float)line.getX1(); xpoints[1] = (float)line.getX2(); ypoints[0] = (float)line.getY1(); ypoints[1] = (float)line.getY2(); calculatePath(); }
public Polyline2D(Line2D line) { npoints = 2; xpoints = new float[2]; ypoints = new float[2]; xpoints[0] = (float)line.getX1(); xpoints[1] = (float)line.getX2(); ypoints[0] = (float)line.getY1(); ypoints[1] = (float)line.getY2(); calculatePath(); }