JClass 4.5.0 API
Documentation

com.klg.jclass.swing.gauge
Class JCGauge

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--com.klg.jclass.swing.gauge.JCGauge
Direct Known Subclasses:
JCCircularGauge

public class JCGauge
extends JComponent
implements MouseListener, MouseMotionListener, com.klg.jclass.util.DefaultComponentLayoutUser, Serializable

The parent class for circular gauges. It contains methods for setting many of the gauge's properties, such as a header, footer, and legend, as well as for adding needles, ranges, and tick objects.

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Field Summary
protected  JCNeedle draggedNeedle
          The needle currently being dragged.
protected  JComponent footer
          The footer component.
protected  Rectangle footerLayoutHints
           
protected  JCGaugeArea gaugeArea
          The drawing area for the circular gauge.
protected  Rectangle gaugeAreaLayoutHints
           
protected  JComponent header
          The header component.
protected  Rectangle headerLayoutHints
           
protected  JCLegend legend
          The Legend.
protected  Rectangle legendLayoutHints
           
protected  Vector needles
          The list of needles assocated with this gauge.
protected  com.klg.jclass.util.JCListenerList pickListeners
          List of listeners interested in pick events.
protected  Vector ranges
          The list of ranges for this gauge.
protected  boolean repaintEnabled
          Allow batching of changes by toggling repaint off/on.
protected  JCCircularScale scale
          The scale associated with this gauge.
protected  boolean snapToValue
          Snap to closest integral scale value; default: false
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
JCGauge()
          No-argument constructor for JCCircularGauge.
 
Method Summary
 void addNeedle(JCNeedle needle)
          Adds a needle to this scale.
 void addNeedle(JCNeedle needle, int index)
          Adds a needle to this scale.
 void addPickListener(JCGaugePickListener l)
          Adds a listener for gauge pick events.
 void addRange(JCRange range)
          Adds a range to the gauge.
 void addRange(JCRange range, int index)
          Adds a range to the gauge.
 void addTick(JCTick tick)
          Adds a tick to a gauge.
 void addTick(JCTick tick, int index)
          Adds a tick object to a gauge.
 JComponent getComponentArea()
          Returns the JClass component's sub-component on which the actual drawing of the gauge will be performed.
 int getDrawingAreaHeight()
          Gets the height of the drawing area represented by this gauge.
 int getDrawingAreaWidth()
          Gets the width of the drawing area represented by this gauge.
 JComponent getFooter()
          Returns the footer for this gauge.
 JCGaugeArea getGaugeArea()
          Returns the gauge area for this gauge.
 JComponent getHeader()
          Returns the header for this gauge.
 Rectangle getLayoutHints(JComponent child)
          Gets layout hints for the specified gauge child.
 JCLegend getLegend()
          Returns the legend for this gauge.
 Vector getNeedles()
          Returns the list of needles associated with this scale.
 Vector getRanges()
          Returns the list of ranges.
 boolean getRepaintEnabled()
          Disable/enable repaints of gauge and its components.
 JCCircularScale getScale()
          Returns the scale associated with this gauge.
 boolean getSnapToValue()
          Returns the snapToValue property that controls whether the needle should snap to the closest discrete integral scale value (true) or to any scale value (false).
 Vector getTicks()
          Returns the tick objects for this gauge.
 void mouseClicked(MouseEvent event)
          Sends pick events to listeners.
 void mouseDragged(MouseEvent event)
           
 void mouseEntered(MouseEvent event)
           
 void mouseExited(MouseEvent event)
           
 void mouseMoved(MouseEvent event)
           
 void mousePressed(MouseEvent event)
           
 void mouseReleased(MouseEvent event)
           
 JCGaugePickEvent pick(Point p)
          Given a screen location in pixels, returns the closest scale value wrapped in a JCGaugePickEvent.
 void removeNeedle(JCNeedle needle)
          Removes a needle from this scale.
 void removePickListener(JCGaugePickListener l)
          Removes a listener to gauge pick events.
 void removeRange(JCRange range)
          Removes a range.
 void removeTick(JCTick tick)
          Removes a tick to a gauge.
 void sendPickEvent(JCGaugePickEvent ev)
          Broadcasts the pick event to interested listeners.
 void setFooter(JComponent newFooter)
          Sets the Footer property.
 void setGaugeArea(JCGaugeArea newGaugeArea)
          Sets the value of the gaugeArea property.
 void setHeader(JComponent newHeader)
          Sets the Header property.
 void setLegend(JCLegend newLegend)
          Sets the Legend property The Legend property controls the object that controls the display of the legend.
 void setRepaintEnabled(boolean repaintEnabled)
          Disable/enable repaints of gauge and its components.
 void setScale(JCCircularScale scale)
          Adds a scale to the gauge.
 void setSnapToValue(boolean snapToValue)
          Sets the snapToValue property that controls whether the needle should snap to the closest discrete integral scale value (true) or to any scale value (false).
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getUIClassID, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setCursor, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

