Examples of SegmentedTimeline


Examples of org.jfree.chart.axis.SegmentedTimeline

        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        Date date = cal.getTime();

        SegmentedTimeline timeline = getTimeline();
        long value = timeline.toTimelineValue(date);
        long ms = timeline.toMillisecond(value);
        Calendar cal2 = Calendar.getInstance(Locale.UK);
        cal2.setTime(new Date(ms));
        Date reverted = cal2.getTime();
        assertTrue("test1", value == (900000 * 34)
                && date.getTime() == reverted.getTime());
View Full Code Here

Examples of org.jfree.chart.axis.SegmentedTimeline

        cal.set(Calendar.MINUTE, 15);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        Date date = cal.getTime();

        SegmentedTimeline timeline = getTimeline();

        long value = timeline.toTimelineValue(date);
        long ms = timeline.toMillisecond(value);
        Calendar cal2 = Calendar.getInstance(Locale.UK);
        cal2.setTime(new Date(ms));
        Date reverted = cal2.getTime();
        assertTrue(
            "test2", value == (900000 * 34 + 900000)
View Full Code Here

Examples of org.jfree.chart.axis.SegmentedTimeline

        cal.set(Calendar.HOUR_OF_DAY, 9);
        cal.set(Calendar.MINUTE, 30);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        Date date = cal.getTime();
        SegmentedTimeline timeline = getTimeline();

        long value = timeline.toTimelineValue(date);
        long ms = timeline.toMillisecond(value);

        Calendar cal2 = Calendar.getInstance(Locale.UK);
        cal2.setTime(new Date(ms));
        Date reverted = cal2.getTime();
        assertTrue(
View Full Code Here

Examples of org.jfree.chart.axis.SegmentedTimeline

        cal.set(Calendar.HOUR_OF_DAY, 9);
        cal.set(Calendar.MINUTE, 30);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 1);
        Date date = cal.getTime();
        SegmentedTimeline timeline = getTimeline();

        long value = timeline.toTimelineValue(date);
        long ms = timeline.toMillisecond(value);
        Calendar cal2 = Calendar.getInstance(Locale.UK);
        cal2.setTime(new Date(ms));
        Date reverted = cal2.getTime();
        assertTrue(
            "test4", value == (900000 * 34 + 900000 * 2 + 1)
View Full Code Here

Examples of org.jfree.chart.axis.SegmentedTimeline

        cal.set(Calendar.HOUR_OF_DAY, 17);
        cal.set(Calendar.MINUTE, 30);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        Date date = cal.getTime();
        SegmentedTimeline timeline = getTimeline();

        long value = timeline.toTimelineValue(date);
        long ms = timeline.toMillisecond(value);
        Calendar cal2 = Calendar.getInstance(Locale.UK);
        cal2.setTime(new Date(ms));
        Date reverted = cal2.getTime();
        Calendar expectedReverted = Calendar.getInstance(Locale.UK);
        expectedReverted.set(Calendar.YEAR, 2004);
View Full Code Here

Examples of org.jfree.chart.axis.SegmentedTimeline

        cal.set(Calendar.HOUR_OF_DAY, 9);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        Date date = cal.getTime();
        SegmentedTimeline timeline = getTimeline();

        long value = timeline.toTimelineValue(date);
        long ms = timeline.toMillisecond(value);
        Calendar cal2 = Calendar.getInstance(Locale.UK);
        cal2.setTime(new Date(ms));
        Date reverted = cal2.getTime();

        Calendar expectedReverted = Calendar.getInstance(Locale.UK);
View Full Code Here

Examples of org.jfree.chart.axis.SegmentedTimeline

        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        Date date = cal.getTime();

        SegmentedTimeline timeline = getTimeline();
        long value = timeline.toTimelineValue(date);
        long ms = timeline.toMillisecond(value);

        Calendar cal2 = Calendar.getInstance(Locale.UK);
        cal2.setTime(new Date(ms));
        Date reverted = cal2.getTime();
View Full Code Here

Examples of org.jfree.chart.axis.SegmentedTimeline

        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        Date date = cal.getTime();

        SegmentedTimeline timeline = getTimeline();

        // Add exception in included segments
        cal.set(Calendar.YEAR, 2004);
        cal.set(Calendar.MONTH, Calendar.MARCH);
        cal.set(Calendar.DAY_OF_MONTH, 29);
        cal.set(Calendar.HOUR_OF_DAY, 9);
        cal.set(Calendar.MINUTE, 15);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        timeline.addException(cal.getTime());

        long value = timeline.toTimelineValue(date);
        long ms = timeline.toMillisecond(value);

        Calendar cal2 = Calendar.getInstance(Locale.UK);
        cal2.setTime(new Date(ms));
        Date reverted = cal2.getTime();
View Full Code Here

Examples of org.jfree.chart.axis.SegmentedTimeline

        cal.set(Calendar.MINUTE, 30);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        Date close = cal.getTime();

        SegmentedTimeline result = null;
        // Create a segmented time line (segment size : 15 minutes)
        long quarterHourCount = (close.getTime() - open.getTime())
            / SegmentedTimeline.FIFTEEN_MINUTE_SEGMENT_SIZE;
        long totalQuarterHourCount = SegmentedTimeline.DAY_SEGMENT_SIZE
            / SegmentedTimeline.FIFTEEN_MINUTE_SEGMENT_SIZE;
        result = new SegmentedTimeline(
            SegmentedTimeline.FIFTEEN_MINUTE_SEGMENT_SIZE,
            (int) quarterHourCount,
            (int) (totalQuarterHourCount - quarterHourCount)
        );
        result.setAdjustForDaylightSaving(true);
        // Set start time
        result.setStartTime(start.getTime());
        // Saturday and Sundays are non business hours
        result.setBaseTimeline(
            SegmentedTimeline.newMondayThroughFridayTimeline()
        );
        /* PUT exclusions in test */
        if (start != null && end != null) {
            result.addBaseTimelineExclusions(start.getTime(), end.getTime());
        }

        return result;
    }
View Full Code Here

Examples of org.jfree.chart.axis.SegmentedTimeline

    /**
     * Tests a basic time line with one exception.
     */
    public void testSegmentedTimelineWithException1() {
        SegmentedTimeline stl = new SegmentedTimeline(10, 2, 3);
        stl.setStartTime(946684800000L)// 1-Jan-2000
        stl.addException(946684800050L);
        assertFalse(stl.containsDomainValue(946684799999L));
        assertTrue(stl.containsDomainValue(946684800000L));
        assertTrue(stl.containsDomainValue(946684800019L));
        assertFalse(stl.containsDomainValue(946684800020L));
        assertFalse(stl.containsDomainValue(946684800049L));
        assertFalse(stl.containsDomainValue(946684800050L));
        assertFalse(stl.containsDomainValue(946684800059L));
        assertTrue(stl.containsDomainValue(946684800060L));
        assertTrue(stl.containsDomainValue(946684800069L));
        assertFalse(stl.containsDomainValue(946684800070L));
        assertFalse(stl.containsDomainValue(946684800099L));
        assertTrue(stl.containsDomainValue(946684800100L));

        //long v = stl.toTimelineValue(946684800020L);
        assertEquals(0, stl.toTimelineValue(946684800000L));
        assertEquals(19, stl.toTimelineValue(946684800019L));
        assertEquals(20, stl.toTimelineValue(946684800020L));
        assertEquals(20, stl.toTimelineValue(946684800049L));
        assertEquals(20, stl.toTimelineValue(946684800050L));
        assertEquals(29, stl.toTimelineValue(946684800069L));
        assertEquals(30, stl.toTimelineValue(946684800070L));
        assertEquals(30, stl.toTimelineValue(946684800099L));
        assertEquals(30, stl.toTimelineValue(946684800100L));

        assertEquals(946684800000L, stl.toMillisecond(0));
        assertEquals(946684800019L, stl.toMillisecond(19));
        assertEquals(946684800060L, stl.toMillisecond(20));
        assertEquals(946684800069L, stl.toMillisecond(29));
        assertEquals(946684800100L, stl.toMillisecond(30));

    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.