DESY ACOP Beans Home

com.cosylab.gui.components
Class Piper

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.cosylab.gui.components.Piper
All Implemented Interfaces:
StateOriginator, PopupManageable, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class Piper
extends javax.swing.JComponent
implements PopupManageable, StateOriginator

A visual component for displaying numerical (double) values using a liquid partially filled vertical tube visualisation. A value label above the pipe displays the textural value together vith possible units.

Version:
$id$
Author:
Jernej Kamenik
See Also:
Serialized Form

Nested Class Summary
static class Piper.LayoutOrientation
          Defines the orietation of the piper.
protected  class Piper.TiltHandler
           
 
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
 
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
Piper()
          Creates a new Piper with zero value.
Piper(double newValue)
          Creates a new Piper displaying the specified value.
 
Method Summary
 AbstractCustomizerPanel getCustomizer()
          Returns the Customizer intance for this displayer.
 java.awt.Color getDarkWaterColor()
           
 java.lang.String getFormat()
          Returns the format of the value label text.
 Piper.LayoutOrientation getLayoutOrientation()
          Returns the layout orientation.
 java.awt.Color getLightWaterColor()
           
 double getMaximum()
          Returns the maximum value displayed at the top of the scale of the Piper.
 double getMinimum()
          Gets the minimum value displayed at the bottom of the scale of the Piper.
 java.awt.Color getOutOfBoundsDarkWaterColor()
           
 java.awt.Color getOutOfBoundsLightWaterColor()
           
 PopupManager getPopupManager()
          Returns popup manager for adding popup actions.
protected  RangedValueController getRangedValue()
          Returns the rangedValue object containing all the value logic.
 State getState()
          Returns the current state of the component.
 java.lang.String getTitle()
          Returns the current title of the component or null is none is set.
 int getTitleMaximumFontSize()
           
 int getTitleMinimumFontSize()
           
 java.lang.String getUnits()
          Returns the units to be displayed in the value label or null is none is set.
 double getValue()
          Returns the value currently displayed.
 RangedValuePolicy getValuePolicy()
          DOCUMENT ME!
 boolean isEnhanced()
          Returns wether the component visualisation is enhanced.
 boolean isLogarithmic()
          Returns true if the display is in logarithmic scale.
 boolean isPopupEnabled()
          Returns whether the user can trigger the component's popup menu through mouse click.
 boolean isResizable()
          Returns the resizable property of the component.
 boolean isStretch()
          Returns wether the pipe should strech all across the width of the component or not.
 boolean isTiltingEnabled()
          Returns whether the component should indicate value out of bounds condition by visually tilting its border.
 boolean isTitleVisible()
           
 boolean isUnitsVisible()
          DOCUMENT ME!
static void main(java.lang.String[] args)
          For demonstration purposes.
protected  void paintComponent(java.awt.Graphics g)
          This method has been overriden to implement custom painting of the Piper.
 void setDarkWaterColor(java.awt.Color color)
          Sets the dark color of the water in the piper.
 void setEnabled(boolean enabled)
          Overriden to implement visual notification of enabled state.
 void setEnhanced(boolean enhanced)
          Triggers on and off the visually enhanced mode of the Piper.
 void setFormat(java.lang.String format)
          Sets the format of the value label text.
 void setLayoutOrientation(Piper.LayoutOrientation orientation)
          Sets the orientation of the pipe.
 void setLightWaterColor(java.awt.Color color)
          Sets the light color of the water in the piper.
 void setLogarithmic(boolean logScale)
          Switches between linear and logarithmic scales displayed.
 void setMaximum(double newMaximum)
          Sets the new maximum value displayed at the top of the scale of the Piper.
 void setMaxMin(double newMax, double newMin)
          Sets both minimum and maximum displayed values displayed at the bottom and at the top of the Pipers's scale.
 void setMinimum(double newMinimum)
          Sets the new minimum value displayed at the bottom of the scale of the Piper.
 void setOutOfBoundsDarkWaterColor(java.awt.Color color)
          Sets the dark color of the water in case value is out of bounds.
 void setOutOfBoundsLightWaterColor(java.awt.Color color)
          Sets the light color of the water in case value is out of bounds.
 void setPopupEnabled(boolean b)
          Enables or disables the popup capabilities of the component.
 void setResizable(boolean b)
          Sets the resizable property of the component.
 void setState(State state)
          Sets the state to the component.
 void setStretch(boolean b)
          Sets if the pipe should strech all across the width of the component or not.
 void setTiltingEnabled(boolean b)
          Sets the tilitng enabled property.
 void setTitle(java.lang.String string)
          Sets the title to be rendered on top of the component when not stretched.
 void setTitleMaximumFontSize(int titleMaximumFontSize)
           
 void setTitleMinimumFontSize(int titleMinimumFontSize)
           
 void setTitleVisible(boolean titleVisible)
           
 void setUnits(java.lang.String units)
          Sets the units to be displayed in the value label.
 void setUnitsVisible(boolean b)
          DOCUMENT ME!
 void setValue(double newValue)
          Sets the new value to be displayed.
 void setValuePolicy(RangedValuePolicy p)
          DOCUMENT ME!
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, 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, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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
 
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

