All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.eou.toolkit.gauge.BaseGauge

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----com.sun.java.swing.JComponent
                           |
                           +----com.sun.java.swing.JPanel
                                   |
                                   +----com.ibm.eou.toolkit.gauge.BaseGauge

public abstract class BaseGauge
extends JPanel
implements Gauge, GaugeSynchronization, Runnable, Adjustable, Serializable
This class provides a generic extensible implementation of the Gauge interface. This class is abstract, and can be extended to create widgets which act as single-value gauges. There is an abstract extended form of the paint method, which must be implemented in derived classes; these must not override the standard component paint method.


Variable Index

 o LOCK
This is the lock for the current gauge values.

Constructor Index

 o BaseGauge(GaugeModel, GaugeSynchronization)
Create a base gauge with the given model and the given gauge synchronization as the default gauge synchronization.
 o BaseGauge(int, int, int, GaugeSynchronization)
Create a base gauge with an initial value and range, and the given gauge synchronization as the default gauge synchronization.

Method Index

 o accumulate()
Increment the accumulator total by one.
 o accumulate(int)
Increment the accumulator total by the specified increment.
 o addAdjustmentListener(AdjustmentListener)
Add a listener to the list of listeners to be notified whenever the gauge value changes.
 o addImage(Image)
Register an image to be monitored during loading
 o addImages(Image[])
Register images to be monitored during loading
 o adjustValue(int)
Increment the current gauge value by the specified amount.
 o areImagesReady()
Return true if all images registered to be monitored during loading are now ready.
 o copyright()
 o createDefaultChangeListener()
Subclasses that want to handle model ChangeEvents differently can override this method to return their own ChangeListener implementation.
 o createDefaultGaugeModelListener()
 o createMissingImage(Color, Color, Dimension, Component)
Return a small rectangular image showing a question mark.
 o dispose()
Release all resources used by the gauge, including stopping all threads.
 o fireStateChanged(ChangeEvent)
Send a ChangeEvent to each listener.
 o gaugeModelChanged(GaugeModelChangeEvent)
This method can be overriden by extending classes which need to react to a change to one or more of the models settings.
 o getAccumulatorInterval()
Return the accumulator interval.
 o getAccumulatorMeasurementInterval()
Return the accumulator measurement interval.
 o getAccumulatorMeasurementMethod()
Return the current accumulator measurement method.
 o getBackgroundStyle()
Return the background to be drawn by this gauge prior to each paint, or null if no background is set. Deprecated.
 o getBlockIncrement()
Return the multi-unit incremental change to be applied to the gauge value.
 o getDefaultGaugeSynchronization()
Return the default gauge synchronization, which is set when the gauge is created.
 o getExtent()
Return the value range represented by the gauge adjustment artefact.
 o getGaugeSynchronization()
Return the current gauge synchronization.
 o getMaximum()
Return the maximum of the current gauge range.
 o getMinimum()
Return the minimum of the current gauge range.
 o getModel()
Return the gauge's data model.
 o getNextValue(int, int, int, int, int, int)
Return the next value which the gauge display will show.
 o getNextValueDelay(boolean)
Return the time interval in milliseconds after which the next value is to be displayed by the gauge.
 o getOrientation()
Return the Orientation
 o getPreferredSize()
Return the preferred size for the gauge, as set by setPreferredSize().
 o getRangeAdjustmentMethod()
Return the current range adjustment method.
 o getUnitIncrement()
Return the unit incremental change to be applied to the gauge value.
 o getUpdateBounds(Dimension, int, int, int, int, int, int)
Return an array of rectangles defining the regions within the gauge display area that will need to be repainted as a result of the supplied next and current display values.
 o getValue()
Return the current value of the gauge.
 o getVisibleAmount()
Deprecated.
 o imagesReady()
This method is called automatically whenever the final image currently registered to be monitored during loading becomes ready.
 o imageUpdate(Image, int, int, int, int, int)
The standard component imageUpdate method.
 o isAccumulatorEnabled()
Return whether or not accumulation is enabled.
 o isEditable()
Return whether this gauge's value may be altered via user interaction.
 o isImageReady(Image)
Return true if the image registered to be monitored during loading is now ready.
 o isSynchronized(int, int, int, int, int, int)
Return true if the gauge considers the current display to be fully synchronized.
 o notifyAdjustmentValueChanged(AdjustmentEvent)
Issue an event to all listeners.
 o notifyGauge()
Inform the gauge that updates should recommence.
 o paint(Graphics, Dimension, int, int, int, boolean, int, int, int)
Paint the gauge. Deprecated.
 o paintComponent(Graphics)
The standard paintComponent method.
 o paintComponent(Graphics, Dimension, int, int, int)
Paint the gauge on to the given graphics, sized to the given dimension.
 o processComponentEvent(ComponentEvent)
 o removeAdjustmentListener(AdjustmentListener)
Remove a listener from the list of listeneres to be notified whenever the gauge value changes.
 o resetAccumulator()
Resets all data members used by the accumulator and starts the timer.
 o resetSynchronization()
 o run()
The standard Runnable run method.
 o setAccumulatorEnabled(boolean)
Specify whether accumulation is enabled.
 o setAccumulatorInterval(long)
Specify the accumulator interval in milliseconds.
 o setAccumulatorMeasurementInterval(long)
Specify the accumulator measurement interval in milliseconds.
 o setAccumulatorMeasurementMethod(int)
Specify the accumulator measurement method.
 o setBackgroundStyle(Background)
Set the background to be drawn by this gauge prior to each paint. Deprecated.
 o setBlockIncrement(int)
Specify the multi-unit incremental change to be applied to the gauge value.
 o setDefaultGaugeSynchronization(GaugeSynchronization)
Set the default gauge synchronization to be used by this gauge.
 o setEditable(boolean)
Specify whether this gauge's value may be altered via user interaction.
 o setExtent(int)
Specify the value range represented by the gauge adjustment artefact.
 o setGaugeSynchronization(GaugeSynchronization)
Set the gauge synchronization to be used by this gauge.
 o setMaximum(int)
Set the maximum of the gauge range.
 o setMinimum(int)
Set the minimum of the gauge range.
 o setModel(GaugeModel)
Set the gauge's data model.
 o setOpaque(boolean)
 o setOrientation(int)
Set the orientation for the gauge.
 o setPreferredSize(int, int)
Set the preferred size for the gauge.
 o setRangeAdjustmentMethod(int)
Specify the required automatic gauge range adjustment method
 o setUnitIncrement(int)
Specify the unit incremental change to be applied to the gauge value.
 o setValue(int)
Set the current gauge value.
 o setVisibleAmount(int)
Deprecated.
 o synchronize()
Wait until the gauge is synchronized.
 o waitForImage(Image)
This method waits until the specified registered image is loaded, and returns immediately if the image is already loaded (or not registered).
 o waitForImages()
This method waits until all currently registered images are loaded.

Variables

 o LOCK
 protected transient Object LOCK
This is the lock for the current gauge values. Synchronizing on this object while making a series of updates to the gauge will ensure atomicity of update. However, the lock should be held as little as possible, and it is always preferable to use one of the multiple update methods.

Constructors

 o BaseGauge
 public BaseGauge(int initialValue,
                  int minimum,
                  int maximum,
                  GaugeSynchronization defaultGaugeSynchronization)
Create a base gauge with an initial value and range, and the given gauge synchronization as the default gauge synchronization. The BackgroundStyle is set to null.

See Also:
setDefaultGaugeSynchronization, setBackgroundStyle
 o BaseGauge
 public BaseGauge(GaugeModel gaugeModel,
                  GaugeSynchronization defaultGaugeSynchronization)
Create a base gauge with the given model and the given gauge synchronization as the default gauge synchronization. The BackgroundStyle is set to null.

See Also:
setDefaultGaugeSynchronization, setBackgroundStyle

Methods

 o copyright
 public static String copyright()
 o setAccumulatorEnabled
 public void setAccumulatorEnabled(boolean accumulatorEnabled)
Specify whether accumulation is enabled.

See Also:
setAccumulatorEnabled
 o isAccumulatorEnabled
 public boolean isAccumulatorEnabled()
