Package uk.ac.starlink.array

# Class PixelMapArrayImpl

java.lang.Object
uk.ac.starlink.array.WrapperArrayImpl
uk.ac.starlink.array.PixelMapArrayImpl

All Implemented Interfaces:
  `ArrayImpl`

public class PixelMapArrayImpl extends WrapperArrayImpl
Wraps an NDArray to produce a virtual ArrayImpl in which each pixel is the same as a pixel of the base array, but in a different order. An `OffsetMapper` object is used to define the mapping between pixels in the base array and pixels in this array.

Note that no assumptions about contiguity of pixels can be made while doing bulk data access on a PixelMapNDArray; where applicable a `WindowArrayImpl` is likely to be more efficient.

Author:
  Mark Taylor (Starlink)
See Also:
  - `OffsetMapper`
  - `WindowArrayImpl`

## Constructor Summary

Constructors
Constructor
Description
`PixelMapArrayImpl(NDArray nda, OrderedNDShape oshape, OffsetMapper mapper)`
Constructs a new ArrayImpl from a base NDArray and an OffsetMapper object which transforms the offset of a pixel in the base array to the offset of the same pixel in this PixelMapArrayImpl.

## Method Summary

Modifier and Type
Method
Description
`AccessImpl`
`getAccess()`
Returns an object which can access the pixels of this ArrayImpl.
`OrderedNDShape`
`getShape()`
Returns an object representing the shape (origin and dimensions) and pixel sequence of this object.

### Methods inherited from class uk.ac.starlink.array.WrapperArrayImpl

`canMap, close, getBadValue, getMapped, getType, getWrapped, isRandom, isReadable, isWritable, multipleAccess, open, toString`

### Methods inherited from class java.lang.Object

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

## Constructor Details

### PixelMapArrayImpl

public PixelMapArrayImpl(NDArray nda, OrderedNDShape oshape, OffsetMapper mapper)
Constructs a new ArrayImpl from a base NDArray and an OffsetMapper object which transforms the offset of a pixel in the base array to the offset of the same pixel in this PixelMapArrayImpl. Since for a non-degenerate case a monotonic pixel offset ordering in a PixelMapNDArray is likely to correspond to a non-monotonic offset ordering in its base array, it is only permitted to construct a PixelMapNDArray from a base array which offers random access.

Parameters:
  `nda` - the base NDArray which supplies the pixels
  `oshape` - the shape and pixel sequence of the NDArray to be constructed
  `mapper` - an OffsetMapper object which turns the offset of a pixel in this NDArray into the offset of the corresponding pixel in the base NDArray
Throws:
  `UnsupportedOperationException` - if nda does not have random access

## Method Details

### getShape

public OrderedNDShape getShape()
Description copied from interface: `ArrayImpl`
Returns an object representing the shape (origin and dimensions) and pixel sequence of this object. The return value must not change over the lifetime of the object.

Specified by:
  `getShape` in interface `ArrayImpl`
Overrides:
  `getShape` in class `WrapperArrayImpl`
Returns:
  the ordered shape

### getAccess

public AccessImpl getAccess() throws IOException
Description copied from interface: `ArrayImpl`
Returns an object which can access the pixels of this ArrayImpl. Each call to this method returns a new and independent AccessImpl, with an offset initialised to 0 (the start of the array data).

This method will only be called after the sole call to open and before the sole call to close.

This method will only be called more than once if the multipleAccess method returns true.

It is the responsibility of the caller to close the returned AccessImpl when it is no longer required; this enables resources it may hold to be released.

Specified by:
  `getAccess` in interface `ArrayImpl`
Overrides:
  `getAccess` in class `WrapperArrayImpl`
Returns:
  an accessor for the pixel data
Throws:
  `IOException` - if there is an IO error