JClass DesktopViews 6.3.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
All Implemented Interfaces:
EventListener, ImageObserver, LegendComponentLayoutUser, MenuContainer, MouseListener, MouseMotionListener, Serializable, com.klg.jclass.util.ServerRenderable
Direct Known Subclasses:
JCCircularGaugeBean

public class JCCircularGauge
extends JCGauge
implements Serializable, com.klg.jclass.util.ServerRenderable

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.

See Also:
Serialized Form

Nested Class Summary
static class JCCircularGauge.GaugeType
          Enums for gauge types.
 
Nested classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  com.klg.jclass.swing.gauge.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, image, indicators, legend, legendLayoutHints, needles, pickListeners, repaintEnabled, scale, scaleImage, 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
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JCCircularGauge()
          No-argument constructor for JCCircularGauge.
JCCircularGauge(boolean createScale)
          Constructs a JCCircularGauge with no default objects except possibly a circular scale.
JCCircularGauge(JCCircularGauge.GaugeType gaugeType)
          Constructs a gauge of the specified gauge type.
 
Method Summary
 void addLabel(JComponent label, com.klg.jclass.swing.gauge.RadialConstraint constraint)
          Adds a label to the gauge.
 void addLabel(JComponent label, com.klg.jclass.swing.gauge.RadialConstraint constraint, int index)
          Adds a label to the gauge.
