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 * ProjectInfo.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: ProjectInfo.java,v 1.5 2005/11/16 15:58:41 taqua Exp $ 036 * 037 * Changes (since 27-Jun-2002) 038 * --------------------------- 039 * 27-Jun-2002 : Added logo, updated source header and Javadocs (DG); 040 * 08-Oct-2002 : Added set methods for most attributes. Fixed errors reported by Checkstyle (DG); 041 * 042 */ 043 044package org.jfree.ui.about; 045 046import java.awt.Image; 047import java.util.Iterator; 048import java.util.List; 049 050import org.jfree.base.BootableProjectInfo; 051import org.jfree.base.Library; 052 053/** 054 * A class for recording the basic information about a free or open source software project. 055 * 056 * @author David Gilbert 057 */ 058public class ProjectInfo extends BootableProjectInfo { 059 060 /** An optional project logo. */ 061 private Image logo; 062 063 /** The licence text. */ 064 private String licenceText; 065 066 /** A list of contributors. */ 067 private List contributors; 068 069 /** 070 * Constructs an empty project info object. 071 */ 072 public ProjectInfo() { 073 // nothing required 074 } 075 076 /** 077 * Constructs a project info object. 078 * 079 * @param name the name of the project. 080 * @param version the version. 081 * @param info other info (usually a URL). 082 * @param logo the project logo. 083 * @param copyright a copyright statement. 084 * @param licenceName the name of the licence that applies to the project. 085 * @param licenceText the text of the licence that applies to the project. 086 */ 087 public ProjectInfo(final String name, 088 final String version, 089 final String info, 090 final Image logo, 091 final String copyright, 092 final String licenceName, 093 final String licenceText) { 094 095 super(name, version, info, copyright, licenceName); 096 this.logo = logo; 097 this.licenceText = licenceText; 098 099 } 100 101 /** 102 * Returns the logo. 103 * 104 * @return the project logo. 105 */ 106 public Image getLogo() { 107 return this.logo; 108 } 109 110 /** 111 * Sets the project logo. 112 * 113 * @param logo the project logo. 114 */ 115 public void setLogo(final Image logo) { 116 this.logo = logo; 117 } 118 119 /** 120 * Returns the licence text. 121 * 122 * @return the licence text. 123 */ 124 public String getLicenceText() { 125 return this.licenceText; 126 } 127 128 /** 129 * Sets the project licence text. 130 * 131 * @param licenceText the licence text. 132 */ 133 public void setLicenceText(final String licenceText) { 134 this.licenceText = licenceText; 135 } 136 137 /** 138 * Returns the list of contributors for the project. 139 * 140 * @return the list of contributors. 141 */ 142 public List getContributors() { 143 return this.contributors; 144 } 145 146 /** 147 * Sets the list of contributors. 148 * 149 * @param contributors the list of contributors. 150 */ 151 public void setContributors(final List contributors) { 152 this.contributors = contributors; 153 } 154 155 /** 156 * Returns a string describing the project. 157 * 158 * @return a string describing the project. 159 */ 160 public String toString() { 161 162 final StringBuffer result = new StringBuffer(); 163 result.append(getName()); 164 result.append(" version "); 165 result.append(getVersion()); 166 result.append(".\n"); 167 result.append(getCopyright()); 168 result.append(".\n"); 169 result.append("\n"); 170 result.append("For terms of use, see the licence below.\n"); 171 result.append("\n"); 172 result.append("FURTHER INFORMATION:"); 173 result.append(getInfo()); 174 result.append("\n"); 175 result.append("CONTRIBUTORS:"); 176 if (this.contributors != null) { 177 final Iterator iterator = this.contributors.iterator(); 178 while (iterator.hasNext()) { 179 final Contributor contributor = (Contributor) iterator.next(); 180 result.append(contributor.getName()); 181 result.append(" ("); 182 result.append(contributor.getEmail()); 183 result.append(")."); 184 } 185 } 186 else { 187 result.append("None"); 188 } 189 190 result.append("\n"); 191 result.append("OTHER LIBRARIES USED BY "); 192 result.append(getName()); 193 result.append(":"); 194 final Library[] libraries = getLibraries(); 195 if (libraries.length != 0) { 196 for (int i = 0; i < libraries.length; i++) { 197 final Library lib = libraries[i]; 198 result.append(lib.getName()); 199 result.append(" "); 200 result.append(lib.getVersion()); 201 result.append(" ("); 202 result.append(lib.getInfo()); 203 result.append(")."); 204 } 205 } 206 else { 207 result.append("None"); 208 } 209 result.append("\n"); 210 result.append(getName()); 211 result.append(" LICENCE TERMS:"); 212 result.append("\n"); 213 result.append(getLicenceText()); 214 215 return result.toString(); 216 217 } 218 219}