Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jfree.chart.axis
Class SegmentedTimeline.Segment

    java.lang.Object
      org.jfree.chart.axis.SegmentedTimeline.Segment

All Implemented Interfaces:
  java.lang.Cloneable, java.lang.Comparable, java.io.Serializable

Direct Known Subclasses:
  SegmentedTimeline.SegmentRange

Enclosing class:
  SegmentedTimeline

public class SegmentedTimeline.Segment
extends java.lang.Object
implements java.lang.Comparable, java.lang.Cloneable, java.io.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:
  Serialized Form

Field Summary
`protected long` | `millisecond` A reference point within the segment.
`protected long` | `segmentEnd` The segment end.
`protected long` | `segmentNumber` The segment number.
`protected long` | `segmentStart` The segment start.

Constructor Summary
`protected` | `SegmentedTimeline.Segment()` Protected constructor only used by sub-classes.
`protected` | `SegmentedTimeline.Segment(long millisecond)` Creates a segment for a given point in time.

Method Summary
`boolean` | `after(SegmentedTimeline.Segment other)` Returns `true` if this segment is wholly after another segment.
`boolean` | `before(SegmentedTimeline.Segment other)` Returns `true` if this segment is wholly before another segment.
`long` | `calculateSegmentNumber(long millisecond)` Calculates the segment number for a given millisecond.
`int` | `compareTo(java.lang.Object object)` Will compare this Segment with another Segment (from Comparable interface).
`boolean` | `contained(long from, long to)` Returns `true` if this segment is contained in an interval.
`boolean` | `contains(long millisecond)` Returns true if a particular millisecond is contained in this segment.
`boolean` | `contains(long from, long to)` Returns `true` if an interval is contained in this segment.
`boolean` | `contains(SegmentedTimeline.Segment segment)` Returns `true` if a segment is contained in this segment.
`SegmentedTimeline.Segment` | `copy()` Returns a copy of ourselves or `null` if there was an exception during cloning.
`void` | `dec()` Decrements the internal attributes of this segment by one segment.
`void` | `dec(long n)` Decrements the internal attributes of this segment by a number of segments.
`boolean` | `equals(java.lang.Object object)` Tests an object (usually another `Segment`) for equality with this segment.
`java.util.Date` | `getDate()` Returns a `Date` that represents the reference point for this segment.
`long` | `getIndex()` Deprecated. Use getMillisecond().
`long` | `getMillisecond()` Returns the millisecond used to reference this segment (always between the segmentStart and segmentEnd).
`long` | `getSegmentCount()` Returns always one (the number of segments contained in this segment).
`long` | `getSegmentEnd()` Gets the end of this segment in ms.
`long` | `getSegmentNumber()` Returns the segment number of this segment.
`long` | `getSegmentStart()` Gets the start of this segment in ms.
`void` | `inc()` Increments the internal attributes of this segment by one segment.
`void` | `inc(long n)` Increments the internal attributes of this segment by a number of segments.
`boolean` | `inExceptionSegments()` Returns true if we are an exception segment.
`boolean` | `inExcludeSegments()` Returns true if we are an excluded segment.
`boolean` | `inIncludeSegments()` Returns true if we are an included segment and we are not an exception.
`SegmentedTimeline.Segment` | `intersect(long from, long to)` Returns a segment that is the intersection of this segment and the interval.
`void` | `moveIndexToEnd()` Moves the index of this segment to the end of the segment.
`void` | `moveIndexToStart()` Moves the index of this segment to the beginning if the segment.

