|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object facets.util.Tracer facets.util.NumberPolicy
public class NumberPolicy
Validation and display of numbers.
NumberPolicy
supplies the policy information required when
validating a number or displaying it in the application surface.
Nested Class Summary | |
---|---|
static class |
NumberPolicy.Ticked
Validation and tick-based display of numbers. |
static class |
NumberPolicy.ValueVariable
NumberPolicy.Ticked that adjusts to changes in the value managed. |
Field Summary | |
---|---|
static int |
COLUMNS_DEFAULT
|
static boolean |
debug
|
static int |
FORMAT_DECIMALS_0
|
static int |
FORMAT_DECIMALS_1
|
static int |
FORMAT_DECIMALS_2
|
static int |
FORMAT_DECIMALS_3
|
static int |
FORMAT_DECIMALS_4
|
static int |
FORMAT_HEX
|
static double |
MAX_VALUE
|
static double |
MIN_VALUE
|
static double |
UNIT_JUMP_DEFAULT
|
Constructor Summary | |
---|---|
NumberPolicy(double min,
double max)
Construct a policy that constrains valid values within the immutable range min to max . |
Method Summary | |
---|---|
boolean |
canCycle()
If true , values outside the range will be normalised to within
it. |
int |
columns()
The column width for text boxes in which values are to be displayed. |
protected boolean |
debug()
|
int |
format()
Hint on formatting the number. |
java.lang.String[] |
incrementTitles()
Human-readable description of increment directions. |
double |
max()
The highest possible value under the policy. |
double |
min()
The lowest possible value under the policy. |
protected boolean |
reverseIncrements()
Reverses the normal increment direction. |
java.lang.String |
toString()
|
double |
unit()
The smallest possible increment under the policy. |
protected double |
unitJump()
Returns the multiple of unit defining the current minimum
valid value change. |
double |
validIncrement(double existing,
boolean positive)
Returns a valid increment to existing in the direction given
by positive , or zero if the incremented value is outside the range. |
double |
validValue(double existing,
double proposed)
Returns the nearest valid value to proposed . |
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 |
---|
public static final double MIN_VALUE
public static final double MAX_VALUE
public static final boolean debug
public static double UNIT_JUMP_DEFAULT
public static int COLUMNS_DEFAULT
public static final int FORMAT_DECIMALS_0
public static final int FORMAT_DECIMALS_1
public static final int FORMAT_DECIMALS_2
public static final int FORMAT_DECIMALS_3
public static final int FORMAT_DECIMALS_4
public static final int FORMAT_HEX
Constructor Detail |
---|
public NumberPolicy(double min, double max)
min
to max
.
Method Detail |
---|
public double max()
Set immutably during construction but only accessed via this method, enabling subclasses to define it dynamically by overriding.
public double min()
Set immutably during construction but only accessed via this method, enabling subclasses to define it dynamically by overriding.
public final double validIncrement(double existing, boolean positive)
existing
in the direction given
by positive
, or zero if the incremented value is outside the range.
Calculation of the increment takes into account
unit
, unitJump
, and reverseIncrements
and
its sum with existing
is validated using valueValue
.
public double validValue(double existing, double proposed)
proposed
.
Though not used in the basic implementation, specifying existing
as a parameter allows for non-linear validation in subclasses.
protected boolean debug()
public double unit()
The default implementation deduces this value from format()
.
public boolean canCycle()
true
, values outside the range will be normalised to within
it.
Default is false
.
public int format()
These are defined by the class FORMAT_x constants, which are mutually exclusive.
For FORMAT_PLACES_x constants
the format should normally be consistent with unit
.
public int columns()
Follows AWT convention.
public java.lang.String[] incrementTitles()
public java.lang.String toString()
toString
in class java.lang.Object
protected boolean reverseIncrements()
Used by validIncrement
, default is false
.
protected double unitJump()
unit
defining the current minimum
valid value change.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |