Package org.opensourcephysics.display
Class DataFile
java.lang.Object
org.opensourcephysics.display.DataAdapter
org.opensourcephysics.display.DataFile
- All Implemented Interfaces:
Data
-
Field Summary
FieldsFields inherited from class org.opensourcephysics.display.DataAdapter
colNames, data, ID, name
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSome objects (eg, a Group) do not contain data, but a list of Data objects that do.protected static double[]
getRowArray
(int rowCount) Returns an array of row numbers.void
Opens an xml or data file specified by name.double[][]
Parses character-delimited data from a string.protected static double[]
parseDoubles
(String[] strings) Parses a String array into doubles.protected static double[][]
parseDoubles
(String text, String rowDelimiter, String colDelimiter) Parses a String into doubles separated by specified row and column delimiters.protected static String[]
parseStrings
(String text, String delimiter) Parses a String into tokens separated by a specified delimiter.protected static String[][]
parseStrings
(String text, String rowDelimiter, String colDelimiter) Parses a String into tokens separated by specified row and column delimiters.protected String
readFirstLine
(Reader in) Methods inherited from class org.opensourcephysics.display.DataAdapter
getColumnNames, getData2D, getData3D, getDatasets, getFillColors, getID, getLineColors, getName, setColumnNames, setID, setName
-
Field Details
-
delimiters
-
-
Constructor Details
-
DataFile
Creates a DataFile using data in the given file.- Parameters:
fileName
-
-
-
Method Details
-
getDataList
Some objects (eg, a Group) do not contain data, but a list of Data objects that do. This method is used by Data displaying tools to create as many pages as needed.- Specified by:
getDataList
in interfaceData
- Overrides:
getDataList
in classDataAdapter
- Returns:
- a list of Data objects, or null if this object contains data
-
open
Opens an xml or data file specified by name.- Parameters:
fileName
- the file name
-
parseData
Parses character-delimited data from a string. This attempts to extract the following information from the string: 1. A title to be used for the tab name 2. One or more columns of double data values 3. Column names for the data columns- Parameters:
dataString
- the data stringfileName
- name of file containing the data string (may be null)- Returns:
- DatasetManager with parsed data, or null if none found
-
readFirstLine
-
parseStrings
Parses a String into tokens separated by a specified delimiter. A token may be "".- Parameters:
text
- the text to parsedelimiter
- the delimiter- Returns:
- an array of String tokens
-
parseStrings
Parses a String into tokens separated by specified row and column delimiters.- Parameters:
text
- the text to parserowDelimiter
- the column delimitercolDelimiter
- the column delimiter- Returns:
- a 2D array of String tokens
-
parseDoubles
Parses a String array into doubles. Unparsable strings are set to Double.NaN.- Parameters:
strings
- the String array to parse- Returns:
- an array of doubles
-
parseDoubles
Parses a String into doubles separated by specified row and column delimiters.- Parameters:
text
- the text to parserowDelimiter
- the column delimitercolDelimiter
- the column delimiter- Returns:
- a 2D array of doubles
-
getRowArray
protected static double[] getRowArray(int rowCount) Returns an array of row numbers.- Parameters:
rowCount
- length of the array- Returns:
- the array
-