JClass 4.5.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

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

Inner classes inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Field Summary
protected  Color foreground
          The scale's foreground color.
protected  JCCircularGauge gauge
          The associated circlar gauge.
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  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
 
Constructor Summary
JCCenter(JCCircularGauge gauge)
          Creates a black disk at the center of the scale whose default radius is 10% of the scale's radius.
JCCenter(JCCircularGauge gauge, Color foreground, double radius)
          Creates a black disk at the center of the scale whose radius and foreground color are parameters.
JCCenter(JCCircularGauge gauge, 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)
          Draws an image as the center.
 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.
 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, 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, 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

gauge

protected JCCircularGauge gauge
The associated circlar gauge.

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. Default: black

scaleImage

protected boolean scaleImage
Boolean that determines whether the image should be scaled when the gauge is resized. Default: 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(JCCircularGauge gauge)
Creates a black disk at the center of the scale whose default radius is 10% of the scale's radius.
Parameters:
gauge - The parent circular gauge.

JCCenter

public JCCenter(JCCircularGauge gauge,
                Color foreground,
                double radius)
Creates a black disk at the center of the scale whose radius and foreground color are parameters.
Parameters:
gauge - The parent circular gauge.
foreground - The Color of the foreground
radius - The radius of the center disc as a fractional proportion of the 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(JCCircularGauge gauge,
                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:
gauge - The parent circular gauge.
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)
Draws an image as the center.
Parameters:
g - The Graphics on which to draw

drawDisc

protected void drawDisc(Graphics g)
Draws a disk at the center of the scale.
Parameters:
g - The graphics on which to draw

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.

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.

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