View Javadoc

1   /*
2     The TauP Toolkit: Flexible Seismic Travel-Time and Raypath Utilities.
3     Copyright (C) 1998-2000 University of South Carolina
4   
5     This program is free software; you can redistribute it and/or
6     modify it under the terms of the GNU General Public License
7     as published by the Free Software Foundation; either version 2
8     of the License, or (at your option) any later version.
9   
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14  
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18  
19    The current version can be found at 
20    <A HREF="www.seis.sc.edu">http://www.seis.sc.edu</A>
21  
22    Bug reports and comments should be directed to 
23    H. Philip Crotwell, crotwell@seis.sc.edu or
24    Tom Owens, owens@seis.sc.edu
25  
26  */
27   
28   
29  package edu.sc.seis.TauP;
30   
31  /***
32    * Displays a message to the user depending on whether there is a GUI or not.
33    *
34    * @version 1.1.3 Wed Jul 18 15:00:35 GMT 2001
35  
36  
37  
38    * @author H. Philip Crotwell
39    *
40    */
41  public class Alert {
42  
43      /*** the machine/OS dependent line terminator, ie \r \r\n or \n. */
44      static String nl = System.getProperty("line.separator");
45  
46      /*** Whether or not a GUI is being used. */
47      static private boolean GUI = false;
48   
49      private Alert() {
50      }
51   	
52      /* reports information in a manner consistant with
53       * the current usage, ie GUI or command line. */
54      public static void info(String message) {
55          if (GUI) {
56              System.out.println(message);
57          } else {
58              System.out.println(message);
59          }
60      } 	
61      /* reports non fatal errors in a manner consistant with
62       * the current usage, ie GUI or command line. */
63      public static void warning(String message, String extra) {
64          if (GUI) {
65              System.err.println("Warning: "+message+ nl +extra);
66          } else {
67              System.err.println("Warning: "+message+ nl +extra);
68          }
69      }
70   
71      /* reports fatal errors in a manner consistant with
72       * the current usage, ie GUI or command line. */
73      public static void error(String message, String extra) {
74          if (GUI) {
75              System.err.println("Error: "+message+ nl +extra);
76          } else {
77              System.err.println("Error: "+message+ nl +extra);
78          }
79      }
80     
81      
82      public static void setGUI(boolean newGUI) {
83          GUI = newGUI;
84      }
85  }
86