1
2 package edu.sc.seis.TauP;
3
4 import javax.swing.table.AbstractTableModel;
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33 /***
34 * PierceTableModel
35 *
36 *
37 * Created: Thu May 6 14:42:17 1999
38 *
39 * @author Philip Crotwell
40 * @version 1.1.3 Wed Jul 18 15:00:35 GMT 2001
41
42
43
44 */
45
46 public class PierceTableModel extends AbstractTableModel {
47
48 public PierceTableModel() {
49
50 }
51
52 public int getRowCount() {
53 if (arrivals.length != 0) {
54 return arrivals[selectedIndex].getNumPiercePoints();
55 } else {
56 return 0;
57 }
58 }
59
60 public int getColumnCount() {
61 return 2;
62 }
63
64 public Object getValueAt(int row, int col) {
65 switch (col) {
66 case 0:
67 double dist = (180.0/Math.PI*
68 arrivals[selectedIndex].getPiercePoint(row).dist);
69 if (arrivals[selectedIndex].getDistDeg() % 360 > 180 &&
70 dist != 0.0) {
71 dist *= -1.0;
72 }
73 return float8_2.form(dist);
74 case 1:
75 return float8_2.form(arrivals[selectedIndex].getPiercePoint(row).depth);
76 default:
77 return "";
78 }
79 }
80
81 public String getColumnName(int col) {
82 switch (col) {
83 case 0:
84 return "Dist";
85 case 1:
86 return "Depth";
87 default:
88 return "";
89 }
90 }
91
92 public void setArrivals(Arrival[] arrivals) {
93 this.arrivals = arrivals;
94 setSelectedIndex(0);
95
96 fireTableDataChanged();
97 }
98
99 public void setSelectedIndex(int index) {
100 this.selectedIndex = index;
101 fireTableDataChanged();
102 }
103
104 private int selectedIndex = 0;
105 private Arrival[] arrivals = new Arrival[0];
106
107 private static Format float8_2 = new Format("%8.2f");
108
109 }