gaugeArea

protected JCGaugeArea gaugeArea
The drawing area for the circular gauge.

header

protected JComponent header
The header component.

footer

protected JComponent footer
The footer component.

legend

protected JCLegend legend
The Legend.
See Also:
JCLegend

scale

protected JCCircularScale scale
The scale associated with this gauge.

needles

protected Vector needles
The list of needles assocated with this gauge.

pickListeners

protected com.klg.jclass.util.JCListenerList pickListeners
List of listeners interested in pick events.

draggedNeedle

protected JCNeedle draggedNeedle
The needle currently being dragged.

ranges

protected Vector ranges
The list of ranges for this gauge.

snapToValue

protected boolean snapToValue
Snap to closest integral scale value; default: false

repaintEnabled

protected boolean repaintEnabled
Allow batching of changes by toggling repaint off/on.

gaugeAreaLayoutHints

protected Rectangle gaugeAreaLayoutHints

legendLayoutHints

protected Rectangle legendLayoutHints

headerLayoutHints

protected Rectangle headerLayoutHints

footerLayoutHints

protected Rectangle footerLayoutHints
Constructor Detail

JCGauge

public JCGauge()
No-argument constructor for JCCircularGauge.
Method Detail

getSnapToValue

public boolean getSnapToValue()
Returns the snapToValue property that controls whether the needle should snap to the closest discrete integral scale value (true) or to any scale value (false).
Returns:
true if discrete movements are enforced, false means continuous movement is allowed.

setSnapToValue

public void setSnapToValue(boolean snapToValue)
Sets the snapToValue property that controls whether the needle should snap to the closest discrete integral scale value (true) or to any scale value (false).
Parameters:
snapToValue - true for discrete movements, false means continuous movement is allowed

addNeedle

public void addNeedle(JCNeedle needle)
Adds a needle to this scale.
Parameters:
needle - A JCNeedle to associate with this scale

addNeedle

public void addNeedle(JCNeedle needle,
                      int index)
Adds a needle to this scale.
Parameters:
needle - The needle to be added
index - The position in the list of needles where this one is to be added

removeNeedle

public void removeNeedle(JCNeedle needle)
Removes a needle from this scale.
Parameters:
needle - The JCNeedle to be removed

getNeedles

public Vector getNeedles()
Returns the list of needles associated with this scale.
Returns:
The Vector of needles for this scale

addTick

public void addTick(JCTick tick)
Adds a tick to a gauge.
Parameters:
tick - The JCCircularTick to be added

addTick

public void addTick(JCTick tick,
                    int index)
Adds a tick object to a gauge.
Parameters:
tick - The JCCircularTick to be added
index - The z-order index

removeTick

public void removeTick(JCTick tick)
Removes a tick to a gauge.
Parameters:
tick - The JCCircularTick to be removed

getTicks

public Vector getTicks()
Returns the tick objects for this gauge.
Returns:
A Vector of tick objects

addRange

public void addRange(JCRange range)
Adds a range to the gauge.
Parameters:
range - The JCRange to be added

addRange

public void addRange(JCRange range,
                     int index)
Adds a range to the gauge.
Parameters:
range - The JCRange to be added
index - The z-order index

removeRange

public void removeRange(JCRange range)
Removes a range.
Parameters:
range - The JCRange to be removed

getRanges

public Vector getRanges()
Returns the list of ranges.
Returns:
the Vector of ranges for this gauge

setScale

public void setScale(JCCircularScale scale)
Adds a scale to the gauge.
Parameters:
scale - The scale to be added

getScale

public JCCircularScale getScale()
Returns the scale associated with this gauge.
Returns:
The scale for the JCCircularGauge component.

getLegend

public JCLegend getLegend()
Returns the legend for this gauge.
Specified by:
getLegend in interface com.klg.jclass.util.DefaultComponentLayoutUser
Returns:
the legend for this gauge

setLegend

public void setLegend(JCLegend newLegend)
Sets the Legend property The Legend property controls the object that controls the display of the legend.
Parameters:
newLegend - The legend for this gauge

