1 package net.sf.openrocket.gui.help.tours;
3 import java.awt.image.BufferedImage;
4 import java.io.IOException;
5 import java.lang.ref.SoftReference;
8 import javax.imageio.ImageIO;
11 * An individual slide in a guided tour. It contains a image (or reference to an
12 * image file) plus a text description (in HTML).
14 * @author Sampo Niskanen <sampo.niskanen@iki.fi>
17 private static final String NO_IMAGE = "none";
19 private final String imageFile;
20 private SoftReference<BufferedImage> imageReference = null;
22 private final String text;
26 public Slide(String imageFile, String text) {
27 this.imageFile = imageFile;
33 public BufferedImage getImage() {
35 if (imageFile.equals(NO_IMAGE)) {
36 return new BufferedImage(0, 0, BufferedImage.TYPE_INT_ARGB);
40 if (imageReference != null) {
41 BufferedImage image = imageReference.get();
47 // Otherwise load and cache
48 BufferedImage image = loadImage();
49 imageReference = new SoftReference<BufferedImage>(image);
54 public String getText() {
60 private BufferedImage loadImage() {
64 URL url = ClassLoader.getSystemResource(imageFile);
66 img = ImageIO.read(url);
71 } catch (IOException e) {