public void strokeTo(
     Shape src,
     AffineTransform at,
     BasicStroke bs,
     boolean thin,
     boolean normalize,
     boolean antialias,
     PathConsumer2D consumer) {
   System.out.println(
       name
           + ".strokeTo("
           + src.getClass().getName()
           + ", "
           + at
           + ", "
           + bs
           + ", "
           + (thin ? "thin" : "wide")
           + ", "
           + (normalize ? "normalized" : "pure")
           + ", "
           + (antialias ? "AA" : "non-AA")
           + ", "
           + consumer.getClass().getName()
           + ")");
   target.strokeTo(src, at, bs, thin, normalize, antialias, consumer);
 }
Exemple #2
0
  /*
   * Return a ShapeSpanIterator ready to iterate the spans of the wide
   * outline of Shape s using the attributes of the SunGraphics2D
   * object.
   *
   * The ShapeSpanIterator returned will be fully constructed
   * and filled with the geometry from the Shape widened by the
   * appropriate BasicStroke and normalization parameters taken
   * from the SunGraphics2D object and be ready to start returning
   * spans.
   *
   * Note that the caller is responsible for calling dispose()
   * on the returned ShapeSpanIterator inside a try/finally block.
   * <pre>
   *     ShapeSpanIterator ssi = LoopPipe.getStrokeSpans(sg2d, s);
   *     try {
   *         // iterate the spans from ssi and operate on them
   *     } finally {
   *         ssi.dispose();
   *     }
   * </pre>
   *
   * REMIND: This should return a SpanIterator interface object
   * but the caller needs to dispose() the object and that method
   * is only on ShapeSpanIterator.
   * TODO: Add a dispose() method to the SpanIterator interface.
   */
  public static ShapeSpanIterator getStrokeSpans(SunGraphics2D sg2d, Shape s) {
    ShapeSpanIterator sr = new ShapeSpanIterator(false);

    try {
      sr.setOutputArea(sg2d.getCompClip());
      sr.setRule(PathIterator.WIND_NON_ZERO);

      BasicStroke bs = (BasicStroke) sg2d.stroke;
      boolean thin = (sg2d.strokeState <= sg2d.STROKE_THINDASHED);
      boolean normalize = (sg2d.strokeHint != SunHints.INTVAL_STROKE_PURE);

      RenderEngine.strokeTo(s, sg2d.transform, bs, thin, normalize, false, sr);
    } catch (Throwable t) {
      sr.dispose();
      sr = null;
      t.printStackTrace();
      throw new InternalError("Unable to Stroke shape (" + t.getMessage() + ")");
    }
    return sr;
  }