View Javadoc

1   // Copyright 2002, FreeHEP.
2   package org.freehep.graphicsio.emf.gdi;
3   
4   import java.io.IOException;
5   
6   import org.freehep.graphicsio.emf.EMFConstants;
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   * SetROP2 TAG.
14   * 
15   * @author Mark Donszelmann
16   * @version $Id: SetROP2.java 10367 2007-01-22 19:26:48Z duns $
17   */
18  public class SetROP2 extends EMFTag implements EMFConstants {
19  
20      private int mode;
21  
22      public SetROP2() {
23          super(20, 1);
24      }
25  
26      public SetROP2(int mode) {
27          this();
28          this.mode = mode;
29      }
30  
31      public EMFTag read(int tagID, EMFInputStream emf, int len)
32              throws IOException {
33  
34          return new SetROP2(emf.readDWORD());
35      }
36  
37      public void write(int tagID, EMFOutputStream emf) throws IOException {
38          emf.writeDWORD(mode);
39      }
40  
41      public String toString() {
42          return super.toString() + "\n  mode: " + mode;
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 SetROP2 function sets the current foreground mix mode.
52          // GDI uses the foreground mix mode to combine pens and interiors
53          // of filled objects with the colors already on the screen. The
54          // foreground mix mode defines how colors from the brush or pen
55          // and the colors in the existing image are to be combined.
56          renderer.setRop2(mode);
57      }
58  }