com.panayotis.gnuplot
Class GNUPlot

java.lang.Object
  extended by com.panayotis.gnuplot.GNUPlot
Direct Known Subclasses:
JavaPlot

public class GNUPlot
extends java.lang.Object

This is the main class of JavaPlot. It is the cental point to create a gnuplot. Typically the user needs to create a new instance of this object and add the desired plots.

It also provides some convinient methods in order to set various parameters.

This object is not serializable, use GNUPlotParameters instead.

See Also:
JavaPlot, addPlot(Plot)

Constructor Summary
GNUPlot()
          Create a new instance of gnuplot, using the default parameters
GNUPlot(boolean isGraph3D)
          Create a new instance of gnuplot, using the default parameters.
GNUPlot(GNUPlotParameters par)
          Create a new instance of gnuplot, with a given set of parameters.
GNUPlot(GNUPlotParameters par, java.lang.String gnuplotpath, GNUPlotTerminal term)
          Create a new instance of gnuplot, with given parameters and given path for gnuplot.
GNUPlot(GNUPlotParameters par, java.lang.String gnuplotpath, GNUPlotTerminal term, boolean isGraph3D)
          Create a new instance of gnuplot, with given parameters and given path for gnuplot.
GNUPlot(java.lang.String gnuplotpath)
          Create a new instance of gnuplot, with a given path for gnuplot.
GNUPlot(java.lang.String gnuplotpath, boolean isGraph3D)
          Create a new instance of gnuplot, with a given path for gnuplot.
 
Method Summary
 void addGraph(Graph gr)
          Add a defined graph to this GNUPlot object.
 void addPlot(Plot plot)
          Add a new Plot
 Axis getAxis(java.lang.String axisname)
          Use this method to get a reference to the plot axis, in order to set various parameters.
 java.lang.String getCommands()
          Retrieves the command which will actually send to gnuplot, if we perform a plot with the already defined parameters to the selected terminal.
static Debug getDebugger()
          Get the specific GNUPlot Debug object
 java.lang.String getGNUPlotPath()
          Retrieve the file path of gnuplot
 GraphLayout getLayout()
          Get the current layout of this plot object
 Page getPage()
          Get a Page containing all Graphs.
 GNUPlotParameters getParameters()
          Ge the actual gnuplot parameters.
 java.util.ArrayList<Plot> getPlots()
          Get a list of the (default) plots used in this set.
 java.util.ArrayList<java.lang.String> getPostInit()
          Execute gnuplot commands before any kind of initialization.
 java.util.ArrayList<java.lang.String> getPreInit()
          Execute gnuplot commands before any kind of initialization.
 GNUPlotTerminal getTerminal()
          Get the current used terminal
 void newGraph()
          Add a new Graph object.
 void newGraph3D()
          Add a new Graph3D object.
 void plot()
          Perform the actual action of plotting.
 void set(java.lang.String key, java.lang.String value)
          Set various GNUPlot parameters.
 void setGNUPlotPath(java.lang.String path)
          Set the desired path for gnuplot executable.
 void setMultiTitle(java.lang.String title)
          Set the title of all graph objects, in multiplot environment.
 void setParameters(GNUPlotParameters parameters)
          Set gnuplot parameters to another set of parameters.
 void setPersist(boolean ispersist)
          Set all terminals to be persistent.
 void setTerminal(GNUPlotTerminal term)
          Change gnuplot terminal.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GNUPlot

public GNUPlot()
        throws GNUPlotException
Create a new instance of gnuplot, using the default parameters

Throws:
GNUPlotException - If the gnuplot executable is not found, this exception is thrown. Typically at this case there is need to use a constructor which defines the gnuplot path.
See Also:
GNUPlot(String), GNUPlot(GNUPlotParameters,String,GNUPlotTerminal,boolean)

GNUPlot

public GNUPlot(boolean isGraph3D)
        throws GNUPlotException
Create a new instance of gnuplot, using the default parameters. Use this method if you want to specifically define that the default plot is Graph3D

Parameters:
isGraph3D - true if the default plot is Graph3D
Throws:
GNUPlotException - If the gnuplot executable is not found, this exception is thrown. Typically at this case there is need to use a constructor which defines the gnuplot path.
See Also:
GNUPlot(String), GNUPlot(GNUPlotParameters,String,GNUPlotTerminal,boolean)

GNUPlot

public GNUPlot(GNUPlotParameters par)
        throws GNUPlotException
Create a new instance of gnuplot, with a given set of parameters.

Parameters:
par - Use this set of parameters, instead of a default one.
Throws:
GNUPlotException - If the gnuplot executable is not found, this exception is thrown. Typically at this case there is need to use a constructor which defines the gnuplot path.
See Also:
GNUPlot(String), GNUPlot(GNUPlotParameters,String,GNUPlotTerminal,boolean)

GNUPlot

public GNUPlot(java.lang.String gnuplotpath)
        throws GNUPlotException
Create a new instance of gnuplot, with a given path for gnuplot. This constructor is useful if the automatic path search for gnuplot is not fruitful, or the user wants to point to a specific gnuplot executable.

Parameters:
gnuplotpath - The pathname of the gnuplot executable. If this parameter is set to null, use the default path.
Throws:
GNUPlotException - If the gnuplot executable is not found, this exception is thrown. It means that the provided path for gnuplot is not valid.

GNUPlot

public GNUPlot(java.lang.String gnuplotpath,
               boolean isGraph3D)
        throws GNUPlotException
Create a new instance of gnuplot, with a given path for gnuplot. This constructor is useful if the automatic path search for gnuplot is not fruitful, or the user wants to point to a specific gnuplot executable.

Parameters:
gnuplotpath - The pathname of the gnuplot executable. If this parameter is set to null, use the default path.
isGraph3D - true if the default plot is Graph3D
Throws:
GNUPlotException - If the gnuplot executable is not found, this exception is thrown. It means that the provided path for gnuplot is not valid.

GNUPlot

public GNUPlot(GNUPlotParameters par,
               java.lang.String gnuplotpath,
               GNUPlotTerminal term)
        throws GNUPlotException
Create a new instance of gnuplot, with given parameters and given path for gnuplot.

This constructor is useful if the user wants to fine tune eny aspect of GNUPlot object, and especially if there is need to define a priori the output terminal.

Any parameters set to null, produce the default parameters.

Parameters:
par - GNUPlot parameters to use. These parameters encapsulate the whole gnuplot variables, including data sets.
gnuplotpath - The pathname of the gnuplot executable. If this parameter is set to null, use the default path.
term - The gnuplot terminal to use
Throws:
GNUPlotException - If the gnuplot executable is not found, this exception is thrown. It means that the provided path for gnuplot is not valid.

GNUPlot

public GNUPlot(GNUPlotParameters par,
               java.lang.String gnuplotpath,
               GNUPlotTerminal term,
               boolean isGraph3D)
        throws GNUPlotException
Create a new instance of gnuplot, with given parameters and given path for gnuplot.

This constructor is useful if the user wants to fine tune eny aspect of GNUPlot object, and especially if there is need to define a priori the output terminal.

Any parameters set to null, produce the default parameters.

Parameters:
par - GNUPlot parameters to use. These parameters encapsulate the whole gnuplot variables, including data sets.
gnuplotpath - The pathname of the gnuplot executable. If this parameter is set to null, use the default path.
term - The gnuplot terminal to use
isGraph3D - true, if this is a Graph3D object
Throws:
GNUPlotException - If the gnuplot executable is not found, this exception is thrown. It means that the provided path for gnuplot is not valid.
Method Detail

set

public void set(java.lang.String key,
                java.lang.String value)
Set various GNUPlot parameters. All parameters added here will be used in the form of "set key value"

Parameters:
key - The key to use for this gnuplot
value - The value of this key

getAxis

public Axis getAxis(java.lang.String axisname)
Use this method to get a reference to the plot axis, in order to set various parameters.

