View Javadoc

1   // Copyright 2002, FreeHEP.
2   package org.freehep.graphicsio.emf.gdi;
3   
4   import java.awt.Dimension;
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   * SetViewportExtEx TAG.
14   * 
15   * @author Mark Donszelmann
16   * @version $Id: SetViewportExtEx.java 10367 2007-01-22 19:26:48Z duns $
17   */
18  public class SetViewportExtEx extends EMFTag {
19  
20      private Dimension size;
21  
22      public SetViewportExtEx() {
23          super(11, 1);
24      }
25  
26      public SetViewportExtEx(Dimension size) {
27          this();
28          this.size = size;
29      }
30  
31      public EMFTag read(int tagID, EMFInputStream emf, int len)
32              throws IOException {
33  
34          return new SetViewportExtEx(emf.readSIZEL());
35      }
36  
37      public void write(int tagID, EMFOutputStream emf) throws IOException {
38          emf.writeSIZEL(size);
39      }
40  
41      public String toString() {
42          return super.toString() + "\n  size: " + size;
43      }
44  
45      // The SetViewportExtEx function sets the horizontal and vertical
46      // extents of the viewport for a device context by using the specified values.
47  
48      /**
49       * displays the tag using the renderer
50       *
51       * @param renderer EMFRenderer storing the drawing session data
52       */
53      public void render(EMFRenderer renderer) {
54          // The viewport refers to the device coordinate system of the device space.
55          // The extent is the maximum value of an axis. This function sets the maximum
56          // values for the horizontal and vertical axes of the viewport in device
57          // coordinates (or pixels). When mapping between page space and device space,
58          // SetWindowExtEx and SetViewportExtEx determine the scaling factor between
59          // the window and the viewport.
60          renderer.setViewportSize(size);
61      }
62  }