1 package net.sf.openrocket.gui.help.tours;
3 import java.awt.Dimension;
5 import javax.swing.JEditorPane;
6 import javax.swing.JScrollPane;
7 import javax.swing.JSplitPane;
8 import javax.swing.event.HyperlinkListener;
9 import javax.swing.text.html.HTMLDocument;
10 import javax.swing.text.html.StyleSheet;
12 import net.sf.openrocket.gui.components.ImageDisplayComponent;
15 * Component that displays a single slide, with the image on top and
16 * text below it. The portions are resizeable.
18 * @author Sampo Niskanen <sampo.niskanen@iki.fi>
20 public class SlideShowComponent extends JSplitPane {
22 private final int WIDTH = 600;
23 private final int HEIGHT_IMAGE = 400;
24 private final int HEIGHT_TEXT = 100;
26 private final ImageDisplayComponent imageDisplay;
27 private final JEditorPane textPane;
30 public SlideShowComponent() {
31 super(VERTICAL_SPLIT);
33 imageDisplay = new ImageDisplayComponent();
34 imageDisplay.setPreferredSize(new Dimension(WIDTH, HEIGHT_IMAGE));
35 this.setLeftComponent(imageDisplay);
37 textPane = new JEditorPane("text/html", "");
38 textPane.setEditable(false);
39 textPane.setPreferredSize(new Dimension(WIDTH, HEIGHT_TEXT));
41 JScrollPane scrollPanel = new JScrollPane(textPane);
42 this.setRightComponent(scrollPanel);
44 this.setResizeWeight(((double) HEIGHT_IMAGE) / (HEIGHT_IMAGE + HEIGHT_TEXT));
49 public void setSlide(Slide slide) {
50 this.imageDisplay.setImage(slide.getImage());
51 this.textPane.setText(slide.getText());
56 * Replace the current HTML style sheet with a new style sheet.
58 public void setStyleSheet(StyleSheet newStyleSheet) {
59 HTMLDocument doc = (HTMLDocument) textPane.getDocument();
60 StyleSheet base = doc.getStyleSheet();
61 StyleSheet[] linked = base.getStyleSheets();
63 for (StyleSheet ss : linked) {
64 base.removeStyleSheet(ss);
68 base.addStyleSheet(newStyleSheet);
72 public void addHyperlinkListener(HyperlinkListener listener) {
73 textPane.addHyperlinkListener(listener);