com.yospace.yae.yogi
Class YogiRange

java.lang.Object
  |
  +--com.yospace.yae.yogi.YogiComponent
        |
        +--com.yospace.yae.yogi.YogiRange
Direct Known Subclasses:
YogiProgressBar, YogiScrollBar, YogiSlider

public class YogiRange
extends YogiComponent

Encapsulates a numeric range and a given value within that range, and provides the "unit" and "block" increment sizes for moving the value.

Note that the min value may be larger than the max value, in which case the value will still be clamped to the range. However, it is recommended that the unit/block increments be set to a negative value, otherwise counting up will head towards min, and components based on this may malfunction in interesting ways.


Field Summary
protected  int maxValue
          The maximum value to which the YogiRange value member may be set.
protected  int minValue
          The minimum value to which the YogiRange value member may be set.
static int PROPERTY_BLOCK_INCREMENT
          Constant for scroll block property.
static int PROPERTY_MAX_VALUE
          Constant for the max value property
static int PROPERTY_MIN_VALUE
          Constant for the min value property
static int PROPERTY_UNIT_INCREMENT
          Constant for scroll unit property.
static int PROPERTY_VALUE
          Constant for the value property
protected  int value
          Value currently represented by the YogiRange.
 
Fields inherited from class com.yospace.yae.yogi.YogiComponent
ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT, BORDER_DOTTED, BORDER_NONE, BORDER_PLAIN, BORDER_ROUNDED, BORDER_SOLID, COLOR_BACKGROUND, COLOR_BORDER, COLOR_FOREGROUND, FOCUS_DEFAULT, FOCUS_OFF, FOCUS_ON, PROPERTY_ALIGN, PROPERTY_BORDER_STYLE, PROPERTY_BOUNDS, PROPERTY_COLOR, PROPERTY_CONTEXT_ENABLED, PROPERTY_ENABLED, PROPERTY_FOCUS, PROPERTY_FOCUS_INDEX, PROPERTY_FOCUS_TRAVERSABLE, PROPERTY_FONT, PROPERTY_HOTKEY, PROPERTY_LOCATION, PROPERTY_OPAQUE, PROPERTY_SIZE, PROPERTY_VISIBLE, PROPERTY_X_INSET, PROPERTY_Y_INSET
 
Constructor Summary
YogiRange()
          Default constructor.
YogiRange(int value, int minValue, int maxValue, int unitIncrement, int blockIncrement)
          Constructor which initialises the YogiRange to specified current, min and max values.
 
Method Summary
 int getBlockIncrement()
          Accesses the size of the vertical scroll block.
 int getMaxValue()
          Gets the maximum value allowed in the YogiRange.
 int getMinValue()
          Gets the minimum value allowed in the YogiRange.
 int getRange()
          Convenience method for determining the range between the minimum and maximum values.
 int getUnitIncrement()
          Accesses the size of the vertical scroll unit.
 int getValue()
          Gets the value of the YogiRange.
 void setBlockIncrement(int blockIncrement)
          Sets the number of pixels to be moved in a vertical "block" scroll.
 void setMaxValue(int maxValue)
          Sets the maximum value of the YogiRange to the specified value.
 void setMinValue(int minValue)
          Sets the minimum value of the YogiRange to the specified value.
 void setUnitIncrement(int unitIncrement)
          Sets the number of pixels to be moved in a vertical "unit" scroll.
 void setValue(int value)
          Sets the current value of the YogiRange to the specified value.
 
Methods inherited from class com.yospace.yae.yogi.YogiComponent
_debugPrintComponents, add, addPropertyChangeListener, bringForwards, bringInFrontOf, bringToFront, contains, containsComponent, ensureVisible, ensureVisible, findComponentAt, findCurrentFocus, findFirstFocus, findFocusDomainRoot, findFocusDomainRootImpl, findHotkeyComponent, findNextFocus, fireActionPerformedEvent, firePropertyChangeEvent, getAlign, getBorderStyle, getBounds, getColor, getColors, getComponent, getComponent, getComponentCount, getComponentIndex, getComponents, getFocusBounds, getFocusIndex, getFont, getGlobalLocation, getHeight, getHotkey, getId, getParent, getParent, getTreeLock, getUI, getWidth, getX, getXInset, getY, getYInset, hasFocus, isActive, isContextEnabled, isEnabled, isFocusDomainRoot, isFocusTraversable, isOpaque, isVisible, keyPressed, keyReleased, keyRepeated, paint, paintBackground, paintBorder, paintForeground, pointerDragged, pointerPressed, pointerReleased, remove, remove, removeAll, removePropertyChangeListener, repaint, repaint, repaintAfterRebounding, requestFocus, requestFocus, sendBackwards, sendBehind, sendToBack, setActionListener, setActive, setAlign, setBorderStyle, setBounds, setColor, setColors, setContextEnabled, setDefaultColor, setEnabled, setFocusDomainRoot, setFocusIndex, setFocusTraversable, setFont, setHotkey, setId, setLocation, setNoFocus, setOpaque, setProperty, setSize, setUI, setVisible, setXInset, setYInset, updateUI
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_VALUE

