View Javadoc

1   // Copyright 2002, FreeHEP.
2   package org.freehep.graphicsio.emf.gdi;
3   
4   import java.awt.Rectangle;
5   import java.awt.geom.GeneralPath;
6   import java.io.IOException;
7   
8   import org.freehep.graphicsio.emf.EMFInputStream;
9   import org.freehep.graphicsio.emf.EMFOutputStream;
10  import org.freehep.graphicsio.emf.EMFTag;
11  import org.freehep.graphicsio.emf.EMFRenderer;
12  
13  /**
14   * StrokeAndFillPath TAG.
15   * 
16   * @author Mark Donszelmann
17   * @version $Id: StrokeAndFillPath.java 10367 2007-01-22 19:26:48Z duns $
18   */
19  public class StrokeAndFillPath extends EMFTag {
20  
21      private Rectangle bounds;
22  
23      public StrokeAndFillPath() {
24          super(63, 1);
25      }
26  
27      public StrokeAndFillPath(Rectangle bounds) {
28          this();
29          this.bounds = bounds;
30      }
31  
32      public EMFTag read(int tagID, EMFInputStream emf, int len)
33              throws IOException {
34  
35          return new StrokeAndFillPath(emf.readRECTL());
36      }
37  
38      public void write(int tagID, EMFOutputStream emf) throws IOException {
39          emf.writeRECTL(bounds);
40      }
41  
42      public String toString() {
43          return super.toString() + "\n  bounds: " + bounds;
44      }
45  
46      /**
47       * displays the tag using the renderer
48       *
49       * @param renderer EMFRenderer storing the drawing session data
50       */
51      public void render(EMFRenderer renderer) {
52          GeneralPath currentPath = renderer.getPath();
53          // fills the current path
54          if (currentPath != null) {
55              renderer.fillShape(currentPath);
56              renderer.drawShape(currentPath);
57              renderer.setPath(null);
58          }
59      }
60  }