View Javadoc

1   // Copyright 2002, FreeHEP.
2   package org.freehep.graphicsio.emf.gdi;
3   
4   import java.awt.Color;
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   * SetBkColor TAG.
14   * 
15   * @author Mark Donszelmann
16   * @version $Id: SetBkColor.java 10367 2007-01-22 19:26:48Z duns $
17   */
18  public class SetBkColor extends EMFTag {
19  
20      private Color color;
21  
22      public SetBkColor() {
23          super(25, 1);
24      }
25  
26      public SetBkColor(Color color) {
27          this();
28          this.color = color;
29      }
30  
31      public EMFTag read(int tagID, EMFInputStream emf, int len)
32              throws IOException {
33  
34          return new SetBkColor(emf.readCOLORREF());
35      }
36  
37      public void write(int tagID, EMFOutputStream emf) throws IOException {
38          emf.writeCOLORREF(color);
39      }
40  
41      public String toString() {
42          return super.toString() + "\n  color: " + color;
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          // This function fills the gaps between styled lines drawn using a
52          // pen created by the CreatePen function; it does not fill the gaps
53          // between styled lines drawn using a pen created by the ExtCreatePen
54          // function. The SetBKColor function also sets the background colors
55          // for TextOut and ExtTextOut.
56  
57          // If the background mode is OPAQUE, the background color is used to
58          // fill gaps between styled lines, gaps between hatched lines in brushes,
59          // and character cells. The background color is also used when converting
60          // bitmaps from color to monochrome and vice versa.
61  
62          // TODO: affects TextOut and ExtTextOut, CreatePen
63      }
64  }