fr.esrf.tangoatk.widget.attribute
Class SimpleScalarViewer

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.text.JTextComponent
                  extended by javax.swing.JTextField
                      extended by fr.esrf.tangoatk.widget.util.JAutoScrolledText
                          extended by fr.esrf.tangoatk.widget.attribute.SimpleScalarViewer
All Implemented Interfaces:
IAttributeStateListener, IBooleanScalarListener, IErrorListener, INumberScalarListener, IStringScalarListener, JDrawable, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.Scrollable, javax.swing.SwingConstants

public class SimpleScalarViewer
extends JAutoScrolledText
implements INumberScalarListener, IStringScalarListener, IBooleanScalarListener, java.beans.PropertyChangeListener, IErrorListener, JDrawable

A light weigth viewer which display a scalar attribute (String or Number) and its unit. Here is an example of use:

 fr.esrf.tangoatk.core.AttributeList attributeList = new
    fr.esrf.tangoatk.core.AttributeList();
 SimpleScalarViewer snv = new SimpleScalarViewer();
 INumberScalar model = (INumberScalar) attributeList.add("jlp/test/1/att_quatre");
 snv.setModel(model);
 attributeList.startRefresher();
 

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JTextField
javax.swing.JTextField.AccessibleJTextField
 
Nested classes/interfaces inherited from class javax.swing.text.JTextComponent
javax.swing.text.JTextComponent.AccessibleJTextComponent, javax.swing.text.JTextComponent.KeyBinding
 
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 fr.esrf.tangoatk.widget.util.JAutoScrolledText
CENTER_ALIGNMENT, CLASSIC_BEHAVIOR, LEFT_ALIGNMENT, MATRIX_BEHAVIOR, RIGHT_ALIGNMENT, SCROLL_LOOP, SCROLL_TO_SEE_END
 
Fields inherited from class javax.swing.JTextField
notifyAction
 
Fields inherited from class javax.swing.text.JTextComponent
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY
 
Fields inherited from class javax.swing.JComponent
accessibleContext, 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, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
SimpleScalarViewer()
          Contructs a SimpleScalar viewer.
 
Method Summary
 void booleanScalarChange(BooleanScalarEvent evt)
           
 void clearModel()
          Clears all model and listener attached to the components
 void errorChange(ErrorEvent evt)
           
 java.awt.Color getBackgroundColor()
          Returns the current background color of this viewer.
 IBooleanScalar getBooleanModel()
           
 javax.swing.JComponent getComponent()
          Returns the JComponent that implements this interface.
 java.lang.String getDescription(java.lang.String name)
          Get a description of this extensions.
 java.lang.String getExtendedParam(java.lang.String name)
          Returns the specified parameter value.
 java.lang.String[] getExtensionList()
          Returns list of extension name for this objects (Empty array for none).
 boolean getHasToolTip()
          getHasToolTip returns true if the viewer has a tooltip (attribute full name)
 java.lang.String getInvalidText()
          Returns the current text which is displayed in case of error.
 INumberScalar getNumberModel()
           
 boolean getQualityInTooltip()
          getQualityInTooltip returns true if the attribute quality factor is displayed inside the viewer's tooltip
 IStringScalar getStringModel()
           
 boolean getUnitVisible()
          Detemines wether the unit is visible
 java.lang.String getUserFormat()
          Returns the user format.
 void initForEditing()
          Call after a component of a JDSwingObject is created, this give a default look and feel for editing.
 boolean isAlarmEnabled()
          Determines whether the background color is overrided by the quality factor.
static void main(java.lang.String[] args)
          Test function
 void numberScalarChange(NumberScalarEvent evt)
           
 void propertyChange(java.beans.PropertyChangeEvent evt)
           
 void setAlarmEnabled(boolean b)
          Enables or disables alarm background (represents the attribute quality factor).
 void setBackgroundColor(java.awt.Color bg)
          Sets the 'VALID' background color of this viewer.
 boolean setExtendedParam(java.lang.String name, java.lang.String value, boolean popupErr)
          Sets the specified param.
 void setHasToolTip(boolean b)
          setHasToolTip display or not a tooltip for this viewer
 void setInvalidText(java.lang.String s)
          Set the text which will be displayed in case of error or INVALID quality.
 void setModel(IBooleanScalar scalar)
          Sets the model for this viewer.
 void setModel(INumberScalar scalar)
          Sets the model for this viewer.
 void setModel(IStringScalar scalar)
          Sets the model for this viewer.
 void setQualityInTooltip(boolean b)
          setQualityInTooltip display or not the attribute quality factor inside the tooltip
 void setUnitVisible(boolean b)
          Displays or hides the unit.
 void setUserFormat(ATKFormat format)
          Sets the ATK user format of this viewer.
 void setUserFormat(java.lang.String format)
          Overrides the format property of the attribute.
 void stateChange(AttributeStateEvent evt)
           
 void stringScalarChange(StringScalarEvent evt)
           
 
Methods inherited from class fr.esrf.tangoatk.widget.util.JAutoScrolledText
addTextListener, getHorizontalOffset, getMargin, getMinimumSize, getPreferredSize, getScrollingMode, getSizingBehavior, getSleepTime, getText, getVerticalOffset, getWaitTime, paint, removeTextListener, setAutoScroll, setHorizontalAlignment, setHorizontalOffset, setMargin, setScrollingMode, setSizingBehavior, setSleepTime, setText, setValueOffsets, setVerticalOffset, setWaitTime
 
Methods inherited from class javax.swing.JTextField
addActionListener, configurePropertiesFromAction, createActionPropertyChangeListener, createDefaultModel, fireActionPerformed, getAccessibleContext, getAction, getActionListeners, getActions, getColumns, getColumnWidth, getHorizontalAlignment, getHorizontalVisibility, getScrollOffset, getUIClassID, isValidateRoot, paramString, postActionEvent, removeActionListener, scrollRectToVisible, setAction, setActionCommand, setColumns, setDocument, setFont, setScrollOffset
 
Methods inherited from class javax.swing.text.JTextComponent
addCaretListener, addInputMethodListener, addKeymap, copy, cut, fireCaretUpdate, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getNavigationFilter, getPreferredScrollableViewportSize, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, paste, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, replaceSelection, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setUI, updateUI, viewToModel, write
 
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, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, 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, 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, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, 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

SimpleScalarViewer

public SimpleScalarViewer()
Contructs a SimpleScalar viewer. Display a scalar atribute and its unit.

Method Detail

getBackgroundColor

public java.awt.Color getBackgroundColor()
Returns the current background color of this viewer. Color used for the VALID attribute quality state


setBackgroundColor

public void setBackgroundColor(java.awt.Color bg)
Sets the 'VALID' background color of this viewer. Color used for the VALID attribute quality state.

Parameters:
bg - Background color.
See Also:
setAlarmEnabled(boolean)

initForEditing

public void initForEditing()
Description copied from interface: JDrawable
Call after a component of a JDSwingObject is created, this give a default look and feel for editing.

Specified by:
initForEditing in interface JDrawable

getComponent

public javax.swing.JComponent getComponent()
Description copied from interface: JDrawable
Returns the JComponent that implements this interface.

Specified by:
getComponent in interface JDrawable

getDescription

public java.lang.String getDescription(java.lang.String name)
Description copied from interface: JDrawable
Get a description of this extensions.

Specified by:
getDescription in interface JDrawable
Parameters:
name - Extension name
Returns:
Empty string for no description.

getExtensionList

public java.lang.String[] getExtensionList()
Description copied from interface: JDrawable
Returns list of extension name for this objects (Empty array for none).

Specified by:
getExtensionList in interface JDrawable

setExtendedParam

public boolean setExtendedParam(java.lang.String name,
                                java.lang.String value,
                                boolean popupErr)
Description copied from interface: JDrawable
Sets the specified param.

Specified by:
setExtendedParam in interface JDrawable
Parameters:
name - Parameter name (Case unsensitive).
value - Parameter value.
popupErr - true when the JDrawable should display a popup if the parameter value is incorrect, false otherwise. Note that the JDrawable must not display an error message if the parameter does not exists even if popupAllowed is true.
Returns:
true if parameters has been succesfully applied, false otherwise.

getExtendedParam

