source: ether_statistics/service/implementation/gov/noaa/pmel/sgt/DayMonthAxis.java @ 569

Last change on this file since 569 was 569, checked in by vmipsl, 12 years ago

Nouveau projet

File size: 3.6 KB
Line 
1/*
2 * $Id: DayMonthAxis.java,v 1.5 2000/12/19 01:00:38 dwd Exp $
3 *
4 * This software is provided by NOAA for full, free and open release.  It is
5 * understood by the recipient/user that NOAA assumes no liability for any
6 * errors contained in the code.  Although this software is released without
7 * conditions or restrictions in its use, it is expected that appropriate
8 * credit be given to its author and to the National Oceanic and Atmospheric
9 * Administration should the software be included by the recipient as an
10 * element in other product development.
11 */
12
13package  gov.noaa.pmel.sgt;
14
15import gov.noaa.pmel.util.GeoDate;
16import gov.noaa.pmel.util.IllegalTimeValue;
17import gov.noaa.pmel.util.TimeRange;
18
19/**
20 * Draws time axes using the day/month style.
21 *
22 * <pre>
23 *        |...........|...........|...........|...........|
24 *             3           4           5           6
25 *                             jun 93
26 * </pre>
27 *
28 * @author Donald Denbo
29 * @version $Revision: 1.5 $, $Date: 2000/12/19 01:00:38 $
30 * @see Axis
31 * @see TimeAxis
32 */
33class DayMonthAxis implements TimeAxisStyle {
34  static final int MONTH_TEST__ = 3;
35  static final String defaultMinorLabelFormat__ = "dd";
36  static final String defaultMajorLabelFormat__ = "yyyy-MM";
37  static final int defaultNumSmallTics__ = 0;
38  int defaultMinorLabelInterval_ = 2;
39  int defaultMajorLabelInterval_ = 1;
40  static final double incrementValue__ = 1.0;
41  static final int incrementUnits__ = GeoDate.DAYS;
42  /**
43   * DayMonthAxis constructor.
44   */
45  public DayMonthAxis() {
46  }
47  public double computeLocation(double prev,double now) {
48    return (prev + now)*0.5;
49  }
50  public void computeDefaults(GeoDate delta) {
51    long days = delta.getTime()/GeoDate.MSECS_IN_DAY;
52    if(days > 30) {
53      defaultMinorLabelInterval_ = 5;
54    } else if(days > 10) {
55      defaultMinorLabelInterval_ = 2;
56    } else {
57      defaultMinorLabelInterval_ = 1;
58    }
59  }
60  public int getMinorValue(GeoDate time) {
61    return time.getGMTDay();
62  }
63  public int getMajorValue(GeoDate time) {
64    return time.getGMTMonth();
65  }
66  public boolean isRoomForMajorLabel(GeoDate delta) {
67    return delta.getTime()/GeoDate.MSECS_IN_DAY > MONTH_TEST__;
68  }
69  public boolean isStartOfMinor(GeoDate time) {
70    return time.getGMTDay() == 1;
71  }
72  public String getDefaultMinorLabelFormat() {
73    return defaultMinorLabelFormat__;
74  }
75  public String getDefaultMajorLabelFormat() {
76    return defaultMajorLabelFormat__;
77  }
78  public int getDefaultNumSmallTics() {
79    return defaultNumSmallTics__;
80  }
81  public int getDefaultMinorLabelInterval() {
82    return defaultMinorLabelInterval_;
83  }
84  public int getDefaultMajorLabelInterval() {
85    return defaultMajorLabelInterval_;
86  }
87  public GeoDate getStartTime(TimeRange tRange) {
88    boolean time_increasing;
89    GeoDate time = null;
90    time_increasing = tRange.end.after(tRange.start);
91    try {
92      if(time_increasing) {
93        time = new GeoDate(tRange.start.getGMTMonth(),
94         tRange.start.getGMTDay(),
95                           tRange.start.getGMTYear(), 0, 0, 0, 0);
96        if(!time.equals(tRange.start)) time.increment(1.0, GeoDate.DAYS);
97      } else {
98        time = new GeoDate(tRange.end.getGMTMonth(),
99         tRange.end.getGMTDay(),
100                           tRange.end.getGMTYear(), 0, 0, 0, 0);
101        if(!time.equals(tRange.end)) time.increment(1.0, GeoDate.DAYS);
102      }
103    } catch (IllegalTimeValue e) {}
104    return time;
105  }
106  public double getIncrementValue() {
107    return incrementValue__;
108  }
109  public int getIncrementUnits() {
110    return incrementUnits__;
111  }
112  public String toString() {
113    return "DayMonthAxis";
114  }
115}
Note: See TracBrowser for help on using the repository browser.