【发布时间】:2016-08-09 21:55:56
【问题描述】:
有人可以给我一些关于如何从我创建的图表中保存图像 (PNG) 的建议吗?
这是java程序:
public class GraphingData extends JPanel {
int[] data = {
110, 535, 0, 459, 380, 199, 212, 722, 332, 836, 149, 10, 656, 465, 100, 173, 277, 381, 685, 988, 89, 585, 381, 779, 378, 769, 265, 10
};
final int PAD = 20;
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
int w = getWidth();
int h = getHeight();
.......
}
public static void main(String[] args) {
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(new GraphingData());
f.setSize(1000,500);
f.setLocation(200,200);
f.setVisible(true);
}
}
【问题讨论】: