Package uk.ac.starlink.array
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:
Converter
,TypeConverter
-
-
Constructor Summary
Constructors Constructor Description ConvertArrayImpl(NDArray nda, Converter conv)
Constructs a new ArrayImpl from an underlying NDArray and a supplied converter object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AccessImpl
getAccess()
Returns an object which can access the pixels of this ArrayImpl.java.lang.Number
getBadValue()
The magic bad value for data.Type
getType()
Returns the primitive type of the data held by this object.-
Methods inherited from class uk.ac.starlink.array.WrapperArrayImpl
canMap, close, getMapped, getShape, getWrapped, isRandom, isReadable, isWritable, multipleAccess, open, toString
-
-
-
-
Constructor Detail
-
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 convertedconv
- a Converter object which operates on the pixels of nda. Its base type (type1) must match the type of nda.- Throws:
java.lang.IllegalArgumentException
- if conv.getType1() is not equal to nda.getType().
-
-
Method Detail
-
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 interfaceArrayImpl
- Overrides:
getType
in classWrapperArrayImpl
- Returns:
- an object representing the type of data held.
-
getBadValue
public java.lang.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 interfaceArrayImpl
- Overrides:
getBadValue
in classWrapperArrayImpl
- Returns:
- the bad value
-
getAccess
public AccessImpl getAccess() throws java.io.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 interfaceArrayImpl
- Overrides:
getAccess
in classWrapperArrayImpl
- Returns:
- an accessor for the pixel data
- Throws:
java.io.IOException
- if there is an IO error
-
-