Class BasicTicker
java.lang.Object
uk.ac.starlink.ttools.plot2.BasicTicker
- All Implemented Interfaces:
Ticker
Partial Ticker implementation based on a rule defining a sequence of ticks.
Concrete subclasses must implement a method to create a Rule
suitable for a given range, and this is used to provide suitable
ticks for particular circumstances, including avoiding label overlap.
- Since:
- 17 Oct 2013
- Author:
- Mark Taylor
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceDefines a specific rule for generating major and minor axis tick marks. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BasicTickerTicker for linear axes.static final BasicTickerTicker for logarithmic axes. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic TickercreateHybridTicker(Scale scale, double linthresh) Returns a ticker instance that is linear within a given distance of the origin and logarithmic or negative logarithmic for larger absolute values.abstract BasicTicker.RulecreateRule(double dlo, double dhi, double approxMajorCount, int adjust) Returns a new rule for labelling an axis in a given range.static Tick[]getMajorTicks(BasicTicker.Rule rule, double dlo, double dhi) Use a given rule to generate major ticks in a given range of coordinates.static Tick[]getMinorTicks(BasicTicker.Rule rule, double dlo, double dhi) Use a given rule to generate minor ticks in a given range of coordinates.getTicks(double dlo, double dhi, boolean withMinor, Captioner captioner, Orientation[] orients, int npix, double crowding) Generates tick marks for labelling a plot axis.static CaptionlinearLabel(long mantissa, int exp) Generates a major tick mark label suitable for use with linear axes.static booleanoverlaps(Tick[] ticks, Axis axis, Captioner captioner, Orientation orient) Determines whether the labels for a set of tick marks would overlap when painted on a given axis.
-
Field Details
-
LINEAR
Ticker for linear axes. -
LOG
Ticker for logarithmic axes.
-
-
Constructor Details
-
BasicTicker
-
-
Method Details
-
createRule
public abstract BasicTicker.Rule createRule(double dlo, double dhi, double approxMajorCount, int adjust) Returns a new rule for labelling an axis in a given range. The tick density is determined by two parameters,approxMajorCount, which gives a baseline value for the number of ticks required over the given range, andadjust. Increasingadjustwill give more major ticks, and decreasing it will give fewer ticks. Each value of adjust should result in a different tick count.- Parameters:
dlo- minimum axis data valuedhi- maximum axis data valueapproxMajorCount- guide value for number of major ticks in rangeadjust- adjusts density of major ticks, zero is normal
-
getTicks
public TickRun getTicks(double dlo, double dhi, boolean withMinor, Captioner captioner, Orientation[] orients, int npix, double crowding) Description copied from interface:TickerGenerates tick marks for labelling a plot axis.The supplied list of orientations is attempted in order; if the required crowding can be satisfied by any of them, that orientation will be used. If it can't be supplied by any (because of unavoidable label overlap) a lower crowding value may be used.
- Specified by:
getTicksin interfaceTicker- Parameters:
dlo- minimum axis data valuedhi- maximum axis data valuewithMinor- if true minor axes are included, if false only major (labelled) ones arecaptioner- caption painterorients- array of label orientations in order of preference, must contain at least one elementnpix- number of pixels along the axiscrowding- 1 for normal tick density on the axis, lower for fewer labels, higher for more- Returns:
- tick array along with orientation actually used
-
createHybridTicker
Returns a ticker instance that is linear within a given distance of the origin and logarithmic or negative logarithmic for larger absolute values.- Parameters:
scale- axis scalinglinthresh- distance from origin within which ticks are linear- Returns:
- new ticker
-
getMajorTicks
Use a given rule to generate major ticks in a given range of coordinates.- Parameters:
rule- tick generation ruledlo- minimum axis data valuedhi- maximum axis data value- Returns:
- array of major ticks
-
getMinorTicks
Use a given rule to generate minor ticks in a given range of coordinates.- Parameters:
rule- tick generation ruledlo- minimum axis data valuedhi- maximum axis data value- Returns:
- array of minor ticks
-
linearLabel
Generates a major tick mark label suitable for use with linear axes. Some care is required assembling the label, to make sure we avoid rounding issues (like 0.999999999999). Double.toString() is not good enough.- Parameters:
mantissa- multiplierexp- power of 10- Returns:
- tick label text
-
overlaps
Determines whether the labels for a set of tick marks would overlap when painted on a given axis.- Parameters:
ticks- major tick marksaxis- axis on which the ticks will be drawncaptioner- caption painterorient- label orientation- Returns:
- true iff some of the ticks are so close to each other that their labels will overlap
-