facets.util
Class NumberPolicy.Ticked

java.lang.Object
  extended by facets.util.Tracer
      extended by facets.util.NumberPolicy
          extended by facets.util.NumberPolicy.Ticked
Direct Known Subclasses:
AnglePolicy, NumberPolicy.ValueVariable, Shades.HSBPolicy, Shades.RGBPolicy
Enclosing class:
NumberPolicy

public static class NumberPolicy.Ticked
extends NumberPolicy

Validation and tick-based display of numbers.

NumberPolicy.Ticked supplies validation and display policy for numbers displayed on a scale such as that of a slider.


Nested Class Summary
 
Nested classes/interfaces inherited from class facets.util.NumberPolicy
NumberPolicy.Ticked, NumberPolicy.ValueVariable
 
Field Summary
static int LABEL_TICKS_DEFAULT
           
static int SNAP_LABELS
           
static int SNAP_NONE
           
static int SNAP_TICKS
           
static int TICKS_DEFAULT
           
 
Fields inherited from class facets.util.NumberPolicy
COLUMNS_DEFAULT, debug, FORMAT_DECIMALS_0, FORMAT_DECIMALS_1, FORMAT_DECIMALS_2, FORMAT_DECIMALS_3, FORMAT_DECIMALS_4, FORMAT_HEX, MAX_VALUE, MIN_VALUE, UNIT_JUMP_DEFAULT
 
Constructor Summary
NumberPolicy.Ticked()
          Convenience constructor for a scale that dynamically defines its constraints.
NumberPolicy.Ticked(double range)
          Convenience constructor for a tick-based policy with local adjstment and infinite range.
NumberPolicy.Ticked(double min, double max)
          Convenience constructor for a full-range tick scale.
NumberPolicy.Ticked(double min, double max, double range)
          Construct a tick-based policy that can optionally display the current value within a local adjustment range.
 
Method Summary
 int labelSpacing()
          The number of ticks between each label.
 NumberPolicy.Ticked localTicks()
          Returns the policy to be used for local adjustment.
 double range()
          The range of possible values.
 int snapType()
          Defines the snap-to-ticks contentStyle.
 int tickSpacing()
          The spacing between each tick, in the value returned by NumberPolicy.unit().
 java.lang.String toString()
           
protected  double unitJump()
          Returns the multiple of unit defining the current minimum valid value change, based on the current snap policy.
 double validValue(double existing, double proposed)
          Returns the nearest valid value to proposed.
 
Methods inherited from class facets.util.NumberPolicy
canCycle, columns, debug, format, incrementTitles, max, min, reverseIncrements, unit, validIncrement
 
Methods inherited from class facets.util.Tracer
trace, trace, trace, trace, trace, traceDebug, traceDebug, traceObjectText, traceOutput, traceOutputWithClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SNAP_NONE

public static final int SNAP_NONE
See Also:
Constant Field Values

SNAP_TICKS

public static final int SNAP_TICKS
See Also:
Constant Field Values

SNAP_LABELS

public static final int SNAP_LABELS
See Also:
Constant Field Values

TICKS_DEFAULT

public static int TICKS_DEFAULT

LABEL_TICKS_DEFAULT

public static int LABEL_TICKS_DEFAULT
Constructor Detail

NumberPolicy.Ticked

public NumberPolicy.Ticked(double range)
Convenience constructor for a tick-based policy with local adjstment and infinite range.


NumberPolicy.Ticked

public NumberPolicy.Ticked(double min,
                           double max)
Convenience constructor for a full-range tick scale.


NumberPolicy.Ticked

public NumberPolicy.Ticked(double min,
                           double max,
                           double range)
Construct a tick-based policy that can optionally display the current value within a local adjustment range.

The policy is constructed from min to max as for its superclass. If range is other than NaN, values will be displayed within this adjustment range, which will centre on the current value unless constrained by min to max.


NumberPolicy.Ticked

public NumberPolicy.Ticked()
Convenience constructor for a scale that dynamically defines its constraints.

Method Detail

validValue

public double validValue(double existing,
                         double proposed)
Description copied from class: NumberPolicy
Returns the nearest valid value to proposed.

Though not used in the basic implementation, specifying existing as a parameter allows for non-linear validation in subclasses.

Overrides:
validValue in class NumberPolicy

labelSpacing

public int labelSpacing()
The number of ticks between each label.


localTicks

public NumberPolicy.Ticked localTicks()
Returns the policy to be used for local adjustment.

The default is to return the NumberPolicy.Ticked itself; this can be overridden to return a policy for local adjustment where the NumberPolicy.Ticked is full-range but local adjustment is also required.


range

public double range()
The range of possible values.

Set immutably during construction but only accessed via this method, enabling subclasses to define it dynamically by overriding.


snapType

public int snapType()
Defines the snap-to-ticks contentStyle.

The value returned should be one of


tickSpacing

public int tickSpacing()
The spacing between each tick, in the value returned by NumberPolicy.unit().


unitJump

protected final double unitJump()
Returns the multiple of unit defining the current minimum valid value change, based on the current snap policy.

The value returned is determined by the values of snapType and tickSpacing.

Overrides:
unitJump in class NumberPolicy

toString

public java.lang.String toString()
Overrides:
toString in class NumberPolicy