1:
42:
43: package ;
44:
45: import ;
46:
47: import ;
48: import ;
49: import ;
50: import ;
51:
52:
56: public class CategoryLabelPositions implements Serializable {
57:
58:
59: private static final long serialVersionUID = -8999557901920364580L;
60:
61:
62: public static final CategoryLabelPositions
63: STANDARD = new CategoryLabelPositions(
64: new CategoryLabelPosition(
65: RectangleAnchor.BOTTOM, TextBlockAnchor.BOTTOM_CENTER
66: ),
67: new CategoryLabelPosition(
68: RectangleAnchor.TOP, TextBlockAnchor.TOP_CENTER
69: ),
70: new CategoryLabelPosition(
71: RectangleAnchor.RIGHT, TextBlockAnchor.CENTER_RIGHT,
72: CategoryLabelWidthType.RANGE, 0.30f
73: ),
74: new CategoryLabelPosition(
75: RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT,
76: CategoryLabelWidthType.RANGE, 0.30f
77: )
78: );
79:
80:
81: public static final CategoryLabelPositions
82: UP_90 = new CategoryLabelPositions(
83: new CategoryLabelPosition(
84: RectangleAnchor.BOTTOM, TextBlockAnchor.CENTER_LEFT,
85: TextAnchor.CENTER_LEFT, -Math.PI / 2.0,
86: CategoryLabelWidthType.RANGE, 0.30f
87: ),
88: new CategoryLabelPosition(
89: RectangleAnchor.TOP, TextBlockAnchor.CENTER_RIGHT,
90: TextAnchor.CENTER_RIGHT, -Math.PI / 2.0,
91: CategoryLabelWidthType.RANGE, 0.30f
92: ),
93: new CategoryLabelPosition(
94: RectangleAnchor.RIGHT, TextBlockAnchor.BOTTOM_CENTER,
95: TextAnchor.BOTTOM_CENTER, -Math.PI / 2.0,
96: CategoryLabelWidthType.CATEGORY, 0.9f
97: ),
98: new CategoryLabelPosition(
99: RectangleAnchor.LEFT, TextBlockAnchor.TOP_CENTER,
100: TextAnchor.TOP_CENTER, -Math.PI / 2.0,
101: CategoryLabelWidthType.CATEGORY, 0.90f
102: )
103: );
104:
105:
106: public static final CategoryLabelPositions
107: DOWN_90 = new CategoryLabelPositions(
108: new CategoryLabelPosition(
109: RectangleAnchor.BOTTOM, TextBlockAnchor.CENTER_RIGHT,
110: TextAnchor.CENTER_RIGHT, Math.PI / 2.0,
111: CategoryLabelWidthType.RANGE, 0.30f
112: ),
113: new CategoryLabelPosition(
114: RectangleAnchor.TOP, TextBlockAnchor.CENTER_LEFT,
115: TextAnchor.CENTER_LEFT, Math.PI / 2.0,
116: CategoryLabelWidthType.RANGE, 0.30f
117: ),
118: new CategoryLabelPosition(
119: RectangleAnchor.RIGHT, TextBlockAnchor.TOP_CENTER,
120: TextAnchor.TOP_CENTER, Math.PI / 2.0,
121: CategoryLabelWidthType.CATEGORY, 0.90f
122: ),
123: new CategoryLabelPosition(
124: RectangleAnchor.LEFT, TextBlockAnchor.BOTTOM_CENTER,
125: TextAnchor.BOTTOM_CENTER, Math.PI / 2.0,
126: CategoryLabelWidthType.CATEGORY, 0.90f
127: )
128: );
129:
130:
131: public static final CategoryLabelPositions UP_45
132: = createUpRotationLabelPositions(Math.PI / 4.0);
133:
134:
135: public static final CategoryLabelPositions DOWN_45
136: = createDownRotationLabelPositions(Math.PI / 4.0);
137:
138:
146: public static CategoryLabelPositions createUpRotationLabelPositions(
147: double angle) {
148: return new CategoryLabelPositions(
149: new CategoryLabelPosition(
150: RectangleAnchor.BOTTOM, TextBlockAnchor.BOTTOM_LEFT,
151: TextAnchor.BOTTOM_LEFT, -angle,
152: CategoryLabelWidthType.RANGE, 0.50f
153: ),
154: new CategoryLabelPosition(
155: RectangleAnchor.TOP, TextBlockAnchor.TOP_RIGHT,
156: TextAnchor.TOP_RIGHT, -angle,
157: CategoryLabelWidthType.RANGE, 0.50f
158: ),
159: new CategoryLabelPosition(
160: RectangleAnchor.RIGHT, TextBlockAnchor.BOTTOM_RIGHT,
161: TextAnchor.BOTTOM_RIGHT, -angle,
162: CategoryLabelWidthType.RANGE, 0.50f
163: ),
164: new CategoryLabelPosition(
165: RectangleAnchor.LEFT, TextBlockAnchor.TOP_LEFT,
166: TextAnchor.TOP_LEFT, -angle,
167: CategoryLabelWidthType.RANGE, 0.50f
168: )
169: );
170: }
171:
172:
180: public static CategoryLabelPositions createDownRotationLabelPositions(
181: double angle) {
182: return new CategoryLabelPositions(
183: new CategoryLabelPosition(
184: RectangleAnchor.BOTTOM, TextBlockAnchor.BOTTOM_RIGHT,
185: TextAnchor.BOTTOM_RIGHT, angle,
186: CategoryLabelWidthType.RANGE, 0.50f
187: ),
188: new CategoryLabelPosition(
189: RectangleAnchor.TOP, TextBlockAnchor.TOP_LEFT,
190: TextAnchor.TOP_LEFT, angle,
191: CategoryLabelWidthType.RANGE, 0.50f
192: ),
193: new CategoryLabelPosition(
194: RectangleAnchor.RIGHT, TextBlockAnchor.TOP_RIGHT,
195: TextAnchor.TOP_RIGHT, angle,
196: CategoryLabelWidthType.RANGE, 0.50f
197: ),
198: new CategoryLabelPosition(
199: RectangleAnchor.LEFT, TextBlockAnchor.BOTTOM_LEFT,
200: TextAnchor.BOTTOM_LEFT, angle,
201: CategoryLabelWidthType.RANGE, 0.50f
202: )
203: );
204: }
205:
206:
210: private CategoryLabelPosition positionForAxisAtTop;
211:
212:
216: private CategoryLabelPosition positionForAxisAtBottom;
217:
218:
222: private CategoryLabelPosition positionForAxisAtLeft;
223:
224:
228: private CategoryLabelPosition positionForAxisAtRight;
229:
230:
233: public CategoryLabelPositions() {
234: this.positionForAxisAtTop = new CategoryLabelPosition();
235: this.positionForAxisAtBottom = new CategoryLabelPosition();
236: this.positionForAxisAtLeft = new CategoryLabelPosition();
237: this.positionForAxisAtRight = new CategoryLabelPosition();
238: }
239:
240:
252: public CategoryLabelPositions(CategoryLabelPosition top,
253: CategoryLabelPosition bottom,
254: CategoryLabelPosition left,
255: CategoryLabelPosition right) {
256:
257: if (top == null) {
258: throw new IllegalArgumentException("Null 'top' argument.");
259: }
260: if (bottom == null) {
261: throw new IllegalArgumentException("Null 'bottom' argument.");
262: }
263: if (left == null) {
264: throw new IllegalArgumentException("Null 'left' argument.");
265: }
266: if (right == null) {
267: throw new IllegalArgumentException("Null 'right' argument.");
268: }
269:
270: this.positionForAxisAtTop = top;
271: this.positionForAxisAtBottom = bottom;
272: this.positionForAxisAtLeft = left;
273: this.positionForAxisAtRight = right;
274:
275: }
276:
277:
285: public CategoryLabelPosition getLabelPosition(RectangleEdge edge) {
286: CategoryLabelPosition result = null;
287: if (edge == RectangleEdge.TOP) {
288: result = this.positionForAxisAtTop;
289: }
290: else if (edge == RectangleEdge.BOTTOM) {
291: result = this.positionForAxisAtBottom;
292: }
293: else if (edge == RectangleEdge.LEFT) {
294: result = this.positionForAxisAtLeft;
295: }
296: else if (edge == RectangleEdge.RIGHT) {
297: result = this.positionForAxisAtRight;
298: }
299: return result;
300: }
301:
302:
311: public static CategoryLabelPositions replaceTopPosition(
312: CategoryLabelPositions base, CategoryLabelPosition top) {
313:
314: if (base == null) {
315: throw new IllegalArgumentException("Null 'base' argument.");
316: }
317: if (top == null) {
318: throw new IllegalArgumentException("Null 'top' argument.");
319: }
320:
321: return new CategoryLabelPositions(
322: top,
323: base.getLabelPosition(RectangleEdge.BOTTOM),
324: base.getLabelPosition(RectangleEdge.LEFT),
325: base.getLabelPosition(RectangleEdge.RIGHT)
326: );
327: }
328:
329:
338: public static CategoryLabelPositions replaceBottomPosition(
339: CategoryLabelPositions base, CategoryLabelPosition bottom) {
340:
341: if (base == null) {
342: throw new IllegalArgumentException("Null 'base' argument.");
343: }
344: if (bottom == null) {
345: throw new IllegalArgumentException("Null 'bottom' argument.");
346: }
347:
348: return new CategoryLabelPositions(
349: base.getLabelPosition(RectangleEdge.TOP),
350: bottom,
351: base.getLabelPosition(RectangleEdge.LEFT),
352: base.getLabelPosition(RectangleEdge.RIGHT)
353: );
354: }
355:
356:
365: public static CategoryLabelPositions replaceLeftPosition(
366: CategoryLabelPositions base, CategoryLabelPosition left) {
367:
368: if (base == null) {
369: throw new IllegalArgumentException("Null 'base' argument.");
370: }
371: if (left == null) {
372: throw new IllegalArgumentException("Null 'left' argument.");
373: }
374:
375: return new CategoryLabelPositions(
376: base.getLabelPosition(RectangleEdge.TOP),
377: base.getLabelPosition(RectangleEdge.BOTTOM),
378: left,
379: base.getLabelPosition(RectangleEdge.RIGHT)
380: );
381: }
382:
383:
392: public static CategoryLabelPositions replaceRightPosition(
393: CategoryLabelPositions base, CategoryLabelPosition right) {
394:
395: if (base == null) {
396: throw new IllegalArgumentException("Null 'base' argument.");
397: }
398: if (right == null) {
399: throw new IllegalArgumentException("Null 'right' argument.");
400: }
401:
402: return new CategoryLabelPositions(
403: base.getLabelPosition(RectangleEdge.TOP),
404: base.getLabelPosition(RectangleEdge.BOTTOM),
405: base.getLabelPosition(RectangleEdge.LEFT),
406: right
407: );
408: }
409:
410:
418: public boolean equals(Object obj) {
419:
420: if (this == obj) {
421: return true;
422: }
423: if (!(obj instanceof CategoryLabelPositions)) {
424: return false;
425: }
426:
427: CategoryLabelPositions that = (CategoryLabelPositions) obj;
428: if (!this.positionForAxisAtTop.equals(that.positionForAxisAtTop)) {
429: return false;
430: }
431: if (!this.positionForAxisAtBottom.equals(
432: that.positionForAxisAtBottom)) {
433: return false;
434: }
435: if (!this.positionForAxisAtLeft.equals(that.positionForAxisAtLeft)) {
436: return false;
437: }
438: if (!this.positionForAxisAtRight.equals(that.positionForAxisAtRight)) {
439: return false;
440: }
441:
442: return true;
443:
444: }
445:
446:
451: public int hashCode() {
452: int result = 19;
453: result = 37 * result + this.positionForAxisAtTop.hashCode();
454: result = 37 * result + this.positionForAxisAtBottom.hashCode();
455: result = 37 * result + this.positionForAxisAtLeft.hashCode();
456: result = 37 * result + this.positionForAxisAtRight.hashCode();
457: return result;
458: }
459: }