com.dlsc.flexgantt.model
Enum SimpleGranularity

java.lang.Object
  extended by java.lang.Enum<SimpleGranularity>
      extended by com.dlsc.flexgantt.model.SimpleGranularity
All Implemented Interfaces:
IGranularity<SimpleGranularity>, java.io.Serializable, java.lang.Comparable<SimpleGranularity>

public enum SimpleGranularity
extends java.lang.Enum<SimpleGranularity>
implements IGranularity<SimpleGranularity>

An enumeration of possible simple granularities. The values in this enumerator are called simple because of their lack of complexity compared to the TimeGranularity enumerator. A simple enumerator value represents an order of 10 (1, 10, 100, 1000, 10000, 100000, ....). The documentation within this class uses the term milliseconds but the numbers could as well be called units or steps. If an application performs scheduling tasks that are based on units and steps instead of real time then it could easily use this enumerator.

Since:
1.0
Author:
Dirk Lemmermann
See Also:
SimpleGranularityDatelineModel, SimpleGranularityDatelineRenderer, SimpleGranularityGridPolicy

Enum Constant Summary
BILLION
          A granularity representing one billion milliseconds.
BILLION_HUNDRED
          A granularity representing one hundred billion milliseconds.
BILLION_TEN
          A granularity representing ten billion milliseconds.
HUNDRED
          A granularity representing one hundred milliseconds.
MILLION
          A granularity representing one million milliseconds.
MILLION_HUNDRED
          A granularity representing one hundred million milliseconds.
MILLION_TEN
          A granularity representing ten million milliseconds.
ONE
          A granularity representing one millisecond.
TEN
          A granularity representing ten milliseconds.
THOUSAND
          A granularity representing one thousand milliseconds.
THOUSAND_HUNDRED
          A granularity representing one hundred thousand milliseconds.
THOUSAND_TEN
          A granularity representing ten thousand milliseconds.
TRILLION
          A granularity representing one trillion milliseconds.
 
Method Summary
 long adjust(long time)
          Adjusts the given time point by rounding it down to the nearest multitude of the milliseconds represented by the granularity value.
 long decrement(long time)
          Decrements the given number of milliseconds with the milliseconds represented by the enumerator value.
 double getDelta(ITimeSpan span)
          Calculates how often the number of milliseconds represented by the time granularity fits into the difference between the given start and end times: (endTime - startTime) / millis.
 long getMillis()
          Returns the number of milliseconds represented by the granularity.
 java.lang.String getName()
          Returns the name of the granularity.
 long increment(long time)
          Increments the given number of milliseconds with the milliseconds represented by the enumerator value.
 boolean isLarger(SimpleGranularity sg)
          Checks whether this granularity is considered to be larger than the given one.
 boolean isSmaller(SimpleGranularity sg)
          Checks whether this granularity is considered to be smaller than the given one.
 SimpleGranularity next()
          Returns the next larger granularity (example: ONE -> TEN -> HUNDRED).
 SimpleGranularity previous()
          Returns the previous smaller granularity (example: HUNDRED -> TEN -> ONE).
static SimpleGranularity valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static SimpleGranularity[] values()
          Returns an array containing the constants of this enum type, in the order they're declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

ONE

public static final SimpleGranularity ONE
A granularity representing one millisecond.

Since:
1.0

TEN

public static final SimpleGranularity TEN
A granularity representing ten milliseconds.

Since:
1.0

HUNDRED

public static final SimpleGranularity HUNDRED
A granularity representing one hundred milliseconds.

Since:
1.0

THOUSAND

public static final SimpleGranularity THOUSAND
A granularity representing one thousand milliseconds.

Since:
1.0

THOUSAND_TEN

public static final SimpleGranularity THOUSAND_TEN
A granularity representing ten thousand milliseconds.

Since:
1.0

THOUSAND_HUNDRED

public static final SimpleGranularity THOUSAND_HUNDRED
A granularity representing one hundred thousand milliseconds.

Since:
1.0

MILLION

public static final SimpleGranularity MILLION
A granularity representing one million milliseconds.

