< prev index next >

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

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 274,283 **** --- 274,294 ---- append(pi, false); } } @Override + public final void trimToSize() { + // trim arrays: + if (numTypes < pointTypes.length) { + this.pointTypes = Arrays.copyOf(pointTypes, numTypes); + } + if (numCoords < floatCoords.length) { + this.floatCoords = Arrays.copyOf(floatCoords, numCoords); + } + } + + @Override float[] cloneCoordsFloat(AffineTransform at) { // trim arrays: float ret[]; if (at == null) { ret = Arrays.copyOf(floatCoords, numCoords);
*** 1143,1152 **** --- 1154,1174 ---- append(pi, false); } } @Override + public final void trimToSize() { + // trim arrays: + if (numTypes < pointTypes.length) { + this.pointTypes = Arrays.copyOf(pointTypes, numTypes); + } + if (numCoords < doubleCoords.length) { + this.doubleCoords = Arrays.copyOf(doubleCoords, numCoords); + } + } + + @Override float[] cloneCoordsFloat(AffineTransform at) { // trim arrays: float ret[] = new float[numCoords]; if (at == null) { for (int i = 0; i < numCoords; i++) {
*** 2468,2477 **** --- 2490,2507 ---- // 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. An application can use this operation to minimize the + * storage of a path. + * @Since 10 + */ + public abstract void 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 >