org.ceryle.util.timeline
Class TimeScale

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.ArrayList
              extended by org.ceryle.util.timeline.TimeScale
All Implemented Interfaces:
Serializable, Cloneable, Iterable, Collection, List, RandomAccess

public class TimeScale
extends ArrayList

A subclass of java.util.ArrayList used to store a time scale, including major and minor tick marks and the major tick labels. TimeScale is the binding between date/time values and pixels, and contains the conversion methods getOffsetFromDate(Date) and getDateFromOffset(int).

This class is for use with TimeLine, which populates a TimeScale with null values for minor ticks and Strings acting as the major tick labels. The major and minor tick fields (ie., which date unit) are found in TimeLine:

NOTE: TimeLine.FIELD_WEEK is not used as a major or minor TimeScale field.

Since:
JDK1.3
Version:
$Id: TimeScale.java,v 3.3 2007-06-15 12:10:05 altheim Exp $
Author:
Murray Altheim
See Also:
TimeLine, Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
TimeScale(int majorScaleIndex, int minorScaleIndex)
          Constructs an empty TimeScale with major and minor scale indices majorScaleIndex and minorScaleIndex (resp.).
TimeScale(int majorScaleIndex, int minorScaleIndex, Collection c)
          Constructs a TimeScale with major and minor scale indices majorScaleIndex and minorScaleIndex (resp.) from the elements of the Collection c, in the order they are returned by the collection's iterator.
TimeScale(int majorScaleIndex, int minorScaleIndex, int count)
          Constructs an empty TimeScale with major and minor scale indices majorScaleIndex and minorScaleIndex (resp.), with an initial number of minor ticks count.
 
Method Summary
 int getLength()
          Returns the length in pixels of this TimeScale based upon the current value of pixels/tick.
 int getMajorScaleIndex()
          Returns the major scale index for this TimeScale (TimeLine.FIELD_CENTURY through TimeLine.FIELD_SECOND).
 int getMinorScaleIndex()
          Returns the minor scale index for this TimeScale (TimeLine.FIELD_CENTURY through TimeLine.FIELD_SECOND).
 int getPixelsPerTick()
          Returns the pixels/tick of this TimeScale.
 void setPixelsPerTick(int pixelsPerTick)
          Sets the pixels/tick of this TimeScale.
 String toString()
          Overrides the toString() method of java.util.AbstractCollection in providing a string representation of this TimeScale.
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, removeAll, retainAll
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, removeAll, retainAll, subList
 

Constructor Detail

TimeScale

public TimeScale(int majorScaleIndex,
                 int minorScaleIndex)
Constructs an empty TimeScale with major and minor scale indices majorScaleIndex and minorScaleIndex (resp.).


TimeScale

public TimeScale(int majorScaleIndex,
                 int minorScaleIndex,
                 Collection c)
Constructs a TimeScale with major and minor scale indices majorScaleIndex and minorScaleIndex (resp.) from the elements of the Collection c, in the order they are returned by the collection's iterator.


TimeScale

public TimeScale(int majorScaleIndex,
                 int minorScaleIndex,
                 int count)
Constructs an empty TimeScale with major and minor scale indices majorScaleIndex and minorScaleIndex (resp.), with an initial number of minor ticks count.

Method Detail

getMajorScaleIndex

public int getMajorScaleIndex()
Returns the major scale index for this TimeScale (TimeLine.FIELD_CENTURY through TimeLine.FIELD_SECOND).


getMinorScaleIndex

public int getMinorScaleIndex()
Returns the minor scale index for this TimeScale (TimeLine.FIELD_CENTURY through TimeLine.FIELD_SECOND).


setPixelsPerTick

public void setPixelsPerTick(int pixelsPerTick)
                      throws ProcessException
Sets the pixels/tick of this TimeScale. Acceptable values are between 2 and 100.

Throws:
ProcessException - if the provided value is out of range

getPixelsPerTick

public int getPixelsPerTick()
Returns the pixels/tick of this TimeScale.


getLength

public int getLength()
Returns the length in pixels of this TimeScale based upon the current value of pixels/tick.


toString

public String toString()
Overrides the toString() method of java.util.AbstractCollection in providing a string representation of this TimeScale.

Overrides:
toString in class AbstractCollection


The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.