added contact information in 'about' box
[iDMC.git] / src / java / org / tsho / dmc2 / ui / DmcAboutFrame.java
blob14723ef92e438d7face6849d83884b2eb523a730
1 /*
2 * Derived from:
3 * ---------------
4 * AboutPanel.java
5 * ---------------
6 * (C) Copyright 2001-2004, by Object Refinery Limited.
8 * Original Author: David Gilbert (for Object Refinery Limited);
9 */
10 package org.tsho.dmc2.ui;
12 import java.awt.BorderLayout;
13 import java.awt.Dimension;
14 import java.awt.Image;
15 import java.util.Arrays;
16 import java.util.List;
17 import java.util.ResourceBundle;
19 import javax.swing.BorderFactory;
20 import javax.swing.JFrame;
21 import javax.swing.JPanel;
22 import javax.swing.JScrollPane;
23 import javax.swing.JTabbedPane;
24 import javax.swing.JTextArea;
25 import javax.swing.border.Border;
27 import org.jfree.JCommon;
28 import org.jfree.chart.JFreeChart;
29 import org.jfree.ui.about.AboutFrame;
30 import org.jfree.ui.about.Contributor;
31 import org.jfree.ui.about.ContributorsPanel;
32 import org.jfree.ui.about.Library;
33 import org.jfree.ui.about.LibraryPanel;
34 import org.jfree.ui.about.Licences;
35 import org.jfree.ui.about.ProjectInfo;
36 import org.jfree.ui.about.SystemPropertiesPanel;
37 import org.tsho.dmc2.DmcDue;
40 public class DmcAboutFrame extends JFrame {
42 private static final String myInfo =
43 "iDMC the interactive Dynamical Model Calculator simulates and performs "
44 + "graphical and numerical analysis of systems of differential and "
45 + "difference equations."
46 + "\n"
47 + "\n"
48 + "For support and bug report contact authors, or send an e-mail to\n"
49 + "idmc-discussion@googlegroups.com";
51 DmcAboutFrame() {
52 this("iDmc", new DmcDueInfo());
55 static class DmcDueInfo extends ProjectInfo {
57 public DmcDueInfo() {
58 setName(DmcDue.Defaults.name);
59 setVersion(DmcDue.Defaults.version);
60 setInfo(myInfo);
61 setCopyright("Copyright 2004-2007 Marji Lines and Alfredo Medio");
62 setLogo(null);
63 setLicenceName("GPL");
64 setLicenceText(Licences.getInstance().getGPL());
66 setContributors(Arrays.asList(
67 new Contributor[]{
68 new Contributor("Antonio, Fabio Di Narzo", "antonio.fabio@gmail.com"),
69 new Contributor("Alexei Grigoriev","alexei_grigoriev@libero.it"),
70 new Contributor("Daniele Pizzoni", "auouo@tin.it")
72 ));
74 setLibraries(Arrays.asList(
75 new Library[]{
76 new Library(JFreeChart.INFO),
77 new Library(JCommon.INFO),
78 new Library("JGoodies Forms", "1.0.3", "BSD", "http://www.jgoodies.com/"),
79 new Library("idmclib", DmcDue.Defaults.nativeLibVersion, "GPL", "http://code.google.com/p/idmclib/"),
81 ));
87 /** The preferred size for the frame. */
88 public static final Dimension PREFERRED_SIZE = new Dimension(560, 360);
90 /** The default border for the panels in the tabbed pane. */
91 public static final Border STANDARD_BORDER = BorderFactory.createEmptyBorder(5, 5, 5, 5);
93 /** Localised resources. */
94 private ResourceBundle resources;
96 /** The application name. */
97 private String application;
99 /** The application version. */
100 private String version;
102 /** The copyright string. */
103 private String copyright;
105 /** Other info about the application. */
106 private String info;
108 /** The project logo. */
109 private Image logo;
111 /** A list of contributors. */
112 private List contributors;
114 /** The licence. */
115 private String licence;
117 /** A list of libraries. */
118 private List libraries;
121 * Constructs an about frame.
123 * @param title the frame title.
124 * @param project information about the project.
126 public DmcAboutFrame(String title, ProjectInfo project) {
128 this(title,
129 project.getName(),
130 "Version " + project.getVersion(),
131 project.getInfo(),
132 project.getLogo(),
133 project.getCopyright(),
134 project.getLicenceText(),
135 project.getContributors(),
136 project.getLibraries());
141 * Constructs an 'About' frame.
143 * @param title the frame title.
144 * @param application the application name.
145 * @param version the version.
146 * @param info other info.
147 * @param logo an optional logo.
148 * @param copyright the copyright notice.
149 * @param licence the licence.
150 * @param contributors a list of developers/contributors.
151 * @param libraries a list of libraries.
153 public DmcAboutFrame(String title,
154 String application, String version, String info,
155 Image logo,
156 String copyright, String licence,
157 List contributors,
158 List libraries) {
160 super(title);
162 this.application = application;
163 this.version = version;
164 this.copyright = copyright;
165 this.info = info;
166 this.logo = logo;
167 this.contributors = contributors;
168 this.licence = licence;
169 this.libraries = libraries;
171 String baseName = "org.jfree.ui.about.resources.AboutResources";
172 this.resources = ResourceBundle.getBundle(baseName);
174 JPanel content = new JPanel(new BorderLayout());
175 content.setBorder(STANDARD_BORDER);
177 JTabbedPane tabs = createTabs();
178 content.add(tabs);
179 setContentPane(content);
181 pack();
186 * Returns the preferred size for the about frame.
188 * @return the preferred size.
190 public Dimension getPreferredSize() {
191 return PREFERRED_SIZE;
195 * Creates a tabbed pane containing an about panel and a system properties panel.
197 * @return a tabbed pane.
199 private JTabbedPane createTabs() {
201 JTabbedPane tabs = new JTabbedPane();
203 JPanel aboutPanel = createAboutPanel();
204 aboutPanel.setBorder(AboutFrame.STANDARD_BORDER);
205 String aboutTab = this.resources.getString("about-frame.tab.about");
206 tabs.add(aboutTab, aboutPanel);
208 JPanel systemPanel = new SystemPropertiesPanel();
209 systemPanel.setBorder(AboutFrame.STANDARD_BORDER);
210 String systemTab = this.resources.getString("about-frame.tab.system");
211 tabs.add(systemTab, systemPanel);
213 return tabs;
218 * Creates a panel showing information about the application, including the name, version,
219 * copyright notice, URL for further information, and a list of contributors.
221 * @return a panel.
223 private JPanel createAboutPanel() {
225 JPanel about = new JPanel(new BorderLayout());
227 JPanel details = new DmcAboutPanel(this.application, this.version, this.copyright, this.info,
228 this.logo);
230 boolean includetabs = false;
231 JTabbedPane tabs = new JTabbedPane();
233 if (this.contributors != null) {
234 JPanel contributorsPanel = new ContributorsPanel(this.contributors);
235 contributorsPanel.setBorder(AboutFrame.STANDARD_BORDER);
236 String contributorsTab = this.resources.getString("about-frame.tab.contributors");
237 tabs.add(contributorsTab, contributorsPanel);
238 includetabs = true;
241 if (this.licence != null) {
242 JPanel licencePanel = createLicencePanel();
243 licencePanel.setBorder(STANDARD_BORDER);
244 String licenceTab = this.resources.getString("about-frame.tab.licence");
245 tabs.add(licenceTab, licencePanel);
246 includetabs = true;
249 if (this.libraries != null) {
250 JPanel librariesPanel = new LibraryPanel(this.libraries);
251 librariesPanel.setBorder(AboutFrame.STANDARD_BORDER);
252 String librariesTab = this.resources.getString("about-frame.tab.libraries");
253 tabs.add(librariesTab, librariesPanel);
254 includetabs = true;
257 about.add(details, BorderLayout.NORTH);
258 if (includetabs) {
259 about.add(tabs);
262 return about;
267 * Creates a panel showing the licence.
269 * @return a panel.
271 private JPanel createLicencePanel() {
273 JPanel licencePanel = new JPanel(new BorderLayout());
274 JTextArea area = new JTextArea(this.licence);
275 area.setLineWrap(true);
276 area.setWrapStyleWord(true);
277 area.setCaretPosition(0);
278 area.setEditable(false);
279 licencePanel.add(new JScrollPane(area));
280 return licencePanel;