JClass 4.5.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.JCScale
                          |
                          +--com.klg.jclass.swing.gauge.JCCircularScale

public class JCCircularScale
extends JCScale
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

Inner classes inherited from class com.klg.jclass.swing.gauge.JCScale
JCScale.Direction
 
Inner classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Field Summary
protected  double extent
          Paints a scale background covering this ratio from the origin.
protected  JCCircularGauge gauge
          The parent gauge.
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.JCScale
direction, max, min, ticks
 
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
JCCircularScale(JCCircularGauge gauge)
          Creates a scale given its parent gauge.
JCCircularScale(JCCircularGauge gauge, JCScale.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.
 double getExtent()
          Returns the background extent for this scale.
 JCCircularGauge getGauge()
          Returns the gauge associated with this scale
 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.
 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 setExtent(double extent)
          Sets the background extent for this scale.
 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.JCScale
addTick, addTick, getDirection, getMax, getMin, getTicks, inBounds, removeTick, setDirection, setMax, setMin
 
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, 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, 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

startAngle

protected double startAngle
The start angle in degrees.

stopAngle

protected double stopAngle
The stop angle in degrees.

gauge

protected JCCircularGauge gauge
The parent gauge.

minSize

protected double minSize
The minimum diameter for the scale.

extent

protected double extent
Paints a scale background covering this ratio from the origin. See A note on the extent property in the manual. Default = 1.0

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. If not just from 0° to 270°. 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(JCCircularGauge gauge)
Creates a scale given its parent gauge.
Parameters:
gauge - The JCCircularGauge associated with this scale.

JCCircularScale

public JCCircularScale(JCCircularGauge gauge,
                       JCScale.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 JCCircularScale.Direction enum indicating CLOCKWISE or COUNTERCLOCKWISE 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 to 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.

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.

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.
Parameters:
p - The point representing the x, y coordinates of the click
Returns:
the value closest to the point

getRadius

public double getRadius()
Returns the current radius of this scale. The radius is calculated as half the width of 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 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

getGauge

public JCCircularGauge getGauge()
Returns the gauge associated with this scale
Returns:
The gauge associated with this scale

getExtent

public double getExtent()
Returns the background extent for this scale. The scale's background is drawn from the center to this distance (expressed as a ratio of the scale's radius). For example, 0.75 means draw from the center out to 75% of the scale's radius. The maximum extent possible is 1.0, the minimum is 0.
Returns:
The extent of the circuar scale's foreground color.

setExtent

public void setExtent(double extent)
Sets the background extent for this scale. The scale's background is drawn from the center to this distance (expressed as a ratio of the scale's radius). For example, 0.75 means draw from the center out to 75% of the scale's radius. The maximum extent possible is 1.0, the minimum is 0. .
Parameters:
extent - The extent of the circuar scale's foreground color. Used when tick objects and labels need to appear "outside" the 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 JCScale

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