Developed by:U.S. Geological Survey"
+ + "
With contributions from:" + "
Instrumental Software Technologies, Inc. (ISTI)"
+ + "
The Incorporated Research Institutions for Seismology (IRIS)"
+ + "
Primary developers:
Dan Cervelli
Tom Parker" + "
");
+ return pane;
+ }
+
+ public void setVisible(boolean v) {
updateThread = new Thread(this, "About");
updateThread.start();
super.setVisible(v);
}
-
- public void run()
- {
- while (!kill)
- {
- try
- {
+
+ public void run() {
+ while (!kill) {
+ try {
update();
Thread.sleep(500);
+ } catch (Exception e) {
}
- catch (Exception e) {}
}
kill = false;
}
@@ -205,53 +196,76 @@ public void run()
/**
* The memory panel overrides the paint method to update the values.
*/
- private class MemoryPanel extends JPanel
- {
+ private class MemoryPanel extends JPanel {
/** serial version UID */
private static final long serialVersionUID = 1L;
/** re-use the number format safely on the Event Dispatch Thread. */
private final NumberFormat nf = new DecimalFormat("#.##");
-
- public MemoryPanel(LayoutManager layout)
- {
+
+ private final JLabel freeMemory;
+ private final JLabel totalMemory;
+ private final JLabel usedMemory;
+ private final JLabel maxMemory;
+ private final JLabel cacheMemory;
+
+ public MemoryPanel(LayoutManager layout) {
super(layout);
+ setBorder(new EmptyBorder(3, 6, 3, 6));
+ add(new JLabel("Free memory: "));
+ freeMemory = new JLabel();
+ add(freeMemory);
+ add(new JLabel("Total memory: "));
+ totalMemory = new JLabel();
+ add(totalMemory);
+ add(new JLabel("Used memory: "));
+ usedMemory = new JLabel();
+ add(usedMemory);
+ add(new JLabel("Max memory: "));
+ maxMemory = new JLabel();
+ add(maxMemory);
+ add(new JLabel("Cache size: "));
+ cacheMemory = new JLabel();
+ add(cacheMemory);
+ setSize(PANE_WIDTH, MEMORY_HEIGHT);
+ setLocation(5, MEMORY_LOC_Y);
+ setBackground(new Color(255, 255, 0));
}
/**
* Invoked by Swing to draw components. This method should not be called
* directly, use the repaint method.
*
- * @param g the graphics.
+ * @param g
+ * the graphics.
*/
- public void paint(Graphics g)
- {
+ public void paint(Graphics g) {
update();
super.paint(g);
}
-
- /**
+
+ /**
* Formats a long as a number of bytes.
- * @param bytes the number of bytes
+ *
+ * @param bytes
+ * the number of bytes
* @return a formatted string
*/
- private String toByteString(long bytes)
- {
+ private String toByteString(long bytes) {
return nf.format(bytes / 1000000.0) + " MB";
}
-
+
/**
- * Updates the memory information displayed in the dialog.
- * This should only be called on the Event Dispatch Thread.
+ * Updates the memory information displayed in the dialog. This should
+ * only be called on the Event Dispatch Thread.
*/
- private void update()
- {
+ private void update() {
Runtime r = Runtime.getRuntime();
freeMemory.setText(toByteString(r.freeMemory()));
totalMemory.setText(toByteString(r.totalMemory()));
usedMemory.setText(toByteString(r.totalMemory() - r.freeMemory()));
maxMemory.setText(toByteString(r.maxMemory()));
-
+
CachedDataSource cache = CachedDataSource.getInstance();
cacheMemory.setText(toByteString(cache.getSize()));
}
@@ -260,9 +274,8 @@ private void update()
/**
* Updates the memory information displayed in the dialog.
*/
- public void update()
- {
- //this will cause paint to be called on the Event Dispatch Thread
+ public void update() {
+ // this will cause paint to be called on the Event Dispatch Thread
memoryPanel.repaint();
}
}
\ No newline at end of file
diff --git a/src/main/java/gov/usgs/volcanoes/swarm/ConfigListener.java b/src/main/java/gov/usgs/volcanoes/swarm/ConfigListener.java
new file mode 100644
index 00000000..deceaaf1
--- /dev/null
+++ b/src/main/java/gov/usgs/volcanoes/swarm/ConfigListener.java
@@ -0,0 +1,5 @@
+package gov.usgs.volcanoes.swarm;
+
+public interface ConfigListener {
+ public void settingsChanged();
+}
diff --git a/src/main/java/gov/usgs/volcanoes/swarm/FileTypeDialog.java b/src/main/java/gov/usgs/volcanoes/swarm/FileTypeDialog.java
index 62e28209..c244b4b2 100644
--- a/src/main/java/gov/usgs/volcanoes/swarm/FileTypeDialog.java
+++ b/src/main/java/gov/usgs/volcanoes/swarm/FileTypeDialog.java
@@ -20,7 +20,7 @@
/*
* @author Tom Parker
*/
-public class FileTypeDialog extends SwarmDialog {
+public class FileTypeDialog extends SwarmModalDialog {
private static final long serialVersionUID = 1L;
private static final JFrame applicationFrame = Swarm.getApplicationFrame();
private JLabel filename;
@@ -30,7 +30,7 @@ public class FileTypeDialog extends SwarmDialog {
private boolean opened = false;
public FileTypeDialog() {
- super(applicationFrame, "Select File Type", true);
+ super(applicationFrame, "Select File Type");
setSizeAndLocation();
}
diff --git a/src/main/java/gov/usgs/volcanoes/swarm/HelpDialog.java b/src/main/java/gov/usgs/volcanoes/swarm/HelpDialog.java
new file mode 100644
index 00000000..82d701d4
--- /dev/null
+++ b/src/main/java/gov/usgs/volcanoes/swarm/HelpDialog.java
@@ -0,0 +1,41 @@
+package gov.usgs.volcanoes.swarm;
+
+import org.pegdown.PegDownProcessor;
+
+import java.awt.Component;
+import java.awt.Dimension;
+import java.util.Scanner;
+
+import javax.swing.BoxLayout;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextPane;
+
+public final class HelpDialog {
+
+ private static final PegDownProcessor pegdownProcessor = new PegDownProcessor();
+
+ public static void displayHelp(Component parent, String helpFile) {
+ final JPanel helpPanel = new JPanel();
+ helpPanel.setLayout(new BoxLayout(helpPanel, BoxLayout.PAGE_AXIS));
+ JTextPane htmlPane = new JTextPane();
+
+ Scanner scanner = new Scanner(HelpDialog.class.getResourceAsStream("/help/" + helpFile), "UTF-8");
+ String text = scanner.useDelimiter("\\A").next();
+ scanner.close();
+
+ htmlPane.setContentType("text/html");
+ htmlPane.setText(pegdownProcessor.markdownToHtml(text));
+ htmlPane.setPreferredSize(new Dimension(500, 600));
+
+ JScrollPane paneScrollPane = new JScrollPane(htmlPane);
+ helpPanel.add(paneScrollPane);
+
+ JOptionPane.showMessageDialog(parent,
+ helpPanel,
+ "A plain message",
+ JOptionPane.PLAIN_MESSAGE);
+
+ }
+}
diff --git a/src/main/java/gov/usgs/volcanoes/swarm/Icons.java b/src/main/java/gov/usgs/volcanoes/swarm/Icons.java
index 796d25bc..b29ba831 100644
--- a/src/main/java/gov/usgs/volcanoes/swarm/Icons.java
+++ b/src/main/java/gov/usgs/volcanoes/swarm/Icons.java
@@ -87,6 +87,7 @@ public class Icons {
public static final ImageIcon rsam_values = getIcon("images/rsam_values.png");
public static final ImageIcon rsam_counts = getIcon("images/rsam_counts.png");
public static final ImageIcon particle_motion = getIcon("images/bee.png");
+ public static final ImageIcon locate = getIcon("images/bee.png");
private static ImageIcon getIcon(String key) {
return new ImageIcon(ClassLoader.getSystemResource(key));
diff --git a/src/main/java/gov/usgs/volcanoes/swarm/OptionsDialog.java b/src/main/java/gov/usgs/volcanoes/swarm/OptionsDialog.java
index be636781..a09e975c 100644
--- a/src/main/java/gov/usgs/volcanoes/swarm/OptionsDialog.java
+++ b/src/main/java/gov/usgs/volcanoes/swarm/OptionsDialog.java
@@ -1,6 +1,8 @@
package gov.usgs.volcanoes.swarm;
import java.awt.BorderLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.Arrays;
@@ -19,6 +21,7 @@
import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.layout.FormLayout;
+import gov.usgs.volcanoes.swarm.map.NationalMapLayer;
import gov.usgs.volcanoes.swarm.options.SwarmOptions;
/**
@@ -26,189 +29,204 @@
* @author Dan Cervelli
* @version $Id: OptionsDialog.java,v 1.7 2007-05-21 02:38:41 dcervelli Exp $
*/
-public class OptionsDialog extends SwarmDialog {
- private static final long serialVersionUID = 1L;
- private static final JFrame applicationFrame = Swarm.getApplicationFrame();
-
- private JPanel dialogPanel;
-
- private JCheckBox durationEnabled;
- private JTextField durationA;
- private JTextField durationB;
- private JCheckBox useLargeCursor;
-
- private JCheckBox tzInstrument;
- private JRadioButton tzLocal;
- private JRadioButton tzSpecific;
- private JComboBox timeZones;
-
- private JRadioButton useMapPacks;
- private JRadioButton useWMS;
- private JTextField wmsServer;
- private JTextField wmsLayer;
- private JTextField wmsStyles;
- private JLabel wmsServerLabel;
- private JLabel wmsLayerLabel;
- private JLabel wmsStylesLabel;
-
- public OptionsDialog() {
- super(applicationFrame, "Options", true);
- createUI();
- setCurrentValues();
- setSizeAndLocation();
- }
-
- private void createFields() {
- durationEnabled = new JCheckBox("Enabled");
- durationA = new JTextField();
- durationB = new JTextField();
- useLargeCursor = new JCheckBox("Large Helicorder Cursor");
- tzInstrument = new JCheckBox("Use instrument time zone if available");
- tzLocal = new JRadioButton("Use local machine time zone:");
- tzSpecific = new JRadioButton("Use specific time zone:");
- ButtonGroup tzGroup = new ButtonGroup();
- tzGroup.add(tzLocal);
- tzGroup.add(tzSpecific);
- String[] tzs = TimeZone.getAvailableIDs();
- Arrays.sort(tzs);
- timeZones = new JComboBox(tzs);
-
- useMapPacks = new JRadioButton("Use local MapPacks");
- useWMS = new JRadioButton("Use WMS");
- ButtonGroup mapGroup = new ButtonGroup();
- mapGroup.add(useMapPacks);
- mapGroup.add(useWMS);
- wmsLayer = new JTextField();
- wmsServer = new JTextField();
- wmsStyles = new JTextField();
- }
-
- protected void createUI() {
- super.createUI();
- createFields();
-
- FormLayout layout = new FormLayout(
- "right:max(30dlu;pref), 3dlu, 40dlu, 3dlu, right:max(40dlu;pref), 3dlu, 40dlu", "");
-
- DefaultFormBuilder builder = new DefaultFormBuilder(layout);
- builder.setDefaultDialogBorder();
-
- builder.appendSeparator("Time Zone");
-
- builder.append(tzInstrument, 7);
- builder.nextLine();
- TimeZone local = TimeZone.getDefault();
-
- builder.append(tzLocal, 7);
- builder.append(" ");
- builder.append(new JLabel(local.getID()), 5);
- builder.nextLine();
-
- builder.append(tzSpecific, 7);
- builder.nextLine();
-
- builder.append(" ");
- builder.append(timeZones, 5);
- builder.nextLine();
-
- builder.appendSeparator("Duration Magnitude");
- builder.append(durationEnabled, 7);
- builder.nextLine();
- builder.append("Md=", durationA);
- builder.append("* Log(t) +", durationB);
-
- builder.appendSeparator("Maps");
- builder.append(useMapPacks, 7);
- builder.nextLine();
- builder.append(useWMS, 7);
- builder.nextLine();
- wmsServerLabel = new JLabel("Server:");
- wmsServerLabel.setLabelFor(wmsServer);
- builder.append(wmsServerLabel);
- builder.append(wmsServer, 5);
- builder.nextLine();
- wmsLayerLabel = new JLabel("Layer:");
- wmsLayerLabel.setLabelFor(wmsLayer);
- builder.append(wmsLayerLabel);
- builder.append(wmsLayer, 5);
- builder.nextLine();
- wmsStylesLabel = new JLabel("Styles:");
- wmsStylesLabel.setLabelFor(wmsStyles);
- builder.append(wmsStylesLabel);
- builder.append(wmsStyles, 5);
- builder.nextLine();
-
- useMapPacks.addItemListener(new ItemListener() {
- public void itemStateChanged(ItemEvent e) {
- doEnables();
- }
- });
-
- builder.appendSeparator("Other");
- builder.append(useLargeCursor, 7);
- builder.nextLine();
-
- dialogPanel = builder.getPanel();
- mainPanel.add(dialogPanel, BorderLayout.CENTER);
- }
-
- public void doEnables() {
- boolean state = useMapPacks.isSelected();
- wmsServer.setEnabled(!state);
- wmsLayer.setEnabled(!state);
- wmsStyles.setEnabled(!state);
- wmsServerLabel.setEnabled(!state);
- wmsLayerLabel.setEnabled(!state);
- wmsStylesLabel.setEnabled(!state);
- }
-
- public void setCurrentValues() {
- useLargeCursor.setSelected(swarmConfig.useLargeCursor);
- durationA.setText(Double.toString(swarmConfig.durationA));
- durationB.setText(Double.toString(swarmConfig.durationB));
- durationEnabled.setSelected(swarmConfig.durationEnabled);
- tzInstrument.setSelected(swarmConfig.useInstrumentTimeZone);
- if (swarmConfig.useLocalTimeZone)
- tzLocal.setSelected(true);
- else
- tzSpecific.setSelected(true);
- timeZones.setSelectedItem(swarmConfig.specificTimeZone.getID());
-
- useMapPacks.setSelected(!swarmConfig.useWMS);
- useWMS.setSelected(swarmConfig.useWMS);
- wmsServer.setText(swarmConfig.wmsServer);
- wmsLayer.setText(swarmConfig.wmsLayer);
- wmsStyles.setText(swarmConfig.wmsStyles);
- doEnables();
- }
-
- public boolean allowOK() {
- String message = null;
- try {
- message = "The duration magnitude constants must be numbers.";
- Double.parseDouble(durationA.getText().trim());
- Double.parseDouble(durationB.getText().trim());
-
- return true;
- } catch (Exception e) {
- JOptionPane.showMessageDialog(this, message, "Options Error", JOptionPane.ERROR_MESSAGE);
- }
- return false;
- }
-
- public void wasOK() {
- swarmConfig.useLargeCursor = useLargeCursor.isSelected();
- swarmConfig.durationEnabled = durationEnabled.isSelected();
- swarmConfig.durationA = Double.parseDouble(durationA.getText().trim());
- swarmConfig.durationB = Double.parseDouble(durationB.getText().trim());
- swarmConfig.useInstrumentTimeZone = tzInstrument.isSelected();
- swarmConfig.useLocalTimeZone = tzLocal.isSelected();
- swarmConfig.specificTimeZone = TimeZone.getTimeZone((String) timeZones.getSelectedItem());
- swarmConfig.useWMS = useWMS.isSelected();
- swarmConfig.wmsServer = wmsServer.getText();
- swarmConfig.wmsLayer = wmsLayer.getText();
- swarmConfig.wmsStyles = wmsStyles.getText();
-
- SwarmOptions.optionsChanged();
- }
+public class OptionsDialog extends SwarmModalDialog {
+ private static final long serialVersionUID = 1L;
+ private static final JFrame applicationFrame = Swarm.getApplicationFrame();
+
+ private JPanel dialogPanel;
+
+ private JCheckBox durationEnabled;
+ private JTextField durationA;
+ private JTextField durationB;
+ private JCheckBox useLargeCursor;
+
+ private JCheckBox tzInstrument;
+ private JRadioButton tzLocal;
+ private JRadioButton tzSpecific;
+ private JComboBox timeZones;
+ private JComboBox