|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Window
java.awt.Frame
javax.swing.JFrame
fern.tools.gnuplot.GnuPlot
public class GnuPlot
The class GnuPlot
provides methods for handling gnuplot data. Additionally
this class can be used as an interface to gnuplot in order to actually plot data.
After data has been added by one of the addData
methods, you are able either
to retrieve the gnuplot data file (as String - getData
- or saved to a file -
saveData
) or to plot
the data by invoking gnuplot.
Once the plot is created, it can be retrieved as an Image object by getImage
,
saved to a png file by saveImage
or presented interactively to the screen
(by setting the visible property to true).
Multiple data can be added as well as another gnuplot object can be merged.
If the plot is shown in the JFrame
, it can be saved by rightclicking on the frame or
pressing F3 / CTRL-S.
Axes
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.BaselineResizeBehavior |
Field Summary |
---|
Fields inherited from class javax.swing.JFrame |
---|
EXIT_ON_CLOSE |
Fields inherited from class java.awt.Frame |
---|
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface javax.swing.WindowConstants |
---|
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
GnuPlot()
The constructor sets the DefaultCloseOperation of this JFrame to DISPOSE_ON_CLOSE. |
Method Summary | |
---|---|
void |
addCommand(String... command)
Adds commands to the list of commands which are given to gnuplot by invoking plot |
Axes |
addData(Axes axes)
Adds data in order to plot it. |
Axes |
addData(Collection col,
String[] dataLabels,
String[] styles)
Adds data in order to plot it. |
Axes |
addData(Object[] arr,
boolean transposed,
String[] dataLabels,
String[] styles)
Adds data in order to plot it. |
Axes |
addData(Object arr,
String[] dataLabels,
String[] styles)
Adds data in order to plot it. |
void |
clearData()
Clears the loaded data. |
List<Axes> |
getAxes()
Returns the Axes object containing the data, labels and styles. |
Collection<String> |
getCommands()
Returns the list of commands, e.g. if you want to remove some command from it. |
List<String> |
getData()
Returns the data in gnuplot data file format as list containing the data for each added axes. |
String |
getDefaultStyle()
The defaultStyle is used, when no style is defined for an column in an axes object. |
BufferedImage |
getImage()
Return the plotted data as image. |
String |
getPlotCommand(List<File> files)
Returns the plot command for a given filename |
boolean |
isAccessible()
Returns whether or not gnuplot is accessible |
void |
merge(GnuPlot gnuplot)
Merges another gnuplot object with this one by add its axes and copy its default style to the axes (if they have no style). |
void |
paint(Graphics g)
|
void |
plot()
Calls gnuplot to plot the data. |
List<File> |
saveData(File file)
Saves the gnuplot data to one ore more files. |
void |
saveImage(File file)
Saves the plotted data to a png file. |
void |
setDefaultStyle(String defaultStyle)
The defaultStyle is used, when no style is defined for an column in an axes object. |
Methods inherited from class javax.swing.JFrame |
---|
getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setTransferHandler, update |
Methods inherited from class java.awt.Frame |
---|
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.awt.MenuContainer |
---|
getFont, postEvent |
Constructor Detail |
---|
public GnuPlot()
Method Detail |
---|
public void addCommand(String... command)
plot
command
- the gnuplot command (e.g. set xrange [0:100])public Collection<String> getCommands()
public void clearData()
public Axes addData(Collection col, String[] dataLabels, String[] styles)
col
- the collections array with the datadataLabels
- label for each value columnstyles
- additional styles for each value column
public Axes addData(Axes axes)
axes
- an axes object with data to plot
public Axes addData(Object arr, String[] dataLabels, String[] styles)
arr
- the data matrix to plotstyles
- additional styles for each value columndataLabels
- label for each value column
public Axes addData(Object[] arr, boolean transposed, String[] dataLabels, String[] styles)
arr
- the data matrix to plottransposed
- if the given matrix is transposedstyles
- additional styles for each value columndataLabels
- label for each value column
public void merge(GnuPlot gnuplot)
gnuplot
- the gnuplot object to merge withpublic List<Axes> getAxes()
public String getPlotCommand(List<File> files)
files
- a list (parallel to axes) of files containing the gnuplot data
public BufferedImage getImage()
public void saveImage(File file) throws IOException
file
- the file to save the png file
IOException
public List<String> getData()
public List<File> saveData(File file) throws IOException
file
- where to save to file
IOException
public boolean isAccessible()
public void plot() throws IOException
loadData
has
to be invoked first. A temporary file is created in the working directory
to hold the data (for compatibility
with cygwin, this file is not created by File.createTempFile
)
and deleted after plotting. If the JFrame is visible, it will be repainted.
The commands are given to gnuplot via its stdin, the plotted image is retrieved
via its stdout.
The name(s) of the temporary files are hashCode()i.gnuplot
. If there
is only one file created, i
is omitted.
IOException
public void paint(Graphics g)
paint
in class Container
public String getDefaultStyle()
public void setDefaultStyle(String defaultStyle)
defaultStyle
- the defaultStyle to set
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |