求教如何把JAVA运行的程序结果生成图表
编了一个XML的小解析器,用来分析不同的XMLfile的质量,比如说elem.数量,attr.数量,运行时间,所用内存等。现在要把这些运行结果用图表来显示出来,主要是来比较四五个类似的xmlfile的质量。
我想用曲线统计图来做,每条线表示一个XMLfile,可是遇上难题了。
小妹在这里请教前辈们了,用什么软件最好阿,或者如何调用JAVA这方面内置的方法,要再装新的工具包吗?
请大家帮忙解决难题啦。$送花$$送花$
先谢谢了。 JFreeChart可以生成你要的效果
可以把JAR绑定到你的JAVA程序
http://www.jfree.org/jfreechart/ 原帖由 etongyi 于 2007-3-28 21:54 发表 http://www.dolc.de/forum/images/common/back.gif
JFreeChart可以生成你要的效果
可以把JAR绑定到你的JAVA程序
http://www.jfree.org/jfreechart/
谢谢谢谢了,终于有高手进来指点了 $送花$$送花$ 原帖由 yiyiyaya^^ 于 2007-3-28 22:10 发表 http://www.dolc.de/forum/images/common/back.gif
谢谢谢谢了,终于有高手进来指点了 $送花$$送花$
我是菜鸟啦~呵呵~碰巧用过~ 把结果写成csv文件输出,用excel也可以$汗$ $汗$ 我用jfreechart导出了两个统计图了。哈哈!
不过不知道能不能把跳出的Fester所显示的图像储存 $frage$ 原帖由 yiyiyaya^^ 于 2007-3-29 23:21 发表 http://www.dolc.de/forum/images/common/back.gif
我用jfreechart导出了两个统计图了。哈哈!
不过不知道能不能把跳出的Fester所显示的图像储存 $frage$
对着图单击右键应该有SAVE AS什么的吧~ 原帖由 greenflute 于 2007-3-29 22:09 发表 http://www.dolc.de/forum/images/common/back.gif
把结果写成csv文件输出,用excel也可以$汗$ $汗$
对啊~也可以的啊~:( 年纪大了脑子转不动了~ 我觉得chart很好用阿,那个csv文档要全用,隔开是吗? 不知道好不好用。
今天学到了 $汗$ 原帖由 etongyi 于 2007-3-29 23:36 发表 http://www.dolc.de/forum/images/common/back.gif
对着图单击右键应该有SAVE AS什么的吧~
那个好像不能这样储存吧,要定义成png格式或者jpg吧。不知道怎么调用阿,用google没有查到,$郁闷$ 原帖由 yiyiyaya^^ 于 2007-3-29 23:51 发表 http://www.dolc.de/forum/images/common/back.gif
那个好像不能这样储存吧,要定义成png格式或者jpg吧。不知道怎么调用阿,用google没有查到,$郁闷$
可以存成PNG啊~难道我又记错了~:( 原帖由 yiyiyaya^^ 于 2007-3-29 23:21 发表 http://www.dolc.de/forum/images/common/back.gif
我用jfreechart导出了两个统计图了。哈哈!
不过不知道能不能把跳出的Fester所显示的图像储存 $frage$
应该是可以的.而且可以根据自己设定的图象格式(PNG,JPG,BMP等等)进行存储.
Beispiel:
import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.ImageIO;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter;
/**
* Wrapper class for an image that includes a rendered image (graphic content).
*
*
*/
@SuppressWarnings("serial")
public class Image
implements Serializable
{
/** The graphic content of the Image object */
private transient BufferedImage content;
/** Default width for new Image objects */
private static int defaultWidth = 400;
/** Default height for new Image objects */
private static int defaultHeight = 400;
/** Width of the Image object */
private int width;
/** Height of the Image object */
private int height;
/**
* Creates a new image object with the default width and height.
*/
public Image()
{
this(defaultWidth, defaultHeight);
}
/**
* Creates a new image object with the specified width and height.
*
* @param width Width of the image object
* @param height Height of the image object
*/
public Image(int width, int height)
{
this.width = width;
this.height = height;
restoreContent();
}
/**
* Sets the default image size for all new images, instanciated with no
* dimension specification.
*
* @param dim Default dimension for new images
*/
public static void setDefaultSize(Dimension dim)
{
defaultWidth = dim.width;
defaultHeight = dim.height;
}
/**
* Returns the graphics content of this image.
*/
public BufferedImage getContent()
{
return content;
}
/**
* Sets a new graphics content.
*
* @param content The new graphics content
*/
public void setContent(BufferedImage content)
{
this.content = content;
}
/**
* Returns the height of the image.
*/
public int getHeight()
{
return height;
}
/**
* Sets the height of the image.
*
* @param height The height of the image
*/
public void setHeight(int height)
{
this.height = height;
}
/**
* Returns the width of the image.
*/
public int getWidth()
{
return width;
}
/**
* Sets the width of the image.
*
* @param width The width of the image
*/
public void setWidth(int width)
{
this.width = width;
}
/**
* Restores the graphics content of the image by assigning it to a new
* BufferedImage with the current dimensions.
*/
public void restoreContent()
{
content = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
}
/**
* Dialog for selecting a target to save the rendered image of an
* algorithm.
*/
public static class SaveImageDialog
{
File returnFile = null;
String returnTyp = null;
/**
* Creates a new SaveImageDialog for the specified BufferedImage and
* saves the image if the OK button is pushed.
*/
public SaveImageDialog(BufferedImage image)
{
JFileChooser fileChooser = new JFileChooser();
fileChooser.setAcceptAllFileFilterUsed(false);
FileFilter jpgFileFilter = new FileFilter()
{
public boolean accept(File f)
{
return f.isDirectory() ||
f.getName().toLowerCase().endsWith(".jpg");
}
public String getDescription()
{
return "JPEG";
}
};
fileChooser.addChoosableFileFilter(jpgFileFilter);
FileFilter bmpFileFilter = new FileFilter()
{
public boolean accept(File f)
{
return f.isDirectory() ||
f.getName().toLowerCase().endsWith(".bmp");
}
public String getDescription()
{
return "BMP";
}
};
fileChooser.addChoosableFileFilter(bmpFileFilter);
FileFilter pngFileFilter = new FileFilter()
{
public boolean accept(File f)
{
return f.isDirectory() ||
f.getName().toLowerCase().endsWith(".png");
}
public String getDescription()
{
return "PNG";
}
};
fileChooser.addChoosableFileFilter(pngFileFilter);
int state = fileChooser.showSaveDialog(null);
if (state == JFileChooser.APPROVE_OPTION)
{
String typ = "bmp";
if (fileChooser.getFileFilter()==jpgFileFilter)
typ = "jpg";
else if (fileChooser.getFileFilter()==bmpFileFilter)
typ = "bmp";
else if (fileChooser.getFileFilter()==pngFileFilter)
typ = "png";
File file = fileChooser.getSelectedFile();
boolean hasEnd = true;
if (file.getAbsolutePath().toLowerCase().endsWith (".jpg"))
typ = "jpg";
else if (file.getAbsolutePath().toLowerCase().endsWith (".png"))
typ = "png";
else if (file.getAbsolutePath().toLowerCase().endsWith (".bmp"))
typ = "bmp";
else
hasEnd = false;
returnTyp=typ;
String name = file.getPath();
try
{
if (!hasEnd)
returnFile = new File(name + "." + typ);
else
returnFile = file;
if (image!=null)
ImageIO.write(image, typ, returnFile);
}
catch (IOException ex)
{
}
}
}
public File getFile()
{
return returnFile;
}
public String getTyp()
{
return returnTyp;
}
}
} 笑脸应该是右括号. 谢谢谢谢斑斑的code,学妹这里有礼了! $送花$
再次谢谢ls热心提供宝贵信息的前辈们。
以后一定来我们的INFO天空多多学习。 原帖由 yiyiyaya^^ 于 2007-3-30 16:49 发表 http://www.dolc.de/forum/images/common/back.gif
谢谢谢谢斑斑的code,学妹这里有礼了! $送花$
再次谢谢ls热心提供宝贵信息的前辈们。
以后一定来我们的INFO天空多多学习。
欢迎欢迎.有空常来. 还好版主出山~$支持$ $支持$ $支持$
页:
[1]