Class SimpleScalarViewer
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.text.JTextComponent
javax.swing.JTextField
fr.esrf.tangoatk.widget.util.JAutoScrolledText
fr.esrf.tangoatk.widget.attribute.SimpleScalarViewer
- All Implemented Interfaces:
fr.esrf.tangoatk.core.IAttributeStateListener,fr.esrf.tangoatk.core.IBooleanScalarListener,fr.esrf.tangoatk.core.IEnumScalarListener,fr.esrf.tangoatk.core.IErrorListener,fr.esrf.tangoatk.core.INumberScalarListener,fr.esrf.tangoatk.core.IStringScalarListener,JDrawable,MouseListener,ImageObserver,MenuContainer,PropertyChangeListener,Serializable,EventListener,Accessible,Scrollable,SwingConstants
public class SimpleScalarViewer
extends JAutoScrolledText
implements fr.esrf.tangoatk.core.IEnumScalarListener, fr.esrf.tangoatk.core.INumberScalarListener, fr.esrf.tangoatk.core.IStringScalarListener, fr.esrf.tangoatk.core.IBooleanScalarListener, PropertyChangeListener, fr.esrf.tangoatk.core.IErrorListener, JDrawable, MouseListener
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JTextField
JTextField.AccessibleJTextFieldNested classes/interfaces inherited from class javax.swing.text.JTextComponent
JTextComponent.AccessibleJTextComponent, JTextComponent.DropLocation, JTextComponent.KeyBindingNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, 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_ENDFields inherited from class javax.swing.JTextField
notifyActionFields inherited from class javax.swing.text.JTextComponent
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEYFields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields 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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanScalarChange(fr.esrf.tangoatk.core.BooleanScalarEvent evt) voidClears all model and listener attached to the componentsvoidenumScalarChange(fr.esrf.tangoatk.core.EnumScalarEvent evt) voiderrorChange(fr.esrf.tangoatk.core.ErrorEvent evt) fr.esrf.tangoatk.core.IBooleanScalargetDescription(String name) Get a description of this extensions.getExtendedParam(String name) Returns the specified parameter value.String[]booleangetHasToolTipreturns true if the viewer has a tooltip (attribute full name)fr.esrf.tangoatk.core.INumberScalarbooleangetQualityInTooltipreturns true if the attribute quality factor is displayed inside the viewer's tooltipfr.esrf.tangoatk.core.IStringScalarbooleanDetemines wether the unit is visibleReturns the user format.voidCall after a component of a JDSwingObject is created, this give a default look and feel for editing.booleanstatic voidTest functionvoidvoidvoidvoidvoidvoidnumberScalarChange(fr.esrf.tangoatk.core.NumberScalarEvent evt) voidvoidsetAlarmEnabled(boolean b) Enables or disables alarm background (represents the attribute quality factor).voidSets the 'VALID' background color of this viewer.booleansetExtendedParam(String name, String value, boolean popupErr) Sets the specified param.voidsetHasToolTip(boolean b) setHasToolTipdisplay or not a tooltip for this viewervoidSet the text which will be displayed in case of error or INVALID quality.voidsetModel(fr.esrf.tangoatk.core.IBooleanScalar scalar) Sets the model for this viewer.voidsetModel(fr.esrf.tangoatk.core.IEnumScalar scalar) Sets the model for this viewer.voidsetModel(fr.esrf.tangoatk.core.INumberScalar scalar) Sets the model for this viewer.voidsetModel(fr.esrf.tangoatk.core.IStringScalar scalar) Sets the model for this viewer.voidsetQualityInTooltip(boolean b) setQualityInTooltipdisplay or not the attribute quality factor inside the tooltipvoidsetUnitVisible(boolean b) Displays or hides the unit.voidsetUserFormat(ATKFormat format) Sets the ATK user format of this viewer.voidsetUserFormat(String format) Overrides the format property of the attribute.voidstateChange(fr.esrf.tangoatk.core.AttributeStateEvent evt) voidstringScalarChange(fr.esrf.tangoatk.core.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, setWaitTimeMethods inherited from class javax.swing.JTextField
actionPropertyChanged, 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, setScrollOffsetMethods inherited from class javax.swing.text.JTextComponent
addCaretListener, addInputMethodListener, addKeymap, copy, cut, fireCaretUpdate, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getDropLocation, getDropMode, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getNavigationFilter, getPreferredScrollableViewportSize, getPrintable, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, modelToView2D, moveCaretPosition, paste, print, print, print, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, replaceSelection, restoreComposedText, saveComposedText, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setDropMode, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setUI, updateUI, viewToModel, viewToModel2D, writeMethods 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, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, updateMethods 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, transferFocusDownCycle, validate, validateTreeMethods 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Constructor Details
-
SimpleScalarViewer
public SimpleScalarViewer()Contructs a SimpleScalar viewer. Display a scalar atribute and its unit.
-
-
Method Details
-
getBackgroundColor
- Returns:
- the current background color of this viewer. Color used for the VALID attribute quality state
-
setBackgroundColor
Sets the 'VALID' background color of this viewer. Color used for the VALID attribute quality state.- Parameters:
bg- Background color.- See Also:
-
initForEditing
public void initForEditing()Description copied from interface:JDrawableCall after a component of a JDSwingObject is created, this give a default look and feel for editing.- Specified by:
initForEditingin interfaceJDrawable
-
getComponent
- Specified by:
getComponentin interfaceJDrawable- Returns:
- the JComponent that implements this interface.
-
getDescription
Description copied from interface:JDrawableGet a description of this extensions.- Specified by:
getDescriptionin interfaceJDrawable- Parameters:
name- Extension name- Returns:
- Empty string for no description.
-
getExtensionList
- Specified by:
getExtensionListin interfaceJDrawable- Returns:
- list of extension name for this objects (Empty array for none).
-
setExtendedParam
Description copied from interface:JDrawableSets the specified param.- Specified by:
setExtendedParamin interfaceJDrawable- 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
Description copied from interface:JDrawableReturns the specified parameter value.- Specified by:
getExtendedParamin interfaceJDrawable- Parameters:
name- Param name (Case unsensitive).- Returns:
- Empty string if not exists, the value otherwise.
-
stringScalarChange
public void stringScalarChange(fr.esrf.tangoatk.core.StringScalarEvent evt) - Specified by:
stringScalarChangein interfacefr.esrf.tangoatk.core.IStringScalarListener
-
numberScalarChange
public void numberScalarChange(fr.esrf.tangoatk.core.NumberScalarEvent evt) - Specified by:
numberScalarChangein interfacefr.esrf.tangoatk.core.INumberScalarListener
-
enumScalarChange
public void enumScalarChange(fr.esrf.tangoatk.core.EnumScalarEvent evt) - Specified by:
enumScalarChangein interfacefr.esrf.tangoatk.core.IEnumScalarListener
-
booleanScalarChange
public void booleanScalarChange(fr.esrf.tangoatk.core.BooleanScalarEvent evt) - Specified by:
booleanScalarChangein interfacefr.esrf.tangoatk.core.IBooleanScalarListener
-
setUserFormat
Overrides the format property of the attribute.- Parameters:
format- C like Format (ex: %5.2f) , null or "" to disable.
-
setUserFormat
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
Returns the user format.- Returns:
- User format
- See Also:
-
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:
-
isAlarmEnabled
public boolean isAlarmEnabled()- Returns:
- whether the background color is overrided by the quality factor.
- See Also:
-
stateChange
public void stateChange(fr.esrf.tangoatk.core.AttributeStateEvent evt) - Specified by:
stateChangein interfacefr.esrf.tangoatk.core.IAttributeStateListener
-
errorChange
public void errorChange(fr.esrf.tangoatk.core.ErrorEvent evt) - Specified by:
errorChangein interfacefr.esrf.tangoatk.core.IErrorListener
-
propertyChange
- Specified by:
propertyChangein interfacePropertyChangeListener
-
setModel
public void setModel(fr.esrf.tangoatk.core.INumberScalar scalar) Sets the model for this viewer.- Parameters:
scalar- scalar model
-
setModel
public void setModel(fr.esrf.tangoatk.core.IStringScalar scalar) Sets the model for this viewer.- Parameters:
scalar- model
-
setModel
public void setModel(fr.esrf.tangoatk.core.IEnumScalar scalar) Sets the model for this viewer.- Parameters:
scalar- model
-
setModel
public void setModel(fr.esrf.tangoatk.core.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
Set the text which will be displayed in case of error or INVALID quality.- Parameters:
s- Text to be displayed.
-
getInvalidText
- Returns:
- the current text which is displayed in case of error.
- See Also:
-
getNumberModel
public fr.esrf.tangoatk.core.INumberScalar getNumberModel() -
getStringModel
public fr.esrf.tangoatk.core.IStringScalar getStringModel() -
getBooleanModel
public fr.esrf.tangoatk.core.IBooleanScalar getBooleanModel() -
getHasToolTip
public boolean getHasToolTip()getHasToolTipreturns true if the viewer has a tooltip (attribute full name)- Returns:
- a
booleanvalue
-
setHasToolTip
public void setHasToolTip(boolean b) setHasToolTipdisplay 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()getQualityInTooltipreturns true if the attribute quality factor is displayed inside the viewer's tooltip- Returns:
- a
booleanvalue
-
setQualityInTooltip
public void setQualityInTooltip(boolean b) setQualityInTooltipdisplay or not the attribute quality factor inside the tooltip- Parameters:
b- If True the attribute quality factor will be displayed inside the tooltip.
-
main
Test function- Parameters:
args- Not used- Throws:
Exception- In case of failure
-
mouseClicked
- Specified by:
mouseClickedin interfaceMouseListener
-
mousePressed
- Specified by:
mousePressedin interfaceMouseListener
-
mouseReleased
- Specified by:
mouseReleasedin interfaceMouseListener
-
mouseEntered
- Specified by:
mouseEnteredin interfaceMouseListener
-
mouseExited
- Specified by:
mouseExitedin interfaceMouseListener
-