001: /* ========================================================================
002: * JCommon : a free general purpose class library for the Java(tm) platform
003: * ========================================================================
004: *
005: * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
006: *
007: * Project Info: http://www.jfree.org/jcommon/index.html
008: *
009: * This library is free software; you can redistribute it and/or modify it
010: * under the terms of the GNU Lesser General Public License as published by
011: * the Free Software Foundation; either version 2.1 of the License, or
012: * (at your option) any later version.
013: *
014: * This library is distributed in the hope that it will be useful, but
015: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
016: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
017: * License for more details.
018: *
019: * You should have received a copy of the GNU Lesser General Public
020: * License along with this library; if not, write to the Free Software
021: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
022: * USA.
023: *
024: * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
025: * in the United States and other countries.]
026: *
027: * ---------------
028: * AboutFrame.java
029: * ---------------
030: * (C) Copyright 2001-2004, by Object Refinery Limited.
031: *
032: * Original Author: David Gilbert (for Object Refinery Limited);
033: * Contributor(s): -;
034: *
035: * $Id: AboutFrame.java,v 1.6 2006/03/23 19:47:05 taqua Exp $
036: *
037: * Changes (from 26-Nov-2001)
038: * --------------------------
039: * 26-Nov-2001 : Version 1, based on code from JFreeChart demo application (DG);
040: * 27-Nov-2001 : Added getPreferredSize() method (DG);
041: * 08-Feb-2002 : List of developers is now optional (DG);
042: * 15-Mar-2002 : Modified to use a ResourceBundle for elements that require localisation (DG);
043: * 25-Mar-2002 : Added new constructor (DG);
044: * 26-Jun-2002 : Removed redundant code (DG);
045: * 08-Oct-2002 : Fixed errors reported by Checkstyle (DG);
046: *
047: */
048:
049: package org.jfree.ui.about;
050:
051: import java.awt.BorderLayout;
052: import java.awt.Dimension;
053: import java.awt.Image;
054: import java.util.List;
055: import java.util.ResourceBundle;
056: import javax.swing.BorderFactory;
057: import javax.swing.JFrame;
058: import javax.swing.JPanel;
059: import javax.swing.JScrollPane;
060: import javax.swing.JTabbedPane;
061: import javax.swing.JTextArea;
062: import javax.swing.border.Border;
063:
064: /**
065: * A frame that displays information about the demonstration application.
066: *
067: * @author David Gilbert
068: */
069: public class AboutFrame extends JFrame {
070:
071: /** The preferred size for the frame. */
072: public static final Dimension PREFERRED_SIZE = new Dimension(560,
073: 360);
074:
075: /** The default border for the panels in the tabbed pane. */
076: public static final Border STANDARD_BORDER = BorderFactory
077: .createEmptyBorder(5, 5, 5, 5);
078:
079: /** Localised resources. */
080: private ResourceBundle resources;
081:
082: /** The application name. */
083: private String application;
084:
085: /** The application version. */
086: private String version;
087:
088: /** The copyright string. */
089: private String copyright;
090:
091: /** Other info about the application. */
092: private String info;
093:
094: /** The project logo. */
095: private Image logo;
096:
097: /** A list of contributors. */
098: private List contributors;
099:
100: /** The licence. */
101: private String licence;
102:
103: /**
104: * Constructs an about frame.
105: *
106: * @param title the frame title.
107: * @param project information about the project.
108: */
109: public AboutFrame(final String title, final ProjectInfo project) {
110:
111: this (title, project.getName(), "Version "
112: + project.getVersion(), project.getInfo(), project
113: .getLogo(), project.getCopyright(), project
114: .getLicenceText(), project.getContributors(), project);
115:
116: }
117:
118: /**
119: * Constructs an 'About' frame.
120: *
121: * @param title the frame title.
122: * @param application the application name.
123: * @param version the version.
124: * @param info other info.
125: * @param logo an optional logo.
126: * @param copyright the copyright notice.
127: * @param licence the licence.
128: * @param contributors a list of developers/contributors.
129: * @param libraries a list of libraries.
130: */
131: public AboutFrame(final String title, final String application,
132: final String version, final String info, final Image logo,
133: final String copyright, final String licence,
134: final List contributors, final ProjectInfo project) {
135:
136: super (title);
137:
138: this .application = application;
139: this .version = version;
140: this .copyright = copyright;
141: this .info = info;
142: this .logo = logo;
143: this .contributors = contributors;
144: this .licence = licence;
145:
146: final String baseName = "org.jfree.ui.about.resources.AboutResources";
147: this .resources = ResourceBundle.getBundle(baseName);
148:
149: final JPanel content = new JPanel(new BorderLayout());
150: content.setBorder(STANDARD_BORDER);
151:
152: final JTabbedPane tabs = createTabs(project);
153: content.add(tabs);
154: setContentPane(content);
155:
156: pack();
157:
158: }
159:
160: /**
161: * Returns the preferred size for the about frame.
162: *
163: * @return the preferred size.
164: */
165: public Dimension getPreferredSize() {
166: return PREFERRED_SIZE;
167: }
168:
169: /**
170: * Creates a tabbed pane containing an about panel and a system properties panel.
171: *
172: * @return a tabbed pane.
173: * @param project
174: */
175: private JTabbedPane createTabs(final ProjectInfo project) {
176:
177: final JTabbedPane tabs = new JTabbedPane();
178:
179: final JPanel aboutPanel = createAboutPanel(project);
180: aboutPanel.setBorder(AboutFrame.STANDARD_BORDER);
181: final String aboutTab = this .resources
182: .getString("about-frame.tab.about");
183: tabs.add(aboutTab, aboutPanel);
184:
185: final JPanel systemPanel = new SystemPropertiesPanel();
186: systemPanel.setBorder(AboutFrame.STANDARD_BORDER);
187: final String systemTab = this .resources
188: .getString("about-frame.tab.system");
189: tabs.add(systemTab, systemPanel);
190:
191: return tabs;
192:
193: }
194:
195: /**
196: * Creates a panel showing information about the application, including the name, version,
197: * copyright notice, URL for further information, and a list of contributors.
198: *
199: * @return a panel.
200: * @param project
201: */
202: private JPanel createAboutPanel(final ProjectInfo project) {
203:
204: final JPanel about = new JPanel(new BorderLayout());
205:
206: final JPanel details = new AboutPanel(this .application,
207: this .version, this .copyright, this .info, this .logo);
208:
209: boolean includetabs = false;
210: final JTabbedPane tabs = new JTabbedPane();
211:
212: if (this .contributors != null) {
213: final JPanel contributorsPanel = new ContributorsPanel(
214: this .contributors);
215: contributorsPanel.setBorder(AboutFrame.STANDARD_BORDER);
216: final String contributorsTab = this .resources
217: .getString("about-frame.tab.contributors");
218: tabs.add(contributorsTab, contributorsPanel);
219: includetabs = true;
220: }
221:
222: if (this .licence != null) {
223: final JPanel licencePanel = createLicencePanel();
224: licencePanel.setBorder(STANDARD_BORDER);
225: final String licenceTab = this .resources
226: .getString("about-frame.tab.licence");
227: tabs.add(licenceTab, licencePanel);
228: includetabs = true;
229: }
230:
231: if (project != null) {
232: final JPanel librariesPanel = new LibraryPanel(project);
233: librariesPanel.setBorder(AboutFrame.STANDARD_BORDER);
234: final String librariesTab = this .resources
235: .getString("about-frame.tab.libraries");
236: tabs.add(librariesTab, librariesPanel);
237: includetabs = true;
238: }
239:
240: about.add(details, BorderLayout.NORTH);
241: if (includetabs) {
242: about.add(tabs);
243: }
244:
245: return about;
246:
247: }
248:
249: /**
250: * Creates a panel showing the licence.
251: *
252: * @return a panel.
253: */
254: private JPanel createLicencePanel() {
255:
256: final JPanel licencePanel = new JPanel(new BorderLayout());
257: final JTextArea area = new JTextArea(this .licence);
258: area.setLineWrap(true);
259: area.setWrapStyleWord(true);
260: area.setCaretPosition(0);
261: area.setEditable(false);
262: licencePanel.add(new JScrollPane(area));
263: return licencePanel;
264:
265: }
266:
267: }
|