Package org.timepedia.chronoscope.client.util.date

Examples of org.timepedia.chronoscope.client.util.date.ChronoDate


   * this value will be the same as the <tt>numTimeUnits</tt> input parameter, but
   * in the aforementioned subclass override case, a different value could
   * get returned (the typical case for this is a date near the end of a month).
   */
  public int incrementTick(int numTimeUnits) {
    ChronoDate date = currTick;
    date.add(timeUnitTickInterval, numTimeUnits);
    return numTimeUnits;
  }
View Full Code Here


      if (hoverX > 0) {
        // consider painting crosshair line on overlay layer for Z order underneath (behind) the points
        hoverLayer.fillRect(hoverX-0.5, 0.5, 1, hoverLayer.getBounds().height);
        int hx = hoverX;
        double dx = windowXtoDomain(hoverX + plotBounds.x);
        ChronoDate cronoDate = new FastChronoDate(dx);

        if (ChronoscopeOptions.isCrosshairDateTimeFormat()) {
          if (crosshairFmt == null && !"auto".equals(ChronoscopeOptions.getCrosshairDateTimeFormat())) {
            crosshairFmt = DateFormatterFactory.getInstance().getDateFormatter(ChronoscopeOptions.getCrosshairDateTimeFormat());
          }
          String label;
          if (crosshairFmt != null) {
            label = crosshairFmt.format(cronoDate.getOffsetTime());
          } else {
            label = getTickFormater().formatCrosshair(cronoDate);
          }
          int labelWidth = hoverLayer.stringWidth(label, "Helvetica", "", "8pt");
          int labelHeight = hoverLayer.stringHeight(label, "Helvetica", "", "8pt");
View Full Code Here

    final double ux = plot.domainToScreenX(dataX, datasetIndex);
    final double uy = plot.rangeToScreenY(dataY, datasetIndex);

    addClickable(datasetIndex, domainIndex, renderState.getPassNumber(), dataX, dataY, ux, uy);

    ChronoDate d = ChronoDate.get(dataX);

    if (methodCallCount == 0) {
      // nothing to do
    }
    else {
View Full Code Here

   * starting at year 1970.
   */
  public Dataset getBasicDataset() {
    int numSamples = 1000;

    ChronoDate d = ChronoDate.get(1970, 0, 1);

    double[] domainValues = new double[numSamples];
    double[] rangeValues = new double[numSamples];

    for (int i = 0; i < numSamples; i++) {
      double tmp = 5.0 * (double) i / (double) numSamples;
      double ry = Math.sin(Math.PI * tmp) / Math.exp(tmp / 5.0);

      domainValues[i] = d.getTime();
      rangeValues[i] = ry;
      d.add(TimeUnit.DAY, 1);
    }

    DatasetRequest.Basic request = new DatasetRequest.Basic();
    request.setIdentifier("mock");
    request.setAxisId("none");
View Full Code Here

   * require this because their quantized intervals are all factors of N,
   * where N is the number of time units that compose the parent time unit.
   */
  @Override
  public int incrementTick(int numTimeUnits) {
    ChronoDate d = this.currTick;
    final int dayOfMonth = d.getDay();
    boolean doSkipToNextMonth = false;
    switch (numTimeUnits) {
      case 2:
        int daysInMonth = d.getDaysInMonth();
        boolean isEven = (daysInMonth % 2 == 0);
        int dayThreshold = daysInMonth - (isEven ? 1 : 2);
        doSkipToNextMonth = (dayOfMonth >= dayThreshold);
        break;
      case 7:
        doSkipToNextMonth = dayOfMonth > (7 * 3);
        break;
      case 14:
        doSkipToNextMonth = dayOfMonth >= 14;
        break;
    }

    int actualIncrement;
    if (doSkipToNextMonth) {
      actualIncrement = gotoFirstOfNextMonth(d);
    }
    else {
      actualIncrement = numTimeUnits;
      d.add(this.timeUnitTickInterval, numTimeUnits);
    }
   
    return actualIncrement;
  }
View Full Code Here

      fail("Expected IllegalArgumentException");
    } catch (IllegalArgumentException e) {}
  }
 
  public void testGetDaysInMonth() {
    ChronoDate d = createTestDate(1582, 0, 1);
    assertEquals(31, d.getDaysInMonth());

    d = createTestDate(2000, 1, 15);
    assertEquals(29, d.getDaysInMonth());
 
    d = createTestDate(1900, 1, 15);
    assertEquals(28, d.getDaysInMonth());

    // Special case: switch from Julian to Gregorian; Oct only has 21 days.
    d = createTestDate(1582, 9, 3);
    assertEquals(21, d.getDaysInMonth());
  }
View Full Code Here

  private static ChronoDate createTestDate(int year, int month, int day) {
    return createTestDate(year, month, day, 0, 0, 0, 0);
  }
 
  private static ChronoDate createTestDate(int year, int month, int day, int hr, int min, int sec, int ms) {
    ChronoDate d = new FastChronoDate(year, month, day);
    d.set().hour(hr).min(min).sec(sec).ms(ms).done();
    return d;
  }
View Full Code Here

  private static Date createJavaDate(int yr, int mo, int day, int hr, int min, int sec) {
    return new Date(yr - 1900, mo, day, hr, min, sec);
  }

  private void testSetTimeUnitFields(int yr, int mo, int day, int hr, int min, int sec) {
    ChronoDate d = createTestDate(yr);
    d.set().month(mo).day(day).hour(hr).min(min).sec(sec).done();
   
    long expectedTimestamp = createJavaDate(yr, mo, day, hr, min, sec).getTime();
    assertEquals(expectedTimestamp, (long)d.getTime());
  }
View Full Code Here

    long expectedTimestamp = createJavaDate(yr, mo, day, hr, min, sec).getTime();
    assertEquals(expectedTimestamp, (long)d.getTime());
  }
 
  public void testSetMillenium() {
    ChronoDate d = new FastChronoDate(-2345, 5, 25);
    d.set(TimeUnit.MILLENIUM, 1);
    assertEquals(1345, 5, 25, d);
   
    d = new FastChronoDate(-2345, 5, 25);
    d.set(TimeUnit.MILLENIUM, -30);
    assertEquals(-30345, 5, 25, d);
  }
View Full Code Here

    int hr = 23;
    int min = 17;
    int sec = 50;
   
    Date javaDate = createJavaDate(year, 0, 1, hr, min, sec);
    ChronoDate chronoDate = createTestDate(year, 0, 1, hr, min, sec, 0);
    assertTimestampEquals(msg, year, javaDate.getTime(), (long)chronoDate.getTime());
   
    javaDate = createJavaDate(year, 0, 31, hr, min, sec);
    chronoDate = createTestDate(year, 0, 31, hr, min, sec, 0);
    assertTimestampEquals(msg, year, javaDate.getTime(), (long)chronoDate.getTime());

    javaDate = createJavaDate(year, 1, 28, hr, min, sec);
    chronoDate = createTestDate(year, 1, 28, hr, min, sec, 0);
    assertTimestampEquals(msg, year, javaDate.getTime(), (long)chronoDate.getTime());
   
    javaDate = createJavaDate(year, 2, 1, hr, min, sec);
    chronoDate = createTestDate(year, 2, 1, hr, min, sec, 0);
    assertTimestampEquals(msg, year, javaDate.getTime(), (long)chronoDate.getTime());

    javaDate = createJavaDate(year, 5, 15, hr, min, sec);
    chronoDate = createTestDate(year, 5, 15, hr, min, sec, 0);
    assertTimestampEquals(msg, year, javaDate.getTime(), (long)chronoDate.getTime());
   
    javaDate = createJavaDate(year, 9, 1, hr, min, sec);
    chronoDate = createTestDate(year, 9, 1, hr, min, sec, 0);
    assertTimestampEquals(msg, year, javaDate.getTime(), (long)chronoDate.getTime());
   
    javaDate = createJavaDate(year, 9, 30, hr, min, sec);
    chronoDate = createTestDate(year, 9, 30, hr, min, sec, 0);
    assertTimestampEquals(msg, year, javaDate.getTime(), (long)chronoDate.getTime());

    javaDate = createJavaDate(year, 11, 31, hr, min, sec);
    chronoDate = createTestDate(year, 11, 31, hr, min, sec, 0);
    assertTimestampEquals(msg, year, javaDate.getTime(), (long)chronoDate.getTime());
  }
View Full Code Here

TOP

Related Classes of org.timepedia.chronoscope.client.util.date.ChronoDate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.