View Javadoc

1   package edu.sc.seis.TauP;
2   
3   import javax.swing.table.AbstractTableModel;
4   
5   /*
6     The TauP Toolkit: Flexible Seismic Travel-Time and Raypath Utilities.
7     Copyright (C) 1998-2000 University of South Carolina
8   
9     This program is free software; you can redistribute it and/or
10    modify it under the terms of the GNU General Public License
11    as published by the Free Software Foundation; either version 2
12    of the License, or (at your option) any later version.
13  
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18  
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22  
23    The current version can be found at 
24    <A HREF="www.seis.sc.edu">http://www.seis.sc.edu</A>
25  
26    Bug reports and comments should be directed to 
27    H. Philip Crotwell, crotwell@seis.sc.edu or
28    Tom Owens, owens@seis.sc.edu
29  
30  */
31  
32  
33  /***
34  * @author H. Philip Crotwell
35  * @version 1.1.3 Wed Jul 18 15:00:35 GMT 2001
36  
37  
38  
39  */
40  public class ArrivalTableModel extends AbstractTableModel {
41  
42  
43      protected Arrival[] arrivals = new Arrival[0];
44  
45      public ArrivalTableModel() {
46  
47      }
48  
49      public int getRowCount() {
50          return arrivals.length;
51      }
52  
53      public int getColumnCount() {
54          return 8;
55      }
56  
57      public Object getValueAt(int row, int col) {
58          switch (col) {
59          case 0:
60              return float8_1.form(arrivals[row].getModuloDistDeg());
61  	case 1:
62  	    return float8_1.form(arrivals[row].getModuloDist() * 
63  				 arrivals[row].getPhase().getTauModel().getRadiusOfEarth());
64          case 2:
65              return float8_1.form(arrivals[row].getSourceDepth());
66          case 3:
67              return arrivals[row].getName();
68          case 4:
69              return float8_2.form(arrivals[row].getTime());
70          case 5:
71              return float8_3.form(Math.PI/180.0*arrivals[row].getRayParam());
72          case 6:
73              return float8_1.form(arrivals[row].getDistDeg());
74          case 7:
75              return (arrivals[row].getName().equals(arrivals[row].getPuristName()) ? "=" : "*");
76          case 8:
77              return arrivals[row].getPuristName();
78          default:
79              return "";
80          }
81      }
82  
83      public String getColumnName(int col) {
84          switch (col) {
85          case 0:
86              return "Dist";
87          case 1:
88  	    return "Dist (km)";
89  	case 2:
90              return "Depth";
91          case 3:
92              return "Name";
93          case 4:
94              return "Time";
95          case 5:
96              return "Ray Param";
97          case 6:
98              return "Purist Dist";
99          case 7:
100             return "";
101         case 8:
102             return "Purist Name";
103         default:
104             return "";
105         }
106     }
107 
108     public void setArrivals(Arrival[] arrivals) {
109         this.arrivals = arrivals;
110         fireTableDataChanged();
111     }
112 
113     private static Format float6_1 = new Format("%6.1f");
114     private static Format float8_1 = new Format("%8.1f");
115     private static Format float8_2 = new Format("%8.2f");
116     private static Format float8_3 = new Format("%8.3f");
117     private static Format float8_4 = new Format("%8.4f");
118 }