Since:
1.0

MILLION_TEN

public static final SimpleGranularity MILLION_TEN
A granularity representing ten million milliseconds.

Since:
1.0

MILLION_HUNDRED

public static final SimpleGranularity MILLION_HUNDRED
A granularity representing one hundred million milliseconds.

Since:
1.0

BILLION

public static final SimpleGranularity BILLION
A granularity representing one billion milliseconds.

Since:
1.0

BILLION_TEN

public static final SimpleGranularity BILLION_TEN
A granularity representing ten billion milliseconds.

Since:
1.0

BILLION_HUNDRED

public static final SimpleGranularity BILLION_HUNDRED
A granularity representing one hundred billion milliseconds.

Since:
1.0

TRILLION

public static final SimpleGranularity TRILLION
A granularity representing one trillion milliseconds.

Since:
1.0
Method Detail

values

public static final SimpleGranularity[] values()
Returns an array containing the constants of this enum type, in the order they're declared. This method may be used to iterate over the constants as follows:
for(SimpleGranularity c : SimpleGranularity.values())
        System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they're declared

valueOf

public static SimpleGranularity valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name

getName

public java.lang.String getName()
Description copied from interface: IGranularity
Returns the name of the granularity.

Specified by:
getName in interface IGranularity<SimpleGranularity>
Returns:
the name of the granularity

increment

public long increment(long time)
Increments the given number of milliseconds with the milliseconds represented by the enumerator value.

Parameters:
time - the time to increment
Returns:
the given time plus the milliseconds represented by the value
Since:
1.0

decrement

public long decrement(long time)
Decrements the given number of milliseconds with the milliseconds represented by the enumerator value.

Parameters:
time - the time to increment
Returns:
the given time minus the milliseconds represented by the value
Since:
1.0

adjust

public long adjust(long time)
Adjusts the given time point by rounding it down to the nearest multitude of the milliseconds represented by the granularity value. Example: the granularity THOUSAND would adjust the time point 4366 to 4000.

Parameters:
time - the time that needs adjustment
Returns:
a number of milliseconds that is a multitude of the number of milliseconds represented by the enumerator value and that is still smaller than the given time
Since:
1.0

getMillis

public long getMillis()
Returns the number of milliseconds represented by the granularity.

Returns:
number of milliseconds represented by the granularity
Since:
1.0

getDelta

public double getDelta(ITimeSpan span)
Calculates how often the number of milliseconds represented by the time granularity fits into the difference between the given start and end times: (endTime - startTime) / millis.

Parameters:
span - the time span for which to return the delta
Returns:
the delta between the start and the end time
Since:
1.0

next

public SimpleGranularity next()
Returns the next larger granularity (example: ONE -> TEN -> HUNDRED).

Returns:
the next larger simple granularity
Since:
1.0

previous

public SimpleGranularity previous()
Returns the previous smaller granularity (example: HUNDRED -> TEN -> ONE).

Returns:
the previous smaller simple granularity
Since:
1.0

isSmaller

public boolean isSmaller(SimpleGranularity sg)
Checks whether this granularity is considered to be smaller than the given one. Example:

SimpleGranularity.THOUSAND.isSmaller(SimpleGranularity.HUNDRED)

would return FALSE since one thousand milliseconds is a larger number than one hundred milliseconds.

Specified by:
isSmaller in interface IGranularity<SimpleGranularity>
Parameters:
sg - the granularity to compare with
Returns:
TRUE if this granularity is smaller than the given granularity
Since:
1.0

isLarger

public boolean isLarger(SimpleGranularity sg)
Checks whether this granularity is considered to be larger than the given one. Example:

SimpleGranularity.THOUSAND.isLarger(SimpleGranularity.HUNDRED)

would return TRUE since one thousand milliseconds is a larger number than one hundred milliseconds.

Specified by:
isLarger in interface IGranularity<SimpleGranularity>
Parameters:
sg - the granularity to compare with
Returns:
TRUE if this granularity is larger than the given granularity
Since:
1.0