Parameters:
axisname - The name of the axis. This typically is "x", "y", "z".
Returns:
The requested Axis, or null if axis is not found

addPlot

public void addPlot(Plot plot)
Add a new Plot

Parameters:
plot - The plot to add to the list of plots.
See Also:
Plot

addGraph

public void addGraph(Graph gr)
Add a defined graph to this GNUPlot object.

Parameters:
gr - Graph object to be added
See Also:
newGraph()

newGraph

public void newGraph()
Add a new Graph object. This method is used to create a multiplot graph. Every "plot" command corresponds to a different Graph object. In order to draw to a new plot gnuplot object, create a new page.

See Also:
newGraph3D()

newGraph3D

public void newGraph3D()
Add a new Graph3D object. This method is used to create a multiplot graph. Every "splot" command corresponds to a different Graph object. In order to draw to a new plot gnuplot object, create a new page.

See Also:
newGraph()

setMultiTitle

public void setMultiTitle(java.lang.String title)
Set the title of all graph objects, in multiplot environment.

Parameters:
title - The title to use

getPlots

public java.util.ArrayList<Plot> getPlots()
Get a list of the (default) plots used in this set. This method is a way to enumerate the plots already inserted, epspecially if a plot is added on the fly.

Returns:
An array of stored plots.

getPage

public Page getPage()
Get a Page containing all Graphs. This method is used for example in order to get a list of graphs already inserted, especially if a graph is automatically added

Returns:
An array of stored Graphs

getLayout

public GraphLayout getLayout()
Get the current layout of this plot object

Returns:
The used layout

plot

public void plot()
          throws GNUPlotException
Perform the actual action of plotting. Use the current parameters and terminal, and perform a plot. If an error occured, an exception is thrown

Throws:
GNUPlotException - This exception is thrown if an error occured. Use the Debug object to dump information about this error.

getCommands

public java.lang.String getCommands()
Retrieves the command which will actually send to gnuplot, if we perform a plot with the already defined parameters to the selected terminal.
This method is used for debugging purposes.

Returns:
The commands to send to the gnuplot executable

setGNUPlotPath

public void setGNUPlotPath(java.lang.String path)
                    throws java.io.IOException
Set the desired path for gnuplot executable.

Parameters:
path - Filename of gnuplot executable
Throws:
java.io.IOException - gnuplot is not found, or not valid

getGNUPlotPath

public java.lang.String getGNUPlotPath()
Retrieve the file path of gnuplot

Returns:
The gnuplot file path

setPersist

public void setPersist(boolean ispersist)
Set all terminals to be persistent. Thus, after executing plot command, the graph window stays open and does not disappear automatically.

Parameters:
ispersist - whether the terminal window should be persistent

setParameters

public void setParameters(GNUPlotParameters parameters)
Set gnuplot parameters to another set of parameters.

Parameters:
parameters - The new GNUPlot parameters.

getParameters

public GNUPlotParameters getParameters()
Ge the actual gnuplot parameters. This method is useful if the developer wants to have access to lower level GNUPlotparameter methods.

Returns:
Object having all information on how to make the plot.

setTerminal

public void setTerminal(GNUPlotTerminal term)
Change gnuplot terminal. Use this method to make gnuplot draw to another terminal than the default

Parameters:
term - The terminal to use

getTerminal

public GNUPlotTerminal getTerminal()
Get the current used terminal

Returns:
The used terminal

getDebugger

public static Debug getDebugger()
Get the specific GNUPlot Debug object

Returns:
The Debug object

getPreInit

public java.util.ArrayList<java.lang.String> getPreInit()
Execute gnuplot commands before any kind of initialization. This method together with getPostInit() is useful to add basic commands to gnuplot exetutable, if the library does not support the desired functionality

Returns:
Array of pre-init commands

getPostInit

public java.util.ArrayList<java.lang.String> getPostInit()
Execute gnuplot commands before any kind of initialization. This method together with getPostInit() is useful to add basic commands to gnuplot exetutable, if the library does not support the desired functionality

Returns:
Array of pre-init commands