Java Code Examples for org.jfree.chart.axis.SegmentedTimeline#getSegmentSize()
The following examples show how to use
org.jfree.chart.axis.SegmentedTimeline#getSegmentSize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SegmentedTimelineTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Tests translations between timelines. * * @param timeline the timeline to use for verifications. * @param startTest ??. */ public void verifyTranslations(SegmentedTimeline timeline, long startTest) { for (long testCycle = TEST_CYCLE_START; testCycle < TEST_CYCLE_END; testCycle += TEST_CYCLE_INC) { long millisecond = startTest + testCycle * timeline.getSegmentSize(); SegmentedTimeline.Segment segment = timeline.getSegment( millisecond); for (int i = 0; i < 1000; i++) { long translatedValue = timeline.toTimelineValue( segment.getMillisecond()); long newValue = timeline.toMillisecond(translatedValue); if (segment.inExcludeSegments() || segment.inExceptionSegments()) { // the reverse transformed value will be in the start of the // next non-excluded and non-exception segment SegmentedTimeline.Segment tempSegment = segment.copy(); tempSegment.moveIndexToStart(); do { tempSegment.inc(); } while (!tempSegment.inIncludeSegments()); assertEquals(tempSegment.getMillisecond(), newValue); } else { assertEquals(segment.getMillisecond(), newValue); } segment.inc(); } } }
Example 2
Source File: SegmentedTimelineTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Tests translations between timelines. * * @param timeline the timeline to use for verifications. * @param startTest ??. */ public void verifyTranslations(SegmentedTimeline timeline, long startTest) { for (long testCycle = TEST_CYCLE_START; testCycle < TEST_CYCLE_END; testCycle += TEST_CYCLE_INC) { long millisecond = startTest + testCycle * timeline.getSegmentSize(); SegmentedTimeline.Segment segment = timeline.getSegment( millisecond); for (int i = 0; i < 1000; i++) { long translatedValue = timeline.toTimelineValue( segment.getMillisecond()); long newValue = timeline.toMillisecond(translatedValue); if (segment.inExcludeSegments() || segment.inExceptionSegments()) { // the reverse transformed value will be in the start of the // next non-excluded and non-exception segment SegmentedTimeline.Segment tempSegment = segment.copy(); tempSegment.moveIndexToStart(); do { tempSegment.inc(); } while (!tempSegment.inIncludeSegments()); assertEquals(tempSegment.getMillisecond(), newValue); } else { assertEquals(segment.getMillisecond(), newValue); } segment.inc(); } } }
Example 3
Source File: SegmentedTimelineTests.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Tests one segment of the Monday through Friday timeline. Internal indices * inside one segment as well as adjacent segments are verified. * @param timeline the timeline to use for verifications. */ public void verifyOneSegment(SegmentedTimeline timeline) { for (long testCycle = TEST_CYCLE_START; testCycle < TEST_CYCLE_END; testCycle += TEST_CYCLE_INC) { // get two consecutive segments for various tests SegmentedTimeline.Segment segment1 = timeline.getSegment( this.monday.getTime().getTime() + testCycle); SegmentedTimeline.Segment segment2 = timeline.getSegment( segment1.getSegmentEnd() + 1); // verify segments are consecutive and correct assertEquals(segment1.getSegmentNumber() + 1, segment2.getSegmentNumber()); assertEquals(segment1.getSegmentEnd() + 1, segment2.getSegmentStart()); assertEquals(segment1.getSegmentStart() + timeline.getSegmentSize() - 1, segment1.getSegmentEnd()); assertEquals(segment1.getSegmentStart() + timeline.getSegmentSize(), segment2.getSegmentStart()); assertEquals(segment1.getSegmentEnd() + timeline.getSegmentSize(), segment2.getSegmentEnd()); // verify various indices inside a segment are the same segment long delta; if (timeline.getSegmentSize() > 1000000) { delta = timeline.getSegmentSize() / 10000; } else if (timeline.getSegmentSize() > 100000) { delta = timeline.getSegmentSize() / 1000; } else if (timeline.getSegmentSize() > 10000) { delta = timeline.getSegmentSize() / 100; } else if (timeline.getSegmentSize() > 1000) { delta = timeline.getSegmentSize() / 10; } else if (timeline.getSegmentSize() > 100) { delta = timeline.getSegmentSize() / 5; } else { delta = 1; } long start = segment1.getSegmentStart() + delta; long end = segment1.getSegmentStart() + timeline.getSegmentSize() - 1; SegmentedTimeline.Segment lastSeg = timeline.getSegment( segment1.getSegmentStart()); SegmentedTimeline.Segment seg; for (long i = start; i < end; i += delta) { seg = timeline.getSegment(i); assertEquals(lastSeg.getSegmentNumber(), seg.getSegmentNumber()); assertEquals(lastSeg.getSegmentStart(), seg.getSegmentStart()); assertEquals(lastSeg.getSegmentEnd(), seg.getSegmentEnd()); assertTrue(lastSeg.getMillisecond() < seg.getMillisecond()); lastSeg = seg; } // try next segment seg = timeline.getSegment(end + 1); assertEquals(segment2.getSegmentNumber(), seg.getSegmentNumber()); assertEquals(segment2.getSegmentStart(), seg.getSegmentStart()); assertEquals(segment2.getSegmentEnd(), seg.getSegmentEnd()); } }
Example 4
Source File: SegmentedTimelineTests.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Tests the inc methods. * @param timeline the timeline to use for verifications. */ public void verifyInc(SegmentedTimeline timeline) { for (long testCycle = TEST_CYCLE_START; testCycle < TEST_CYCLE_END; testCycle += TEST_CYCLE_INC) { long m = timeline.getSegmentSize(); SegmentedTimeline.Segment segment = timeline.getSegment(testCycle); SegmentedTimeline.Segment seg1 = segment.copy(); for (int i = 0; i < 1000; i++) { // test inc() method SegmentedTimeline.Segment seg2 = seg1.copy(); seg2.inc(); if ((seg1.getSegmentEnd() + 1) != seg2.getSegmentStart()) { // logically consecutive segments non-physically consecutive // (with non-contained time in between) assertTrue(!timeline.containsDomainRange( seg1.getSegmentEnd() + 1, seg2.getSegmentStart() - 1)); assertEquals(0, (seg2.getSegmentStart() - seg1.getSegmentStart()) % m); assertEquals(0, (seg2.getSegmentEnd() - seg1.getSegmentEnd()) % m); assertEquals(0, (seg2.getMillisecond() - seg1.getMillisecond()) % m); } else { // physically consecutive assertEquals(seg1.getSegmentStart() + m, seg2.getSegmentStart()); assertEquals(seg1.getSegmentEnd() + m, seg2.getSegmentEnd()); assertEquals(seg1.getMillisecond() + m, seg2.getMillisecond()); } // test inc(n) method SegmentedTimeline.Segment seg3 = seg1.copy(); SegmentedTimeline.Segment seg4 = seg1.copy(); for (int j = 0; j < i; j++) { seg3.inc(); } seg4.inc(i); assertEquals(seg3.getSegmentStart(), seg4.getSegmentStart()); assertEquals(seg3.getSegmentEnd(), seg4.getSegmentEnd()); assertEquals(seg3.getMillisecond(), seg4.getMillisecond()); // go to another segment to continue test seg1.inc(); } } }
Example 5
Source File: SegmentedTimelineTests.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Tests one segment of the Monday through Friday timeline. Internal indices * inside one segment as well as adjacent segments are verified. * @param timeline the timeline to use for verifications. */ public void verifyOneSegment(SegmentedTimeline timeline) { for (long testCycle = TEST_CYCLE_START; testCycle < TEST_CYCLE_END; testCycle += TEST_CYCLE_INC) { // get two consecutive segments for various tests SegmentedTimeline.Segment segment1 = timeline.getSegment( this.monday.getTime().getTime() + testCycle); SegmentedTimeline.Segment segment2 = timeline.getSegment( segment1.getSegmentEnd() + 1); // verify segments are consecutive and correct assertEquals(segment1.getSegmentNumber() + 1, segment2.getSegmentNumber()); assertEquals(segment1.getSegmentEnd() + 1, segment2.getSegmentStart()); assertEquals(segment1.getSegmentStart() + timeline.getSegmentSize() - 1, segment1.getSegmentEnd()); assertEquals(segment1.getSegmentStart() + timeline.getSegmentSize(), segment2.getSegmentStart()); assertEquals(segment1.getSegmentEnd() + timeline.getSegmentSize(), segment2.getSegmentEnd()); // verify various indices inside a segment are the same segment long delta; if (timeline.getSegmentSize() > 1000000) { delta = timeline.getSegmentSize() / 10000; } else if (timeline.getSegmentSize() > 100000) { delta = timeline.getSegmentSize() / 1000; } else if (timeline.getSegmentSize() > 10000) { delta = timeline.getSegmentSize() / 100; } else if (timeline.getSegmentSize() > 1000) { delta = timeline.getSegmentSize() / 10; } else if (timeline.getSegmentSize() > 100) { delta = timeline.getSegmentSize() / 5; } else { delta = 1; } long start = segment1.getSegmentStart() + delta; long end = segment1.getSegmentStart() + timeline.getSegmentSize() - 1; SegmentedTimeline.Segment lastSeg = timeline.getSegment( segment1.getSegmentStart()); SegmentedTimeline.Segment seg; for (long i = start; i < end; i += delta) { seg = timeline.getSegment(i); assertEquals(lastSeg.getSegmentNumber(), seg.getSegmentNumber()); assertEquals(lastSeg.getSegmentStart(), seg.getSegmentStart()); assertEquals(lastSeg.getSegmentEnd(), seg.getSegmentEnd()); assertTrue(lastSeg.getMillisecond() < seg.getMillisecond()); lastSeg = seg; } // try next segment seg = timeline.getSegment(end + 1); assertEquals(segment2.getSegmentNumber(), seg.getSegmentNumber()); assertEquals(segment2.getSegmentStart(), seg.getSegmentStart()); assertEquals(segment2.getSegmentEnd(), seg.getSegmentEnd()); } }
Example 6
Source File: SegmentedTimelineTests.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Tests the inc methods. * @param timeline the timeline to use for verifications. */ public void verifyInc(SegmentedTimeline timeline) { for (long testCycle = TEST_CYCLE_START; testCycle < TEST_CYCLE_END; testCycle += TEST_CYCLE_INC) { long m = timeline.getSegmentSize(); SegmentedTimeline.Segment segment = timeline.getSegment(testCycle); SegmentedTimeline.Segment seg1 = segment.copy(); for (int i = 0; i < 1000; i++) { // test inc() method SegmentedTimeline.Segment seg2 = seg1.copy(); seg2.inc(); if ((seg1.getSegmentEnd() + 1) != seg2.getSegmentStart()) { // logically consecutive segments non-physically consecutive // (with non-contained time in between) assertTrue(!timeline.containsDomainRange( seg1.getSegmentEnd() + 1, seg2.getSegmentStart() - 1)); assertEquals(0, (seg2.getSegmentStart() - seg1.getSegmentStart()) % m); assertEquals(0, (seg2.getSegmentEnd() - seg1.getSegmentEnd()) % m); assertEquals(0, (seg2.getMillisecond() - seg1.getMillisecond()) % m); } else { // physically consecutive assertEquals(seg1.getSegmentStart() + m, seg2.getSegmentStart()); assertEquals(seg1.getSegmentEnd() + m, seg2.getSegmentEnd()); assertEquals(seg1.getMillisecond() + m, seg2.getMillisecond()); } // test inc(n) method SegmentedTimeline.Segment seg3 = seg1.copy(); SegmentedTimeline.Segment seg4 = seg1.copy(); for (int j = 0; j < i; j++) { seg3.inc(); } seg4.inc(i); assertEquals(seg3.getSegmentStart(), seg4.getSegmentStart()); assertEquals(seg3.getSegmentEnd(), seg4.getSegmentEnd()); assertEquals(seg3.getMillisecond(), seg4.getMillisecond()); // go to another segment to continue test seg1.inc(); } } }