001package jmri; 002 003/** 004 * A lightweight class that provides a methods to retrieve the current JMRI 005 * application name and icon. 006 * <p> 007 * The current name is set when a given JMRI application is launched. 008 * <hr> 009 * This file is part of JMRI. 010 * <p> 011 * JMRI is free software; you can redistribute it and/or modify it under the 012 * terms of version 2 of the GNU General Public License as published by the Free 013 * Software Foundation. See the "COPYING" file for a copy of this license. 014 * <p> 015 * JMRI is distributed in the hope that it will be useful, but WITHOUT ANY 016 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 017 * A PARTICULAR PURPOSE. See the GNU General Public License for more details. 018 * 019 * @author Matthew Harris Copyright (C) 2011 020 */ 021public class Application { 022 023 private static String name = null; 024 private static String logo = "resources/logo.gif"; 025 private static String URL = "http://jmri.org"; 026 027 /** 028 * Return the current JMRI application name. 029 * 030 * @return String containing JMRI application name or "JMRI" if name has not 031 * been set. 032 */ 033 public static String getApplicationName() { 034 if (Application.name == null) { 035 return "JMRI"; 036 } 037 return Application.name; 038 } 039 040 /** 041 * Set the current JMRI application name. 042 * 043 * @param applicationName String containing the JMRI application name 044 * @throws IllegalAccessException if attempting to modify once set 045 * @throws IllegalArgumentException if a null name passed 046 */ 047 public static void setApplicationName(String applicationName) throws IllegalAccessException, IllegalArgumentException { 048 if (Application.name == null) { 049 if (applicationName != null) { 050 Application.name = applicationName; 051 } else { 052 throw new IllegalArgumentException("Application name cannot be null."); 053 } 054 } else { 055 throw new IllegalAccessException("Application name cannot be modified once set."); 056 } 057 } 058 059 /** 060 * Return the current JMRI application logo path. This path is relative to 061 * the JMRI application installation path. If the application does not have 062 * its own icon, return the JMRI default icon. 063 * 064 * @return String containing the application icon path 065 */ 066 public static String getLogo() { 067 return logo; 068 } 069 070 /** 071 * Set the current JMRI application logo path. 072 * 073 * @param logo String with the relative path to the JMRI application icon 074 */ 075 public static void setLogo(String logo) { 076 if (logo == null) { 077 logo = "resources/logo.gif"; 078 } 079 Application.logo = logo; 080 } 081 082 /** 083 * @return the URL 084 */ 085 public static String getURL() { 086 return Application.URL; 087 } 088 089 /** 090 * @param URL the URL to set 091 */ 092 public static void setURL(String URL) { 093 if (URL == null) { 094 URL = "http://jmri.org"; 095 } 096 Application.URL = URL; 097 } 098 099}