com.dlsc.flexgantt.swing.selector
Class Selector

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by javax.swing.JWindow
                  extended by com.dlsc.flexgantt.swing.selector.Selector
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.LayoutManager, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.RootPaneContainer
Direct Known Subclasses:
ActionSelector, BookmarksSelector, ColumnChooserSelector, GranularitySelector, GridSelector, LayerSelector, OverviewSelector, PagingSelector, SimpleGranularityHorizonSelector, TimeGranularityGotoSelector, TimeGranularityHorizonSelector, TimeZoneSelector

public class Selector
extends javax.swing.JWindow
implements java.awt.LayoutManager

A selector is a window without any decorations that contains a single component and a title. The window can be animated depending on the Java version and platform used (requires Java 6 or higher). The selector is hooked to a 'parent' component and will be shown on the top, or the bottom, or to the left or to the right of this parent component.

The animation behaviour of selectors can be controlled globally via static method calls. This way the animation can be turned off if not desired.

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

Nested Class Summary
static class Selector.Location
          An enumator used for indicating where the selector window will be shown.
 
Nested classes/interfaces inherited from class javax.swing.JWindow
javax.swing.JWindow.AccessibleJWindow
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
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.JWindow
accessibleContext, rootPane, rootPaneCheckingEnabled
 
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
Selector(java.lang.String title, javax.swing.JComponent parentComponent, javax.swing.JComponent contentComponent, Selector.Location location)
          Constructs a new selector window.
Selector(java.lang.String title, javax.swing.JComponent parentComponent, Selector.Location location)
          Constructs a new selector window without specifying a content component.
 
Method Summary
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
           
 javax.swing.JLabel getCloseSelectorLabel()
          Returns the label used for closing the selector.
 javax.swing.JComponent getContentComponent()
          Returns the component that is shown as the selector 'content'.
 javax.swing.JPanel getFooterPanel()
          Returns the panel used as a footer in the bottom of the selector.
static int getGlobalAnimationDuration()
          Returns the duration used for the show / hide animation.
 javax.swing.JPanel getHeaderPanel()
          Returns the panel that contains the title label and the close icon.
 javax.swing.JComponent getParentComponent()
          Returns the parent component, which is the component to which the selector window gets hooked.
 Selector.Location getSelectorLocation()
          Returns the location where the selector will appear (above, below, to the left, or to the right of the parent component).
 javax.swing.JLabel getTitleLabel()
          Returns the label used for displaying the title of the selector window.
 boolean isAnimationEnabled()
          Returns the flag that individually determines whether the selector will use an animation to show or hide itself.
static boolean isGlobalAnimationEnabled()
          Returns the (global) flag for signalling whether all selectors will use an animation when showing up or hiding.
 void layoutContainer(java.awt.Container parent)
           
 java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
           
 java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
           
 void removeLayoutComponent(java.awt.Component comp)
           
 void setAnimationEnabled(boolean enabled)
          Sets the flag that individually determines whether the selector will use an animation to show or hide itself.
 void setContentComponent(javax.swing.JComponent comp)
          Sets the content of the selector window.
static void setGlobalAnimationDuration(int duration)
          Sets the duration used for the show / hide animation.
static void setGlobalAnimationEnabled(boolean enabled)
          Specifies whether the selector windows will use animations when showing or hiding themselves.
 void setVisible(boolean b)
          Overrides the standard method in order to implement a nice looking animation (slide in / out) of the selector window.
 
Methods inherited from class javax.swing.JWindow
addImpl, createRootPane, getAccessibleContext, getContentPane, getGlassPane, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, remove, setContentPane, setGlassPane, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update, windowInit
 
Methods inherited from class java.awt.Window
addNotify, addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, finalize, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Selector

public Selector(java.lang.String title,
                javax.swing.JComponent parentComponent,
                javax.swing.JComponent contentComponent,
                Selector.Location location)
Constructs a new selector window.

Parameters:
title - the title of the selector window
parentComponent - the parent component to which the selector gets hooked
contentComponent - the content component that will be shown inside the selector
location - the location where the selector window will be shown
Since:
1.0

Selector

