org.havi.ui
Class HStaticRange

java.lang.Object
  extended by java.awt.Component
      extended by org.havi.ui.HComponent
          extended by org.havi.ui.HVisible
              extended by org.havi.ui.HStaticRange
All Implemented Interfaces:
java.awt.image.ImageObserver, java.io.Serializable, TestOpacity, HMatteLayer, HNoInputPreferred, HOrientable, HState
Direct Known Subclasses:
HRange

public class HStaticRange
extends HVisible
implements HNoInputPreferred, HOrientable

The HStaticRange is a user interface component used to display a static value which is within a fixed range, but does not permit the user to navigate (focus) upon it. By default it uses the HRangeLook to render itself.


The parameters to the constructors are as follows, in cases where parameters are not used, then the constructor should use the default values.

Default parameter values exposed in the constructors

ParameterDescriptionDefault value Set methodGet method
x x-coordinate of top left hand corner of this component in pixels, relative to its parent container (subject to layout management). --- java.awt.Component#setBounds java.awt.Component#getBounds
y y-coordinate of top left hand corner of this component in pixels, relative to its parent container (subject to layout management). --- java.awt.Component#setBounds java.awt.Component#getBounds
width width of this component in pixels (subject to layout management). --- java.awt.Component#setBounds java.awt.Component#getBounds
height height of this component in pixels (subject to layout management). --- java.awt.Component#setBounds java.awt.Component#getBounds
orientation The "orientation" of the range object. ORIENT_LEFT_TO_RIGHT setOrientation getOrientation
minimum The minimum value that can be returned by this range object. 0 setRange getMinValue
maximum The maximum value that can be returned by this range object. 100 setRange getMaxValue
value The current value returned by this range object. 0 setValue getValue

Default parameter values not exposed in the constructors

DescriptionDefault valueSet method Get method
Associated matte (HMatte). none (i.e. getMatte() returns null) setMatte getMatte
The text layout manager responsible for text formatting. An HDefaultTextLayoutManager object. HVisible.setTextLayoutManager(org.havi.ui.HTextLayoutManager) HVisible.getTextLayoutManager()
The background painting mode HVisible.NO_BACKGROUND_FILL HVisible.setBackgroundMode(int) HVisible.getBackgroundMode()
The default preferred size not set (i.e. NO_DEFAULT_SIZE) unless specified by width and height parameters HVisible.setDefaultSize(java.awt.Dimension) HVisible.getDefaultSize()
The horizontal content alignment HVisible.HALIGN_CENTER HVisible.setHorizontalAlignment(int) HVisible.getHorizontalAlignment()
The vertical content alignment HVisible.VALIGN_CENTER HVisible.setVerticalAlignment(int) HVisible.getVerticalAlignment()
The content scaling mode HVisible.RESIZE_NONE HVisible.setResizeMode(int) HVisible.getResizeMode()
The border mode true HVisible.setBordersEnabled(boolean) HVisible.getBordersEnabled()
The default "look" for this class. A platform specific HRangeLook HStaticRange.setDefaultLook HStaticRange.getDefaultLook
The "look" for this object. The HRangeLook returned from HStaticRange.getDefaultLook when this object was created. HStaticRange.setLook HStaticRange.getLook
The offsets for the "thumb" of this range control min = 0, max = 0 setThumbOffsets getThumbMinOffset / getThumbMaxOffset
The behavior of this range object with respect to its "thumb" values SLIDER_BEHAVIOR setBehavior getBehavior

See Also:
Serialized Form

Field Summary
static int SCROLLBAR_BEHAVIOR
          The HStaticRange shall behave as a scrollbar, i.e. the allowable values that may be set / returned for the HStaticRange shall be affected by the "thumb" offsets, and hence its value shall be able to vary between [minimum + minThumbOffset, maximum - maxThumbOffset].
static int SLIDER_BEHAVIOR
          The HStaticRange shall behave as a slider, i.e. the allowable values that may be set / returned for the HStaticRange shall not be affected by the "thumb" offsets, and hence its value shall be able to vary between [minimum, maximum].
 
Fields inherited from class org.havi.ui.HVisible
ADJUSTMENT_VALUE_CHANGE, ANIMATE_CONTENT_CHANGE, ANIMATION_POSITION_CHANGE, BACKGROUND_FILL, BORDER_CHANGE, CARET_POSITION_CHANGE, CONTENT_CHANGE, ECHO_CHAR_CHANGE, EDIT_MODE_CHANGE, FIRST_CHANGE, GRAPHIC_CONTENT_CHANGE, HALIGN_CENTER, HALIGN_JUSTIFY, HALIGN_LEFT, HALIGN_RIGHT, ITEM_VALUE_CHANGE, LAST_CHANGE, LIST_CONTENT_CHANGE, LIST_ICONSIZE_CHANGE, LIST_LABELSIZE_CHANGE, LIST_MULTISELECTION_CHANGE, LIST_SCROLLPOSITION_CHANGE, LIST_SELECTION_CHANGE, MIN_MAX_CHANGE, NO_BACKGROUND_FILL, NO_DEFAULT_HEIGHT, NO_DEFAULT_SIZE, NO_DEFAULT_WIDTH, ORIENTATION_CHANGE, REPEAT_COUNT_CHANGE, RESIZE_ARBITRARY, RESIZE_NONE, RESIZE_PRESERVE_ASPECT, SIZE_CHANGE, STATE_CHANGE, TEXT_CONTENT_CHANGE, TEXT_VALUE_CHANGE, THUMB_OFFSETS_CHANGE, UNKNOWN_CHANGE, VALIGN_BOTTOM, VALIGN_CENTER, VALIGN_JUSTIFY, VALIGN_TOP
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface org.havi.ui.HOrientable
ORIENT_BOTTOM_TO_TOP, ORIENT_LEFT_TO_RIGHT, ORIENT_RIGHT_TO_LEFT, ORIENT_TOP_TO_BOTTOM
 
Fields inherited from interface org.havi.ui.HState
ACTIONED_FOCUSED_STATE, ACTIONED_STATE, ACTIONED_STATE_BIT, ALL_STATES, DISABLED_ACTIONED_FOCUSED_STATE, DISABLED_ACTIONED_STATE, DISABLED_FOCUSED_STATE, DISABLED_STATE, DISABLED_STATE_BIT, FIRST_STATE, FOCUSED_STATE, FOCUSED_STATE_BIT, LAST_STATE, NORMAL_STATE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
HStaticRange()
          Creates an HStaticRange object.
HStaticRange(int orientation, int minimum, int maximum, int value)
          Creates an HStaticRange object.
HStaticRange(int orientation, int minimum, int maximum, int value, int x, int y, int width, int height)
          Creates an HStaticRange object.
 
Method Summary
 int getBehavior()
          Returns the behavior for this HStaticRange.
static HRangeLook getDefaultLook()
          Returns the currently set default HLook for HStaticRange components.
 int getMaxValue()
          Get the maximum value of the range
 int getMinValue()
          Gets the minimum of the range.
 int getOrientation()
          Retrieve the orientation of the HStaticRange.
 int getThumbMaxOffset()
          Returns the thumb offset for its maximum value.
 int getThumbMinOffset()
          Returns the thumb offset for its minimum value.
 int getValue()
          Gets the value of the control.
 void setBehavior(int behavior)
          Sets the behavior for this HStaticRange.
static void setDefaultLook(HRangeLook look)
          Sets the default HLook for further HStaticRange Components.
 void setLook(HLook hlook)
          Sets the HLook for this component.
 void setOrientation(int orient)
          Set the orientation of the HStaticRange.
 boolean setRange(int minimum, int maximum)
          Sets the range of values for the control.
 void setThumbOffsets(int minOffset, int maxOffset)
          Set the offsets for the "thumb" area on this range control.
 void setValue(int value)
          Sets the value of the control, subject to its current behavior.
 
Methods inherited from class org.havi.ui.HVisible
getAnimateContent, getBackgroundMode, getBordersEnabled, getContent, getDefaultSize, getGraphicContent, getHorizontalAlignment, getInteractionState, getLook, getLookData, getMaximumSize, getMinimumSize, getPreferredSize, getResizeMode, getTextContent, getTextLayoutManager, getVerticalAlignment, isFocusTraversable, isOpaque, paint, setAnimateContent, setBackgroundMode, setBordersEnabled, setContent, setDefaultSize, setEnabled, setGraphicContent, setHorizontalAlignment, setInteractionState, setLookData, setResizeMode, setTextContent, setTextLayoutManager, setVerticalAlignment, update
 
Methods inherited from class org.havi.ui.HComponent
getMatte, isDoubleBuffered, isEnabled, processEvent, setMatte
 
Methods inherited from class java.awt.Component
addComponentListener, addFocusListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disableEvents, dispatchEvent, doLayout, enableEvents, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getCursor, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getParent, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, hasFocus, imageUpdate, invalidate, isDisplayable, isLightweight, isShowing, isValid, isVisible, list, list, list, list, list, paintAll, paramString, prepareImage, prepareImage, print, printAll, processComponentEvent, processFocusEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, removeComponentListener, removeFocusListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, repaint, repaint, repaint, repaint, requestFocus, setBackground, setBounds, setBounds, setCursor, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, toString, transferFocus, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SLIDER_BEHAVIOR

public static final int SLIDER_BEHAVIOR
The HStaticRange shall behave as a slider, i.e. the allowable values that may be set / returned for the HStaticRange shall not be affected by the "thumb" offsets, and hence its value shall be able to vary between [minimum, maximum].

See Also:
Constant Field Values

SCROLLBAR_BEHAVIOR

public static final int SCROLLBAR_BEHAVIOR
The HStaticRange shall behave as a scrollbar, i.e. the allowable values that may be set / returned for the HStaticRange shall be affected by the "thumb" offsets, and hence its value shall be able to vary between [minimum + minThumbOffset, maximum - maxThumbOffset].

See Also:
Constant Field Values
Constructor Detail

HStaticRange

public HStaticRange()
Creates an HStaticRange object. See the class description for details of constructor parameters and default values.


HStaticRange

public HStaticRange(int orientation,
                    int minimum,
                    int maximum,
                    int value,
                    int x,
                    int y,
                    int width,
                    int height)
Creates an HStaticRange object. See the class description for details of constructor parameters and default values.


HStaticRange

public HStaticRange(int orientation,
                    int minimum,
                    int maximum,
                    int value)
Creates an HStaticRange object. See the class description for details of constructor parameters and default values.

Method Detail

setLook

public void setLook(HLook hlook)
             throws HInvalidLookException
Sets the HLook for this component.

Overrides:
setLook in class HVisible
Parameters:
hlook - The HLook that is to be used for this component. Note that this parameter may be null, in which case the component will not draw itself until a look is set.
Throws:
HInvalidLookException - If the Look is not an HRangeLook.

setDefaultLook

public static void setDefaultLook(HRangeLook look)
Sets the default HLook for further HStaticRange Components.

Parameters:
look - The HLook that will be used by default when creating a new HStaticRange component. Note that this parameter may be null, in which case newly created components shall not draw themselves until a non-null look is set using the setLook method.

getDefaultLook

public static HRangeLook getDefaultLook()
Returns the currently set default HLook for HStaticRange components.

Returns:
The HLook that is used by default when creating a new HStaticRange component.

getOrientation

public int getOrientation()
Retrieve the orientation of the HStaticRange. The orientation controls how the associated HLook lays out the component.

Specified by:
getOrientation in interface HOrientable
Returns:
one of ORIENT_LEFT_TO_RIGHT, ORIENT_RIGHT_TO_LEFT, ORIENT_TOP_TO_BOTTOM, or ORIENT_BOTTOM_TO_TOP.

setOrientation

public void setOrientation(int orient)
Set the orientation of the HStaticRange. The orientation controls the layout of the component.

Specified by:
setOrientation in interface HOrientable
Parameters:
orient - one of ORIENT_LEFT_TO_RIGHT, ORIENT_RIGHT_TO_LEFT, ORIENT_TOP_TO_BOTTOM, or ORIENT_BOTTOM_TO_TOP.

setRange

public boolean setRange(int minimum,
                        int maximum)
Sets the range of values for the control. If the maximum is greater than the minimum and the value of the control is outside the new range (subject to the control's current behavior), then the value is changed to the closest valid value.

Parameters:
minimum - The minimum value of the range control
maximum - The maximum value of the range control
Returns:
Indicates if the min and max values have been set correctly. Returns false if the minimum value is greater than or equal to the maximum value, otherwise returns true

getMinValue

public int getMinValue()
Gets the minimum of the range.

Returns:
The minimum value for the range

getMaxValue

public int getMaxValue()
Get the maximum value of the range

Returns:
The maximum value of the range.

setValue

public void setValue(int value)
Sets the value of the control, subject to its current behavior. If the specified value is not valid, then the method shall round it to the closest valid value. An application can retrieve the corrected value by means of method getValue().

Parameters:
value - the value for this HStaticRange
See Also:
SLIDER_BEHAVIOR, SCROLLBAR_BEHAVIOR

getValue

public int getValue()
Gets the value of the control. Note that the recovered value is subject to the control's current behavior.

See Also:
SLIDER_BEHAVIOR, SCROLLBAR_BEHAVIOR

setThumbOffsets

public void setThumbOffsets(int minOffset,
                            int maxOffset)
Set the offsets for the "thumb" area on this range control. The "thumb" is then drawn from (value - minOffset), to (value + maxOffset) positions outside of the HRange values [minimum:maximum] are clipped to the closest value.

There is no requirement that minOffset == maxOffset. For example, both offsets may be zero, yielding a thermometer-like range object. All measurements are in the same units as the minimum / maximum values on the HStaticRange object. The size of the "thumb" is the application author's responsibility. By default the "thumb" does not affect the range over which the value of the HStaticRange may be modified. It is recommended that the HRangeLook provides mechanisms to denote the value of the HStaticRange, in addition to indicating the extent of the thumb as defined by the offsets.

If this control's behavior is SCROLLBAR_BEHAVIOR, then the following rules apply: If the thumb offsets are illegal, i.e. minimum + thumbMinOffset is equal or greater than maximum - thumbMaxOffset, then an IllegalArgumentException shall be thrown. If the control's value is not valid for the specified offsets, then the value shall be changed to the closest valid value.

See Also:
setBehavior(int)

getThumbMinOffset

public int getThumbMinOffset()
Returns the thumb offset for its minimum value.

Returns:
the thumb offset for its minimum value.

getThumbMaxOffset

public int getThumbMaxOffset()
Returns the thumb offset for its maximum value.

Returns:
the thumb offset for its maximum value.

setBehavior

public void setBehavior(int behavior)
Sets the behavior for this HStaticRange. If the new behavior is SCROLLBAR_BEHAVIOR and the control's settings for range and thumb offsets are illegal, i.e. minimum + thumbMinOffset is equal or greater than maximum - thumbMaxOffset, then an IllegalArgumentException shall be thrown. If the control's value is not valid for the offsets, then the value shall be changed to the closest valid value.

Parameters:
behavior - the behavior for this HStaticRange (SLIDER_BEHAVIOR or SCROLLBAR_BEHAVIOR).

getBehavior

public int getBehavior()
Returns the behavior for this HStaticRange.

Returns:
the behavior for this HStaticRange.