< prev index next >

src/java.desktop/share/classes/java/awt/geom/Path2D.java

Print this page

        

*** 272,281 **** --- 272,293 ---- this.pointTypes = new byte[INIT_SIZE]; this.floatCoords = new float[INIT_SIZE * 2]; append(pi, false); } } + + @Override + public final Path2D trimToSize() { + // trim arrays: + if (numTypes < pointTypes.length) { + this.pointTypes = Arrays.copyOf(pointTypes, numTypes); + } + if (numCoords < floatCoords.length) { + this.floatCoords = Arrays.copyOf(floatCoords, numCoords); + } + return this; + } @Override float[] cloneCoordsFloat(AffineTransform at) { // trim arrays: float ret[];
*** 1141,1150 **** --- 1153,1174 ---- this.pointTypes = new byte[INIT_SIZE]; this.doubleCoords = new double[INIT_SIZE * 2]; append(pi, false); } } + + @Override + public final Path2D trimToSize() { + // trim arrays: + if (numTypes < pointTypes.length) { + this.pointTypes = Arrays.copyOf(pointTypes, numTypes); + } + if (numCoords < doubleCoords.length) { + this.doubleCoords = Arrays.copyOf(doubleCoords, numCoords); + } + return this; + } @Override float[] cloneCoordsFloat(AffineTransform at) { // trim arrays: float ret[] = new float[numCoords];
*** 2468,2477 **** --- 2492,2512 ---- // but one of our subclasses (GeneralPath) needs to // offer "public Object clone()" for backwards // compatibility so we cannot restrict it further. // REMIND: Can we do both somehow? + /** + * Trims the capacity of this Path2D instance to its current + * size. If the capacity of this path is larger than its current + * size, then the capacity is changed to equal the size by replacing + * its internal data array. An application can use this operation to + * minimize the storage of a path. + * @return this Path2D instance + * @Since 10 + */ + public abstract Path2D trimToSize(); + /* * Support fields and methods for serializing the subclasses. */ private static final byte SERIAL_STORAGE_FLT_ARRAY = 0x30; private static final byte SERIAL_STORAGE_DBL_ARRAY = 0x31;
< prev index next >