adm
Class CLabel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Label
              |
              +--adm.CLabel

public class CLabel
extends java.awt.Label
implements CConstants, CInterface, DeviceListener

CLabel is an awt component bean. It is used to display a value of the specified device property in the control system as a text label. The size, bound, foreground, background, the font and alignment of the label can be set by the user. It also can display the specific string if setText(String) method is called.

The color of the text will be the same as the foreground color if the color mode is set to CLRMOD_STATIC (default). The color of the text will change to yellow or red if the property is in a warning or alarm state (as determined by warning and alarm limits) when the color mode is set to CLRMOD_ALARM.

The display value can be formatted following printf conventions, or using one of following static format constants:

  1. FRMT_INTEGER (%d)
  2. FRMT_FLOAT (%.3f)
  3. FRMT_SCIENTIFIC (%.3e)
  4. FRMT_AUTO (%.3g)
  5. FRMT_HEX (%#x)
  6. FRMT_OCTAL (%#o)
The default format is FRMT_AUTO which means the value will display as a floating point number or scientific notation depending on the value.

Since:
adm0.1
See Also:
Serialized Form

Fields inherited from class java.awt.Label
CENTER, LEFT, RIGHT
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface adm.CConstants
ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, AXIS_BOTTOM, AXIS_LEFT, AXIS_RIGHT, AXIS_STYLE_LINEAR, AXIS_STYLE_LOG10, AXIS_TOP, CLASS_QUERY, CLRMOD_ALARM, CLRMOD_STATIC, COLUMN, DEVICE_QUERY, DIR_DOWN, DIR_LEFT, DIR_RIGHT, DIR_UP, FILL_FROM_CENTER, FILL_FROM_EDGE, FRMT_AUTO, FRMT_FLOAT, FRMT_HEX, FRMT_INTEGER, FRMT_OCTAL, FRMT_SCIENTIFIC, HORIZONTAL, LABEL_ALL, LABEL_AXIS, LABEL_NONE, LABEL_VALUE, PROPERTY_QUERY, RANGE_AUTO, RANGE_FROM_PROPERTY, RANGE_STATIC, ROW, STYLE_FILLUNDER, STYLE_LINE, STYLE_POINT, VERTICAL
 
Constructor Summary
CLabel()
          Null constructor.
CLabel(java.lang.String aText)
          Constructs a new label with the specified string of text, left justfied
CLabel(java.lang.String dName, java.lang.String pName)
          Null constructor with device name and property name
 
Method Summary
 void deviceChanged(DeviceEvent evt)
          At first call, try to get the limits.
 int getColorMode()
          Return the color mode property
 java.lang.String getDeviceName()
          Return the device name to which this component is connected.
 java.lang.String getFormat()
          Return the text format (format is following the printf conventions)
 java.lang.String getPropertyName()
          Return the device property name to which this component is connected.
 void setColorMode(int newColorMode)
          Set the color mode property
 void setDeviceName(java.lang.String newName)
          Set the Device name
 void setFormat(java.lang.String aFormat)
          Set the text format.
 void setPropertyName(java.lang.String newName)
          Set device property name
 void setText(java.lang.String aText)
          Set the text for this label to the specified text.
 
Methods inherited from class java.awt.Label
addNotify, getAlignment, getText, setAlignment
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, deliverEvent, disable, dispatchEvent, doLayout, enable, enable, enableInputMethods, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CLabel

public CLabel()
Null constructor. If setText is not called, this label will displays the value of the specified device property.

CLabel

public CLabel(java.lang.String dName,
              java.lang.String pName)
Null constructor with device name and property name
Parameters:
dName - device name
pName - property name

CLabel

public CLabel(java.lang.String aText)
Constructs a new label with the specified string of text, left justfied
Parameters:
sText - the text string that this label presents.
Method Detail

setColorMode

public final void setColorMode(int newColorMode)
Set the color mode property
Parameters:
newColorMode - the new color mode, which may be one of:
  1. CConstants.CLRMOD_STATIC
  2. CConstants.CLRMOD_ALARM

getColorMode

public final int getColorMode()
Return the color mode property

setText

public void setText(java.lang.String aText)
Set the text for this label to the specified text. If the sText is not null or "", the label will not show the value retrieved from the control system. Otherwise the label will be clear (set to "") and device/property value will be displayed.
Overrides:
setText in class java.awt.Label
Parameters:
sText - the text string that this label presents.

getFormat

public final java.lang.String getFormat()
Return the text format (format is following the printf conventions)

setFormat

public final void setFormat(java.lang.String aFormat)
Set the text format. The label will be forced to display the value of the specified device property.
Parameters:
format - the format of the label text, which following printf conventions. Or use one of following string:
  1. CConstants.FRMT_INTEGER
  2. CConstants.FRMT_FLOAT
  3. CConstants.FRMT_SCIENTIFIC
  4. CConstants.FRMT_AUTO
  5. CConstants.FRMT_HEX
  6. CConstants.FRMT_OCTAL

setDeviceName

public void setDeviceName(java.lang.String newName)
Set the Device name
Specified by:
setDeviceName in interface CInterface
Parameters:
newName - the name of device you want to connect

getDeviceName

public java.lang.String getDeviceName()
Return the device name to which this component is connected. If device name is not set, return empty string "".
Specified by:
getDeviceName in interface CInterface

setPropertyName

public void setPropertyName(java.lang.String newName)
Set device property name
Specified by:
setPropertyName in interface CInterface
Parameters:
newName - the name of device property you want to connect

getPropertyName

public java.lang.String getPropertyName()
Return the device property name to which this component is connected. If property name is not set, return empty string "".
Specified by:
getPropertyName in interface CInterface

deviceChanged

public void deviceChanged(DeviceEvent evt)
At first call, try to get the limits. If failed, always use foreground color. If success, the label color will change according to the value when the color mode is set to CLRMOD_ALARM.
Specified by:
deviceChanged in interface DeviceListener