JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.swing.gauge
Class JCAbstractScale

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

public abstract class JCAbstractScale
extends JComponent
implements JCScale

A graduated scale. A scale has a minimum value, a maximum value, and a direction. It also is associated with other objects like JCTick, JCIndicator, JCNeedle, and JCRange. These associated objects use the scale to get information that they need to render themselves.

See Also:
Serialized Form

Nested Class Summary
static class JCAbstractScale.Direction
          Enum's for the direction parameter.
 
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  JCAbstractScale.Direction direction
          A JCCircularScale.Direction enum, FORWARD or BACKWARD, giving the direction in which scale values increase.
protected  com.klg.jclass.swing.gauge.JCGauge gauge
          The parent gauge.
protected  Image image
          An image may be used for this scale.
protected  double max
          The minumum value this scale can have.
protected  double min
          The maximum value this scale can have.
protected  Vector ranges
          The list of ranges for this scale.
protected  boolean scaleImage
          Boolean that determines if the image should be matched when the scale is resized.
protected  Vector ticks
          A list of tick objects for this scale.
protected  double zoomFactor
          Paints a scale background, covering this ratio from the origin for circular scales and the top or left for linear scales.
 
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
JCAbstractScale(com.klg.jclass.swing.gauge.JCGauge gauge)
          Creates a graduated scale.
JCAbstractScale(com.klg.jclass.swing.gauge.JCGauge gauge, JCAbstractScale.Direction direction, double min, double max, Color foreground)
          Creates a graduated scale.
 
Method Summary
 void addRange(com.klg.jclass.swing.gauge.JCRange range)
          Adds a range object to a scale.
 void addRange(com.klg.jclass.swing.gauge.JCRange range, int index)
          Adds a range object to a scale.
 void addTick(com.klg.jclass.swing.gauge.JCTick tick)
          Adds a tick object to a scale.
 void addTick(com.klg.jclass.swing.gauge.JCTick tick, int index)
          Adds a tick object to a scale.
 JCAbstractScale.Direction getDirection()
          Returns the JCCircularScale.Direction for this scale, FORWARD or BACKWARD, giving the direction in which scale values increase.
 double getExtent()
          Deprecated. As of JClass version 4.5.1 replaced by getZoomFactor().
 com.klg.jclass.swing.gauge.JCGauge getGauge()
          Returns the gauge associated with this scale.
 Image getImage()
          Gets the Image used to mark the scale.
 double getMax()
          Returns the maximum value for this scale.
 double getMin()
          Returns the minimum value for this scale.
 Vector getRanges()
          Returns the Vector of tick objects for this scale.
 boolean getScaleImage()
          Scales the image in relation to the scale dimensions.
 Vector getTicks()
          Returns the Vector of tick objects for this scale.
 double getZoomFactor()
          Returns the zoom factor for this scale.
 boolean inBounds(double value)
          Returns true if the value is within the scale's minimum and maximum.
abstract  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 removeRange(com.klg.jclass.swing.gauge.JCRange range)
          Removes a range from a scale.
 void removeTick(com.klg.jclass.swing.gauge.JCTick tick)
          Removes a tick from a scale.
 void setDirection(JCAbstractScale.Direction direction)
          Sets the JCAbstractScale.Direction for this scale, FORWARD or BACKWARD, giving the direction in which scale values increase.
 void setExtent(double zoomFactor)
          Deprecated. As of JClass version 4.5.1 replaced by setZoomFactor().
 void setImage(Image image)
          Sets the Image used to mark the scale.
 void setMax(double max)
          Sets the maximum value for this scale.
 void setMin(double min)
          Sets the minimum value for this scale.
 void setScaleImage(boolean scaleImage)
          Determines whether to adapt the image according to the scale dimensions.
 void setZoomFactor(double zoomFactor)
          Sets the zoom factor for this scale.
 
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, 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, paintComponent, 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.swing.gauge.JCScale
setBorder
 

Field Detail

gauge

protected com.klg.jclass.swing.gauge.JCGauge gauge
The parent gauge.


direction

protected JCAbstractScale.Direction direction
A JCCircularScale.Direction enum, FORWARD or BACKWARD, giving the direction in which scale values increase.
The default value is FORWARD.


min

protected double min
The maximum value this scale can have.


max

protected double max
The minumum value this scale can have.


zoomFactor

protected double zoomFactor
Paints a scale background, covering this ratio from the origin for circular scales and the top or left for linear scales. See A note on the zoomFactor property in the manual. The default is 1.0.


ticks

protected Vector ticks
A list of tick objects for this scale.


ranges

protected Vector ranges
The list of ranges for this scale.


image

protected Image image
An image may be used for this scale.


scaleImage

protected boolean scaleImage
Boolean that determines if the image should be matched when the scale is resized. The default is true.

Constructor Detail

JCAbstractScale

public JCAbstractScale(com.klg.jclass.swing.gauge.JCGauge gauge)
Creates a graduated scale.

Parameters:
gauge - the parent gauge

JCAbstractScale

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

Parameters:
gauge - the parent gauge
direction - the scale's direction
min - the scale's minimum value
max - the scale's maximum value
foreground - the scale's foreground color
Method Detail

getGauge

public com.klg.jclass.swing.gauge.JCGauge getGauge()
Returns the gauge associated with this scale.