Piper

public Piper(double newValue)
Creates a new Piper displaying the specified value.

Parameters:
newValue - double

Piper

public Piper()
Creates a new Piper with zero value.

Method Detail

getCustomizer

public AbstractCustomizerPanel getCustomizer()
Returns the Customizer intance for this displayer.

Returns:
the Customizer intance for this displayer

setEnhanced

public void setEnhanced(boolean enhanced)
Triggers on and off the visually enhanced mode of the Piper. When enhanced, the liquid filling is painted with a gradient color and anti-aliasing is used.

Parameters:
enhanced -

isEnhanced

public boolean isEnhanced()
Returns wether the component visualisation is enhanced.

Returns:
boolean

setFormat

public void setFormat(java.lang.String format)
Sets the format of the value label text.

Parameters:
format - The format to set

getFormat

public java.lang.String getFormat()
Returns the format of the value label text.

Returns:
String

setMaximum

public void setMaximum(double newMaximum)
Sets the new maximum value displayed at the top of the scale of the Piper. This method delegates all logic to the RangedValue implementation.

Parameters:
newMaximum - double

getMaximum

public double getMaximum()
Returns the maximum value displayed at the top of the scale of the Piper.

Returns:
double

setMinimum

public void setMinimum(double newMinimum)
Sets the new minimum value displayed at the bottom of the scale of the Piper. This method delegates all logic to the RangedValue implementation.

Parameters:
newMinimum - double

getMinimum

public double getMinimum()
Gets the minimum value displayed at the bottom of the scale of the Piper.

Returns:
double

setLogarithmic

public void setLogarithmic(boolean logScale)
Switches between linear and logarithmic scales displayed. This method delegates all logic to the RangedValue implementation.

Parameters:
logScale - boolean

isLogarithmic

public boolean isLogarithmic()
Returns true if the display is in logarithmic scale.

Returns:
boolean

setMaxMin

public void setMaxMin(double newMax,
                      double newMin)
Sets both minimum and maximum displayed values displayed at the bottom and at the top of the Pipers's scale. This method delegates all logic to the RangedValue implementation.

Parameters:
newMax - double
newMin - double

setPopupEnabled

public void setPopupEnabled(boolean b)
Enables or disables the popup capabilities of the component.

Parameters:
b - the component should bring up popup dialog on mouse click.

isPopupEnabled

public boolean isPopupEnabled()
Returns whether the user can trigger the component's popup menu through mouse click.

Returns:
true if popup is enabled

setValue

public void setValue(double newValue)
Sets the new value to be displayed. This method delegates all logic to the RangedValue implementation.

Parameters:
newValue - double

getValue

public double getValue()
Returns the value currently displayed.

Returns:
double

main

public static void main(java.lang.String[] args)
For demonstration purposes.

Parameters:
args - String[]

setEnabled

public void setEnabled(boolean enabled)
Overriden to implement visual notification of enabled state.

Overrides:
setEnabled in class javax.swing.JComponent
See Also:
Component.setEnabled(boolean)

getPopupManager

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

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

setResizable

public void setResizable(boolean b)
Sets the resizable property of the component. If set, all components text is rendered in font size, adjusted to the size of the whole component.

Parameters:
b -

isResizable

public boolean isResizable()
Returns the resizable property of the component.

