aboutsummaryrefslogtreecommitdiff
path: root/src/ImageFrame.java
diff options
context:
space:
mode:
authorJoshua Rahm <joshua.rahm@colorado.edu>2015-01-30 17:11:48 -0700
committerJoshua Rahm <joshua.rahm@colorado.edu>2015-01-30 17:11:48 -0700
commit1c5e38fe69ac8a6decbdd8abe93112f4e3369315 (patch)
tree926cef8cb76d46862ed2c4ec7028720611e47476 /src/ImageFrame.java
downloadModulus3D-1c5e38fe69ac8a6decbdd8abe93112f4e3369315.tar.gz
Modulus3D-1c5e38fe69ac8a6decbdd8abe93112f4e3369315.tar.bz2
Modulus3D-1c5e38fe69ac8a6decbdd8abe93112f4e3369315.zip
added source
Diffstat (limited to 'src/ImageFrame.java')
-rw-r--r--src/ImageFrame.java89
1 files changed, 89 insertions, 0 deletions
diff --git a/src/ImageFrame.java b/src/ImageFrame.java
new file mode 100644
index 0000000..3fb7321
--- /dev/null
+++ b/src/ImageFrame.java
@@ -0,0 +1,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
+ */ \ No newline at end of file