
com.panayotis.gnuplot.terminal.ImageTerminal Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pa-toolbox-extern-javaplot Show documentation
Show all versions of pa-toolbox-extern-javaplot Show documentation
This JavaPlot library has not been written by me (the author of the PA-Toolbox project).
See the given URL for the original JavaPlot project.
These files have been extracted from the download JavaPlot-0.5.0.tar.bz2.
It is included here just to resolve external dependencies of other PA-Toolbox submodules.
The newest version!
/* Copyright (c) 2007-2014 by panayotis.com
*
* JavaPlot is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 2.
*
* JavaPlot is free in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with CrossMobile; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* Created on October 16, 2007, 1:34 AM
*/
package com.panayotis.gnuplot.terminal;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import javax.imageio.ImageIO;
/**
* This terminal is able to process gnuplot output as an image. The image
* produced can be used by any Java object which is able to handle BufferedImage
*
* @author teras
*/
public class ImageTerminal extends FileTerminal {
private BufferedImage img;
/**
* Create a new image terminal, and use PNG as it's backend
*/
public ImageTerminal() {
super("png");
}
/**
* Read the produced image from gnuplot standard output
*
* @param stdout The gnuplot output stream
* @return The error definition, if any
*/
public String processOutput(InputStream stdout) {
try {
img = ImageIO.read(stdout);
} catch (IOException ex) {
return "Unable to create PNG image: " + ex.getMessage();
}
if (img == null)
return "Unable to create image from the gnuplot output. Null image created.";
return null;
}
/**
* Get a handler of the produced image by this terminal
*
* @return the plot image
*/
public BufferedImage getImage() {
return img;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy