Example usage for org.jfree.data.time Hour getHour

List of usage examples for org.jfree.data.time Hour getHour

Introduction

In this page you can find the example usage for org.jfree.data.time Hour getHour.

Prototype

public int getHour() 

Source Link

Document

Returns the hour.

Usage

From source file:playground.yu.utils.charts.TimeLineChart.java

public void addSeries(final String title, final double[] times, final double[] ys) {
    // final TimeTableXYDataset series = new TimeTableXYDataset();
    for (int i = 0, n = Math.min(times.length, ys.length); i < n; i++) {
        final Hour hour = new Hour((int) times[i] / 3600, new Day());
        final Minute min = new Minute((int) ((times[i] - hour.getHour() * 3600) / 60), hour);
        final Second sec = new Second((int) (times[i] - hour.getHour() * 3600 - min.getMinute() * 60), min);
        this.dataset.add(sec, ys[i], title);
    }//from ww w .  j  ava  2  s .c o m
    // this.dataset.addSeries(series);
}

From source file:playground.yu.utils.charts.TimeScatterChart.java

/**
 * Adds a new data series to the chart with the specified title.
 * <code>xs<code> and <code>ys</code> should have the same length. If not,
 * only as many items are shown as the shorter array contains.
 * /*from w ww. ja v a2  s . co m*/
 * @param title
 * @param times
 *            The time axle.
 * @param ys
 *            The y values.
 */
public void addSeries(final String title, final double[] times, final double[] ys) {
    // final TimeTableXYDataset series = new TimeTableXYDataset();
    for (int i = 0, n = Math.min(times.length, ys.length); i < n; i++) {
        final Hour hour = new Hour((int) times[i] / 3600, new Day());
        final Minute min = new Minute((int) ((times[i] - hour.getHour() * 3600) / 60), hour);
        final Second sec = new Second((int) (times[i] - hour.getHour() * 3600 - min.getMinute() * 60), min);
        this.dataset.add(sec, ys[i], title);
    }
    // this.dataset.addSeries(series);
}

From source file:org.jfree.data.time.HourTest.java

/**
 * Set up an hour equal to hour zero, 1 January 1900.  Request the next
 * hour, it should be null.//w  ww  .j  ava 2s  .c om
 */
@Test
public void testFirstHourNext() {
    Hour first = new Hour(0, new Day(1, MonthConstants.JANUARY, 1900));
    Hour next = (Hour) first.next();
    assertEquals(1, next.getHour());
    assertEquals(1900, next.getYear());
}

From source file:org.jfree.data.time.HourTest.java

/**
 * Set up an hour equal to hour zero, 1 January 1900.  Request the previous
 * hour, it should be null./*from  w  w w . j a v  a 2s.c  o m*/
 */
@Test
public void testLastHourPrevious() {
    Hour last = new Hour(23, new Day(31, MonthConstants.DECEMBER, 9999));
    Hour previous = (Hour) last.previous();
    assertEquals(22, previous.getHour());
    assertEquals(9999, previous.getYear());
}

From source file:org.jfree.data.time.HourTest.java

/**
 * Problem for date parsing.//from w w w  .ja v  a 2 s.  c  o  m
 */
@Test
public void testParseHour() {
    // test 1...
    Hour h = Hour.parseHour("2002-01-29 13");
    assertEquals(13, h.getHour());
}

From source file:org.jfree.data.time.junit.HourTest.java

/**
 * Set up an hour equal to hour zero, 1 January 1900.  Request the next
 * hour, it should be null./*from   ww  w  .jav a2 s.co  m*/
 */
public void testFirstHourNext() {
    Hour first = new Hour(0, new Day(1, MonthConstants.JANUARY, 1900));
    Hour next = (Hour) first.next();
    assertEquals(1, next.getHour());
    assertEquals(1900, next.getYear());
}

From source file:org.jfree.data.time.junit.HourTest.java

/**
 * Set up an hour equal to hour zero, 1 January 1900.  Request the previous
 * hour, it should be null.//from w  w  w .  j  ava 2 s .  c o m
 */
public void testLastHourPrevious() {
    Hour last = new Hour(23, new Day(31, MonthConstants.DECEMBER, 9999));
    Hour previous = (Hour) last.previous();
    assertEquals(22, previous.getHour());
    assertEquals(9999, previous.getYear());
}

From source file:org.jfree.data.time.junit.HourTest.java

/**
 * Problem for date parsing.//w  ww. j  a va 2s . c  o m
 */
public void testParseHour() {
    // test 1...
    Hour h = Hour.parseHour("2002-01-29 13");
    assertEquals(13, h.getHour());
}

From source file:org.jfree.data.time.HourTest.java

/**
 * In GMT, the 4pm on 21 Mar 2002 is java.util.Date(1,014,307,200,000L).
 * Use this to check the hour constructor.
 *//*  w w w  .  j  a va 2  s.  c  o m*/
@Test
public void testDateConstructor1() {
    TimeZone zone = TimeZone.getTimeZone("GMT");
    Locale locale = Locale.getDefault(); // locale should not matter here
    Hour h1 = new Hour(new Date(1014307199999L), zone, locale);
    Hour h2 = new Hour(new Date(1014307200000L), zone, locale);

    assertEquals(15, h1.getHour());
    assertEquals(1014307199999L, h1.getLastMillisecond(zone));

    assertEquals(16, h2.getHour());
    assertEquals(1014307200000L, h2.getFirstMillisecond(zone));
}

From source file:org.jfree.data.time.HourTest.java

/**
 * In Sydney, the 4pm on 21 Mar 2002 is java.util.Date(1,014,267,600,000L).
 * Use this to check the hour constructor.
 *///from  w  ww  .  ja  va  2 s . com
@Test
public void testDateConstructor2() {
    TimeZone zone = TimeZone.getTimeZone("Australia/Sydney");
    Locale locale = Locale.getDefault(); // locale should not matter here
    Hour h1 = new Hour(new Date(1014267599999L), zone, locale);
    Hour h2 = new Hour(new Date(1014267600000L), zone, locale);

    assertEquals(15, h1.getHour());
    assertEquals(1014267599999L, h1.getLastMillisecond(zone));

    assertEquals(16, h2.getHour());
    assertEquals(1014267600000L, h2.getFirstMillisecond(zone));
}