lu.tudor.santec.jtimechooser
Class TimeUnit

java.lang.Object
  extended by lu.tudor.santec.jtimechooser.TimeUnit

public class TimeUnit
extends java.lang.Object

Author:
jens.ferring(at)tudor.lu This TimeUnit is supposed to keep and select the correct data for a JTimeChooser.
It is used for the MouseEvents of the JTimeChooser.

Field Summary
static int NO_TIME_UNIT_SELECTED
           
 
Constructor Summary
TimeUnit(TimeChooserModel model)
           
 
Method Summary
 void decreaseRounds()
          Decreases the number of rounds by 1.
 int getMaxValue()
          If this value is crossed, the rounds shall be increased.
 int getPixelPerHour()
           
 int getPixelPerMinute()
           
 int getPixelPerSecond()
           
 int getPixelPerUnit()
           
 int getRounds()
          When the users drags the mouse and increases or decreases the value of the time unit, the value of the next upper time unit will be changed, if the min or max value is crossed.
 int getScrollAmountPerUnit()
           
 int getScrollsPerHour()
           
 int getScrollsPerMinute()
           
 int getScrollsPerSecond()
           
 int getTimeUnit()
           
 int getValue()
           
 void increaseRounds()
          Increases the number of rounds by 1.
 boolean isTimeUnitValid()
           
 void reset()
          Resets the data.
 void setPixelPerHour(int pixelPerHour)
          Sets how many pixels must be dragged to change the hours by 1.
 void setPixelPerMinute(int pixelPerMinute)
          Sets how many pixels must be dragged to change the minutes by 1.
 void setPixelPerSecond(int pixelPerSecond)
          Sets how many pixels must be dragged to change the seconds by 1.
 void setScrollsPerHour(int scrollsPerHour)
           
 void setScrollsPerMinute(int scrollsPerMinute)
           
 void setScrollsPerSecond(int scrollsPerSecond)
           
 void setTimeUnit(int caretPosition)
          The caret position is crucial for which time unit is set.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_TIME_UNIT_SELECTED

public static final int NO_TIME_UNIT_SELECTED
See Also:
Constant Field Values
Constructor Detail

TimeUnit

public TimeUnit(TimeChooserModel model)
Parameters:
chooser - The JTimeChooser this TimeUnit keeps the data for.
Method Detail

reset

public void reset()
Resets the data. Should be called after the mouse was released.


getTimeUnit

public int getTimeUnit()
Returns:
The current time unit.

setTimeUnit

public void setTimeUnit(int caretPosition)
The caret position is crucial for which time unit is set.

Parameters:
caretPosition - the caret position of the JTimeChooser text field.

isTimeUnitValid

public boolean isTimeUnitValid()
Returns:
is the TimeUnit valid

getValue

public int getValue()
Returns:
the value of the selected time unit when the time unit was set.

getRounds

public int getRounds()
When the users drags the mouse and increases or decreases the value of the time unit, the value of the next upper time unit will be changed, if the min or max value is crossed. One round counts, how often this value is crossed.
0 means the max or min value wasn't crossed. A negative value counts how often the value was lower than 0.

Returns:
The number of rounds.

increaseRounds

public void increaseRounds()
Increases the number of rounds by 1.


decreaseRounds

public void decreaseRounds()
Decreases the number of rounds by 1.


getMaxValue

public int getMaxValue()
If this value is crossed, the rounds shall be increased.

Returns:
The max value for the set time unit.

getPixelPerUnit

public int getPixelPerUnit()
Returns:
Defines how many pixels must be dragged, to change the value of the time unit by 1.

getScrollAmountPerUnit

public int getScrollAmountPerUnit()
Returns:
Defines by what the value is in- / decreased, if the mouse wheel is rotated.

getPixelPerHour

public int getPixelPerHour()
Returns:
Defines how many pixels must be dragged, to change the hours by 1.

setPixelPerHour

public void setPixelPerHour(int pixelPerHour)
Sets how many pixels must be dragged to change the hours by 1.

Parameters:
pixelPerHour -

getPixelPerMinute

public int getPixelPerMinute()
Returns:
Defines how many pixels must be dragged, to change the minutes by 1.

setPixelPerMinute

public void setPixelPerMinute(int pixelPerMinute)
Sets how many pixels must be dragged to change the minutes by 1.

Parameters:
pixelPerMinute -

getPixelPerSecond

public int getPixelPerSecond()
Returns:
Defines how many pixels must be dragged, to change the seconds by 1.

setPixelPerSecond

public void setPixelPerSecond(int pixelPerSecond)
Sets how many pixels must be dragged to change the seconds by 1.

Parameters:
pixelPerSecond -

getScrollsPerHour

public int getScrollsPerHour()
Returns:
Defines by what value the hours are in- / decreased, if the mouse wheel is rotated.

setScrollsPerHour

public void setScrollsPerHour(int scrollsPerHour)
Parameters:
scrollsPerHour - The value the hours are in- / decreased, if the mouse wheel is rotated.

getScrollsPerMinute

public int getScrollsPerMinute()
Returns:
Defines by what value the minutes are in- / decreased, if the mouse wheel is rotated.

setScrollsPerMinute

public void setScrollsPerMinute(int scrollsPerMinute)
Parameters:
scrollsPerMinute - The value the minutes are in- / decreased, if the mouse wheel is rotated.

getScrollsPerSecond

public int getScrollsPerSecond()
Returns:
Defines by what value the seconds are in- / decreased, if the mouse wheel is rotated.

setScrollsPerSecond

public void setScrollsPerSecond(int scrollsPerSecond)
Parameters:
scrollsPerSecond - The value the seconds are in- / decreased, if the mouse wheel is rotated.