001/* ======================================================================== 002 * JCommon : a free general purpose class library for the Java(tm) platform 003 * ======================================================================== 004 * 005 * (C) Copyright 2000-2008, 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-2008, by Object Refinery Limited. 031 * 032 * Original Author: David Gilbert (for Object Refinery Limited); 033 * Contributor(s): -; 034 * 035 * $Id: AboutFrame.java,v 1.8 2008/12/18 09:57:32 mungady 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 043 * localisation (DG); 044 * 25-Mar-2002 : Added new constructor (DG); 045 * 26-Jun-2002 : Removed redundant code (DG); 046 * 08-Oct-2002 : Fixed errors reported by Checkstyle (DG); 047 * 18-Dec-2008 : Use ResourceBundleWrapper - see JFreeChart patch 1607918 by 048 * Jess Thrysoee (DG); 049 * 050 */ 051 052package org.jfree.ui.about; 053 054import java.awt.BorderLayout; 055import java.awt.Dimension; 056import java.awt.Image; 057import java.util.List; 058import java.util.ResourceBundle; 059 060import javax.swing.BorderFactory; 061import javax.swing.JFrame; 062import javax.swing.JPanel; 063import javax.swing.JScrollPane; 064import javax.swing.JTabbedPane; 065import javax.swing.JTextArea; 066import javax.swing.border.Border; 067 068import org.jfree.util.ResourceBundleWrapper; 069 070/** 071 * A frame that displays information about the demonstration application. 072 * 073 * @author David Gilbert 074 */ 075public class AboutFrame extends JFrame { 076 077 /** The preferred size for the frame. */ 078 public static final Dimension PREFERRED_SIZE = new Dimension(560, 360); 079 080 /** The default border for the panels in the tabbed pane. */ 081 public static final Border STANDARD_BORDER 082 = BorderFactory.createEmptyBorder(5, 5, 5, 5); 083 084 /** Localised resources. */ 085 private ResourceBundle resources; 086 087 /** The application name. */ 088 private String application; 089 090 /** The application version. */ 091 private String version; 092 093 /** The copyright string. */ 094 private String copyright; 095 096 /** Other info about the application. */ 097 private String info; 098 099 /** The project logo. */ 100 private Image logo; 101 102 /** A list of contributors. */ 103 private List contributors; 104 105 /** The licence. */ 106 private String licence; 107 108 /** 109 * Constructs an about frame. 110 * 111 * @param title the frame title. 112 * @param project information about the project. 113 */ 114 public AboutFrame(final String title, final ProjectInfo project) { 115 116 this(title, 117 project.getName(), 118 "Version " + project.getVersion(), 119 project.getInfo(), 120 project.getLogo(), 121 project.getCopyright(), 122 project.getLicenceText(), 123 project.getContributors(), 124 project); 125 126 } 127 128 /** 129 * Constructs an 'About' frame. 130 * 131 * @param title the frame title. 132 * @param application the application name. 133 * @param version the version. 134 * @param info other info. 135 * @param logo an optional logo. 136 * @param copyright the copyright notice. 137 * @param licence the licence. 138 * @param contributors a list of developers/contributors. 139 * @param project info about the project. 140 */ 141 public AboutFrame(final String title, 142 final String application, final String version, 143 final String info, 144 final Image logo, 145 final String copyright, final String licence, 146 final List contributors, 147 final ProjectInfo project) { 148 149 super(title); 150 151 this.application = application; 152 this.version = version; 153 this.copyright = copyright; 154 this.info = info; 155 this.logo = logo; 156 this.contributors = contributors; 157 this.licence = licence; 158 159 final String baseName = "org.jfree.ui.about.resources.AboutResources"; 160 this.resources = ResourceBundleWrapper.getBundle(baseName); 161 162 final JPanel content = new JPanel(new BorderLayout()); 163 content.setBorder(STANDARD_BORDER); 164 165 final JTabbedPane tabs = createTabs(project); 166 content.add(tabs); 167 setContentPane(content); 168 169 pack(); 170 171 } 172 173 /** 174 * Returns the preferred size for the about frame. 175 * 176 * @return the preferred size. 177 */ 178 public Dimension getPreferredSize() { 179 return PREFERRED_SIZE; 180 } 181 182 /** 183 * Creates a tabbed pane containing an about panel and a system properties 184 * panel. 185 * 186 * @return a tabbed pane. 187 * @param project 188 */ 189 private JTabbedPane createTabs(final ProjectInfo project) { 190 191 final JTabbedPane tabs = new JTabbedPane(); 192 193 final JPanel aboutPanel = createAboutPanel(project); 194 aboutPanel.setBorder(AboutFrame.STANDARD_BORDER); 195 final String aboutTab = this.resources.getString( 196 "about-frame.tab.about"); 197 tabs.add(aboutTab, aboutPanel); 198 199 final JPanel systemPanel = new SystemPropertiesPanel(); 200 systemPanel.setBorder(AboutFrame.STANDARD_BORDER); 201 final String systemTab = this.resources.getString( 202 "about-frame.tab.system"); 203 tabs.add(systemTab, systemPanel); 204 205 return tabs; 206 207 } 208 209 /** 210 * Creates a panel showing information about the application, including the 211 * name, version, copyright notice, URL for further information, and a list 212 * of contributors. 213 214 * @param project 215 * 216 * @return a panel. 217 */ 218 private JPanel createAboutPanel(final ProjectInfo project) { 219 220 final JPanel about = new JPanel(new BorderLayout()); 221 222 final JPanel details = new AboutPanel(this.application, this.version, 223 this.copyright, this.info, this.logo); 224 225 boolean includetabs = false; 226 final JTabbedPane tabs = new JTabbedPane(); 227 228 if (this.contributors != null) { 229 final JPanel contributorsPanel = new ContributorsPanel( 230 this.contributors); 231 contributorsPanel.setBorder(AboutFrame.STANDARD_BORDER); 232 final String contributorsTab = this.resources.getString( 233 "about-frame.tab.contributors"); 234 tabs.add(contributorsTab, contributorsPanel); 235 includetabs = true; 236 } 237 238 if (this.licence != null) { 239 final JPanel licencePanel = createLicencePanel(); 240 licencePanel.setBorder(STANDARD_BORDER); 241 final String licenceTab = this.resources.getString( 242 "about-frame.tab.licence"); 243 tabs.add(licenceTab, licencePanel); 244 includetabs = true; 245 } 246 247 if (project != null) { 248 final JPanel librariesPanel = new LibraryPanel(project); 249 librariesPanel.setBorder(AboutFrame.STANDARD_BORDER); 250 final String librariesTab = this.resources.getString( 251 "about-frame.tab.libraries"); 252 tabs.add(librariesTab, librariesPanel); 253 includetabs = true; 254 } 255 256 about.add(details, BorderLayout.NORTH); 257 if (includetabs) { 258 about.add(tabs); 259 } 260 261 return about; 262 263 } 264 265 /** 266 * Creates a panel showing the licence. 267 * 268 * @return a panel. 269 */ 270 private JPanel createLicencePanel() { 271 272 final JPanel licencePanel = new JPanel(new BorderLayout()); 273 final JTextArea area = new JTextArea(this.licence); 274 area.setLineWrap(true); 275 area.setWrapStyleWord(true); 276 area.setCaretPosition(0); 277 area.setEditable(false); 278 licencePanel.add(new JScrollPane(area)); 279 return licencePanel; 280 281 } 282 283 284}