Package uk.ac.starlink.ttools.plot2.geom
Class SlaveTicker
java.lang.Object
uk.ac.starlink.ttools.plot2.geom.SlaveTicker
- All Implemented Interfaces:
Ticker
Ticker implementation that provides ticks for a supplied function
based on a separate master axis.
This is suitable when two different axes are attached to the same
dimension of a plot, providing different numerical mappings of
the same underlying quantity.
- Since:
- 5 Dec 2022
- Author:
- Mark Taylor
-
Constructor Summary
ConstructorsConstructorDescriptionSlaveTicker
(Axis masterAxis, DoubleUnaryOperator masterToSlaveFunc, Ticker basicTicker) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic SlaveTicker
createTicker
(Axis masterAxis, DoubleUnaryOperator masterToSlaveFunc) Creates a SlaveTicker instance with automatic selection of basic ticker.getTicks
(double masterDlo, double masterDhi, boolean withMinor, Captioner captioner, Orientation[] orients, int npix, double crowding) Generates tick marks for labelling a plot axis.double
masterToSlave
(double masterValue) Maps a value on the master axis to a value on the slave axis.double
slaveToMaster
(double slaveValue) Maps a value on the slave axis to a value on the master axis.
-
Constructor Details
-
SlaveTicker
Constructor. The assumption is that the supplied mapping function is monotonic and fairly well-behaved over the relevant range. If not, the ticks might not come out well.- Parameters:
masterAxis
- master axismasterToSlaveFunc
- function mapping values on the master axis to values on the slave axisbasicTicker
- ticker than can provide labels on a given range
-
-
Method Details
-
getTicks
public TickRun getTicks(double masterDlo, double masterDhi, boolean withMinor, Captioner captioner, Orientation[] orients, int npix, double crowding) Description copied from interface:Ticker
Generates 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:
getTicks
in interfaceTicker
- Parameters:
masterDlo
- minimum axis data valuemasterDhi
- 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
-
masterToSlave
public double masterToSlave(double masterValue) Maps a value on the master axis to a value on the slave axis.- Parameters:
masterValue
- master axis value- Returns:
- slave axis value
-
slaveToMaster
public double slaveToMaster(double slaveValue) Maps a value on the slave axis to a value on the master axis.- Parameters:
slaveValue
- slave axis value- Returns:
- master axis value
-
createTicker
Creates a SlaveTicker instance with automatic selection of basic ticker.- Parameters:
masterAxis
- master axismasterToSlaveFunc
- function mapping values on the master axis to values on the slave axis- Returns:
- new ticker
-