ehsbe CommonsTM
Version 1.1.0rc3

com.ehsbe.commons.gui.wizard
Class Sidebar

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 org.jdesktop.swingx.JXPanel
                      extended by org.jdesktop.swingx.JXImagePanel
                          extended by com.ehsbe.commons.gui.wizard.Sidebar
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, Scrollable

public class Sidebar
extends org.jdesktop.swingx.JXImagePanel

A sidebar Panel, which displays a background image and short description of tasks to execute.

If insets are set, the background image gets centered and clipped wrt. the remaining space. If margins are set, the task descriptions are indented wrt. the given insets.

Version:
$Revision: 495 $
Author:
Jens Elkner
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jdesktop.swingx.JXImagePanel
org.jdesktop.swingx.JXImagePanel.Style
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  String DEFAULT_IMAGE
          default background image to use
 String PROPERTY_DEPTH
          property name of the event fired, when the depth of task descriptions to be displayed have been changed
 String PROPERTY_INDENT
          property name of the event fired, when the indent has been changed
 String PROPERTY_LINESPACE
          property name of the event fired, when the line spacing has been changed
 String PROPERTY_MARGIN
          property name of the event fired, when margins have been changed
 String PROPERTY_TASK
          property name of the event fired, when the active task has been changed
 
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
Sidebar()
          Create a default sidebar with a default background image, no insets and a margin of 5 pixels on all sides.
Sidebar(String imagePath)
          Create a default sidebar with no insets and a margin of 5 pixels on all sides.
 
Method Summary
 void adjustActive(TaskControl control)
          Adjust the display wrt. the new task in action.
 void adjustList(TaskControl control)
          Adjust the current list of task, i.e. reflect the change in the structure of a task tree.
 Font getBoldFont()
          Get the font, which is used to draw the description for the current task in action.
 int getDepth()
          Get the depth of task used to draw descriptions.
 int getIndent()
          Get the indent size as number of 'em's for nested descritions.
 int[] getLineSpacing()
          Get the spaces between the lines.
 Insets getMargins()
          Get the margins currently set.
 boolean isOptimizedDrawingEnabled()
          
protected  void paintComponent(Graphics g)
          
 void setBoldFont(Font boldFont)
          Set the font, which should be used to draw the description for the current task in action.
 void setDepth(int depth)
          Set the depth of tasks, which should be displayed in this panel.
 void setFont(Font font)
          
 void setImage(Image image)
          Same as JXImagePanel.setImage(Image), but waits 'til image loading is complete.
 void setImage(String imagePath)
          Set the image, which should be used as the background for this sidebar.
 void setIndent(int indent)
          Set the indent size as number of 'em's for nested descritions.
 void setLineSpacing(int[] spacing)
          Set the spaces between the lines.
 void setLocale(Locale l)
          
 void setMargins(Insets margins)
          Set the margins for the task descriptions to be displayed.
 
Methods inherited from class org.jdesktop.swingx.JXImagePanel
getImage, getPreferredSize, getStyle, isEditable, setDefaultImage, setEditable, setImageLoader, setStyle
 
Methods inherited from class org.jdesktop.swingx.JXPanel
getAlpha, getBackgroundPainter, getEffectiveAlpha, getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, isInheritAlpha, isPaintBorderInsets, paint, setAlpha, setBackground, setBackgroundPainter, setInheritAlpha, setPaintBorderInsets, setScrollableTracksViewportHeight, setScrollableTracksViewportWidth
 
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, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, 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, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, 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, 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
 

Field Detail

DEFAULT_IMAGE

protected String DEFAULT_IMAGE
default background image to use


PROPERTY_MARGIN

public String PROPERTY_MARGIN
property name of the event fired, when margins have been changed


PROPERTY_DEPTH

public String PROPERTY_DEPTH
property name of the event fired, when the depth of task descriptions to be displayed have been changed


PROPERTY_TASK

public String PROPERTY_TASK
property name of the event fired, when the active task has been changed


