public class OrderedNDShape extends NDShape implements Cloneable
NDShape
s with an additional
ordering specified which indicates the sequence in which pixels
are encountered. This class thus defines a mapping between an
ordered sequence of positions and their coordinates in N-dimensional
space.DEFAULT_ORIGIN
Constructor and Description |
---|
OrderedNDShape(long[] origin,
long[] dims,
Order order)
Creates an OrderedNDShape from its origin, dimensions and ordering.
|
OrderedNDShape(long[] dims,
Order order)
Creates an OrderedNDShape with a default origin from its dimensions
and ordering.
|
OrderedNDShape(NDShape shape)
Creates a new OrderedNDShape from an NDShape.
|
OrderedNDShape(NDShape shape,
Order order)
Creates an OrderedNDShape from a NDShape and an ordering.
|
Modifier and Type | Method and Description |
---|---|
Object |
clone() |
boolean |
equals(Object other)
Indicates whether another object is equivalent to this one.
|
Order |
getOrder()
Gets the ordering scheme of this object.
|
int |
hashCode() |
long[] |
offsetToPosition(long offset)
Determines the coordinates of a pixel at a given offset within the
pixel sequence.
|
Iterator |
pixelIterator()
Returns an Iterator which will iterate over all the pixels in this
OrderedNDShape's pixel sequence.
|
Iterator |
pixelIterator(long start,
long length)
Returns an Iterator which will iterate over a range of pixels
in this OrderedNDShape's pixel sequence.
|
long |
positionToOffset(long[] pos)
Returns the offset of a pixel having given coordinates within
the sequence of pixels defined by this OrderedNDShape.
|
boolean |
sameSequence(OrderedNDShape other)
Indicates whether another object represents the same pixel sequence
as this.
|
String |
toString() |
fromString, getDims, getLimits, getNumDims, getNumPixels, getOrigin, getUpperBounds, intersection, intsToLongs, longsToInts, sameShape, toString, toString, union, within
public OrderedNDShape(long[] origin, long[] dims, Order order)
origin
- an array representing the origindims
- an array representing the dimension extentsorder
- an Order object specifying the pixel ordering scheme.
If the null value is supplied, an arbitrary ordering
scheme will be applied.IllegalArgumentException
- if origin and dims have different
lengths or any of the dimensions are not positivepublic OrderedNDShape(long[] dims, Order order)
NDShape.DEFAULT_ORIGIN
.dims
- an array representing the dimension extentsorder
- an Order object specifying the pixel ordering scheme.
If the null value is supplied, an arbitrary ordering
scheme will be applied.IllegalArgumentException
- if any of the dimensions are not
positivepublic OrderedNDShape(NDShape shape, Order order)
shape
- a NDShape objectorder
- an Order object specifying the pixel ordering scheme
If the null value is supplied, an arbitrary ordering
scheme will be applied.public OrderedNDShape(NDShape shape)
shape
is in fact an instance
of OrderedNDShape
,
the created object will be equivalent to it. If not, a new
OrderedNDShape object will be created with an arbitrary
ordering scheme.shape
- an NDShape or OrderedNDShape objectpublic Order getOrder()
public Iterator pixelIterator(long start, long length)
next
method of the returned Iterator returns an array of longs
giving the coordinates of the next pixel in the sequence.
Note that this long array is the same object every time, but its
contents change at each iteration. It should not be modified
by clients.start
- the first offset in the pixel sequence over which to
iteratelength
- the number of pixels over which to iterateIllegalArgumentException
- if start and length would imply
iteration outside of this shape or length is negativepublic Iterator pixelIterator()
next
method of the returned Iterator returns an array of longs
giving the coordinates of the next pixel in the sequence.
Note that this long array is the same object every time, but its
contents change at each iteration. It should not be modified
by clients.
Equivalent to pixelIterator(0,getNumPixels())
;
public long positionToOffset(long[] pos)
pos
- a coordinate vector giving a pixel positionpos
occursIndexOutOfBoundsException
- if pos is outside this shapepublic long[] offsetToPosition(long offset)
offset
- an offset into the list of pixelsoffset
IndexOutOfBoundsException
- if offset
is outside this shapepublic boolean sameSequence(OrderedNDShape other)
other
- the shape to compare with this onepublic boolean equals(Object other)
Copyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.