Package org.jfree.chart.axis
Class SegmentedTimeline.Segment
java.lang.Object
org.jfree.chart.axis.SegmentedTimeline.Segment
- All Implemented Interfaces:
Serializable,Cloneable,Comparable
- Direct Known Subclasses:
SegmentedTimeline.SegmentRange
- Enclosing class:
- SegmentedTimeline
public class SegmentedTimeline.Segment
extends Object
implements Comparable, Cloneable, Serializable
Internal class to represent a valid segment for this timeline. A segment
is valid on a timeline if it is part of its included, excluded or
exception segments.
Each segment will know its segment number, segmentStart, segmentEnd and index inside the segment.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longA reference point within the segment.protected longThe segment end.protected longThe segment number.protected longThe segment start. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanafter(SegmentedTimeline.Segment other) Returnstrueif this segment is wholly after another segment.booleanbefore(SegmentedTimeline.Segment other) Returnstrueif this segment is wholly before another segment.longcalculateSegmentNumber(long millis) Calculates the segment number for a given millisecond.intWill compare this Segment with another Segment (from Comparable interface).booleancontained(long from, long to) Returnstrueif this segment is contained in an interval.booleancontains(long millis) Returns true if a particular millisecond is contained in this segment.booleancontains(long from, long to) Returnstrueif an interval is contained in this segment.booleancontains(SegmentedTimeline.Segment segment) Returnstrueif a segment is contained in this segment.copy()Returns a copy of ourselves ornullif there was an exception during cloning.voiddec()Decrements the internal attributes of this segment by one segment.voiddec(long n) Decrements the internal attributes of this segment by a number of segments.booleanTests an object (usually anotherSegment) for equality with this segment.getDate()Returns aDatethat represents the reference point for this segment.longReturns the millisecond used to reference this segment (always between the segmentStart and segmentEnd).longReturns always one (the number of segments contained in this segment).longGets the end of this segment in ms.longReturns the segment number of this segment.longGets the start of this segment in ms.voidinc()Increments the internal attributes of this segment by one segment.voidinc(long n) Increments the internal attributes of this segment by a number of segments.booleanReturns true if we are an exception segment.booleanReturns true if we are an excluded segment.booleanReturns true if we are an included segment and we are not an exception.intersect(long from, long to) Returns a segment that is the intersection of this segment and the interval.voidMoves the index of this segment to the end of the segment.voidMoves the index of this segment to the beginning if the segment.
-
Field Details
-
segmentNumber
The segment number. -
segmentStart
The segment start. -
segmentEnd
The segment end. -
millisecond
A reference point within the segment.
-
-
Constructor Details
-
Segment
protected Segment()Protected constructor only used by sub-classes. -
Segment
Creates a segment for a given point in time.- Parameters:
millisecond- the millisecond (as encoded by java.util.Date).
-
-
Method Details
-
calculateSegmentNumber
Calculates the segment number for a given millisecond.- Parameters:
millis- the millisecond (as encoded by java.util.Date).- Returns:
- The segment number.
-
getSegmentNumber
Returns the segment number of this segment. Segments start at 0.- Returns:
- The segment number.
-
getSegmentCount
Returns always one (the number of segments contained in this segment).- Returns:
- The segment count (always 1 for this class).
-
getSegmentStart
Gets the start of this segment in ms.- Returns:
- The segment start.
-
getSegmentEnd
Gets the end of this segment in ms.- Returns:
- The segment end.
-
getMillisecond
Returns the millisecond used to reference this segment (always between the segmentStart and segmentEnd).- Returns:
- The millisecond.
-
getDate
Returns aDatethat represents the reference point for this segment.- Returns:
- The date.
-
contains
Returns true if a particular millisecond is contained in this segment.- Parameters:
millis- the millisecond to verify.- Returns:
trueif the millisecond is contained in the segment.
-
contains
Returnstrueif an interval is contained in this segment.- Parameters:
from- the start of the interval.to- the end of the interval.- Returns:
trueif the interval is contained in the segment.
-
contains
Returnstrueif a segment is contained in this segment.- Parameters:
segment- the segment to test for inclusion- Returns:
trueif the segment is contained in this segment.
-
contained
Returnstrueif this segment is contained in an interval.- Parameters:
from- the start of the interval.to- the end of the interval.- Returns:
trueif this segment is contained in the interval.
-
intersect
Returns a segment that is the intersection of this segment and the interval.- Parameters:
from- the start of the interval.to- the end of the interval.- Returns:
- A segment.
-
before
Returnstrueif this segment is wholly before another segment.- Parameters:
other- the other segment.- Returns:
- A boolean.
-
after
Returnstrueif this segment is wholly after another segment.- Parameters:
other- the other segment.- Returns:
- A boolean.
-
equals
Tests an object (usually anotherSegment) for equality with this segment. -
copy
Returns a copy of ourselves ornullif there was an exception during cloning.- Returns:
- A copy of this segment.
-
compareTo
Will compare this Segment with another Segment (from Comparable interface).- Specified by:
compareToin interfaceComparable- Parameters:
object- The other Segment to compare with- Returns:
- -1: this < object, 0: this.equal(object) and +1: this > object
-
inIncludeSegments
Returns true if we are an included segment and we are not an exception.- Returns:
trueorfalse.
-
inExcludeSegments
Returns true if we are an excluded segment.- Returns:
trueorfalse.
-
inExceptionSegments
Returns true if we are an exception segment. This is implemented via a binary search on the exceptionSegments sorted list. If the segment is not listed as an exception in our list and we have a baseTimeline, a check is performed to see if the segment is inside an excluded segment from our base. If so, it is also considered an exception.- Returns:
trueif we are an exception segment.
-
inc
Increments the internal attributes of this segment by a number of segments.- Parameters:
n- Number of segments to increment.
-
inc
Increments the internal attributes of this segment by one segment. The exact time incremented is segmentSize. -
dec
Decrements the internal attributes of this segment by a number of segments.- Parameters:
n- Number of segments to decrement.
-
dec
Decrements the internal attributes of this segment by one segment. The exact time decremented is segmentSize. -
moveIndexToStart
Moves the index of this segment to the beginning if the segment. -
moveIndexToEnd
Moves the index of this segment to the end of the segment.
-