1 package edu.sc.seis.TauP;
2
3 import java.awt.Color;
4 import java.awt.Graphics;
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 * PathPlot.java
35 *
36 *
37 * Created: Fri May 7 15:45:43 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 PathPlot extends ArrivalPlot {
47
48 public PathPlot() {
49 super();
50
51 setOpaque(true);
52
53 }
54
55 public void paintBackground(Graphics g) {
56 int xOffset = getSize().width/2;
57 int yOffset = getSize().height/2;
58 int pixelRad = Math.min(xOffset,
59 yOffset);
60 double roe = 6371;
61 Color origColor = g.getColor();
62
63 Color aColor, bColor, fillColor;
64 aColor = new Color(220, 220, 220);
65 bColor = Color.white;
66 fillColor = aColor;
67 boolean whichColor = true;
68
69 int disconRad;
70 if (tMod != null) {
71 roe = tMod.getRadiusOfEarth();
72 disconRad = pixelRad;
73 fillColor = whichColor ? aColor : bColor;
74 g.setColor(fillColor);
75 whichColor = ! whichColor;
76 g.fillOval(xOffset-disconRad, yOffset-disconRad,
77 2*disconRad,
78 2*disconRad);
79 for (int i=0;i<tMod.tauBranches[0].length-1;i++) {
80 if (tMod.tauBranches[0][i].getBotDepth() !=
81 tMod.tauBranches[1][i].getBotDepth()) {
82 disconRad = (int)Math.round((tMod.getRadiusOfEarth()-
83 tMod.tauBranches[0][i].getBotDepth()) /
84 roe * pixelRad);
85 fillColor = whichColor ? aColor : bColor;
86 g.setColor(fillColor);
87 whichColor = ! whichColor;
88 g.fillOval(xOffset-disconRad, yOffset-disconRad,
89 2*disconRad,
90 2*disconRad);
91 } else {
92 disconRad = (int)Math.round((tMod.getRadiusOfEarth()-
93 tMod.tauBranches[1][i].getBotDepth()) /
94 roe * pixelRad);
95 fillColor = whichColor ? aColor : bColor;
96 g.setColor(fillColor);
97 whichColor = ! whichColor;
98 g.fillOval(xOffset-disconRad, yOffset-disconRad,
99 2*disconRad,
100 2*disconRad);
101 }
102 }
103 }
104
105 g.setColor(origColor);
106 }
107
108 public void paintArrivals(Graphics g) {
109 for (int i=0;i<arrivals.size(); i++) {
110 paintPaths(g, i);
111 }
112 }
113
114 public void paintForeground(Graphics g) {
115 if (selectedIndex >= 0 && selectedIndex < arrivals.size()) {
116 Color orig = g.getColor();
117 g.setColor(Color.red);
118 paintPaths(g, selectedIndex);
119 g.setColor(orig);
120 }
121 }
122
123 protected void paintPaths(Graphics g, int i) {
124 Arrival a;
125 int[] x, y;
126 int xOffset = getSize().width/2;
127 int yOffset = getSize().height/2;
128 int pixelRad = Math.min(xOffset,
129 yOffset);
130 double roe = 6371;
131
132 a = (Arrival)arrivals.elementAt(i);
133 x = new int[a.getNumPathPoints()];
134 y = new int[a.getNumPathPoints()];
135
136 if ((a.dist*180/Math.PI) % 360 > 180) {
137
138 for (int j = 0; j < x.length; j++) {
139 x[j] = xOffset +(int)Math.rint(Math.sin(-1*a.getPathPoint(j).dist)
140 * ( roe-a.getPathPoint(j).depth) /
141 roe * pixelRad);
142 y[j] = yOffset -(int)Math.rint(Math.cos(-1*a.getPathPoint(j).dist)
143 * ( roe-a.getPathPoint(j).depth) /
144 roe * pixelRad);
145 }
146 } else {
147 for (int j = 0; j < x.length; j++) {
148 x[j] = xOffset +(int)Math.rint(Math.sin(a.getPathPoint(j).dist)
149 * ( roe-a.getPathPoint(j).depth) /
150 roe * pixelRad);
151 y[j] = yOffset -(int)Math.rint(Math.cos(a.getPathPoint(j).dist)
152 * ( roe-a.getPathPoint(j).depth) /
153 roe * pixelRad);
154 }
155 }
156
157 g.drawPolyline(x, y, x.length);
158 }
159
160 }