jhplot
Class P2D
- java.lang.Object
-
- jhplot.Plottable
-
- jhplot.P2D
-
- All Implemented Interfaces:
- java.io.Serializable
public class P2D extends Plottable implements java.io.Serializable
A container to hold data points in X,Y,Z. Should be used to plot data in 3D. This is a high-performance array implementation.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description P2D()
Construct an empty containerP2D(java.lang.String title)
Construct an empty container with a titleP2D(java.lang.String title, java.lang.String sfile)
Construct a P2D from a file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description void
add(double x, double y, double z)
Adds values of a plot-point pair (X,Y,Z).void
clear()
Clear the containerP2D
copy()
Get a copy of the current holderP2D
copy(java.lang.String newtitle)
create an exact of the current holdervoid
doc()
Show online documentation.void
fill(double[] xa, double[] ya, double[] za)
Fill a P2D container from 3 arrays.double[]
getArrayX()
Get array representing X-valuesdouble[]
getArrayY()
Get array representing Y-valuesdouble[]
getArrayZ()
Get array representing Z-valuesjplot.DataArray2D
getDataArray()
Return a DataArray2D container.double
getMax(int axis)
Returns the maximum value in the range.double
getMin(int axis)
Returns the minimum value in the range.java.awt.Color
getSymbolColor()
Get color attributeint
getSymbolSize()
Get size of the symbolsdouble
getX(int i)
Return a specific X-value.double
getY(int i)
Return a specific Y-value.double
getZ(int i)
Return a specific Z-value.double
mean(int axis)
Returns the mean value for any axisdouble
meanX()
Returns the mean value in X.double
meanY()
Returns the mean value in Y.double
meanZ()
Returns the mean value in Z.P2D
merge(P2D a)
Merge two P2D containersint
read(java.io.BufferedReader br)
Read P2D from a file.int
read(java.io.File sfile)
Read P2D from a file.int
read(java.lang.String sfile)
Read P2D from a file.int
read(java.net.URL url)
Read data from URL.int
readGZip(java.lang.String sfile)
Read P2D from a GZiped file.P2D
readSerialized(java.lang.String name)
Read a P2D object from a serialized fileint
readZip(java.lang.String sfile)
Read P1D from a Zipped file.void
set(int i, double x, double y, double z)
Sets the values of (x,y,z).void
setDataArray(jplot.DataArray2D data)
Set data in a form of DataArrayvoid
setDoubleArrayLists(DoubleArrayList dataX2, DoubleArrayList dataY2, DoubleArrayList dataZ2)
Set the array from DoubleArrayListsvoid
setSymbolColor(java.awt.Color c)
Sets symbol colorvoid
setSymbolSize(int s)
Sets the symbol sizeint
size()
Return the length of the data vector.void
toFile(java.lang.String name)
Write a P2D to an external file.java.lang.String
toString()
Convert to a stringvoid
toTable()
Print the P2D container to a Table in a separate Frame.int
writeSerialized(java.lang.String name)
Write a object to a serialized file
-
-
-
Constructor Detail
-
P2D
public P2D()
Construct an empty container
-
P2D
public P2D(java.lang.String title)
Construct an empty container with a title- Parameters:
title
- New title
-
P2D
public P2D(java.lang.String title, java.lang.String sfile)
Construct a P2D from a file. Data should be separated by space in 3 columns.- Parameters:
title
- Title of the containersfile
- File name with input. It can be either a file on a file system or URL location (must start from http or ftp)
-
-
Method Detail
-
getSymbolColor
public java.awt.Color getSymbolColor()
Get color attribute- Returns:
- Color
-
setSymbolColor
public void setSymbolColor(java.awt.Color c)
Sets symbol color- Parameters:
c
- Color
-
getSymbolSize
public int getSymbolSize()
Get size of the symbols- Returns:
- size of the symbols
-
read
public int read(java.io.BufferedReader br)
Read P2D from a file. The old content will be lost. The file should contain 3 columns: x,y,z. Comment lines starting with "#" and "*" are ignored.- Parameters:
br
- Input buffered reader- Returns:
- zero if success
-
read
public int read(java.io.File sfile)
Read P2D from a file. The old content will be lost. Use a space to separate values in columns and tab to put new row. Comment lines starting with "#" and "*" are ignored.- Parameters:
sfile
- input file- Returns:
- zero if success
-
read
public int read(java.net.URL url)
Read data from URL. Use a space to separate values in columns and tab to put new row.- Parameters:
url
- URL location of input file
-
read
public int read(java.lang.String sfile)
Read P2D from a file. It can read URL if the string starts from http or ftp, otherwise a file on the file system is assumed.The old content will be lost. Use a space to separate values in columns and tab to put new row. Comment lines starting with "#" and "*" are ignored.
- Parameters:
sfile
- File name with input- Returns:
- zero if success
-
readGZip
public int readGZip(java.lang.String sfile)
Read P2D from a GZiped file. It can read URL if the string starts from http or ftp, otherwise a file on the file system is assumed.Use a space to separate values in columns and tab to put new row.
- Parameters:
sfile
- File name with input (extension .gz)- Returns:
- zero if success
-
readZip
public int readZip(java.lang.String sfile)
Read P1D from a Zipped file. The old content will be lost. The file should contain 2, or 4, or 6, or 10 columns: 1) x,y: data without any errors 2) x,y, y(upper), y(lower) - data with 1st level errors on Y 3) x,y, x(left), x(right), y(upper), y(lower) - data with 1st level errors on X and Y 4) x,y, x(left), x(right), y(upper), y(lower), x(leftSys), x(rightSys), y(upperSys), y(lowerSys) - data with X and Y and 1st and 2nd level errors- Parameters:
sfile
- File name with input (extension zip)- Returns:
- zero if success
-
setSymbolSize
public void setSymbolSize(int s)
Sets the symbol size- Parameters:
s
- symbol size
-
toFile
public void toFile(java.lang.String name)
Write a P2D to an external file.- Parameters:
name
- File name with output
-
merge
public P2D merge(P2D a)
Merge two P2D containers- Parameters:
a
- Container to be added- Returns:
- New P2D container
-
setDataArray
public void setDataArray(jplot.DataArray2D data)
Set data in a form of DataArray- Parameters:
data
- input data
-
getDataArray
public jplot.DataArray2D getDataArray()
Return a DataArray2D container.- Returns:
- Container of type DataArray
-
add
public void add(double x, double y, double z)
Adds values of a plot-point pair (X,Y,Z).- Parameters:
x
- X-value of the plot-pointy
- Y-value of the plot-pointz
- Z-value of the plot-point
-
fill
public void fill(double[] xa, double[] ya, double[] za)
Fill a P2D container from 3 arrays. If it is not empty, add values will be appended. It is assumed that all errors are zero.- Parameters:
xa
- array with X valuesya
- array with Y valuesza
- array with Z values
-
set
public void set(int i, double x, double y, double z)
Sets the values of (x,y,z).- Parameters:
i
- index of the plot-pointx
- x-value of the plot-pointy
- y-value of the plot-pointz
- z-value of the plot-point
-
size
public int size()
Return the length of the data vector.- Returns:
- length of the PlotPoint vector
-
copy
public P2D copy()
Get a copy of the current holder
-
toString
public java.lang.String toString()
Convert to a string- Overrides:
toString
in classjava.lang.Object
- Returns:
- String representing the data
-
copy
public P2D copy(java.lang.String newtitle)
create an exact of the current holder- Parameters:
newtitle
- new title
-
setDoubleArrayLists
public void setDoubleArrayLists(DoubleArrayList dataX2, DoubleArrayList dataY2, DoubleArrayList dataZ2)
Set the array from DoubleArrayLists- Parameters:
dataX2
- input XdataY2
- input YdataZ2
- input Z
-
getArrayX
public double[] getArrayX()
Get array representing X-values- Returns:
- array with X values
-
writeSerialized
public int writeSerialized(java.lang.String name)
Write a object to a serialized file- Parameters:
name
- serialized file name for output.- Returns:
- zero if no errors
-
readSerialized
public P2D readSerialized(java.lang.String name)
Read a P2D object from a serialized file- Parameters:
name
- serialized file name for input.- Returns:
- new P2D object
-
getArrayY
public double[] getArrayY()
Get array representing Y-values- Returns:
- array with Y values
-
getArrayZ
public double[] getArrayZ()
Get array representing Z-values- Returns:
- array with Y values
-
getX
public double getX(int i)
Return a specific X-value. This function returns POSINF (1e300) if index i falls beyond the valid range.- Parameters:
i
- index of the array- Returns:
- the value of x at index i
-
getY
public double getY(int i)
Return a specific Y-value. This function returns POSINF (1e300) if index i falls beyond the valid range.- Parameters:
i
- index of the array- Returns:
- the value of y at index i
-
getZ
public double getZ(int i)
Return a specific Z-value. This function returns POSINF (1e300) if index i falls beyond the valid range.- Parameters:
i
- index of the array- Returns:
- the value of z at index i
-
getMax
public double getMax(int axis)
Returns the maximum value in the range.- Parameters:
axis
- defines to which axis this function applies. axis=0 - X, axis=1 - Y, axis=2 - Z,- Returns:
- the maximum value.
-
getMin
public double getMin(int axis)
Returns the minimum value in the range. axis=0 - X, axis=1 - Y, axis=2 - Z.- Parameters:
axis
- defines to which axis this function applies.- Returns:
- the minimum value.
-
meanX
public double meanX()
Returns the mean value in X.- Returns:
- Mean value in X
-
meanY
public double meanY()
Returns the mean value in Y.- Returns:
- Mean value in Y
-
meanZ
public double meanZ()
Returns the mean value in Z.- Returns:
- Mean value in Y
-
mean
public double mean(int axis)
Returns the mean value for any axis- Parameters:
axis
- axis (0,1,2)- Returns:
- Mean value for axis (0,1,2)
-
clear
public void clear()
Clear the container
-
toTable
public void toTable()
Print the P2D container to a Table in a separate Frame. The numbers are formatted to scientific format. One can sort and search the data in this table (but not modify)
-
doc
public void doc()
Show online documentation.
-
-
DMelt 3.0 © DataMelt by jWork.ORG