1 |
|
2 |
package org.freehep.graphicsio.emf.gdiplus; |
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 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
@author |
15 |
@version |
16 |
|
17 |
public class FillEllipse extends EMFPlusTag { |
18 |
|
19 |
private int brushIndex; |
20 |
private Color brushColor; |
21 |
private float x, y, w, h; |
22 |
|
23 |
public FillEllipse() { |
24 |
super(14, 1); |
25 |
} |
26 |
|
27 |
public FillEllipse(int penIndex, int brushIndex, float x, float y, float w, float h) { |
28 |
this(); |
29 |
flags = penIndex; |
30 |
this.brushIndex = brushIndex; |
31 |
this.x = x; |
32 |
this.y = y; |
33 |
this.w = w; |
34 |
this.h = h; |
35 |
} |
36 |
|
37 |
public EMFPlusTag read(int tagID, int flags, EMFInputStream emf, int len) |
38 |
throws IOException { |
39 |
FillEllipse tag = new FillEllipse(); |
40 |
tag.flags = flags; |
41 |
if ((flags & 0x8000) > 0) { |
42 |
tag.brushColor = emf.readCOLOR(); |
43 |
} else { |
44 |
tag.brushIndex = emf.readUINT(); |
45 |
} |
46 |
if ((flags & 0x4000) > 0) { |
47 |
tag.x = emf.readWORD(); |
48 |
tag.y = emf.readWORD(); |
49 |
tag.w = emf.readWORD(); |
50 |
tag.h = emf.readWORD(); |
51 |
} else { |
52 |
tag.x = emf.readFLOAT(); |
53 |
tag.y = emf.readFLOAT(); |
54 |
tag.w = emf.readFLOAT(); |
55 |
tag.h = emf.readFLOAT(); |
56 |
} |
57 |
return tag; |
58 |
} |
59 |
|
60 |
public void write(int tagID, int flags, EMFOutputStream emf) throws IOException { |
61 |
|
62 |
emf.writeUINT(brushIndex); |
63 |
emf.writeFLOAT(x); |
64 |
emf.writeFLOAT(y); |
65 |
emf.writeFLOAT(w); |
66 |
emf.writeFLOAT(h); |
67 |
} |
68 |
|
69 |
public String toString() { |
70 |
StringBuffer sb = new StringBuffer(super.toString()); |
71 |
sb.append("\n rect: ("+x+", "+y+", "+w+", "+h+")"); |
72 |
sb.append("\n "); |
73 |
sb.append(brushColor != null ? "brushColor: "+brushColor : "brushIndex: "+brushIndex); |
74 |
return sb.toString(); |
75 |
} |
76 |
} |