getGaugeArea

public JCGaugeArea getGaugeArea()
Returns the gauge area for this gauge.
Returns:
the JCGaugeArea for this gauge

setGaugeArea

public void setGaugeArea(JCGaugeArea newGaugeArea)
Sets the value of the gaugeArea property. This is currently disabled. The gaugeArea property controls the object that controls the display of the gauge.
Parameters:
newGaugeArea -  

setRepaintEnabled

public void setRepaintEnabled(boolean repaintEnabled)
Disable/enable repaints of gauge and its components. This allows for batched updates. A repaint is issued when set to true.
Parameters:
repaintEnabled - true enables repaints, false disables them

getRepaintEnabled

public boolean getRepaintEnabled()
Disable/enable repaints of gauge and its components. This allows for batched updates.
Returns:
repaintEnabled -- true enables repaints, false disables them

pick

public JCGaugePickEvent pick(Point p)
Given a screen location in pixels, returns the closest scale value wrapped in a JCGaugePickEvent.
Parameters:
p - The Point at which the event occurred
Returns:
a JCGaugePickEvent which wraps the closest value

addPickListener

public void addPickListener(JCGaugePickListener l)
Adds a listener for gauge pick events.
Parameters:
l -  

removePickListener

public void removePickListener(JCGaugePickListener l)
Removes a listener to gauge pick events.
Parameters:
l -  

sendPickEvent

public void sendPickEvent(JCGaugePickEvent ev)
Broadcasts the pick event to interested listeners.
Parameters:
ev - The JCGaugePickEvent of interest

getHeader

public JComponent getHeader()
Returns the header for this gauge.
Specified by:
getHeader in interface com.klg.jclass.util.DefaultComponentLayoutUser
Returns:
the header for this gauge

setHeader

public void setHeader(JComponent newHeader)
Sets the Header property. The Header property controls the object that controls the display of the header.
Parameters:
newHeader - The JComponent that is used as a header for the gauge

getFooter

public JComponent getFooter()
Returns the footer for this gauge.
Specified by:
getFooter in interface com.klg.jclass.util.DefaultComponentLayoutUser
Returns:
the footer for this gauge

setFooter

public void setFooter(JComponent newFooter)
Sets the Footer property. The Footer property controls the object that controls the display of the footer.
Parameters:
newFooter - The JComponent that is used as a footer for the gauge

getDrawingAreaHeight

public int getDrawingAreaHeight()
Gets the height of the drawing area represented by this gauge.
Specified by:
getDrawingAreaHeight in interface com.klg.jclass.util.DefaultComponentLayoutUser

getDrawingAreaWidth

public int getDrawingAreaWidth()
Gets the width of the drawing area represented by this gauge.
Specified by:
getDrawingAreaWidth in interface com.klg.jclass.util.DefaultComponentLayoutUser

getLayoutHints

public Rectangle getLayoutHints(JComponent child)
Gets layout hints for the specified gauge child.
Specified by:
getLayoutHints in interface com.klg.jclass.util.DefaultComponentLayoutUser
Parameters:
child - gauge child -- either the gaugeArea, legend, header, or footer.
Returns:
Rectangle object containing the desired layout hints. Null is child is not one of the valid children of gauge.

getComponentArea

public JComponent getComponentArea()
Returns the JClass component's sub-component on which the actual drawing of the gauge will be performed.
Specified by:
getComponentArea in interface com.klg.jclass.util.DefaultComponentLayoutUser
Returns:
the JCComponent on which to draw

mouseEntered

public void mouseEntered(MouseEvent event)
Specified by:
mouseEntered in interface MouseListener
Parameters:
event -  

mouseExited

public void mouseExited(MouseEvent event)
Specified by:
mouseExited in interface MouseListener
Parameters:
event -  

mouseReleased

public void mouseReleased(MouseEvent event)
Specified by:
mouseReleased in interface MouseListener
Parameters:
event -  

mousePressed

public void mousePressed(MouseEvent event)
Specified by:
mousePressed in interface MouseListener
Parameters:
event -  

mouseClicked

public void mouseClicked(MouseEvent event)
Sends pick events to listeners.
Specified by:
mouseClicked in interface MouseListener
Parameters:
event -  

mouseMoved

public void mouseMoved(MouseEvent event)
Specified by:
mouseMoved in interface MouseMotionListener

mouseDragged

public void mouseDragged(MouseEvent event)
Specified by:
mouseDragged in interface MouseMotionListener

Copyright© 1999-2000 KL Group Inc.
All rights reserved.