Debian Codegraph @

freehep-graphicsio-cgm/src/main/java/org/freehep/graphicsio/cgm/TextAlignment.java

raw symbols SCIP
1 // Copyright 2001, FreeHEP.
2 package org.freehep.graphicsio.cgm;
3
4 import java.io.IOException;
5
6 /**
7 * TextAlignment TAG.
8 *
9 * @author Mark Donszelmann
10 * @author Charles Loomis
11 * @version $Id: freehep-graphicsio-cgm/src/main/java/org/freehep/graphicsio/cgm/TextAlignment.java 278fac7cefaa 2005/12/05 04:00:43 duns $
12 */
13 public class TextAlignment extends CGMTag {
14
15 public static final int NORMAL_HORIZONTAL = 0;
16
17 public static final int LEFT = 1;
18
19 public static final int CENTRE = 2;
20
21 public static final int RIGHT = 3;
22
23 public static final int CONTINUOUS_HORIZONTAL = 4;
24
25 public static final int NORMAL_VERTICAL = 0;
26
27 public static final int TOP = 1;
28
29 public static final int CAP = 2;
30
31 public static final int HALF = 3;
32
33 public static final int BASE = 4;
34
35 public static final int BOTTOM = 5;
36
37 public static final int CONTINUOUS_VERTICAL = 6;
38
39 private int horizontalType, verticalType;
40
41 private double horizontal, vertical;
42
43 public TextAlignment() {
44 super(5, 18, 1);
45 }
46
47 public TextAlignment(int horizontalType, int verticalType,
48 double horizontal, double vertical) {
49 this();
50 this.horizontalType = horizontalType;
51 this.verticalType = verticalType;
52 this.horizontal = horizontal;
53 this.vertical = vertical;
54 }
55
56 public void write(int tagID, CGMOutputStream cgm) throws IOException {
57 cgm.writeEnumerate(horizontalType);
58 cgm.writeEnumerate(verticalType);
59 cgm.writeReal(horizontal);
60 cgm.writeReal(vertical);
61 }
62
63 public void write(int tagID, CGMWriter cgm) throws IOException {
64 cgm.print("TEXTALIGN ");
65 switch (horizontalType) {
66 default:
67 case NORMAL_HORIZONTAL:
68 cgm.print("NORHORIZ");
69 break;
70 case LEFT:
71 cgm.print("LEFT");
72 break;
73 case CENTRE:
74 cgm.print("CTR");
75 break;
76 case RIGHT:
77 cgm.print("RIGHT");
78 break;
79 case CONTINUOUS_HORIZONTAL:
80 cgm.print("CONTHORIZ");
81 break;
82 }
83 cgm.print(", ");
84 switch (verticalType) {
85 default:
86 case NORMAL_VERTICAL:
87 cgm.print("NORMVERT");
88 break;
89 case TOP:
90 cgm.print("TOP");
91 break;
92 case CAP:
93 cgm.print("CAP");
94 break;
95 case HALF:
96 cgm.print("HALF");
97 break;
98 case BASE:
99 cgm.print("BASE");
100 break;
101 case BOTTOM:
102 cgm.print("BOTTOM");
103 break;
104 case CONTINUOUS_VERTICAL:
105 cgm.print("CONTVERT");
106 break;
107 }
108 cgm.print(", ");
109 cgm.writeReal(horizontal);
110 cgm.print(", ");
111 cgm.writeReal(vertical);
112 }
113 }