作成したグラフから画像(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);
}
}
可能なdupはhttp://stackoverflow.com/questions/8202253/saving-a-java-2d-graphics-image-as-png-fileですか? – vjkumar