View Javadoc

1   // Copyright 2002, FreeHEP.
2   package org.freehep.graphicsio.emf.gdi;
3   
4   import java.io.IOException;
5   import java.awt.geom.GeneralPath;
6   import java.awt.Stroke;
7   
8   import org.freehep.graphicsio.emf.EMFInputStream;
9   import org.freehep.graphicsio.emf.EMFTag;
10  import org.freehep.graphicsio.emf.EMFRenderer;
11  
12  /**
13   * WidenPath TAG.
14   * 
15   * @author Mark Donszelmann
16   * @version $Id: WidenPath.java 10367 2007-01-22 19:26:48Z duns $
17   */
18  public class WidenPath extends EMFTag {
19  
20      public WidenPath() {
21          super(66, 1);
22      }
23  
24      public EMFTag read(int tagID, EMFInputStream emf, int len)
25              throws IOException {
26  
27          return this;
28      }
29  
30      /**
31       * displays the tag using the renderer
32       *
33       * @param renderer EMFRenderer storing the drawing session data
34       */
35      public void render(EMFRenderer renderer) {
36          GeneralPath currentPath = renderer.getPath();
37          Stroke currentPenStroke = renderer.getPenStroke();
38          // The WidenPath function redefines the current path as the area
39          // that would be painted if the path were stroked using the pen
40          // currently selected into the given device context.
41          if (currentPath != null && currentPenStroke != null) {
42              GeneralPath newPath = new GeneralPath(
43                  renderer.getWindingRule());
44              newPath.append(currentPenStroke.createStrokedShape(currentPath), false);
45              renderer.setPath(newPath);
46          }
47      }
48  }