1
2 package org.freehep.graphicsio.emf.gdi;
3
4 import org.freehep.graphicsio.emf.EMFConstants;
5 import org.freehep.graphicsio.emf.EMFTag;
6 import org.freehep.graphicsio.emf.EMFRenderer;
7 import org.freehep.graphicsio.emf.EMFOutputStream;
8
9 import java.awt.Rectangle;
10 import java.io.IOException;
11
12
13
14
15
16
17
18 public abstract class AbstractExtTextOut extends EMFTag implements EMFConstants {
19
20 private Rectangle bounds;
21
22 private int mode;
23
24 private float xScale, yScale;
25
26
27
28
29
30
31
32
33
34
35
36 protected AbstractExtTextOut(
37 int id,
38 int version,
39 Rectangle bounds,
40 int mode,
41 float xScale,
42 float yScale) {
43
44 super(id, version);
45 this.bounds = bounds;
46 this.mode = mode;
47 this.xScale = xScale;
48 this.yScale = yScale;
49 }
50
51 public abstract Text getText();
52
53 public String toString() {
54 return super.toString() +
55 "\n bounds: " + bounds +
56 "\n mode: " + mode +
57 "\n xScale: " + xScale +
58 "\n yScale: " + yScale +
59 "\n" + getText().toString();
60 }
61
62 public void write(int tagID, EMFOutputStream emf) throws IOException {
63 emf.writeRECTL(bounds);
64 emf.writeDWORD(mode);
65 emf.writeFLOAT(xScale);
66 emf.writeFLOAT(yScale);
67 getText().write(emf);
68 }
69
70
71
72
73
74
75 public void render(EMFRenderer renderer) {
76 Text text = getText();
77 renderer.drawOrAppendText(
78 text.getString(),
79 text.getPos().getX(),
80 text.getPos().getY());
81 }
82 }