|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectFacemorph.DataBase.Batch
public class Batch
Batch stores a list of image files and template files, together with any variables including ID defined
Nested Class Summary | |
---|---|
class |
Batch.BatchFileException
|
static class |
Batch.Type
Describes the type of a Object to allow the system to determine compatability |
Field Summary | |
---|---|
protected java.lang.String |
baseDirectory
Base directory of the files in the Batch |
static java.awt.Color |
colour_exists
|
static java.awt.Color |
colour_invalid
|
static java.awt.Color |
colour_unknown
|
protected java.util.Map<java.lang.String,java.lang.Integer> |
columnHeaderMap
Mapping from the header name to the column number (to aid lookup) |
protected java.util.Vector<java.lang.String> |
columnNames
Column names |
protected java.util.Vector<Batch.Type> |
columnType
The type of *all* the variables in a column |
protected java.util.Vector<java.lang.String> |
imageFiles
list of file names of images in batch |
protected java.util.Vector<java.lang.Integer> |
imageFileStatus
status (if known) of the imageFile |
static java.lang.String |
imagesHeaderName
the name of the header containing the image file names |
static int |
invalid_status
The index has not status because it in not a valid index |
static int |
status_exists
The file exists and may be valid |
static int |
status_invalid
The file exists and is invalid |
static int |
status_unknown
The status of the file is unavailable |
protected java.util.Vector<java.lang.String> |
templateFiles
list of file names of templates for the faces in the imageFile list. |
protected java.util.Vector<java.lang.Integer> |
templateFileStatus
status (if known) of the templateFiles |
static java.lang.String |
templateHeaderName
the name of the header containing the image file names |
protected java.util.Vector<java.util.Vector<java.lang.Object>> |
variables
The variable data itself. |
Constructor Summary | |
---|---|
Batch()
Construct an empty Batch of images |
|
Batch(Batch other,
java.util.Vector<java.lang.Boolean> filter)
Copy a subset of the Batch defined by the filter |
|
Batch(java.io.File f)
|
Method Summary | |
---|---|
int |
addColumn(java.lang.String columnName,
Batch.Type columnType)
Add a new data column to the batch file |
void |
addMatrix(BigMat matrix,
int[] selectedColumns,
int[] selectedRows)
|
void |
addMatrix(BigMat matrix,
java.util.Vector<java.lang.String> headers,
int[] selectedRows,
boolean createColumns)
|
void |
addRecord(java.lang.String imageFile,
int imageStatus,
java.lang.String templateFile,
int templateStatus)
Add a record to the end of the Batch |
void |
addRecord(java.lang.String imageFile,
java.lang.String templateFile)
Add a record to the end of the Batch |
void |
addRecord(java.util.Vector<java.lang.Object> variables)
Add a row of variables as a record to th variable lable (assumed ordered) |
protected void |
calculateColumnTypes()
Traverse the data in the variables table to determine the type of the data |
java.lang.Object |
clone()
|
BigMat |
constructMatrix(boolean[] selectedColumns,
boolean[] selectedRows)
Construct a BigMat matrix from numerical data in the Batch file |
BigMat |
constructMatrix(boolean addImage,
boolean addTemplate,
int[] selectedColumns,
int[] selectedRows)
Construct a BigMat matrix from numerical data in the Batch file |
BigMat |
constructMatrix(int[] selectedColumns,
int[] selectedRows)
Construct a BigMat matrix from numerical data in the Batch file |
BigMat |
constructMatrix(java.util.Vector<java.lang.String> headers)
Construct a BigMat matrix from numerical data in the Batch file |
BigMat |
constructMatrix(java.util.Vector<java.lang.String> headers,
boolean[] selectedRows)
Construct a BigMat matrix from numerical data in the Batch file |
BigMat |
constructMatrix(java.util.Vector<java.lang.String> headers,
int[] selectedRows)
Construct a BigMat matrix from numerical data in the Batch file |
protected Batch.Type |
determineType(java.lang.String datum)
Attempt to determine the type of the data in the string |
protected java.util.Map<java.lang.String,java.lang.Integer> |
extractHeader(java.lang.String line)
Attempt to extract the column labels of a csv file returns null if any of the line entries is not a string (j.e) is a number |
protected java.lang.String |
extractInQuotes(java.lang.String text,
int offset)
|
protected int |
extractInteger(java.lang.String datum)
Attempt to extract an integer value from the string |
protected double |
extractNumber(java.lang.String datum)
Attempt to extract a floating point value from the string |
protected java.lang.String |
extractString(java.lang.String datum)
Will remove quotation marks from around a string or else simply return the string |
java.lang.Object |
get(int row,
int col)
Access the object at a particular row or column. |
java.lang.Object |
get(int row,
java.lang.String name)
Access the object at a particular row or column. |
java.lang.String |
getBaseDirectory()
|
java.lang.String |
getColumnHeader(int col)
Returns the name (if any) of the column |
java.lang.String[] |
getColumnHeaders()
|
java.util.Vector<java.lang.String> |
getColumnHeaders(Batch.Type type)
|
int |
getColumnIndex(java.lang.String name)
Returns the column index of the first column with a particular name |
java.lang.Object |
getColumnObject(int colNo)
Returns a 'null' or 'zero' filled object of the type required by this column |
int[] |
getColumnOfIntegers(int colNo)
Returns a vector of integers from a particular column. |
double[] |
getColumnOfNumbers(int colNo)
Returns a vector of doubles from a particular column. |
Batch.Type |
getColumnType(int colNo)
Return the type of data in a particular column |
java.io.File |
getImageFile(int index)
Returns an appropriate File object for the image names If the name begins with [drive letter]:\ then the path is not added otherwise it is. |
java.io.File |
getImageFile(java.lang.String name)
Returns an appropriate File object for the image names If the name begins with [drive letter]:\ then the path is not added otherwise it is. |
java.util.Iterator<java.lang.String> |
getImageFileIterator()
|
java.lang.String |
getImageFileName(int index)
Get the image file name at position index |
int |
getImageFileStatus(int index)
The status of the image file |
ImageIterator |
getImageIterator()
|
int |
getInteger(int row,
int col)
Get the data in a particular row and column as an integer value |
int |
getInteger(int row,
java.lang.String name)
Get the data in a particular row and column as an integer value |
int |
getNoColumns()
|
double |
getNumber(int row,
int col)
Get the data in a particular row and column as a double value |
double |
getNumber(int row,
java.lang.String name)
Get the data in a particular row and column as a double value |
java.lang.String |
getString(int row,
int col)
Get the data as a string, this is guaranteed to succeed, if any data exists at the specified location |
java.lang.String |
getString(int row,
java.lang.String name)
Get the data as a string, this is guaranteed to succeed, if any data exists at the specified location |
java.io.File |
getTemplateFile(int index)
Returns an appropriate File object for the image names If the name begins with [drive letter]:\ then the path is not added otherwise it is. |
java.util.Iterator<java.lang.String> |
getTemplateFileIterator()
|
java.lang.String |
getTemplateFileName(int index)
Get the template file name at position index |
int |
getTemplateFileStatus(int index)
The status of the template file |
TemplateIterator |
getTemplateIterator()
|
boolean |
hasColumn(java.lang.String name)
Returns true if the column is in the Batch file |
protected boolean |
isQuoted(java.lang.String testString)
|
void |
read(java.io.File f)
Read in a Batch file |
void |
readCSV(java.io.File f)
Read in data from a CSV file |
void |
readTXT(java.io.File f)
Read in a txt file batch file (old psychomorph-format) |
void |
removeColumn(int column)
remove a column from the batch file referenced by its index |
void |
removeRecord(int recordNumber)
remove a record including image and template components; |
void |
set(int row,
int col,
double value)
Put a particular value in the variable table |
void |
set(int row,
int col,
int value)
Put a particular value in the variable table |
void |
set(int row,
int col,
java.lang.Object value)
Put a particular value in the variable table |
void |
set(int row,
int col,
java.lang.String value)
Put a particular value in the variable table |
void |
setBaseDirectory(java.lang.String bd)
Set base directory |
void |
setColumn(int columnIndex,
double[] data)
Sets the values of the given column (index) with the values in the vector of doubles. |
void |
setImageFileName(int index,
java.lang.String name)
Change the image file name |
void |
setImageFileStatus(int index,
int status)
Set the status of the j^th image |
void |
setTemplateFileName(int index,
java.lang.String name)
Change the template file name |
void |
setTemplateFileStatus(int index,
int status)
Set the status of the j^th template |
int |
size()
|
void |
syncRecordLengths()
Make the lengths of the various vectors the same. |
void |
updateStatus()
|
void |
write(java.io.File f)
Write the batch to a file |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.String baseDirectory
protected java.util.Vector<java.lang.String> imageFiles
protected java.util.Vector<java.lang.String> templateFiles
protected java.util.Vector<java.lang.Integer> imageFileStatus
protected java.util.Vector<java.lang.Integer> templateFileStatus
public static final java.lang.String imagesHeaderName
public static final java.lang.String templateHeaderName
public static final int invalid_status
public static final int status_unknown
public static final int status_exists
public static final int status_invalid
public static java.awt.Color colour_unknown
public static java.awt.Color colour_exists
public static java.awt.Color colour_invalid
protected java.util.Vector<java.lang.String> columnNames
protected java.util.Map<java.lang.String,java.lang.Integer> columnHeaderMap
protected java.util.Vector<java.util.Vector<java.lang.Object>> variables
protected java.util.Vector<Batch.Type> columnType
Constructor Detail |
---|
public Batch()
public Batch(java.io.File f) throws java.io.IOException
java.io.IOException
public Batch(Batch other, java.util.Vector<java.lang.Boolean> filter)
other
- A Batch file to take a subset offilter
- Filter to apply to the other Batch file, on entries marked
true are copied.Method Detail |
---|
public java.lang.Object clone()
clone
in class java.lang.Object
public int size()
public java.lang.String getImageFileName(int index)
index
- record number
public java.io.File getImageFile(int index)
index
- record number
public java.io.File getImageFile(java.lang.String name)
name
- name of the file to process
public void setImageFileName(int index, java.lang.String name)
index
- recordname
- new namepublic java.lang.String getTemplateFileName(int index)
index
- record number
public java.io.File getTemplateFile(int index)
index
- record number
public void setTemplateFileName(int index, java.lang.String name)
index
- recordname
- new namepublic int getImageFileStatus(int index)
index
- record number
public void setImageFileStatus(int index, int status)
index
- record numberstatus
- record statuspublic int getTemplateFileStatus(int index)
index
- record number
public void setTemplateFileStatus(int index, int status)
index
- record numberstatus
- record statuspublic void setBaseDirectory(java.lang.String bd)
bd
- public java.lang.String getBaseDirectory()
public void addRecord(java.lang.String imageFile, java.lang.String templateFile)
imageFile
- filename of the image to addtemplateFile
- filename of the template to addpublic void addRecord(java.util.Vector<java.lang.Object> variables)
variables
- an (ordered) list of variables to add to the tablepublic int addColumn(java.lang.String columnName, Batch.Type columnType)
columnName
- The name to give the added columncolumnType
- the type of the data in the column
public void removeColumn(int column)
column
- index of column to remove
Batch.BatchFileException
public void removeRecord(int recordNumber)
recordNumber
- public void addRecord(java.lang.String imageFile, int imageStatus, java.lang.String templateFile, int templateStatus)
imageFile
- filename of the image to addimageStatus
- status of the filetemplateFile
- filename of the template to addtemplateStatus
- status of the templatepublic java.lang.String[] getColumnHeaders()
public java.util.Vector<java.lang.String> getColumnHeaders(Batch.Type type)
public java.lang.String getColumnHeader(int col)
col
- the column number
public int getColumnIndex(java.lang.String name)
name
- the name of header (as specified in the first row of the CSV
file)
public Batch.Type getColumnType(int colNo)
colNo
- the column return type information about
public java.lang.Object getColumnObject(int colNo)
colNo
- The column to query
public int getNoColumns()
public double[] getColumnOfNumbers(int colNo)
colNo
- the column to vectorise
public int[] getColumnOfIntegers(int colNo)
colNo
- the column to vectorise
public void setColumn(int columnIndex, double[] data)
columnIndex
- index of the column to setdata
- vector of numbers to fill the column withpublic boolean hasColumn(java.lang.String name)
name
- name of the column to search for
public void syncRecordLengths()
public java.lang.Object get(int row, int col)
row
- the record number of the datum to accesscol
- the column containing the datum
public int getInteger(int row, int col)
row
- the record number to accesscol
- the colum containing the data
public double getNumber(int row, int col)
row
- the record number to accesscol
- the colum containing the data
public java.lang.String getString(int row, int col)
row
- the record numbercol
- the column containing the data
public java.lang.Object get(int row, java.lang.String name)
row
- the record number of the datum to accesscol
- the column containing the datum
public int getInteger(int row, java.lang.String name)
row
- the record number to accesscol
- the colum containing the data
public double getNumber(int row, java.lang.String name)
row
- the record number to accesscol
- the colum containing the data
public java.lang.String getString(int row, java.lang.String name)
row
- the record numbercol
- the column containing the data
public void set(int row, int col, java.lang.Object value)
row
- the record number to altercol
- the column containing the datavalue
- the data to setpublic void set(int row, int col, int value)
row
- the record number to altercol
- the column containing the datavalue
- the data to setpublic void set(int row, int col, double value)
row
- the record number to altercol
- the column containing the datavalue
- the data to setpublic void set(int row, int col, java.lang.String value)
row
- the record number to altercol
- the column containing the datavalue
- the data to setpublic java.util.Iterator<java.lang.String> getImageFileIterator()
public ImageIterator getImageIterator()
public java.util.Iterator<java.lang.String> getTemplateFileIterator()
public TemplateIterator getTemplateIterator()
public void read(java.io.File f) throws java.io.IOException
java.io.IOException
public void readCSV(java.io.File f) throws java.io.IOException
f
- file to read
java.io.IOException
protected java.util.Map<java.lang.String,java.lang.Integer> extractHeader(java.lang.String line)
line
- Line to read in
protected Batch.Type determineType(java.lang.String datum)
datum
- The data in string form
protected java.lang.String extractString(java.lang.String datum)
datum
- A string to extract the string from
protected int extractInteger(java.lang.String datum)
datum
- string containing the number
protected double extractNumber(java.lang.String datum)
protected void calculateColumnTypes()
protected boolean isQuoted(java.lang.String testString)
protected java.lang.String extractInQuotes(java.lang.String text, int offset)
public void readTXT(java.io.File f) throws java.io.IOException
java.io.IOException
public void write(java.io.File f) throws java.io.IOException
f
- file to write to
java.io.IOException
public void updateStatus()
public BigMat constructMatrix(java.util.Vector<java.lang.String> headers)
headers
- a selected of (named) headers to take columns from.
(ordered)
public BigMat constructMatrix(java.util.Vector<java.lang.String> headers, boolean[] selectedRows)
headers
- a selected of (named) headers to take columns from.
(ordered)selectedRows
- (optional) a filter over the records (rows) to choose
a subset from which to build the BigMat
public BigMat constructMatrix(java.util.Vector<java.lang.String> headers, int[] selectedRows)
headers
- a selected of (named) headers to take columns from.
(ordered)selectedRows
- (optional) an index over the records (rows) to choose
a subset from which to build the BigMat
public BigMat constructMatrix(boolean[] selectedColumns, boolean[] selectedRows)
headers
- a filter over the columnsselectedRows
- (optional) a filter over the records (rows) to choose
a subset from which to build the BigMat
public BigMat constructMatrix(int[] selectedColumns, int[] selectedRows)
headers
- (optional) an index over the columnsselectedRows
- (optional) an index over the records (rows) to choose
a subset from which to build the BigMat
public BigMat constructMatrix(boolean addImage, boolean addTemplate, int[] selectedColumns, int[] selectedRows)
headers
- (optional) an index over the columnsselectedRows
- (optional) an index over the records (rows) to choose
a subset from which to build the BigMat
public void addMatrix(BigMat matrix, java.util.Vector<java.lang.String> headers, int[] selectedRows, boolean createColumns)
public void addMatrix(BigMat matrix, int[] selectedColumns, int[] selectedRows)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |