1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package net.sourceforge.jeuclid.layout;
20
21 import java.util.ArrayList;
22 import java.util.List;
23
24
25
26
27 public class LayoutInfoImpl implements LayoutInfo {
28
29 private LayoutStage layoutStage;
30
31 private float ascentHeightS1;
32
33 private float ascentHeightS2;
34
35 private float descentHeightS1;
36
37 private float descentHeightS2;
38
39 private float horizontalS1;
40
41 private float horizontalS2;
42
43 private float widthS1;
44
45 private float widthS2;
46
47 private float posXS1;
48
49 private float posXS2;
50
51 private float posYS1;
52
53 private float posYS2;
54
55 private float stretchAscent = -1.0f;
56
57 private float stretchDescent = -1.0f;
58
59 private float stretchWidth = -1.0f;
60
61 private final List<GraphicsObject> graphicObjects;
62
63
64
65
66 public LayoutInfoImpl() {
67 this.layoutStage = LayoutStage.NONE;
68 this.graphicObjects = new ArrayList<GraphicsObject>();
69 }
70
71
72 public LayoutStage getLayoutStage() {
73 return this.layoutStage;
74 }
75
76
77 public void setLayoutStage(final LayoutStage newStage) {
78 this.layoutStage = newStage;
79 }
80
81
82 public float getAscentHeight(final LayoutStage stage) {
83 if (LayoutStage.STAGE1.equals(stage)) {
84 return this.ascentHeightS1;
85 } else {
86 return this.ascentHeightS2;
87 }
88 }
89
90
91 public float getDescentHeight(final LayoutStage stage) {
92 if (LayoutStage.STAGE1.equals(stage)) {
93 return this.descentHeightS1;
94 } else {
95 return this.descentHeightS2;
96 }
97 }
98
99
100 public float getHorizontalCenterOffset(final LayoutStage stage) {
101 if (LayoutStage.STAGE1.equals(stage)) {
102 return this.horizontalS1;
103 } else {
104 return this.horizontalS2;
105 }
106 }
107
108
109 public float getPosX(final LayoutStage stage) {
110 if (LayoutStage.STAGE1.equals(stage)) {
111 return this.posXS1;
112 } else {
113 return this.posXS2;
114 }
115 }
116
117
118 public float getPosY(final LayoutStage stage) {
119 if (LayoutStage.STAGE1.equals(stage)) {
120 return this.posYS1;
121 } else {
122 return this.posYS2;
123 }
124 }
125
126
127 public float getWidth(final LayoutStage stage) {
128 if (LayoutStage.STAGE1.equals(stage)) {
129 return this.widthS1;
130 } else {
131 return this.widthS2;
132 }
133 }
134
135
136 public void moveTo(final float x, final float y, final LayoutStage stage) {
137 this.posXS2 = x;
138 this.posYS2 = y;
139 if (LayoutStage.STAGE1.equals(stage)) {
140 this.posXS1 = x;
141 this.posYS1 = y;
142 }
143
144 }
145
146
147 public void setAscentHeight(final float ascentHeight,
148 final LayoutStage stage) {
149 this.ascentHeightS2 = ascentHeight;
150 if (LayoutStage.STAGE1.equals(stage)) {
151 this.ascentHeightS1 = ascentHeight;
152 }
153 }
154
155
156 public void setDescentHeight(final float descentHeight,
157 final LayoutStage stage) {
158 this.descentHeightS2 = descentHeight;
159 if (LayoutStage.STAGE1.equals(stage)) {
160 this.descentHeightS1 = descentHeight;
161 }
162 }
163
164
165 public void setHorizontalCenterOffset(final float newOffset,
166 final LayoutStage stage) {
167 this.horizontalS2 = newOffset;
168 if (LayoutStage.STAGE1.equals(stage)) {
169 this.horizontalS1 = newOffset;
170 }
171 }
172
173
174 public void setWidth(final float width, final LayoutStage stage) {
175 this.widthS2 = width;
176 if (LayoutStage.STAGE1.equals(stage)) {
177 this.widthS1 = width;
178 }
179 }
180
181
182 public void setGraphicsObject(final GraphicsObject graphicsObject) {
183 this.graphicObjects.clear();
184 this.graphicObjects.add(graphicsObject);
185 }
186
187
188 public List<GraphicsObject> getGraphicObjects() {
189 return this.graphicObjects;
190 }
191
192
193 public float getStretchWidth() {
194 return this.stretchWidth;
195 }
196
197
198 public void setStretchWidth(final float newStretchWidth) {
199 this.stretchWidth = newStretchWidth;
200 }
201
202
203 public float getStretchAscent() {
204 if (this.stretchAscent < 0.0f) {
205 return this.ascentHeightS1;
206 } else {
207 return this.stretchAscent;
208 }
209 }
210
211
212 public float getStretchDescent() {
213 if (this.stretchDescent < 0.0f) {
214 return this.descentHeightS1;
215 } else {
216 return this.stretchDescent;
217 }
218 }
219
220
221 public void setStretchAscent(final float newStretchAscent) {
222 this.stretchAscent = newStretchAscent;
223
224 }
225
226
227 public void setStretchDescent(final float newStretchDescent) {
228 this.stretchDescent = newStretchDescent;
229 }
230
231
232 public void shiftVertically(final float offsetY, final LayoutStage stage) {
233 this.posYS2 += offsetY;
234 if (LayoutStage.STAGE1.equals(stage)) {
235 this.posYS1 += offsetY;
236 }
237 }
238 }