Class 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:
  • Constructor Details

    • SimpleScalarViewer

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

    • getBackgroundColor

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

      public void setBackgroundColor(Color bg)
      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: 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 JComponent getComponent()
      Specified by:
      getComponent in interface JDrawable
      Returns:
      the JComponent that implements this interface.
    • getDescription

      public String getDescription(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 String[] getExtensionList()
      Specified by:
      getExtensionList in interface JDrawable
      Returns:
      list of extension name for this objects (Empty array for none).
    • setExtendedParam

      public boolean setExtendedParam(String name, 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 String getExtendedParam(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(fr.esrf.tangoatk.core.StringScalarEvent evt)
      Specified by:
      stringScalarChange in interface fr.esrf.tangoatk.core.IStringScalarListener
    • numberScalarChange

      public void numberScalarChange(fr.esrf.tangoatk.core.NumberScalarEvent evt)
      Specified by:
      numberScalarChange in interface fr.esrf.tangoatk.core.INumberScalarListener
    • enumScalarChange

      public void enumScalarChange(fr.esrf.tangoatk.core.EnumScalarEvent evt)
      Specified by:
      enumScalarChange in interface fr.esrf.tangoatk.core.IEnumScalarListener
    • booleanScalarChange

      public void booleanScalarChange(fr.esrf.tangoatk.core.BooleanScalarEvent evt)
      Specified by:
      booleanScalarChange in interface fr.esrf.tangoatk.core.IBooleanScalarListener
    • setUserFormat

      public void setUserFormat(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 String 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:
      stateChange in interface fr.esrf.tangoatk.core.IAttributeStateListener
    • errorChange

      public void errorChange(fr.esrf.tangoatk.core.ErrorEvent evt)
      Specified by:
      errorChange in interface fr.esrf.tangoatk.core.IErrorListener
    • propertyChange

      public void propertyChange(PropertyChangeEvent evt)
      Specified by:
      propertyChange in interface PropertyChangeListener
    • 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

      public void setInvalidText(String s)
      Set the text which will be displayed in case of error or INVALID quality.
      Parameters:
      s - Text to be displayed.
    • getInvalidText

      public String 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()
      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(String[] args) throws Exception
      Test function
      Parameters:
      args - Not used
      Throws:
      Exception - In case of failure
    • mouseClicked

      public void mouseClicked(MouseEvent e)
      Specified by:
      mouseClicked in interface MouseListener
    • mousePressed

      public void mousePressed(MouseEvent e)
      Specified by:
      mousePressed in interface MouseListener
    • mouseReleased

      public void mouseReleased(MouseEvent e)
      Specified by:
      mouseReleased in interface MouseListener
    • mouseEntered

      public void mouseEntered(MouseEvent e)
      Specified by:
      mouseEntered in interface MouseListener
    • mouseExited

      public void mouseExited(MouseEvent e)
      Specified by:
      mouseExited in interface MouseListener