Class ConvertArrayImpl

java.lang.Object
uk.ac.starlink.array.WrapperArrayImpl
uk.ac.starlink.array.ConvertArrayImpl
All Implemented Interfaces:
ArrayImpl

public class ConvertArrayImpl extends WrapperArrayImpl
Wraps an NDArray to produce a virtual NDArray whose pixels are modified using a Converter object. Amongst other possibilities this can perform type conversion and transform pixel values using a supplied real function.
Author:
Mark Taylor (Starlink)
See Also:
  • Constructor Details

    • ConvertArrayImpl

      public ConvertArrayImpl(NDArray nda, Converter conv)
      Constructs a new ArrayImpl from an underlying NDArray and a supplied converter object.
      Parameters:
      nda - the base NDArray which supplies the pixels to be converted
      conv - a Converter object which operates on the pixels of nda. Its base type (type1) must match the type of nda.
      Throws:
      IllegalArgumentException - if conv.getType1() is not equal to nda.getType().
  • Method Details

    • getType

      public Type getType()
      Description copied from interface: ArrayImpl
      Returns the primitive type of the data held by this object. The return value must not change over the lifetime of the object.
      Specified by:
      getType in interface ArrayImpl
      Overrides:
      getType in class WrapperArrayImpl
      Returns:
      an object representing the type of data held.
    • getBadValue

      public Number getBadValue()
      Description copied from interface: ArrayImpl
      The magic bad value for data. The returned type should be one of the primitive wrapper types, Byte, Short, Integer, Float, Double as appropriate for the type of this array. It may be null if there is no bad value. The return value must not change over the lifetime of the object.
      Specified by:
      getBadValue in interface ArrayImpl
      Overrides:
      getBadValue in class WrapperArrayImpl
      Returns:
      the bad value
    • 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