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   import java.util.logging.Logger;
7   
8   import org.freehep.graphicsio.emf.EMFConstants;
9   import org.freehep.graphicsio.emf.EMFInputStream;
10  import org.freehep.graphicsio.emf.EMFOutputStream;
11  import org.freehep.graphicsio.emf.EMFRenderer;
12  
13  /**
14   * EMF LogBrush32
15   *
16   * @author Mark Donszelmann
17   * @version $Id: LogBrush32.java 10377 2007-01-23 15:44:34Z duns $ see
18   *          http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/brushes_8yk2.asp
19   */
20  public class LogBrush32 implements EMFConstants, GDIObject {
21  
22      private int style;
23  
24      private Color color;
25  
26      private int hatch;
27  
28      public LogBrush32(int style, Color color, int hatch) {
29          this.style = style;
30          this.color = color;
31          this.hatch = hatch;
32      }
33  
34      public LogBrush32(EMFInputStream emf) throws IOException {
35          style = emf.readUINT();
36          color = emf.readCOLORREF();
37          hatch = emf.readULONG();
38      }
39  
40      public void write(EMFOutputStream emf) throws IOException {
41          emf.writeUINT(style);
42          emf.writeCOLORREF(color);
43          emf.writeULONG(hatch);
44      }
45  
46      public String toString() {
47          return "  LogBrush32\n" + "    style: " + style +
48              "\n    color: " + color +
49              "\n    hatch: " + hatch;
50      }
51  
52      /**
53       * displays the tag using the renderer
54       *
55       * @param renderer EMFRenderer storing the drawing session data
56       */
57      public void render(EMFRenderer renderer) {
58          if (style == EMFConstants.BS_SOLID) {
59              renderer.setBrushPaint(color);
60          } else if (style == EMFConstants.BS_NULL) {
61              // note: same value as BS_HOLLOW
62              // Should probably do this by making a paint implementation that does nothing,
63              // but a 100% transparent color works just as well for now.
64              renderer.setBrushPaint(new Color(0, 0, 0, 0));
65  
66              // TODO: Support pattern types
67              // TODO: Support hatching
68              // TODO: Support DIB types
69          } else {
70              Logger logger = Logger.getLogger("org.freehep.graphicsio.emf");
71              logger.warning("LogBrush32 style not supported: " + toString());
72              renderer.setBrushPaint(color);
73          }
74      }
75  }