();
+ for (String requiredBndl : requiredBundles) {
+ // Extract bundle name which is first item in
+ // semicolon
+ // split list
+ String[] bndlParts = requiredBndl.split("[;]");
+ Bundle reqBndl = bundles.get(bndlParts[0]);
+ if (reqBndl != null) {
+ // Found bundle, process context for bundle
+ OSGIXmlApplicationContext parent = createContext(
+ bundles, contextMap, reqBndl, processing);
+ if (parent != null) {
+ // Context found, add to list
+ parentContexts.add(parent);
+ }
+ }
+ }
- if (parentContexts.size() > 0) {
- // Context with parent context
- appCtx = new OSGIXmlApplicationContext(
- new OSGIGroupApplicationContext(parentContexts),
- files.toArray(new String[0]), bundle);
- } else {
- // No parent context required
- appCtx = new OSGIXmlApplicationContext(
- files.toArray(new String[0]), bundle);
- }
- }
- }
- contextMap.put(bundleName, appCtx);
- }
- processing.remove(bundleName);
- return appCtx;
- }
+ if (parentContexts.size() > 0) {
+ // Context with parent context
+ appCtx = new OSGIXmlApplicationContext(
+ new OSGIGroupApplicationContext(parentContexts),
+ files.toArray(new String[0]), bundle);
+ } else {
+ // No parent context required
+ appCtx = new OSGIXmlApplicationContext(
+ files.toArray(new String[0]), bundle);
+ }
+ }
+ }
+ contextMap.put(bundleName, appCtx);
+ }
+ processing.remove(bundleName);
+ return appCtx;
+ }
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
- */
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ }
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Based on the command line arguments, determine whether or not an Eclipse
+ * p2 repository will be installed
+ *
+ * @return true if an Eclipse p2 repository is going to be installed, false
+ * otherwise
+ */
+ private boolean isInstallOperation() {
+ final String P2_DIRECTOR = "org.eclipse.equinox.p2.director";
+
+ /**
+ * We look at the command line arguments instead of the program
+ * arguments (com.raytheon.uf.viz.application.ProgramArguments) because
+ * the command line arguments include almost everything that was passed
+ * as an argument to the Eclipse executable instead of just what CAVE is
+ * interested in.
+ */
+ for (String argument : Platform.getCommandLineArgs()) {
+ if (P2_DIRECTOR.equals(argument)) {
+ return Boolean.TRUE;
+ }
+ }
+
+ return Boolean.FALSE;
+ }
}
diff --git a/cave/com.raytheon.uf.viz.stats/META-INF/MANIFEST.MF b/cave/com.raytheon.uf.viz.stats/META-INF/MANIFEST.MF
index bbc9e9368e..87e75da1c0 100644
--- a/cave/com.raytheon.uf.viz.stats/META-INF/MANIFEST.MF
+++ b/cave/com.raytheon.uf.viz.stats/META-INF/MANIFEST.MF
@@ -12,7 +12,8 @@ Require-Bundle: org.eclipse.ui,
com.raytheon.uf.common.stats;bundle-version="1.0.0",
com.raytheon.uf.common.time;bundle-version="1.12.1174",
com.raytheon.uf.common.util;bundle-version="1.12.1174",
- com.google.guava;bundle-version="1.0.0"
+ com.google.guava;bundle-version="1.0.0",
+ com.raytheon.uf.common.units;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: com.raytheon.uf.viz.stats,
diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/GroupingComp.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/GroupingComp.java
index 3f9e39259b..61bb2f5ae4 100644
--- a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/GroupingComp.java
+++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/GroupingComp.java
@@ -20,7 +20,7 @@
package com.raytheon.uf.viz.stats.ui;
/**
- * TODO Add Description
+ * Grouping Composite for the Stats Graph.
*
*
*
@@ -36,10 +36,13 @@ package com.raytheon.uf.viz.stats.ui;
* @version 1.0
*/
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.regex.Pattern;
import org.eclipse.swt.SWT;
@@ -59,22 +62,25 @@ import org.eclipse.swt.widgets.ColorDialog;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
import com.raytheon.uf.common.stats.data.GraphData;
/**
* Composites that contains the controls to change colors and to determine what
* is displayed.
- *
+ *
*
- *
+ *
* SOFTWARE HISTORY
- *
+ *
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
- * Oct 16, 2012 lvenable Initial creation
- *
+ * Oct 16, 2012 lvenable Initial creation
+ * Jan 11, 2013 1357 mpduff Implement.
+ *
*
- *
+ *
* @author lvenable
* @version 1.0
*/
@@ -106,9 +112,11 @@ public class GroupingComp extends Composite implements IGroupSelection {
/** Grouping callback */
private final IStatsGroup callback;
+ private final List selectionEntries = new ArrayList();
+
/**
* Constructor.
- *
+ *
* @param parentComp
* Parent composite.
* @param swtStyle
@@ -191,12 +199,26 @@ public class GroupingComp extends Composite implements IGroupSelection {
*/
private void createControls() {
List keyArray = graphData.getKeysWithData();
+ Map> grpNameMap = graphData.getGroupAndNamesMap();
+ // Create the Selection Entry objects
for (String key : keyArray) {
+ SelectionEntry se = new SelectionEntry();
+ String[] parts = colonPattern.split(key);
+
+ Set grpNames = grpNameMap.keySet();
+ Iterator iter = grpNames.iterator();
+ for (int i = 0; i < grpNames.size(); i++) {
+ se.addPair(iter.next(), parts[i]);
+ }
+ this.selectionEntries.add(se);
+ }
+
+ for (SelectionEntry se : selectionEntries) {
GridData gd = new GridData(20, 10);
Label lbl = new Label(controlComp, SWT.BORDER);
lbl.setLayoutData(gd);
- lbl.setData(key);
+ lbl.setData(se);
lbl.addMouseListener(new MouseAdapter() {
@Override
public void mouseDown(MouseEvent e) {
@@ -206,8 +228,9 @@ public class GroupingComp extends Composite implements IGroupSelection {
});
Button btn = new Button(controlComp, SWT.CHECK);
- btn.setText(key);
+ btn.setText(se.toString());
btn.setSelection(true);
+ btn.setData(se);
btn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
@@ -216,8 +239,8 @@ public class GroupingComp extends Composite implements IGroupSelection {
}
});
- labelMap.put(key, lbl);
- checkBtnMap.put(key, btn);
+ labelMap.put(se.toString(), lbl);
+ checkBtnMap.put(se.toString(), btn);
}
}
@@ -245,22 +268,22 @@ public class GroupingComp extends Composite implements IGroupSelection {
displaySelectionMgrDlg();
}
});
-// Not including this functionality in the branch.
-// gd = new GridData(buttonWidth, SWT.DEFAULT);
-// Button colorMgrBtn = new Button(buttonComp, SWT.PUSH);
-// colorMgrBtn.setText("Color Manager...");
-// colorMgrBtn.setLayoutData(gd);
-// colorMgrBtn.addSelectionListener(new SelectionAdapter() {
-// @Override
-// public void widgetSelected(SelectionEvent e) {
-// displayColorMgrDlg();
-// }
-// });
+ // Not including this functionality in the branch.
+ // gd = new GridData(buttonWidth, SWT.DEFAULT);
+ // Button colorMgrBtn = new Button(buttonComp, SWT.PUSH);
+ // colorMgrBtn.setText("Color Manager...");
+ // colorMgrBtn.setLayoutData(gd);
+ // colorMgrBtn.addSelectionListener(new SelectionAdapter() {
+ // @Override
+ // public void widgetSelected(SelectionEvent e) {
+ // displayColorMgrDlg();
+ // }
+ // });
}
/**
* Handle the check button event.
- *
+ *
* @param btn
* Check box being checked/unchecked.
*/
@@ -278,13 +301,13 @@ public class GroupingComp extends Composite implements IGroupSelection {
/**
* Handle the color label that is being clicked.
- *
+ *
* @param lbl
* Label that was clicked.
*/
private void handleLabelClickEvent(Label lbl) {
RGB rgb = lbl.getBackground().getRGB();
- String key = (String) lbl.getData();
+ String key = ((SelectionEntry) lbl.getData()).toString();
ColorDialog colorDlg = new ColorDialog(this.getShell());
colorDlg.setRGB(rgb);
@@ -343,36 +366,30 @@ public class GroupingComp extends Composite implements IGroupSelection {
if (selectionMangerDlg == null || selectionMangerDlg.isDisposed()) {
selectionMangerDlg = new SelectionManagerDlg(getShell(), graphData,
this);
- selectionMangerDlg.open();
- } else {
- selectionMangerDlg.bringToTop();
}
+
+ selectionMangerDlg.open();
}
/**
* Display the Color Manager dialog.
*/
// Implementing in the next release.
-// private void displayColorMgrDlg() {
-// ColorManagerDlg dlg = new ColorManagerDlg(getShell(), graphData, this);
-// dlg.open();
-// }
+ // private void displayColorMgrDlg() {
+ // ColorManagerDlg dlg = new ColorManagerDlg(getShell(), graphData, this);
+ // dlg.open();
+ // }
/**
* {@inheritDoc}
*/
@Override
public void setSelections(Map> selectionMap) {
- List keySequence = graphData.getKeySequence();
-
- Map> offMap = new HashMap>();
+ Multimap offMap = ArrayListMultimap.create();
for (String key : selectionMap.keySet()) {
for (String selection : selectionMap.get(key).keySet()) {
if (!selectionMap.get(key).get(selection)) {
- if (!offMap.containsKey(key)) {
- offMap.put(key, new ArrayList());
- }
- offMap.get(key).add(selection);
+ offMap.put(key, selection);
}
}
}
@@ -385,19 +402,18 @@ public class GroupingComp extends Composite implements IGroupSelection {
}
} else {
for (String btnKey : checkBtnMap.keySet()) {
- String[] parts = colonPattern.split(btnKey);
+ Button b = checkBtnMap.get(btnKey);
+ SelectionEntry se = (SelectionEntry) b.getData();
- for (String group : offMap.keySet()) {
- for (String part : parts) {
- int idx = keySequence.indexOf(part);
- if (idx >= 0 && offMap.get(group).contains(keySequence.get(idx))) {
- checkBtnMap.get(btnKey).setSelection(false);
- keyRgbMap.remove(btnKey);
- } else {
- checkBtnMap.get(btnKey).setSelection(true);
- keyRgbMap.put(btnKey, labelMap.get(btnKey)
- .getBackground().getRGB());
- }
+ for (String key : offMap.keySet()) {
+ Collection valueList = offMap.get(key);
+ if (valueList.contains(se.getValue(key))) {
+ checkBtnMap.get(btnKey).setSelection(false);
+ keyRgbMap.remove(btnKey);
+ } else {
+ checkBtnMap.get(btnKey).setSelection(true);
+ keyRgbMap.put(btnKey, labelMap.get(btnKey)
+ .getBackground().getRGB());
}
}
}
@@ -405,4 +421,33 @@ public class GroupingComp extends Composite implements IGroupSelection {
fireCallback();
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setItemsOff(List keys) {
+ for (String key : keys) {
+ if (checkBtnMap.containsKey(key)) {
+ checkBtnMap.get(key).setSelection(false);
+ keyRgbMap.remove(key);
+ }
+ }
+
+ fireCallback();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Map getStates() {
+ Map stateMap = new HashMap();
+
+ for (Map.Entry state : checkBtnMap.entrySet()) {
+ stateMap.put(state.getKey(), state.getValue().getSelection());
+ }
+
+ return stateMap;
+ }
}
diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/HideDlg.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/HideDlg.java
new file mode 100644
index 0000000000..82c9893bb2
--- /dev/null
+++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/HideDlg.java
@@ -0,0 +1,161 @@
+/**
+ * This software was developed and / or modified by Raytheon Company,
+ * pursuant to Contract DG133W-05-CQ-1067 with the US Government.
+ *
+ * U.S. EXPORT CONTROLLED TECHNICAL DATA
+ * This software product contains export-restricted data whose
+ * export/transfer/disclosure is restricted by U.S. law. Dissemination
+ * to non-U.S. persons whether in the United States or abroad requires
+ * an export license or other authorization.
+ *
+ * Contractor Name: Raytheon Company
+ * Contractor Address: 6825 Pine Street, Suite 340
+ * Mail Stop B8
+ * Omaha, NE 68106
+ * 402.291.0100
+ *
+ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
+ * further licensing information.
+ **/
+package com.raytheon.uf.viz.stats.ui;
+
+import java.util.Arrays;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Layout;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.Shell;
+
+import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
+
+/**
+ * Hide graph lines dialog.
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * Dec 4, 2012 1357 mpduff Initial creation.
+ *
+ *
+ *
+ * @author mpduff
+ * @version 1.0
+ */
+
+public class HideDlg extends CaveSWTDialog {
+ /** Data List Widget */
+ private List dataList;
+
+ /** List of keys */
+ private final java.util.List keyList;
+
+ /** Callback to hide the lines */
+ private final IGroupSelection callback;
+
+ /**
+ * Constructor.
+ *
+ * @param parent
+ * The parent shell
+ * @param keyList
+ * The list of keys
+ * @param callback
+ * the callback
+ */
+ public HideDlg(Shell parent, java.util.List keyList,
+ IGroupSelection callback) {
+ super(parent);
+ setText("Hide Graph Lines");
+
+ this.keyList = keyList;
+ this.callback = callback;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Layout constructShellLayout() {
+ // Create the main layout for the shell.
+ GridLayout mainLayout = new GridLayout(1, true);
+ mainLayout.marginHeight = 1;
+ mainLayout.marginWidth = 1;
+ return mainLayout;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void initializeComponents(Shell shell) {
+ setReturnValue(false);
+
+ Composite mainComp = new Composite(shell, SWT.NONE);
+ GridLayout gl = new GridLayout(1, false);
+ gl.marginHeight = 0;
+ gl.marginWidth = 0;
+ gl.horizontalSpacing = 0;
+ gl.verticalSpacing = 5;
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
+ mainComp.setLayout(gl);
+ mainComp.setLayoutData(gd);
+
+ GridData listData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ listData.widthHint = 200;
+ listData.heightHint = 300;
+ dataList = new List(mainComp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL
+ | SWT.H_SCROLL);
+ dataList.setLayoutData(listData);
+ dataList.setItems(keyList.toArray(new String[keyList.size()]));
+
+ Composite buttonComp = new Composite(shell, SWT.NONE);
+ buttonComp.setLayout(new GridLayout(2, false));
+ buttonComp.setLayoutData(new GridData(SWT.CENTER, SWT.DEFAULT, true,
+ false));
+
+ int buttonWidth = 120;
+ gd = new GridData(buttonWidth, SWT.DEFAULT);
+ Button hideBtn = new Button(buttonComp, SWT.PUSH);
+ hideBtn.setText("Hide Graph Lines");
+ hideBtn.setLayoutData(gd);
+ hideBtn.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ handleHide();
+ }
+ });
+
+ gd = new GridData(buttonWidth, SWT.DEFAULT);
+ Button closeBtn = new Button(buttonComp, SWT.PUSH);
+ closeBtn.setText("Close");
+ closeBtn.setLayoutData(gd);
+ closeBtn.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ close();
+ }
+ });
+ }
+
+ /**
+ * Hide event handler
+ */
+ private void handleHide() {
+ if (dataList.getSelectionCount() > 0) {
+ String[] itemsToHide = dataList.getSelection();
+ callback.setItemsOff(Arrays.asList(itemsToHide));
+ for (String item : itemsToHide) {
+ dataList.remove(item);
+ }
+ }
+ }
+}
diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/IGroupSelection.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/IGroupSelection.java
index e6ba63b898..9f546562d2 100644
--- a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/IGroupSelection.java
+++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/IGroupSelection.java
@@ -19,21 +19,23 @@
**/
package com.raytheon.uf.viz.stats.ui;
+import java.util.List;
import java.util.Map;
/**
* Interface for Group Selections.
- *
+ *
*
- *
+ *
* SOFTWARE HISTORY
- *
+ *
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
- * Oct 18, 2012 728 mpduff Initial creation
- *
+ * Oct 18, 2012 728 mpduff Initial creation.
+ * Jan 17, 2013 1357 mpduff Added setItemsOff and getStates.
+ *
*
- *
+ *
* @author mpduff
* @version 1.0
*/
@@ -41,8 +43,23 @@ import java.util.Map;
public interface IGroupSelection {
/**
* Set the selections.
- *
+ *
* @param selectionMap
*/
void setSelections(Map> selectionMap);
+
+ /**
+ * Turn off the provided items.
+ *
+ * @param keys
+ * keys of the items to not draw
+ */
+ void setItemsOff(List keys);
+
+ /**
+ * Get the state of each item.
+ *
+ * @return Map of item -> checked or not checked
+ */
+ Map getStates();
}
diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/IStatsDisplay.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/IStatsDisplay.java
index 12afff43ba..49ef4ef9a1 100644
--- a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/IStatsDisplay.java
+++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/IStatsDisplay.java
@@ -24,21 +24,21 @@ import java.util.Map;
import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.common.stats.data.GraphData;
-
+import com.raytheon.uf.common.stats.util.UnitUtils;
/**
* Stats display interface.
- *
+ *
*
- *
+ *
* SOFTWARE HISTORY
- *
+ *
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 3, 2012 728 mpduff Initial creation
- *
+ *
*
- *
+ *
* @author mpduff
* @version 1.0
*/
@@ -46,29 +46,36 @@ import com.raytheon.uf.common.stats.data.GraphData;
public interface IStatsDisplay {
/**
* Get the GraphData object
- *
+ *
* @return GraphData
*/
GraphData getGraphData();
/**
* Draw grid lines flag
- *
+ *
* @return true to draw the grid lines
*/
boolean drawGridLines();
/**
* Draw data lines flag
- *
+ *
* @return true to draw the data lines
*/
boolean drawDataLines();
/**
* Get the group settings.
- *
+ *
* @return The group settings map
*/
Map getGroupSettings();
+
+ /**
+ * Get the UnitUtils object.
+ *
+ * @return the UnitUtils object
+ */
+ UnitUtils getUnitUtils();
}
diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/SelectionEntry.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/SelectionEntry.java
new file mode 100644
index 0000000000..b8b4620c8e
--- /dev/null
+++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/SelectionEntry.java
@@ -0,0 +1,87 @@
+/**
+ * This software was developed and / or modified by Raytheon Company,
+ * pursuant to Contract DG133W-05-CQ-1067 with the US Government.
+ *
+ * U.S. EXPORT CONTROLLED TECHNICAL DATA
+ * This software product contains export-restricted data whose
+ * export/transfer/disclosure is restricted by U.S. law. Dissemination
+ * to non-U.S. persons whether in the United States or abroad requires
+ * an export license or other authorization.
+ *
+ * Contractor Name: Raytheon Company
+ * Contractor Address: 6825 Pine Street, Suite 340
+ * Mail Stop B8
+ * Omaha, NE 68106
+ * 402.291.0100
+ *
+ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
+ * further licensing information.
+ **/
+package com.raytheon.uf.viz.stats.ui;
+
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * Stats Graph Item.
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * Jan 24, 2013 mpduff Initial creation
+ *
+ *
+ *
+ * @author mpduff
+ * @version 1.0
+ */
+public class SelectionEntry {
+ private final Map values = new LinkedHashMap();
+
+ private boolean checked = true;
+
+ public SelectionEntry() {
+
+ }
+
+ public void addPair(String key, String value) {
+ values.put(key, value);
+ }
+
+ public String getValue(String key) {
+ return values.get(key);
+ }
+
+ /**
+ * @return the checked
+ */
+ public boolean isChecked() {
+ return checked;
+ }
+
+ /**
+ * @param checked
+ * the checked to set
+ */
+ public void setChecked(boolean checked) {
+ this.checked = checked;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+
+ for (Iterator iter = values.values().iterator(); iter.hasNext();) {
+ sb.append(iter.next());
+ if (iter.hasNext()) {
+ sb.append(":");
+ }
+ }
+
+ return sb.toString();
+ }
+}
diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/SelectionManagerDlg.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/SelectionManagerDlg.java
index 71f48ae27d..d12231d3c5 100644
--- a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/SelectionManagerDlg.java
+++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/SelectionManagerDlg.java
@@ -21,8 +21,10 @@ package com.raytheon.uf.viz.stats.ui;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
@@ -44,17 +46,18 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialogBase;
/**
* Stats Selection Manager Dialog.
- *
+ *
*
- *
+ *
* SOFTWARE HISTORY
- *
+ *
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
- * Oct 18, 2012 lvenable Initial creation
- *
+ * Oct 18, 2012 lvenable Initial creation
+ * Jan 17, 2013 1357 mpduff Added selection state handling.
+ *
*
- *
+ *
* @author lvenable
* @version 1.0
*/
@@ -74,9 +77,9 @@ public class SelectionManagerDlg extends CaveSWTDialogBase {
/**
* Constructor.
- *
+ *
* @param parentShell
- * @param graphData
+ * @param selectionEntries
* @param callback
*/
public SelectionManagerDlg(Shell parentShell, GraphData graphData,
@@ -86,8 +89,8 @@ public class SelectionManagerDlg extends CaveSWTDialogBase {
| CAVE.INDEPENDENT_SHELL);
setText("Selection Manager");
- this.graphData = graphData;
this.callback = callback;
+ this.graphData = graphData;
}
/**
@@ -202,7 +205,7 @@ public class SelectionManagerDlg extends CaveSWTDialogBase {
/**
* Check the path of the item.
- *
+ *
* @param item
* @param checked
* @param grayed
@@ -232,7 +235,7 @@ public class SelectionManagerDlg extends CaveSWTDialogBase {
/**
* Check or uncheck the items in the TreeItem
- *
+ *
* @param item
* @param checked
*/
@@ -261,10 +264,27 @@ public class SelectionManagerDlg extends CaveSWTDialogBase {
for (String subKey : array) {
TreeItem subTreeItem = new TreeItem(treeItem, SWT.NONE);
subTreeItem.setText(subKey);
-
subTreeItem.setChecked(true);
}
}
+
+ // Determine group checkbox setting, unchecked, grayed, checked
+ TreeItem[] children = selectionTree.getItems();
+ Set selectionSet = new HashSet();
+ for (TreeItem item : children) {
+ item.setChecked(true);
+ for (TreeItem subItem : item.getItems()) {
+ selectionSet.add(subItem.getChecked());
+ }
+
+ if (selectionSet.contains(Boolean.TRUE)
+ && selectionSet.contains(Boolean.FALSE)) {
+ item.setChecked(true);
+ item.setGrayed(true);
+ } else if (!selectionSet.contains(Boolean.TRUE)) {
+ item.setChecked(false);
+ }
+ }
}
/**
@@ -314,6 +334,5 @@ public class SelectionManagerDlg extends CaveSWTDialogBase {
} else {
callback.setSelections(selectionMap);
}
-
}
}
diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsControlDlg.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsControlDlg.java
index 013b15fec7..62e63e59f1 100644
--- a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsControlDlg.java
+++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsControlDlg.java
@@ -69,7 +69,8 @@ import com.raytheon.viz.ui.widgets.duallist.IUpdate;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
- * Sep 25, 2012 mpduff Initial creation
+ * Sep 25, 2012 1357 mpduff Initial creation.
+ * Jan 17, 2013 1357 mpduff Added timestep settings.
*
*
*
@@ -92,7 +93,7 @@ public class StatsControlDlg extends CaveSWTDialog implements IStatsControl,
TimeUtil.MILLIS_PER_HOUR * 3, TimeUtil.MILLIS_PER_HOUR * 6,
TimeUtil.MILLIS_PER_HOUR * 12, TimeUtil.MILLIS_PER_DAY,
TimeUtil.MILLIS_PER_WEEK, TimeUtil.MILLIS_PER_WEEK * 2,
- TimeUtil.MILLIS_PER_MONTH };
+ TimeUtil.MILLIS_PER_30_DAYS };
/** Date Format object */
private final ThreadLocal sdf = new ThreadLocal() {
@@ -619,7 +620,24 @@ public class StatsControlDlg extends CaveSWTDialog implements IStatsControl,
}
TimeRange tr = new TimeRange(start, end);
request.setTimeRange(tr);
- request.setTimeStep(5);
+
+ if (tr.getDuration() <= TimeUtil.MILLIS_PER_HOUR) {
+ request.setTimeStep(5);
+ } else if (tr.getDuration() <= TimeUtil.MILLIS_PER_HOUR * 3) {
+ request.setTimeStep(5);
+ } else if (tr.getDuration() <= TimeUtil.MILLIS_PER_HOUR * 6) {
+ request.setTimeStep(10);
+ } else if (tr.getDuration() <= TimeUtil.MILLIS_PER_HOUR * 12) {
+ request.setTimeStep(20);
+ } else if (tr.getDuration() <= TimeUtil.MILLIS_PER_HOUR * 24) {
+ request.setTimeStep(40);
+ } else if (tr.getDuration() <= TimeUtil.MILLIS_PER_DAY * 7) {
+ request.setTimeStep(240);
+ } else if (tr.getDuration() <= TimeUtil.MILLIS_PER_DAY * 14) {
+ request.setTimeStep(480);
+ } else {
+ request.setTimeStep(1000);
+ }
try {
GraphDataResponse response = (GraphDataResponse) ThriftClient
diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsDisplayCanvas.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsDisplayCanvas.java
index b6a26959d7..8ef620b160 100644
--- a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsDisplayCanvas.java
+++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsDisplayCanvas.java
@@ -23,15 +23,19 @@ import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
+import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.TimeZone;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.events.PaintEvent;
@@ -47,31 +51,41 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.common.stats.data.DataPoint;
import com.raytheon.uf.common.stats.data.GraphData;
import com.raytheon.uf.common.stats.data.StatsData;
-import com.raytheon.uf.common.stats.util.DataViewUtils;
+import com.raytheon.uf.common.stats.util.DataView;
+import com.raytheon.uf.common.stats.util.UnitUtils;
+import com.raytheon.uf.common.stats.util.UnitUtils.TimeConversion;
+import com.raytheon.uf.common.stats.util.UnitUtils.UnitTypes;
import com.raytheon.uf.common.time.TimeRange;
import com.raytheon.uf.common.time.util.TimeUtil;
+import com.raytheon.uf.common.units.DataSizeUnit;
import com.raytheon.uf.viz.core.RGBColors;
import com.raytheon.uf.viz.stats.display.ScaleManager;
/**
* Statistics graph canvas.
- *
+ *
*
- *
+ *
* SOFTWARE HISTORY
- *
+ *
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
- * Oct 3, 2012 728 mpduff Initial creation
- *
+ * Oct 03, 2012 728 mpduff Initial creation.
+ * Jan 17, 2013 1357 mpduff Added mouse listeners.
+ * Jan 29, 2013 1523 mpduff Fix for count units.
+ *
*
- *
+ *
* @author mpduff
* @version 1.0
*/
@@ -106,6 +120,15 @@ public class StatsDisplayCanvas extends Canvas {
}
};
+ /** Decimal Format object */
+ private final ThreadLocal decFormat = new ThreadLocal() {
+ @Override
+ protected DecimalFormat initialValue() {
+ DecimalFormat format = new DecimalFormat("########.#");
+ return format;
+ }
+ };
+
/** Constant */
private final String COLON = ":";
@@ -185,21 +208,18 @@ public class StatsDisplayCanvas extends Canvas {
/** Tooltip shell */
private Shell tooltip;
- /** Graph Data object */
- private GraphData graphData;
+ /** Data View, avg, min, max, etc. */
+ private DataView view = DataView.AVG;
- /** Smallest value in the data set */
- private double minValue;
+ /** Group selection callback */
+ private IGroupSelection groupCallback;
- /** Largest value in the data set */
- private double maxValue;
-
- private String view = DataViewUtils.DataView.AVG.getView(); // Defaults to
- // average
+ /** Hide dataset dialog */
+ private HideDlg hideDlg;
/**
* Constructor
- *
+ *
* @param parent
* Parent composite
* @param callback
@@ -214,8 +234,7 @@ public class StatsDisplayCanvas extends Canvas {
this.callback = callback;
this.graphTitle = graphTitle;
- this.graphData = callback.getGraphData();
- TimeRange tr = graphData.getTimeRange();
+ TimeRange tr = callback.getGraphData().getTimeRange();
String start = titleDateFormat.get().format(tr.getStart());
String end = titleDateFormat.get().format(tr.getEnd());
@@ -258,11 +277,18 @@ public class StatsDisplayCanvas extends Canvas {
handleMouseMoveEvent(e);
}
});
+
+ addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseDown(MouseEvent e) {
+ handleMouseDownEvent(e);
+ }
+ });
}
/**
* Initialize drawing settings.
- *
+ *
* @param gc
* The Graphics Context
*/
@@ -280,7 +306,7 @@ public class StatsDisplayCanvas extends Canvas {
/**
* Draw on the canvas.
- *
+ *
* @param gc
* The Graphics Context
*/
@@ -327,7 +353,7 @@ public class StatsDisplayCanvas extends Canvas {
/**
* Draw the X axis.
- *
+ *
* @param gc
* The Graphics Context
*/
@@ -342,8 +368,7 @@ public class StatsDisplayCanvas extends Canvas {
List dateList = new ArrayList();
SimpleDateFormat sdf = axisFormat.get();
-
- TimeRange tr = graphData.getTimeRange();
+ TimeRange tr = callback.getGraphData().getTimeRange();
dateList.add(tr.getStart()); // Add the first date
long milliRange = tr.getDuration();
@@ -356,24 +381,29 @@ public class StatsDisplayCanvas extends Canvas {
long startMillis = tr.getStart().getTime();
StringBuilder buffer = new StringBuilder();
- Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+ Calendar cal = TimeUtil.newGmtCalendar();
for (long i = tr.getStart().getTime(); i <= tr.getEnd().getTime(); i += TimeUtil.MILLIS_PER_HOUR) {
cal.setTimeInMillis(i);
int[] tickArray = {
- (int) (GRAPH_BORDER + (i - startMillis) / millisPerPixelX),
+ Math.round(GRAPH_BORDER + (i - startMillis)
+ / millisPerPixelX),
GRAPH_BORDER + GRAPH_HEIGHT,
- (int) (GRAPH_BORDER + (i - startMillis) / millisPerPixelX),
+ Math.round(GRAPH_BORDER + (i - startMillis)
+ / millisPerPixelX),
GRAPH_BORDER + GRAPH_HEIGHT + height };
- if (cal.get(Calendar.HOUR_OF_DAY) == 0) {
+ if (cal.get(Calendar.HOUR_OF_DAY) == 0
+ && cal.get(Calendar.MINUTE) == 0) {
gc.setLineWidth(3);
} else {
gc.setLineWidth(1);
}
int hour = cal.get(Calendar.HOUR_OF_DAY);
+ // Draw the tick marks
if ((numHours / 24 <= 7) || (hour % 6) == 0) {
gc.drawPolyline(tickArray);
+ // Draw grid lines
if (callback.drawGridLines()) {
boolean draw = false;
if (numHours <= 6) {
@@ -386,19 +416,20 @@ public class StatsDisplayCanvas extends Canvas {
if (draw) {
int[] gridLine = new int[] {
- (int) (GRAPH_BORDER + (i - startMillis)
+ Math.round(GRAPH_BORDER + (i - startMillis)
/ millisPerPixelX),
GRAPH_BORDER + GRAPH_HEIGHT,
- (int) (GRAPH_BORDER + (i - startMillis)
+ Math.round(GRAPH_BORDER + (i - startMillis)
/ millisPerPixelX), GRAPH_BORDER };
gc.drawPolyline(gridLine);
}
}
}
+ // Save the Zero hour for later
if (hour == 0) {
- dateLocationList.add((int) (GRAPH_BORDER + (i - startMillis)
- / millisPerPixelX));
+ dateLocationList.add(Math.round(GRAPH_BORDER
+ + (i - startMillis) / millisPerPixelX));
if (!dateList.contains(cal.getTime())) {
dateList.add(cal.getTime());
}
@@ -406,22 +437,28 @@ public class StatsDisplayCanvas extends Canvas {
buffer.setLength(0); // Clear the buffer
int y = GRAPH_BORDER + GRAPH_HEIGHT + 20;
int hr = cal.get(Calendar.HOUR_OF_DAY);
+ int minute = cal.get(Calendar.MINUTE);
+
+ // Draw the tick marks
if ((numHours <= 24) || (hour % 6 == 0 && numHours <= 168)) {
if (numHours <= 3) {
- for (int j = 0; j < 60; j += 15) {
+ for (int j = 0; j < TimeUtil.MINUTES_PER_HOUR; j += 15) {
+
buffer.setLength(0);
- int x = (int) (GRAPH_BORDER + (i - startMillis + j
- * TimeUtil.MILLIS_PER_MINUTE)
+ int x = Math.round(GRAPH_BORDER
+ + (i - startMillis + j
+ * TimeUtil.MILLIS_PER_MINUTE)
/ millisPerPixelX);
if (numHours == 1
|| (numHours == 3 && (j == 0 || j == 30))) {
String hrStr = (hr < 10) ? ZERO.concat(String
.valueOf(hr)) : String.valueOf(hr);
- if (j == 0) {
+ if (minute == 0) {
buffer.append(hrStr).append(COLON)
.append(MINUTE_00);
} else {
- buffer.append(hrStr).append(COLON).append(j);
+ buffer.append(hrStr).append(COLON)
+ .append(minute);
}
int adjustment = buffer.length() * fontAveWidth / 2
- 1;
@@ -429,30 +466,46 @@ public class StatsDisplayCanvas extends Canvas {
if (callback.drawGridLines()) {
int[] gridLineArray = {
- (int) (GRAPH_BORDER + (i - startMillis + TimeUtil.MILLIS_PER_MINUTE
- * j)
- / millisPerPixelX),
+ Math.round(GRAPH_BORDER
+ + (i - startMillis + TimeUtil.MILLIS_PER_MINUTE
+ * j) / millisPerPixelX),
GRAPH_BORDER + GRAPH_HEIGHT,
- (int) (GRAPH_BORDER + (i - startMillis + TimeUtil.MILLIS_PER_MINUTE
- * j)
- / millisPerPixelX),
+ Math.round(GRAPH_BORDER
+ + (i - startMillis + TimeUtil.MILLIS_PER_MINUTE
+ * j) / millisPerPixelX),
GRAPH_BORDER };
+ if (hr == 0 && minute == 0) {
+ gc.setLineWidth(3);
+ }
gc.drawPolyline(gridLineArray);
+ gc.setLineWidth(1);
+ }
+ minute += 15;
+ // Roll the minutes and hours, account for rolling
+ // to the next hour/minute
+ if (minute >= TimeUtil.MINUTES_PER_HOUR) {
+ minute = 0;
+ hr++;
+ if (hr == TimeUtil.HOURS_PER_DAY) {
+ hr = 0;
+ }
}
}
+
+ // Minor tick marks
int[] minorTickArray = {
- (int) (GRAPH_BORDER + (i - startMillis + TimeUtil.MILLIS_PER_MINUTE
- * j)
- / millisPerPixelX),
+ Math.round(GRAPH_BORDER
+ + (i - startMillis + TimeUtil.MILLIS_PER_MINUTE
+ * j) / millisPerPixelX),
GRAPH_BORDER + GRAPH_HEIGHT,
- (int) (GRAPH_BORDER + (i - startMillis + TimeUtil.MILLIS_PER_MINUTE
- * j)
- / millisPerPixelX),
+ Math.round(GRAPH_BORDER
+ + (i - startMillis + TimeUtil.MILLIS_PER_MINUTE
+ * j) / millisPerPixelX),
GRAPH_BORDER + GRAPH_HEIGHT + height - 5 };
gc.drawPolyline(minorTickArray);
}
} else {
- int x = (int) (GRAPH_BORDER + (i - startMillis)
+ int x = Math.round(GRAPH_BORDER + (i - startMillis)
/ millisPerPixelX);
String hrStr = (hr < 10) ? ZERO.concat(String.valueOf(hr))
: String.valueOf(hr);
@@ -462,13 +515,13 @@ public class StatsDisplayCanvas extends Canvas {
if (callback.drawGridLines()) {
if ((numHours == 24 && hr % 6 == 0)
- || (numHours == 168 && hr == 0)) {
+ || (numHours == TimeUtil.HOURS_PER_WEEK && hr == 0)) {
int[] gridLineArray = {
- (int) (GRAPH_BORDER + (i - startMillis)
+ Math.round(GRAPH_BORDER + (i - startMillis)
/ millisPerPixelX),
GRAPH_BORDER + GRAPH_HEIGHT,
- (int) (GRAPH_BORDER + (i - startMillis)
+ Math.round(GRAPH_BORDER + (i - startMillis)
/ millisPerPixelX), GRAPH_BORDER };
gc.setLineWidth(1);
gc.drawPolyline(gridLineArray);
@@ -477,7 +530,7 @@ public class StatsDisplayCanvas extends Canvas {
}
}
} else if (numHours == 336 && hour == 0) {
- int x = (int) (GRAPH_BORDER + (i - startMillis)
+ int x = Math.round(GRAPH_BORDER + (i - startMillis)
/ millisPerPixelX);
buffer.append(cal.get(Calendar.MONTH) + 1);
buffer.append("/");
@@ -489,10 +542,10 @@ public class StatsDisplayCanvas extends Canvas {
// show every other line
if (showLine) {
int[] gridLineArray = {
- (int) (GRAPH_BORDER + (i - startMillis)
+ Math.round(GRAPH_BORDER + (i - startMillis)
/ millisPerPixelX),
GRAPH_BORDER + GRAPH_HEIGHT,
- (int) (GRAPH_BORDER + (i - startMillis)
+ Math.round(GRAPH_BORDER + (i - startMillis)
/ millisPerPixelX), GRAPH_BORDER };
gc.setLineWidth(1);
gc.drawPolyline(gridLineArray);
@@ -503,7 +556,7 @@ public class StatsDisplayCanvas extends Canvas {
} else if (numHours == 720) {
if (cal.get(Calendar.DAY_OF_MONTH) % 2 == 0 && hour == 0) {
- int x = (int) (GRAPH_BORDER + (i - startMillis)
+ int x = Math.round(GRAPH_BORDER + (i - startMillis)
/ millisPerPixelX);
buffer.append(cal.get(Calendar.MONTH) + 1);
buffer.append("/");
@@ -513,10 +566,10 @@ public class StatsDisplayCanvas extends Canvas {
if (callback.drawGridLines()) {
if (showLine) {
int[] gridLineArray = {
- (int) (GRAPH_BORDER + (i - startMillis)
+ Math.round(GRAPH_BORDER + (i - startMillis)
/ millisPerPixelX),
GRAPH_BORDER + GRAPH_HEIGHT,
- (int) (GRAPH_BORDER + (i - startMillis)
+ Math.round(GRAPH_BORDER + (i - startMillis)
/ millisPerPixelX), GRAPH_BORDER };
gc.setLineWidth(1);
gc.drawPolyline(gridLineArray);
@@ -556,7 +609,7 @@ public class StatsDisplayCanvas extends Canvas {
/**
* Draw the Y axis.
- *
+ *
* @param gc
* The Graphics Context
*/
@@ -568,14 +621,21 @@ public class StatsDisplayCanvas extends Canvas {
gc.drawPolyline(yAxis);
Map groupSettings = callback.getGroupSettings();
-
+ GraphData graphData = callback.getGraphData();
double minVal = graphData.getMinValue(groupSettings.keySet(), view);
double maxVal = graphData.getMaxValue(groupSettings.keySet(), view);
+ if (view != DataView.COUNT) {
+ UnitUtils uu = callback.getUnitUtils();
+ minVal = uu.convertValue(minVal);
+ maxVal = uu.convertValue(maxVal);
+ }
+
+ setScaleValues(minVal, maxVal);
+
int numberTicks = 4;
double inc = 5;
double minScaleVal = 0;
double maxScaleVal = 10;
- scalingManager = new ScaleManager(minVal, maxVal);
numberTicks = scalingManager.getMajorTickCount();
inc = scalingManager.getMajorTickIncrement();
@@ -607,16 +667,18 @@ public class StatsDisplayCanvas extends Canvas {
/**
* Draw the YAxis label.
- *
+ *
* @param gc
* The Graphics Context
*/
private void drawYAxisLabel(GC gc) {
- String unit = this.graphData.getDisplayUnit();
+ GraphData graphData = callback.getGraphData();
+ String unit = graphData.getDisplayUnit();
StringBuilder yAxisLabel = new StringBuilder(graphTitle);
- if (unit != null && !unit.equalsIgnoreCase(COUNT) && unit.length() > 0
- && !view.equals(DataViewUtils.DataView.COUNT.getView())) {
+ if (isCount(unit)) {
+ yAxisLabel.append(" Counts");
+ } else {
yAxisLabel.append(" (").append(unit).append(")");
}
@@ -637,9 +699,13 @@ public class StatsDisplayCanvas extends Canvas {
t.dispose();
}
+ private boolean isCount(String unit) {
+ return view.equals(DataView.COUNT) || COUNT.equalsIgnoreCase(unit);
+ }
+
/**
* Draw the data on the canvas.
- *
+ *
* @param gc
* The Graphics Context
*/
@@ -647,6 +713,8 @@ public class StatsDisplayCanvas extends Canvas {
double maxScaleVal = scalingManager.getMaxScaleValue();
double minScaleVal = scalingManager.getMinScaleValue();
Map groupSettings = callback.getGroupSettings();
+ UnitUtils uu = callback.getUnitUtils();
+ GraphData graphData = callback.getGraphData();
for (String key : graphData.getKeysWithData()) {
if (groupSettings.containsKey(key)) {
@@ -672,30 +740,27 @@ public class StatsDisplayCanvas extends Canvas {
int lastYpix = -999;
for (DataPoint point : dataList) {
long x = point.getX();
- double y;
+ double y = point.getValue(view);
- if (view.equals(DataViewUtils.DataView.AVG
- .getView())) {
- y = point.getAvg();
- } else if (view.equals(DataViewUtils.DataView.MIN
- .getView())) {
- y = point.getMin();
- } else if (view.equals(DataViewUtils.DataView.MAX
- .getView())) {
- y = point.getMax();
- } else if (view.equals(DataViewUtils.DataView.SUM
- .getView())) {
- y = point.getSum();
- } else {
- y = point.getCount();
+ if (view != DataView.COUNT) {
+ y = uu.convertValue(y);
}
+
+ int xPix = 0;
int yPix = y2pixel(minScaleVal, maxScaleVal, y);
- int xPix = (int) ((x - startMillis)
- / millisPerPixelX + GRAPH_BORDER);
+
+ long diff = x - startMillis;
+ if (diff == 0) {
+ xPix = GRAPH_BORDER;
+ } else {
+ xPix = Math
+ .round((diff / millisPerPixelX + GRAPH_BORDER));
+ }
if (xPix > GRAPH_BORDER + GRAPH_WIDTH) {
- break;
+ continue;
}
+
pointList.add(xPix);
pointList.add(yPix);
Rectangle rect = new Rectangle(xPix - 3, yPix - 3,
@@ -710,6 +775,7 @@ public class StatsDisplayCanvas extends Canvas {
lastYpix = yPix;
}
+ // Draw each rectangle
for (int i = 0; i < rectangleMap.get(key).size(); i++) {
Rectangle rect = rectangleMap.get(key).get(i);
gc.setForeground(color);
@@ -727,7 +793,7 @@ public class StatsDisplayCanvas extends Canvas {
/**
* Y Value to pixel conversion.
- *
+ *
* @param yMin
* The smallest y value
* @param yMax
@@ -739,12 +805,12 @@ public class StatsDisplayCanvas extends Canvas {
private int y2pixel(double yMin, double yMax, double y) {
double yDiff = yMax - yMin;
double yValue = (GRAPH_HEIGHT / yDiff) * (y - yMin);
- return (int) (GRAPH_HEIGHT - Math.round(yValue) + GRAPH_BORDER);
+ return Math.round(GRAPH_HEIGHT - Math.round(yValue) + GRAPH_BORDER);
}
/**
* Mouse move event hanler.
- *
+ *
* @param e
* MouseEvent object
*/
@@ -758,6 +824,8 @@ public class StatsDisplayCanvas extends Canvas {
if (graphData == null) {
return;
}
+
+ UnitUtils uu = callback.getUnitUtils();
for (String key : graphData.getKeys()) {
int idx = 0;
if (rectangleMap.containsKey(key)) {
@@ -771,7 +839,24 @@ public class StatsDisplayCanvas extends Canvas {
sb.append(key).append(colon);
DataPoint point = graphData.getStatsData(key)
.getData().get(idx);
- sb.append(point.getSampleText(view));
+ double value = point.getValue(view);
+
+ if (!view.equals(DataView.COUNT)) {
+ if (uu.getUnitType() == UnitTypes.DATA_SIZE) {
+ value = uu.convertDataSizeValue(
+ DataSizeUnit.BYTE, value);
+ } else if (uu.getUnitType() == UnitTypes.TIME) {
+ value = uu.convertTimeValue(
+ TimeConversion.MS, (long) value);
+ }
+ }
+
+ SimpleDateFormat dateFormat = titleDateFormat.get();
+ DecimalFormat decimalFormat = decFormat.get();
+
+ sb.append(dateFormat.format(new Date(point.getX())))
+ .append("Z, ");
+ sb.append(decimalFormat.format(value));
}
}
idx++;
@@ -790,9 +875,102 @@ public class StatsDisplayCanvas extends Canvas {
}
}
+ private void setScaleValues(double minVal, double maxVal) {
+ scalingManager = new ScaleManager(minVal, maxVal);
+ }
+
+ private void handleMouseDownEvent(MouseEvent e) {
+ if (e.button == 3) {
+ GraphData graphData = callback.getGraphData();
+ if (graphData == null) {
+ return;
+ }
+
+ int x = e.x;
+ int y = e.y;
+ List keyList = new ArrayList();
+ for (String key : graphData.getKeys()) {
+ if (rectangleMap.containsKey(key)) {
+ for (Rectangle rect : rectangleMap.get(key)) {
+ if (callback.getGroupSettings().containsKey(key)) {
+ // if true then data are on the graph
+ if (rect.contains(x, y)) {
+ keyList.add(key);
+ }
+ }
+ }
+ }
+ }
+
+ if (!keyList.isEmpty()) {
+ showPopup(keyList);
+ }
+ }
+ }
+
+ private void showPopup(final List inputList) {
+ // Remove the tooltip if it is up
+ if (tooltip != null && !tooltip.isDisposed()) {
+ tooltip.dispose();
+ }
+
+ // Remove any duplicate entries
+ Set set = new HashSet(inputList);
+ final List keyList = new ArrayList(set);
+ Collections.sort(keyList);
+
+ Menu menu = new Menu(this.getShell(), SWT.POP_UP);
+
+ if (keyList.size() == 1) {
+ MenuItem selectAll = new MenuItem(menu, SWT.NONE);
+ selectAll.setText("Hide " + keyList.get(0));
+ selectAll.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ handleHide(keyList);
+ }
+ });
+ } else if (keyList.size() > 1) {
+ MenuItem hideAll = new MenuItem(menu, SWT.NONE);
+ hideAll.setText("Hide All Data At Point");
+ hideAll.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ handleHide(keyList);
+ }
+ });
+
+ new MenuItem(menu, SWT.SEPARATOR);
+
+ MenuItem hideGraphDlgMI = new MenuItem(menu, SWT.NONE);
+ hideGraphDlgMI.setText("Hide Graph Lines...");
+ hideGraphDlgMI.addListener(SWT.Selection, new Listener() {
+ @Override
+ public void handleEvent(Event event) {
+ showHideDlg(keyList);
+ }
+ });
+ }
+
+ // We need to make the menu visible
+ menu.setVisible(true);
+ }
+
+ private void handleHide(List keyList) {
+ groupCallback.setItemsOff(keyList);
+ redraw();
+ }
+
+ private void showHideDlg(List keyList) {
+ if (hideDlg == null || hideDlg.isDisposed()) {
+ this.hideDlg = new HideDlg(getShell(), keyList, groupCallback);
+ }
+ hideDlg.open();
+ }
+
/**
* Show the "tooltip" mouseover.
- *
+ *
* @param parent
* @param x
* @param y
@@ -824,7 +1002,7 @@ public class StatsDisplayCanvas extends Canvas {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.swt.widgets.Widget#dispose()
*/
@Override
@@ -836,20 +1014,20 @@ public class StatsDisplayCanvas extends Canvas {
}
/**
- * Set the graph data.
- *
- * @param graphData
- * The GraphData object
+ * @param view
+ * The view type
*/
- public void setGraphData(GraphData graphData) {
- this.graphData = graphData;
+ public void setView(DataView view) {
+ this.view = view;
}
/**
- * Set the view type.
- * @param view The view type
+ * Set the group selection callback.
+ *
+ * @param groupCallback
+ * The group callback
*/
- public void setView(String view) {
- this.view = view;
+ public void setCallback(IGroupSelection groupCallback) {
+ this.groupCallback = groupCallback;
}
}
diff --git a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsGraphDlg.java b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsGraphDlg.java
index 1a9e209d87..172f9daba3 100644
--- a/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsGraphDlg.java
+++ b/cave/com.raytheon.uf.viz.stats/src/com/raytheon/uf/viz/stats/ui/StatsGraphDlg.java
@@ -20,24 +20,21 @@
package com.raytheon.uf.viz.stats.ui;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.ImageLoader;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Menu;
@@ -48,7 +45,8 @@ import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.common.stats.GraphDataRequest;
import com.raytheon.uf.common.stats.GraphDataResponse;
import com.raytheon.uf.common.stats.data.GraphData;
-import com.raytheon.uf.common.stats.util.DataViewUtils;
+import com.raytheon.uf.common.stats.util.DataView;
+import com.raytheon.uf.common.stats.util.UnitUtils;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
@@ -61,17 +59,19 @@ import com.raytheon.viz.ui.widgets.duallist.ButtonImages.ButtonImage;
/**
* The Graph Data Structure.
- *
+ *
*
- *
+ *
* SOFTWARE HISTORY
- *
+ *
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
- * Oct 3, 2012 728 mpduff Initial creation
- *
+ * Oct 03, 2012 728 mpduff Initial creation.
+ * Jan 17, 2013 1357 mpduff Add ability to change units.
+ * Jan 18, 2013 1386 mpduff Change menu text.
+ *
*
- *
+ *
* @author mpduff
* @version 1.0
*/
@@ -101,8 +101,8 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay,
/** Menu bar */
private Menu menuBar;
- /** Save Menu Item */
- private MenuItem saveMI;
+ // /** Save Menu Item */
+ // private MenuItem saveMI;
/** Exit Menu item */
private MenuItem exitMI;
@@ -143,9 +143,17 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay,
/** Data view combo */
private Combo viewCombo;
+ /** Menu item map */
+ private final Map menuItemMap = new HashMap();
+
+ /** The currently displayed unit */
+ private String displayUnit;
+
+ private UnitUtils unitUtils;
+
/**
* Constructor.
- *
+ *
* @param parent
* Parent Shell
* @param callback
@@ -204,6 +212,8 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay,
groupComp.setLayout(gl);
groupComp.setLayoutData(gd);
+ displayCanvas.setCallback(groupComp);
+
gd = new GridData(SWT.FILL, SWT.DEFAULT, false, true);
gl = new GridLayout(2, false);
Composite ctrlComp = new Composite(leftComp, SWT.NONE);
@@ -220,11 +230,11 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay,
graphLabel.setText("Graph: ");
List viewList = new ArrayList();
- viewList.add(DataViewUtils.DataView.AVG.getView());
- viewList.add(DataViewUtils.DataView.MIN.getView());
- viewList.add(DataViewUtils.DataView.MAX.getView());
- viewList.add(DataViewUtils.DataView.SUM.getView());
- viewList.add(DataViewUtils.DataView.COUNT.getView());
+ viewList.add(DataView.AVG.getView());
+ viewList.add(DataView.MIN.getView());
+ viewList.add(DataView.MAX.getView());
+ viewList.add(DataView.SUM.getView());
+ viewList.add(DataView.COUNT.getView());
gd = new GridData(SWT.LEFT, SWT.CENTER, true, false);
viewCombo = new Combo(dataComp, SWT.READ_ONLY);
@@ -314,15 +324,15 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay,
Menu fileMenu = new Menu(menuBar);
fileMenuItem.setMenu(fileMenu);
- saveMI = new MenuItem(fileMenu, SWT.NONE);
- saveMI.setText("&Save\tCtrl+S");
- saveMI.setAccelerator(SWT.CTRL + 'S');
- saveMI.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- saveGraph();
- }
- });
+ // saveMI = new MenuItem(fileMenu, SWT.NONE);
+ // saveMI.setText("&Save Graph Image\tCtrl+S");
+ // saveMI.setAccelerator(SWT.CTRL + 'S');
+ // saveMI.addSelectionListener(new SelectionAdapter() {
+ // @Override
+ // public void widgetSelected(SelectionEvent event) {
+ // saveGraph();
+ // }
+ // });
exitMI = new MenuItem(fileMenu, SWT.NONE);
exitMI.setText("&Quit\tCtrl+Q");
@@ -371,11 +381,63 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay,
displayCanvas.redraw();
}
});
+
+ // Set up the display units menu choices
+ MenuItem unitsMI = new MenuItem(graphMenu, SWT.CASCADE);
+ unitsMI.setText("Display Units");
+
+ unitUtils = new UnitUtils(graphData.getEventType(),
+ graphData.getDataType());
+ String displayUnit = graphData.getDisplayUnit();
+ unitUtils.setUnitType(displayUnit);
+ unitUtils.setDisplayUnit(displayUnit);
+ Set units = unitUtils.getUnitOptions();
+
+ Menu unitsMenu = new Menu(graphMenu);
+ unitsMI.setMenu(unitsMenu);
+
+ for (String unit : units) {
+ MenuItem mi = new MenuItem(unitsMenu, SWT.CHECK);
+ mi.setText(unit);
+ if (unit.equals(graphData.getDisplayUnit())) {
+ mi.setSelection(true);
+ }
+ mi.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ handleUnitsSelection(e);
+ }
+ });
+
+ menuItemMap.put(unit, mi);
+ }
+ }
+
+ /**
+ * Handle the unit selection event.
+ *
+ * @param e
+ * The selection event
+ */
+ private void handleUnitsSelection(SelectionEvent e) {
+ MenuItem m = (MenuItem) e.getSource();
+ for (Entry es : menuItemMap.entrySet()) {
+ MenuItem mi = es.getValue();
+ if (es.getKey().equals(m.getText())) {
+ m.setSelection(true);
+ displayUnit = m.getText();
+ unitUtils.setDisplayUnit(displayUnit);
+ graphData.setDisplayUnit(displayUnit);
+ displayCanvas.redraw();
+ } else {
+ mi.setSelection(false);
+ }
+ }
}
/**
* Create the canvas.
- *
+ *
* @param comp
* Composite holding the canvas
*/
@@ -395,7 +457,7 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay,
/**
* Set the GraphData object.
- *
+ *
* @param graphData
*/
public void setGraphData(GraphData graphData) {
@@ -412,7 +474,7 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay,
/**
* Set the title.
- *
+ *
* @param title
*/
public void setTitle(String title) {
@@ -421,66 +483,66 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay,
/**
* Set the graph title.
- *
+ *
* @param graphTitle
*/
public void setGraphTitle(String graphTitle) {
this.graphTitle = graphTitle;
}
- /**
- * Open a file dialog for saving the canvas.
- */
- private void saveGraph() {
- FileDialog dialog = new FileDialog(shell, SWT.SAVE);
- String filename = dialog.open();
- if (filename == null) {
- return;
- }
- saveCanvas(filename);
- }
+ // /**
+ // * Open a file dialog for saving the canvas.
+ // */
+ // private void saveGraph() {
+ // FileDialog dialog = new FileDialog(shell, SWT.SAVE);
+ // String filename = dialog.open();
+ // if (filename == null) {
+ // return;
+ // }
+ // saveCanvas(filename);
+ // }
- /**
- * Captures the canvas and saves the result into a file in a format
- * determined by the filename extension .
- *
- * @param control
- * The control to save
- * @param fileName
- * The name of the image to be saved
- */
- public void saveCanvas(String filename) {
- StringBuilder sb = new StringBuilder();
- Display display = displayCanvas.getDisplay();
- Image image = new Image(display, displayCanvas.getBounds().width,
- displayCanvas.getBounds().height);
- GC gc = new GC(image);
-
- displayCanvas.drawCanvas(gc);
-
- /* Default to PNG */
- int style = SWT.IMAGE_PNG;
-
- if ((filename.endsWith(".jpg") == true) || filename.endsWith("jpeg")) {
- style = SWT.IMAGE_JPEG;
- } else if (filename.endsWith(".bmp") == true) {
- style = SWT.IMAGE_BMP;
- } else {
- filename += ".png";
- }
-
- ImageLoader loader = new ImageLoader();
- loader.data = new ImageData[] { image.getImageData() };
- loader.save(filename, style);
-
- sb.setLength(0);
- image.dispose();
- gc.dispose();
- }
+ // /**
+ // * Captures the canvas and saves the result into a file in a format
+ // * determined by the filename extension .
+ // *
+ // * @param control
+ // * The control to save
+ // * @param fileName
+ // * The name of the image to be saved
+ // */
+ // public void saveCanvas(String filename) {
+ // StringBuilder sb = new StringBuilder();
+ // Display display = displayCanvas.getDisplay();
+ // Image image = new Image(display, displayCanvas.getBounds().width,
+ // displayCanvas.getBounds().height);
+ // GC gc = new GC(image);
+ //
+ // displayCanvas.drawCanvas(gc);
+ //
+ // /* Default to PNG */
+ // int style = SWT.IMAGE_PNG;
+ //
+ // if ((filename.endsWith(".jpg") == true) || filename.endsWith("jpeg")) {
+ // style = SWT.IMAGE_JPEG;
+ // } else if (filename.endsWith(".bmp") == true) {
+ // style = SWT.IMAGE_BMP;
+ // } else {
+ // filename += ".png";
+ // }
+ //
+ // ImageLoader loader = new ImageLoader();
+ // loader.data = new ImageData[] { image.getImageData() };
+ // loader.save(filename, style);
+ //
+ // sb.setLength(0);
+ // image.dispose();
+ // gc.dispose();
+ // }
/**
* Request the graph be redrawn with a new time range.
- *
+ *
* @param parameter
* The amount of time to move
*/
@@ -516,7 +578,6 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay,
default:
return;
}
-
GraphDataRequest request = new GraphDataRequest();
request.setGrouping(this.groupList);
request.setCategory(this.category);
@@ -525,7 +586,7 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay,
request.setField(dataTypeID);
TimeRange newTimeRange = new TimeRange(newStart, newEnd);
request.setTimeRange(newTimeRange);
- request.setTimeStep(5);
+ request.setTimeStep((int) graphData.getTimeStep());
try {
GraphDataResponse response = (GraphDataResponse) ThriftClient
.sendRequest(request);
@@ -544,7 +605,6 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay,
}
this.graphData = localGraphData;
- this.displayCanvas.setGraphData(graphData);
this.displayCanvas.redraw();
} catch (VizException e) {
this.statusHandler.handle(Priority.ERROR, "Error Requesting Data",
@@ -556,7 +616,8 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay,
* Handler for data view combo box change.
*/
private void handleDataViewChange() {
- String view = viewCombo.getText();
+ String viewStr = viewCombo.getText();
+ DataView view = DataView.fromString(viewStr);
this.displayCanvas.setView(view);
this.displayCanvas.redraw();
}
@@ -596,7 +657,7 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay,
/**
* Set the groups.
- *
+ *
* @param groupList
* List of groups
*/
@@ -606,7 +667,7 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay,
/**
* Set the category.
- *
+ *
* @param category
*/
public void setCategory(String category) {
@@ -615,7 +676,7 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay,
/**
* Set the event type.
- *
+ *
* @param typeID
*/
public void setEventType(String typeID) {
@@ -624,10 +685,18 @@ public class StatsGraphDlg extends CaveSWTDialog implements IStatsDisplay,
/**
* Set the data type id.
- *
+ *
* @param dataTypeID
*/
public void setDataType(String dataTypeID) {
this.dataTypeID = dataTypeID;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public UnitUtils getUnitUtils() {
+ return this.unitUtils;
+ }
}
diff --git a/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/ThinClientComponent.java b/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/ThinClientComponent.java
index 7a7b439666..f2a2ff1134 100644
--- a/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/ThinClientComponent.java
+++ b/cave/com.raytheon.uf.viz.thinclient.cave/src/com/raytheon/uf/viz/thinclient/cave/ThinClientComponent.java
@@ -55,9 +55,6 @@ import com.raytheon.uf.viz.thinclient.localization.LocalizationCachePersistence;
import com.raytheon.uf.viz.thinclient.localization.ThinClientLocalizationInitializer;
import com.raytheon.uf.viz.thinclient.preferences.ThinClientPreferenceConstants;
import com.raytheon.uf.viz.thinclient.refresh.TimedRefresher;
-import com.raytheon.viz.alerts.jobs.AutoUpdater;
-import com.raytheon.viz.alerts.jobs.MenuUpdater;
-import com.raytheon.viz.alerts.observers.ProductAlertObserver;
import com.raytheon.viz.ui.personalities.awips.AbstractCAVEComponent;
import com.raytheon.viz.ui.personalities.awips.CAVE;
@@ -188,8 +185,11 @@ public class ThinClientComponent extends CAVE implements IThinClientComponent {
@Override
protected void initializeObservers() {
ThinClientNotificationManagerJob.getInstance();
- ProductAlertObserver.addObserver(null, new MenuUpdater());
- ProductAlertObserver.addObserver(null, new AutoUpdater());
+ IPreferenceStore store = Activator.getDefault().getPreferenceStore();
+ if (store.getBoolean(ThinClientPreferenceConstants.P_DISABLE_JMS) == false) {
+ // JMS Enabled, register product alerts
+ registerProductAlerts();
+ }
}
public void stopComponent() {
diff --git a/cave/com.raytheon.uf.viz.ui.menus/src/com/raytheon/uf/viz/ui/menus/widgets/BundleContributionItem.java b/cave/com.raytheon.uf.viz.ui.menus/src/com/raytheon/uf/viz/ui/menus/widgets/BundleContributionItem.java
index f111585083..032600742c 100644
--- a/cave/com.raytheon.uf.viz.ui.menus/src/com/raytheon/uf/viz/ui/menus/widgets/BundleContributionItem.java
+++ b/cave/com.raytheon.uf.viz.ui.menus/src/com/raytheon/uf/viz/ui/menus/widgets/BundleContributionItem.java
@@ -56,8 +56,11 @@ import com.raytheon.uf.viz.core.procedures.BundleUtil.BundleDataItem;
import com.raytheon.uf.viz.core.rsc.URICatalog;
import com.raytheon.uf.viz.core.rsc.URICatalog.IURIRefreshCallback;
import com.raytheon.uf.viz.ui.menus.xml.BundleMenuContribution;
-import com.raytheon.viz.ui.MenuLoader;
-import com.raytheon.viz.ui.actions.LoadSerializedXml;
+import com.raytheon.viz.ui.BundleLoader;
+import com.raytheon.viz.ui.BundleLoader.BundleInfoType;
+import com.raytheon.viz.ui.BundleProductLoader;
+import com.raytheon.viz.ui.UiUtil;
+import com.raytheon.viz.ui.editor.AbstractEditor;
/**
* Provides an Eclipse menu contribution that loads a bundle, and is decorated
@@ -345,15 +348,19 @@ public class BundleContributionItem extends ContributionItem {
private void loadBundle(Event event) {
try {
+ Bundle bundle = BundleLoader.getBundle(
+ this.menuContribution.xml.bundleFile, substitutions,
+ BundleInfoType.FILE_LOCATION);
+ AbstractEditor editor = UiUtil.createOrOpenEditor(
+ this.menuContribution.xml.editorType, bundle.getDisplays());
+ BundleLoader loader;
if (this.menuContribution.xml.fullBundleLoad == null
|| this.menuContribution.xml.fullBundleLoad == false) {
- MenuLoader.loadProduct(this.menuContribution.xml.editorType,
- this.menuContribution.xml.bundleFile, substitutions);
+ loader = new BundleProductLoader(editor, bundle);
} else {
- LoadSerializedXml.loadTo(PathManagerFactory.getPathManager()
- .getStaticFile(this.menuContribution.xml.bundleFile),
- substitutions);
+ loader = new BundleLoader(editor, bundle);
}
+ loader.schedule();
if (this.menuContribution.xml.command != null) {
ICommandService service = (ICommandService) PlatformUI
diff --git a/cave/com.raytheon.viz.alerts/src/com/raytheon/viz/alerts/observers/ProductAlertObserver.java b/cave/com.raytheon.viz.alerts/src/com/raytheon/viz/alerts/observers/ProductAlertObserver.java
index c83bf232d9..7fc148a79f 100644
--- a/cave/com.raytheon.viz.alerts/src/com/raytheon/viz/alerts/observers/ProductAlertObserver.java
+++ b/cave/com.raytheon.viz.alerts/src/com/raytheon/viz/alerts/observers/ProductAlertObserver.java
@@ -19,6 +19,7 @@
**/
package com.raytheon.viz.alerts.observers;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -306,58 +307,49 @@ public class ProductAlertObserver implements INotificationObserver {
PracticeDataURINotificationMessage uriMsg = (PracticeDataURINotificationMessage) payLoad;
dataURIs = uriMsg.getDataURIs();
}
- for (int i = 0; i < dataURIs.length; ++i) {
- String str = dataURIs[i];
- processDataURI(str);
- }
-
- startWrappers();
-
- if (dataURIs != null && dataURIs.length > 0) {
- alertsProcessed += dataURIs.length;
- }
-
- long curTime = System.currentTimeMillis();
- if (curTime - ALERT_LOG_INTERVAL > lastLogTime) {
- if (alertsProcessed > 0) {
- statusHandler.handle(Priority.VERBOSE, "Processed "
- + alertsProcessed + " alerts in the last "
- + ((curTime - lastLogTime) / 60000)
- + " minutes");
- alertsProcessed = 0;
- }
- lastLogTime = curTime;
- }
+ processDataURIs(Arrays.asList(dataURIs));
}
}
}
- public static void processDerivedAlerts(Collection datauris) {
- for (String datauri : datauris) {
- getInstance().processDataURI(datauri);
+ /**
+ * Processes the DataURIs as alert messages
+ *
+ * @param datauris
+ */
+ public static void processDataURIAlerts(Collection datauris) {
+ getInstance().processDataURIs(datauris);
+ }
+
+ private synchronized void processDataURIs(Collection dataURIs) {
+ for (String str : dataURIs) {
+ processDataURI(str);
+ }
+
+ startWrappers();
+
+ if (dataURIs != null && dataURIs.size() > 0) {
+ alertsProcessed += dataURIs.size();
+ }
+
+ long curTime = System.currentTimeMillis();
+ if (curTime - ALERT_LOG_INTERVAL > lastLogTime) {
+ if (alertsProcessed > 0) {
+ statusHandler.handle(Priority.VERBOSE, "Processed "
+ + alertsProcessed + " alerts in the last "
+ + ((curTime - lastLogTime) / 60000) + " minutes");
+ alertsProcessed = 0;
+ }
+ lastLogTime = curTime;
}
- getInstance().startWrappers();
}
private void processDataURI(String datauri) {
if (datauri == null)
return;
try {
- Map attribs;
- try {
- attribs = RecordFactory.getInstance().loadMapFromUri(datauri);
-
- } catch (NoPluginException e) {
- // ignore, if we hit this it means we received an alert from
- // edex about ingested data, but viz doesn't have the necessary
- // plugins to do anything with it
- return;
- } catch (Exception e1) {
- statusHandler.handle(Priority.WARN, e1.getLocalizedMessage(),
- e1);
- return;
- }
-
+ Map attribs = RecordFactory.getInstance()
+ .loadMapFromUri(datauri);
AlertMessage am = new AlertMessage();
am.dataURI = datauri;
am.decodedAlert = Collections.unmodifiableMap(attribs);
@@ -379,11 +371,12 @@ public class ProductAlertObserver implements INotificationObserver {
sendToObserver(obs, am);
}
}
-
- } catch (RuntimeException e) {
- statusHandler
- .handle(Priority.PROBLEM, "Error preparing updates", e);
-
+ } catch (NoPluginException e) {
+ // ignore, if we hit this it means we received an alert from
+ // edex about ingested data, but viz doesn't have the necessary
+ // plugins to do anything with it
+ } catch (Exception e1) {
+ statusHandler.handle(Priority.WARN, e1.getLocalizedMessage(), e1);
}
}
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/BaseGfePyController.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/BaseGfePyController.java
index 3305246d2d..e02600cd53 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/BaseGfePyController.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/BaseGfePyController.java
@@ -51,6 +51,8 @@ import com.raytheon.viz.gfe.smartscript.FieldDefinition;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 10, 2008 njensen Initial creation
+ * Jan 18, 2013 njensen Added garbageCollect()
+ *
*
*
* @author njensen
@@ -354,4 +356,20 @@ public abstract class BaseGfePyController extends PythonScript implements
execute("addModule", INTERFACE, argMap);
}
+ /**
+ * Runs the python garbage collector. This should be run at the end of a
+ * procedure or tool in case the custom python used tk. If the python used
+ * tk and it is not garbage collected, errors about invalid threads may
+ * occur when the garbage collector runs in another python interpreter.
+ */
+ public void garbageCollect() {
+ try {
+ jep.eval("import gc");
+ jep.eval("gc.collect()");
+ } catch (JepException e) {
+ statusHandler.handle(Priority.PROBLEM,
+ "Error garbage collecting GFE python interpreter", e);
+ }
+ }
+
}
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/DbParm.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/DbParm.java
index 688b4d7f7c..aa9d2efe9c 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/DbParm.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/DbParm.java
@@ -73,6 +73,7 @@ import com.raytheon.viz.gfe.core.griddata.IGridData;
* to use IFPClient
* 02/23/12 #346 dgilling Implement a dispose method.
* 03/01/12 #346 dgilling Re-order dispose method.
+ * 01/21/12 #1504 randerso Cleaned up old debug logging to improve performance
*
*
*
@@ -411,6 +412,7 @@ public class DbParm extends Parm {
// normal mode
if (normal) {
Arrays.sort(grids);
+
// Now replace the existing grids with the new ones
replaceGrids(affectedTimeRange, grids);
@@ -621,6 +623,7 @@ public class DbParm extends Parm {
success &= allSaved;
}
+
// if any pending saves
if (sgr.size() > 0) {
if (doSave(sgr)) {
@@ -630,13 +633,7 @@ public class DbParm extends Parm {
} else {
success = false;
}
- }
-
- // if any pending saves
- if (sgr.size() > 0) {
- if (!doSave(sgr)) {
- success = false;
- }
+ pendingUnlocks.clear();
}
if (success) {
@@ -757,10 +754,10 @@ public class DbParm extends Parm {
List lreq = new ArrayList(timesToSave.size());
for (int i = 0; i < timesToSave.size(); i++) {
- String msg = "Reverting " + getParmID() + " tr="
- + timesToSave.get(i);
- statusHandler.handle(Priority.DEBUG, msg, new Exception("Debug: "
- + msg));
+ // String msg = "Reverting " + getParmID() + " tr="
+ // + timesToSave.get(i);
+ // statusHandler.handle(Priority.DEBUG, msg, new Exception("Debug: "
+ // + msg));
boolean success = true;
IGridData[] grids = null;
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/gridmanager/GridCanvas.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/gridmanager/GridCanvas.java
index fb3813d64f..ceebd780f3 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/gridmanager/GridCanvas.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/gridmanager/GridCanvas.java
@@ -24,9 +24,8 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
-import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -107,8 +106,11 @@ import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
* Apr 7, 2009 randerso Initial creation
* Jun 3, 2011 8919 rferrel Determine grid's VisMode based
* on imageOnEdit
- * 08/20/2012 #1082 randerso Moved calcStepTimes to AbstractParmManager for
+ * 08/20/2012 #1082 randerso Moved calcStepTimes to AbstractParmManager for
* use in PngWriter
+ * 11/30/2012 #1328 mschenke Made GFE use descriptor for time matching
+ * and time storage and manipulation
+ * 01/22/2013 #1518 randerso Removed use of Map with Parms as keys
*
*
*
@@ -256,8 +258,6 @@ public class GridCanvas extends Canvas implements IMessageClient {
private ArrayList gridBarList;
- private Map parmToGridBar;
-
private Rectangle selection;
private MenuManager menuMgr;
@@ -294,7 +294,6 @@ public class GridCanvas extends Canvas implements IMessageClient {
dataMgr = gridManager.getDataManager();
gridBarList = new ArrayList();
- parmToGridBar = new HashMap();
Parm[] displayedParms = gridManager.getDataManager().getParmManager()
.getDisplayedParms();
@@ -684,10 +683,13 @@ public class GridCanvas extends Canvas implements IMessageClient {
if (deletions != null) {
for (Parm parm : deletions) {
- GridBar gridBar = parmToGridBar.remove(parm);
- if (gridBar != null) {
- gridBarList.remove(gridBar);
- gridBar.dispose();
+ Iterator iter = gridBarList.iterator();
+ while (iter.hasNext()) {
+ GridBar gridBar = iter.next();
+ if (gridBar.getParm().equals(parm)) {
+ iter.remove();
+ gridBar.dispose();
+ }
}
}
}
@@ -695,11 +697,8 @@ public class GridCanvas extends Canvas implements IMessageClient {
if (additions != null) {
for (Parm parm : additions) {
if (!parm.getGridInfo().isTimeIndependentParm()) {
- if (!parmToGridBar.containsKey(parm)) {
- GridBar gridBar = new GridBar(this, parm, gridManager);
- gridBarList.add(gridBar);
- parmToGridBar.put(parm, gridBar);
- }
+ GridBar gridBar = new GridBar(this, parm, gridManager);
+ gridBarList.add(gridBar);
}
}
}
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ifpimage/ImageLegendResource.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ifpimage/ImageLegendResource.java
index 9ef5676f0c..da5272e317 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ifpimage/ImageLegendResource.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ifpimage/ImageLegendResource.java
@@ -21,7 +21,6 @@ package com.raytheon.viz.gfe.ifpimage;
import java.util.ArrayList;
import java.util.Calendar;
-import java.util.Collection;
import java.util.Formatter;
import java.util.HashMap;
import java.util.List;
@@ -31,6 +30,7 @@ import java.util.TimeZone;
import org.eclipse.swt.graphics.RGB;
+import com.raytheon.uf.common.dataplugin.gfe.type.Pair;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.TimeRange;
import com.raytheon.uf.viz.core.RGBColors;
@@ -42,7 +42,6 @@ import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability;
import com.raytheon.viz.core.ColorUtil;
import com.raytheon.viz.gfe.Activator;
import com.raytheon.viz.gfe.core.DataManager;
-import com.raytheon.viz.gfe.core.griddata.IGridData;
import com.raytheon.viz.gfe.core.parm.Parm;
import com.raytheon.viz.gfe.core.parm.ParmDisplayAttributes.VisMode;
import com.raytheon.viz.gfe.rsc.GFELegendResource;
@@ -62,6 +61,10 @@ import com.raytheon.viz.gfe.rsc.GFEResource;
* Jul 10, 2012 15186 ryu Set legend font
* Aug 20, 2012 #1078 dgilling Fix handling of ImageLegend_color
* setting.
+ * Nov 30, 2012 #1328 mschenke Made GFE use descriptor for time matching
+ * and time storage and manipulation
+ * Jan 22, 2013 #1518 randerso Removed use of Map with Parms as keys,
+ * really just needed a list anyway.
*
*
*
@@ -100,9 +103,8 @@ public class ImageLegendResource extends GFELegendResource {
@Override
public LegendEntry[] getLegendData(IDescriptor descriptor) {
- Map parmRscMap = new HashMap();
- Collection parms = getLegendOrderedParms(descriptor, parmRscMap);
- LegendData[] data = makeLegend(parms, parmRscMap);
+ List> parms = getLegendOrderedParms(descriptor);
+ LegendData[] data = makeLegend(parms);
LegendEntry[] entries = new LegendEntry[data.length];
for (int i = 0; i < entries.length; ++i) {
@@ -113,15 +115,15 @@ public class ImageLegendResource extends GFELegendResource {
return entries;
}
- private LegendData[] makeLegend(Collection parms,
- Map parmRscMap) {
+ private LegendData[] makeLegend(List> parms) {
FramesInfo currInfo = descriptor.getFramesInfo();
DataTime curTime = currInfo.getCurrentFrame();
// loop through the grids
List legendData = new ArrayList();
- for (Parm parm : parms) {
- ResourcePair rp = parmRscMap.get(parm);
+ for (Pair pair : parms) {
+ Parm parm = pair.getFirst();
+ ResourcePair rp = pair.getSecond();
GFEResource rsc = (GFEResource) rp.getResource();
String parmName = parm.getParmID().getParmName();
ResourceProperties props = rp.getProperties();
@@ -150,7 +152,6 @@ public class ImageLegendResource extends GFELegendResource {
// get the units for the time string
String units = rsc.getParm().getGridInfo().getUnitString();
- IGridData[] gd = new IGridData[0];
Locale locale = Locale.getDefault();
String lang = getLanguage();
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureJob.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureJob.java
index ab3d246e95..a9b8a5d7c3 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureJob.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/procedures/ProcedureJob.java
@@ -56,6 +56,7 @@ import com.raytheon.viz.gfe.jobs.AsyncProgressJob;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 8, 2009 njensen Initial creation
+ * Jan 18, 2013 1509 njensen Garbage collect after running procedure
*
*
*
@@ -395,6 +396,7 @@ public class ProcedureJob extends AbstractQueueJob {
statusHandler.handle(Priority.PROBLEM, "Error executing procedure "
+ procedureName, e);
} finally {
+ controller.garbageCollect();
progressJob.done(pjStatus);
}
}
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFELegendResource.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFELegendResource.java
index ce10249422..4431e1be17 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFELegendResource.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFELegendResource.java
@@ -23,13 +23,11 @@ import static com.raytheon.viz.gfe.core.parm.ParmDisplayAttributes.VisMode.IMAGE
import java.text.SimpleDateFormat;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
+import java.util.Comparator;
import java.util.Date;
-import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.TimeZone;
import org.eclipse.jface.preference.IPreferenceStore;
@@ -37,6 +35,7 @@ import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID;
import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID;
+import com.raytheon.uf.common.dataplugin.gfe.type.Pair;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
@@ -65,6 +64,7 @@ import com.raytheon.viz.gfe.PreferenceInitializer;
import com.raytheon.viz.gfe.core.DataManager;
import com.raytheon.viz.gfe.core.ISpatialDisplayManager;
import com.raytheon.viz.gfe.core.griddata.IGridData;
+import com.raytheon.viz.gfe.core.msgs.INewModelAvailableListener;
import com.raytheon.viz.gfe.core.msgs.Message;
import com.raytheon.viz.gfe.core.msgs.Message.IMessageClient;
import com.raytheon.viz.gfe.core.msgs.ShowQuickViewDataMsg;
@@ -83,13 +83,18 @@ import com.raytheon.viz.ui.input.InputAdapter;
* 03/17/2008 chammack Initial Creation.
* 08/19/2009 2547 rjpeter Implement Test/Prac database display.
* 07/10/2012 15186 ryu Clean up initInternal per Ron
+ * 11/30/2012 #1328 mschenke Made GFE use descriptor for time matching
+ * and time storage and manipulation
+ * 01/22/2013 #1518 randerso Removed use of Map with Parms as keys,
+ * really just needed a list anyway.
*
*
* @author chammack
* @version 1.0
*/
public class GFELegendResource extends
- AbstractLegendResource implements IMessageClient {
+ AbstractLegendResource implements
+ IMessageClient, INewModelAvailableListener {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(GFELegendResource.class);
@@ -118,8 +123,6 @@ public class GFELegendResource extends
private class GFELegendInputHandler extends InputAdapter {
- private boolean inDrag;
-
ResourcePair mouseDownRsc = null;
@Override
@@ -158,10 +161,9 @@ public class GFELegendResource extends
if (rsc.getResource() instanceof GFEResource) {
GFEResource gfeRsc = (GFEResource) rsc
.getResource();
- DataManager
- .getCurrentInstance()
- .getSpatialDisplayManager()
- .makeVisible(gfeRsc.getParm(),
+ GFELegendResource.this.dataManager
+ .getSpatialDisplayManager().makeVisible(
+ gfeRsc.getParm(),
!props.isVisible(), false);
} else {
@@ -173,8 +175,7 @@ public class GFELegendResource extends
} else if (mouseButton == 2) {
if (rsc.getResource() instanceof GFEResource) {
GFEResource gfeRsc = (GFEResource) rsc.getResource();
- ISpatialDisplayManager sdm = DataManager
- .getCurrentInstance()
+ ISpatialDisplayManager sdm = GFELegendResource.this.dataManager
.getSpatialDisplayManager();
Parm parm = gfeRsc.getParm();
@@ -242,7 +243,6 @@ public class GFELegendResource extends
}.run();
}
- @SuppressWarnings("unchecked")
public GFELegendResource(DataManager dataManager,
GFELegendResourceData resourceData, LoadProperties loadProps) {
super(resourceData, loadProps);
@@ -257,8 +257,6 @@ public class GFELegendResource extends
} catch (Exception e) {
mode = LegendMode.GRIDS;
}
-
- Message.registerInterest(this, ShowQuickViewDataMsg.class);
}
protected void addSpaces(StringBuilder sb, int numSpace) {
@@ -267,23 +265,6 @@ public class GFELegendResource extends
}
}
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#finalize()
- */
- @SuppressWarnings("unchecked")
- @Override
- protected void finalize() throws Throwable {
- // FIXME: this needs to be a dispose method.
- Message.unregisterInterest(this, ShowQuickViewDataMsg.class);
-
- if (font != null) {
- font.dispose();
- font = null;
- }
- }
-
/*
* (non-Javadoc)
*
@@ -319,26 +300,21 @@ public class GFELegendResource extends
}
/**
- * Gets an ordered collection of Parms to display for the legend.
+ * Gets an ordered list of Parm/ResourcePair pairs to display for the
+ * legend.
*
* @param descriptor
- * @param parmRscMap
- * optional map to create Parm->ResourcePair mapping for parms
- * returned
* @return
*/
- protected Collection getLegendOrderedParms(IDescriptor descriptor,
- Map parmRscMap) {
- List parms = new ArrayList();
+ protected List> getLegendOrderedParms(
+ IDescriptor descriptor) {
+ List> parms = new ArrayList>();
for (ResourcePair rp : descriptor.getResourceList()) {
if (rp.getResource() instanceof GFEResource) {
Parm parm = ((GFEResource) rp.getResource()).getParm();
if (qvGrid == null
|| (qvGrid != null && qvGrid.getParm() == parm)) {
- parms.add(parm);
- if (parmRscMap != null) {
- parmRscMap.put(parm, rp);
- }
+ parms.add(new Pair(parm, rp));
if (qvGrid != null) {
break;
}
@@ -346,8 +322,14 @@ public class GFELegendResource extends
}
}
- Collections.sort(parms);
- Collections.reverse(parms);
+ Collections.sort(parms, new Comparator>() {
+
+ @Override
+ public int compare(Pair o1,
+ Pair o2) {
+ return o2.getFirst().compareTo(o1.getFirst());
+ }
+ });
return parms;
}
@@ -362,8 +344,7 @@ public class GFELegendResource extends
.getActivatedParm();
StringBuilder labelBuilder = new StringBuilder();
- Map parmRscMap = new HashMap();
- Collection parms = getLegendOrderedParms(descriptor, parmRscMap);
+ List> parms = getLegendOrderedParms(descriptor);
Parm qvParm = null;
if (qvGrid != null) {
qvParm = qvGrid.getParm();
@@ -374,11 +355,12 @@ public class GFELegendResource extends
ParmID topoID = dataManager.getTopoManager().getCompositeParmID();
// Topmost resources: GFE Parms
- for (Parm parm : parms) {
+ for (Pair pair : parms) {
+ Parm parm = pair.getFirst();
ParmID parmId = parm.getParmID();
DatabaseID dbId = parmId.getDbId();
StringBuilder sb = new StringBuilder();
- ResourcePair rp = parmRscMap.get(parm);
+ ResourcePair rp = pair.getSecond();
GFEResource rsc = (GFEResource) rp.getResource();
LegendData ld = new LegendData();
ResourceProperties props = rp.getProperties();
@@ -435,33 +417,27 @@ public class GFELegendResource extends
// get the model name
labelBuilder.setLength(0);
- labelBuilder.append(dbId.getModelName());
+ labelBuilder.append(dbId.getShortModelId());
- boolean iscTyped = false;
- if (dataManager.getParmManager().iscMode()
- && dbId.equals(dataManager.getParmManager()
- .getMutableDatabase())) {
+ // FIXME this is from A1 and is not consistent with the code in
+ // getLongestFields
- ParmID iscPID = dataManager.getParmManager().getISCParmID(
- parmId);
- if (iscPID.isValid()) {
- // vparms (i.e. temp hazards) can't get here
- String iscStr = "+" + iscPID.getDbId().getDbType()
- + iscPID.getDbId().getModelName();
- labelBuilder.append(iscStr);
- iscTyped = true;
- }
- }
+ // if (_showISCMode && _quickViewGrid == GridID()
+ // && _grids[i].gridID().parm()->parmID().databaseID() ==
+ // _dbss->dataManager()->parmMgr()->mutableDatabase())
+ // {
+ // unsigned int mpos = 0;
+ // if (modelText.found(' ', mpos))
+ // {
+ // ParmID iscPID =
+ // _dbss->dataManager()->parmMgr()->getISCParmID(
+ // _grids[i].gridID().parm()->parmID());
+ // TextString iscStr = "+" + iscPID.databaseID().type() +
+ // iscPID.databaseID().model();
+ // modelText.insertBefore(mpos, iscStr);
+ // }
+ // }
- if (!iscTyped) {
- String type = dbId.getDbType();
- if ((type != null) && (type.length() > 0)) {
- labelBuilder.append("_");
- labelBuilder.append(type);
- }
- }
-
- labelBuilder.append(" (" + dbId.getSiteId() + ")");
sb.append(labelBuilder.toString());
diff = lengths[3] - labelBuilder.length();
addSpaces(sb, diff + 1);
@@ -562,16 +538,14 @@ public class GFELegendResource extends
* @param descriptor
* @return
*/
- private int[] getLongestFields(Collection parms) {
+ private int[] getLongestFields(List> parms) {
// Iterator rl = descriptor.getResourceList().iterator();
int[] sz = new int[4];
StringBuilder labelBuilder = new StringBuilder();
// synchronized (rl) {
// while (rl.hasNext()) {
- for (Parm parm : parms) {
- // AbstractVizResource, ?> resource = rl.next().getResource();
- // if (resource instanceof GFEResource) {
- // Parm parm = ((GFEResource) resource).getParm();
+ for (Pair pair : parms) {
+ Parm parm = pair.getFirst();
ParmID parmId = parm.getParmID();
sz[0] = Math.max(sz[0], parmId.getParmName().length());
sz[1] = Math.max(sz[1], parmId.getParmLevel().length());
@@ -580,52 +554,33 @@ public class GFELegendResource extends
DatabaseID dbId = parmId.getDbId();
labelBuilder.setLength(0);
- labelBuilder.append(dbId.getModelName());
+ labelBuilder.append(dbId.getShortModelId());
- boolean iscTyped = false;
- if (dataManager.getParmManager().iscMode()
- && dbId.equals(dataManager.getParmManager()
- .getMutableDatabase())) {
+ // FIXME this is A1 code and is not consistent with the code in
+ // getLegendDataGrids
- ParmID iscPID = dataManager.getParmManager().getISCParmID(
- parmId);
- if (iscPID.isValid()) {
- // vparms (i.e. temp hazards) can't get here
- String iscStr = "+" + iscPID.getDbId().getDbType()
- + iscPID.getDbId().getModelName();
- labelBuilder.append(iscStr);
- iscTyped = true;
- }
- }
-
- if (!iscTyped) {
- String type = dbId.getDbType();
- if ((type != null) && (type.length() > 0)) {
- labelBuilder.append("_");
- labelBuilder.append(type);
- }
- }
-
- labelBuilder.append(" (" + dbId.getSiteId() + ")");
- // TODO: FIXME
// if (showIscMode
// && ids[i].gridID().parm()->parmID().databaseID() ==
// _dbss->dataManager()->parmMgr()->mutableDatabase())
// label += "+VISC";
- sz[3] = Math.max(sz[3], labelBuilder.length());
- // }
+ sz[3] = Math.max(sz[3], labelBuilder.length());
}
- // }
return sz;
}
+ @SuppressWarnings("unchecked")
@Override
protected void disposeInternal() {
super.disposeInternal();
+
+ this.dataManager.getParmManager().removeNewModelAvailableListener(this);
+ Message.unregisterInterest(this, ShowQuickViewDataMsg.class);
+
if (font != null) {
font.dispose();
+ font = null;
}
IDisplayPaneContainer container = getResourceContainer();
if (container != null) {
@@ -633,9 +588,14 @@ public class GFELegendResource extends
}
}
+ @SuppressWarnings("unchecked")
@Override
protected void initInternal(IGraphicsTarget target) throws VizException {
super.initInternal(target);
+
+ Message.registerInterest(this, ShowQuickViewDataMsg.class);
+ this.dataManager.getParmManager().addNewModelAvailableListener(this);
+
int fontNum = 3;
if (GFEPreference.contains("SELegend_font")) {
fontNum = GFEPreference.getIntPreference("SELegend_font");
@@ -689,4 +649,9 @@ public class GFELegendResource extends
}
}
+ @Override
+ public void newModelAvailable(DatabaseID additions) {
+ issueRefresh();
+ }
+
}
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/colorbar/DiscreteColorbar.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/colorbar/DiscreteColorbar.java
index 503d3ad132..a504f92471 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/colorbar/DiscreteColorbar.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/colorbar/DiscreteColorbar.java
@@ -82,7 +82,7 @@ import com.vividsolutions.jts.geom.Coordinate;
/**
* Implements a colorbar for continuous (scalar and vector) elements
- *
+ *
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
@@ -91,11 +91,13 @@ import com.vividsolutions.jts.geom.Coordinate;
* Aug 20, 2008 dglazesk Updated for the new ColorMap interface
* Aug 20, 2012 1079 randerso Changed to display all discrete values for
* non-overlapping discretes
- * Jan 9, 2013 15661 ryu Set font for drawing regular Wx/discrete parm labels.
- * Jan 10, 2013 15548 ryu Update colorbar when new discrete colormap is selected
- *
+ * Jan 9, 2013 15661 ryu Set font for drawing regular Wx/discrete parm labels.
+ * Jan 10, 2013 15548 ryu Update colorbar when new discrete colormap is selected
+ * Jan 23, 2013 #1524 randerso Fix missing discrete color bar and error when clicking
+ * on discrete color bar when no grid exists
+ *
*
- *
+ *
* @author chammack
* @version 1.0
*/
@@ -139,7 +141,7 @@ public class DiscreteColorbar implements IColorBarDisplay,
/**
* Constructor for the Discrete Color Bar
- *
+ *
* @param parm
* The parm
* @param colorbarResource
@@ -162,8 +164,7 @@ public class DiscreteColorbar implements IColorBarDisplay,
DataManager dataManager = parm.getDataManager();
ISpatialDisplayManager spatialDisplayManager = dataManager
.getSpatialDisplayManager();
- ResourcePair resourcePair = spatialDisplayManager
- .getResourcePair(parm);
+ ResourcePair resourcePair = spatialDisplayManager.getResourcePair(parm);
AbstractVizResource, ?> resource = resourcePair.getResource();
ColorMapParameters params = resource.getCapability(
ColorMapCapability.class).getColorMapParameters();
@@ -172,7 +173,7 @@ public class DiscreteColorbar implements IColorBarDisplay,
/*
* (non-Javadoc)
- *
+ *
* @see com.raytheon.viz.gfe.rsc.colorbar.IColorBarDisplay#dispose()
*/
@Override
@@ -193,7 +194,7 @@ public class DiscreteColorbar implements IColorBarDisplay,
/**
* Gets the Discrete Color map.
- *
+ *
* @return Returns the color map used for the discrete data.
*/
public static ColorMap getFallbackColorMap() {
@@ -202,7 +203,7 @@ public class DiscreteColorbar implements IColorBarDisplay,
/*
* (non-Javadoc)
- *
+ *
* @see
* com.raytheon.viz.core.drawables.IRenderable#paint(com.raytheon.viz.core
* .IGraphicsTarget, com.raytheon.viz.core.drawables.PaintProperties)
@@ -210,7 +211,7 @@ public class DiscreteColorbar implements IColorBarDisplay,
@Override
public void paint(IGraphicsTarget target, PaintProperties paintProps)
throws VizException {
- DataTime currentTime = paintProps.getDataTime();
+ DataTime currentTime = paintProps.getFramesInfo().getCurrentFrame();
if (parm == null || currentTime == null) {
return;
}
@@ -426,7 +427,7 @@ public class DiscreteColorbar implements IColorBarDisplay,
* Labels that do not fit their designated band on the bar will be
* truncated. Pickup value text will always be displayed in full, so any
* text it overlaps will not be drawn.
- *
+ *
* @param target
* The graphics target on which to draw
* @param colorTable
@@ -557,7 +558,7 @@ public class DiscreteColorbar implements IColorBarDisplay,
/**
* Draws the colorbar once colors and patterns have been decided.
- *
+ *
* @param target
* The graphics target on which to draw.
* @param pixelExtent
@@ -657,34 +658,42 @@ public class DiscreteColorbar implements IColorBarDisplay,
/*
* (non-Javadoc)
- *
+ *
* @see
* com.raytheon.viz.gfe.rsc.colorbar.IColorBarDisplay#getValueAt(double[],
* int)
*/
@Override
public WxValue getValueAt(double[] coord, int mouseButton) {
- PixelExtent lastExtent = colorbarResource.getExtent();
- float fractionX = (float) ((coord[0] - lastExtent.getMinX()) / (lastExtent
- .getMaxX() - lastExtent.getMinX()));
- int index = (int) (gridKeys.size() * fractionX);
- if (index >= gridKeys.size()) {
- index = gridKeys.size() - 1;
- }
+ WxValue retVal = null;
+ if (!gridKeys.isEmpty()) {
+ PixelExtent lastExtent = colorbarResource.getExtent();
+ float fractionX = (float) ((coord[0] - lastExtent.getMinX()) / (lastExtent
+ .getMaxX() - lastExtent.getMinX()));
+ int index = (int) (gridKeys.size() * fractionX);
+ if (index >= gridKeys.size()) {
+ index = gridKeys.size() - 1;
+ }
- switch (parm.getGridInfo().getGridType()) {
- case DISCRETE: {
- DiscreteWxValue castedVal = (DiscreteWxValue) gridKeys.get(index);
- return new DiscreteWxValue(castedVal.getDiscreteKey(), parm);
- }
- case WEATHER: {
- WeatherWxValue castedVal = (WeatherWxValue) gridKeys.get(index);
- return new WeatherWxValue(castedVal.getWeatherKey(), parm);
- }
- default:
- throw new IllegalArgumentException(
- "getValueAt does not support type: "
- + parm.getGridInfo().getGridType());
+ switch (parm.getGridInfo().getGridType()) {
+ case DISCRETE: {
+ DiscreteWxValue castedVal = (DiscreteWxValue) gridKeys
+ .get(index);
+ retVal = new DiscreteWxValue(castedVal.getDiscreteKey(), parm);
+ break;
+ }
+ case WEATHER: {
+ WeatherWxValue castedVal = (WeatherWxValue) gridKeys.get(index);
+ retVal = new WeatherWxValue(castedVal.getWeatherKey(), parm);
+
+ break;
+ }
+ default:
+ throw new IllegalArgumentException(
+ "getValueAt does not support type: "
+ + parm.getGridInfo().getGridType());
+ }
}
+ return retVal;
}
}
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/colorbar/GFEColorbarResource.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/colorbar/GFEColorbarResource.java
index 9e5888fdf6..22a6bafaec 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/colorbar/GFEColorbarResource.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/colorbar/GFEColorbarResource.java
@@ -28,8 +28,6 @@ import java.util.Set;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GFERecord.GridType;
import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID;
@@ -98,8 +96,10 @@ import com.raytheon.viz.ui.input.InputAdapter;
* 05Aug2008 #1405 ebabin Fix fo delta not displaying after first use.
* 06/03/2011 #8919 rferrel No longer display color bar when
* VisMode is GRAPHIC
- * 11/13/20112 #1298 rferrel Changes for non-blocking SetDeltaDialog.
+ * 11/13/2012 #1298 rferrel Changes for non-blocking SetDeltaDialog.
* Changes for non-blocking SetValueDialog.
+ * 01/23/2013 #1524 randerso Fix error when clicking on discrete color bar when
+ * no grid exists
*
*
*
@@ -175,6 +175,10 @@ public class GFEColorbarResource extends
private void setPickup(double[] v, int mouseButton) {
WxValue val = colorbarDisplay.getValueAt(v, mouseButton);
+ if (val == null) {
+ return;
+ }
+
Parm parm = getParm();
if (parm == null) {
throw new IllegalStateException("Parm is null from colorbar");
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolJob.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolJob.java
index 05dcae6f9f..c154f9439b 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolJob.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/script/SmartToolJob.java
@@ -53,6 +53,7 @@ import com.raytheon.viz.gfe.smarttool.Tool;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 19, 2010 njensen Initial creation
+ * Jan 18, 2013 1509 njensen Garbage collect after running tool
*
*
*
@@ -164,6 +165,7 @@ public class SmartToolJob extends AbstractQueueJob {
"Error in smart tool", e);
throw e;
} finally {
+ python.garbageCollect();
progressJob.done(pjResult);
req = request;
request = null;
diff --git a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/GridProductBrowserDataDefinition.java b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/GridProductBrowserDataDefinition.java
index 16a87185fc..f0d46ed512 100644
--- a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/GridProductBrowserDataDefinition.java
+++ b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/GridProductBrowserDataDefinition.java
@@ -47,9 +47,12 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.datastructure.DataCubeContainer;
+import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
+import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.level.LevelMappingFactory;
import com.raytheon.uf.viz.core.rsc.DisplayType;
+import com.raytheon.uf.viz.core.rsc.ResourceProperties;
import com.raytheon.uf.viz.core.rsc.ResourceType;
import com.raytheon.uf.viz.derivparam.library.DerivParamDesc;
import com.raytheon.uf.viz.derivparam.library.DerivedParameterGenerator;
@@ -129,6 +132,48 @@ public class GridProductBrowserDataDefinition extends
return new GridResourceData();
}
+ @Override
+ public void constructResource(String[] selection, ResourceType type) {
+ GridInventory inventory = getInventory();
+ if (inventory == null) {
+ super.constructResource(selection, type);
+ return;
+ }
+ if (type != null) {
+ loadProperties.setResourceType(type);
+ }
+ HashMap parameters = getProductParameters(
+ selection, order);
+ List ensembles = null;
+ try {
+ ensembles = inventory.getEnsembles(parameters);
+ } catch (VizException e) {
+ statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
+ }
+ if (ensembles != null && ensembles.size() > 1) {
+ Collections.sort(ensembles);
+ List pairs = new ArrayList();
+ for (String ensemble : ensembles) {
+ ResourcePair pair = new ResourcePair();
+ resourceData = getResourceData();
+ HashMap newParameters = new HashMap(
+ parameters);
+ newParameters.put(GridConstants.ENSEMBLE_ID,
+ new RequestConstraint(ensemble));
+ resourceData.setMetadataMap(newParameters);
+ pair.setResourceData(resourceData);
+ pair.setLoadProperties(loadProperties);
+ pair.setProperties(new ResourceProperties());
+ pairs.add(pair);
+ }
+ constructResource(pairs);
+ } else {
+ resourceData = getResourceData();
+ resourceData.setMetadataMap(parameters);
+ constructResource();
+ }
+ }
+
@Override
protected String[] queryData(String param,
HashMap queryList) {
diff --git a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/inv/GridUpdater.java b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/inv/GridUpdater.java
index 227c654343..367873f2e3 100644
--- a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/inv/GridUpdater.java
+++ b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/inv/GridUpdater.java
@@ -298,7 +298,7 @@ public class GridUpdater implements IAlertObserver {
}
}
myUpdates.addAll(datauris);
- ProductAlertObserver.processDerivedAlerts(datauris);
+ ProductAlertObserver.processDataURIAlerts(datauris);
}
/**
diff --git a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/inv/RadarUpdater.java b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/inv/RadarUpdater.java
index 81c04a55b4..8dc2089ab6 100644
--- a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/inv/RadarUpdater.java
+++ b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/inv/RadarUpdater.java
@@ -203,7 +203,7 @@ public class RadarUpdater implements IAlertObserver {
"Unable to generate updates for derived product", e);
}
}
- ProductAlertObserver.processDerivedAlerts(datauris);
+ ProductAlertObserver.processDataURIAlerts(datauris);
}
private CacheKey getCacheKey(RadarRequestableLevelNode rNode) {
diff --git a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/general/AbstractGridResource.java b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/general/AbstractGridResource.java
index ed9a9b0ae8..0b9037e1f6 100644
--- a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/general/AbstractGridResource.java
+++ b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/general/AbstractGridResource.java
@@ -51,6 +51,7 @@ import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.drawables.ColorMapLoader;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
+import com.raytheon.uf.viz.core.drawables.ColorMapParameters.PersistedParameters;
import com.raytheon.uf.viz.core.drawables.IRenderable;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.exception.VizException;
@@ -595,6 +596,13 @@ public abstract class AbstractGridResource
// reuse the old parameters. This is useful when the resource is
// sharing capabilities, for example in an FFGVizGroupResource.
newParameters = oldParameters;
+ } else if (oldParameters != null) {
+ newParameters.setColorMapName(oldParameters.getColorMapName());
+ newParameters.setColorMap(oldParameters.getColorMap());
+ PersistedParameters persisted = oldParameters.getPersisted();
+ if (persisted != null) {
+ newParameters.applyPersistedParameters(persisted);
+ }
}
return newParameters;
}
diff --git a/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResourceData.java b/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResourceData.java
index 71705c8b2d..10340b221c 100644
--- a/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResourceData.java
+++ b/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResourceData.java
@@ -81,6 +81,16 @@ public class LightningResourceData extends AbstractRequestableResourceData {
return rsc;
}
+ @Override
+ public boolean isUpdatingOnMetadataOnly() {
+ return true;
+ }
+
+ @Override
+ public boolean isRetrieveData() {
+ return true;
+ }
+
/**
* @return the handlingPositiveStrikes
*/
diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/MetarPrecipResource.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/MetarPrecipResource.java
index 06c0dcd3aa..58a3d61d28 100644
--- a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/MetarPrecipResource.java
+++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/MetarPrecipResource.java
@@ -157,7 +157,11 @@ public class MetarPrecipResource extends
@Override
protected void paintInternal(IGraphicsTarget target,
PaintProperties paintProps) throws VizException {
- List precips = data.get(paintProps.getDataTime());
+ DataTime time = paintProps.getDataTime();
+ if (time == null) {
+ return;
+ }
+ List precips = getPrecipData(time);
if (precips == null) {
dataProcessJob.schedule();
return;
@@ -201,6 +205,19 @@ public class MetarPrecipResource extends
target.drawStrings(strings);
}
+ private List getPrecipData(DataTime time) {
+ List currData = null;
+ synchronized (data) {
+ currData = data.get(time);
+ }
+ if (currData != null) {
+ synchronized (currData) {
+ return new ArrayList(currData);
+ }
+ }
+ return null;
+ }
+
@Override
protected void initInternal(IGraphicsTarget target) throws VizException {
@@ -262,7 +279,7 @@ public class MetarPrecipResource extends
Double magnification = getCapability(MagnificationCapability.class)
.getMagnification();
- List precips = data.get(descriptor
+ List precips = getPrecipData(descriptor
.getTimeForResource(this));
if (precips == null || precips.isEmpty()) {
@@ -299,12 +316,14 @@ public class MetarPrecipResource extends
private void processReproject() {
if (reproject) {
reproject = false;
- for (List dataList : data.values()) {
- for (RenderablePrecipData precip : dataList) {
- Coordinate latLon = precip.getLatLon();
- double[] px = descriptor.worldToPixel(new double[] {
- latLon.x, latLon.y });
- precip.string.setCoordinates(px[0], px[1], px[2]);
+ synchronized (data) {
+ for (List dataList : data.values()) {
+ for (RenderablePrecipData precip : dataList) {
+ Coordinate latLon = precip.getLatLon();
+ double[] px = descriptor.worldToPixel(new double[] {
+ latLon.x, latLon.y });
+ precip.string.setCoordinates(px[0], px[1], px[2]);
+ }
}
}
}
@@ -312,10 +331,12 @@ public class MetarPrecipResource extends
}
private void processRemoves() {
- while (!removes.isEmpty()) {
- DataTime toRemove = removes.poll();
- this.dataTimes.remove(toRemove);
- this.data.remove(toRemove);
+ synchronized (data) {
+ while (!removes.isEmpty()) {
+ DataTime toRemove = removes.poll();
+ this.dataTimes.remove(toRemove);
+ this.data.remove(toRemove);
+ }
}
}
@@ -354,10 +375,13 @@ public class MetarPrecipResource extends
// No need to reprocess times after the earliest update.
continue;
}
- Iterator iter = entry.getValue().iterator();
- while (iter.hasNext()) {
- if (newStations.contains(iter.next().getStationName())) {
- iter.remove();
+ synchronized (entry.getValue()) {
+ Iterator iter = entry.getValue()
+ .iterator();
+ while (iter.hasNext()) {
+ if (newStations.contains(iter.next().getStationName())) {
+ iter.remove();
+ }
}
}
addData(time, container.getBasePrecipData(time));
@@ -393,6 +417,9 @@ public class MetarPrecipResource extends
}
int curIndex = frameInfo.getFrameIndex();
int count = frameInfo.getFrameCount();
+ if (times.length != count) {
+ System.out.println("Uh oh");
+ }
// This will generate the number series 0, -1, 1, -2, 2, -3, 3...
for (int i = 0; i < count / 2 + 1; i = i < 0 ? -i : -i - 1) {
int index = (count + curIndex + i) % count;
@@ -417,27 +444,31 @@ public class MetarPrecipResource extends
}
}
}
- // This will only happen if frames were removed while we were processing
- // DOn't leave any half created frames
- for (DataTime time : baseOnly) {
- this.dataTimes.remove(time);
- this.data.remove(time);
+
+ synchronized (data) {
+ // This will only happen if frames were removed while we were
+ // processing. Don't leave any half created frames
+ for (DataTime time : baseOnly) {
+ this.dataTimes.remove(time);
+ this.data.remove(time);
+ }
}
}
private void addData(DataTime time, List precips) {
if (precips.isEmpty()) {
if (!dataTimes.contains(time)) {
- List newPrecips = Collections.emptyList();
- data.put(time, newPrecips);
+ synchronized (data) {
+ List newPrecips = Collections
+ .emptyList();
+ data.put(time, newPrecips);
+ }
dataTimes.add(time);
}
}
if (data.containsKey(time)) {
precips = new ArrayList