Return whether or not accumulation is enabled.

See Also:
isAccumulatorEnabled
 o setAccumulatorInterval
 public void setAccumulatorInterval(long accumulatorInterval)
Specify the accumulator interval in milliseconds.

See Also:
setAccumulatorMeasurementInterval
 o getAccumulatorInterval
 public long getAccumulatorInterval()
Return the accumulator interval.

See Also:
setAccumulatorInterval
 o setAccumulatorMeasurementMethod
 public void setAccumulatorMeasurementMethod(int accumulatorMeasurementMethod)
Specify the accumulator measurement method.

See Also:
setAccumulatorMeasurementInterval
 o getRangeAdjustmentMethod
 public int getRangeAdjustmentMethod()
Return the current range adjustment method.

See Also:
getRangeAdjustmentMethod
 o setRangeAdjustmentMethod
 public void setRangeAdjustmentMethod(int rangeAdjustmentMethod)
Specify the required automatic gauge range adjustment method

See Also:
setRangeAdjustmentMethod
 o getAccumulatorMeasurementMethod
 public int getAccumulatorMeasurementMethod()
Return the current accumulator measurement method.

See Also:
getAccumulatorMeasurementMethod
 o setAccumulatorMeasurementInterval
 public void setAccumulatorMeasurementInterval(long accumulatorMeasurementInterval)
Specify the accumulator measurement interval in milliseconds.

See Also:
setAccumulatorMeasurementInterval
 o getAccumulatorMeasurementInterval
 public long getAccumulatorMeasurementInterval()
Return the accumulator measurement interval.

See Also:
getAccumulatorMeasurementInterval
 o resetAccumulator
 public void resetAccumulator()
Resets all data members used by the accumulator and starts the timer.

 o accumulate
 public void accumulate()
Increment the accumulator total by one.

See Also:
accumulate
 o accumulate
 public void accumulate(int increment)
Increment the accumulator total by the specified increment.

See Also:
accumulate
 o addAdjustmentListener
 public void addAdjustmentListener(AdjustmentListener listener)
Add a listener to the list of listeners to be notified whenever the gauge value changes.

 o removeAdjustmentListener
 public void removeAdjustmentListener(AdjustmentListener listener)
Remove a listener from the list of listeneres to be notified whenever the gauge value changes.

 o notifyAdjustmentValueChanged
 protected void notifyAdjustmentValueChanged(AdjustmentEvent event)
Issue an event to all listeners.

 o getOrientation
 public int getOrientation()
Return the Orientation

 o setOrientation
 public void setOrientation(int orientation)
Set the orientation for the gauge.

See Also:
getOrientation
 o getUnitIncrement
 public int getUnitIncrement()
Return the unit incremental change to be applied to the gauge value.

See Also:
setUnitIncrement
 o setUnitIncrement
 public void setUnitIncrement(int unitIncrement)
Specify the unit incremental change to be applied to the gauge value. This value might be used by an extending gauge that allows scroll bar like interaction to alter its value, and would be used in response to the equivalent of an end button on a scroll bar being selected.

 o getBlockIncrement
 public int getBlockIncrement()
Return the multi-unit incremental change to be applied to the gauge value.

See Also:
setBlockIncrement
 o setBlockIncrement
 public void setBlockIncrement(int blockIncrement)
Specify the multi-unit incremental change to be applied to the gauge value. This value might be used by an extending gauge that allows scroll bar like interaction to alter its value, and would be used in response to the equivalent of selection in the scroll bar shaft.

 o getVisibleAmount
 public int getVisibleAmount()
Note: getVisibleAmount() is deprecated. use getExtent() instead.

See Also:
getExtent
 o setVisibleAmount
 public void setVisibleAmount(int visibleAmount)
Note: setVisibleAmount() is deprecated. use setExtent(int) instead.

See Also:
setExtent
 o getExtent
 public int getExtent()
Return the value range represented by the gauge adjustment artefact.

See Also:
setExtent
 o setExtent
 public void setExtent(int extent)
