1 |
|
2 |
package org.freehep.graphicsio.emf.gdiplus; |
3 |
|
4 |
import java.io.IOException; |
5 |
|
6 |
import org.freehep.graphicsio.emf.EMFInputStream; |
7 |
import org.freehep.graphicsio.emf.EMFOutputStream; |
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
@author |
14 |
@version |
15 |
|
16 |
public class DrawEllipse extends EMFPlusTag { |
17 |
|
18 |
private float x, y, w, h; |
19 |
|
20 |
public DrawEllipse() { |
21 |
super(15, 1); |
22 |
} |
23 |
|
24 |
public DrawEllipse(int penIndex, float x, float y, float w, float h) { |
25 |
this(); |
26 |
flags = penIndex; |
27 |
this.x = x; |
28 |
this.y = y; |
29 |
this.w = w; |
30 |
this.h = h; |
31 |
} |
32 |
|
33 |
public EMFPlusTag read(int tagID, int flags, EMFInputStream emf, int len) |
34 |
throws IOException { |
35 |
DrawEllipse tag = new DrawEllipse(); |
36 |
tag.flags = flags; |
37 |
if ((flags & 0x4000) > 0) { |
38 |
tag.x = emf.readWORD(); |
39 |
tag.y = emf.readWORD(); |
40 |
tag.w = emf.readWORD(); |
41 |
tag.h = emf.readWORD(); |
42 |
} else { |
43 |
tag.x = emf.readFLOAT(); |
44 |
tag.y = emf.readFLOAT(); |
45 |
tag.w = emf.readFLOAT(); |
46 |
tag.h = emf.readFLOAT(); |
47 |
} |
48 |
return tag; |
49 |
} |
50 |
|
51 |
public void write(int tagID, int flags, EMFOutputStream emf) throws IOException { |
52 |
|
53 |
emf.writeFLOAT(x); |
54 |
emf.writeFLOAT(y); |
55 |
emf.writeFLOAT(w); |
56 |
emf.writeFLOAT(h); |
57 |
} |
58 |
|
59 |
public String toString() { |
60 |
return super.toString() +"\n rect: ("+x+", "+y+", "+w+", "+h+")"; |
61 |
} |
62 |
} |