DESY ACOP Beans Home

com.cosylab.gui.components
Class AbstractDisplayerPanel

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.cosylab.gui.components.AbstractDisplayerPanel
All Implemented Interfaces:
StateOriginator, PopupManageable, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible
Direct Known Subclasses:
AbstractNumericDisplayerPanel, LabelDisplayer, LabelledGauger, LabelledLedder

public abstract class AbstractDisplayerPanel
extends javax.swing.JPanel
implements PopupManageable, StateOriginator

A container for simple displayers is able to display a small dispalyer component together with an optional title in a vertical or horizontal resizable layout. It also supports com.cosylab.gui.components.util.PopupManager and com.cosylab.gui.components.customizer.Customizer.

Version:
$id$
Author:
Jernej Kamenik
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.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int DYNAMIC_LAYOUT
          Lays out components either horizontally or vertically according to the space available
static int HORIZONTAL_LAYOUT
          Lays out the components horizontaly.
static int VERTICAL_LAYOUT
          Lays out componetns vertically
 
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
AbstractDisplayerPanel()
          Constructs AbstractDisplayerPanel already containing the valueComponent.
AbstractDisplayerPanel(java.lang.String title, boolean titleVisible, int layoutOrientation, boolean resizable, boolean enabled, boolean enchanced, int minTitleFontSize, int maxTitleFontSize)
          Constructs AbstractDisplayerPanel already containing the valueComponent with inital values.
 
Method Summary
 AbstractCustomizerPanel getCustomizer()
          Loads the default com.cosylab.gui.components.customizer.Customizer for this displayer and returns it.
 int getLayoutOrientation()
           Returns the current layout orientation setting.
 PopupManager getPopupManager()
          Returns popum manager for adding popup actions.
 State getState()
          Returns the current state of the component.
 java.lang.String getTitle()
          Returns the title displayed beside the value component.
protected  javax.swing.JLabel getTitleComponent()
          Returns the component to display the title of thi displayer.
 int getTitleMaximumFontSize()
          Returns the maximum font size allowed.
 int getTitleMinimumFontSize()
          Returns the minimum font size allowed.
protected abstract  javax.swing.JComponent getValueComponent()
          Should return the component to display the value of this displayer.
protected  void internalSetEnabled()
           
protected  void internalSetEnhanced()
           
protected  void internalSetResizable()
           
protected  void internalSetTitle()
           
 boolean isDragEnabled()
          Returns true if drag is enabled.
 boolean isDropEnabled()
          Returns true if drop is enabled.
 boolean isEnhanced()
          Determines whether the displayer panel is to be rendered enhanced.
 boolean isPopupEnabled()
          Return true if the popup menu is enabled or false otherwise.
 boolean isResizable()
           Determines wether the components inside the panel should resize together with the panel or should maintain their preferred sizes.
 boolean isTitleVisible()
          Determines wether the title of this component is displayed beside the value component.
protected  void layoutDisplayer()
          Lays out the displayer according to the set layout orientation.
protected  void layoutValue()
           
protected  void layoutValueAndTitle()
           
 void setBackground(java.awt.Color bg)
           
 void setDragEnabled(boolean enabled)
          Enables/disables mouse dragging.
 void setDropEnabled(boolean enabled)
          Enable/disable the mouse drop.
 void setEnabled(boolean enabled)
          Overriden to disable subcomponents.
 void setEnhanced(boolean b)
          Sets the enhanced property of the displayer panel
 void setForeground(java.awt.Color fg)
           
 void setLayoutOrientation(int i)
          Sets the orientation tag determining how the title and value components should be layed out inside the panel.
 void setPopupEnabled(boolean enabled)
          Enables or disables the popup menu.
 void setResizable(boolean b)
          Sets the resizability of the title and value components of the panel.
 void setState(State state)
          Sets the state to the component.
 void setTitle(java.lang.String value)
          Sets the title to be displayed beside the value component.
 void setTitleMaximumFontSize(int max)
          Sets the maximum title font size allowed.
 void setTitleMinimumFontSize(int min)
          Sets the minimum title font size allowed.
 void setTitleVisible(boolean b)
          Adds or removes the Title displayed beside the value component.
 void setTransferHandler(javax.swing.TransferHandler newHandler)
           
 
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, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, 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
 

Field Detail

HORIZONTAL_LAYOUT

public static final int HORIZONTAL_LAYOUT
Lays out the components horizontaly.

See Also:
Constant Field Values

VERTICAL_LAYOUT

public static final int VERTICAL_LAYOUT
Lays out componetns vertically

See Also:
Constant Field Values

DYNAMIC_LAYOUT

public static final int DYNAMIC_LAYOUT
Lays out components either horizontally or vertically according to the space available

See Also:
Constant Field Values
Constructor Detail

AbstractDisplayerPanel

public AbstractDisplayerPanel()
Constructs AbstractDisplayerPanel already containing the valueComponent.


AbstractDisplayerPanel

public AbstractDisplayerPanel(java.lang.String title,
                              boolean titleVisible,
                              int layoutOrientation,
                              boolean resizable,
                              boolean enabled,
                              boolean enchanced,
                              int minTitleFontSize,
                              int maxTitleFontSize)
Constructs AbstractDisplayerPanel already containing the valueComponent with inital values. It is cheap to set values now, since component is not in AWT containment.

Parameters:
title - initial value
titleVisible - initial value
layoutOrientation - initial value
resizable - initial value
enabled - initial value
enchanced - initial value
minTitleFontSize - initial value
maxTitleFontSize - initial value
Method Detail

getCustomizer

public AbstractCustomizerPanel getCustomizer()
Loads the default com.cosylab.gui.components.customizer.Customizer for this displayer and returns it.

Returns:
the Customizer intance for this displayer

setEnabled

public void setEnabled(boolean enabled)
Overriden to disable subcomponents.

Overrides:
setEnabled in class javax.swing.JComponent
Parameters:
enabled - if the component is to be enabled

setEnhanced

public void setEnhanced(boolean b)
Sets the enhanced property of the displayer panel

Parameters:
b - whether to render in enhanced mode

isEnhanced

public boolean isEnhanced()
Determines whether the displayer panel is to be rendered enhanced.

Returns:
true if diaplayer panel is enhanced

setLayoutOrientation

public void setLayoutOrientation(int i)
Sets the orientation tag determining how the title and value components should be layed out inside the panel.

Parameters:
i - layout tag, valid values are HORIZONTAL_LAYOUT, VERTICAL_LAYOUT, DYNAMIC_LAYOUT
Throws:
java.lang.IllegalArgumentException - if no applicable parameter is supplied
See Also:
getLayoutOrientation()

getLayoutOrientation

public int getLayoutOrientation()

Returns the current layout orientation setting.

Possible values are:

Returns:
int

getPopupManager

public PopupManager getPopupManager()
Returns popum manager for adding popup actions.

Specified by:
getPopupManager in interface PopupManageable
Returns:
returns popup manager, which manages popup menu
See Also:
PopupManageable.getPopupManager()

isPopupEnabled

public boolean isPopupEnabled()
Return true if the popup menu is enabled or false otherwise.

Returns:
true if popup is enabled

setPopupEnabled

public void setPopupEnabled(boolean enabled)
Enables or disables the popup menu.

Parameters:
enabled - true if enable or false if disableds

setResizable

public void setResizable(boolean b)
Sets the resizability of the title and value components of the panel.

Parameters:
b - wether the title and value components should adjust their sizes in accord with the size of the panel.
See Also:
isResizable()

isResizable

public boolean isResizable()

Determines wether the components inside the panel should resize together with the panel or should maintain their preferred sizes.

When disabled, the size of the components inside the panel is determined according to the preferred size of the panel.

Returns:
true if the title and value components resize accordingly with the size of the panel, false otherwise.

setState

public void setState(State state)
Sets the state to the component.

Specified by:
setState in interface StateOriginator
Parameters:
state - to set.
See Also:
StateOriginator.setState(com.cosylab.application.state.State)

getState

public State getState()
Returns the current state of the component.

Specified by:
getState in interface StateOriginator
Returns:
current state.
See Also:
StateOriginator.getState()

setTitle

public void setTitle(java.lang.String value)
Sets the title to be displayed beside the value component.

Parameters:
value - title String to be displayed

getTitle

public java.lang.String getTitle()
Returns the title displayed beside the value component.

Returns:
title displayed

setTitleVisible

public void setTitleVisible(boolean b)
Adds or removes the Title displayed beside the value component.

Parameters:
b - wether the title should be displayed or not.

isTitleVisible

public boolean isTitleVisible()
Determines wether the title of this component is displayed beside the value component.

Returns:
true if the title is displayed and false if not.

getTitleComponent

protected javax.swing.JLabel getTitleComponent()
Returns the component to display the title of thi displayer. This method is used by the #DisplayerLayout.

Returns:
component displaying the title

getValueComponent

protected abstract javax.swing.JComponent getValueComponent()
Should return the component to display the value of this displayer. This method is called inside the constructor to add the valueComponent to the AbstractDisplayerPanel. Subclasses should thus use lazy initialization inside this method.

Returns:
the value component of the AbstractDisplayerPanel.

internalSetEnabled

protected void internalSetEnabled()

internalSetEnhanced

protected void internalSetEnhanced()

internalSetResizable

protected void internalSetResizable()

internalSetTitle

protected void internalSetTitle()

layoutDisplayer

protected void layoutDisplayer()
Lays out the displayer according to the set layout orientation.


layoutValue

protected void layoutValue()

layoutValueAndTitle

protected void layoutValueAndTitle()

getTitleMaximumFontSize

public int getTitleMaximumFontSize()
Returns the maximum font size allowed.

Returns:

getTitleMinimumFontSize

public int getTitleMinimumFontSize()
Returns the minimum font size allowed.

Returns:

setTitleMaximumFontSize

public void setTitleMaximumFontSize(int max)
Sets the maximum title font size allowed.

Parameters:
max -

setTitleMinimumFontSize

public void setTitleMinimumFontSize(int min)
Sets the minimum title font size allowed.

Parameters:
min -

setTransferHandler

public void setTransferHandler(javax.swing.TransferHandler newHandler)
Overrides:
setTransferHandler in class javax.swing.JComponent

setDragEnabled

public void setDragEnabled(boolean enabled)
Enables/disables mouse dragging. Dragging can only be enabled if this component uses CosyTransferHandler.

Parameters:
enabled -

isDragEnabled

public boolean isDragEnabled()
Returns true if drag is enabled.

Returns:
true if drag is enabled

setDropEnabled

public void setDropEnabled(boolean enabled)
Enable/disable the mouse drop. Drop can only be enabled if this component uses CosyTransferHandler.

Parameters:
enabled -

isDropEnabled

public boolean isDropEnabled()
Returns true if drop is enabled.

Returns:
true if drop is enabled

setBackground

public void setBackground(java.awt.Color bg)
Overrides:
setBackground in class javax.swing.JComponent

setForeground

public void setForeground(java.awt.Color fg)
Overrides:
setForeground in class javax.swing.JComponent


Copyright © 2010. All Rights Reserved.