Methods inherited from class java.lang.Object
`clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### segmentNumber

    protected long segmentNumber

  The segment number.

### segmentStart

    protected long segmentStart

  The segment start.

### segmentEnd

    protected long segmentEnd

  The segment end.

### millisecond

    protected long millisecond

  A reference point within the segment.

Constructor Detail

### SegmentedTimeline.Segment

    protected SegmentedTimeline.Segment()

  Protected constructor only used by sub-classes.

### SegmentedTimeline.Segment

    protected SegmentedTimeline.Segment(long millisecond)

  Creates a segment for a given point in time.

Parameters:
  `millisecond` - the millisecond (as encoded by java.util.Date).

Method Detail

### calculateSegmentNumber

    public long calculateSegmentNumber(long millisecond)

  Calculates the segment number for a given millisecond.

  Parameters:
    `millisecond` - the millisecond (as encoded by java.util.Date).
  Returns:
    The segment number.

### getSegmentNumber

    public long getSegmentNumber()

  Returns the segment number of this segment. Segments start at 0.

  Returns:
    The segment number.

### getSegmentCount

    public long getSegmentCount()

  Returns always one (the number of segments contained in this segment).

  Returns:
    The segment count (always 1 for this class).

### getSegmentStart

    public long getSegmentStart()

  Gets the start of this segment in ms.

  Returns:
    The segment start.

### getSegmentEnd

    public long getSegmentEnd()

  Gets the end of this segment in ms.

  Returns:
    The segment end.

### getMillisecond

    public long getMillisecond()

  Returns the millisecond used to reference this segment (always between the segmentStart and segmentEnd).

  Returns:
    The millisecond.

### getIndex

    public long getIndex()

  Deprecated. Use getMillisecond().

  Gets the index in this segment. Index will always be between the segmentStart and segmentEnd.

  Returns:
    The index.

### getDate

    public java.util.Date getDate()

  Returns a `Date` that represents the reference point for this segment.

  Returns:
    The date.

### contains

    public boolean contains(long millisecond)

  Returns true if a particular millisecond is contained in this segment.

  Parameters:
    `millisecond` - the millisecond to verify.
  Returns:
    `true` if the millisecond is contained in the segment.

### contains

    public boolean contains(long from,
                            long to)

  Returns `true` if an interval is contained in this segment.

  Parameters:
    `from` - the start of the interval.
    `to` - the end of the interval.
  Returns:
    `true` if the interval is contained in the segment.

### contains

    public boolean contains(SegmentedTimeline.Segment segment)

  Returns `true` if a segment is contained in this segment.

  Parameters:
    `segment` - the segment to test for inclusion
  Returns:
    `true` if the segment is contained in this segment.

### contained

    public boolean contained(long from,
                             long to)

  Returns `true` if this segment is contained in an interval.

  Parameters:
    `from` - the start of the interval.
    `to` - the end of the interval.
  Returns:
    true this segment is contained in the interval

### intersect

    public SegmentedTimeline.Segment intersect(long from,
                                               long to)

  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

    public boolean before(SegmentedTimeline.Segment other)

  Returns `true` if this segment is wholly before another segment.

  Parameters:
    `other` - the other segment.
  Returns:
    A boolean.

### after

    public boolean after(SegmentedTimeline.Segment other)

  Returns `true` if this segment is wholly after another segment.

  Parameters:
    `other` - the other segment.
  Returns:
    A boolean.

### equals

    public boolean equals(java.lang.Object object)

  Tests an object (usually another `Segment`) for equality with this segment.

  Parameters:
    `object` - The other segment to compare with us
  Returns:
    true if we are the same segment

### copy

    public SegmentedTimeline.Segment copy()

  Returns a copy of ourselves or `null` if there was an exception during cloning.

  Returns:
    A copy of this segment.

### compareTo

    public int compareTo(java.lang.Object object)

  Will compare this Segment with another Segment (from Comparable interface).

  Specified by:
    `compareTo` in interface `java.lang.Comparable`
  Parameters:
    `object` - The other Segment to compare with
  Returns:
    -1: this < object, 0: this.equal(object) and +1: this > object

### inIncludeSegments

    public boolean inIncludeSegments()

  Returns true if we are an included segment and we are not an exception.

  Returns:
    `true` or `false`.

### inExcludeSegments

    public boolean inExcludeSegments()

  Returns true if we are an excluded segment.

  Returns:
    `true` or `false`.

### inExceptionSegments

    public boolean 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:
    true if we are an exception segment.

### inc

    public void inc(long n)

  Increments the internal attributes of this segment by a number of segments.

  Parameters:
    `n` - Number of segments to increment.

### inc

    public void inc()

  Increments the internal attributes of this segment by one segment. The exact time incremented is segmentSize.

### dec

    public void dec(long n)

  Decrements the internal attributes of this segment by a number of segments.

  Parameters:
    `n` - Number of segments to decrement.

### dec

    public void dec()

  Decrements the internal attributes of this segment by one segment. The exact time decremented is segmentSize.

### moveIndexToStart

    public void moveIndexToStart()

  Moves the index of this segment to the beginning if the segment.

### moveIndexToEnd

    public void moveIndexToEnd()

  Moves the index of this segment to the end of the segment.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD