org.havi.ui
Class HRangeLook

java.lang.Object
  extended byorg.havi.ui.HRangeLook
All Implemented Interfaces:
java.lang.Cloneable, HAdjustableLook, HExtendedLook, HLook

public class HRangeLook
extends java.lang.Object
implements HExtendedLook, HAdjustableLook

The HRangeLook class is used to display a slider or scrollbar type range control on screen. It is used by specific HVisible components which implement the HAdjustmentValue interface to present a graphical representation of the value to the user. This look will be provided by the platform and the exact way in which it is rendered will be platform dependant.

This look does NOT use content set on the HVisible.

This is the default look that is used by HStaticRange and its subclasses.


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
None.

Default parameter values not exposed in the constructors

DescriptionDefault valueSet method Get method
None.

See Also:
HRange

Field Summary
 
Fields inherited from interface org.havi.ui.HAdjustableLook
ADJUST_BUTTON_LESS, ADJUST_BUTTON_MORE, ADJUST_NONE, ADJUST_PAGE_LESS, ADJUST_PAGE_MORE, ADJUST_THUMB
 
Constructor Summary
HRangeLook()
          Creates an HRangeLook object.
 
Method Summary
 void fillBackground(java.awt.Graphics g, HVisible visible, int state)
          The HExtendedLook.fillBackground(java.awt.Graphics, org.havi.ui.HVisible, int) method paints the component with its current background Color according to the HVisible.setBackgroundMode(int) method of HVisible.
 java.awt.Insets getInsets(HVisible hvisible)
          Determines the insets of this HLook, which indicate the size of the border.
 java.awt.Dimension getMaximumSize(HVisible hvisible)
          Gets the maximum size of the HVisible component when drawn with this HLook.
 java.awt.Dimension getMinimumSize(HVisible hvisible)
          Gets the minimum size of the HVisible component when drawn with this HLook.
 java.awt.Dimension getPreferredSize(HVisible hvisible)
          Gets the preferred size of the HVisible component when drawn with this HLook.
 java.lang.Integer getValue(HOrientable component, java.awt.Point pt)
          Returns the value of the component which corresponds to the pointer position specified by pt.
 int hitTest(HOrientable component, java.awt.Point pt)
          Returns a value which indicates the pointer click position in the on-screen representation of the orientable component.
 boolean isOpaque(HVisible hvisible)
          Returns true if the entire painted area of the HVisible when using this look is fully opaque, i.e. the showLook method guarantees that all pixels are painted in an opaque Color.
 void renderBorders(java.awt.Graphics g, HVisible visible, int state)
          The HExtendedLook.renderBorders(java.awt.Graphics, org.havi.ui.HVisible, int) method paints any implementation specific borders according to the HVisible.setBordersEnabled(boolean) method of HVisible.
 void renderVisible(java.awt.Graphics g, HVisible visible, int state)
          The HExtendedLook.renderVisible(java.awt.Graphics, org.havi.ui.HVisible, int) method paints any content or other data associated with the look's HVisible.
 void showLook(java.awt.Graphics g, HVisible visible, int state)
          The showLook method is the entry point for repainting the entire HVisible component.
 void widgetChanged(HVisible visible, HChangeData[] changes)
          Called by the HVisible whenever its content, state, or any other data changes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HRangeLook

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

Method Detail

fillBackground

public void fillBackground(java.awt.Graphics g,
                           HVisible visible,
                           int state)
The HExtendedLook.fillBackground(java.awt.Graphics, org.havi.ui.HVisible, int) method paints the component with its current background Color according to the HVisible.setBackgroundMode(int) method of HVisible.

This method is only called from showLook within this HExtendedLook implementation. It's not the intention to call this method directly from outside of the HExtendedLook.

Regardless of the background mode, it is an implementation option for this method to render added decorations which may affect the look's transparency. This method shall not be used to render any HVisible related data or content associated with the HVisible. It is purely for background and decoration only.

The fillBackground method should not modify the clipRect (clipping rectangle) of the Graphics object that is passed to it in a way which includes any area not part of that original clipRect. If any modifications are made, the original clipRect shall be restored.

Specified by:
fillBackground in interface HExtendedLook
Parameters:
g - the graphics context.
visible - the visible.
state - the state parameter indicates the state of the visible
Since:
MHP 1.0.3/1.1.1
See Also:
HLook.isOpaque(org.havi.ui.HVisible)

renderBorders

public void renderBorders(java.awt.Graphics g,
                          HVisible visible,
                          int state)
The HExtendedLook.renderBorders(java.awt.Graphics, org.havi.ui.HVisible, int) method paints any implementation specific borders according to the HVisible.setBordersEnabled(boolean) method of HVisible. If borders are drawn, the border decoration shall be rendered within the border area as returned by getInsets. The behavior of this method, when a subclass overrides the method getInsets is undefined, except that it will never draw outside the border area as returned by getInsets.

This method is only called from showLook within this HExtendedLook implementation. It's not the intention to call this method directly from outside of the HExtendedLook.

The HExtendedLook.renderBorders(java.awt.Graphics, org.havi.ui.HVisible, int) method should not modify the clipRect (clipping rectangle) of the Graphics object that is passed to it in a way which includes any area not part of that original clipRect. If any modifications are made, the original clipRect shall be restored.

Specified by:
renderBorders in interface HExtendedLook
Parameters:
g - the graphics context.
visible - the visible.
state - the state parameter indicates the state of the visible
Since:
MHP 1.0.3/1.1.1

renderVisible

public void renderVisible(java.awt.Graphics g,
                          HVisible visible,
                          int state)
The HExtendedLook.renderVisible(java.awt.Graphics, org.havi.ui.HVisible, int) method paints any content or other data associated with the look's HVisible. This method shall not be used to render a background nor any other decoration. Its purpose is purely to render content or other value data stored on the HVisible. This may be set via HVisible methods such as setTextContent and setGraphicContent. Rendering shall take place within the bounds returned by the getInsets method.

This method is only called from showLook within this HExtendedLook implementation. It's not the intention to call this method directly from outside of the HExtendedLook.

For looks which draw content (e.g. HTextLook, HGraphicLook and HAnimateLook), if no content is associated with the component, this method does nothing.

The HExtendedLook.renderVisible(java.awt.Graphics, org.havi.ui.HVisible, int) method should not modify the clipRect (clipping rectangle) of the Graphics object that is passed to it in a way which includes any area not part of that original clipRect. If any modifications are made, the original clipRect shall be restored.

Specified by:
renderVisible in interface HExtendedLook
Parameters:
g - the graphics context.
visible - the visible.
state - the state parameter indicates the state of the visible
Since:
MHP 1.0.3/1.1.1

showLook

public void showLook(java.awt.Graphics g,
                     HVisible visible,
                     int state)
The showLook method is the entry point for repainting the entire HVisible component. This method delegates the responsibility of drawing the component background, borders and any HVisible related data or content to the fillBackground, renderVisible and renderBorders methods respectively, subject to the clipping rectangle of the Graphics object passed to it. This method shall call the methods fillBackground, renderVisible, and renderBorders in that order and shall not do any rendering itself.

The showLook method should not modify the clipRect (clipping rectangle) of the Graphics object that is passed to it in a way which includes any area not part of that original clipRect. If any modifications are made, the original clipRect shall be restored.

Any resources explicitly associated with an HExtendedLook should be loaded by the HExtendedLook during its creation, etc. Note that the "standard" looks don't load content by default.

This method is called from the HVisible.paint(java.awt.Graphics) method of HVisible and must never be called from elsewhere. Components wishing to redraw themselves should call their repaint method in the usual way.

Specified by:
showLook in interface HExtendedLook
Parameters:
g - the graphics context.
visible - the visible.
state - the state parameter indicates the state of the visible, allowing the look to render the appropriate content for that state. Note that some components (e.g. HStaticRange, HRange, HRangeValue) do not use state-based content.

widgetChanged

public void widgetChanged(HVisible visible,
                          HChangeData[] changes)
Called by the HVisible whenever its content, state, or any other data changes. See the class description of HVisible for more information about the changes parameter.

The implementation of this method should work out which graphical areas of the HVisible have changed and make any relevant calls to trigger the repainting of those areas.

