Exemplo n.º 1
0
 /** @see Graphics#create() */
 public Graphics create() {
   PdfGraphics2D g2 = new PdfGraphics2D();
   g2.onlyShapes = this.onlyShapes;
   g2.transform = new AffineTransform(this.transform);
   g2.baseFonts = this.baseFonts;
   g2.fontMapper = this.fontMapper;
   g2.kids = this.kids;
   g2.paint = this.paint;
   g2.fillGState = this.fillGState;
   g2.strokeGState = this.strokeGState;
   g2.background = this.background;
   g2.mediaTracker = this.mediaTracker;
   g2.convertImagesToJPEG = this.convertImagesToJPEG;
   g2.jpegQuality = this.jpegQuality;
   g2.setFont(this.font);
   g2.cb = this.cb.getDuplicate();
   g2.cb.saveState();
   g2.width = this.width;
   g2.height = this.height;
   g2.followPath(new Area(new Rectangle2D.Float(0, 0, width, height)), CLIP);
   if (this.clip != null) g2.clip = new Area(this.clip);
   g2.stroke = stroke;
   g2.originalStroke = originalStroke;
   g2.strokeOne = (BasicStroke) g2.transformStroke(g2.strokeOne);
   g2.oldStroke = g2.strokeOne;
   g2.setStrokeDiff(g2.oldStroke, null);
   g2.cb.saveState();
   if (g2.clip != null) g2.followPath(g2.clip, CLIP);
   g2.kid = true;
   synchronized (kids) {
     kids.add(g2);
   }
   return g2;
 }
Exemplo n.º 2
0
 /** @see Graphics2D#clip(Shape) */
 public void clip(Shape s) {
   if (s == null) {
     setClip(null);
     return;
   }
   s = transform.createTransformedShape(s);
   if (clip == null) clip = new Area(s);
   else clip.intersect(new Area(s));
   followPath(s, CLIP);
 }
Exemplo n.º 3
0
 /** @see Graphics#setClip(Shape) */
 public void setClip(Shape s) {
   cb.restoreState();
   cb.saveState();
   if (s != null) s = transform.createTransformedShape(s);
   if (s == null) {
     clip = null;
   } else {
     clip = new Area(s);
     followPath(s, CLIP);
   }
   paintFill = paintStroke = null;
   currentFillGState = currentStrokeGState = 255;
   oldStroke = strokeOne;
 }
Exemplo n.º 4
0
 /** @see Graphics#create() */
 public Graphics create() {
   PdfGraphics2D g2 = new PdfGraphics2D();
   g2.rhints.putAll(this.rhints);
   g2.onlyShapes = this.onlyShapes;
   g2.transform = new AffineTransform(this.transform);
   g2.baseFonts = this.baseFonts;
   g2.fontMapper = this.fontMapper;
   g2.paint = this.paint;
   g2.fillGState = this.fillGState;
   g2.currentFillGState = this.currentFillGState;
   g2.strokeGState = this.strokeGState;
   g2.background = this.background;
   g2.mediaTracker = this.mediaTracker;
   g2.convertImagesToJPEG = this.convertImagesToJPEG;
   g2.jpegQuality = this.jpegQuality;
   g2.setFont(this.font);
   g2.cb = this.cb.getDuplicate();
   g2.cb.saveState();
   g2.width = this.width;
   g2.height = this.height;
   g2.followPath(new Area(new Rectangle2D.Float(0, 0, width, height)), CLIP);
   if (this.clip != null) g2.clip = new Area(this.clip);
   g2.composite = composite;
   g2.stroke = stroke;
   g2.originalStroke = originalStroke;
   g2.strokeOne = (BasicStroke) g2.transformStroke(g2.strokeOne);
   g2.oldStroke = g2.strokeOne;
   g2.setStrokeDiff(g2.oldStroke, null);
   g2.cb.saveState();
   if (g2.clip != null) g2.followPath(g2.clip, CLIP);
   g2.kid = true;
   if (this.kids == null) this.kids = new ArrayList();
   this.kids.add(new Integer(cb.getInternalBuffer().size()));
   this.kids.add(g2);
   return g2;
 }
Exemplo n.º 5
0
 /** @see Graphics2D#fill(Shape) */
 public void fill(Shape s) {
   followPath(s, FILL);
 }
Exemplo n.º 6
0
 /** @see Graphics2D#draw(Shape) */
 public void draw(Shape s) {
   followPath(s, STROKE);
 }
Exemplo n.º 7
0
  private void followPath(Shape s, int drawType) {
    if (s == null) return;
    if (drawType == STROKE) {
      if (!(stroke instanceof BasicStroke)) {
        s = stroke.createStrokedShape(s);
        followPath(s, FILL);
        return;
      }
    }
    if (drawType == STROKE) {
      setStrokeDiff(stroke, oldStroke);
      oldStroke = stroke;
      setStrokePaint();
    } else if (drawType == FILL) setFillPaint();
    PathIterator points;
    int traces = 0;
    if (drawType == CLIP) points = s.getPathIterator(IDENTITY);
    else points = s.getPathIterator(transform);
    float[] coords = new float[6];
    while (!points.isDone()) {
      ++traces;
      int segtype = points.currentSegment(coords);
      normalizeY(coords);
      switch (segtype) {
        case PathIterator.SEG_CLOSE:
          cb.closePath();
          break;

        case PathIterator.SEG_CUBICTO:
          cb.curveTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]);
          break;

        case PathIterator.SEG_LINETO:
          cb.lineTo(coords[0], coords[1]);
          break;

        case PathIterator.SEG_MOVETO:
          cb.moveTo(coords[0], coords[1]);
          break;

        case PathIterator.SEG_QUADTO:
          cb.curveTo(coords[0], coords[1], coords[2], coords[3]);
          break;
      }
      points.next();
    }
    switch (drawType) {
      case FILL:
        if (traces > 0) {
          if (points.getWindingRule() == PathIterator.WIND_EVEN_ODD) cb.eoFill();
          else cb.fill();
        }
        break;
      case STROKE:
        if (traces > 0) cb.stroke();
        break;
      default: // drawType==CLIP
        if (traces == 0) cb.rectangle(0, 0, 0, 0);
        if (points.getWindingRule() == PathIterator.WIND_EVEN_ODD) cb.eoClip();
        else cb.clip();
        cb.newPath();
    }
  }