public class PlotParser extends SwingWorker<Vector<Vector<String>>,Void>
PlotSelectionFrame.
Furthermore, this class can be used for extracting specified data (header,
unit: e.g. extractColumn(int column), extractData(Vector<Integer>
vecRows, Vector<Integer> vecCols)) from given data
(setData(Vector<Vector<Double>> data))SwingWorker.StateValue| Modifier and Type | Field and Description |
|---|---|
private BufferedReader |
buf |
private Vector<Vector<String>> |
dataString |
private Vector<Vector<Double>> |
dataValues |
private File |
file |
private FileInputStream |
fin |
private String[] |
headers |
private static org.apache.log4j.Logger |
logger |
private int |
numColumns |
private int |
numRows |
private String[] |
units |
| Constructor and Description |
|---|
PlotParser()
Default constructor.
|
PlotParser(File file)
Constructs a plot parser for a given file.
|
| Modifier and Type | Method and Description |
|---|---|
protected Vector<Vector<String>> |
doInBackground() |
protected void |
done() |
Vector<Double> |
extractColumn(int column) |
Vector<Vector<Double>> |
extractData(Vector<Integer> vecRows,
Vector<Integer> vecCols) |
String |
extractHeader(int col) |
String[] |
extractHeaders(Vector<Integer> vecCols) |
String |
extractUnit(int col) |
String[] |
extractUnits(Vector<Integer> vecCols) |
Vector<Vector<Double>> |
getData() |
Vector<Vector<String>> |
getDataString() |
String[] |
getHeaders() |
Vector<String> |
getRowFromDataString(int row) |
String[] |
getUnits() |
Vector<Vector<String>> |
parseContent()
|
void |
setData(Vector<Vector<Double>> data) |
void |
setDataString(Vector<Vector<String>> data) |
void |
setFile(File file)
Sets the file to be parsed.
|
void |
setHeaders(int row) |
void |
setHeaders(String[] headers) |
void |
setUnits(int row) |
void |
setUnits(String[] units) |
addPropertyChangeListener, cancel, execute, firePropertyChange, get, get, getProgress, getPropertyChangeSupport, getState, isCancelled, isDone, process, publish, removePropertyChangeListener, run, setProgressprivate static final org.apache.log4j.Logger logger
private File file
private int numColumns
private int numRows
private FileInputStream fin
private BufferedReader buf
private String[] headers
private String[] units
public PlotParser()
public PlotParser(File file)
file - an ASCII encoded plain text filepublic void setFile(File file)
file - the file to be parsedpublic void setHeaders(String[] headers)
headers - String[]public String[] getHeaders()
public void setUnits(String[] units)
units - String[]public String[] getUnits()
public void setDataString(Vector<Vector<String>> data)
data - Vector<Vector<String>>public Vector<Vector<String>> getDataString()
public void setHeaders(int row)
throws ArrayIndexOutOfBoundsException
row - (int) from which to set the headers String[]ArrayIndexOutOfBoundsExceptionpublic void setUnits(int row)
row - (int) from which to set the units String[]public Vector<String> getRowFromDataString(int row)
public Vector<Vector<String>> parseContent()
Vector<
Vector<String>>. In the end, pass the parsed
content on to the PlotSelectionFrame instance in order to enable
the user to choose the data.public Vector<Double> extractColumn(int column)
public Vector<Vector<Double>> extractData(Vector<Integer> vecRows, Vector<Integer> vecCols) throws NumberFormatException
vecRows - the vector of row indicesvecCols - the vector of column indicesNumberFormatExceptionpublic String[] extractHeaders(Vector<Integer> vecCols)
public String[] extractUnits(Vector<Integer> vecCols)
public String extractHeader(int col)
public String extractUnit(int col)
protected Vector<Vector<String>> doInBackground() throws Exception
doInBackground in class SwingWorker<Vector<Vector<String>>,Void>ExceptionCopyright © 2009–2017 Helmut Ahammer, Philipp Kainz. All rights reserved.