adm
Class CBits

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--adm.CCanvas
                    |
                    +--adm.CAnimatedCanvas
                          |
                          +--adm.CBits

public class CBits
extends CAnimatedCanvas
implements java.awt.event.MouseListener

CBits is an awt component bean. It displays and controls an integer property's value in the control system as bit patterns. The size, bound, foreground, background and the font of the label on the widget can be set like an awt component.

The bits display range can be set through the setDisplayBits (int, int), setStartBit (int) and setEndBit (int) methods. The default bits display range is 0 to 15.

By default it is a monitor widget only (the controllable property is set to false). Since version 0.3 it is can used to control the individual bits by calling setControllable(true). If the controllable property is set to true, the individual bit rectangle works like a push button. Pushing the bit button the value will change from 0 to 1 or 1 to 0.

There are three label styles with a default of LABEL_NONE. If LABEL_AXIS (or LABEL_VALUE) is used, start/end bit numbers and a arrow indicating increasing bit number will be shown. All the information including the device and property name is shown when LABEL_ALL is used.

CBits has four directions which can be selected. The bits can start from right (direction = DIR_LEFT), left (direction = DIR_RIGHT), top (direction = DIR_DOWN) or bottom (direction = DIR_UP).

Since:
adm0.2
See Also:
Serialized Form

Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
CBits()
          Null constructor.
CBits(int direction)
          Construct a CBits class with specific direction.
CBits(java.lang.String dName, java.lang.String pName)
          Constructor with device name and property name
 
Method Summary
 void deviceChanged(DeviceEvent event)
           
 int getDirection()
          Return the direction
 int getEndBit()
          Return the endBit
 int getStartBit()
          Return the startBit
 boolean isControllable()
          Return true if this widget is controllabel.
 void mouseClicked(java.awt.event.MouseEvent me)
           
 void mouseEntered(java.awt.event.MouseEvent me)
          MouseListener interface
 void mouseExited(java.awt.event.MouseEvent me)
           
 void mousePressed(java.awt.event.MouseEvent me)
           
 void mouseReleased(java.awt.event.MouseEvent me)
          Handles mouse release.
 void setControllable(boolean b)
          Set the controllable parameter.
 void setDirection(int newDir)
          Set bit position direction
 void setDisplayBits(int sBit, int eBit)
          Set the startBit and endBit.
 void setEndBit(int eBit)
          Set the endBit.
 void setStartBit(int sBit)
          Set the startBit.
 
Methods inherited from class adm.CAnimatedCanvas
getBackground, getColorMode, getDisplayHi, getDisplayLo, getFont, getForeground, getFrameWidth, getLabelStyle, getRangeStyle, paint, setBackground, setBounds, setBounds, setColorMode, setDisplayHi, setDisplayLo, setDisplayRange, setFont, setForeground, setFrameWidth, setLabelStyle, setRangeStyle, setSize, setSize, update
 
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, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFontMetrics, 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, setComponentOrientation, setCursor, setDropTarget, setEnabled, setLocale, setLocation, setLocation, setName, setVisible, show, show, size, toString, transferFocus, validate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CBits

public CBits()
Null constructor.

CBits

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

CBits

public CBits(int direction)
Construct a CBits class with specific direction.
Parameters:
direction - the direction of the bits display, which be one of:
  1. CConstants.DIR_UP
  2. CConstants.DIR_DOWN
  3. CConstants.DIR_RIGHT
  4. CConstants.DIR_LEFT
Method Detail

getStartBit

public int getStartBit()
Return the startBit

getEndBit

public int getEndBit()
Return the endBit

setStartBit

public void setStartBit(int sBit)
Set the startBit. sBit must lesser than endBit otherwise nothing is changed.
Parameters:
sBit - start bit position

setEndBit

public void setEndBit(int eBit)
Set the endBit. eBit must larger or equal than startBit otherwise nothing is changed.
Parameters:
eBit - end bit position

setDisplayBits

public void setDisplayBits(int sBit,
                           int eBit)
Set the startBit and endBit. eBit must larger or equal than sBit otherwise nothing is changed.
Parameters:
sBit - start bit position
eBit - end bit position

getDirection

public int getDirection()
Return the direction

setDirection

public void setDirection(int newDir)
Set bit position direction
Parameters:
newDir - the new direction, which be one of:
  1. CConstants.DIR_UP
  2. CConstan.DIR_DOWN
  3. CConstants.DIR_RIGHT
  4. CConstan.DIR_LEFT

setControllable

public void setControllable(boolean b)
Set the controllable parameter.
Parameters:
b - = true (this widget can used to control value) = false (only used to monitor the value)

isControllable

public boolean isControllable()
Return true if this widget is controllabel. Rerurn flase if not

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent me)
MouseListener interface
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent me)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent me)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent me)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent me)
Handles mouse release. Mouse up on the bit cell, change the 1 to 0 or 0 to 1.
Specified by:
mouseReleased in interface java.awt.event.MouseListener

deviceChanged

public void deviceChanged(DeviceEvent event)
Overrides:
deviceChanged in class CAnimatedCanvas