257 * @param at the specified {@code AffineTransform} object 258 * @since 1.6 259 */ 260 public Float(Shape s, AffineTransform at) { 261 if (s instanceof Path2D) { 262 Path2D p2d = (Path2D) s; 263 setWindingRule(p2d.windingRule); 264 this.numTypes = p2d.numTypes; 265 // trim arrays: 266 this.pointTypes = Arrays.copyOf(p2d.pointTypes, p2d.numTypes); 267 this.numCoords = p2d.numCoords; 268 this.floatCoords = p2d.cloneCoordsFloat(at); 269 } else { 270 PathIterator pi = s.getPathIterator(at); 271 setWindingRule(pi.getWindingRule()); 272 this.pointTypes = new byte[INIT_SIZE]; 273 this.floatCoords = new float[INIT_SIZE * 2]; 274 append(pi, false); 275 } 276 } 277 278 @Override 279 float[] cloneCoordsFloat(AffineTransform at) { 280 // trim arrays: 281 float ret[]; 282 if (at == null) { 283 ret = Arrays.copyOf(floatCoords, numCoords); 284 } else { 285 ret = new float[numCoords]; 286 at.transform(floatCoords, 0, ret, 0, numCoords / 2); 287 } 288 return ret; 289 } 290 291 @Override 292 double[] cloneCoordsDouble(AffineTransform at) { 293 // trim arrays: 294 double ret[] = new double[numCoords]; 295 if (at == null) { 296 for (int i = 0; i < numCoords; i++) { 1126 * @param at the specified {@code AffineTransform} object 1127 * @since 1.6 1128 */ 1129 public Double(Shape s, AffineTransform at) { 1130 if (s instanceof Path2D) { 1131 Path2D p2d = (Path2D) s; 1132 setWindingRule(p2d.windingRule); 1133 this.numTypes = p2d.numTypes; 1134 // trim arrays: 1135 this.pointTypes = Arrays.copyOf(p2d.pointTypes, p2d.numTypes); 1136 this.numCoords = p2d.numCoords; 1137 this.doubleCoords = p2d.cloneCoordsDouble(at); 1138 } else { 1139 PathIterator pi = s.getPathIterator(at); 1140 setWindingRule(pi.getWindingRule()); 1141 this.pointTypes = new byte[INIT_SIZE]; 1142 this.doubleCoords = new double[INIT_SIZE * 2]; 1143 append(pi, false); 1144 } 1145 } 1146 1147 @Override 1148 float[] cloneCoordsFloat(AffineTransform at) { 1149 // trim arrays: 1150 float ret[] = new float[numCoords]; 1151 if (at == null) { 1152 for (int i = 0; i < numCoords; i++) { 1153 ret[i] = (float) doubleCoords[i]; 1154 } 1155 } else { 1156 at.transform(doubleCoords, 0, ret, 0, numCoords / 2); 1157 } 1158 return ret; 1159 } 1160 1161 @Override 1162 double[] cloneCoordsDouble(AffineTransform at) { 1163 // trim arrays: 1164 double ret[]; 1165 if (at == null) { 2452 public final PathIterator getPathIterator(AffineTransform at, 2453 double flatness) 2454 { 2455 return new FlatteningPathIterator(getPathIterator(at), flatness); 2456 } 2457 2458 /** 2459 * Creates a new object of the same class as this object. 2460 * 2461 * @return a clone of this instance. 2462 * @exception OutOfMemoryError if there is not enough memory. 2463 * @see java.lang.Cloneable 2464 * @since 1.6 2465 */ 2466 public abstract Object clone(); 2467 // Note: It would be nice to have this return Path2D 2468 // but one of our subclasses (GeneralPath) needs to 2469 // offer "public Object clone()" for backwards 2470 // compatibility so we cannot restrict it further. 2471 // REMIND: Can we do both somehow? 2472 2473 /* 2474 * Support fields and methods for serializing the subclasses. 2475 */ 2476 private static final byte SERIAL_STORAGE_FLT_ARRAY = 0x30; 2477 private static final byte SERIAL_STORAGE_DBL_ARRAY = 0x31; 2478 2479 private static final byte SERIAL_SEG_FLT_MOVETO = 0x40; 2480 private static final byte SERIAL_SEG_FLT_LINETO = 0x41; 2481 private static final byte SERIAL_SEG_FLT_QUADTO = 0x42; 2482 private static final byte SERIAL_SEG_FLT_CUBICTO = 0x43; 2483 2484 private static final byte SERIAL_SEG_DBL_MOVETO = 0x50; 2485 private static final byte SERIAL_SEG_DBL_LINETO = 0x51; 2486 private static final byte SERIAL_SEG_DBL_QUADTO = 0x52; 2487 private static final byte SERIAL_SEG_DBL_CUBICTO = 0x53; 2488 2489 private static final byte SERIAL_SEG_CLOSE = 0x60; 2490 private static final byte SERIAL_PATH_END = 0x61; 2491 | 257 * @param at the specified {@code AffineTransform} object 258 * @since 1.6 259 */ 260 public Float(Shape s, AffineTransform at) { 261 if (s instanceof Path2D) { 262 Path2D p2d = (Path2D) s; 263 setWindingRule(p2d.windingRule); 264 this.numTypes = p2d.numTypes; 265 // trim arrays: 266 this.pointTypes = Arrays.copyOf(p2d.pointTypes, p2d.numTypes); 267 this.numCoords = p2d.numCoords; 268 this.floatCoords = p2d.cloneCoordsFloat(at); 269 } else { 270 PathIterator pi = s.getPathIterator(at); 271 setWindingRule(pi.getWindingRule()); 272 this.pointTypes = new byte[INIT_SIZE]; 273 this.floatCoords = new float[INIT_SIZE * 2]; 274 append(pi, false); 275 } 276 } 277 278 @Override 279 public final Path2D trimToSize() { 280 // trim arrays: 281 if (numTypes < pointTypes.length) { 282 this.pointTypes = Arrays.copyOf(pointTypes, numTypes); 283 } 284 if (numCoords < floatCoords.length) { 285 this.floatCoords = Arrays.copyOf(floatCoords, numCoords); 286 } 287 return this; 288 } 289 290 @Override 291 float[] cloneCoordsFloat(AffineTransform at) { 292 // trim arrays: 293 float ret[]; 294 if (at == null) { 295 ret = Arrays.copyOf(floatCoords, numCoords); 296 } else { 297 ret = new float[numCoords]; 298 at.transform(floatCoords, 0, ret, 0, numCoords / 2); 299 } 300 return ret; 301 } 302 303 @Override 304 double[] cloneCoordsDouble(AffineTransform at) { 305 // trim arrays: 306 double ret[] = new double[numCoords]; 307 if (at == null) { 308 for (int i = 0; i < numCoords; i++) { 1138 * @param at the specified {@code AffineTransform} object 1139 * @since 1.6 1140 */ 1141 public Double(Shape s, AffineTransform at) { 1142 if (s instanceof Path2D) { 1143 Path2D p2d = (Path2D) s; 1144 setWindingRule(p2d.windingRule); 1145 this.numTypes = p2d.numTypes; 1146 // trim arrays: 1147 this.pointTypes = Arrays.copyOf(p2d.pointTypes, p2d.numTypes); 1148 this.numCoords = p2d.numCoords; 1149 this.doubleCoords = p2d.cloneCoordsDouble(at); 1150 } else { 1151 PathIterator pi = s.getPathIterator(at); 1152 setWindingRule(pi.getWindingRule()); 1153 this.pointTypes = new byte[INIT_SIZE]; 1154 this.doubleCoords = new double[INIT_SIZE * 2]; 1155 append(pi, false); 1156 } 1157 } 1158 1159 @Override 1160 public final Path2D trimToSize() { 1161 // trim arrays: 1162 if (numTypes < pointTypes.length) { 1163 this.pointTypes = Arrays.copyOf(pointTypes, numTypes); 1164 } 1165 if (numCoords < doubleCoords.length) { 1166 this.doubleCoords = Arrays.copyOf(doubleCoords, numCoords); 1167 } 1168 return this; 1169 } 1170 1171 @Override 1172 float[] cloneCoordsFloat(AffineTransform at) { 1173 // trim arrays: 1174 float ret[] = new float[numCoords]; 1175 if (at == null) { 1176 for (int i = 0; i < numCoords; i++) { 1177 ret[i] = (float) doubleCoords[i]; 1178 } 1179 } else { 1180 at.transform(doubleCoords, 0, ret, 0, numCoords / 2); 1181 } 1182 return ret; 1183 } 1184 1185 @Override 1186 double[] cloneCoordsDouble(AffineTransform at) { 1187 // trim arrays: 1188 double ret[]; 1189 if (at == null) { 2476 public final PathIterator getPathIterator(AffineTransform at, 2477 double flatness) 2478 { 2479 return new FlatteningPathIterator(getPathIterator(at), flatness); 2480 } 2481 2482 /** 2483 * Creates a new object of the same class as this object. 2484 * 2485 * @return a clone of this instance. 2486 * @exception OutOfMemoryError if there is not enough memory. 2487 * @see java.lang.Cloneable 2488 * @since 1.6 2489 */ 2490 public abstract Object clone(); 2491 // Note: It would be nice to have this return Path2D 2492 // but one of our subclasses (GeneralPath) needs to 2493 // offer "public Object clone()" for backwards 2494 // compatibility so we cannot restrict it further. 2495 // REMIND: Can we do both somehow? 2496 2497 /** 2498 * Trims the capacity of this Path2D instance to its current 2499 * size. If the capacity of this path is larger than its current 2500 * size, then the capacity is changed to equal the size by replacing 2501 * its internal data array. An application can use this operation to 2502 * minimize the storage of a path. 2503 * @return this Path2D instance 2504 * @Since 10 2505 */ 2506 public abstract Path2D trimToSize(); 2507 2508 /* 2509 * Support fields and methods for serializing the subclasses. 2510 */ 2511 private static final byte SERIAL_STORAGE_FLT_ARRAY = 0x30; 2512 private static final byte SERIAL_STORAGE_DBL_ARRAY = 0x31; 2513 2514 private static final byte SERIAL_SEG_FLT_MOVETO = 0x40; 2515 private static final byte SERIAL_SEG_FLT_LINETO = 0x41; 2516 private static final byte SERIAL_SEG_FLT_QUADTO = 0x42; 2517 private static final byte SERIAL_SEG_FLT_CUBICTO = 0x43; 2518 2519 private static final byte SERIAL_SEG_DBL_MOVETO = 0x50; 2520 private static final byte SERIAL_SEG_DBL_LINETO = 0x51; 2521 private static final byte SERIAL_SEG_DBL_QUADTO = 0x52; 2522 private static final byte SERIAL_SEG_DBL_CUBICTO = 0x53; 2523 2524 private static final byte SERIAL_SEG_CLOSE = 0x60; 2525 private static final byte SERIAL_PATH_END = 0x61; 2526 |