adm
Class CRect

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--adm.CCanvas
                    |
                    +--adm.CRect
Direct Known Subclasses:
COval

public class CRect
extends CCanvas

CRect awt component bean. It is used to monitor the state of a specific device property in a control system. The size, bound, foreground and background can be set like the awt component.

CRect has the color mode property. When it is set to CLRMOD_ALARM, the color of the widget will change from foreground to yellow or red if the property is in warning or alarm state (determined by warning and alarm limits). When the foreground and the background color are the same as the container's, this widget will only appear when the device property is in the warning and alarm states.

Since version 0.3 this widget can used to monitor the Enum type device - property. A color map (table) is used to represent the state when the color mode is CLRMOD_ALARM. Default colorMap contains 12 colors, and uses color black for state above 12. User can overwrite this colorMap by calling the setColorMap (Color[] newColor). If the length of the newColor is less than the number of the Enum states, the color black will be used for the remaining states.

Since:
adm0.1
See Also:
Serialized Form

Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
CRect()
          Null Constructor.
CRect(int w, int h)
          Constuctor.
CRect(int w, int h, java.awt.Color fg, java.awt.Color bg)
          Constuctor.
CRect(java.lang.String dName, java.lang.String pName)
          Constructor with device name and property name
 
Method Summary
 void deviceChanged(DeviceEvent evt)
          To get the new value, to calculate the new color and call repaint() to update the color.
 java.awt.Color[] getColorMap()
          Get the color map for the Enum type device property
 int getColorMode()
          Return the color mode property
 java.lang.String getLabel()
          Return the label string.
 void paint(java.awt.Graphics g)
          draw Rectange and label if label is set
 void setColorMap(java.awt.Color[] colors)
          Set the color map for the Enum type device property to overwrite the default color array.
 void setColorMode(int newColorMode)
          Set the color mode property
 void setLabel(java.lang.String newLabel)
          Set the label string appeared on the widget If null, there is no label on the widget (default)
 
Methods inherited from class adm.CCanvas
getDeviceName, getPropertyName, setDeviceAndPropertyName, setDeviceName, setPropertyName
 
Methods inherited from class java.awt.Canvas
addNotify
 
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, 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

CRect

public CRect()
Null Constructor.

CRect

public CRect(java.lang.String dName,
             java.lang.String pName)
Constructor with device name and property name
Parameters:
dName - device name
pName - property name

CRect

public CRect(int w,
             int h)
Constuctor.
Parameters:
w - the width of the component
h - the height of the component

CRect

public CRect(int w,
             int h,
             java.awt.Color fg,
             java.awt.Color bg)
Constuctor.
Parameters:
w - the width of the component
h - the height of the component
fg - the foreground color of the component
bg - the background color of the component
Method Detail

setLabel

public final void setLabel(java.lang.String newLabel)
Set the label string appeared on the widget If null, there is no label on the widget (default)

getLabel

public final java.lang.String getLabel()
Return the label string. There is no lable if null returned

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

setColorMap

public final void setColorMap(java.awt.Color[] colors)
Set the color map for the Enum type device property to overwrite the default color array. The size of the color array must equal to the size of Enum string. The widget will use the black to replace the missing color.
Parameters:
colors - a array of colors

getColorMap

public final java.awt.Color[] getColorMap()
Get the color map for the Enum type device property

paint

public void paint(java.awt.Graphics g)
draw Rectange and label if label is set
Overrides:
paint in class java.awt.Canvas
Parameters:
g - offGraphics object

deviceChanged

public void deviceChanged(DeviceEvent evt)
To get the new value, to calculate the new color and call repaint() to update the color.