upgraded idmclib version to 0.2.0
[iDMC.git] / src / java / org / tsho / dmc2 / ui / DmcAboutFrame.java
blob94e764524359a33b9a13c77bfea81be518a2e9de
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 + "The software program was developed within a research project financed "
49 + "by the Italian Ministry of Universities, the Universities of Udine and "
50 + "Ca'Foscari of Venice, the Friuli-Venezia Giulia Region.";
54 DmcAboutFrame() {
55 this("iDmc", new DmcDueInfo());
58 static class DmcDueInfo extends ProjectInfo {
60 public DmcDueInfo() {
61 setName(DmcDue.Defaults.name);
62 setVersion(DmcDue.Defaults.version);
63 setInfo(myInfo);
64 setCopyright("Copyright 2004-2007 Marji Lines and Alfredo Medio");
65 setLogo(null);
66 setLicenceName("GPL");
67 setLicenceText(Licences.getInstance().getGPL());
69 setContributors(Arrays.asList(
70 new Contributor[]{
71 new Contributor("Daniele Pizzoni", "auouo@tin.it"),
72 new Contributor("Alexei Grigoriev","alexei_grigoriev@libero.it"),
73 new Contributor("Antonio, Fabio Di Narzo", "antonio.fabio@gmail.com")
75 ));
77 setLibraries(Arrays.asList(
78 new Library[]{
79 new Library(JFreeChart.INFO),
80 new Library(JCommon.INFO),
81 new Library("JGoodies Forms", "1.0.3", "BSD", "http://www.jgoodies.com/"),
82 new Library("idmclib", "0.2.0", "GPL", ""),
84 ));
90 /** The preferred size for the frame. */
91 public static final Dimension PREFERRED_SIZE = new Dimension(560, 360);
93 /** The default border for the panels in the tabbed pane. */
94 public static final Border STANDARD_BORDER = BorderFactory.createEmptyBorder(5, 5, 5, 5);
96 /** Localised resources. */
97 private ResourceBundle resources;
99 /** The application name. */
100 private String application;
102 /** The application version. */
103 private String version;
105 /** The copyright string. */
106 private String copyright;
108 /** Other info about the application. */
109 private String info;
111 /** The project logo. */
112 private Image logo;
114 /** A list of contributors. */
115 private List contributors;
117 /** The licence. */
118 private String licence;
120 /** A list of libraries. */
121 private List libraries;
124 * Constructs an about frame.
126 * @param title the frame title.
127 * @param project information about the project.
129 public DmcAboutFrame(String title, ProjectInfo project) {
131 this(title,
132 project.getName(),
133 "Version " + project.getVersion(),
134 project.getInfo(),
135 project.getLogo(),
136 project.getCopyright(),
137 project.getLicenceText(),
138 project.getContributors(),
139 project.getLibraries());
144 * Constructs an 'About' frame.
146 * @param title the frame title.
147 * @param application the application name.
148 * @param version the version.
149 * @param info other info.
150 * @param logo an optional logo.
151 * @param copyright the copyright notice.
152 * @param licence the licence.
153 * @param contributors a list of developers/contributors.
154 * @param libraries a list of libraries.
156 public DmcAboutFrame(String title,
157 String application, String version, String info,
158 Image logo,
159 String copyright, String licence,
160 List contributors,
161 List libraries) {
163 super(title);
165 this.application = application;
166 this.version = version;
167 this.copyright = copyright;
168 this.info = info;
169 this.logo = logo;
170 this.contributors = contributors;
171 this.licence = licence;
172 this.libraries = libraries;
174 String baseName = "org.jfree.ui.about.resources.AboutResources";
175 this.resources = ResourceBundle.getBundle(baseName);
177 JPanel content = new JPanel(new BorderLayout());
178 content.setBorder(STANDARD_BORDER);
180 JTabbedPane tabs = createTabs();
181 content.add(tabs);
182 setContentPane(content);
184 pack();
189 * Returns the preferred size for the about frame.
191 * @return the preferred size.
193 public Dimension getPreferredSize() {
194 return PREFERRED_SIZE;
198 * Creates a tabbed pane containing an about panel and a system properties panel.
200 * @return a tabbed pane.
202 private JTabbedPane createTabs() {
204 JTabbedPane tabs = new JTabbedPane();
206 JPanel aboutPanel = createAboutPanel();
207 aboutPanel.setBorder(AboutFrame.STANDARD_BORDER);
208 String aboutTab = this.resources.getString("about-frame.tab.about");
209 tabs.add(aboutTab, aboutPanel);
211 JPanel systemPanel = new SystemPropertiesPanel();
212 systemPanel.setBorder(AboutFrame.STANDARD_BORDER);
213 String systemTab = this.resources.getString("about-frame.tab.system");
214 tabs.add(systemTab, systemPanel);
216 return tabs;
221 * Creates a panel showing information about the application, including the name, version,
222 * copyright notice, URL for further information, and a list of contributors.
224 * @return a panel.
226 private JPanel createAboutPanel() {
228 JPanel about = new JPanel(new BorderLayout());
230 JPanel details = new DmcAboutPanel(this.application, this.version, this.copyright, this.info,
231 this.logo);
233 boolean includetabs = false;
234 JTabbedPane tabs = new JTabbedPane();
236 if (this.contributors != null) {
237 JPanel contributorsPanel = new ContributorsPanel(this.contributors);
238 contributorsPanel.setBorder(AboutFrame.STANDARD_BORDER);
239 String contributorsTab = this.resources.getString("about-frame.tab.contributors");
240 tabs.add(contributorsTab, contributorsPanel);
241 includetabs = true;
244 if (this.licence != null) {
245 JPanel licencePanel = createLicencePanel();
246 licencePanel.setBorder(STANDARD_BORDER);
247 String licenceTab = this.resources.getString("about-frame.tab.licence");
248 tabs.add(licenceTab, licencePanel);
249 includetabs = true;
252 if (this.libraries != null) {
253 JPanel librariesPanel = new LibraryPanel(this.libraries);
254 librariesPanel.setBorder(AboutFrame.STANDARD_BORDER);
255 String librariesTab = this.resources.getString("about-frame.tab.libraries");
256 tabs.add(librariesTab, librariesPanel);
257 includetabs = true;
260 about.add(details, BorderLayout.NORTH);
261 if (includetabs) {
262 about.add(tabs);
265 return about;
270 * Creates a panel showing the licence.
272 * @return a panel.
274 private JPanel createLicencePanel() {
276 JPanel licencePanel = new JPanel(new BorderLayout());
277 JTextArea area = new JTextArea(this.licence);
278 area.setLineWrap(true);
279 area.setWrapStyleWord(true);
280 area.setCaretPosition(0);
281 area.setEditable(false);
282 licencePanel.add(new JScrollPane(area));
283 return licencePanel;