public Selector(java.lang.String title,
                javax.swing.JComponent parentComponent,
                Selector.Location location)
Constructs a new selector window without specifying a content component. Use setContentComponent(JComponent) to set the component before the selector gets shown for the first time.

Parameters:
title - the title of the selector window
parentComponent - the parent component to which the selector gets hooked
location - the location where the selector window will be shown
Since:
1.0
Method Detail

setContentComponent

public void setContentComponent(javax.swing.JComponent comp)
Sets the content of the selector window.

Parameters:
comp - the content component
Since:
1.0

getContentComponent

public javax.swing.JComponent getContentComponent()
Returns the component that is shown as the selector 'content'.

Returns:
the content component
Since:
1.0

setVisible

public void setVisible(boolean b)
Overrides the standard method in order to implement a nice looking animation (slide in / out) of the selector window. Several checks will be performed before actually performing the animation. The Java version used needs to be at least Java 6 or higher and animations need to be enabled (which can be controlled for each selector but also globally).

Overrides:
setVisible in class java.awt.Component
Since:
1.0
See Also:
setAnimationEnabled(boolean), setGlobalAnimationEnabled(boolean)

isAnimationEnabled

public boolean isAnimationEnabled()
Returns the flag that individually determines whether the selector will use an animation to show or hide itself.

Returns:
TRUE if the selector window uses an animation to show or hide itself
Since:
1.0

setAnimationEnabled

public void setAnimationEnabled(boolean enabled)
Sets the flag that individually determines whether the selector will use an animation to show or hide itself.

Parameters:
enabled - if TRUE if the selector window uses an animation to show or hide itself
Since:
1.0

getParentComponent

public javax.swing.JComponent getParentComponent()
Returns the parent component, which is the component to which the selector window gets hooked. The selector window will show up in a location relative to the parent component (above, below, left, right).

Returns:
the parent component to which the selector window is hooked
Since:
1.0

addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component comp)
Specified by:
addLayoutComponent in interface java.awt.LayoutManager

layoutContainer

public void layoutContainer(java.awt.Container parent)
Specified by:
layoutContainer in interface java.awt.LayoutManager

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
Specified by:
minimumLayoutSize in interface java.awt.LayoutManager

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
Specified by:
preferredLayoutSize in interface java.awt.LayoutManager

removeLayoutComponent

public void removeLayoutComponent(java.awt.Component comp)
Specified by:
removeLayoutComponent in interface java.awt.LayoutManager

getSelectorLocation

public Selector.Location getSelectorLocation()
Returns the location where the selector will appear (above, below, to the left, or to the right of the parent component).

Returns:
the (relative) location of the selector window
Since:
1.0

getTitleLabel

public javax.swing.JLabel getTitleLabel()
Returns the label used for displaying the title of the selector window.

Returns:
the title label
Since:
1.0

getHeaderPanel

public javax.swing.JPanel getHeaderPanel()
Returns the panel that contains the title label and the close icon.

Returns:
the header panel
Since:
1.0

isGlobalAnimationEnabled

public static boolean isGlobalAnimationEnabled()
Returns the (global) flag for signalling whether all selectors will use an animation when showing up or hiding.

Returns:
the flag that controls the selector animations globally
Since:
1.0

setGlobalAnimationEnabled

public static void setGlobalAnimationEnabled(boolean enabled)
Specifies whether the selector windows will use animations when showing or hiding themselves.

Parameters:
enabled - if TRUE all selectors will use animations
Since:
1.0

getGlobalAnimationDuration

public static int getGlobalAnimationDuration()
Returns the duration used for the show / hide animation.

Returns:
the duration of the animation
Since:
1.0

setGlobalAnimationDuration

public static void setGlobalAnimationDuration(int duration)
Sets the duration used for the show / hide animation.

Parameters:
duration - the duration of the show / hide animation
Since:
1.0

getFooterPanel

public javax.swing.JPanel getFooterPanel()
Returns the panel used as a footer in the bottom of the selector.

Returns:
the footer panel
Since:
1.0

getCloseSelectorLabel

public javax.swing.JLabel getCloseSelectorLabel()
Returns the label used for closing the selector.

Returns:
the close label
Since:
1.0