- All Known Implementing Classes:
IntegerTickSelector
,NumberTickSelector
public interface TickSelector
Provides standard tick sizes and formatting for numerical axes.
Conceptually, the selector maintains a list of standard tick sizes (ordered
by size), and a pointer to the current (selected) tick size. Clients of
the selector will initialise the pointer by calling the
select(double)
method with a reference value (a guess, based on
context, of the largest usable tick size - for example, one half of the
axis length) then, as required, move the pointer to a smaller or larger
tick size (using the next()
and previous()
methods) to
find the most appropriate standard size to use.
The NumberTickSelector
class provides a standard implementation,
but you can create your own if necessary.
-
Method Summary
Modifier and Type Method Description Format
getCurrentTickLabelFormat()
Returns the tick formatter associated with the tick size that the cursor is currently referencing.double
getCurrentTickSize()
Returns the tick size that the cursor is currently referencing.boolean
next()
Move the cursor to the next (larger) tick size, if there is one.boolean
previous()
Move the cursor to the previous (smaller) tick size, if there is one.double
select(double reference)
Selects and returns a standard tick size that is greater than or equal to the specified reference value and, ideally, as close to it as possible (to minimise the number of iterations used by axes to determine the tick size to use).
-
Method Details
-
select
Selects and returns a standard tick size that is greater than or equal to the specified reference value and, ideally, as close to it as possible (to minimise the number of iterations used by axes to determine the tick size to use). After a call to this method, thegetCurrentTickSize()
method should return the selected tick size (there is a "cursor" that points to this tick size), thenext()
method should move the pointer to the next (larger) standard tick size, and theprevious()
method should move the pointer to the previous (smaller) standard tick size.- Parameters:
reference
- the reference value (must be positive and finite).- Returns:
- The selected tick size.
-
next
boolean next()Move the cursor to the next (larger) tick size, if there is one. Returnstrue
in the case that the cursor is moved, andfalse
where there are a finite number of tick sizes and the current tick size is the largest available.- Returns:
- A boolean.
-
previous
boolean previous()Move the cursor to the previous (smaller) tick size, if there is one. Returnstrue
in the case that the cursor is moved, andfalse
where there are a finite number of tick sizes and the current tick size is the smallest available.- Returns:
- A boolean.
-
getCurrentTickSize
double getCurrentTickSize()Returns the tick size that the cursor is currently referencing.- Returns:
- The tick size.
-
getCurrentTickLabelFormat
Returns the tick formatter associated with the tick size that the cursor is currently referencing.- Returns:
- The formatter.
-