com.dlsc.flexgantt.swing.timeline
Class AbstractTimelineControlPanel<T extends IGranularity>

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by com.dlsc.flexgantt.swing.timeline.AbstractTimelineControlPanel<T>
Type Parameters:
T - the type of the granularity used by the dateline model
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.ChangeListener
Direct Known Subclasses:
SimpleGranularityTimelineControlPanel, TimeGranularityTimelineControlPanel

public abstract class AbstractTimelineControlPanel<T extends IGranularity>
extends javax.swing.JPanel
implements javax.swing.event.ChangeListener, java.awt.event.ActionListener

A panel used for controlling the time span and the granularity displayed by the timeline.

Since:
1.0
Author:
Dirk Lemmermann
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
protected AbstractTimelineControlPanel(Timeline timeline, boolean showGranularity)
          Constructs a new control panel.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
           
protected abstract  void applySettings()
          Applys the settings made in the control panel to the timeline.
protected abstract  javax.swing.SpinnerModel createEndTimeModel()
          Creates the model for the end time spinner.
protected abstract  javax.swing.ComboBoxModel createGranularityModel()
          Creates the model for the granularity combo box.
protected abstract  javax.swing.SpinnerModel createStartTimeModel()
          Creates the model for the start time spinner.
 javax.swing.JButton getApplyButton()
          Returns the button used for applying the settings to the timeline.
 javax.swing.SpinnerModel getEndTimeModel()
          Returns the spinner model used for the end time.
 javax.swing.JSpinner getEndTimeSpinner()
          Returns the spinner used for editing the end time.
 javax.swing.JLabel getFromLabel()
          Returns the label used for labelling the from spiner.
 T getGranularity()
          Returns the granularity shown in the combo box (not the one used by the timeline).
 javax.swing.JComboBox getGranularityBox()
          Returns the combo box used for selecting the granularity.
 javax.swing.JLabel getGranularityLabel()
          Returns the label used for labelling the granularity combo box.
 javax.swing.ComboBoxModel getGranularityModel()
          Returns the combo box model used by the granularity combo box.
 javax.swing.SpinnerModel getStartTimeModel()
          Returns the spinner model used for the start time.
 javax.swing.JSpinner getStartTimeSpinner()
          Returns the spinner used for editing the start time.
 Timeline getTimeline()
          Returns the timeline that is being controlled by the panel.
abstract  ITimeSpan getTimeSpan()
          Returns the time span shown by the panel (not the timeline)
 javax.swing.JLabel getToLabel()
          Returns the label used for labelling the to spiner.
abstract  boolean isValidSettings()
          Checks whether the current settings are valid (end time is larger or equal to start time).
 void setGranularity(T value)
          Sets a granularity to be shown in the granularity selector / combo box.
protected abstract  void setTimeSpan(ITimeSpan span)
          Sets the time span shown by the panel (not on the timeline, updates the start and end spinner).
 void stateChanged(javax.swing.event.ChangeEvent evt)
           
abstract  void updateControlPanel()
          Updates the control panel to reflect the current settings of the timeline.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, 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, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, 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, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
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, hide, 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, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractTimelineControlPanel

protected AbstractTimelineControlPanel(Timeline timeline,
                                       boolean showGranularity)
Constructs a new control panel.

Parameters:
timeline - the timeline controlled by the panel
showGranularity - if TRUE the controls for changing the granularity will be shown
Since:
1.0
Method Detail

updateControlPanel

public abstract void updateControlPanel()
Updates the control panel to reflect the current settings of the timeline.

Since:
1.0

createStartTimeModel

protected abstract javax.swing.SpinnerModel createStartTimeModel()
Creates the model for the start time spinner.

Returns:
a spinner model
Since:
1.0

createEndTimeModel

protected abstract javax.swing.SpinnerModel createEndTimeModel()
Creates the model for the end time spinner.

Returns:
a spinner model
Since:
1.0

createGranularityModel

protected abstract javax.swing.ComboBoxModel createGranularityModel()
Creates the model for the granularity combo box.

Returns:
a combo box model
Since:
1.0

setTimeSpan

protected abstract void setTimeSpan(ITimeSpan span)
Sets the time span shown by the panel (not on the timeline, updates the start and end spinner).

Parameters:
span - the timeline's time span
Since:
1.0

getTimeSpan

public abstract ITimeSpan getTimeSpan()
Returns the time span shown by the panel (not the timeline)

Returns:
the panel's time span
Since:
1.0

isValidSettings

public abstract boolean isValidSettings()
Checks whether the current settings are valid (end time is larger or equal to start time).

Returns:
TRUE if the current settings made in the panel are consistent / valid
Since:
1.0

setGranularity

public void setGranularity(T value)
Sets a granularity to be shown in the granularity selector / combo box.

Parameters:
value - the value to show in the combo box
Since:
1.0

getGranularity

public T getGranularity()
Returns the granularity shown in the combo box (not the one used by the timeline).

Returns:
the current granularity selected in the combo box
Since:
1.0

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent evt)
Specified by:
stateChanged in interface javax.swing.event.ChangeListener

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

applySettings

protected abstract void applySettings()
Applys the settings made in the control panel to the timeline.

Since:
1.0

getEndTimeModel

public javax.swing.SpinnerModel getEndTimeModel()
Returns the spinner model used for the end time.

Returns:
the end time spinner model
Since:
1.0

getEndTimeSpinner

public javax.swing.JSpinner getEndTimeSpinner()
Returns the spinner used for editing the end time.

Returns:
the end time spinner
Since:
1.0

getStartTimeModel

public javax.swing.SpinnerModel getStartTimeModel()
Returns the spinner model used for the start time.

Returns:
the start time spinner model
Since:
1.0

getStartTimeSpinner

public javax.swing.JSpinner getStartTimeSpinner()
Returns the spinner used for editing the start time.

Returns:
the start time spinner
Since:
1.0

getGranularityBox

public javax.swing.JComboBox getGranularityBox()
Returns the combo box used for selecting the granularity.

Returns:
the granularity combo box
Since:
1.0

getGranularityModel

public javax.swing.ComboBoxModel getGranularityModel()
Returns the combo box model used by the granularity combo box.

Returns:
the granularity combo box model
Since:
1.0

getTimeline

public Timeline getTimeline()
Returns the timeline that is being controlled by the panel.

Returns:
the controlled timeline
Since:
1.0

getApplyButton

public javax.swing.JButton getApplyButton()
Returns the button used for applying the settings to the timeline.

Returns:
the apply button
Since:
1.0

getFromLabel

public javax.swing.JLabel getFromLabel()
Returns the label used for labelling the from spiner.

Returns:
the label for the from spinner
Since:
1.0

getGranularityLabel

public javax.swing.JLabel getGranularityLabel()
Returns the label used for labelling the granularity combo box.

Returns:
the label for the granularity combo box
Since:
1.0

getToLabel

public javax.swing.JLabel getToLabel()
Returns the label used for labelling the to spiner.

Returns:
the label for the to spinner
Since:
1.0