163 * <p>
164 * The specified {@code src} {@link Shape} is widened according
165 * to the specified attribute parameters as per the
166 * {@link BasicStroke} specification.
167 *
168 * @param src the source path to be widened
169 * @param width the width of the widened path as per {@code BasicStroke}
170 * @param caps the end cap decorations as per {@code BasicStroke}
171 * @param join the segment join decorations as per {@code BasicStroke}
172 * @param miterlimit the miter limit as per {@code BasicStroke}
173 * @param dashes the dash length array as per {@code BasicStroke}
174 * @param dashphase the initial dash phase as per {@code BasicStroke}
175 * @return the widened path stored in a new {@code Shape} object
176 * @since 1.7
177 */
178 public abstract Shape createStrokedShape(Shape src,
179 float width,
180 int caps,
181 int join,
182 float miterlimit,
183 float dashes[],
184 float dashphase);
185
186 /**
187 * Sends the geometry for a widened path as specified by the parameters
188 * to the specified consumer.
189 * <p>
190 * The specified {@code src} {@link Shape} is widened according
191 * to the parameters specified by the {@link BasicStroke} object.
192 * Adjustments are made to the path as appropriate for the
193 * {@link java.awt.RenderingHints#VALUE_STROKE_NORMALIZE} hint if the
194 * {@code normalize} boolean parameter is true.
195 * Adjustments are made to the path as appropriate for the
196 * {@link java.awt.RenderingHints#VALUE_ANTIALIAS_ON} hint if the
197 * {@code antialias} boolean parameter is true.
198 * <p>
199 * The geometry of the widened path is forwarded to the indicated
200 * {@link PathConsumer2D} object as it is calculated.
201 *
202 * @param src the source path to be widened
203 * @param bs the {@code BasicSroke} object specifying the
254 * @param at the transform to be applied to the shape and the
255 * stroke attributes
256 * @param clip the current clip in effect in device coordinates
257 * @param bs if non-null, a {@code BasicStroke} whose attributes
258 * should be applied to this operation
259 * @param thin true if the transformed stroke attributes are smaller
260 * than the minimum dropout pen width
261 * @param normalize true if the {@code VALUE_STROKE_NORMALIZE}
262 * {@code RenderingHint} is in effect
263 * @param bbox returns the bounds of the iteration
264 * @return the {@code AATileGenerator} instance to be consulted
265 * for tile coverages, or null if there is no output to render
266 * @since 1.7
267 */
268 public abstract AATileGenerator getAATileGenerator(Shape s,
269 AffineTransform at,
270 Region clip,
271 BasicStroke bs,
272 boolean thin,
273 boolean normalize,
274 int bbox[]);
275
276 /**
277 * Construct an antialiased tile generator for the given parallelogram
278 * store the bounds of the tile iteration in the bbox parameter.
279 * The parallelogram is specified as a starting point and 2 delta
280 * vectors that indicate the slopes of the 2 pairs of sides of the
281 * parallelogram.
282 * The 4 corners of the parallelogram are defined by the 4 points:
283 * <ul>
284 * <li> {@code x}, {@code y}
285 * <li> {@code x+dx1}, {@code y+dy1}
286 * <li> {@code x+dx1+dx2}, {@code y+dy1+dy2}
287 * <li> {@code x+dx2}, {@code y+dy2}
288 * </ul>
289 * The {@code lw1} and {@code lw2} parameters provide a specification
290 * for an optionally stroked parallelogram if they are positive numbers.
291 * The {@code lw1} parameter is the ratio of the length of the {@code dx1},
292 * {@code dx2} delta vector to half of the line width in that same
293 * direction.
294 * The {@code lw2} parameter provides the same ratio for the other delta
320 *
321 * @param x the X coordinate of the first corner of the parallelogram
322 * @param y the Y coordinate of the first corner of the parallelogram
323 * @param dx1 the X coordinate delta of the first leg of the parallelogram
324 * @param dy1 the Y coordinate delta of the first leg of the parallelogram
325 * @param dx2 the X coordinate delta of the second leg of the parallelogram
326 * @param dy2 the Y coordinate delta of the second leg of the parallelogram
327 * @param lw1 the line width ratio for the first leg of the parallelogram
328 * @param lw2 the line width ratio for the second leg of the parallelogram
329 * @param clip the current clip in effect in device coordinates
330 * @param bbox returns the bounds of the iteration
331 * @return the {@code AATileGenerator} instance to be consulted
332 * for tile coverages, or null if there is no output to render
333 * @since 1.7
334 */
335 public abstract AATileGenerator getAATileGenerator(double x, double y,
336 double dx1, double dy1,
337 double dx2, double dy2,
338 double lw1, double lw2,
339 Region clip,
340 int bbox[]);
341
342 /**
343 * Returns the minimum pen width that the antialiasing rasterizer
344 * can represent without dropouts occurring.
345 * @since 1.7
346 */
347 public abstract float getMinimumAAPenSize();
348
349 /**
350 * Utility method to feed a {@link PathConsumer2D} object from a
351 * given {@link PathIterator}.
352 * This method deals with the details of running the iterator and
353 * feeding the consumer a segment at a time.
354 */
355 public static void feedConsumer(PathIterator pi, PathConsumer2D consumer) {
356 float coords[] = new float[6];
357 while (!pi.isDone()) {
358 switch (pi.currentSegment(coords)) {
359 case PathIterator.SEG_MOVETO:
360 consumer.moveTo(coords[0], coords[1]);
361 break;
362 case PathIterator.SEG_LINETO:
363 consumer.lineTo(coords[0], coords[1]);
364 break;
365 case PathIterator.SEG_QUADTO:
366 consumer.quadTo(coords[0], coords[1],
367 coords[2], coords[3]);
368 break;
369 case PathIterator.SEG_CUBICTO:
370 consumer.curveTo(coords[0], coords[1],
371 coords[2], coords[3],
372 coords[4], coords[5]);
373 break;
374 case PathIterator.SEG_CLOSE:
375 consumer.closePath();
376 break;
377 }
378 pi.next();
379 }
380 }
381
382 static class Tracer extends RenderingEngine {
383 RenderingEngine target;
384 String name;
385
386 public Tracer(RenderingEngine target) {
387 this.target = target;
388 name = target.getClass().getName();
389 }
390
391 public Shape createStrokedShape(Shape src,
392 float width,
393 int caps,
394 int join,
395 float miterlimit,
396 float dashes[],
397 float dashphase)
398 {
399 System.out.println(name+".createStrokedShape("+
400 src.getClass().getName()+", "+
401 "width = "+width+", "+
402 "caps = "+caps+", "+
403 "join = "+join+", "+
404 "miter = "+miterlimit+", "+
405 "dashes = "+dashes+", "+
406 "dashphase = "+dashphase+")");
407 return target.createStrokedShape(src,
408 width, caps, join, miterlimit,
409 dashes, dashphase);
410 }
411
412 public void strokeTo(Shape src,
413 AffineTransform at,
414 BasicStroke bs,
415 boolean thin,
416 boolean normalize,
422 at+", "+
423 bs+", "+
424 (thin ? "thin" : "wide")+", "+
425 (normalize ? "normalized" : "pure")+", "+
426 (antialias ? "AA" : "non-AA")+", "+
427 consumer.getClass().getName()+")");
428 target.strokeTo(src, at, bs, thin, normalize, antialias, consumer);
429 }
430
431 public float getMinimumAAPenSize() {
432 System.out.println(name+".getMinimumAAPenSize()");
433 return target.getMinimumAAPenSize();
434 }
435
436 public AATileGenerator getAATileGenerator(Shape s,
437 AffineTransform at,
438 Region clip,
439 BasicStroke bs,
440 boolean thin,
441 boolean normalize,
442 int bbox[])
443 {
444 System.out.println(name+".getAATileGenerator("+
445 s.getClass().getName()+", "+
446 at+", "+
447 clip+", "+
448 bs+", "+
449 (thin ? "thin" : "wide")+", "+
450 (normalize ? "normalized" : "pure")+")");
451 return target.getAATileGenerator(s, at, clip,
452 bs, thin, normalize,
453 bbox);
454 }
455 public AATileGenerator getAATileGenerator(double x, double y,
456 double dx1, double dy1,
457 double dx2, double dy2,
458 double lw1, double lw2,
459 Region clip,
460 int bbox[])
461 {
462 System.out.println(name+".getAATileGenerator("+
463 x+", "+y+", "+
464 dx1+", "+dy1+", "+
465 dx2+", "+dy2+", "+
466 lw1+", "+lw2+", "+
467 clip+")");
468 return target.getAATileGenerator(x, y,
469 dx1, dy1,
470 dx2, dy2,
471 lw1, lw2,
472 clip, bbox);
473 }
474 }
475 }
|
163 * <p>
164 * The specified {@code src} {@link Shape} is widened according
165 * to the specified attribute parameters as per the
166 * {@link BasicStroke} specification.
167 *
168 * @param src the source path to be widened
169 * @param width the width of the widened path as per {@code BasicStroke}
170 * @param caps the end cap decorations as per {@code BasicStroke}
171 * @param join the segment join decorations as per {@code BasicStroke}
172 * @param miterlimit the miter limit as per {@code BasicStroke}
173 * @param dashes the dash length array as per {@code BasicStroke}
174 * @param dashphase the initial dash phase as per {@code BasicStroke}
175 * @return the widened path stored in a new {@code Shape} object
176 * @since 1.7
177 */
178 public abstract Shape createStrokedShape(Shape src,
179 float width,
180 int caps,
181 int join,
182 float miterlimit,
183 float[] dashes,
184 float dashphase);
185
186 /**
187 * Sends the geometry for a widened path as specified by the parameters
188 * to the specified consumer.
189 * <p>
190 * The specified {@code src} {@link Shape} is widened according
191 * to the parameters specified by the {@link BasicStroke} object.
192 * Adjustments are made to the path as appropriate for the
193 * {@link java.awt.RenderingHints#VALUE_STROKE_NORMALIZE} hint if the
194 * {@code normalize} boolean parameter is true.
195 * Adjustments are made to the path as appropriate for the
196 * {@link java.awt.RenderingHints#VALUE_ANTIALIAS_ON} hint if the
197 * {@code antialias} boolean parameter is true.
198 * <p>
199 * The geometry of the widened path is forwarded to the indicated
200 * {@link PathConsumer2D} object as it is calculated.
201 *
202 * @param src the source path to be widened
203 * @param bs the {@code BasicSroke} object specifying the
254 * @param at the transform to be applied to the shape and the
255 * stroke attributes
256 * @param clip the current clip in effect in device coordinates
257 * @param bs if non-null, a {@code BasicStroke} whose attributes
258 * should be applied to this operation
259 * @param thin true if the transformed stroke attributes are smaller
260 * than the minimum dropout pen width
261 * @param normalize true if the {@code VALUE_STROKE_NORMALIZE}
262 * {@code RenderingHint} is in effect
263 * @param bbox returns the bounds of the iteration
264 * @return the {@code AATileGenerator} instance to be consulted
265 * for tile coverages, or null if there is no output to render
266 * @since 1.7
267 */
268 public abstract AATileGenerator getAATileGenerator(Shape s,
269 AffineTransform at,
270 Region clip,
271 BasicStroke bs,
272 boolean thin,
273 boolean normalize,
274 int[] bbox);
275
276 /**
277 * Construct an antialiased tile generator for the given parallelogram
278 * store the bounds of the tile iteration in the bbox parameter.
279 * The parallelogram is specified as a starting point and 2 delta
280 * vectors that indicate the slopes of the 2 pairs of sides of the
281 * parallelogram.
282 * The 4 corners of the parallelogram are defined by the 4 points:
283 * <ul>
284 * <li> {@code x}, {@code y}
285 * <li> {@code x+dx1}, {@code y+dy1}
286 * <li> {@code x+dx1+dx2}, {@code y+dy1+dy2}
287 * <li> {@code x+dx2}, {@code y+dy2}
288 * </ul>
289 * The {@code lw1} and {@code lw2} parameters provide a specification
290 * for an optionally stroked parallelogram if they are positive numbers.
291 * The {@code lw1} parameter is the ratio of the length of the {@code dx1},
292 * {@code dx2} delta vector to half of the line width in that same
293 * direction.
294 * The {@code lw2} parameter provides the same ratio for the other delta
320 *
321 * @param x the X coordinate of the first corner of the parallelogram
322 * @param y the Y coordinate of the first corner of the parallelogram
323 * @param dx1 the X coordinate delta of the first leg of the parallelogram
324 * @param dy1 the Y coordinate delta of the first leg of the parallelogram
325 * @param dx2 the X coordinate delta of the second leg of the parallelogram
326 * @param dy2 the Y coordinate delta of the second leg of the parallelogram
327 * @param lw1 the line width ratio for the first leg of the parallelogram
328 * @param lw2 the line width ratio for the second leg of the parallelogram
329 * @param clip the current clip in effect in device coordinates
330 * @param bbox returns the bounds of the iteration
331 * @return the {@code AATileGenerator} instance to be consulted
332 * for tile coverages, or null if there is no output to render
333 * @since 1.7
334 */
335 public abstract AATileGenerator getAATileGenerator(double x, double y,
336 double dx1, double dy1,
337 double dx2, double dy2,
338 double lw1, double lw2,
339 Region clip,
340 int[] bbox);
341
342 /**
343 * Returns the minimum pen width that the antialiasing rasterizer
344 * can represent without dropouts occurring.
345 * @since 1.7
346 */
347 public abstract float getMinimumAAPenSize();
348
349 /**
350 * Utility method to feed a {@link PathConsumer2D} object from a
351 * given {@link PathIterator}.
352 * This method deals with the details of running the iterator and
353 * feeding the consumer a segment at a time.
354 */
355 public static void feedConsumer(PathIterator pi, PathConsumer2D consumer) {
356 float[] coords = new float[6];
357 while (!pi.isDone()) {
358 switch (pi.currentSegment(coords)) {
359 case PathIterator.SEG_MOVETO:
360 consumer.moveTo(coords[0], coords[1]);
361 break;
362 case PathIterator.SEG_LINETO:
363 consumer.lineTo(coords[0], coords[1]);
364 break;
365 case PathIterator.SEG_QUADTO:
366 consumer.quadTo(coords[0], coords[1],
367 coords[2], coords[3]);
368 break;
369 case PathIterator.SEG_CUBICTO:
370 consumer.curveTo(coords[0], coords[1],
371 coords[2], coords[3],
372 coords[4], coords[5]);
373 break;
374 case PathIterator.SEG_CLOSE:
375 consumer.closePath();
376 break;
377 }
378 pi.next();
379 }
380 }
381
382 static class Tracer extends RenderingEngine {
383 RenderingEngine target;
384 String name;
385
386 public Tracer(RenderingEngine target) {
387 this.target = target;
388 name = target.getClass().getName();
389 }
390
391 public Shape createStrokedShape(Shape src,
392 float width,
393 int caps,
394 int join,
395 float miterlimit,
396 float[] dashes,
397 float dashphase)
398 {
399 System.out.println(name+".createStrokedShape("+
400 src.getClass().getName()+", "+
401 "width = "+width+", "+
402 "caps = "+caps+", "+
403 "join = "+join+", "+
404 "miter = "+miterlimit+", "+
405 "dashes = "+dashes+", "+
406 "dashphase = "+dashphase+")");
407 return target.createStrokedShape(src,
408 width, caps, join, miterlimit,
409 dashes, dashphase);
410 }
411
412 public void strokeTo(Shape src,
413 AffineTransform at,
414 BasicStroke bs,
415 boolean thin,
416 boolean normalize,
422 at+", "+
423 bs+", "+
424 (thin ? "thin" : "wide")+", "+
425 (normalize ? "normalized" : "pure")+", "+
426 (antialias ? "AA" : "non-AA")+", "+
427 consumer.getClass().getName()+")");
428 target.strokeTo(src, at, bs, thin, normalize, antialias, consumer);
429 }
430
431 public float getMinimumAAPenSize() {
432 System.out.println(name+".getMinimumAAPenSize()");
433 return target.getMinimumAAPenSize();
434 }
435
436 public AATileGenerator getAATileGenerator(Shape s,
437 AffineTransform at,
438 Region clip,
439 BasicStroke bs,
440 boolean thin,
441 boolean normalize,
442 int[] bbox)
443 {
444 System.out.println(name+".getAATileGenerator("+
445 s.getClass().getName()+", "+
446 at+", "+
447 clip+", "+
448 bs+", "+
449 (thin ? "thin" : "wide")+", "+
450 (normalize ? "normalized" : "pure")+")");
451 return target.getAATileGenerator(s, at, clip,
452 bs, thin, normalize,
453 bbox);
454 }
455 public AATileGenerator getAATileGenerator(double x, double y,
456 double dx1, double dy1,
457 double dx2, double dy2,
458 double lw1, double lw2,
459 Region clip,
460 int[] bbox)
461 {
462 System.out.println(name+".getAATileGenerator("+
463 x+", "+y+", "+
464 dx1+", "+dy1+", "+
465 dx2+", "+dy2+", "+
466 lw1+", "+lw2+", "+
467 clip+")");
468 return target.getAATileGenerator(x, y,
469 dx1, dy1,
470 dx2, dy2,
471 lw1, lw2,
472 clip, bbox);
473 }
474 }
475 }
|