JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.swing.gauge
Class JCLinearScale

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

public class JCLinearScale
extends JCAbstractScale

JCLinearScale provides a graduated scale drawn in a linear fashion. It is oriented either horizontally or vertically.

See Also:
Serialized Form

Nested Class Summary
static class JCLinearScale.Orientation
          Orientation enumeration.
 
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  JCLinearScale.Orientation orientation
          The orientation of this scale.
protected  boolean useZoomFactorForMax
          Asks: "Does zoomFactor have effect in the maximum extent direction?".
protected  boolean useZoomFactorForMin
          Asks: "Does zoomFactor have effect in the minimum extent direction?".
 
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
JCLinearScale(com.klg.jclass.swing.gauge.JCLinearGauge gauge)
          Creates a scale given its parent gauge.
JCLinearScale(com.klg.jclass.swing.gauge.JCLinearGauge gauge, JCAbstractScale.Direction direction, double min, double max, JCLinearScale.Orientation orientation, Color foreground)
          Creates a graduated linear scale.
 
Method Summary
 Component add(Component c)
          Overrides add to pass in a linear constraint.
 Component add(Component c, int index)
          Overrides add to pass in a linear constraint.
protected  void drawImage(Graphics g, Image image, Rectangle bounds)
          Draws an image as the scale.
 com.klg.jclass.swing.gauge.JCLinearGauge getLinearGauge()
          Returns the gauge associated with this scale.
 JCLinearScale.Orientation getOrientation()
          Returns the JCLinearScale.Orientation for this linear scale, HORIZONTAL or VERTICAL, giving the orientation in which scale values are rendered.
 Dimension getPreferredSize()
          This is called by our widget parent when it wants to know our preferred size.
 Rectangle getScaleSize()
          Calculates the rectangle that defines the position and dimensions of the linear scale.
 boolean getUseZoomFactorForMax()
          Gets the value of useZoomFactorForMax, which tells whether the ZoomFactor is in effect in the maximum extent direction or not.
 boolean getUseZoomFactorForMin()
          Gets the value of useZoomFactorForMin, which tells whether the ZoomFactor is in effect in the minimum extent direction or not.
 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 setOrientation(JCLinearScale.Orientation orientation)
          Sets the JCLinearScale.Orientation for this linear scale, HORIZONTAL or VERTICAL, giving the orientation in which scale values are rendered.
 void setUseZoomFactorForMax(boolean useZoomFactorForMax)
          Sets the useZoomFactorForMax value, which tells whether the ZoomFactor is in effect in the maximum extent direction or not.
 void setUseZoomFactorForMin(boolean useZoomFactorForMin)
          Sets the useZoomFactorForMin value, which tells whether the ZoomFactor is in effect in the minimum extent direction or not.
 
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

orientation

protected JCLinearScale.Orientation orientation
The orientation of this scale.


useZoomFactorForMin

protected boolean useZoomFactorForMin
Asks: "Does zoomFactor have effect in the minimum extent direction?".


useZoomFactorForMax

protected boolean useZoomFactorForMax
Asks: "Does zoomFactor have effect in the maximum extent direction?".

Constructor Detail

JCLinearScale

public JCLinearScale(com.klg.jclass.swing.gauge.JCLinearGauge gauge)
Creates a scale given its parent gauge.

Parameters:
gauge - the JCLinearGauge associated with this scale

JCLinearScale

public JCLinearScale(com.klg.jclass.swing.gauge.JCLinearGauge gauge,
                     JCAbstractScale.Direction direction,
                     double min,
                     double max,
                     JCLinearScale.Orientation orientation,
                     Color foreground)
Creates a graduated linear scale.

Parameters:
orientation -
gauge - the JCLinearGauge associated with this scale
direction - a JCAbstractScale.Direction enum indicating FORWARD or BACKWARD
min - the minumum value a scale can have
max - the maximum value a scale can have
foreground - the color of this scale's foreground
Method Detail

getLinearGauge

public com.klg.jclass.swing.gauge.JCLinearGauge getLinearGauge()
Returns the gauge associated with this scale.

Returns:
the gauge associated with this scale

getPreferredSize

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

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

add

public Component add(Component c)
Overrides add to pass in a linear 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 linear 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:

getScaleSize

public Rectangle getScaleSize()
Calculates the rectangle that defines the position and dimensions of the linear scale.

Returns:
a rectangle that contains the position and dimensions of the linear scale

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

getOrientation

public JCLinearScale.Orientation getOrientation()
Returns the JCLinearScale.Orientation for this linear scale, HORIZONTAL or VERTICAL, giving the orientation in which scale values are rendered.

Returns:
the JCLinearScale.Orientation for this scale

setOrientation

public void setOrientation(JCLinearScale.Orientation orientation)
Sets the JCLinearScale.Orientation for this linear scale, HORIZONTAL or VERTICAL, giving the orientation in which scale values are rendered.

Parameters:
orientation - the JCLinearScale.Orientation

getUseZoomFactorForMin

public boolean getUseZoomFactorForMin()
Gets the value of useZoomFactorForMin, which tells whether the ZoomFactor is in effect in the minimum extent direction or not.

Returns:
the current useZoomFactorForMin value

setUseZoomFactorForMin

public void setUseZoomFactorForMin(boolean useZoomFactorForMin)
Sets the useZoomFactorForMin value, which tells whether the ZoomFactor is in effect in the minimum extent direction or not.

Parameters:
useZoomFactorForMin - the new useZoomFactorForMin value

getUseZoomFactorForMax

public boolean getUseZoomFactorForMax()
Gets the value of useZoomFactorForMax, which tells whether the ZoomFactor is in effect in the maximum extent direction or not.

Returns:
the current useZoomFactorForMax value

setUseZoomFactorForMax

public void setUseZoomFactorForMax(boolean useZoomFactorForMax)
Sets the useZoomFactorForMax value, which tells whether the ZoomFactor is in effect in the maximum extent direction or not.

Parameters:
useZoomFactorForMax - the new useZoomFactorForMax value

drawImage

protected void drawImage(Graphics g,
                         Image image,
                         Rectangle bounds)
Draws an image as the scale.

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

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

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