Debian Codegraph @

src/dr/geo/GTOPO30Browser.java

raw symbols SCIP
1 /*
2 * GTOPO30Browser.java
3 *
4 * Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
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 * @author Alexei Drummond
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 }