Specify the value range represented by the gauge adjustment artefact. This value might be used by an extending gauge that allows scroll bar like interaction to alter its value, and would be used to set the dimension if the equivalent of a scroll bar thumb.

 o getMinimum
 public int getMinimum()
Return the minimum of the current gauge range.

 o setMinimum
 public void setMinimum(int minimum)
Set the minimum of the gauge range.

 o getMaximum
 public int getMaximum()
Return the maximum of the current gauge range.

 o setMaximum
 public void setMaximum(int maximum)
Set the maximum of the gauge range.

 o setValue
 public void setValue(int value)
Set the current gauge value. If the value is outside of the current gauge range, the gauge minimum or maximum may be adjusted, according to the current range adjustment method.

See Also:
setRangeAdjustmentMethod
 o getValue
 public int getValue()
Return the current value of the gauge. Note that this may not be the value currently displayed to the user, if the gauge display is not yet synchronized.

 o adjustValue
 public void adjustValue(int valueChange)
Increment the current gauge value by the specified amount. If the resulting value is outside of the current gauge range, the gauge minimum or maximum may be adjusted, according to the current range adjustment method.

See Also:
setRangeAdjustmentMethod
 o isEditable
 public boolean isEditable()
Return whether this gauge's value may be altered via user interaction.

 o setEditable
 public void setEditable(boolean editable)
Specify whether this gauge's value may be altered via user interaction.

 o setOpaque
 public void setOpaque(boolean isOpaque)
Overrides:
setOpaque in class JComponent
 o dispose
 public void dispose()
Release all resources used by the gauge, including stopping all threads. This method should be called when the gauge is no longer required.

 o resetSynchronization
 public void resetSynchronization()
 o getDefaultGaugeSynchronization
 public GaugeSynchronization getDefaultGaugeSynchronization()
Return the default gauge synchronization, which is set when the gauge is created.

See Also:
setDefaultGaugeSynchronization
 o setDefaultGaugeSynchronization
 protected final void setDefaultGaugeSynchronization(GaugeSynchronization defaultGaugeSynchronization)
Set the default gauge synchronization to be used by this gauge. If null is passed, the default gauge synchronization is reset to an immediate update synchronization.

See Also:
setGaugeSynchronization
 o getGaugeSynchronization
 public GaugeSynchronization getGaugeSynchronization()
Return the current gauge synchronization. If a gauge synchronization has been set, that will be returned, otherwise this gauge's default gauge synchronization will be returned.

See Also:
setGaugeSynchronization
 o setGaugeSynchronization
 public void setGaugeSynchronization(GaugeSynchronization gaugeSynchronization)
Set the gauge synchronization to be used by this gauge. If null is passed, the gauge synchronization is reset to this gauge's default synchronization.

See Also:
setDefaultGaugeSynchronization
 o setPreferredSize
 public void setPreferredSize(int x,
                              int y)
Set the preferred size for the gauge.

See Also:
getPreferredSize
 o getPreferredSize
 public final Dimension getPreferredSize()
Return the preferred size for the gauge, as set by setPreferredSize(). The preferred size returned is constrained below by the size returned by minimumSize().

Overrides:
getPreferredSize in class JComponent
See Also:
setPreferredSize
 o getBackgroundStyle
 public Background getBackgroundStyle()
Note: getBackgroundStyle() is deprecated.

Return the background to be drawn by this gauge prior to each paint, or null if no background is set.

See Also:
setBackgroundStyle
 o setBackgroundStyle
 public void setBackgroundStyle(Background background)
Note: setBackgroundStyle() is deprecated. Now that gauges may be drawn with a transparent background, the ability to supply a background is no longer needed.

Set the background to be drawn by this gauge prior to each paint. Setting null as the background causes no background to be drawn prior to each paint.

See Also:
setOpaque
 o notifyGauge
 protected void notifyGauge()
Inform the gauge that updates should recommence. This is done automatically whenever the value changes, but can also be done explicitly by classes extending BaseGauge, in order to resume update behaviour after a halt.

 o isSynchronized
 public boolean isSynchronized(int gaugeValue,
                               int gaugeMin,
                               int gaugeMax,
                               int displayValue,
                               int displayMin,
                               int displayMax)
