1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
/* */ import StandardIO.Approvable;
/* */ import StandardIO.MFileFilter;
/* */ import StandardIO.ModulusFileChooser;
/* */ import java.awt.FlowLayout;
/* */ import java.awt.Graphics;
/* */ import java.awt.Graphics2D;
/* */ import java.awt.event.ActionEvent;
/* */ import java.awt.event.ActionListener;
/* */ import java.awt.event.MouseEvent;
/* */ import java.awt.event.MouseListener;
/* */ import java.awt.geom.AffineTransform;
/* */ import java.awt.image.BufferedImage;
/* */ import java.io.File;
/* */ import java.io.IOException;
/* */ import javax.imageio.ImageIO;
/* */ import javax.swing.JButton;
/* */ import javax.swing.JDialog;
/* */
/* */ public class ImageFrame extends JDialog
/* */ implements MouseListener, ActionListener
/* */ {
/* */ private BufferedImage image;
/* */ private JButton saveButton;
/* 25 */ private Approvable imageSaveApprove = new Approvable()
/* */ {
/* */ public void onApprove(File file) {
/* */ try {
/* 29 */ file.createNewFile();
/* 30 */ ImageIO.write(ImageFrame.this.image, file.toString().substring(file.toString().lastIndexOf(".") + 1), file);
/* */ }
/* */ catch (IOException localIOException)
/* */ {
/* */ }
/* */ }
/* */
/* */ public void onCancel()
/* */ {
/* */ }
/* 25 */ };
/* */
/* */ public ImageFrame(BufferedImage img)
/* */ {
/* 37 */ setAlwaysOnTop(true);
/* 38 */ setLayout(new FlowLayout());
/* 39 */ setTitle("Snapshot");
/* 40 */ this.image = img;
/* 41 */ this.saveButton = new JButton("Save");
/* 42 */ add(this.saveButton);
/* 43 */ this.saveButton.setVisible(true);
/* 44 */ this.saveButton.addActionListener(this);
/* 45 */ addMouseListener(this);
/* 46 */ reset();
/* */ }
/* */ public void setImage(BufferedImage image) {
/* 49 */ this.image = image;
/* 50 */ reset();
/* */ }
/* */ private void reset() {
/* 53 */ setSize(350, 300);
/* 54 */ repaint();
/* */ }
/* */ public void paint(Graphics g2) {
/* 57 */ Graphics2D g = (Graphics2D)g2;
/* 58 */ if (this.image != null)
/* 59 */ g.drawImage(this.image, AffineTransform.getScaleInstance(getWidth() / this.image.getWidth(), getHeight() / this.image.getHeight()), null);
/* */ }
/* */ public void mouseClicked(MouseEvent e) {
/* */ }
/* */ public void mouseEntered(MouseEvent e) {
/* */ }
/* */
/* */ public void mouseExited(MouseEvent e) {
/* */ }
/* */
/* */ public void mousePressed(MouseEvent e) {
/* */ }
/* */
/* */ public void mouseReleased(MouseEvent e) {
/* */ }
/* */
/* 75 */ public void actionPerformed(ActionEvent e) { ModulusFileChooser mfc = new ModulusFileChooser(this.imageSaveApprove, "", new MFileFilter[] { new MFileFilter(new String[] { ".png" }, "png Image"), new MFileFilter(new String[] { ".gif" }, "Comput"), new MFileFilter(new String[] { ".bmp" }, "Bitmap") });
/* 76 */ mfc.promptSave();
/* */ }
/* */ }
/* Location: Modulus.jar
* Qualified Name: ImageFrame
* JD-Core Version: 0.6.2
*/
|