001 /**
002 * Copyright (C) 2007-2008, Jens Lehmann
003 *
004 * This file is part of DL-Learner.
005 *
006 * DL-Learner is free software; you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation; either version 3 of the License, or
009 * (at your option) any later version.
010 *
011 * DL-Learner is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014 * GNU General Public License for more details.
015 *
016 * You should have received a copy of the GNU General Public License
017 * along with this program. If not, see <http://www.gnu.org/licenses/>.
018 *
019 */
020 package org.dllearner.gui;
021
022 import java.net.URL;
023
024 import javax.swing.ImageIcon;
025 import javax.swing.JFrame;
026 import javax.swing.JLabel;
027 import javax.swing.JScrollPane;
028 import javax.swing.JTextPane;
029 import javax.swing.text.BadLocationException;
030 import javax.swing.text.Style;
031 import javax.swing.text.StyleConstants;
032 import javax.swing.text.StyleContext;
033 import javax.swing.text.StyledDocument;
034
035 import org.dllearner.Info;
036
037 /**
038 * Window displaying some information about DL-Learner and DL-Learner GUI.
039 *
040 * @author Jens Lehmann
041 *
042 */
043 public class AboutWindow extends JFrame {
044
045 private static final long serialVersionUID = -5448814141333659068L;
046
047 /**
048 * Displays a classical "About" window.
049 */
050 public AboutWindow() {
051 setTitle("About");
052 setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
053 setLocationByPlatform(true);
054 setSize(400, 400);
055
056 URL imgURL = AboutWindow.class.getResource("dl-learner.gif");
057
058 String html = "<html><p align=\"center\"><img src=\""+imgURL+"\" alt=\"DL-Learner logo\"/></p>";
059 html += "<p align=\"center\"><i>DL-Learner</i><br />Build " + Info.build + "</p>";
060 html += "<br /><p align=\"center\"><i>License</i><br />GNU General Public License Version 3</p>";
061 html += "<br /><p align=\"center\"><i>Homepage</i><br /><a href=\"http://dl-learner.org\">http://dl-learner.org</a></p>";
062 html += "<br /><p align=\"center\"><i>DL-Learner GUI developers</i><br />";
063 html += "Jens Lehmann<br />Tilo Hielscher</p>";
064 html += "<br /><p align=\"center\"><i>DL-Learner contributors in general</i><br />";
065 html += "Jens Lehmann<br />";
066 html += " Sebastian Hellmann (SPARQL component and more)<br />";
067 html += "Sebastian Knappe (DBpedia Navigator)<br />";
068 html += "Tilo Hielscher (DL-Learner GUI)<br />";
069 html += "Lorenz Bühmann (ORE Tool)<br />";
070 html += "Maria Moritz, Vu Duc Minh (OntoWiki plugin)<br />";
071 html += "Christian Kötteritzsch (Protégé 4 plugin)<br />";
072 html += "Collette Hagert (DB to OWL converter)</p>";
073 html += "</html>";
074
075 JLabel label = new JLabel(html);
076 // label.setFont(new Font("Serif", Font.PLAIN, 14));
077
078 add(label);
079
080 // SimpleAttributeSet bold = new SimpleAttributeSet();
081 // StyleConstants.setBold(bold, true);
082 // StyleConstants.setAlignment(bold, StyleConstants.ALIGN_CENTER);
083 //
084 // JTextPane textPane = new JTextPane();
085 // StyledDocument doc = textPane.getStyledDocument();
086 //
087 //
088 // textPane.setText("DL-Learner");
089 // doc.setParagraphAttributes(0, doc.getLength(), bold, false);
090 // add(textPane);
091 //
092 //
093
094 // Put the editor pane in a scroll pane.
095 // JTextPane textPane = createTextPane();
096 JScrollPane editorScrollPane = new JScrollPane(label);
097 editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
098 // editorScrollPane.setPreferredSize(new Dimension(250, 145));
099 // editorScrollPane.setMinimumSize(new Dimension(10, 10));
100
101 add(editorScrollPane);
102
103 setVisible(true);
104 }
105
106 @SuppressWarnings("unused")
107 private JTextPane createTextPane() {
108 String[] initString = { " ", "DL-Learner ", "Build " + Info.build,
109 "DL-Learner GUI developers:", "Jens Lehmann\nTilo Hielscher\n" };
110
111 String[] initStyles = { "icon", "bold", "regular", "italic", "regular" };
112
113 JTextPane textPane = new JTextPane();
114 // textPane.setSize(300, 200);
115 textPane.setEditable(false);
116 StyledDocument doc = textPane.getStyledDocument();
117 addStylesToDocument(doc);
118
119 try {
120 for (int i = 0; i < initString.length; i++) {
121 doc.insertString(doc.getLength(), initString[i] + "\n", doc.getStyle(initStyles[i]));
122 }
123 } catch (BadLocationException ble) {
124 System.err.println("Couldn't insert initial text into text pane.");
125 }
126
127 return textPane;
128 }
129
130 private void addStylesToDocument(StyledDocument doc) {
131 Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
132
133 Style regular = doc.addStyle("regular", def);
134 // StyleConstants.setFontFamily(def, "SansSerif");
135
136 Style s = doc.addStyle("italic", regular);
137 StyleConstants.setItalic(s, true);
138
139 s = doc.addStyle("bold", regular);
140 StyleConstants.setAlignment(s, StyleConstants.ALIGN_RIGHT);
141 StyleConstants.setBold(s, true);
142
143 s = doc.addStyle("icon", regular);
144 StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER);
145 ImageIcon pigIcon = createImageIcon("dl-learner.gif", "DL-Learner logo");
146 StyleConstants.setIcon(s, pigIcon);
147 }
148
149
150 private static ImageIcon createImageIcon(String path, String description) {
151 URL imgURL = AboutWindow.class.getResource(path);
152 if (imgURL != null) {
153 return new ImageIcon(imgURL, description);
154 } else {
155 System.err.println("Couldn't find file: " + path);
156 return null;
157 }
158 }
159
160 }