00001 package de.tum.in.fipm.kipm.gui.visualisation.applets; 00002 00003 import processing.core.PApplet; 00004 import processing.core.PImage; 00005 import java.awt.Dimension; 00006 00007 public class ImageViewerApplet extends PApplet { 00008 00009 private static final long serialVersionUID = 4502618030349542714L; 00010 00011 00012 PImage img; 00013 String image = null; 00014 00015 public ImageViewerApplet(String image) { 00016 this.image = image; 00017 } 00018 00019 public ImageViewerApplet() { 00020 00021 } 00022 00023 public void setup() { 00024 00025 if(this.image != null) { 00026 System.out.println("Loading " + image); 00027 this.img = loadImage(image); 00028 size(img.width, img.height, P2D); 00029 } 00030 else 00031 size(279, 400, P2D); 00032 } 00033 00034 public void draw() { 00035 00036 background(20, 20, 20); 00037 00038 if(this.img!=null) { 00039 image(this.img, 0,0,this.img.width,this.img.height); 00040 } 00041 } 00042 00043 00044 public void setImage(String image) { 00045 this.img=loadImage(image); 00046 this.height = img.height; 00047 this.width = img.width; 00048 setSize(width, height); 00049 setPreferredSize(new Dimension(width,height)); 00050 setMaximumSize(new Dimension(width,height)); 00051 setMinimumSize(new Dimension(width,height)); 00052 draw(); 00053 } 00054 00055 } 00056