Example #1
0
  public static void main(String[] args) {
    try {
      // define time domain "once every fourth year"
      TimeDomainDefinition year4def =
          new TimeDomainDefinition(
              "year4", Resolution.YEAR, 0L, new Cycle(true, false, false, false));
      TimeDomain year4 = TimeDomainManager.getFactory().get(year4def, true);

      // define "missing value" for String (else, the default is null)
      String missingValue = "(missing)";
      TimeSeriesFactory.getInstance().define(String.class, missingValue);

      TimeAddressable<String> olympics = TimeSeriesFactory.make(year4, String.class);
      olympics.put(
          year4.time("1896"),
          new String[] {"Athens", "Paris", "Saint-Louis", "London", "Stockholm"});
      olympics.put(
          year4.time("1920"),
          new String[] {"Antwerp", "Paris", "Amsterdam", "Los Angeles", "Berlin"});

      for (Observation<String> oly : olympics) {
        System.out.println(oly.toString());
      }

    } catch (Exception e) {
      System.err.println("Oops...\n" + e.getMessage());
    }
  }
Example #2
0
 private Class<? extends RegularTimePeriod> findTimeClass(TimeDomain timeDomain)
     throws KeyedException {
   Class<? extends RegularTimePeriod> jfcTimeClass = null;
   // determine JFreeChart type of time from the time domain
   switch (timeDomain.getResolution()) {
     case YEAR:
       jfcTimeClass = org.jfree.data.time.Year.class;
       break;
     case MONTH:
       jfcTimeClass = org.jfree.data.time.Month.class;
       break;
     case DAY:
       jfcTimeClass = org.jfree.data.time.Day.class;
       break;
     case HOUR:
       jfcTimeClass = org.jfree.data.time.Hour.class;
       break;
     case MIN:
       jfcTimeClass = org.jfree.data.time.Minute.class;
       break;
     case SEC:
       jfcTimeClass = org.jfree.data.time.Second.class;
       break;
     case MSEC:
       jfcTimeClass = org.jfree.data.time.Millisecond.class;
       break;
     case USEC:
       throw K.JFC_USEC_ERR.exception();
     default:
       throw new RuntimeException("bug: " + timeDomain.getResolution());
   }
   return jfcTimeClass;
 }
Example #3
0
 @Override
 public String toString(TimeDomain value) {
   return value == null ? null : value.getLabel();
 }