A minimum implementation of this method could simply call

 visible.repaint()
 

Specified by:
widgetChanged in interface HLook
Parameters:
visible - the HVisible which has changed
changes - an array containing hint data and associated hint objects. If this argument is null a full repaint will be triggered.

getMinimumSize

public java.awt.Dimension getMinimumSize(HVisible hvisible)
Gets the minimum size of the HVisible component when drawn with this HLook.

This size may be determined in several ways depending on the information available to the look. These steps are performed in order and the first available result is returned. For the purposes of this algorithm HLook classes that do not use content (e.g. HRangeLook) are treated as if no content was present.

The extra space required for border decoration can be determined from the getInsets method.

  1. If this look is an HTextLook and if HVisible.getTextLayoutManager() returns an HDefaultTextLayoutManager, then this method should delegate the call to its getMinimumSize() method plus any additional dimensions that the HLook requires for border decoration etc. If the HDefaultTextLayoutManager returns a zero size, then proceed with the following steps.
  2. If the HLook supports the scaling of its content (e.g. an HGraphicLook) and scaling is requested and content is set, then the return value is a size containing the width of the narrowest content and the height of the shortest content plus any additional dimensions that the HLook requires for border decoration etc.
  3. If the HLook does not support scaling of content or no scaling is requested, and content is set then the return value is a size sufficiently large to hold each piece of content plus any additional dimensions that the HLook requires for border decoration etc.
  4. If no content is available but a default preferred size has been set using setDefaultSize has been called to set then the return value is this value (as obtained with getDefaultSize) plus any additional dimensions that the HLook requires for border decoration etc.
  5. If there is no content or default size set then the return value is an implementation-specific minimum size plus any additional dimensions that the HLook requires for border decoration etc.

Specified by:
getMinimumSize in interface HLook
Parameters:
hvisible - HVisible to which this HLook is attached.
Returns:
A dimension object indicating this HLook's minimum size.
See Also:
HVisible.getMinimumSize()

getPreferredSize

public java.awt.Dimension getPreferredSize(HVisible hvisible)
Gets the preferred size of the HVisible component when drawn with this HLook.

This size may be determined in several ways depending on the information available to the look. These steps are performed in order and the first available result is returned. For the purposes of this algorithm HLook classes that do not use content (e.g. HRangeLook) are treated as if no content was present.

The extra space required for border decoration can be determined from the getInsets method.

  1. If a default preferred size has been set for this HVisible (using setDefaultSize) then the return value is this size (obtained with getDefaultSize) plus any additional dimensions that the HLook requires for border decoration etc.
  2. If this look is an HTextLook and if a default preferred size has not been set and HVisible.getTextLayoutManager() returns an HDefaultTextLayoutManager, then this method should delegate the call to its getPreferredSize() method plus any additional dimensions that the HLook requires for border decoration etc. If the HDefaultTextLayoutManager returns a zero size, then proceed with the following steps.
  3. If this HLook does not support scaling of content or no scaling is requested, and content is present then the return value is a size that is sufficiently large to hold each piece of content plus any additional dimensions that the HLook requires for border decoration etc.
  4. If this HLook supports the scaling of its content (e.g. an HGraphicLook) and content is set then the return value is the current size of the HVisible as returned by getSize).
  5. If there is no content and no default size set then the return value is the current size of the HVisible as returned by getSize).

If a default preferred size has been set for this HVisible (using setDefaultSize()) and the default preferred size has a NO_DEFAULT_WIDTH then the return value is a Dimension with this height (obtained with getDefaultSize()) and the preferred width for the content plus any additional dimensions that the HLook requires for border decoration etc.

If a default preferred size has been set for this HVisible (using setDefaultSize()) and the default preferred size has a NO_DEFAULT_HEIGHT then the return value is a Dimension with this width (obtained with getDefaultSize()) and the preferred height for the content plus any additional dimensions that the HLook requires for border decoration etc.

Specified by:
getPreferredSize in interface HLook
Parameters:
hvisible - HVisible to which this HLook is attached.
Returns:
A dimension object indicating the preferred size of the HVisible when drawn with this HLook.
See Also:
HVisible.getPreferredSize(), HVisible.setDefaultSize(java.awt.Dimension)

getMaximumSize

public java.awt.Dimension getMaximumSize(HVisible hvisible)
Gets the maximum size of the HVisible component when drawn with this HLook.

This size may be determined in several ways depending on the information available to the look. These steps are performed in order and the first available result is returned. For the purposes of this algorithm HLook classes that do not use content (e.g. HRangeLook) are treated as if no content was present.

The extra space required for border decoration can be determined from the getInsets method.

  1. If this look is an HTextLook and if HVisible.getTextLayoutManager() returns an HDefaultTextLayoutManager, then this method should delegate the call to its getMaximumSize() method plus any additional dimensions that the HLook requires for border decoration etc. If the HDefaultTextLayoutManager returns a zero size, then proceed with the following steps.
  2. If the HLook supports the scaling of its content (e.g. an HGraphicLook) then the return value is the current size of the HVisible (as returned by HVisible#getSize).
  3. If the HLook does not support scaling of content or no scaling is requested, and content is set then the return value is a size sufficiently large to hold each piece of content plus any additional dimensions that the HLook requires for border decoration etc.
  4. If there is no content set then a maximum size of [Short.MAX_VALUE, Short.MAX_VALUE] is returned as a Dimension.

Specified by:
getMaximumSize in interface HLook
Parameters:
hvisible - HVisible to which this HLook is attached.
Returns:
A dimension object indicating this HLook's maximum size.
See Also:
HVisible.getMaximumSize()

isOpaque

public boolean isOpaque(HVisible hvisible)
Returns true if the entire painted area of the HVisible when using this look is fully opaque, i.e. the showLook method guarantees that all pixels are painted in an opaque Color.

The default value is implementation specific and depends on the background painting mode of the given HVisible. The consequences of an invalid overridden value are implementation specific.

Specified by:
isOpaque in interface HLook
Parameters:
hvisible - the visible to test
Returns:
true if all the pixels with the java.awt.Component#getBounds method of an HVisible using this look are fully opaque, i.e. the showLook method guarantees that all pixels are painted in an opaque Color, otherwise false.

getInsets

public java.awt.Insets getInsets(HVisible hvisible)
Determines the insets of this HLook, which indicate the size of the border. This area is reserved for the HLook to use for drawing borders around the associated HVisible.

Specified by:
getInsets in interface HLook
Parameters:
hvisible - HVisible to which this HLook is attached.
Returns:
the insets of this HLook.

hitTest

public int hitTest(HOrientable component,
                   java.awt.Point pt)
Returns a value which indicates the pointer click position in the on-screen representation of the orientable component.

The behavior of this method in HListGroupLook differs from the behavior of HAdjustableLook.hitTest() in that if the position belongs to an HListElement of the associated HListGroup, then this method will return the index of that element. The look will not change the appearance of that element (eg. by highlighting it). Such a change may only occur due to a call to widgetChanged(org.havi.ui.HVisible, org.havi.ui.HChangeData[]).

Note that it is a valid implementation option to always return ADJUST_NONE.

Specified by:
hitTest in interface HAdjustableLook
Parameters:
component - - the HOrientable component for which the hit position should be calculated
pt - - the pointer click point relative to the upper-left corner of the specified component.
Returns:
one of ADJUST_NONE, ADJUST_BUTTON_LESS, ADJUST_PAGE_LESS, ADJUST_THUMB, ADJUST_PAGE_MORE or ADJUST_BUTTON_MORE.

getValue

public java.lang.Integer getValue(HOrientable component,
                                  java.awt.Point pt)
Returns the value of the component which corresponds to the pointer position specified by pt. If the position does not map to a value (eg. the mouse is outside the active area of the component), this method returns null.

The look shall not reflect the value returned by this method visibly. If the component uses the returned value, it will inform the look by calling widgetChanged().

Specified by:
getValue in interface HAdjustableLook
Parameters:
component - an HOrientable implemented by an HVisible
pt - the position of the mouse-cursor relative to the upper-left corner of the associated component
Returns:
the value associated with the specified position or null
See Also:
hitTest(org.havi.ui.HOrientable, java.awt.Point)