1:
55:
56: package ;
57:
58: import ;
59: import ;
60: import ;
61: import ;
62: import ;
63: import ;
64: import ;
65: import ;
66: import ;
67: import ;
68: import ;
69: import ;
70: import ;
71: import ;
72: import ;
73: import ;
74: import ;
75: import ;
76: import ;
77: import ;
78: import ;
79: import ;
80:
81: import ;
82: import ;
83: import ;
84: import ;
85: import ;
86: import ;
87: import ;
88: import ;
89: import ;
90: import ;
91: import ;
92: import ;
93: import ;
94: import ;
95:
96:
102: public class PeriodAxis extends ValueAxis
103: implements Cloneable, PublicCloneable, Serializable {
104:
105:
106: private static final long serialVersionUID = 8353295532075872069L;
107:
108:
109: private RegularTimePeriod first;
110:
111:
112: private RegularTimePeriod last;
113:
114:
118: private TimeZone timeZone;
119:
120:
123: private Calendar calendar;
124:
125:
129: private Class autoRangeTimePeriodClass;
130:
131:
135: private Class majorTickTimePeriodClass;
136:
137:
141: private boolean minorTickMarksVisible;
142:
143:
147: private Class minorTickTimePeriodClass;
148:
149:
150: private float minorTickMarkInsideLength = 0.0f;
151:
152:
153: private float minorTickMarkOutsideLength = 2.0f;
154:
155:
156: private transient Stroke minorTickMarkStroke = new BasicStroke(0.5f);
157:
158:
159: private transient Paint minorTickMarkPaint = Color.black;
160:
161:
162: private PeriodAxisLabelInfo[] labelInfo;
163:
164:
169: public PeriodAxis(String label) {
170: this(label, new Day(), new Day());
171: }
172:
173:
182: public PeriodAxis(String label,
183: RegularTimePeriod first, RegularTimePeriod last) {
184: this(label, first, last, TimeZone.getDefault());
185: }
186:
187:
197: public PeriodAxis(String label,
198: RegularTimePeriod first, RegularTimePeriod last,
199: TimeZone timeZone) {
200:
201: super(label, null);
202: this.first = first;
203: this.last = last;
204: this.timeZone = timeZone;
205: this.calendar = Calendar.getInstance(timeZone);
206: this.autoRangeTimePeriodClass = first.getClass();
207: this.majorTickTimePeriodClass = first.getClass();
208: this.minorTickMarksVisible = false;
209: this.minorTickTimePeriodClass = RegularTimePeriod.downsize(
210: this.majorTickTimePeriodClass);
211: setAutoRange(true);
212: this.labelInfo = new PeriodAxisLabelInfo[2];
213: this.labelInfo[0] = new PeriodAxisLabelInfo(Month.class,
214: new SimpleDateFormat("MMM"));
215: this.labelInfo[1] = new PeriodAxisLabelInfo(Year.class,
216: new SimpleDateFormat("yyyy"));
217:
218: }
219:
220:
225: public RegularTimePeriod getFirst() {
226: return this.first;
227: }
228:
229:
235: public void setFirst(RegularTimePeriod first) {
236: if (first == null) {
237: throw new IllegalArgumentException("Null 'first' argument.");
238: }
239: this.first = first;
240: notifyListeners(new AxisChangeEvent(this));
241: }
242:
243:
248: public RegularTimePeriod getLast() {
249: return this.last;
250: }
251:
252:
258: public void setLast(RegularTimePeriod last) {
259: if (last == null) {
260: throw new IllegalArgumentException("Null 'last' argument.");
261: }
262: this.last = last;
263: notifyListeners(new AxisChangeEvent(this));
264: }
265:
266:
272: public TimeZone getTimeZone() {
273: return this.timeZone;
274: }
275:
276:
282: public void setTimeZone(TimeZone zone) {
283: if (zone == null) {
284: throw new IllegalArgumentException("Null 'zone' argument.");
285: }
286: this.timeZone = zone;
287: this.calendar = Calendar.getInstance(zone);
288: notifyListeners(new AxisChangeEvent(this));
289: }
290:
291:
297: public Class getAutoRangeTimePeriodClass() {
298: return this.autoRangeTimePeriodClass;
299: }
300:
301:
308: public void setAutoRangeTimePeriodClass(Class c) {
309: if (c == null) {
310: throw new IllegalArgumentException("Null 'c' argument.");
311: }
312: this.autoRangeTimePeriodClass = c;
313: notifyListeners(new AxisChangeEvent(this));
314: }
315:
316:
321: public Class getMajorTickTimePeriodClass() {
322: return this.majorTickTimePeriodClass;
323: }
324:
325:
332: public void setMajorTickTimePeriodClass(Class c) {
333: if (c == null) {
334: throw new IllegalArgumentException("Null 'c' argument.");
335: }
336: this.majorTickTimePeriodClass = c;
337: notifyListeners(new AxisChangeEvent(this));
338: }
339:
340:
346: public boolean isMinorTickMarksVisible() {
347: return this.minorTickMarksVisible;
348: }
349:
350:
357: public void setMinorTickMarksVisible(boolean visible) {
358: this.minorTickMarksVisible = visible;
359: notifyListeners(new AxisChangeEvent(this));
360: }
361:
362:
367: public Class getMinorTickTimePeriodClass() {
368: return this.minorTickTimePeriodClass;
369: }
370:
371:
378: public void setMinorTickTimePeriodClass(Class c) {
379: if (c == null) {
380: throw new IllegalArgumentException("Null 'c' argument.");
381: }
382: this.minorTickTimePeriodClass = c;
383: notifyListeners(new AxisChangeEvent(this));
384: }
385:
386:
392: public Stroke getMinorTickMarkStroke() {
393: return this.minorTickMarkStroke;
394: }
395:
396:
403: public void setMinorTickMarkStroke(Stroke stroke) {
404: if (stroke == null) {
405: throw new IllegalArgumentException("Null 'stroke' argument.");
406: }
407: this.minorTickMarkStroke = stroke;
408: notifyListeners(new AxisChangeEvent(this));
409: }
410:
411:
417: public Paint getMinorTickMarkPaint() {
418: return this.minorTickMarkPaint;
419: }
420:
421:
428: public void setMinorTickMarkPaint(Paint paint) {
429: if (paint == null) {
430: throw new IllegalArgumentException("Null 'paint' argument.");
431: }
432: this.minorTickMarkPaint = paint;
433: notifyListeners(new AxisChangeEvent(this));
434: }
435:
436:
441: public float getMinorTickMarkInsideLength() {
442: return this.minorTickMarkInsideLength;
443: }
444:
445:
451: public void setMinorTickMarkInsideLength(float length) {
452: this.minorTickMarkInsideLength = length;
453: notifyListeners(new AxisChangeEvent(this));
454: }
455:
456:
461: public float getMinorTickMarkOutsideLength() {
462: return this.minorTickMarkOutsideLength;
463: }
464:
465:
471: public void setMinorTickMarkOutsideLength(float length) {
472: this.minorTickMarkOutsideLength = length;
473: notifyListeners(new AxisChangeEvent(this));
474: }
475:
476:
481: public PeriodAxisLabelInfo[] getLabelInfo() {
482: return this.labelInfo;
483: }
484:
485:
490: public void setLabelInfo(PeriodAxisLabelInfo[] info) {
491: this.labelInfo = info;
492:
493: }
494:
495:
500: public Range getRange() {
501:
502: return new Range(this.first.getFirstMillisecond(this.calendar),
503: this.last.getLastMillisecond(this.calendar));
504: }
505:
506:
517: public void setRange(Range range, boolean turnOffAutoRange,
518: boolean notify) {
519: super.setRange(range, turnOffAutoRange, false);
520: long upper = Math.round(range.getUpperBound());
521: long lower = Math.round(range.getLowerBound());
522: this.first = createInstance(this.autoRangeTimePeriodClass,
523: new Date(lower), this.timeZone);
524: this.last = createInstance(this.autoRangeTimePeriodClass,
525: new Date(upper), this.timeZone);
526: }
527:
528:
532: public void configure() {
533: if (this.isAutoRange()) {
534: autoAdjustRange();
535: }
536: }
537:
538:
551: public AxisSpace reserveSpace(Graphics2D g2, Plot plot,
552: Rectangle2D plotArea, RectangleEdge edge,
553: AxisSpace space) {
554:
555: if (space == null) {
556: space = new AxisSpace();
557: }
558:
559:
560: if (!isVisible()) {
561: return space;
562: }
563:
564:
565: double dimension = getFixedDimension();
566: if (dimension > 0.0) {
567: space.ensureAtLeast(dimension, edge);
568: }
569:
570:
571: Rectangle2D labelEnclosure = getLabelEnclosure(g2, edge);
572: double labelHeight = 0.0;
573: double labelWidth = 0.0;
574: double tickLabelBandsDimension = 0.0;
575:
576: for (int i = 0; i < this.labelInfo.length; i++) {
577: PeriodAxisLabelInfo info = this.labelInfo[i];
578: FontMetrics fm = g2.getFontMetrics(info.getLabelFont());
579: tickLabelBandsDimension
580: += info.getPadding().extendHeight(fm.getHeight());
581: }
582:
583: if (RectangleEdge.isTopOrBottom(edge)) {
584: labelHeight = labelEnclosure.getHeight();
585: space.add(labelHeight + tickLabelBandsDimension, edge);
586: }
587: else if (RectangleEdge.isLeftOrRight(edge)) {
588: labelWidth = labelEnclosure.getWidth();
589: space.add(labelWidth + tickLabelBandsDimension, edge);
590: }
591:
592:
593: double tickMarkSpace = 0.0;
594: if (isTickMarksVisible()) {
595: tickMarkSpace = getTickMarkOutsideLength();
596: }
597: if (this.minorTickMarksVisible) {
598: tickMarkSpace = Math.max(tickMarkSpace,
599: this.minorTickMarkOutsideLength);
600: }
601: space.add(tickMarkSpace, edge);
602: return space;
603: }
604:
605:
619: public AxisState draw(Graphics2D g2,
620: double cursor,
621: Rectangle2D plotArea,
622: Rectangle2D dataArea,
623: RectangleEdge edge,
624: PlotRenderingInfo plotState) {
625:
626: AxisState axisState = new AxisState(cursor);
627: if (isAxisLineVisible()) {
628: drawAxisLine(g2, cursor, dataArea, edge);
629: }
630: drawTickMarks(g2, axisState, dataArea, edge);
631: for (int band = 0; band < this.labelInfo.length; band++) {
632: axisState = drawTickLabels(band, g2, axisState, dataArea, edge);
633: }
634:
635:
636:
637: axisState = drawLabel(getLabel(), g2, plotArea, dataArea, edge,
638: axisState);
639: return axisState;
640:
641: }
642:
643:
651: protected void drawTickMarks(Graphics2D g2, AxisState state,
652: Rectangle2D dataArea,
653: RectangleEdge edge) {
654: if (RectangleEdge.isTopOrBottom(edge)) {
655: drawTickMarksHorizontal(g2, state, dataArea, edge);
656: }
657: else if (RectangleEdge.isLeftOrRight(edge)) {
658: drawTickMarksVertical(g2, state, dataArea, edge);
659: }
660: }
661:
662:
671: protected void drawTickMarksHorizontal(Graphics2D g2, AxisState state,
672: Rectangle2D dataArea,
673: RectangleEdge edge) {
674: List ticks = new ArrayList();
675: double x0 = dataArea.getX();
676: double y0 = state.getCursor();
677: double insideLength = getTickMarkInsideLength();
678: double outsideLength = getTickMarkOutsideLength();
679: RegularTimePeriod t = RegularTimePeriod.createInstance(
680: this.majorTickTimePeriodClass, this.first.getStart(),
681: getTimeZone());
682: long t0 = t.getFirstMillisecond(this.calendar);
683: Line2D inside = null;
684: Line2D outside = null;
685: long firstOnAxis = getFirst().getFirstMillisecond(this.calendar);
686: long lastOnAxis = getLast().getLastMillisecond(this.calendar);
687: while (t0 <= lastOnAxis) {
688: ticks.add(new NumberTick(new Double(t0), "", TextAnchor.CENTER,
689: TextAnchor.CENTER, 0.0));
690: x0 = valueToJava2D(t0, dataArea, edge);
691: if (edge == RectangleEdge.TOP) {
692: inside = new Line2D.Double(x0, y0, x0, y0 + insideLength);
693: outside = new Line2D.Double(x0, y0, x0, y0 - outsideLength);
694: }
695: else if (edge == RectangleEdge.BOTTOM) {
696: inside = new Line2D.Double(x0, y0, x0, y0 - insideLength);
697: outside = new Line2D.Double(x0, y0, x0, y0 + outsideLength);
698: }
699: if (t0 > firstOnAxis) {
700: g2.setPaint(getTickMarkPaint());
701: g2.setStroke(getTickMarkStroke());
702: g2.draw(inside);
703: g2.draw(outside);
704: }
705:
706: if (this.minorTickMarksVisible) {
707: RegularTimePeriod tminor = RegularTimePeriod.createInstance(
708: this.minorTickTimePeriodClass, new Date(t0),
709: getTimeZone());
710: long tt0 = tminor.getFirstMillisecond(this.calendar);
711: while (tt0 < t.getLastMillisecond(this.calendar)
712: && tt0 < lastOnAxis) {
713: double xx0 = valueToJava2D(tt0, dataArea, edge);
714: if (edge == RectangleEdge.TOP) {
715: inside = new Line2D.Double(xx0, y0, xx0,
716: y0 + this.minorTickMarkInsideLength);
717: outside = new Line2D.Double(xx0, y0, xx0,
718: y0 - this.minorTickMarkOutsideLength);
719: }
720: else if (edge == RectangleEdge.BOTTOM) {
721: inside = new Line2D.Double(xx0, y0, xx0,
722: y0 - this.minorTickMarkInsideLength);
723: outside = new Line2D.Double(xx0, y0, xx0,
724: y0 + this.minorTickMarkOutsideLength);
725: }
726: if (tt0 >= firstOnAxis) {
727: g2.setPaint(this.minorTickMarkPaint);
728: g2.setStroke(this.minorTickMarkStroke);
729: g2.draw(inside);
730: g2.draw(outside);
731: }
732: tminor = tminor.next();
733: tt0 = tminor.getFirstMillisecond(this.calendar);
734: }
735: }
736: t = t.next();
737: t0 = t.getFirstMillisecond(this.calendar);
738: }
739: if (edge == RectangleEdge.TOP) {
740: state.cursorUp(Math.max(outsideLength,
741: this.minorTickMarkOutsideLength));
742: }
743: else if (edge == RectangleEdge.BOTTOM) {
744: state.cursorDown(Math.max(outsideLength,
745: this.minorTickMarkOutsideLength));
746: }
747: state.setTicks(ticks);
748: }
749:
750:
758: protected void drawTickMarksVertical(Graphics2D g2, AxisState state,
759: Rectangle2D dataArea,
760: RectangleEdge edge) {
761:
762: }
763:
764:
775: protected AxisState drawTickLabels(int band, Graphics2D g2, AxisState state,
776: Rectangle2D dataArea,
777: RectangleEdge edge) {
778:
779:
780: double delta1 = 0.0;
781: FontMetrics fm = g2.getFontMetrics(this.labelInfo[band].getLabelFont());
782: if (edge == RectangleEdge.BOTTOM) {
783: delta1 = this.labelInfo[band].getPadding().calculateTopOutset(
784: fm.getHeight());
785: }
786: else if (edge == RectangleEdge.TOP) {
787: delta1 = this.labelInfo[band].getPadding().calculateBottomOutset(
788: fm.getHeight());
789: }
790: state.moveCursor(delta1, edge);
791: long axisMin = this.first.getFirstMillisecond(this.calendar);
792: long axisMax = this.last.getLastMillisecond(this.calendar);
793: g2.setFont(this.labelInfo[band].getLabelFont());
794: g2.setPaint(this.labelInfo[band].getLabelPaint());
795:
796:
797: RegularTimePeriod p1 = this.labelInfo[band].createInstance(
798: new Date(axisMin), this.timeZone);
799: RegularTimePeriod p2 = this.labelInfo[band].createInstance(
800: new Date(axisMax), this.timeZone);
801: String label1 = this.labelInfo[band].getDateFormat().format(
802: new Date(p1.getMiddleMillisecond(this.calendar)));
803: String label2 = this.labelInfo[band].getDateFormat().format(
804: new Date(p2.getMiddleMillisecond(this.calendar)));
805: Rectangle2D b1 = TextUtilities.getTextBounds(label1, g2,
806: g2.getFontMetrics());
807: Rectangle2D b2 = TextUtilities.getTextBounds(label2, g2,
808: g2.getFontMetrics());
809: double w = Math.max(b1.getWidth(), b2.getWidth());
810: long ww = Math.round(java2DToValue(dataArea.getX() + w + 5.0,
811: dataArea, edge)) - axisMin;
812: long length = p1.getLastMillisecond(this.calendar)
813: - p1.getFirstMillisecond(this.calendar);
814: int periods = (int) (ww / length) + 1;
815:
816: RegularTimePeriod p = this.labelInfo[band].createInstance(
817: new Date(axisMin), this.timeZone);
818: Rectangle2D b = null;
819: long lastXX = 0L;
820: float y = (float) (state.getCursor());
821: TextAnchor anchor = TextAnchor.TOP_CENTER;
822: float yDelta = (float) b1.getHeight();
823: if (edge == RectangleEdge.TOP) {
824: anchor = TextAnchor.BOTTOM_CENTER;
825: yDelta = -yDelta;
826: }
827: while (p.getFirstMillisecond(this.calendar) <= axisMax) {
828: float x = (float) valueToJava2D(p.getMiddleMillisecond(
829: this.calendar), dataArea, edge);
830: DateFormat df = this.labelInfo[band].getDateFormat();
831: String label = df.format(new Date(p.getMiddleMillisecond(
832: this.calendar)));
833: long first = p.getFirstMillisecond(this.calendar);
834: long last = p.getLastMillisecond(this.calendar);
835: if (last > axisMax) {
836:
837:
838: Rectangle2D bb = TextUtilities.getTextBounds(label, g2,
839: g2.getFontMetrics());
840: if ((x + bb.getWidth() / 2) > dataArea.getMaxX()) {
841: float xstart = (float) valueToJava2D(Math.max(first,
842: axisMin), dataArea, edge);
843: if (bb.getWidth() < (dataArea.getMaxX() - xstart)) {
844: x = ((float) dataArea.getMaxX() + xstart) / 2.0f;
845: }
846: else {
847: label = null;
848: }
849: }
850: }
851: if (first < axisMin) {
852:
853:
854: Rectangle2D bb = TextUtilities.getTextBounds(label, g2,
855: g2.getFontMetrics());
856: if ((x - bb.getWidth() / 2) < dataArea.getX()) {
857: float xlast = (float) valueToJava2D(Math.min(last,
858: axisMax), dataArea, edge);
859: if (bb.getWidth() < (xlast - dataArea.getX())) {
860: x = (xlast + (float) dataArea.getX()) / 2.0f;
861: }
862: else {
863: label = null;
864: }
865: }
866:
867: }
868: if (label != null) {
869: g2.setPaint(this.labelInfo[band].getLabelPaint());
870: b = TextUtilities.drawAlignedString(label, g2, x, y, anchor);
871: }
872: if (lastXX > 0L) {
873: if (this.labelInfo[band].getDrawDividers()) {
874: long nextXX = p.getFirstMillisecond(this.calendar);
875: long mid = (lastXX + nextXX) / 2;
876: float mid2d = (float) valueToJava2D(mid, dataArea, edge);
877: g2.setStroke(this.labelInfo[band].getDividerStroke());
878: g2.setPaint(this.labelInfo[band].getDividerPaint());
879: g2.draw(new Line2D.Float(mid2d, y, mid2d, y + yDelta));
880: }
881: }
882: lastXX = last;
883: for (int i = 0; i < periods; i++) {
884: p = p.next();
885: }
886: }
887: double used = 0.0;
888: if (b != null) {
889: used = b.getHeight();
890:
891: if (edge == RectangleEdge.BOTTOM) {
892: used += this.labelInfo[band].getPadding().calculateBottomOutset(
893: fm.getHeight());
894: }
895: else if (edge == RectangleEdge.TOP) {
896: used += this.labelInfo[band].getPadding().calculateTopOutset(
897: fm.getHeight());
898: }
899: }
900: state.moveCursor(used, edge);
901: return state;
902: }
903:
904:
915: public List refreshTicks(Graphics2D g2,
916: AxisState state,
917: Rectangle2D dataArea,
918: RectangleEdge edge) {
919: return Collections.EMPTY_LIST;
920: }
921:
922:
934: public double valueToJava2D(double value,
935: Rectangle2D area,
936: RectangleEdge edge) {
937:
938: double result = Double.NaN;
939: double axisMin = this.first.getFirstMillisecond(this.calendar);
940: double axisMax = this.last.getLastMillisecond(this.calendar);
941: if (RectangleEdge.isTopOrBottom(edge)) {
942: double minX = area.getX();
943: double maxX = area.getMaxX();
944: if (isInverted()) {
945: result = maxX + ((value - axisMin) / (axisMax - axisMin))
946: * (minX - maxX);
947: }
948: else {
949: result = minX + ((value - axisMin) / (axisMax - axisMin))
950: * (maxX - minX);
951: }
952: }
953: else if (RectangleEdge.isLeftOrRight(edge)) {
954: double minY = area.getMinY();
955: double maxY = area.getMaxY();
956: if (isInverted()) {
957: result = minY + (((value - axisMin) / (axisMax - axisMin))
958: * (maxY - minY));
959: }
960: else {
961: result = maxY - (((value - axisMin) / (axisMax - axisMin))
962: * (maxY - minY));
963: }
964: }
965: return result;
966:
967: }
968:
969:
979: public double java2DToValue(double java2DValue,
980: Rectangle2D area,
981: RectangleEdge edge) {
982:
983: double result = Double.NaN;
984: double min = 0.0;
985: double max = 0.0;
986: double axisMin = this.first.getFirstMillisecond(this.calendar);
987: double axisMax = this.last.getLastMillisecond(this.calendar);
988: if (RectangleEdge.isTopOrBottom(edge)) {
989: min = area.getX();
990: max = area.getMaxX();
991: }
992: else if (RectangleEdge.isLeftOrRight(edge)) {
993: min = area.getMaxY();
994: max = area.getY();
995: }
996: if (isInverted()) {
997: result = axisMax - ((java2DValue - min) / (max - min)
998: * (axisMax - axisMin));
999: }
1000: else {
1001: result = axisMin + ((java2DValue - min) / (max - min)
1002: * (axisMax - axisMin));
1003: }
1004: return result;
1005: }
1006:
1007:
1010: protected void autoAdjustRange() {
1011:
1012: Plot plot = getPlot();
1013: if (plot == null) {
1014: return;
1015: }
1016:
1017: if (plot instanceof ValueAxisPlot) {
1018: ValueAxisPlot vap = (ValueAxisPlot) plot;
1019:
1020: Range r = vap.getDataRange(this);
1021: if (r == null) {
1022: r = getDefaultAutoRange();
1023: }
1024:
1025: long upper = Math.round(r.getUpperBound());
1026: long lower = Math.round(r.getLowerBound());
1027: this.first = createInstance(this.autoRangeTimePeriodClass,
1028: new Date(lower), this.timeZone);
1029: this.last = createInstance(this.autoRangeTimePeriodClass,
1030: new Date(upper), this.timeZone);
1031: setRange(r, false, false);
1032: }
1033:
1034: }
1035:
1036:
1043: public boolean equals(Object obj) {
1044: if (obj == this) {
1045: return true;
1046: }
1047: if (obj instanceof PeriodAxis && super.equals(obj)) {
1048: PeriodAxis that = (PeriodAxis) obj;
1049: if (!this.first.equals(that.first)) {
1050: return false;
1051: }
1052: if (!this.last.equals(that.last)) {
1053: return false;
1054: }
1055: if (!this.timeZone.equals(that.timeZone)) {
1056: return false;
1057: }
1058: if (!this.autoRangeTimePeriodClass.equals(
1059: that.autoRangeTimePeriodClass)) {
1060: return false;
1061: }
1062: if (!(isMinorTickMarksVisible()
1063: == that.isMinorTickMarksVisible())) {
1064: return false;
1065: }
1066: if (!this.majorTickTimePeriodClass.equals(
1067: that.majorTickTimePeriodClass)) {
1068: return false;
1069: }
1070: if (!this.minorTickTimePeriodClass.equals(
1071: that.minorTickTimePeriodClass)) {
1072: return false;
1073: }
1074: if (!this.minorTickMarkPaint.equals(that.minorTickMarkPaint)) {
1075: return false;
1076: }
1077: if (!this.minorTickMarkStroke.equals(that.minorTickMarkStroke)) {
1078: return false;
1079: }
1080: if (!Arrays.equals(this.labelInfo, that.labelInfo)) {
1081: return false;
1082: }
1083: return true;
1084: }
1085: return false;
1086: }
1087:
1088:
1093: public int hashCode() {
1094: if (getLabel() != null) {
1095: return getLabel().hashCode();
1096: }
1097: else {
1098: return 0;
1099: }
1100: }
1101:
1102:
1110: public Object clone() throws CloneNotSupportedException {
1111: PeriodAxis clone = (PeriodAxis) super.clone();
1112: clone.timeZone = (TimeZone) this.timeZone.clone();
1113: clone.labelInfo = new PeriodAxisLabelInfo[this.labelInfo.length];
1114: for (int i = 0; i < this.labelInfo.length; i++) {
1115: clone.labelInfo[i] = this.labelInfo[i];
1116:
1117: }
1118: return clone;
1119: }
1120:
1121:
1132: private RegularTimePeriod createInstance(Class periodClass,
1133: Date millisecond, TimeZone zone) {
1134: RegularTimePeriod result = null;
1135: try {
1136: Constructor c = periodClass.getDeclaredConstructor(new Class[] {
1137: Date.class, TimeZone.class});
1138: result = (RegularTimePeriod) c.newInstance(new Object[] {
1139: millisecond, zone});
1140: }
1141: catch (Exception e) {
1142:
1143: }
1144: return result;
1145: }
1146:
1147:
1154: private void writeObject(ObjectOutputStream stream) throws IOException {
1155: stream.defaultWriteObject();
1156: SerialUtilities.writeStroke(this.minorTickMarkStroke, stream);
1157: SerialUtilities.writePaint(this.minorTickMarkPaint, stream);
1158: }
1159:
1160:
1168: private void readObject(ObjectInputStream stream)
1169: throws IOException, ClassNotFoundException {
1170: stream.defaultReadObject();
1171: this.minorTickMarkStroke = SerialUtilities.readStroke(stream);
1172: this.minorTickMarkPaint = SerialUtilities.readPaint(stream);
1173: }
1174:
1175: }