public static final int PROPERTY_VALUE
Constant for the value property

PROPERTY_MIN_VALUE

public static final int PROPERTY_MIN_VALUE
Constant for the min value property

PROPERTY_MAX_VALUE

public static final int PROPERTY_MAX_VALUE
Constant for the max value property

PROPERTY_UNIT_INCREMENT

public static final int PROPERTY_UNIT_INCREMENT
Constant for scroll unit property.

PROPERTY_BLOCK_INCREMENT

public static final int PROPERTY_BLOCK_INCREMENT
Constant for scroll block property.

value

protected int value
Value currently represented by the YogiRange.

minValue

protected int minValue
The minimum value to which the YogiRange value member may be set.

maxValue

protected int maxValue
The maximum value to which the YogiRange value member may be set.
Constructor Detail

YogiRange

public YogiRange()
Default constructor. Values set to represent a percentage model, i.e. value=0, min=0, max=100. Unit increment is set to 1 pixel, block increment to 10 pixels.

YogiRange

public YogiRange(int value,
                 int minValue,
                 int maxValue,
                 int unitIncrement,
                 int blockIncrement)
Constructor which initialises the YogiRange to specified current, min and max values.
Parameters:
value - the YogiRange's current value.
minValue - the YogiRange's minimum value.
maxValue - the YogiRange's maximum value.
unitIncrement - the YogiRange's unit increment.
blockIncrement - the YogiRange's block increment.
Method Detail

setValue

public void setValue(int value)
Sets the current value of the YogiRange to the specified value. The value will be clamped to the range min to max inclusive. A PropertyChange event of PROPERTY_VALUE is fired if the value to set is different from the previous value.
Parameters:
value - the YogiRange's current value.

setMinValue

public void setMinValue(int minValue)
Sets the minimum value of the YogiRange to the specified value. There is no restriction on this value: it may be more than the maximum value thus defining a negative range. A PropertyChange event of PROPERTY_MIN_VALUE is fired if the value to set is different from the previous value.

If the value now lies outside the range min to max inclusive, then it is clamped to the nearest limit, and a PROPERTY_VALUE event will be fired.

Parameters:
minValue - the YogiRange's minimum value.

setMaxValue

public void setMaxValue(int maxValue)
Sets the maximum value of the YogiRange to the specified value. There is no restriction on this value: it may be less than the minimum value thus defining a negative range. A PropertyChange event of PROPERTY_MAX_VALUE is fired if the value to set is different from the previous value.

If the value now lies outside the range min to max inclusive, then it is clamped to the nearest limit, and a PROPERTY_VALUE event will be fired.

Parameters:
maxValue - the YogiRange's maximum value.

getValue

public int getValue()
Gets the value of the YogiRange.
Returns:
the current YogiRange value.

getMinValue

public int getMinValue()
Gets the minimum value allowed in the YogiRange.
Returns:
the YogiRange minimum value.

getMaxValue

public int getMaxValue()
Gets the maximum value allowed in the YogiRange.
Returns:
the YogiRange maximum value.

setUnitIncrement

public void setUnitIncrement(int unitIncrement)
Sets the number of pixels to be moved in a vertical "unit" scroll.
Parameters:
unit - the size of a vertical unit scroll in pixels.

setBlockIncrement

public void setBlockIncrement(int blockIncrement)
Sets the number of pixels to be moved in a vertical "block" scroll.
Parameters:
block - the size of a vertical block scroll in pixels.

getUnitIncrement

public int getUnitIncrement()
Accesses the size of the vertical scroll unit.
Returns:
the vertical scroll unit in pixels.

getBlockIncrement

public int getBlockIncrement()
Accesses the size of the vertical scroll block.
Returns:
the vertical scroll block in pixels.

getRange

public int getRange()
Convenience method for determining the range between the minimum and maximum values.
Returns:
a positive integer denoting the difference between the minimum values.

Copyright 2002 Yospace Holdings Ltd. All Rights Reserved.