JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.swing.gauge
Class JCCircularScale

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--com.klg.jclass.swing.gauge.JCAbstractScale
                          |
                          +--com.klg.jclass.swing.gauge.JCCircularScale
All Implemented Interfaces:
ImageObserver, JCScale, MenuContainer, Serializable

public class JCCircularScale
extends JCAbstractScale
implements Serializable

JCCircularScale provides a graduated scale. Angular measurements follow this convention: Zero degrees is at 3 o'clock, 90° at 12 o'clock, 180° at 9 o'clock and 270° at 6 o'clock. JCTicks are used to mark this scale so that readings may be taken. See the section on how angles are measured in the manual.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class com.klg.jclass.swing.gauge.JCAbstractScale
JCAbstractScale.Direction
 
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  double minSize
          The minimum diameter for the scale.
protected  boolean paintCompleteBackground
          Paints the complete background defined by JCCircularGauge.GaugeType, not just area swept by the scale.
protected  double startAngle
          The start angle in degrees.
protected  double stopAngle
          The stop angle in degrees.
 
Fields inherited from class com.klg.jclass.swing.gauge.JCAbstractScale
direction, gauge, image, max, min, ranges, scaleImage, ticks, zoomFactor
 
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
JCCircularScale(com.klg.jclass.swing.gauge.JCCircularGauge gauge)
          Creates a scale given its parent gauge.
JCCircularScale(com.klg.jclass.swing.gauge.JCCircularGauge gauge, JCAbstractScale.Direction direction, double min, double max, double startAngle, double stopAngle, Color foreground)
          Creates a graduated scale.
 
Method Summary
 Component add(Component c)
          Overrides add to pass in a radial constraint.
 Component add(Component c, int index)
          Overrides add to pass in a radial constraint.
protected  void drawImage(Graphics g, Image image, Rectangle bounds)
           
 com.klg.jclass.swing.gauge.JCCircularGauge getCircularGauge()
          Returns the circular gauge associated with this scale.
protected  Shape getCircularScaleShape(com.klg.jclass.swing.gauge.JCCircularScale cscale)
           
 boolean getPaintCompleteBackground()
          Paints the complete background defined by the GaugeType, not just area swept by scale.
 Dimension getPreferredSize()
          This is called by our widget parent when it wants to know our preferrred size.
 double getRadius()
          Returns the current radius of this scale.
protected  Insets getScaleInsets()
          Since the scale and the gaugeArea share the same real estate, their insets may overlap (note that the scale's border will be drawn overtop of the gaugeArea's border).
 double getStartAngle()
          Returns the start angle for this scale.
 double getStopAngle()
          Returns the stop angle for this scale.
 void paintComponent(Graphics g)
          Draws the background of this scale.
 double pick(Point p)
          Given a screen position in pixels, returns the closest scale value.
 void redraw()
          Call this instead of paint so that the repaintEnabled flag can be checked.
 void setPaintCompleteBackground(boolean paintCompleteBackground)
          If true, paints the complete background for this GaugeType, not just area between the scale's start and stop angles.
 void setStartAngle(double startAngle)
          Sets the start angle for this scale.
 void setStopAngle(double stopAngle)
          Sets the stop angle for this scale.
 
Methods inherited from class com.klg.jclass.swing.gauge.JCAbstractScale
addRange, addRange, addTick, addTick, getDirection, getExtent, getGauge, getImage, getMax, getMin, getRanges, getScaleImage, getTicks, getZoomFactor, inBounds, removeRange, removeTick, setDirection, setExtent, setImage, setMax, setMin, setScaleImage, setZoomFactor
 
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, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, 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, 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.swing.gauge.JCScale
setBorder
 

Field Detail

startAngle

protected double startAngle
The start angle in degrees.


stopAngle

protected double stopAngle
The stop angle in degrees.


minSize

protected double minSize
The minimum diameter for the scale.


paintCompleteBackground

protected boolean paintCompleteBackground
Paints the complete background defined by JCCircularGauge.GaugeType, not just area swept by the scale. For instance, a scale whose type is FULL_CIRCLE and whose angular sweep is from 0° to 270° paints only that region. The default is false.
True means paint the entire area specified in GaugeType, false means just the area spanning the scale's sweep angle.

Constructor Detail

JCCircularScale

public JCCircularScale(com.klg.jclass.swing.gauge.JCCircularGauge gauge)
Creates a scale given its parent gauge.

Parameters:
gauge - the JCCircularGauge associated with this scale.

JCCircularScale

public JCCircularScale(com.klg.jclass.swing.gauge.JCCircularGauge gauge,
                       JCAbstractScale.Direction direction,
                       double min,
                       double max,
                       double startAngle,
                       double stopAngle,
                       Color foreground)
Creates a graduated scale.

Parameters:
gauge - the JCCircularGauge associated with this scale.
direction - a JCAbstractScale.Direction enum indicating FORWARD or BACKWARD direction
min - the minumum value this scale can have
max - the maximum value this scale can have
startAngle - the start angle in degrees
stopAngle - the stop angle in degrees
foreground - the color of this scale's foreground
Method Detail

getPreferredSize

public Dimension getPreferredSize()
This is called by our widget parent when it wants to know our preferrred size.

Overrides:
getPreferredSize in class JComponent
Returns:
the Dimension (size) we'd like to be based on our radius

add

public Component add(Component c)
Overrides add to pass in a radial constraint.

Overrides:
add in class Container
Parameters:
c - the component to be added
Returns:

add

public Component add(Component c,
                     int index)
Overrides add to pass in a radial constraint.

Overrides:
add in class Container
Parameters:
c - the component to be added
index - the order this component has in the list; components added last are drawn first
Returns:

paintComponent

public void paintComponent(Graphics g)
Draws the background of this scale.

Overrides:
paintComponent in class JComponent
Parameters:
g - the Graphics object onto which we will draw our background

pick

public double pick(Point p)
Given a screen position in pixels, returns the closest scale value.

Specified by:
pick in interface JCScale
Specified by:
pick in class JCAbstractScale
Parameters:
p - the point representing the X, Y coordinates of the click
Returns:
the value closest to the point

getScaleInsets

protected Insets getScaleInsets()
Since the scale and the gaugeArea share the same real estate, their insets may overlap (note that the scale's border will be drawn overtop of the gaugeArea's border). Thus we need to return an Insets object which is the union of both.

Returns:
the scale/gaugeArea insets

getRadius

public double getRadius()
Returns the current radius of this scale. The radius is calculated as half the width of gauge area.
Note: The radius will be "scaled" by the scale's zoomFactor so the actual size may be smaller than the gauge area.

Returns:
the radius of the circular scale

getStartAngle

public double getStartAngle()
Returns the start angle for this scale.

Returns:
the start angle for this scale in degrees

setStartAngle

public void setStartAngle(double startAngle)
Sets the start angle for this scale.

Parameters:
startAngle - the start angle for this scale, in degrees

getStopAngle

public double getStopAngle()
Returns the stop angle for this scale.

Returns:
the stop angle for this scale, in degrees

setStopAngle

public void setStopAngle(double stopAngle)
Sets the stop angle for this scale.

Parameters:
stopAngle - the stop angle for this scale, in degrees

getCircularGauge

public com.klg.jclass.swing.gauge.JCCircularGauge getCircularGauge()
Returns the circular gauge associated with this scale.

Returns:
the circular gauge associated with this scale

getPaintCompleteBackground

public boolean getPaintCompleteBackground()
Paints the complete background defined by the GaugeType, not just area swept by scale. For instance, you can have a scale defined from 0° to 270° for a FULL_CIRCLE, yet have the full circle background painted, not just from 0° to 270°. The default is false.

Returns:
true means paint all the background; false means just the area spanned by scale's sweep angle

setPaintCompleteBackground

public void setPaintCompleteBackground(boolean paintCompleteBackground)
If true, paints the complete background for this GaugeType, not just area between the scale's start and stop angles. For instance, a scale defined from 0° to 270° and having gauge type FULL_CIRCLE has the full circular background painted, not just the part from 0° to 270°. The default is false.

Parameters:
paintCompleteBackground - true means paint all of the background consistent with the gauge type

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.

Overrides:
redraw in class JCAbstractScale

getCircularScaleShape

protected Shape getCircularScaleShape(com.klg.jclass.swing.gauge.JCCircularScale cscale)

drawImage

protected void drawImage(Graphics g,
                         Image image,
                         Rectangle bounds)

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