jhplot
Class P2D

java.lang.Object
  extended by jhplot.P2D
All Implemented Interfaces:
Serializable

public class P2D
extends Object
implements Serializable

A container to hold data points in X,Y,Z.

See Also:
Serialized Form

Constructor Summary
P2D()
          Construct an empty container with a title
P2D(String title)
          Construct an empty container with a title
P2D(String title, String sfile)
          Construct a P2D from a file.
 
Method Summary
 void add(double x, double y, double z)
          Adds values of a plot-point pair (X,Y,Z).
 void clear()
          Clear the container
 P2D copy()
          Get a copy of the current holder
 P2D copy(String newtitle)
          create an exact of the current holder
 void 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-values
 double[] getArrayY()
          Get array representing Y-values
 double[] getArrayZ()
          Get array representing Z-values
 jplot.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.
 Color getSymbolColor()
          Get color attribute
 int getSymbolSize()
          Get size of the symbols
 String getTitle()
          Get a new title
 double 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 axis
 double 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 containers
 void print()
          Print a P2D container on the screen
 int read(BufferedReader br)
          Read P2D from a file.
 int read(File sfile)
          Read P2D from a file.
 int read(String sfile)
          Read P2D from a file.
 int read(URL url)
          Read data from URL.
 int readGZip(String sfile)
          Read P2D from a GZiped file.
 P2D readSerialized(String name)
          Read a P2D object from a serialized file
 int readZip(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 DataArray
 void setSymbolColor(Color c)
          Sets symbol color
 void setSymbolSize(int s)
          Sets the symbol size
 void setTitle(String title)
          Set a new title
 int size()
          Return the length of the data vector.
 void toFile(String name)
          Write a P2D to an external file.
 String toString()
          Convert to a string
 void toTable()
          Print the P2D container to a Table in a separate Frame.
 void toTable(boolean format)
          Print the P2D container to a Table in a separate Frame.
 int writeSerialized(String name)
          Write a P0D object to a serialized file
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

P2D

public P2D(String title)
Construct an empty container with a title

Parameters:
title - New title

P2D

public P2D()
Construct an empty container with a title


P2D

public P2D(String title,
           String sfile)
Construct a P2D from a file. Data should be separated by space in 3 columns.

Parameters:
title - Title of the container
sfile - 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

setTitle

public void setTitle(String title)
Set a new title

Parameters:
title - New Title

getTitle

public String getTitle()
Get a new title

Returns:
Title

getSymbolColor

public Color getSymbolColor()
Get color attribute

Returns:
Color

setSymbolColor

public void setSymbolColor(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(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(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(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(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(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(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(String name)
Write a P2D to an external file.

Parameters:
name - File name with output

print

public void print()
Print a P2D container on the screen


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-point
y - Y-value of the plot-point
z - 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 values
ya - array with Y values
za - 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-point
x - x-value of the plot-point
y - y-value of the plot-point
z - 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 String toString()
Convert to a string

Overrides:
toString in class Object
Returns:
String representing P1D

copy

public P2D copy(String newtitle)
create an exact of the current holder

Parameters:
newtitle - new title

getArrayX

public double[] getArrayX()
Get array representing X-values

Returns:
array with X values

writeSerialized

public int writeSerialized(String name)
Write a P0D object to a serialized file

Parameters:
name - serialized file name for output.
Returns:
zero if no errors

readSerialized

public P2D readSerialized(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)


toTable

public void toTable(boolean format)
Print the P2D container to a Table in a separate Frame. One can sort and search the data in this table (but not modify)

Parameters:
format - if false, numbers will not be formatted to scientific format ##.#####E00

doc

public void doc()
Show online documentation.



jHepWork 3.1 ©