Return true if the gauge considers the current display to be fully synchronized. This class delegates this method to the current gauge synchronization.

See Also:
setGaugeSynchronization, getGaugeSynchronization, isSynchronized
 o getNextValueDelay
 public long getNextValueDelay(boolean isSynchronized)
Return the time interval in milliseconds after which the next value is to be displayed by the gauge. This class delegates this method to the current gauge synchronization.

See Also:
setGaugeSynchronization, getGaugeSynchronization, getNextValueDelay
 o getNextValue
 public int getNextValue(int gaugeValue,
                         int gaugeMinimum,
                         int gaugeMaximum,
                         int displayValue,
                         int displayMinimum,
                         int displayMaximum)
Return the next value which the gauge display will show. This class delegates this method to the current gauge synchronization.

See Also:
setGaugeSynchronization, getGaugeSynchronization, getNextValue
 o waitForImage
 protected void waitForImage(Image image)
This method waits until the specified registered image is loaded, and returns immediately if the image is already loaded (or not registered).

See Also:
addImage, addImages, imagesReady, isImageReady, areImagesReady, waitForImages
 o waitForImages
 protected void waitForImages()
This method waits until all currently registered images are loaded.

See Also:
addImage, addImages, imagesReady, isImageReady, areImagesReady, waitForImage
 o imagesReady
 protected void imagesReady()
This method is called automatically whenever the final image currently registered to be monitored during loading becomes ready. The default implementation re-lays out the parent and repaints this component.

See Also:
addImage, addImages, imagesReady, areImagesReady, isImageReady, waitForImage, waitForImages
 o imageUpdate
 public boolean imageUpdate(Image image,
                            int flags,
                            int x,
                            int y,
                            int w,
                            int h)
The standard component imageUpdate method. This method is essential for correct functioning of this class. If overridden, super.imageUpdate should still be called.

Overrides:
imageUpdate in class Component
 o addImages
 protected void addImages(Image images[])
Register images to be monitored during loading

See Also:
addImage, areImagesReady, imagesReady, isImageReady, waitForImage, waitForImages
 o addImage
 protected void addImage(Image image)
Register an image to be monitored during loading

See Also:
addImages, areImagesReady, imagesReady, isImageReady, waitForImage, waitForImages
 o isImageReady
 public boolean isImageReady(Image image)
Return true if the image registered to be monitored during loading is now ready. An image is considered ready when it has completed loading, been aborted, or has an error.

See Also:
addImage, addImages, areImagesReady, waitForImage, waitForImages
 o areImagesReady
 public boolean areImagesReady()
Return true if all images registered to be monitored during loading are now ready. An image is considered ready when it has completed loading, been aborted, or has an error.

See Also:
addImage, addImages, isImageReady, waitForImage, waitForImages
 o createMissingImage
 protected static Image createMissingImage(Color backgroundColor,
                                           Color foregroundColor,
                                           Dimension dimension,
                                           Component component)
Return a small rectangular image showing a question mark.

 o paintComponent
 public final void paintComponent(Graphics graphics)
The standard paintComponent method. This method is declared final to prevent overriding by extending classes. An extended signature paintComponent method should be overridden instead

Overrides:
paintComponent in class JPanel
See Also:
paintComponent
 o paint
 public void paint(Graphics g,
                   Dimension d,
                   int nextDisplayValue,
                   int nextDisplayMinimum,
                   int nextDisplayMaximum,
                   boolean incremental,
                   int currentDisplayValue,
                   int currentDisplayMinimum,
                   int currentDisplayMaximum)
Note: paint() is deprecated. All gauges should now implement the paintComponent method.

Paint the gauge. This deprecated method relies on the provision of next and current display values and ranges, plus a flag to indicate an incremental update. To conform with the Swing painting model a new paint method has been introduced that relies on paint optimization based on clipping regions. This method is temporarily retained for compatibility, although the last four parameter values will always be code>false, 0, 0, 0.

Parameters:
g - a graphics to draw on.
d - the dimension of the area to draw into.
nextDisplayValue - the value to show.
nextDisplayMinimum - the minimum of the range to show.
nextDisplayMaximum - the maximum of the range to show.
incremental - whether this is an incremental paint request.
currentDisplayValue - the value currently displaying.
currentDisplayMinimum - the minimum of the range the current display value is in.
currentDisplayMaximum - the maximum of the range the current display value is in.
See Also:
paintComponent
 o paintComponent
 public void paintComponent(Graphics graphics,
                            Dimension size,
                            int displayValue,
                            int displayMinimum,
                            int displayMaximum)
Paint the gauge on to the given graphics, sized to the given dimension. This dimansion may differ from the gauge component size to accommodate any border that may be drawn.

Extending classes should override this method to provide their unique gauge rendering. Paint optimization should be performed by only rendering elements of the gauge that intersect any active clipping rectangle for the supplied graphics. Extending classes will not normally need to implement their own double buffering since Swing components provide this behaviour by default.

To provide smooth animations, this method will be called many times as the display value is synchronized with the gauge value. To allow this process to set appropriate clipping regions for each synchronizing paint, the getUpdateBounds method may be overriden.

Parameters:
graphics - the Graphics to be drawn on.
size - the size of the area that requires painting.
displayValue - the value to be represented by the gauge.
displayMinimum - the minimum gauge value for this representation.
displayMaximum - the maximum gauge value for this representation.
See Also:
getUpdateBounds
 o run
 public void run()
The standard Runnable run method.

 o getUpdateBounds
 protected Rectangle[] getUpdateBounds(Dimension size,
                                       int nextDisplayValue,
                                       int nextDisplayMinimum,
                                       int nextDisplayMaximum,
                                       int currentDisplayValue,
                                       int currentDisplayMinimum,
                                       int currentDisplayMaximum)
Return an array of rectangles defining the regions within the gauge display area that will need to be repainted as a result of the supplied next and current display values. These rectangles are used to trigger gauge painting with the correct clipping region set, allowing gauge painting to be optimized.

By default this method returns an array of one rectangle covering the whole gauge. Extending classes should override this method to restrict the region(s) that need to be repainted on incremental paints.

Parameters:
size - the size of the area available for the gauge to paint into.
nextDisplayValue - the value to be represented by the gauge when next painted.
nextDisplayMin - the minimum of the gauge range matching the nextDisplayValue.
nextDisplayMax - the maximum of the gauge range matching the nextDisplayValue.
currentDisplayValue - the value currently represented by the gauge.
currentDisplayMin - the minimum of the gauge range matching the currentDisplayValue.
currentDisplayMax - the maximum of the gauge range matching the currentDisplayValue.
Returns:
Rectangle[] - An array of rectangles representing the regions that require painting, or null if the gauge display will not alter based on the supplied next and current values.
 o synchronize
 public void synchronize()
Wait until the gauge is synchronized. The gauge is synchronized when the current gauge synchronization confirms that it is synchronized.

See Also:
setGaugeSynchronization
 o getModel
 public GaugeModel getModel()
Return the gauge's data model.

 o setModel
 public void setModel(GaugeModel gaugeModel)
Set the gauge's data model.

 o processComponentEvent
 protected void processComponentEvent(ComponentEvent componentEvent)
Overrides:
processComponentEvent in class Component
 o fireStateChanged
 protected void fireStateChanged(ChangeEvent changeEvent)
Send a ChangeEvent to each listener. This method method is called each time a ChangeEvent is received from the model.

 o gaugeModelChanged
 protected void gaugeModelChanged(GaugeModelChangeEvent e)
This method can be overriden by extending classes which need to react to a change to one or more of the models settings.

 o createDefaultChangeListener
 protected ChangeListener createDefaultChangeListener()
Subclasses that want to handle model ChangeEvents differently can override this method to return their own ChangeListener implementation. The default ChangeListener just forwards ChangeEvents to the ChangeListeners added directly to the gauge.

See Also:
fireStateChanged
 o createDefaultGaugeModelListener
 protected GaugeModelListener createDefaultGaugeModelListener()

All Packages  Class Hierarchy  This Package  Previous  Next  Index