protected  void drawImage(Graphics g, Image image, Rectangle bounds, Color color)
          Draws an image as the gauge background.
 Rectangle getArcBounds()
          Determines the x, y, width and height of an arc's bounding box.
 com.klg.jclass.swing.gauge.JCCenter getCenter()
          Returns the center for this gauge.
 com.klg.jclass.swing.gauge.JCCircularScale getCircularScale()
          Returns the circular gauge's circular scale (appropriately cast).
 com.klg.jclass.swing.gauge.JCCircularNeedle getClosestNeedle(com.klg.jclass.swing.gauge.JCGaugePickEvent pe, JCAbstractNeedle.InteractionType interactionType)
          Returns the closest needle to the clicked/dragged point.
 JCCircularGauge.GaugeType getGaugeType()
          Gets the gauge type, one of the JCCircularGauge.GaugeType enums.
 Graphics getGraphics()
          Overrides parent getGraphics().
 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 serverPaint(Graphics igc)
          Internal use only.
 Image serverSnapshot()
          Internal use only.
 void setCenter(com.klg.jclass.swing.gauge.JCCenter center)
          Sets the center for this gauge.
 void setCenter(com.klg.jclass.swing.gauge.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.
 void setGraphics(Graphics g)
          Provides a way for the circular gauge to draw to a custom Graphics object.
 void setScale(com.klg.jclass.swing.gauge.JCCircularScale scale)
          Adds a circular scale to the circular gauge.
 void setScale(com.klg.jclass.swing.gauge.JCCircularScale scale, boolean addToGaugeArea)
          Adds a circular scale to the circular gauge.
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
addIndicator, addIndicator, addNeedle, addNeedle, addPickListener, addRange, addRange, addTick, addTick, getAbout, getComponentArea, getDrawingAreaHeight, getDrawingAreaWidth, getFooter, getGaugeArea, getHeader, getImage, getIndicators, getLayoutHints, getLegend, getNeedles, getRanges, getRepaintEnabled, getScale, getScaleImage, getSnapToValue, getTicks, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, pick, removeIndicator, removeNeedle, removePickListener, removeRange, removeTick, sendPickEvent, setAbout, setFooter, setGaugeArea, setHeader, setImage, setIndicatorScales, setLegend, setNeedleScales, setRepaintEnabled, setScaleImage, setSnapToValue
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.klg.jclass.util.legend.LegendComponentLayoutUser
getPreferredSize
 

Field Detail

gaugeType

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


center

protected com.klg.jclass.swing.gauge.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:
setScale(JCCircularScale), setCenter(JCCenter), JCGauge.addNeedle(JCAbstractNeedle), JCGauge.addTick(JCTick), JCGauge.getScale(), getCenter(), JCGauge.removeNeedle(JCAbstractNeedle), JCGauge.removeTick(JCTick)

JCCircularGauge

public JCCircularGauge(boolean createScale)
Constructs a JCCircularGauge with no default objects except possibly a circular scale.

Use the following methods to add needles, indicators, ticks, and ranges.

Parameters:
createScale -
See Also:
setScale(JCCircularScale), setCenter(JCCenter), JCGauge.addIndicator(JCAbstractIndicator), JCGauge.addNeedle(JCAbstractNeedle), JCAbstractScale.addRange(JCRange), JCGauge.addTick(JCTick), JCGauge.getScale(), getCenter(), JCGauge.removeIndicator(JCAbstractIndicator), JCGauge.removeNeedle(JCAbstractNeedle), JCAbstractScale.removeRange(JCRange), JCGauge.removeTick(JCTick)

JCCircularGauge

public JCCircularGauge(JCCircularGauge.GaugeType gaugeType)
Constructs a gauge of the specified gauge type. The scale, center, needles, ranges and ticks must be added using the following methods.

Parameters:
gaugeType - one of the constants defined in this class
See Also:
setScale(JCCircularScale), setCenter(JCCenter), JCGauge.addIndicator(JCAbstractIndicator), JCGauge.addNeedle(JCAbstractNeedle), JCAbstractScale.addRange(JCRange), JCGauge.addTick(JCTick), JCGauge.getScale(), getCenter(), JCGauge.removeIndicator(JCAbstractIndicator), JCGauge.removeNeedle(JCAbstractNeedle), JCAbstractScale.removeRange(JCRange), 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

getCircularScale

public com.klg.jclass.swing.gauge.JCCircularScale getCircularScale()
Returns the circular gauge's circular scale (appropriately cast).

Returns:
the circular gauge's circular scale

setScale

public void setScale(com.klg.jclass.swing.gauge.JCCircularScale scale,
                     boolean addToGaugeArea)
Adds a circular scale to the circular gauge.

Parameters:
scale - the circular scale to be added
addToGaugeArea - add the scale to the gauge's gaugeArea?

setScale

public void setScale(com.klg.jclass.swing.gauge.JCCircularScale scale)
Adds a circular scale to the circular gauge.

Parameters:
scale - the circular scale to be added

addLabel

public void addLabel(JComponent label,
                     com.klg.jclass.swing.gauge.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,
                     com.klg.jclass.swing.gauge.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 com.klg.jclass.swing.gauge.JCCenter getCenter()
Returns the center for this gauge.

Returns:
the JCCenter object associated with this gauge

setCenter

public void setCenter(com.klg.jclass.swing.gauge.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(com.klg.jclass.swing.gauge.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

public 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.

Specified by:
mouseClicked in interface MouseListener
Overrides:
mouseClicked in class JCGauge
Parameters:
event - a MouseEvent

mouseDragged

public void mouseDragged(MouseEvent event)
Drags the closest needle.

Specified by:
mouseDragged in interface MouseMotionListener
Overrides:
mouseDragged in class JCGauge
Parameters:
event - a MouseEvent

getClosestNeedle

public com.klg.jclass.swing.gauge.JCCircularNeedle getClosestNeedle(com.klg.jclass.swing.gauge.JCGaugePickEvent pe,
                                                                    JCAbstractNeedle.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 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
Returns:
The angle based on the 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.

Specified by:
redraw in class JCGauge

drawImage

protected void drawImage(Graphics g,
                         Image image,
                         Rectangle bounds,
                         Color color)
Draws an image as the gauge background.

Parameters:
g - the Graphics on which to draw
bounds -
color -
image -

getGraphics

public Graphics getGraphics()
Overrides parent getGraphics(). If another Graphics object has been set to be the current one, it is returned. Otherwise, call the superclass' getGraphics() method.

Specified by:
getGraphics in interface com.klg.jclass.util.ServerRenderable
Overrides:
getGraphics in class JComponent
Returns:
the Graphics object to use to draw this chart

setGraphics

public void setGraphics(Graphics g)
Provides a way for the circular gauge to draw to a custom Graphics object. Call with a null to specify use of the default Graphics object used to draw to the screen.

Specified by:
setGraphics in interface com.klg.jclass.util.ServerRenderable
Parameters:
g - Graphics object to use for drawing

serverSnapshot

public Image serverSnapshot()
Internal use only. Don't use.

Specified by:
serverSnapshot in interface com.klg.jclass.util.ServerRenderable

serverPaint

public void serverPaint(Graphics igc)
Internal use only. Don't use.

Specified by:
serverPaint in interface com.klg.jclass.util.ServerRenderable

Copyright © 2004 Quest Software Inc..
All rights reserved.