Esempio n. 1
0
  public void fill(SunGraphics2D sg2d, Shape s) {
    if (sg2d.strokeState == sg2d.STROKE_THIN) {
      Path2D.Float p2df;
      int transX;
      int transY;
      if (sg2d.transformState <= sg2d.TRANSFORM_INT_TRANSLATE) {
        if (s instanceof Path2D.Float) {
          p2df = (Path2D.Float) s;
        } else {
          p2df = new Path2D.Float(s);
        }
        transX = sg2d.transX;
        transY = sg2d.transY;
      } else {
        p2df = new Path2D.Float(s, sg2d.transform);
        transX = 0;
        transY = 0;
      }
      sg2d.loops.fillPathLoop.FillPath(sg2d, sg2d.getSurfaceData(), transX, transY, p2df);
      return;
    }

    ShapeSpanIterator sr = getFillSSI(sg2d);
    try {
      sr.setOutputArea(sg2d.getCompClip());
      AffineTransform at =
          ((sg2d.transformState == sg2d.TRANSFORM_ISIDENT) ? null : sg2d.transform);
      sr.appendPath(s.getPathIterator(at));
      fillSpans(sg2d, sr);
    } finally {
      sr.dispose();
    }
  }
Esempio n. 2
0
  public void draw(SunGraphics2D sg2d, Shape s) {
    if (sg2d.strokeState == sg2d.STROKE_THIN) {
      Path2D.Float p2df;
      int transX;
      int transY;
      if (sg2d.transformState <= sg2d.TRANSFORM_INT_TRANSLATE) {
        if (s instanceof Path2D.Float) {
          p2df = (Path2D.Float) s;
        } else {
          p2df = new Path2D.Float(s);
        }
        transX = sg2d.transX;
        transY = sg2d.transY;
      } else {
        p2df = new Path2D.Float(s, sg2d.transform);
        transX = 0;
        transY = 0;
      }
      sg2d.loops.drawPathLoop.DrawPath(sg2d, sg2d.getSurfaceData(), transX, transY, p2df);
      return;
    }

    if (sg2d.strokeState == sg2d.STROKE_CUSTOM) {
      fill(sg2d, sg2d.stroke.createStrokedShape(s));
      return;
    }

    ShapeSpanIterator sr = getStrokeSpans(sg2d, s);

    try {
      fillSpans(sg2d, sr);
    } finally {
      sr.dispose();
    }
  }
Esempio n. 3
0
  public void fillPolygon(SunGraphics2D sg2d, int xPoints[], int yPoints[], int nPoints) {
    ShapeSpanIterator sr = getFillSSI(sg2d);

    try {
      sr.setOutputArea(sg2d.getCompClip());
      sr.appendPoly(xPoints, yPoints, nPoints, sg2d.transX, sg2d.transY);
      fillSpans(sg2d, sr);
    } finally {
      sr.dispose();
    }
  }
Esempio n. 4
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;
  }