View Javadoc

1   // Copyright 2002, FreeHEP.
2   package org.freehep.graphicsio.emf.gdi;
3   
4   import java.awt.Rectangle;
5   import java.io.IOException;
6   
7   import org.freehep.graphicsio.emf.EMFInputStream;
8   import org.freehep.graphicsio.emf.EMFOutputStream;
9   import org.freehep.graphicsio.emf.EMFTag;
10  import org.freehep.graphicsio.emf.EMFRenderer;
11  
12  /**
13   * IntersectClipRect TAG.
14   *
15   * @author Mark Donszelmann
16   * @version $Id: IntersectClipRect.java 10377 2007-01-23 15:44:34Z duns $
17   */
18  public class IntersectClipRect extends EMFTag {
19  
20      private Rectangle bounds;
21  
22      public IntersectClipRect() {
23          super(30, 1);
24      }
25  
26      public IntersectClipRect(Rectangle bounds) {
27          this();
28          this.bounds = bounds;
29      }
30  
31      public EMFTag read(int tagID, EMFInputStream emf, int len)
32              throws IOException {
33  
34          return new IntersectClipRect(emf.readRECTL());
35      }
36  
37      public void write(int tagID, EMFOutputStream emf) throws IOException {
38          emf.writeRECTL(bounds);
39      }
40  
41      public String toString() {
42          return super.toString() + "\n  bounds: " + bounds;
43      }
44  
45      /**
46       * displays the tag using the renderer
47       *
48       * @param renderer EMFRenderer storing the drawing session data
49       */
50      public void render(EMFRenderer renderer) {
51          // The IntersectClipRect function creates a new clipping
52          // region from the intersection of the current clipping
53          // region and the specified rectangle.
54          renderer.clip(bounds);
55      }
56  }