JClass 4.5.0 API
Documentation

com.klg.jclass.swing.gauge
Class JCCircularGauge

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

public class JCCircularGauge
extends JCGauge
implements Serializable

JCCircularGauge models a real-world gauge such as you might see on a car dashboard. This class encapsulates the available types of circular gauges: full circle, semicircle, and quadrant.

JCCircularGauge manual.

See Also:
Serialized Form

Inner Class Summary
static class JCCircularGauge.GaugeType
          Enums for gauge types.
 
Inner classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Field Summary
protected  JCCenter center
          The center object.
protected  JCCircularGauge.GaugeType gaugeType
          The type of gauge, full circle, semicircle, or quadrant.
protected  Vector labels
          The list of labels for this gauge.
 
Fields inherited from class com.klg.jclass.swing.gauge.JCGauge
draggedNeedle, footer, footerLayoutHints, gaugeArea, gaugeAreaLayoutHints, header, headerLayoutHints, legend, legendLayoutHints, needles, pickListeners, ranges, repaintEnabled, scale, snapToValue
 
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
JCCircularGauge()
          No-argument constructor for JCCircularGauge.
JCCircularGauge(JCCircularGauge.GaugeType gaugeType)
          Constructs a gauge of the specified gauge type.
 
Method Summary
 void addLabel(JComponent label, RadialConstraint constraint)
          Adds a label to the gauge.
 void addLabel(JComponent label, RadialConstraint constraint, int index)
          Adds a label to the gauge.
protected  Rectangle getArcBounds()
          Determines the x, y, width and height of an arc's bounding box.
 JCCenter getCenter()
          Returns the center for this gauge.
 JCNeedle getClosestNeedle(JCGaugePickEvent pe, JCNeedle.InteractionType interactionType)
          Returns the closest needle to the clicked/dragged point.
 JCCircularGauge.GaugeType getGaugeType()
          Gets the gauge type, one of the JCCircularGauge.GaugeType enums.
 void mouseClicked(MouseEvent event)
          Sends pick events to listeners and moves the closest needle with a CLICK interaction enabled to the value indicated by the mouse click.
 void mouseDragged(MouseEvent event)
          Drags the closest needle.
 void paintComponent(Graphics g)
          Paints the gauge.
 void redraw()
          Call this instead of paint so that the repaintEnabled flag can be checked.
 void removeLabel(JComponent label)
          Removes a label.
 void setCenter(JCCenter center)
          Sets the center for this gauge.
 void setCenter(JCCenter center, int index)
          Sets the center object for this gauge.
 void setGaugeType(JCCircularGauge.GaugeType gaugeType)
          Sets the type for this gauge, one of the JCCircularGauge.GaugeType enums.
protected  double valueToAngle(double value)
          A convenience method that returns the angle corresponding to a circular scale value.
 
Methods inherited from class com.klg.jclass.swing.gauge.JCGauge
addNeedle, addNeedle, addPickListener, addRange, addRange, addTick, addTick, getComponentArea, getDrawingAreaHeight, getDrawingAreaWidth, getFooter, getGaugeArea, getHeader, getLayoutHints, getLegend, getNeedles, getRanges, getRepaintEnabled, getScale, getSnapToValue, getTicks, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, pick, removeNeedle, removePickListener, removeRange, removeTick, sendPickEvent, setFooter, setGaugeArea, setHeader, setLegend, setRepaintEnabled, setScale, setSnapToValue
 
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, 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

gaugeType

protected JCCircularGauge.GaugeType gaugeType
The type of gauge, full circle, semicircle, or quadrant.

center

protected JCCenter center
The center object.

labels

protected Vector labels
The list of labels for this gauge.
See Also:
JCLabelGenerator
Constructor Detail

JCCircularGauge

