public class TextReader extends FormatReader
Modifier and Type | Field and Description |
---|---|
private java.lang.String[] |
channels
List of channel labels.
|
private float[][] |
data
Because we have no way of indexing into the text file efficiently
in general, we cheat and store the entire file's data in a giant array.
|
private static java.lang.String |
LABEL_X |
private static java.lang.String |
LABEL_Y |
private static boolean |
LITTLE_ENDIAN |
private int |
row
Current row number.
|
private int |
rowLength
Number of tokens per row.
|
private int |
sizeX
Image width.
|
private int |
sizeY
Image height.
|
private static long |
TIME_OFFSET
How often to report progress during initialization, in milliseconds.
|
private int |
xIndex
Column index for X coordinate.
|
private int |
yIndex
Column index for Y coordinate.
|
core, coreIndex, datasetDescription, domains, filterMetadata, flattenedResolutions, group, hasCompanionFiles, in, indexedAsRGB, metadata, metadataStore, normalizeData, resolution, saveOriginalMetadata, series, suffixNecessary, suffixSufficient, THUMBNAIL_DIMENSION
COMPRESSION_SUFFIXES, currentId, format, LOGGER, metadataOptions, suffixes
CAN_GROUP, CANNOT_GROUP, MUST_GROUP
Constructor and Description |
---|
TextReader()
Constructs a new text reader.
|
Modifier and Type | Method and Description |
---|---|
private void |
assignValues(double[] rowData)
Assigns values from the given row into the data array.
|
private long |
checkTime(long time,
int no,
long pos,
long len) |
void |
close(boolean fileOnly)
Closes the currently open file.
|
java.lang.String |
getChannelLabel(int c)
Gets the label for the given channel.
|
java.lang.Class<?> |
getNativeDataType()
Returns the native data type of image planes for this reader, as returned
by
IFormatReader.openPlane(int, int, int, int, int) or IFormatWriter.savePlane(int, java.lang.Object) . |
private java.lang.String[] |
getNextLine(java.util.List<java.lang.String> lines) |
private boolean |
getRowData(java.lang.String[] tokens,
double[] rowData)
Parses numerical row data from the given tokens.
|
private int |
getX(double[] rowData) |
private int |
getY(double[] rowData) |
protected void |
initFile(java.lang.String id)
Initializes the given file (parsing header information, etc.).
|
boolean |
isThisType(loci.common.RandomAccessInputStream stream)
Checks if the given stream is a valid stream for this file format.
|
byte[] |
openBytes(int no,
byte[] buf,
int x,
int y,
int w,
int h)
Obtains a sub-image of the specified image plane
into a pre-allocated byte array.
|
java.lang.Object |
openPlane(int no,
int x,
int y,
int w,
int h)
Obtains the specified image plane (or sub-image thereof) in the reader's
native data structure.
|
private int |
parseFileHeader(java.util.List<java.lang.String> lines)
Parses the file looking for the file header.
|
private void |
parseHeaderRow(java.lang.String[] tokens)
Populates rowLength, xIndex, yIndex, and channels.
|
private void |
parseTableData(java.util.List<java.lang.String> lines,
int linesToSkip)
Reads the tabular data into the data array.
|
private void |
populateCoreMetadata(int sizeX,
int sizeY,
int sizeZ,
int sizeC,
int sizeT)
Populates the
CoreMetadata values. |
private java.util.List<java.lang.String> |
readFile(java.lang.String id) |
addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMeta, addGlobalMetaList, addMeta, addMetaList, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMeta, addSeriesMetaList, close, coreIndexToSeries, fileGroupOption, flattenHashtables, get16BitLookupTable, get8BitLookupTable, getAcquisitionMode, getAdvancedSeriesUsedFiles, getAdvancedUsedFiles, getArcType, getBinning, getBitsPerPixel, getCompression, getContrastMethod, getCoreIndex, getCoreMetadataList, getCorrection, getCurrentCore, getCurrentFile, getDatasetStructureDescription, getDetectorType, getDimensionOrder, getDimensionOrder, getDomains, getEffectiveSizeC, getExperimentType, getFilamentType, getFillRule, getFilterType, getFontFamily, getFontStyle, getGlobalMeta, getGlobalMetadata, getIlluminationType, getImageCount, getImmersion, getIndex, getIndex, getLaserMedium, getLaserType, getMarker, getMedium, getMetadataStore, getMetadataStoreRoot, getMetadataValue, getMicrobeamManipulationType, getMicroscopeType, getModuloC, getModuloT, getModuloZ, getNamingConvention, getOptimalTileHeight, getOptimalTileWidth, getPixelType, getPixelType, getPossibleDomains, getPulse, getRequiredDirectories, getResolution, getResolutionCount, getRGBChannelCount, getRotationTransform, getSeries, getSeriesCount, getSeriesMeta, getSeriesMetadata, getSeriesMetadataValue, getSeriesUsedFiles, getSeriesUsedFiles, getSizeC, getSizeT, getSizeX, getSizeY, getSizeZ, getThumbSizeX, getThumbSizeY, getUnderlyingReaders, getUsedFiles, getUsedFiles, getZCTCoords, getZCTModuloCoords, hasCompanionFiles, hasFlattenedResolutions, isFalseColor, isGroupFiles, isIndexed, isInterleaved, isInterleaved, isLittleEndian, isMetadataComplete, isMetadataFiltered, isNormalized, isOrderCertain, isOriginalMetadataPopulated, isRGB, isSingleFile, isThisType, isThisType, isThisType, isThumbnailSeries, isUsedFile, makeFilterMetadata, openBytes, openBytes, openBytes, openThumbBytes, readPlane, readPlane, reopenFile, seriesToCoreIndex, setCoreIndex, setFlattenedResolutions, setGroupFiles, setId, setMetadataFiltered, setMetadataStore, setNormalized, setOriginalMetadataPopulated, setResolution, setSeries, updateMetadataLists
checkSuffix, checkSuffix, getFormat, getMetadataOptions, getSuffixes, getSupportedMetadataLevels, setMetadataOptions
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getFormat, getSuffixes
getMetadataOptions, getSupportedMetadataLevels, setMetadataOptions
private static final boolean LITTLE_ENDIAN
private static final java.lang.String LABEL_X
private static final java.lang.String LABEL_Y
private static final long TIME_OFFSET
private float[][] data
private int row
private int rowLength
private int xIndex
private int yIndex
private java.lang.String[] channels
private int sizeX
private int sizeY
public java.lang.String getChannelLabel(int c)
public boolean isThisType(loci.common.RandomAccessInputStream stream) throws java.io.IOException
IFormatReader
isThisType
in interface IFormatReader
isThisType
in class FormatReader
stream
- A RandomAccessInputStream representing the file to check.
The first byte in the stream is assumed to be the first byte
in the file.java.io.IOException
public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, java.io.IOException
IFormatReader
openBytes
in interface IFormatReader
openBytes
in class FormatReader
no
- the image index within the file.buf
- a pre-allocated buffer.x
- X coordinate of the upper-left corner of the sub-imagey
- Y coordinate of the upper-left corner of the sub-imagew
- width of the sub-imageh
- height of the sub-imagebuf
for convenience.FormatException
- if there was a problem parsing the metadata of the
file.java.io.IOException
- if there was a problem reading the file.public java.lang.Object openPlane(int no, int x, int y, int w, int h) throws FormatException, java.io.IOException
IFormatReader
BufferedImage
. The openPlane method exists to
maintain generality and efficiency while avoiding pollution of the API
with AWT-specific logic.openPlane
in interface IFormatReader
openPlane
in class FormatReader
FormatException
java.io.IOException
FormatReader
,
BufferedImageReader
public void close(boolean fileOnly) throws java.io.IOException
IFormatReader
Closeable.close()
.close
in interface IFormatReader
close
in class FormatReader
java.io.IOException
public java.lang.Class<?> getNativeDataType()
IFormatHandler
IFormatReader.openPlane(int, int, int, int, int)
or IFormatWriter.savePlane(int, java.lang.Object)
.
For most readers this type will be a byte array; however, some readers
call external APIs that work with other types such as
BufferedImage
.getNativeDataType
in interface IFormatHandler
getNativeDataType
in class FormatHandler
protected void initFile(java.lang.String id) throws FormatException, java.io.IOException
FormatReader
initFile
in class FormatReader
FormatException
- if a parsing error occurs processing the file.java.io.IOException
- if an I/O error occurs processing the fileprivate java.util.List<java.lang.String> readFile(java.lang.String id) throws java.io.IOException
java.io.IOException
private int parseFileHeader(java.util.List<java.lang.String> lines) throws FormatException
FormatException
private void parseTableData(java.util.List<java.lang.String> lines, int linesToSkip)
private void populateCoreMetadata(int sizeX, int sizeY, int sizeZ, int sizeC, int sizeT)
CoreMetadata
values.private boolean getRowData(java.lang.String[] tokens, double[] rowData)
tokens
- list of token strings to parserowData
- array to fill in with the data; length must match tokensprivate void parseHeaderRow(java.lang.String[] tokens)
private void assignValues(double[] rowData)
private long checkTime(long time, int no, long pos, long len)
private int getX(double[] rowData)
private int getY(double[] rowData)
private java.lang.String[] getNextLine(java.util.List<java.lang.String> lines)
Copyright © 2020 Open Microscopy Environment