public class TimeSlider extends JComponent implements MouseListener, MouseMotionListener
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
protected List<TimeRange> |
actualTimeRanges
List of valid times ranges, taking into account the minimum and maximum
|
protected double |
end
The end of the selected time range.
|
protected JButton |
endButton
The button used to indicate the end time.
|
protected boolean |
left |
protected double |
maximum
The maximum time.
|
static long |
MILLIS_BY_DAY |
static long |
MILLIS_BY_HOUR |
static long |
MILLIS_BY_MINUTE |
static long |
MILLIS_BY_MONTH |
static long |
MILLIS_BY_SECOND |
static long |
MILLIS_BY_WEEK |
static long |
MILLIS_BY_YEAR |
protected double |
minimum
The minimum time.
|
protected boolean |
right |
protected double |
start
The start of the selected time range.
|
protected JButton |
startButton
The button used to indicate the start time.
|
protected List<TimeRange> |
timeRanges
List of event markers. * protected final List
|
protected double |
value
The selected time.
|
protected JButton |
valueButton
The button used to indicate the time.
|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
TimeSlider(boolean isAbsolute)
Creates a time slider with the maximum available range.
|
Modifier and Type | Method and Description |
---|---|
void |
addTimeAdjustmentListener(TimeAdjustmentListener l)
Add a listener for time adjustments.
|
void |
clearTimeRanges()
Remove all time ranges.
|
JToolTip |
createToolTip()
Creates the tooltip for the component.
|
void |
doLayout()
Layout the buttons.
|
protected void |
fireBoundsChanged()
Fires a bounds changed event to all adjustment listeners.
|
void |
fireRangeChanged()
Fires a range changed event to all adjustment listeners.
|
void |
fireValueChanged()
Fires a value changed event to all adjustment listeners.
|
double |
getActualMaximum()
Get the maximum value allowed on the time slider.
|
double |
getActualMinimum()
Get the minimum value allowed on the time slider.
|
Instant |
getCurrentInstant()
Get the current DateTime if the value is changeable or null if the value
isn't changeable.
|
Instant |
getEndInstant()
Returns a DateTime instance to represents the end date
|
double |
getMaximum()
Gets the maximum allowed time value.
|
double |
getMinimum()
Gets the minimum allowed time value.
|
Dimension |
getMinimumSize()
Get the minimum dimensions for this component.
|
double |
getNextValidTime(double time)
Get a time that is valid and greater than or equal to the current one.
|
Dimension |
getPreferredSize()
Get the preferred size for this component.
|
Instant |
getStartInstant()
Gets the text for the tooltip.
|
boolean |
getValueChangeable() |
boolean |
isTimeValid(double time)
Tell if the time is valid with respect to the current time bounds and
ranges.
|
boolean |
isValueAdjusting()
Indicates if the value is being continuously changed in the UI.
|
void |
mouseClicked(MouseEvent me)
Called when the mouse is clicked.
|
void |
mouseDragged(MouseEvent me)
Called when the mouse is dragged.
|
void |
mouseEntered(MouseEvent me) |
void |
mouseExited(MouseEvent me) |
void |
mouseMoved(MouseEvent me) |
void |
mousePressed(MouseEvent me)
Called when the mouse is pressed.
|
void |
mouseReleased(MouseEvent me)
Called whn the mouse is released.
|
void |
moveLeft(boolean left) |
void |
moveRight(boolean right) |
protected void |
paintComponent(Graphics g)
Paint the components.
|
void |
removeTimeAdjustmentListener(TimeAdjustmentListener l)
Remove a listener for time adjustments.
|
void |
resetAllDates()
Reset all dates
|
void |
resetMaximumBound()
Reset to maximum date
|
void |
resetMinimumBound()
Reset to minimum date
|
void |
resetValue()
Reset to initial value date
|
void |
setCurrentInstant(Instant currentInstant)
Sets the current time of the slider
|
void |
setEnabled(boolean enabled)
Sets if this component is enabled.
|
void |
setEndInstant(Instant endInstant)
Sets the end DateTime of the slider
|
void |
setRangeChangeable(boolean changeable)
Set if a time range can be changed via the UI elements
|
void |
setStartInstant(Instant startInstant)
Set the start DateTime of the slider
|
void |
setTimeRanges(List<TimeRange> newTimeRanges)
Replace the current set of time ranges with this one.
|
void |
setValueChangeable(boolean changeable)
Sets if the time value of the slider can be changed by the UI element.
|
void |
setValues(Instant minimunInstant,
Instant maximumInstant) |
void |
setValueVisible(boolean visible)
Set if the value is visible in the slider UI.
|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public static final long MILLIS_BY_SECOND
public static final long MILLIS_BY_MINUTE
public static final long MILLIS_BY_HOUR
public static final long MILLIS_BY_DAY
public static final long MILLIS_BY_WEEK
public static final long MILLIS_BY_MONTH
public static final long MILLIS_BY_YEAR
protected double minimum
protected double start
protected double value
protected double end
protected double maximum
protected final List<TimeRange> timeRanges
protected final List<TimeRange> actualTimeRanges
protected final JButton startButton
protected final JButton valueButton
protected final JButton endButton
protected boolean right
protected boolean left
public TimeSlider(boolean isAbsolute)
public void setValueChangeable(boolean changeable)
changeable
- if true, the value can be changed, false otherwise.public boolean getValueChangeable()
public void setValueVisible(boolean visible)
visible
- if true the value is shown, if false the value is not shownpublic void setRangeChangeable(boolean changeable)
changeable
- if true, the time range can be changed, false otherwsiepublic void moveRight(boolean right)
public void moveLeft(boolean left)
public void setCurrentInstant(Instant currentInstant)
current
- public void setStartInstant(Instant startInstant)
start
- public void setEndInstant(Instant endInstant)
end
- public double getMinimum()
public double getMaximum()
public void resetMinimumBound()
public void resetMaximumBound()
public void resetValue()
public void resetAllDates()
public void setTimeRanges(List<TimeRange> newTimeRanges)
newTimeRanges
- a list of time rangespublic boolean isTimeValid(double time)
time
- the time to checkpublic double getNextValidTime(double time)
public void clearTimeRanges()
public boolean isValueAdjusting()
public double getActualMinimum()
public double getActualMaximum()
protected void paintComponent(Graphics g)
paintComponent
in class JComponent
public Dimension getMinimumSize()
getMinimumSize
in class JComponent
public Dimension getPreferredSize()
getPreferredSize
in class JComponent
public JToolTip createToolTip()
createToolTip
in class JComponent
public Instant getStartInstant()
me
- the mouse event that triggered thispublic Instant getEndInstant()
public Instant getCurrentInstant()
public void mouseDragged(MouseEvent me)
mouseDragged
in interface MouseMotionListener
me
- the mosue event that triggered thispublic void mousePressed(MouseEvent me)
mousePressed
in interface MouseListener
me
- the mouse event that triggered thispublic void mouseReleased(MouseEvent me)
mouseReleased
in interface MouseListener
me
- the mouse event that triggered thispublic void mouseMoved(MouseEvent me)
mouseMoved
in interface MouseMotionListener
public void mouseClicked(MouseEvent me)
mouseClicked
in interface MouseListener
me
- the mouse event that triggered thispublic void mouseEntered(MouseEvent me)
mouseEntered
in interface MouseListener
public void mouseExited(MouseEvent me)
mouseExited
in interface MouseListener
public void addTimeAdjustmentListener(TimeAdjustmentListener l)
l
- the listener to addpublic void removeTimeAdjustmentListener(TimeAdjustmentListener l)
l
- the listener to removepublic void fireValueChanged()
public void fireRangeChanged()
protected void fireBoundsChanged()
public void setEnabled(boolean enabled)
setEnabled
in class JComponent
enabled
- true if this component should be enabled, false otherwise