adm
Class CAnimatedCanvas

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--adm.CCanvas
                    |
                    +--adm.CAnimatedCanvas
Direct Known Subclasses:
CBits, CIndicator, CMeter

public abstract class CAnimatedCanvas
extends CCanvas

CAnimatedCanvas class extends CCanvas and implements double buffering. It can be used as a base class for widgets with complicated graphics. The background paint and foreground paint are separated in this class. The background painted is only called the first time in the paint method. Only the foreground paint is performed for each update. This provides a better image update (smoother) and an efficient paint. It is better to use this base class when developing widgets with the complicated backgrounds or dynamic graphics.

CAnimatedCanvas is abstract class. The derived classes must implement paintBackground and paintForeground methods.

Since:
adm0.3
See Also:
Serialized Form

Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
CAnimatedCanvas()
          Null Constructor
CAnimatedCanvas(int width, int height)
          Constructor Defines the canvas size and uses default foreground and background colors.
CAnimatedCanvas(int width, int height, java.awt.Color fg, java.awt.Color bg)
          Constructor Defines the canvas size and sets foreground and background colors.
CAnimatedCanvas(java.lang.String dName, java.lang.String pName)
          Constructor with device name and property name
 
Method Summary
 void deviceChanged(DeviceEvent evt)
           
 java.awt.Color getBackground()
          Return the background color of the component
 int getColorMode()
          Return the color mode property
 double getDisplayHi()
          Return display high
 double getDisplayLo()
          Return display low
 java.awt.Font getFont()
          Return the font of the text on the component
 java.awt.Color getForeground()
          Return the foreground color of the component
 int getFrameWidth()
          Return the frame width of component face
 int getLabelStyle()
          Return the label style property
 int getRangeStyle()
          Return the range style property
 void paint(java.awt.Graphics g)
          Draw offscreen graphics and repaint it onto the screen.
 void setBackground(java.awt.Color newBg)
          Set component background color
 void setBounds(int x, int y, int w, int h)
          Set the bounds of the canvas.
 void setBounds(java.awt.Rectangle r)
          Set the bounds of the canvas.
 void setColorMode(int newColorMode)
          Set the color mode property
 void setDisplayHi(double hi)
          Set the display high.
 void setDisplayLo(double lo)
          Set the display low.
 void setDisplayRange(double lo, double hi)
          Set the display limits.
 void setFont(java.awt.Font newFont)
          Set text font for labeling and displaying values.
 void setForeground(java.awt.Color newFg)
          Set compoenet foreground color
 void setFrameWidth(int pixels)
          Set the frame width of component face
 void setLabelStyle(int newLab)
          Set the label style property
 void setRangeStyle(int newRangeStyle)
          Set the range style property
 void setSize(java.awt.Dimension d)
          Set canvas size.
 void setSize(int newWidth, int newHeight)
          Set canvas size.
 void update(java.awt.Graphics g)
          Overwrite the parent update method so it only call this.paint(g)
 
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

CAnimatedCanvas

public CAnimatedCanvas()
Null Constructor

CAnimatedCanvas

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

CAnimatedCanvas

public CAnimatedCanvas(int width,
                       int height)
Constructor Defines the canvas size and uses default foreground and background colors.
Parameters:
width - component width
height - component height

CAnimatedCanvas

public CAnimatedCanvas(int width,
                       int height,
                       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

setSize

public void setSize(int newWidth,
                    int newHeight)
Set canvas size.
Overrides:
setSize in class java.awt.Component
Parameters:
newWidth - width of the component
newHeight - height of the component

setSize

public void setSize(java.awt.Dimension d)
Set canvas size.
Overrides:
setSize in class java.awt.Component
Parameters:
d - dimension of the component

setBounds

public void setBounds(int x,
                      int y,
                      int w,
                      int h)
Set the bounds of the canvas.
Overrides:
setBounds in class java.awt.Component
Parameters:
x - component X location
y - component Y location
w - component width
h - component height

setBounds

public void setBounds(java.awt.Rectangle r)
Set the bounds of the canvas.
Overrides:
setBounds in class java.awt.Component
Parameters:
r - a rectange bounding box for component

setFont

public void setFont(java.awt.Font newFont)
Set text font for labeling and displaying values.
Overrides:
setFont in class java.awt.Component
Parameters:
newFont - font for any text on the component

getFont

public java.awt.Font getFont()
Return the font of the text on the component
Overrides:
getFont in class java.awt.Component

setBackground

public void setBackground(java.awt.Color newBg)
Set component background color
Overrides:
setBackground in class java.awt.Component
Parameters:
newBg - the background color of component

setForeground

public void setForeground(java.awt.Color newFg)
Set compoenet foreground color
Overrides:
setForeground in class java.awt.Component
Parameters:
newFg - the foreground color of component

getBackground

public java.awt.Color getBackground()
Return the background color of the component
Overrides:
getBackground in class java.awt.Component

getForeground

public java.awt.Color getForeground()
Return the foreground color of the component
Overrides:
getForeground in class java.awt.Component

setFrameWidth

public void setFrameWidth(int pixels)
Set the frame width of component face
Parameters:
pixels - the pixels of the frame width

getFrameWidth

public int getFrameWidth()
Return the frame width of component face

setLabelStyle

public void setLabelStyle(int newLab)
Set the label style property
Parameters:
newLab - the new label style, which may be one of:
  1. CConstants.LABEL_NONE
  2. CConstants.LABEL_AXIS
  3. CConstants.LABEL_VALUE
  4. CConstants.LABEL_ALL

getLabelStyle

public int getLabelStyle()
Return the label style property

setColorMode

public 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 int getColorMode()
Return the color mode property

setRangeStyle

public void setRangeStyle(int newRangeStyle)
Set the range style property
Parameters:
newRangeStyle - the new range style, which may be one of:
  1. CConstants.RANGE_AUTO
  2. CConstants.RANGE_FROM_PROPERTY
  3. CConstants.RANGE_STATIC

getRangeStyle

public int getRangeStyle()
Return the range style property

setDisplayRange

public void setDisplayRange(double lo,
                            double hi)
Set the display limits. 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.

setDisplayHi

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

setDisplayLo

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

getDisplayHi

public double getDisplayHi()
Return display high

getDisplayLo

public double getDisplayLo()
Return display low

update

public final void update(java.awt.Graphics g)
Overwrite the parent update method so it only call this.paint(g)
Overrides:
update in class java.awt.Component

paint

public final void paint(java.awt.Graphics g)
Draw offscreen graphics and repaint it onto the screen. Calls derived class' paintForeground(g) and paintBackground(g).
Overrides:
paint in class java.awt.Canvas

deviceChanged

public void deviceChanged(DeviceEvent evt)