adm
Class CSlider

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

public class CSlider
extends CIndicator
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener

CSlider is an awt component bean. It provide a convenient means for allowing a user to control a device property's value in a control system. The size, bound, foreground, background and the font of the label on the slider can be set like an awt component.

There are four label styles which can be selected, with a default of LABEL_NONE. If LABEL_AXIS is used, tick marks and display range will appear. The property's value will also shown if LABEL_VALUE is selected. All the information including the device and property name will on the widget when the LABEL_ALL is used.

The orientation of the CSilder widget can be either VERTICAL (default) or HORIZONTAL.

There are two ways to adjust the value: (1) dragging the thumb and (2) clicking the face of the slider. When the thumb is dragged, only a change larger than precision will be sent to the control system. The precision value will be obtained from control system if it is available. Otherwise the default value of 1% of the control range will be used. When clicking on the face, the value of the property will increase or decrease a unit increment depending upon the clicking position. By default the unit increment is the same as the precision, and they can be changed using either the setPrecision(double) or setUnitIncrement(double) method. Double clicking the thumb, a new window will pop up to allow the user to change the unit increment value on the fly. Create a slider component. It is used to control the device property value.

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
CSlider()
          Null Constructor.
CSlider(int w, int h)
          Constructor.
CSlider(int w, int h, java.awt.Color fg, java.awt.Color bg)
          Constructor Defines the canvas size and sets foreground and background colors.
CSlider(java.lang.String dName, java.lang.String pName)
          Constructor with device name and property name
 
Method Summary
 void deviceChanged(DeviceEvent event)
           
 double getControlHi()
          Return control high
 double getControlLo()
          Return control low
 double getPrecision()
          Return the precision value.
 double getUnitIncrement()
          Return the unit increment value.
 void mouseClicked(java.awt.event.MouseEvent me)
          Handles mouse click.
 void mouseDragged(java.awt.event.MouseEvent me)
          Handle the mouse drag.
 void mouseEntered(java.awt.event.MouseEvent me)
          MouseListener interface
 void mouseExited(java.awt.event.MouseEvent me)
          MouseListener interface
 void mouseMoved(java.awt.event.MouseEvent me)
          MouseMotionListener interface
 void mousePressed(java.awt.event.MouseEvent me)
          Press the mouse in the thumb area to initiate a drag, and monitoring will be suspended.
 void mouseReleased(java.awt.event.MouseEvent me)
          Handle the mouse release.
 void setControlHi(double hi)
          Set control high.
 void setControlLo(double lo)
          Set control low.
 void setControlRange(double lo, double hi)
          Set control high and control low.
 void setPrecision(double newPrecision)
          Set precision.
 void setUnitIncrement(double newUnitIncrement)
          Set unit increment value.
 
Methods inherited from class adm.CIndicator
getOrientation, setOrientation
 
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

CSlider

public CSlider()
Null Constructor.

CSlider

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

CSlider

public CSlider(int w,
               int h)
Constructor. Defines the canvas size and use default foreground and background color
Parameters:
width - component width
height - component height

CSlider

public CSlider(int w,
               int h,
               java.awt.Color fg,
               java.awt.Color bg)
Constructor Defines the canvas size and sets foreground and background colors.
Parameters:
width - component width
height - component height
fg - foreground color
bg - background color
Method Detail

setControlRange

public void setControlRange(double lo,
                            double hi)
Set control high and control low. The range style property will be forced to RANGE_STATIC.
Parameters:
lo - the display low
Hi - the display high hi must be larger than lo otherwise nothing is changed.

setControlHi

public void setControlHi(double hi)
Set control high. The range style property will be forced to RANGE_STATIC.
Parameters:
Hi - the display high hi must be larger than controlLo otherwise nothing is changed.

setControlLo

public void setControlLo(double lo)
Set control low. The range style property will be forced to RANGE_STATIC.
Parameters:
lo - the display low lo must be smaller than controlHi otherwise nothing is changed.

getControlHi

public double getControlHi()
Return control high

getControlLo

public double getControlLo()
Return control low

setUnitIncrement

public void setUnitIncrement(double newUnitIncrement)
Set unit increment value. This is the value change when user clicks the slider face. Default value is 1% of control range.

getUnitIncrement

public double getUnitIncrement()
Return the unit increment value.

setPrecision

public void setPrecision(double newPrecision)
Set precision. This value is used to control the rate at which the data is sent to control system when the user is dragging the thumb of slider. Default value is 1% of control range.

getPrecision

public double getPrecision()
Return the precision value.

deviceChanged

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

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)
MouseListener interface
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent me)
Handles mouse click. Click on the face, the value will change a unit increment. If double click the thumb, pop up a new window to allow the user to change the unit increment value.
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent me)
Press the mouse in the thumb area to initiate a drag, and monitoring will be suspended.
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent me)
Handle the mouse release. Release the mouse to terminate a drag and resume monitoring.
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent me)
Handle the mouse drag. Only a change larger than precision will be sent.
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent me)
MouseMotionListener interface
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener