Class ReorderingMapper

java.lang.Object
uk.ac.starlink.array.ReorderingMapper
All Implemented Interfaces:
OffsetMapper

public class ReorderingMapper extends Object implements OffsetMapper
Implements the OffsetMapper interface to map between arrays with the same shape but different ordering schemes.
Author:
Mark Taylor (Starlink)
  • Constructor Summary

    Constructors
    Constructor
    Description
    ReorderingMapper(NDShape shape, Order order1, Order order2)
    Constructs an OffsetMapper which maps between two arrays with the same shape but different pixel sequences.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    mapOffset(long off1)
    Returns an offset into array 2 corresponding to a given offset in array 1.
    long[]
    mapRange(long[] range1)
    Returns a two-element array (min,max) indicating the range of mapping output values (array 2 offsets) which correspond to a given range of input values (array 1 offsets).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ReorderingMapper

      public ReorderingMapper(NDShape shape, Order order1, Order order2)
      Constructs an OffsetMapper which maps between two arrays with the same shape but different pixel sequences.
      Parameters:
      shape - the common shape of the two arrays
      order1 - the ordering scheme of array 1
      order2 - the ordering scheme of array 2
  • Method Details

    • mapOffset

      public long mapOffset(long off1)
      Description copied from interface: OffsetMapper
      Returns an offset into array 2 corresponding to a given offset in array 1. Any long value may be returned, though depending on the the size of array 2 it may not fall within its bounds. A negative value always corresponds to a pixel which does not exist in array 2. It is the responsibility of clients of this OffsetMapper to cope with such out-of-bounds return values sensibly.
      Specified by:
      mapOffset in interface OffsetMapper
      Parameters:
      off1 - the offset into the array 1 giving a pixel position
      Returns:
      the offset into array 2 giving the position of the corresponding pixel off1 into array 1
    • mapRange

      public long[] mapRange(long[] range1)
      Description copied from interface: OffsetMapper
      Returns a two-element array (min,max) indicating the range of mapping output values (array 2 offsets) which correspond to a given range of input values (array 1 offsets). The return value constitutes a guarantee that OffsetMapper.mapOffset(long) will not return any value outside of the range returned, as long as no value outside of the supplied range parameter is not supplied to it. The returned range is only used for efficiency purposes and may be conservative (a larger range than will actually be returned). A null value may be returned; this, like a return value of {-Long.MIN_VALUE,Long.MAX_VALUE} constitutes no guarantee about the mapping output values.
      Specified by:
      mapRange in interface OffsetMapper
      Parameters:
      range1 - a two-element array giving the lowest value and highest value (inclusive) which will be supplied to the mapOffset method (range to be considered in array 1)
      Returns:
      a two-element array giving the lowest value and highest value (inclusive) which could be returned by the mapOffset method (range which could be returned in array 2) under the above circumstances. May be null if the information is not available