public class SequenceBuilder extends java.lang.Object
// Input sequence Sequence in = ... // Create a SequenceBuilder object, that will be in charge of allocating // and feeding the output sequence. SequenceBuilder builder = new SequenceBuilder ( // The output sequence will have the same size and data-type than the input in.getSizeX(), in.getSizeY(), in.getSizeZ(), in.getSizeT(), in.getSizeC(), in.getDataType_() ); // Start the building process. builder.beginUpdate(); try { // Here, the copy can be multi-threaded. No synchronization or mutex-locking // is required on the side of the SequenceBuilder object. ... // Thread 1 forall(int t,z,c in listOfXYPlanesToBeDoneByThread1) { // Retrieve the array that will hold the pixel values corresponding to // the XY-plane at coordinates (t, z, c) in the output sequence. If this // object does not exist, it is created. The object returned by the // method getData is actually an instance of byte[], short[], int[], // float[] or double[], depending on the data-type specified in the // SequenceBuilder constructor. // // Remark: depending on the context, it may be more convenient to call // builder.getDataAsDouble, builder.getDataAsByte, etc... // Object buffer = builder.getData(t, z, c); // Execute the copy. For example: { Array1DUtil.arrayToArray(in.getDataXY(t, z, c), buffer); } // Mark the array returned by the previous call to builder.getData(t, z, c) // as ready to be incorporated in the output sequence. // // Remark: there should only be one call to the method validateData // per set of coordinates (t, z, c). // builder.validateData(t, z, c); } ... // Thread 2 forall(int t,z,c in listOfXYPlanesToBeDoneByThread2) { // etc... } ... } // Finish the building process (each call to beginUpdate() must be followed // by a call to endUpdate()). finally { builder.endUpdate(); } // Return the sequence that have been created by the SequenceBuilder object. return builder.getResult();
Constructor and Description |
---|
SequenceBuilder(int sizeX,
int sizeY,
int sizeZ,
int sizeT,
int sizeC,
DataType dataType)
Allocate a new sequence that will have the given size, dataType and an empty name
|
SequenceBuilder(int sizeX,
int sizeY,
int sizeZ,
int sizeT,
int sizeC,
DataType dataType,
Sequence target)
If non-null, the 'target' argument will be used to store the result of the
sequence building process, and no new sequence will be created.
|
Modifier and Type | Method and Description |
---|---|
void |
beginUpdate()
Start building the sequence
|
void |
endUpdate()
Finish building the sequence.
|
java.lang.Object |
getData(int t,
int z,
int c)
Retrieve or allocate the buffer for the XY plane corresponding to the given (t,z,c) coordinates
|
byte[] |
getDataAsByte(int t,
int z,
int c)
Retrieve or allocate the buffer for the XY plane corresponding to the given (t,z,c) coordinates
|
double[] |
getDataAsDouble(int t,
int z,
int c)
Retrieve or allocate the buffer for the XY plane corresponding to the given (t,z,c) coordinates
|
float[] |
getDataAsFloat(int t,
int z,
int c)
Retrieve or allocate the buffer for the XY plane corresponding to the given (t,z,c) coordinates
|
int[] |
getDataAsInt(int t,
int z,
int c)
Retrieve or allocate the buffer for the XY plane corresponding to the given (t,z,c) coordinates
|
short[] |
getDataAsShort(int t,
int z,
int c)
Retrieve or allocate the buffer for the XY plane corresponding to the given (t,z,c) coordinates
|
DataType |
getDataType()
Data-type of the sequence to be created
|
Sequence |
getResult()
Return the output sequence
|
int |
getSizeC()
Size C of the sequence to be created
|
int |
getSizeT()
Size T of the sequence to be created
|
int |
getSizeX()
Size X of the sequence to be created
|
int |
getSizeY()
Size Y of the sequence to be created
|
int |
getSizeZ()
Size Z of the sequence to be created
|
boolean |
isPreAllocated()
Check if the sequence is pre-allocated, i.e. if it already has the proper
size and data-type that was specified by the argument passed to the
SequenceBuilder constructor
|
void |
validateData(int t,
int z,
int c)
Validate the buffer for the XY plane corresponding to the given (t,z,c) coordinates
|
public SequenceBuilder(int sizeX, int sizeY, int sizeZ, int sizeT, int sizeC, DataType dataType)
public SequenceBuilder(int sizeX, int sizeY, int sizeZ, int sizeT, int sizeC, DataType dataType, Sequence target)
public int getSizeX()
public int getSizeY()
public int getSizeZ()
public int getSizeT()
public int getSizeC()
public DataType getDataType()
public boolean isPreAllocated()
public void beginUpdate()
java.lang.IllegalStateException
- if the object is already in an "updating" statepublic void endUpdate()
public double[] getDataAsDouble(int t, int z, int c)
java.lang.NullPointerException
- if the method beginUpdate() has not been called previously.public float[] getDataAsFloat(int t, int z, int c)
java.lang.NullPointerException
- if the method beginUpdate() has not been called previously.public byte[] getDataAsByte(int t, int z, int c)
java.lang.NullPointerException
- if the method beginUpdate() has not been called previously.public short[] getDataAsShort(int t, int z, int c)
java.lang.NullPointerException
- if the method beginUpdate() has not been called previously.public int[] getDataAsInt(int t, int z, int c)
java.lang.NullPointerException
- if the method beginUpdate() has not been called previously.public java.lang.Object getData(int t, int z, int c)
java.lang.NullPointerException
- if the method beginUpdate() has not been called previously.public void validateData(int t, int z, int c)
java.lang.NullPointerException
- if the method beginUpdate() has not been called previously.