JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.swing.gauge
Class JCAbstractNeedle

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--com.klg.jclass.swing.gauge.JCAbstractIndicator
                          |
                          +--com.klg.jclass.swing.gauge.JCAbstractNeedle
All Implemented Interfaces:
ImageObserver, JCIndicator, JCNeedle, MenuContainer, Serializable
Direct Known Subclasses:
JCCircularNeedle, JCLinearNeedle

public abstract class JCAbstractNeedle
extends JCAbstractIndicator
implements JCNeedle

A needle points to a current value on its associated scale. The end user may choose to interact with a needle. There may be multiple needles associated with a scale.

See Also:
JCAbstractNeedle, Serialized Form

Nested Class Summary
static class JCAbstractNeedle.InteractionType
          Needle interaction 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  ChangeEvent changeEvent
          Reuse the same event for notifications.
protected  com.klg.jclass.util.JCListenerList changeListeners
          List of listeners interested in knowing when a needle's value has changed.
protected  JCAbstractNeedle.InteractionType interactionType
          The type of interaction, one of InteractionType.NONE InteractionType.DRAG InteractionType.CLICK InteractionType CLICK_DRAG
protected  boolean sendEvents
          Controls whether to send change events or not.
 
Fields inherited from class com.klg.jclass.swing.gauge.JCAbstractIndicator
indicatorStyle, indicatorWidth, inner_extent, outer_extent, reversed, scale, value
 
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
JCAbstractNeedle(Color foreground, double needleWidth, com.klg.jclass.swing.gauge.JCScale scale, boolean visible, double inner_extent, double outer_extent, com.klg.jclass.swing.gauge.JCIndicatorStyle needleStyle, double value)
          Creates a needle.
JCAbstractNeedle(Color foreground, double needleWidth, com.klg.jclass.swing.gauge.JCScale scale, JCAbstractNeedle.InteractionType interactionType, boolean visible, double length, com.klg.jclass.swing.gauge.JCIndicatorStyle needleStyle, double value)
          Deprecated. Beginning with JClass 5, the length parameter has been replaced with inner_extent and outer_extent.
JCAbstractNeedle(com.klg.jclass.swing.gauge.JCScale scale)
          Creates a needle.
 
Method Summary
 void addChangeListener(ChangeListener l)
          Adds listener interested in needle movements.
 JCAbstractNeedle.InteractionType getInteractionType()
          Returns the interation type for this needle.
 double getLength()
          Returns the length of this needle as a ratio of the scale's radius, width, or height (depending on the scale's type and orientation).
 com.klg.jclass.swing.gauge.JCIndicatorStyle getNeedleStyle()
          Returns the JCIndicatorStyle for this needle.
 double getNeedleWidth()
          Returns the width for this needle (this is actually stored in the inherited indicatorWidth property).
 Dimension getPreferredSize()
          Returns the preferred size for this component.
 boolean getSendEvents()
          Returns a sendEvents flag; true means events will be sent when the needle's value changes, false means do not send the events.
abstract  void paint(Graphics g)
          This routine actually draws the needle object on the screen.
 void removeChangeListener(ChangeListener l)
          Removes listener interested in needle movements.
 void sendChangeEvent(ChangeEvent ev)
          Broadcasts the move event to interested listeners.
 void setInteractionType(JCAbstractNeedle.InteractionType interactionType)
          Sets the interation type for this needle.
 void setLength(double length)
          Sets the length of this needle as a ratio of the scale's radius, width, or height (depending on the scale's type and orientation).
 void setNeedleStyle(com.klg.jclass.swing.gauge.JCIndicatorStyle needleStyle)
          Sets the JCIndicatorStyle for this needle.
 void setNeedleWidth(double needleWidth)
          Sets the width of needle (this is actually stored in the inherited indicatorWidth property).
 void setSendEvents(boolean sendEvents)
          Sets the sendEvents flag; true means events will be sent when the needle's value changes, false means do not send the events.
 void setValue(double value)
          Sets the scale value to which this needle should point.
 
Methods inherited from class com.klg.jclass.swing.gauge.JCAbstractIndicator
getIndicatorStyle, getIndicatorWidth, getInnerExtent, getOuterExtent, getScale, getValue, isReversed, redraw, setIndicatorStyle, setIndicatorWidth, setInnerExtent, setOuterExtent, setReversed, setScale
 
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, 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.JCIndicator
getIndicatorStyle, getIndicatorWidth, getInnerExtent, getOuterExtent, getScale, getValue, isReversed, setIndicatorStyle, setIndicatorWidth, setInnerExtent, setOuterExtent, setReversed
 

Field Detail

changeListeners

protected com.klg.jclass.util.JCListenerList changeListeners
List of listeners interested in knowing when a needle's value has changed.


changeEvent

protected ChangeEvent changeEvent
Reuse the same event for notifications. The source will be this needle.


sendEvents

protected boolean sendEvents
Controls whether to send change events or not.


interactionType

protected JCAbstractNeedle.InteractionType interactionType
The type of interaction, one of

Constructor Detail

JCAbstractNeedle

public JCAbstractNeedle(com.klg.jclass.swing.gauge.JCScale scale)
Creates a needle.

Parameters:
scale - the associated circular or linear scale

JCAbstractNeedle

public JCAbstractNeedle(Color foreground,
                        double needleWidth,
                        com.klg.jclass.swing.gauge.JCScale scale,
                        boolean visible,
                        double inner_extent,
                        double outer_extent,
                        com.klg.jclass.swing.gauge.JCIndicatorStyle needleStyle,
                        double value)
Creates a needle.