Specified by:
getGauge in interface JCScale
Returns:
the gauge associated with this scale

getDirection

public JCAbstractScale.Direction getDirection()
Returns the JCCircularScale.Direction for this scale, FORWARD or BACKWARD, giving the direction in which scale values increase.

Specified by:
getDirection in interface JCScale
Returns:
the JCCircularScale.Direction for this scale

setDirection

public void setDirection(JCAbstractScale.Direction direction)
Sets the JCAbstractScale.Direction for this scale, FORWARD or BACKWARD, giving the direction in which scale values increase.

Specified by:
setDirection in interface JCScale
Parameters:
direction - the JCCircularScale.Direction

getMax

public double getMax()
Returns the maximum value for this scale.

Specified by:
getMax in interface JCScale
Returns:
the maximum value for this scale

setMax

public void setMax(double max)
Sets the maximum value for this scale.

Specified by:
setMax in interface JCScale
Parameters:
max - the maxiumum value for this scale

getMin

public double getMin()
Returns the minimum value for this scale.

Specified by:
getMin in interface JCScale
Returns:
the minimum value for this scale

setMin

public void setMin(double min)
Sets the minimum value for this scale.

Specified by:
setMin in interface JCScale
Parameters:
min - the minimum value for this scale

getExtent

public double getExtent()
Deprecated. As of JClass version 4.5.1 replaced by getZoomFactor().

Returns the zoom factor for this scale.

Specified by:
getExtent in interface JCScale
Returns:
the zoomFactor of this scale

setExtent

public void setExtent(double zoomFactor)
Deprecated. As of JClass version 4.5.1 replaced by setZoomFactor().

Sets the zoom factor for this scale.

Specified by:
setExtent in interface JCScale
Parameters:
zoomFactor - the new zoomFactor

getZoomFactor

public double getZoomFactor()
Returns the zoom factor for this scale. The scale is normally sized so it fits exactly within the component. This may not always be what the user wants as ticks, labels, and other components may need to be drawn outside the scale. Setting zoomFactor allows the scale to be smaller so things outside the scale can be seen.

Specified by:
getZoomFactor in interface JCScale
Returns:
the zoomFactor of this scale

setZoomFactor

public void setZoomFactor(double zoomFactor)
Sets the zoom factor for this scale. The scale is normally sized so it fits exactly within the component. This may not always be what the user wants as ticks, labels, and other components may need to be drawn outside the scale.

Specified by:
setZoomFactor in interface JCScale
Parameters:
zoomFactor - the new zoomFactor

getTicks

public Vector getTicks()
Returns the Vector of tick objects for this scale.

Specified by:
getTicks in interface JCScale
Returns:
a Vector of ticks

addTick

public void addTick(com.klg.jclass.swing.gauge.JCTick tick)
Adds a tick object to a scale.

Specified by:
addTick in interface JCScale
Parameters:
tick - the tick object to be added

addTick

public void addTick(com.klg.jclass.swing.gauge.JCTick tick,
                    int index)
Adds a tick object to a scale.

Specified by:
addTick in interface JCScale
Parameters:
tick - the JCTick to be added to the scale
index - the Z-order index

removeTick

public void removeTick(com.klg.jclass.swing.gauge.JCTick tick)
Removes a tick from a scale.

Specified by:
removeTick in interface JCScale
Parameters:
tick - the JCCircularTick to be removed

getRanges

public Vector getRanges()
Returns the Vector of tick objects for this scale.

Specified by:
getRanges in interface JCScale
Returns:
a Vector of ranges

addRange

public void addRange(com.klg.jclass.swing.gauge.JCRange range)
Adds a range object to a scale.

Specified by:
addRange in interface JCScale
Parameters:
range - the range object to be added

addRange

public void addRange(com.klg.jclass.swing.gauge.JCRange range,
                     int index)
Adds a range object to a scale.

Specified by:
addRange in interface JCScale
Parameters:
range - the JCRange to be added to the scale
index - the Z-order index

removeRange

public void removeRange(com.klg.jclass.swing.gauge.JCRange range)
Removes a range from a scale.

Specified by:
removeRange in interface JCScale
Parameters:
range - the JCRange to be removed

inBounds

public boolean inBounds(double value)
Returns true if the value is within the scale's minimum and maximum.

Specified by:
inBounds in interface JCScale
Parameters:
value - the value to be tested
Returns:
true if the value is within the scale's minimum and maximum

getImage

public Image getImage()
Gets the Image used to mark the scale.

Returns:
the Image used to mark the scale

setImage

public void setImage(Image image)
Sets the Image used to mark the scale.

Parameters:
image - the Image used to mark the scale

getScaleImage

public boolean getScaleImage()
Scales the image in relation to the scale dimensions.

Returns:
true if the image is to be matched to the size of the bounding box of the scale; otherwise, center the image based on its length and width

setScaleImage

public void setScaleImage(boolean scaleImage)
Determines whether to adapt the image according to the scale dimensions.

Parameters:
scaleImage - true if the image is to be matched to the size of the bounding box of the scale; otherwise, center the image based on its length and width

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.


pick

public abstract double pick(Point p)
Given a screen position in pixels, returns the closest scale value. This method is abstract and must be overridden.

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

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