JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.swing.gauge
Class JCCenter

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

public class JCCenter
extends JComponent
implements Serializable

A center object is used to mark the position of the center of a circular scale in a JCCircularScale widget. It can be a disk or an image.

See Also:
Serialized Form

Nested Class Summary
 
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  Color foreground
          The scale's foreground color.
protected  Image image
          An Image may be used to mark the center of the gauge.
protected  double radius
          The size of the disk, expressed as a ratio based on the radius of the associated scale.
protected  com.klg.jclass.swing.gauge.JCCircularScale scale
          The associated circular scale.
protected  boolean scaleImage
          Boolean that determines whether the image should be scaled when the gauge is resized.
 
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
JCCenter(com.klg.jclass.swing.gauge.JCCircularScale scale)
          Creates a black disk at the center of the scale whose default radius is 10% of the scale's radius.
JCCenter(com.klg.jclass.swing.gauge.JCCircularScale scale, Color foreground, double radius)
          Creates a black disk at the center of the scale whose radius and foreground color are parameters.
JCCenter(com.klg.jclass.swing.gauge.JCCircularScale scale, Color foreground, Image image)
          Creates a center using the provided image with no scaling.
 
Method Summary
protected  void drawDisc(Graphics g)
          Draws a disk at the center of the scale.
protected  void drawImage(Graphics g, Image image, Rectangle bounds)
           
protected  Shape getCenterShape()
           
 Image getImage()
          Gets the Image to be used to mark the center of the circular scale.
 Dimension getPreferredSize()
          Overridden so that the center can scale itself proportionately with the scale.
 double getRadius()
          Gets the radius of the center.
 com.klg.jclass.swing.gauge.JCCircularScale getScale()
          Returns the scale associated with this center.
 boolean getScaleImage()
          Scales the image in relation to the radius.
 void paintComponent(Graphics g)
          This routine actually draws the center object on the screen.
 void redraw()
          Call this instead of paint so that the repaintEnabled flag can be checked.
 void setImage(Image image)
          Sets the Image to be used to mark the center of the circular scale.
 void setRadius(double radius)
          Sets the radius of the disk.
 void setScaleImage(boolean scaleImage)
          Determines whether to scale the image according to the radius.
 
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, 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
 

Field Detail

scale

protected com.klg.jclass.swing.gauge.JCCircularScale scale
The associated circular scale.


image

protected Image image
An Image may be used to mark the center of the gauge.


foreground

protected Color foreground
The scale's foreground color. The default is black.


scaleImage

protected boolean scaleImage
Boolean that determines whether the image should be scaled when the gauge is resized. The default is true.


radius

protected double radius
The size of the disk, expressed as a ratio based on the radius of the associated scale.

Constructor Detail

JCCenter

public JCCenter(com.klg.jclass.swing.gauge.JCCircularScale scale)
Creates a black disk at the center of the scale whose default radius is 10% of the scale's radius.

Parameters:
scale - the associated circular scale

JCCenter

public JCCenter(com.klg.jclass.swing.gauge.JCCircularScale scale,
                Color foreground,
                double radius)
Creates a black disk at the center of the scale whose radius and foreground color are parameters.

Parameters:
scale - the associated circular scale
foreground - the Color of the foreground
radius - The radius of the center disc as a fractional proportion of the associated scale's radius, from 0.0-1.0. For example, 0.5 means the center will have a radius half the size of the scale's radius.

JCCenter

public JCCenter(com.klg.jclass.swing.gauge.JCCircularScale scale,
                Color foreground,
                Image image)
Creates a center using the provided image with no scaling. The size of the center will be based on the size of the image.

Parameters:
scale - the associated circular scale
foreground - the Color of the foreground
image - the image used as the center
Method Detail

paintComponent

public void paintComponent(Graphics g)
This routine actually draws the center object on the screen. If there is no associated circular scale, or if the radius is 0.0, nothing is drawn. Also note that the background is not drawn if an image is used.

Overrides:
paintComponent in class JComponent
Parameters:
g -

getPreferredSize

public Dimension getPreferredSize()
Overridden so that the center can scale itself proportionately with the scale.

Overrides:
getPreferredSize in class JComponent
Returns:
a Dimension object indicating the preferred size of the component

drawImage

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

drawDisc

protected void drawDisc(Graphics g)
Draws a disk at the center of the scale.

Parameters:
g - the graphics on which to draw

getScale

public com.klg.jclass.swing.gauge.JCCircularScale getScale()
Returns the scale associated with this center.

Returns:
the circular scale for the JCCenter component

setRadius

public void setRadius(double radius)
Sets the radius of the disk. The radius parameter is a decimal fraction of the scale's radius.

Parameters:
radius - the radius of the center as a proportion of the circular scale's radius

getRadius

public double getRadius()
Gets the radius of the center. The value is a decimal fraction of the scale's radius.

Returns:

getImage

public Image getImage()
Gets the Image to be used to mark the center of the circular scale.

Returns:
the image that is used to mark the center of the circular scale

setImage

public void setImage(Image image)
Sets the Image to be used to mark the center of the circular scale.

Parameters:
image - the Image to be used to mark the center of the circular scale

getScaleImage

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

Returns:
true if the image is to be scaled to the size of the bounding box with length and width equal to "radius"; otherwise, center the image based on its length and width

setScaleImage

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

Parameters:
scaleImage - true if the image is to be scaled to the size of the bounding box with length and width equal to "radius"; 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.


getCenterShape

protected Shape getCenterShape()

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