1 /** 2 * Copyright (c) 2011, The University of Southampton and the individual contributors. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without modification, 6 * are permitted provided that the following conditions are met: 7 * 8 * * Redistributions of source code must retain the above copyright notice, 9 * this list of conditions and the following disclaimer. 10 * 11 * * Redistributions in binary form must reproduce the above copyright notice, 12 * this list of conditions and the following disclaimer in the documentation 13 * and/or other materials provided with the distribution. 14 * 15 * * Neither the name of the University of Southampton nor the names of its 16 * contributors may be used to endorse or promote products derived from this 17 * software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 package org.openimaj.content.slideshow; 31 32 import java.awt.image.BufferedImage; 33 import java.io.IOException; 34 import java.util.ArrayList; 35 import java.util.List; 36 37 import javax.swing.JFrame; 38 39 /** 40 * A slideshow that can be used in a Java Swing application. The slideshow is 41 * created in a new window (JFrame). 42 * 43 * @author Jonathon Hare (jsh2@ecs.soton.ac.uk) 44 * 45 */ 46 public class SlideshowApplication extends Slideshow { 47 protected FullscreenUtility fsutil; 48 49 /** 50 * Default constructor. 51 * 52 * @param slides 53 * The slides to display. 54 * @param slideWidth 55 * The slide width. 56 * @param slideHeight 57 * The slide height. 58 * @param background 59 * The background image. 60 * @throws IOException 61 */ 62 public SlideshowApplication(List<Slide> slides, int slideWidth, int slideHeight, BufferedImage background) 63 throws IOException 64 { 65 super(new JFrame(), slides, slideWidth, slideHeight, background); 66 fsutil = new FullscreenUtility((JFrame) container); 67 } 68 69 /** 70 * Default constructor. 71 * 72 * @param slide 73 * The slide to display. 74 * @param slideWidth 75 * The slide width. 76 * @param slideHeight 77 * The slide height. 78 * @param background 79 * The background image. 80 * @throws IOException 81 */ 82 public SlideshowApplication(Slide slide, int slideWidth, int slideHeight, BufferedImage background) 83 throws IOException 84 { 85 super(new JFrame(), createList(slide), slideWidth, slideHeight, background); 86 fsutil = new FullscreenUtility((JFrame) container); 87 } 88 89 /** 90 * Default constructor. 91 * 92 * @param slide 93 * The slide to display. 94 * @param slideWidth 95 * The slide width. 96 * @param slideHeight 97 * The slide height. 98 * @throws IOException 99 */ 100 public SlideshowApplication(Slide slide, int slideWidth, int slideHeight) 101 throws IOException 102 { 103 super(new JFrame(), createList(slide), slideWidth, slideHeight, null); 104 fsutil = new FullscreenUtility((JFrame) container); 105 } 106 107 private static List<Slide> createList(Slide... slides) { 108 final List<Slide> slidesl = new ArrayList<Slide>(); 109 110 for (final Slide s : slides) 111 slidesl.add(s); 112 113 return slidesl; 114 } 115 116 @Override 117 protected void pack() { 118 ((JFrame) container).pack(); 119 } 120 121 @Override 122 public void setFullscreen(boolean fullscreen) { 123 fsutil.setFullscreen(fullscreen); 124 } 125 126 @Override 127 protected boolean isFullscreen() { 128 return fsutil.fullscreen; 129 } 130 }