package cs437.som.demo;

import javax.swing.*;
import java.awt.*;
import java.awt.image.BufferedImage;

/**
* A simple frame for displaying a square image, scaled to 400x400 in a window.
*/
class ImageFrame extends JFrame {
    private static final int IMAGE_DIMENSION = 400;
    private static final int FRAME_DIMENSION = 420;
    Image image;

    public ImageFrame(String title, BufferedImage image) {
        super(title);
        this.image = image.getScaledInstance(IMAGE_DIMENSION, IMAGE_DIMENSION,
                Image.SCALE_DEFAULT);
        setSize(FRAME_DIMENSION, FRAME_DIMENSION);
        setLocation(0, 0);
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        setVisible(true);
    }

    public ImageFrame(String title, BufferedImage image, int x, int y) {
        super(title);
        this.image = image.getScaledInstance(IMAGE_DIMENSION, IMAGE_DIMENSION,
                Image.SCALE_DEFAULT);
        setSize(FRAME_DIMENSION, FRAME_DIMENSION);
        setLocation(x, y);
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        setVisible(true);
    }

    @Override
    public void paint(Graphics g) {
        super.paint(g);
        g.drawImage(image, 0, 0, IMAGE_DIMENSION, IMAGE_DIMENSION, this);
    }

    @Override
    public boolean imageUpdate(Image img, int infoflags, int x, int y, int w, int h) {
        return (infoflags & ALLBITS) != 0;
    }

    @Override public String toString() { return "ImageFrame"; }
}

@@ -37,17 +37,84 @@
 x.swing.
-*
+JFrame;%0Aimport javax.swing.WindowConstants;%0Aimport java.awt.Graphics
 ;%0Aimport
@@ -123,17 +123,21 @@
 ava.awt.
-*
+Image
 ;%0Aimport
@@ -254,16 +254,23 @@
 dow.%0A*/%0A
+public 
 class Im
@@ -295,16 +295,92 @@
 Frame %7B%0A
+    /** The height and width dimension to which the image will be scaled */%0A
     priv
@@ -422,16 +422,67 @@
 N = 400;
+%0A%0A    /** The height and width the frame will be */
 %0A    pri
@@ -530,25 +530,199 @@
 20;%0A
-    Image image;%0A
+%0A    /** Image cache */%0A    Image image;%0A%0A    /**%0A     * Display an image in a new frame.%0A     *%0A     * @param title The window title to use.%0A     * @param image The image to display.%0A     */
 %0A   
@@ -1091,24 +1091,306 @@
 ue);%0A    %7D%0A%0A
+    /**%0A     * Display an image in a new frame.%0A     *%0A     * @param title The window title to use.%0A     * @param image The image to display.%0A     * @param x The x location of the window's upper left corner.%0A     * @param y The y location of the window's upper left corner.%0A     */%0A
     public I
@@ -1760,32 +1760,69 @@
 e(true);%0A    %7D%0A%0A
+    /**%0A     * %7B@inheritDoc%7D%0A     */%0A
     @Override%0A  
@@ -1952,32 +1952,69 @@
 , this);%0A    %7D%0A%0A
+    /**%0A     * %7B@inheritDoc%7D%0A     */%0A
     @Override%0A  
@@ -2144,24 +2144,61 @@
 = 0;%0A    %7D%0A%0A
+    /**%0A     * %7B@inheritDoc%7D%0A     */%0A
     @Overrid

Comment ImageFrame class.