PROPERTY_INDENT

public String PROPERTY_INDENT
property name of the event fired, when the indent has been changed


PROPERTY_LINESPACE

public String PROPERTY_LINESPACE
property name of the event fired, when the line spacing has been changed

Constructor Detail

Sidebar

public Sidebar()
Create a default sidebar with a default background image, no insets and a margin of 5 pixels on all sides.


Sidebar

public Sidebar(String imagePath)
Create a default sidebar with no insets and a margin of 5 pixels on all sides.

Parameters:
imagePath - resource path of the background image to use. Might be null.
Method Detail

setImage

public void setImage(String imagePath)
Set the image, which should be used as the background for this sidebar.

NOTE: The path gets not tracked and thus causes always the image to be loaded, even if it is the same, which is already set!

Parameters:
imagePath - a resource path, i.e. which can be fetched via current ClassLoader.getResourceAsStream(String). If null a default image gets loaded.

setImage

public void setImage(Image image)
Same as JXImagePanel.setImage(Image), but waits 'til image loading is complete.

Overrides:
setImage in class org.jdesktop.swingx.JXImagePanel

getMargins

public Insets getMargins()
Get the margins currently set.

Returns:
the margins.

setMargins

public void setMargins(Insets margins)
Set the margins for the task descriptions to be displayed. So e.g. for left oriented text, the x position is this panels left inset plus the given left margin and analog for all other sides.

Parameters:
margins - margins to set. If null default values gets set.

setBoldFont

public void setBoldFont(Font boldFont)
Set the font, which should be used to draw the description for the current task in action.

Parameters:
boldFont - font to use. If null, the font gets derived from the Component.getFont().

getBoldFont

public Font getBoldFont()
Get the font, which is used to draw the description for the current task in action.

Returns:
the boldFont.

isOptimizedDrawingEnabled

public boolean isOptimizedDrawingEnabled()

Overrides:
isOptimizedDrawingEnabled in class JComponent

setDepth

public void setDepth(int depth)
Set the depth of tasks, which should be displayed in this panel. E.g. if 1, the description of the origins Task.getSubTasks() are drawn, only. If 2, the descriptions of the sub tasks will from all origins sub task will be drawn and so on.

Parameters:
depth - depth to set.

getDepth

public int getDepth()
Get the depth of task used to draw descriptions.

Returns:
the task depth.

setIndent

public void setIndent(int indent)
Set the indent size as number of 'em's for nested descritions.

Parameters:
indent - indent to set.

getIndent

public int getIndent()
Get the indent size as number of 'em's for nested descritions.

Returns:
the indent.

setLineSpacing

public void setLineSpacing(int[] spacing)
Set the spaces between the lines. Field 0 is the number of pixels before a task of depth 0, field 1 the number of pixels before a task of depth 1 and so on.

Parameters:
spacing - linespacing to set. If null default linespacing will be used.

getLineSpacing

public int[] getLineSpacing()
Get the spaces between the lines. Field 0 is the number of pixels before a task of depth 1, field 1 the number of pixels before a task of depth 2 and so on.

Returns:
line spacing used. Might be empty, but not null.

adjustActive

public void adjustActive(TaskControl control)
Adjust the display wrt. the new task in action.

Parameters:
control - controller of the current executing task.

adjustList

public void adjustList(TaskControl control)
Adjust the current list of task, i.e. reflect the change in the structure of a task tree.

Parameters:
control - controller of the current executing task.

setFont

public void setFont(Font font)

Overrides:
setFont in class JComponent

setLocale

public void setLocale(Locale l)

Overrides:
setLocale in class Component

paintComponent

protected void paintComponent(Graphics g)

Overrides:
paintComponent in class org.jdesktop.swingx.JXImagePanel

ehsbe CommonsTM
Version 1.1.0rc3

Copyright ©2005-2009 EHSBE, Walther-Rathenau-Str. 58, 39104 Magdeburg, Sachsen-Anhalt, Germany. All Rights Reserved.