public JCCircularGauge()
No-argument constructor for JCCircularGauge. Creates a default center, needle, and tick marks.
See Also:
JCGauge.setScale(JCCircularScale), setCenter(JCCenter), JCGauge.addNeedle(JCNeedle), JCGauge.addTick(JCTick), JCGauge.getScale(), getCenter(), JCGauge.removeNeedle(JCNeedle), JCGauge.removeTick(JCTick)

JCCircularGauge

public JCCircularGauge(JCCircularGauge.GaugeType gaugeType)
Constructs a gauge of the specified gauge type. The scale, center, needles and ticks must be added using these methods,
Parameters:
gaugeType - One of the constants defined in this class.
See Also:
JCGauge.setScale(JCCircularScale), setCenter(JCCenter), JCGauge.addNeedle(JCNeedle), JCGauge.addTick(JCTick), JCGauge.getScale(), getCenter(), JCGauge.removeNeedle(JCNeedle), JCGauge.removeTick(JCTick)
Method Detail

paintComponent

public void paintComponent(Graphics g)
Paints the gauge.
Overrides:
paintComponent in class JComponent
Parameters:
g - The Graphics with which to paint

addLabel

public void addLabel(JComponent label,
                     RadialConstraint constraint)
Adds a label to the gauge.
Parameters:
label - The JComponent to be added as a label
constraint - The RadialConstraint specifying where to place the label

addLabel

public void addLabel(JComponent label,
                     RadialConstraint constraint,
                     int index)
Adds a label to the gauge.
Parameters:
label - The JComponent to be added as a label
constraint - The RadialConstraint specifying where to place the label
index - The z-order index

removeLabel

public void removeLabel(JComponent label)
Removes a label.
Parameters:
label - The JComponent to be removed

getCenter

public JCCenter getCenter()
Returns the center for this gauge.
Returns:
The JCCenter object associated with this gauge.

setCenter

public void setCenter(JCCenter center,
                      int index)
Sets the center object for this gauge.
Parameters:
center - The JCCenter for this gauge
index - The z-order index at which to add the center

setCenter

public void setCenter(JCCenter center)
Sets the center for this gauge.
Parameters:
center - The JCCenter for this gauge

getGaugeType

public JCCircularGauge.GaugeType getGaugeType()
Gets the gauge type, one of the JCCircularGauge.GaugeType enums.
Returns:
The gauge type

setGaugeType

public void setGaugeType(JCCircularGauge.GaugeType gaugeType)
Sets the type for this gauge, one of the JCCircularGauge.GaugeType enums.
Parameters:
gaugeType - The gauge type, full circle, semicircle, or quadrant.

getArcBounds

protected Rectangle getArcBounds()
Determines the x, y, width and height of an arc's bounding box.
Returns:
The Rectangle bounding the arc

mouseClicked

public void mouseClicked(MouseEvent event)
Sends pick events to listeners and moves the closest needle with a CLICK interaction enabled to the value indicated by the mouse click.
Overrides:
mouseClicked in class JCGauge
Parameters:
event - A MouseEvent

mouseDragged

public void mouseDragged(MouseEvent event)
Drags the closest needle.
Overrides:
mouseDragged in class JCGauge
Parameters:
event - A MouseEvent

getClosestNeedle

public JCNeedle getClosestNeedle(JCGaugePickEvent pe,
                                 JCNeedle.InteractionType interactionType)
Returns the closest needle to the clicked/dragged point. Returns closest needle of type CLICK/DRAG/CLICK_DRAG, or if there are none of these, the closest needle of type NONE.
Parameters:
pe - The pick event with the click inforamation
interactionType - The needle must be of this JCNeedle.InteractionType
Returns:
The closest needle of the indicated type

valueToAngle

protected double valueToAngle(double value)
A convenience method that returns the angle corresponding to a circular scale value.
Parameters:
value - A circular scale value.

redraw

public void redraw()
Call this instead of paint so that the repaintEnabled flag can be checked. No repaint will occur if that flag is false.

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