Parameters:
foreground - the needle's color
needleWidth - the needle's width in pixels
scale - the associated JCScale
visible - a Boolean that controls the visibility of the needle
inner_extent - the needle's inner extent, expressed as a ratio of its length to the relevant dimension (radius, width/length) of the associated scale
outer_extent - the needle's outer extent, expressed as a ratio of its length to the relevant dimension of the associated scale
needleStyle - needle styles are kept in JCIndicatorStyle; user-defined needle styles may be passed to the JCIndicatorStyle's constructor
value - the needle's value; the needle points to this value on its associated scale

JCAbstractNeedle

public JCAbstractNeedle(Color foreground,
                        double needleWidth,
                        com.klg.jclass.swing.gauge.JCScale scale,
                        JCAbstractNeedle.InteractionType interactionType,
                        boolean visible,
                        double length,
                        com.klg.jclass.swing.gauge.JCIndicatorStyle needleStyle,
                        double value)
Deprecated. Beginning with JClass 5, the length parameter has been replaced with inner_extent and outer_extent.

Creates a needle.

Parameters:
foreground - the needle's color
needleWidth - the needle's width in pixels
scale - the associated JCScale
interactionType - the interaction type, CLICK, CLICK_DRAG, or NONE
visible - a Boolean that controls the visibility of the needle
length - the needle's length, expressed as a ratio of its length to the relevant dimension (radius, width/length) of the associated scale
needleStyle - needle styles are kept in JCIndicatorStyle; user-defined needle styles may be passed to the JCIndicatorStyle's constructor
value - the needle's value; the needle points to this value on its associated scale
Method Detail

getPreferredSize

public Dimension getPreferredSize()
Returns the preferred size for this component.

Overrides:
getPreferredSize in class JCAbstractIndicator
Returns:
the preferred size

paint

public abstract void paint(Graphics g)
This routine actually draws the needle object on the screen.

Specified by:
paint in class JCAbstractIndicator
Parameters:
g -

addChangeListener

public void addChangeListener(ChangeListener l)
Adds listener interested in needle movements.

Parameters:
l - the listener to be added

removeChangeListener

public void removeChangeListener(ChangeListener l)
Removes listener interested in needle movements.

Specified by:
removeChangeListener in interface JCNeedle
Parameters:
l - the listener to be removed

sendChangeEvent

public void sendChangeEvent(ChangeEvent ev)
Broadcasts the move event to interested listeners.

Specified by:
sendChangeEvent in interface JCNeedle
Parameters:
ev - the ChangeEvent of interest

setValue

public void setValue(double value)
Sets the scale value to which this needle should point. Also notifies listeners if sendEvents is true.

Specified by:
setValue in interface JCIndicator
Overrides:
setValue in class JCAbstractIndicator
Parameters:
value - the value at which to point

getLength

public double getLength()
Returns the length of this needle as a ratio of the scale's radius, width, or height (depending on the scale's type and orientation).
Note: The length is really the outer extent.

Specified by:
getLength in interface JCNeedle
Returns:
the length of this needle as a ratio of the scale's radius, width, or height (depending on the scale's type and orientation)

setLength

public void setLength(double length)
Sets the length of this needle as a ratio of the scale's radius, width, or height (depending on the scale's type and orientation). For example, for a circular scale, 0.75 means draw out to 75% of the scale's radius.

Specified by:
setLength in interface JCNeedle
Parameters:
length - the length of this needle as a ratio of the scale's radius, width, or height (depending on the scale's type and orientation)

getNeedleStyle

public com.klg.jclass.swing.gauge.JCIndicatorStyle getNeedleStyle()
Returns the JCIndicatorStyle for this needle.

Specified by:
getNeedleStyle in interface JCNeedle
Returns:
the JCIndicatorStyle of this needle

setNeedleStyle

public void setNeedleStyle(com.klg.jclass.swing.gauge.JCIndicatorStyle needleStyle)
Sets the JCIndicatorStyle for this needle.

Specified by:
setNeedleStyle in interface JCNeedle
Parameters:
needleStyle - the JCIndicatorStyle for this needle

getNeedleWidth

public double getNeedleWidth()
Returns the width for this needle (this is actually stored in the inherited indicatorWidth property).

Specified by:
getNeedleWidth in interface JCNeedle
Returns:
the width of this needle

setNeedleWidth

public void setNeedleWidth(double needleWidth)
Sets the width of needle (this is actually stored in the inherited indicatorWidth property).

Specified by:
setNeedleWidth in interface JCNeedle
Parameters:
needleWidth - the width of this needle

getInteractionType

public JCAbstractNeedle.InteractionType getInteractionType()
Returns the interation type for this needle.

Specified by:
getInteractionType in interface JCNeedle
Returns:
the JCAbstractNeedle.InteractionType for this needle

setInteractionType

public void setInteractionType(JCAbstractNeedle.InteractionType interactionType)
Sets the interation type for this needle.

Specified by:
setInteractionType in interface JCNeedle
Parameters:
interactionType - the JCNeedle.InteractionType for this needle, one of:
  • InteractionType.NONE
  • InteractionType.DRAG
  • InteractionType.CLICK
  • InteractionType.CLICK_DRAG

getSendEvents

public boolean getSendEvents()
Returns a sendEvents flag; true means events will be sent when the needle's value changes, false means do not send the events.

Specified by:
getSendEvents in interface JCNeedle
Returns:
the sendEvents boolean

setSendEvents

public void setSendEvents(boolean sendEvents)
Sets the sendEvents flag; true means events will be sent when the needle's value changes, false means do not send the events.

Specified by:
setSendEvents in interface JCNeedle
Parameters:
sendEvents - true means send needle's value change events to listeners, false means do not send the events

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