# Class BinMapper

java.lang.Object
uk.ac.starlink.ttools.plot2.layer.BinMapper

@Equality public class BinMapper extends Object
Maps axis values to bin indices.

Since:
  16 Jan 2017
Author:
  Mark Taylor

## Constructor Summary

Constructors
Constructor
Description
`BinMapper(Scale scale, double scaleWidth, double binPhase, double dpoint)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`boolean`
`equals(Object o)`
`int`
`getBinIndex(double dvalue)`
Returns the bin index for a given value.
`double[]`
`getBinLimits(int index)`
Returns the bin limits for a given bin index.
`int`
`hashCode()`

### Methods inherited from class Object

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

## Constructor Details

### BinMapper

public BinMapper(Scale scale, double scaleWidth, double binPhase, double dpoint)
Constructor.

The `dpoint` parameter is used internally to determine the zero point of the bins. In principle this should make no difference to behaviour, but in case that the data is situated a very long way from 1, setting it close to the actual data point locations may avoid rounding errors.

Parameters:
  `scale` - axis scaling
  `scaleWidth` - extent of bins in scale units
  `binPhase` - determines sub-bin boundary shifts along axis, normally in range 0..1
  `dpoint` - representative data space point on axis which bins are situated

## Method Details

### getBinIndex

public int getBinIndex(double dvalue)
Returns the bin index for a given value. In case of an invalid value (NaN, or non-positive for log scale), behaviour is undefined (quite likely zero will be returned).

Parameters:
  `dvalue` - valid axis value in data space
Returns:
  bin index

### getBinLimits

public double[] getBinLimits(int index)
Returns the bin limits for a given bin index.

Parameters:
  `index` - bin index
Returns:
  (lower,upper) bin limits

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `Object`

### equals

public boolean equals(Object o)

Overrides:
  `equals` in class `Object`