1
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.EMFRenderer;
10
11
12
13
14
15
16
17 public class ExtLogPen extends AbstractPen {
18
19 private int penStyle;
20
21 private int width;
22
23 private int brushStyle;
24
25 private Color color;
26
27 private int hatch;
28
29 private int[] style;
30
31 public ExtLogPen(
32 int penStyle,
33 int width,
34 int brushStyle,
35 Color color,
36 int hatch,
37 int[] style) {
38
39 this.penStyle = penStyle;
40 this.width = width;
41 this.brushStyle = brushStyle;
42 this.color = color;
43 this.hatch = hatch;
44 this.style = style;
45 }
46
47 public ExtLogPen(EMFInputStream emf) throws IOException {
48 penStyle = emf.readDWORD();
49 width = emf.readDWORD();
50 brushStyle = emf.readUINT();
51 color = emf.readCOLORREF();
52 hatch = emf.readULONG();
53 int nStyle = emf.readDWORD();
54
55 if (nStyle == 0)
56 emf.readDWORD();
57 style = emf.readDWORD(nStyle);
58 }
59
60 public void write(EMFOutputStream emf) throws IOException {
61 emf.writeDWORD(penStyle);
62 emf.writeDWORD(width);
63 emf.writeUINT(brushStyle);
64 emf.writeCOLORREF(color);
65 emf.writeULONG(hatch);
66 emf.writeDWORD(style.length);
67
68 if (style.length == 0)
69 emf.writeDWORD(0);
70 emf.writeDWORD(style);
71 }
72
73 public String toString() {
74 StringBuffer s = new StringBuffer();
75 s.append(" ExtLogPen\n");
76 s.append(" penStyle: ");
77 s.append(Integer.toHexString(penStyle));
78 s.append("\n");
79 s.append(" width: ");
80 s.append(width);
81 s.append("\n");
82 s.append(" brushStyle: ");
83 s.append(brushStyle);
84 s.append("\n");
85 s.append(" color: ");
86 s.append(color);
87 s.append("\n");
88 s.append(" hatch: ");
89 s.append(hatch);
90 s.append("\n");
91 for (int i = 0; i < style.length; i++) {
92 s.append(" style[");
93 s.append(i);
94 s.append("]: ");
95 s.append(style[i]);
96 s.append("\n");
97 }
98 return s.toString();
99 }
100
101
102
103
104
105
106 public void render(EMFRenderer renderer) {
107 renderer.setUseCreatePen(false);
108 renderer.setPenPaint(color);
109 renderer.setPenStroke(
110 createStroke(renderer, penStyle, style, width));
111 }
112 }