| 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 | 80899 | private float stretchAscent = -1.0f; |
| 56 | |
|
| 57 | 80899 | private float stretchDescent = -1.0f; |
| 58 | |
|
| 59 | 80899 | private float stretchWidth = -1.0f; |
| 60 | |
|
| 61 | |
private final List<GraphicsObject> graphicObjects; |
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | 80899 | public LayoutInfoImpl() { |
| 67 | 80899 | this.layoutStage = LayoutStage.NONE; |
| 68 | 80899 | this.graphicObjects = new ArrayList<GraphicsObject>(); |
| 69 | 80899 | } |
| 70 | |
|
| 71 | |
|
| 72 | |
public LayoutStage getLayoutStage() { |
| 73 | 352285 | return this.layoutStage; |
| 74 | |
} |
| 75 | |
|
| 76 | |
|
| 77 | |
public void setLayoutStage(final LayoutStage newStage) { |
| 78 | 120239 | this.layoutStage = newStage; |
| 79 | 120239 | } |
| 80 | |
|
| 81 | |
|
| 82 | |
public float getAscentHeight(final LayoutStage stage) { |
| 83 | 158450 | if (LayoutStage.STAGE1.equals(stage)) { |
| 84 | 99709 | return this.ascentHeightS1; |
| 85 | |
} else { |
| 86 | 58741 | return this.ascentHeightS2; |
| 87 | |
} |
| 88 | |
} |
| 89 | |
|
| 90 | |
|
| 91 | |
public float getDescentHeight(final LayoutStage stage) { |
| 92 | 156569 | if (LayoutStage.STAGE1.equals(stage)) { |
| 93 | 100963 | return this.descentHeightS1; |
| 94 | |
} else { |
| 95 | 55606 | return this.descentHeightS2; |
| 96 | |
} |
| 97 | |
} |
| 98 | |
|
| 99 | |
|
| 100 | |
public float getHorizontalCenterOffset(final LayoutStage stage) { |
| 101 | 30932 | if (LayoutStage.STAGE1.equals(stage)) { |
| 102 | 19437 | return this.horizontalS1; |
| 103 | |
} else { |
| 104 | 11495 | return this.horizontalS2; |
| 105 | |
} |
| 106 | |
} |
| 107 | |
|
| 108 | |
|
| 109 | |
public float getPosX(final LayoutStage stage) { |
| 110 | 105963 | if (LayoutStage.STAGE1.equals(stage)) { |
| 111 | 22154 | return this.posXS1; |
| 112 | |
} else { |
| 113 | 83809 | return this.posXS2; |
| 114 | |
} |
| 115 | |
} |
| 116 | |
|
| 117 | |
|
| 118 | |
public float getPosY(final LayoutStage stage) { |
| 119 | 146091 | if (LayoutStage.STAGE1.equals(stage)) { |
| 120 | 49324 | return this.posYS1; |
| 121 | |
} else { |
| 122 | 96767 | return this.posYS2; |
| 123 | |
} |
| 124 | |
} |
| 125 | |
|
| 126 | |
|
| 127 | |
public float getWidth(final LayoutStage stage) { |
| 128 | 158659 | if (LayoutStage.STAGE1.equals(stage)) { |
| 129 | 98037 | return this.widthS1; |
| 130 | |
} else { |
| 131 | 60622 | return this.widthS2; |
| 132 | |
} |
| 133 | |
} |
| 134 | |
|
| 135 | |
|
| 136 | |
public void moveTo(final float x, final float y, final LayoutStage stage) { |
| 137 | 122072 | this.posXS2 = x; |
| 138 | 122072 | this.posYS2 = y; |
| 139 | 122072 | if (LayoutStage.STAGE1.equals(stage)) { |
| 140 | 79436 | this.posXS1 = x; |
| 141 | 79436 | this.posYS1 = y; |
| 142 | |
} |
| 143 | |
|
| 144 | 122072 | } |
| 145 | |
|
| 146 | |
|
| 147 | |
public void setAscentHeight(final float ascentHeight, |
| 148 | |
final LayoutStage stage) { |
| 149 | 111007 | this.ascentHeightS2 = ascentHeight; |
| 150 | 111007 | if (LayoutStage.STAGE1.equals(stage)) { |
| 151 | 81747 | this.ascentHeightS1 = ascentHeight; |
| 152 | |
} |
| 153 | 111007 | } |
| 154 | |
|
| 155 | |
|
| 156 | |
public void setDescentHeight(final float descentHeight, |
| 157 | |
final LayoutStage stage) { |
| 158 | 111007 | this.descentHeightS2 = descentHeight; |
| 159 | 111007 | if (LayoutStage.STAGE1.equals(stage)) { |
| 160 | 81747 | this.descentHeightS1 = descentHeight; |
| 161 | |
} |
| 162 | 111007 | } |
| 163 | |
|
| 164 | |
|
| 165 | |
public void setHorizontalCenterOffset(final float newOffset, |
| 166 | |
final LayoutStage stage) { |
| 167 | 104528 | this.horizontalS2 = newOffset; |
| 168 | 104528 | if (LayoutStage.STAGE1.equals(stage)) { |
| 169 | 81747 | this.horizontalS1 = newOffset; |
| 170 | |
} |
| 171 | 104528 | } |
| 172 | |
|
| 173 | |
|
| 174 | |
public void setWidth(final float width, final LayoutStage stage) { |
| 175 | 108081 | this.widthS2 = width; |
| 176 | 108081 | if (LayoutStage.STAGE1.equals(stage)) { |
| 177 | 84464 | this.widthS1 = width; |
| 178 | |
} |
| 179 | 108081 | } |
| 180 | |
|
| 181 | |
|
| 182 | |
public void setGraphicsObject(final GraphicsObject graphicsObject) { |
| 183 | 43480 | this.graphicObjects.clear(); |
| 184 | 43480 | this.graphicObjects.add(graphicsObject); |
| 185 | 43480 | } |
| 186 | |
|
| 187 | |
|
| 188 | |
public List<GraphicsObject> getGraphicObjects() { |
| 189 | 75031 | return this.graphicObjects; |
| 190 | |
} |
| 191 | |
|
| 192 | |
|
| 193 | |
public float getStretchWidth() { |
| 194 | 1672 | return this.stretchWidth; |
| 195 | |
} |
| 196 | |
|
| 197 | |
|
| 198 | |
public void setStretchWidth(final float newStretchWidth) { |
| 199 | 14212 | this.stretchWidth = newStretchWidth; |
| 200 | 14212 | } |
| 201 | |
|
| 202 | |
|
| 203 | |
public float getStretchAscent() { |
| 204 | 96992 | if (this.stretchAscent < 0.0f) { |
| 205 | 36165 | return this.ascentHeightS1; |
| 206 | |
} else { |
| 207 | 60827 | return this.stretchAscent; |
| 208 | |
} |
| 209 | |
} |
| 210 | |
|
| 211 | |
|
| 212 | |
public float getStretchDescent() { |
| 213 | 96992 | if (this.stretchDescent < 0.0f) { |
| 214 | 36165 | return this.descentHeightS1; |
| 215 | |
} else { |
| 216 | 60827 | return this.stretchDescent; |
| 217 | |
} |
| 218 | |
} |
| 219 | |
|
| 220 | |
|
| 221 | |
public void setStretchAscent(final float newStretchAscent) { |
| 222 | 73588 | this.stretchAscent = newStretchAscent; |
| 223 | |
|
| 224 | 73588 | } |
| 225 | |
|
| 226 | |
|
| 227 | |
public void setStretchDescent(final float newStretchDescent) { |
| 228 | 73588 | this.stretchDescent = newStretchDescent; |
| 229 | 73588 | } |
| 230 | |
|
| 231 | |
|
| 232 | |
public void shiftVertically(final float offsetY, final LayoutStage stage) { |
| 233 | 9823 | this.posYS2 += offsetY; |
| 234 | 9823 | if (LayoutStage.STAGE1.equals(stage)) { |
| 235 | 7733 | this.posYS1 += offsetY; |
| 236 | |
} |
| 237 | 9823 | } |
| 238 | |
} |