public java.lang.String getExtendedParam(java.lang.String name)
Description copied from interface: JDrawable
Returns the specified parameter value.

Specified by:
getExtendedParam in interface JDrawable
Parameters:
name - Param name (Case unsensitive).
Returns:
Empty string if not exists, the value otherwise.

stringScalarChange

public void stringScalarChange(StringScalarEvent evt)
Specified by:
stringScalarChange in interface IStringScalarListener

numberScalarChange

public void numberScalarChange(NumberScalarEvent evt)
Specified by:
numberScalarChange in interface INumberScalarListener

booleanScalarChange

public void booleanScalarChange(BooleanScalarEvent evt)
Specified by:
booleanScalarChange in interface IBooleanScalarListener

setUserFormat

public void setUserFormat(java.lang.String format)
Overrides the format property of the attribute.

Parameters:
format - C like Format (ex: %5.2f) , null or "" to disable.

setUserFormat

public void setUserFormat(ATKFormat format)
Sets the ATK user format of this viewer. It allows more specific formating than String format.
 Ex of use:
   time_format = new ATKFormat() {
     public String format(Number n) {
       int d = n.intValue() / 60;
       Object[] o = {new Integer(d / 60), new Integer(d % 60)};
       return Format.sprintf("%02dh %02dmn", o);
     }
   };
   myViewer.setUserFormat(time_format);
 

Parameters:
format - ATKFormat object or null to disable.

getUserFormat

public java.lang.String getUserFormat()
Returns the user format.

Returns:
User format
See Also:
setUserFormat(java.lang.String)

setUnitVisible

public void setUnitVisible(boolean b)
Displays or hides the unit.

Parameters:
b - true to display the unit, false otherwise

getUnitVisible

public boolean getUnitVisible()
Detemines wether the unit is visible

Returns:
true if unit is visible

setAlarmEnabled

public void setAlarmEnabled(boolean b)
Enables or disables alarm background (represents the attribute quality factor).

Parameters:
b - True to enable alarm.
See Also:
setBackgroundColor(java.awt.Color)

isAlarmEnabled

public boolean isAlarmEnabled()
Determines whether the background color is overrided by the quality factor.

See Also:
setAlarmEnabled(boolean), setBackgroundColor(java.awt.Color)

stateChange

public void stateChange(AttributeStateEvent evt)
Specified by:
stateChange in interface IAttributeStateListener

errorChange

public void errorChange(ErrorEvent evt)
Specified by:
errorChange in interface IErrorListener

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

setModel

public void setModel(INumberScalar scalar)
Sets the model for this viewer.

Parameters:
scalar - scalar model

setModel

public void setModel(IStringScalar scalar)
Sets the model for this viewer.

Parameters:
scalar - model

setModel

public void setModel(IBooleanScalar scalar)
Sets the model for this viewer.

Parameters:
scalar - model

clearModel

public void clearModel()
Clears all model and listener attached to the components


setInvalidText

public void setInvalidText(java.lang.String s)
Set the text which will be displayed in case of error or INVALID quality.

Parameters:
s - Text to be displayed.

getInvalidText

public java.lang.String getInvalidText()
Returns the current text which is displayed in case of error.

See Also:
setInvalidText(java.lang.String)

getNumberModel

public INumberScalar getNumberModel()

getStringModel

public IStringScalar getStringModel()

getBooleanModel

public IBooleanScalar getBooleanModel()

getHasToolTip

public boolean getHasToolTip()
getHasToolTip returns true if the viewer has a tooltip (attribute full name)

Returns:
a boolean value

setHasToolTip

public void setHasToolTip(boolean b)
setHasToolTip display or not a tooltip for this viewer

Parameters:
b - If True the attribute full name will be displayed as tooltip for the viewer

getQualityInTooltip

public boolean getQualityInTooltip()
getQualityInTooltip returns true if the attribute quality factor is displayed inside the viewer's tooltip

Returns:
a boolean value

setQualityInTooltip

public void setQualityInTooltip(boolean b)
setQualityInTooltip display or not the attribute quality factor inside the tooltip

Parameters:
b - If True the attribute quality factor will be displayed inside the tooltip.

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Test function

Parameters:
args - Not used
Throws:
java.lang.Exception