# Class SlaveTicker

java.lang.Object
uk.ac.starlink.ttools.plot2.geom.SlaveTicker

All Implemented Interfaces:
  `Ticker`

public class SlaveTicker extends Object implements 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

Constructors
Constructor
Description
`SlaveTicker(Axis masterAxis, DoubleUnaryOperator masterToSlaveFunc, Ticker basicTicker)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`static SlaveTicker`
`createTicker(Axis masterAxis, DoubleUnaryOperator masterToSlaveFunc)`
Creates a SlaveTicker instance with automatic selection of basic ticker.
`TickRun`
`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.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### SlaveTicker

public SlaveTicker(Axis masterAxis, DoubleUnaryOperator masterToSlaveFunc, Ticker basicTicker)
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 axis
  `masterToSlaveFunc` - function mapping values on the master axis to values on the slave axis
  `basicTicker` - 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 interface `Ticker`
Parameters:
  `masterDlo` - minimum axis data value
  `masterDhi` - maximum axis data value
  `withMinor` - if true minor axes are included, if false only major (labelled) ones are
  `captioner` - caption painter
  `orients` - array of label orientations in order of preference, must contain at least one element
  `npix` - number of pixels along the axis
  `crowding` - 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

public static SlaveTicker createTicker(Axis masterAxis, DoubleUnaryOperator masterToSlaveFunc)
Creates a SlaveTicker instance with automatic selection of basic ticker.

Parameters:
  `masterAxis` - master axis
  `masterToSlaveFunc` - function mapping values on the master axis to values on the slave axis
Returns:
  new ticker