Returns:
resizable

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()

setStretch

public void setStretch(boolean b)
Sets if the pipe should strech all across the width of the component or not.

Parameters:
b -

isStretch

public boolean isStretch()
Returns wether the pipe should strech all across the width of the component or not.

Returns:
strech

setTiltingEnabled

public void setTiltingEnabled(boolean b)
Sets the tilitng enabled property.

Parameters:
b - whether the component should tilt when value is out of bounds.

isTiltingEnabled

public boolean isTiltingEnabled()
Returns whether the component should indicate value out of bounds condition by visually tilting its border.

Returns:
boolean

setTitle

public void setTitle(java.lang.String string)
Sets the title to be rendered on top of the component when not stretched. Can be null in which case nothing is rendered.

Parameters:
string - title

getTitle

public java.lang.String getTitle()
Returns the current title of the component or null is none is set.

Returns:
title

setUnits

public void setUnits(java.lang.String units)
Sets the units to be displayed in the value label. If null, nothing is rendered.

Parameters:
units - The units to set, can be null

getUnits

public java.lang.String getUnits()
Returns the units to be displayed in the value label or null is none is set.

Returns:
String

getRangedValue

protected RangedValueController getRangedValue()
Returns the rangedValue object containing all the value logic.

Returns:
RangedValue

setLayoutOrientation

public void setLayoutOrientation(Piper.LayoutOrientation orientation)
Sets the orientation of the pipe. Pipe's bounds are position according to the orientation (eg. TOP_DOWN means that lower values are printed at the top of the piper and higher at the bottom; piper is filled from the top down).

Parameters:
orientation -

getLayoutOrientation

public Piper.LayoutOrientation getLayoutOrientation()
Returns the layout orientation.

Returns:

paintComponent

protected void paintComponent(java.awt.Graphics g)
This method has been overriden to implement custom painting of the Piper.

Overrides:
paintComponent in class javax.swing.JComponent
Parameters:
g - Graphics
See Also:
JComponent.paintComponent(java.awt.Graphics)

setValuePolicy

public void setValuePolicy(RangedValuePolicy p)
DOCUMENT ME!

Parameters:
p - DOCUMENT ME!

getValuePolicy

public RangedValuePolicy getValuePolicy()
DOCUMENT ME!

Returns:

isUnitsVisible

public boolean isUnitsVisible()
DOCUMENT ME!

Returns:

setUnitsVisible

public void setUnitsVisible(boolean b)
DOCUMENT ME!

Parameters:
b -

isTitleVisible

public boolean isTitleVisible()

setTitleVisible

public void setTitleVisible(boolean titleVisible)

getTitleMaximumFontSize

public int getTitleMaximumFontSize()

setTitleMaximumFontSize

public void setTitleMaximumFontSize(int titleMaximumFontSize)

getTitleMinimumFontSize

public int getTitleMinimumFontSize()

setTitleMinimumFontSize

public void setTitleMinimumFontSize(int titleMinimumFontSize)

setLightWaterColor

public void setLightWaterColor(java.awt.Color color)
Sets the light color of the water in the piper.

Parameters:
color -

setDarkWaterColor

public void setDarkWaterColor(java.awt.Color color)
Sets the dark color of the water in the piper.

Parameters:
color -

setOutOfBoundsLightWaterColor

public void setOutOfBoundsLightWaterColor(java.awt.Color color)
Sets the light color of the water in case value is out of bounds.

Parameters:
color -

setOutOfBoundsDarkWaterColor

public void setOutOfBoundsDarkWaterColor(java.awt.Color color)
Sets the dark color of the water in case value is out of bounds.

Parameters:
color -

getLightWaterColor

public java.awt.Color getLightWaterColor()
Returns:
the light color of the water in the piper

getDarkWaterColor

public java.awt.Color getDarkWaterColor()
Returns:
the dark color of the water in the piper

getOutOfBoundsLightWaterColor

public java.awt.Color getOutOfBoundsLightWaterColor()
Returns:
the light color of the water in case value is out of bounds

getOutOfBoundsDarkWaterColor

public java.awt.Color getOutOfBoundsDarkWaterColor()
Returns:
the dark color of the water in case value is out of bounds


Copyright © 2010. All Rights Reserved.