1 package jp.sourceforge.stigmata.ui.swing.mds;
4 import java.awt.Dimension;
5 import java.awt.Graphics2D;
6 import java.awt.image.BufferedImage;
7 import java.io.IOException;
8 import java.io.OutputStream;
10 import javax.imageio.ImageIO;
11 import javax.swing.JOptionPane;
12 import javax.swing.SwingUtilities;
14 import jp.sourceforge.stigmata.ui.swing.UnsupportedFormatException;
15 import jp.sourceforge.stigmata.utils.BinaryDataWritable;
16 import jp.sourceforge.talisman.mds.ui.swing.MdsPane;
19 * @author Haruaki TAMADA
21 public class MdsImageExporter implements BinaryDataWritable{
22 private MdsPane viewer;
24 public MdsImageExporter(MdsPane viewer){
29 public void writeBinaryData(OutputStream out, String format)
30 throws IOException, UnsupportedFormatException{
31 Dimension size = viewer.getSize();
32 BufferedImage image = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB);
33 Graphics2D g = image.createGraphics();
34 g.setColor(Color.WHITE);
35 g.fillRect(0, 0, size.width, size.height);
39 ImageIO.write(image, format, out);
41 } catch(IOException e){
42 JOptionPane.showMessageDialog(
43 SwingUtilities.getRoot(viewer), e.getMessage(),
44 viewer.getMessages().get("error.dialog.title"),
45 JOptionPane.WARNING_MESSAGE