| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
package dr.geo; |
| 27 |
|
| 28 |
import dr.app.gui.ColorFunction; |
| 29 |
|
| 30 |
import javax.swing.*; |
| 31 |
import javax.swing.event.ChangeEvent; |
| 32 |
import javax.swing.event.ChangeListener; |
| 33 |
import java.awt.*; |
| 34 |
import java.io.IOException; |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
public class GTOPO30Browser extends JFrame implements ChangeListener { |
| 40 |
|
| 41 |
GTOPO30Panel gtopo30panel; |
| 42 |
JScrollPane scrollPane; |
| 43 |
|
| 44 |
public GTOPO30Browser(String[] tilefiles) throws IOException { |
| 45 |
super("GTOPO30 Browser"); |
| 46 |
|
| 47 |
ColorFunction function = new ColorFunction( |
| 48 |
new Color[]{Color.blue, Color.yellow, Color.green.darker(), Color.orange.darker(), Color.white, Color.pink}, |
| 49 |
new float[]{-410, 0, 100, 1500, 4000, 8800}); |
| 50 |
|
| 51 |
gtopo30panel = new GTOPO30Panel(tilefiles, function); |
| 52 |
|
| 53 |
|
| 54 |
scrollPane = new JScrollPane(gtopo30panel); |
| 55 |
|
| 56 |
getContentPane().add(BorderLayout.CENTER, scrollPane); |
| 57 |
|
| 58 |
JSlider scale = new JSlider(JSlider.HORIZONTAL, 1, 100, 10); |
| 59 |
scale.addChangeListener(this); |
| 60 |
|
| 61 |
getContentPane().add(BorderLayout.SOUTH, scale); |
| 62 |
} |
| 63 |
|
| 64 |
public static void main(String[] args) throws IOException { |
| 65 |
|
| 66 |
GTOPO30Browser browser = new GTOPO30Browser(args); |
| 67 |
browser.setSize(800, 800); |
| 68 |
browser.setVisible(true); |
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
public void stateChanged(ChangeEvent e) { |
| 73 |
JSlider source = (JSlider) e.getSource(); |
| 74 |
if (!source.getValueIsAdjusting()) { |
| 75 |
int scale = source.getValue(); |
| 76 |
gtopo30panel.setScale((double) scale / 100.0f); |
| 77 |
scrollPane.repaint(); |
| 78 |
} |
| 79 |
} |
| 80 |
} |