00001 package gov.nasa.arc.ase.ltl;
00002
00003
00004 import java.awt.*;
00005 import java.awt.image.BufferedImage;
00006 import java.awt.geom.AffineTransform;
00007
00008 class ImageCanvas extends Canvas {
00009
00010 Image image = null;
00011 float degree = 1;
00012 MediaTracker tracker = new MediaTracker(this);
00013 int canvasHeight = 600;
00014 int canvasWidth = 600;
00015 ImagePanel pane;
00016
00017 public ImageCanvas(ImagePanel pane) {
00018 this.pane = pane;
00019 }
00020 public Dimension getPreferredSize() {
00021 return new Dimension(canvasWidth, canvasHeight);
00022 }
00023 public void increase() {
00024 degree = degree + (float)0.1;
00025 if (degree > 2)
00026 degree = 2;
00027 }
00028 public void paint(Graphics g) {
00029
00030 if (image != null) {
00031 int width = image.getWidth(this);
00032 int height = image.getHeight(this);
00033 int newWidth = Math.round((float)width * degree);
00034 int newHeight = Math.round((float)height * degree);
00035 if (newWidth > getWidth() || newHeight > getHeight()) {
00036 setSize(newWidth+5, newHeight+5);
00037 canvasWidth = newWidth+5;
00038 canvasHeight = newHeight+5;
00039 }
00040
00041 if (tracker.statusID(0, false) == MediaTracker.COMPLETE) {
00042 g.drawImage(image, 0, 0, newWidth, newHeight, this);
00043 pane.doLayout();
00044 }
00045 }
00046
00047 }
00048 public void reduce() {
00049 degree = degree - (float)0.1;
00050 if (degree < 0.5)
00051 degree = (float)0.5;
00052 }
00053 public void setImage(Image imageIn) {
00054 image = imageIn;
00055 tracker.addImage(image, 0);
00056 }
00057 public void setNormal() {
00058 degree = 1;
00059 }
00060 }