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.
-
LOCK
- This is the lock for the current gauge values.
-
BaseGauge(GaugeModel, GaugeSynchronization)
- Create a base gauge with the given model and the given gauge
synchronization as the default gauge synchronization.
-
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.
-
accumulate()
- Increment the accumulator total by one.
-
accumulate(int)
- Increment the accumulator total by the specified increment.
-
addAdjustmentListener(AdjustmentListener)
- Add a listener to the list of listeners
to be notified whenever the gauge value changes.
-
addImage(Image)
- Register an image to be monitored during
loading
-
addImages(Image[])
- Register images to be monitored during
loading
-
adjustValue(int)
- Increment the current gauge value by the specified amount.
-
areImagesReady()
- Return true if all images registered to be
monitored during loading are now ready.
-
copyright()
-
-
createDefaultChangeListener()
- Subclasses that want to handle model ChangeEvents differently
can override this method to return their own ChangeListener
implementation.
-
createDefaultGaugeModelListener()
-
-
createMissingImage(Color, Color, Dimension, Component)
- Return a small rectangular image showing a question mark.
-
dispose()
- Release all resources used by the gauge, including
stopping all threads.
-
fireStateChanged(ChangeEvent)
- Send a ChangeEvent to each listener.
-
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.
-
getAccumulatorInterval()
- Return the accumulator interval.
-
getAccumulatorMeasurementInterval()
- Return the accumulator measurement interval.
-
getAccumulatorMeasurementMethod()
- Return the current accumulator measurement method.
-
getBackgroundStyle()
- Return the background to be drawn by this gauge prior
to each paint, or null if no background is set.
Deprecated.
-
getBlockIncrement()
- Return the multi-unit incremental change to be applied to the
gauge value.
-
getDefaultGaugeSynchronization()
- Return the default gauge synchronization, which
is set when the gauge is created.
-
getExtent()
- Return the value range represented by the gauge adjustment artefact.
-
getGaugeSynchronization()
- Return the current gauge synchronization.
-
getMaximum()
- Return the maximum of the current gauge range.
-
getMinimum()
- Return the minimum of the current gauge range.
-
getModel()
- Return the gauge's data model.
-
getNextValue(int, int, int, int, int, int)
- Return the next value which
the gauge display will show.
-
getNextValueDelay(boolean)
- Return the time interval in milliseconds after
which the next value is to be displayed by the
gauge.
-
getOrientation()
- Return the Orientation
-
getPreferredSize()
- Return the preferred size for the gauge, as
set by setPreferredSize().
-
getRangeAdjustmentMethod()
- Return the current range adjustment method.
-
getUnitIncrement()
- Return the unit incremental change to be applied to the
gauge value.
-
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.
-
getValue()
- Return the current value of the gauge.
-
getVisibleAmount()
-
Deprecated.
-
imagesReady()
- This method is called automatically whenever
the final image currently registered to be
monitored during loading becomes ready.
-
imageUpdate(Image, int, int, int, int, int)
- The standard component imageUpdate method.
-
isAccumulatorEnabled()
- Return whether or not accumulation is enabled.
-
isEditable()
- Return whether this gauge's value may be altered via user interaction.
-
isImageReady(Image)
- Return true if the image registered to be
monitored during loading is now ready.
-
isSynchronized(int, int, int, int, int, int)
- Return true if the gauge
considers the current display to be
fully synchronized.
-
notifyAdjustmentValueChanged(AdjustmentEvent)
- Issue an event to all listeners.
-
notifyGauge()
- Inform the gauge that updates should recommence.
-
paint(Graphics, Dimension, int, int, int, boolean, int, int, int)
- Paint the gauge.
Deprecated.
-
paintComponent(Graphics)
- The standard paintComponent method.
-
paintComponent(Graphics, Dimension, int, int, int)
- Paint the gauge on to the given graphics, sized
to the given dimension.
-
processComponentEvent(ComponentEvent)
-
-
removeAdjustmentListener(AdjustmentListener)
- Remove a listener from the list of listeneres
to be notified whenever the gauge value changes.
-
resetAccumulator()
- Resets all data members used by the accumulator and starts the timer.
-
resetSynchronization()
-
-
run()
- The standard Runnable run method.
-
setAccumulatorEnabled(boolean)
- Specify whether accumulation is enabled.
-
setAccumulatorInterval(long)
- Specify the accumulator interval in milliseconds.
-
setAccumulatorMeasurementInterval(long)
- Specify the accumulator measurement interval in milliseconds.
-
setAccumulatorMeasurementMethod(int)
- Specify the accumulator measurement method.
-
setBackgroundStyle(Background)
- Set the background to be drawn by this gauge prior
to each paint.
Deprecated.
-
setBlockIncrement(int)
- Specify the multi-unit incremental change to be applied to the
gauge value.
-
setDefaultGaugeSynchronization(GaugeSynchronization)
- Set the default gauge synchronization to be used by this gauge.
-
setEditable(boolean)
- Specify whether this gauge's value may be altered via user interaction.
-
setExtent(int)
- Specify the value range represented by the gauge adjustment artefact.
-
setGaugeSynchronization(GaugeSynchronization)
- Set the gauge synchronization to be used by this gauge.
-
setMaximum(int)
- Set the maximum of the gauge range.
-
setMinimum(int)
- Set the minimum of the gauge range.
-
setModel(GaugeModel)
- Set the gauge's data model.
-
setOpaque(boolean)
-
-
setOrientation(int)
- Set the orientation for the gauge.
-
setPreferredSize(int, int)
- Set the preferred size for the gauge.
-
setRangeAdjustmentMethod(int)
- Specify the required automatic gauge range adjustment method
-
setUnitIncrement(int)
- Specify the unit incremental change to be applied to the
gauge value.
-
setValue(int)
- Set the current gauge value.
-
setVisibleAmount(int)
-
Deprecated.
-
synchronize()
- Wait until the gauge is synchronized.
-
waitForImage(Image)
- This method waits until the specified
registered image is loaded, and
returns immediately if the image is
already loaded (or not registered).
-
waitForImages()
- This method waits until all currently
registered images are loaded.
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.
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
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
copyright
public static String copyright()
setAccumulatorEnabled
public void setAccumulatorEnabled(boolean accumulatorEnabled)
- Specify whether accumulation is enabled.
- See Also:
- setAccumulatorEnabled
isAccumulatorEnabled
public boolean isAccumulatorEnabled()
- Return whether or not accumulation is enabled.
- See Also:
- isAccumulatorEnabled
setAccumulatorInterval
public void setAccumulatorInterval(long accumulatorInterval)
- Specify the accumulator interval in milliseconds.
- See Also:
- setAccumulatorMeasurementInterval
getAccumulatorInterval
public long getAccumulatorInterval()
- Return the accumulator interval.
- See Also:
- setAccumulatorInterval
setAccumulatorMeasurementMethod
public void setAccumulatorMeasurementMethod(int accumulatorMeasurementMethod)
- Specify the accumulator measurement method.
- See Also:
- setAccumulatorMeasurementInterval
getRangeAdjustmentMethod
public int getRangeAdjustmentMethod()
- Return the current range adjustment method.
- See Also:
- getRangeAdjustmentMethod
setRangeAdjustmentMethod
public void setRangeAdjustmentMethod(int rangeAdjustmentMethod)
- Specify the required automatic gauge range adjustment method
- See Also:
- setRangeAdjustmentMethod
getAccumulatorMeasurementMethod
public int getAccumulatorMeasurementMethod()
- Return the current accumulator measurement method.
- See Also:
- getAccumulatorMeasurementMethod
setAccumulatorMeasurementInterval
public void setAccumulatorMeasurementInterval(long accumulatorMeasurementInterval)
- Specify the accumulator measurement interval in milliseconds.
- See Also:
- setAccumulatorMeasurementInterval
getAccumulatorMeasurementInterval
public long getAccumulatorMeasurementInterval()
- Return the accumulator measurement interval.
- See Also:
- getAccumulatorMeasurementInterval
resetAccumulator
public void resetAccumulator()
- Resets all data members used by the accumulator and starts the timer.
accumulate
public void accumulate()
- Increment the accumulator total by one.
- See Also:
- accumulate
accumulate
public void accumulate(int increment)
- Increment the accumulator total by the specified increment.
- See Also:
- accumulate
addAdjustmentListener
public void addAdjustmentListener(AdjustmentListener listener)
- Add a listener to the list of listeners
to be notified whenever the gauge value changes.
removeAdjustmentListener
public void removeAdjustmentListener(AdjustmentListener listener)
- Remove a listener from the list of listeneres
to be notified whenever the gauge value changes.
notifyAdjustmentValueChanged
protected void notifyAdjustmentValueChanged(AdjustmentEvent event)
- Issue an event to all listeners.
getOrientation
public int getOrientation()
- Return the Orientation
setOrientation
public void setOrientation(int orientation)
- Set the orientation for the gauge.
- See Also:
- getOrientation
getUnitIncrement
public int getUnitIncrement()
- Return the unit incremental change to be applied to the
gauge value.
- See Also:
- setUnitIncrement
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.
getBlockIncrement
public int getBlockIncrement()
- Return the multi-unit incremental change to be applied to the
gauge value.
- See Also:
- setBlockIncrement
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.
getVisibleAmount
public int getVisibleAmount()
- Note: getVisibleAmount() is deprecated.
use getExtent() instead.
- See Also:
- getExtent
setVisibleAmount
public void setVisibleAmount(int visibleAmount)
- Note: setVisibleAmount() is deprecated.
use setExtent(int) instead.
- See Also:
- setExtent
getExtent
public int getExtent()
- Return the value range represented by the gauge adjustment artefact.
- See Also:
- setExtent
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.
getMinimum
public int getMinimum()
- Return the minimum of the current gauge range.
setMinimum
public void setMinimum(int minimum)
- Set the minimum of the gauge range.
getMaximum
public int getMaximum()
- Return the maximum of the current gauge range.
setMaximum
public void setMaximum(int maximum)
- Set the maximum of the gauge range.
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
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.
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
isEditable
public boolean isEditable()
- Return whether this gauge's value may be altered via user interaction.
setEditable
public void setEditable(boolean editable)
- Specify whether this gauge's value may be altered via user interaction.
setOpaque
public void setOpaque(boolean isOpaque)
- Overrides:
- setOpaque in class JComponent
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.
resetSynchronization
public void resetSynchronization()
getDefaultGaugeSynchronization
public GaugeSynchronization getDefaultGaugeSynchronization()
- Return the default gauge synchronization, which
is set when the gauge is created.
- See Also:
- setDefaultGaugeSynchronization
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
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
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
setPreferredSize
public void setPreferredSize(int x,
int y)
- Set the preferred size for the gauge.
- See Also:
- getPreferredSize
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
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
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
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.
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
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
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
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
waitForImages
protected void waitForImages()
- This method waits until all currently
registered images are loaded.
- See Also:
- addImage, addImages, imagesReady, isImageReady, areImagesReady, waitForImage
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
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
addImages
protected void addImages(Image images[])
- Register images to be monitored during
loading
- See Also:
- addImage, areImagesReady, imagesReady, isImageReady, waitForImage, waitForImages
addImage
protected void addImage(Image image)
- Register an image to be monitored during
loading
- See Also:
- addImages, areImagesReady, imagesReady, isImageReady, waitForImage, waitForImages
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
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
createMissingImage
protected static Image createMissingImage(Color backgroundColor,
Color foregroundColor,
Dimension dimension,
Component component)
- Return a small rectangular image showing a question mark.
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
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
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
run
public void run()
- The standard Runnable run method.
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.
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
getModel
public GaugeModel getModel()
- Return the gauge's data model.
setModel
public void setModel(GaugeModel gaugeModel)
- Set the gauge's data model.
processComponentEvent
protected void processComponentEvent(ComponentEvent componentEvent)
- Overrides:
- processComponentEvent in class Component
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.
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.
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
createDefaultGaugeModelListener
protected GaugeModelListener createDefaultGaugeModelListener()
All Packages Class Hierarchy This Package Previous Next Index