();
- map.put("Audio", LocalizationLevel.SITE);
- map.put("Configurations", LocalizationLevel.USER);
- map.put("Scripts", LocalizationLevel.SITE);
- map.put("Python", LocalizationLevel.SITE);
- return map;
- }
-}
diff --git a/cave/com.raytheon.uf.viz.alertviz.localization/src/com/raytheon/uf/viz/alertviz/localization/actions/AlertVizFileImportAction.java b/cave/com.raytheon.uf.viz.alertviz.localization/src/com/raytheon/uf/viz/alertviz/localization/actions/AlertVizFileImportAction.java
deleted file mode 100644
index 103ab383f1..0000000000
--- a/cave/com.raytheon.uf.viz.alertviz.localization/src/com/raytheon/uf/viz/alertviz/localization/actions/AlertVizFileImportAction.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/**
- * 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.alertviz.localization.actions;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Shell;
-
-import com.raytheon.uf.common.localization.IPathManager;
-import com.raytheon.uf.common.localization.LocalizationContext;
-import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
-import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
-import com.raytheon.uf.common.localization.LocalizationFile;
-import com.raytheon.uf.common.localization.PathManagerFactory;
-import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException;
-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.localization.filetreeview.FileTreeEntryData;
-import com.raytheon.viz.ui.VizWorkbenchManager;
-
-/**
- * Opens a file dialog for importing files.
- *
- *
- *
- * SOFTWARE HISTORY
- *
- * Date Ticket# Engineer Description
- * ------------ ---------- ----------- --------------------------
- * Apr 04, 2011 5853 bgonzale Initial creation
- *
- *
- *
- * @author bgonzale
- * @version 1.0
- */
-
-public class AlertVizFileImportAction extends Action {
- private static final transient IUFStatusHandler statusHandler = UFStatus
- .getHandler(AlertVizFileImportAction.class, "GDN_ADMIN",
- "GDN_ADMIN");
-
- private static final String PLUGIN_ID = "com.raytheon.uf.viz.alertviz.ui";
-
- private static final String ASTERISK = "*";
-
- private static final String ALL_FILES = "*.*";
-
- private LocalizationLevel level;
-
- private String[] extensions;
-
- private String path;
-
- /**
- * @param fileEntry
- *
- */
- public AlertVizFileImportAction(FileTreeEntryData fileEntry) {
- this(fileEntry, LocalizationLevel.USER);
- }
-
- /**
- * @param fileEntry
- * @param level
- *
- */
- public AlertVizFileImportAction(FileTreeEntryData fileEntry,
- LocalizationLevel level) {
- super("Import");
- this.level = level == null ? LocalizationLevel.USER : level;
- this.path = fileEntry.getPath();
- String[] fileEntryExtensions = fileEntry.getPathData().getFilter();
- this.extensions = new String[fileEntryExtensions.length + 1];
- for (int i = 0; i < fileEntryExtensions.length; ++i) {
- this.extensions[i] = ASTERISK + fileEntryExtensions[i];
- }
- this.extensions[this.extensions.length - 1] = ALL_FILES;
- }
-
- @Override
- public void run() {
- Shell shell = VizWorkbenchManager.getInstance().getCurrentWindow()
- .getShell();
- FileDialog fd = new FileDialog(shell, SWT.OPEN | SWT.MULTI);
-
- fd.setText("Import " + level + " File");
- fd.setFilterExtensions(extensions);
- fd.setFilterPath(System.getProperty("user.home"));
-
- String fileName = fd.open();
-
- if (fileName != null) {
- File file = new File(fileName);
-
- if (file.exists() && file.isFile()) {
- IPathManager pm = PathManagerFactory.getPathManager();
- LocalizationContext ctx = pm.getContext(
- LocalizationType.CAVE_STATIC, level);
- LocalizationFile locFile = pm.getLocalizationFile(ctx, path
- + File.separator + file.getName());
-
- try {
- saveToLocalizationFile(file, locFile);
- } catch (FileNotFoundException e) {
- statusHandler.handle(Priority.PROBLEM,
- e.getLocalizedMessage(), e);
- } catch (IOException e) {
- statusHandler.handle(Priority.PROBLEM,
- e.getLocalizedMessage(), e);
- } catch (LocalizationOpFailedException e) {
- statusHandler.handle(Priority.CRITICAL,
- "Error Importing file " + fileName, e);
- }
- }
- }
- }
-
- private void saveToLocalizationFile(File file, LocalizationFile locFile)
- throws IOException, LocalizationOpFailedException {
- File newFile = locFile.getFile();
- InputStream in = new FileInputStream(file);
- OutputStream out = new FileOutputStream(newFile);
- byte[] buff = new byte[1024];
- int len;
-
- while ((len = in.read(buff)) > 0) {
- out.write(buff, 0, len);
- }
- in.close();
- out.close();
- locFile.save();
- }
-}
diff --git a/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/FileSelectDlg.java b/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/FileSelectDlg.java
index 1583162020..d6ca0ce033 100644
--- a/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/FileSelectDlg.java
+++ b/cave/com.raytheon.uf.viz.alertviz.ui/src/com/raytheon/uf/viz/alertviz/ui/dialogs/FileSelectDlg.java
@@ -341,7 +341,7 @@ public class FileSelectDlg extends Dialog {
importNewBtn1.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
FileDialog newFileDlg = new FileDialog(shell, SWT.OPEN
- | SWT.MULTI);
+ | SWT.SINGLE);
newFileDlg.setFilterExtensions(fileExtensions);
String newFileName = newFileDlg.open();
if (newFileName != null) {
diff --git a/cave/com.raytheon.uf.viz.alertviz/plugin.xml b/cave/com.raytheon.uf.viz.alertviz/plugin.xml
index 4e5ec8901c..2cac8a257e 100644
--- a/cave/com.raytheon.uf.viz.alertviz/plugin.xml
+++ b/cave/com.raytheon.uf.viz.alertviz/plugin.xml
@@ -27,5 +27,79 @@
id="com.raytheon.viz.notification.statusHandler">
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/catalog/ScriptCreator.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/catalog/ScriptCreator.java
index 94052790a2..6fb89eeb6c 100644
--- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/catalog/ScriptCreator.java
+++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/catalog/ScriptCreator.java
@@ -50,7 +50,10 @@ import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.localization.LocalizationManager;
/**
- * Creates uEngine scripts on the fly.
+ * Creates uEngine scripts on the fly. DEPRECATED: Requests from viz should go
+ * through ThriftClient to the thrift service instead of using ScriptCreator and
+ * then going to the uengine service. The thrift service performs faster and is
+ * more maintainable. Use ThriftClient.
*
*
*
@@ -73,6 +76,7 @@ import com.raytheon.uf.viz.core.localization.LocalizationManager;
* @author brockwoo
* @version 1
*/
+@Deprecated
public class ScriptCreator {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(ScriptCreator.class);
diff --git a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/requests/ThriftClient.java b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/requests/ThriftClient.java
index 4399790fbb..22bcb88135 100644
--- a/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/requests/ThriftClient.java
+++ b/cave/com.raytheon.uf.viz.core/src/com/raytheon/uf/viz/core/requests/ThriftClient.java
@@ -4,6 +4,7 @@ import java.io.IOException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
+import java.util.UUID;
import javax.jws.WebService;
@@ -20,6 +21,7 @@ import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.serialization.SerializationUtil;
import com.raytheon.uf.common.serialization.comm.IServerRequest;
import com.raytheon.uf.common.serialization.comm.RemoteServiceRequest;
+import com.raytheon.uf.common.serialization.comm.RequestWrapper;
import com.raytheon.uf.common.serialization.comm.ServiceException;
import com.raytheon.uf.common.serialization.comm.response.ServerErrorResponse;
import com.raytheon.uf.common.serialization.comm.util.ExceptionWrapper;
@@ -50,9 +52,9 @@ import com.raytheon.uf.viz.core.localization.LocalizationManager;
**/
/**
- * The thrift client. used to send requests to the RemoteReqeustServer. Make
+ * The thrift client. used to send requests to the RemoteRequestServer. Make
* sure request type has registered a handler to handle the request on the
- * server
+ * server.
*
*
*
@@ -60,6 +62,7 @@ import com.raytheon.uf.viz.core.localization.LocalizationManager;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 3, 2009 mschenke Initial creation
+ * Jul 24, 2012 njensen Enhanced logging
*
*
*
@@ -273,9 +276,12 @@ public class ThriftClient {
private static Object sendRequest(IServerRequest request,
String httpAddress, String uri) throws VizException {
httpAddress += uri;
+ String uniqueId = UUID.randomUUID().toString();
+ RequestWrapper wrapper = new RequestWrapper(request, VizApp.getWsId(),
+ uniqueId);
byte[] message;
try {
- message = SerializationUtil.transformToThrift(request);
+ message = SerializationUtil.transformToThrift(wrapper);
} catch (SerializationException e) {
throw new VizException("unable to serialize request object", e);
}
@@ -287,8 +293,8 @@ public class ThriftClient {
.postBinary(httpAddress, message);
long time = System.currentTimeMillis() - t0;
if (time >= SIMPLE_LOG_TIME) {
- System.out.println("Took " + time + "ms to run request "
- + request);
+ System.out.println("Took " + time + "ms to run request id["
+ + uniqueId + "] " + request.toString());
}
if (time >= BAD_LOG_TIME) {
new Exception() {
diff --git a/cave/com.raytheon.uf.viz.d2d.ui/localization/styleRules/d2dArrowStyleRules.xml b/cave/com.raytheon.uf.viz.d2d.ui/localization/styleRules/d2dArrowStyleRules.xml
index 1daeeb5004..3879db62cb 100644
--- a/cave/com.raytheon.uf.viz.d2d.ui/localization/styleRules/d2dArrowStyleRules.xml
+++ b/cave/com.raytheon.uf.viz.d2d.ui/localization/styleRules/d2dArrowStyleRules.xml
@@ -80,9 +80,9 @@
K/m*1.0E6
-->
+ K/m*1.0E6
diff --git a/cave/com.raytheon.uf.viz.d2d.ui/localization/styleRules/d2dContourStyleRules.xml b/cave/com.raytheon.uf.viz.d2d.ui/localization/styleRules/d2dContourStyleRules.xml
index 66a272a6c3..bab5801554 100644
--- a/cave/com.raytheon.uf.viz.d2d.ui/localization/styleRules/d2dContourStyleRules.xml
+++ b/cave/com.raytheon.uf.viz.d2d.ui/localization/styleRules/d2dContourStyleRules.xml
@@ -4084,4 +4084,13 @@ in | .03937 | 0 | 4 | | |..|8000F0FF| | 16 | \
+
+
+ Wind
+ Gust
+
+
+ kts
+
+
diff --git a/cave/com.raytheon.uf.viz.d2d.ui/localization/styleRules/d2dGraphStyleRules.xml b/cave/com.raytheon.uf.viz.d2d.ui/localization/styleRules/d2dGraphStyleRules.xml
index 1f2f625258..55d705073b 100644
--- a/cave/com.raytheon.uf.viz.d2d.ui/localization/styleRules/d2dGraphStyleRules.xml
+++ b/cave/com.raytheon.uf.viz.d2d.ui/localization/styleRules/d2dGraphStyleRules.xml
@@ -498,4 +498,13 @@
+
+
+ MTV
+
+
+ g*m/(kg*s)
+
+
+
\ No newline at end of file
diff --git a/cave/com.raytheon.uf.viz.d2d.ui/plugin.xml b/cave/com.raytheon.uf.viz.d2d.ui/plugin.xml
index cbeadc3c23..0f116eb2dd 100644
--- a/cave/com.raytheon.uf.viz.d2d.ui/plugin.xml
+++ b/cave/com.raytheon.uf.viz.d2d.ui/plugin.xml
@@ -1548,7 +1548,7 @@
diff --git a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/AddAWIPSProcedure.java b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/AddAWIPSProcedure.java
index 15e570416e..056292b90f 100644
--- a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/AddAWIPSProcedure.java
+++ b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/AddAWIPSProcedure.java
@@ -57,7 +57,7 @@ public class AddAWIPSProcedure extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
Procedure procedure = new Procedure();
- ProcedureDlg dlg = new ProcedureDlg(null, procedure,
+ ProcedureDlg dlg = ProcedureDlg.getOrCreateDialog(null, procedure,
HandlerUtil.getActiveShell(event));
dlg.open();
diff --git a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/OpenAWIPSProcedure.java b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/OpenAWIPSProcedure.java
index 7e8183533b..7e9d075b4b 100644
--- a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/OpenAWIPSProcedure.java
+++ b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/actions/OpenAWIPSProcedure.java
@@ -24,6 +24,8 @@ import java.io.File;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.handlers.HandlerUtil;
import com.raytheon.uf.common.localization.LocalizationFile;
@@ -53,6 +55,8 @@ import com.raytheon.viz.ui.actions.LoadSerializedXml;
*/
public class OpenAWIPSProcedure extends AbstractHandler {
+ private OpenProcedureListDlg dialog;
+
/*
* (non-Javadoc)
*
@@ -62,16 +66,21 @@ public class OpenAWIPSProcedure extends AbstractHandler {
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
- ProcedureListDlg listDlg = new OpenProcedureListDlg(
+ if(dialog != null){
+ dialog.open();
+ return null;
+ }
+
+ dialog = new OpenProcedureListDlg(
HandlerUtil.getActiveShell(event));
- listDlg.open();
-
- LocalizationFile selectedFile = listDlg.getSelectedFile();
-
+ dialog.open();
+
+ LocalizationFile selectedFile = dialog.getSelectedFile();
+ dialog = null;
if (selectedFile != null) {
File f = selectedFile.getFile();
Procedure p = (Procedure) LoadSerializedXml.deserialize(f);
- ProcedureDlg dlg = new ProcedureDlg(
+ ProcedureDlg dlg = ProcedureDlg.getOrCreateDialog(
LocalizationUtil.extractName(selectedFile.getName()), p,
VizWorkbenchManager.getInstance().getCurrentWindow()
.getShell());
diff --git a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/ProcedureDlg.java b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/ProcedureDlg.java
index 3af3ceef9c..cd0eae8c30 100644
--- a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/ProcedureDlg.java
+++ b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/ProcedureDlg.java
@@ -23,6 +23,7 @@ package com.raytheon.uf.viz.d2d.ui.dialogs.procedures;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
@@ -83,6 +84,22 @@ import com.raytheon.viz.ui.actions.SaveBundle;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
import com.raytheon.viz.ui.editor.AbstractEditor;
+/**
+ *
+ * Dialog for loading or modifying procedures.
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ *
+ *
+ *
+ * @author unknown
+ * @version 1.0
+ */
public class ProcedureDlg extends CaveSWTDialog {
private static final transient IUFStatusHandler statusHandler = UFStatus
@@ -94,6 +111,8 @@ public class ProcedureDlg extends CaveSWTDialog {
public static final String PROCEDURES_DIR = "/procedures";
+ private static Collection openDialogs = new ArrayList();
+
private Font font;
private List dataList;
@@ -148,7 +167,7 @@ public class ProcedureDlg extends CaveSWTDialog {
private final java.util.List bundles;
- public ProcedureDlg(String fileName, Procedure p, Shell parent) {
+ private ProcedureDlg(String fileName, Procedure p, Shell parent) {
// Win32
super(parent, SWT.DIALOG_TRIM | SWT.RESIZE, CAVE.INDEPENDENT_SHELL
| CAVE.DO_NOT_BLOCK);
@@ -203,6 +222,9 @@ public class ProcedureDlg extends CaveSWTDialog {
@Override
protected void disposed() {
font.dispose();
+ synchronized (openDialogs) {
+ openDialogs.remove(this);
+ }
}
@Override
@@ -989,4 +1011,44 @@ public class ProcedureDlg extends CaveSWTDialog {
};
dlg.open();
}
+
+ /**
+ * If there is a procedure dialog open for the given filename, return it,
+ * otherwise null.
+ *
+ * @param fileName
+ * @return
+ */
+ public static ProcedureDlg getDialog(String fileName) {
+ synchronized (openDialogs) {
+ if (fileName != null) {
+ for (ProcedureDlg dialog : openDialogs) {
+ if (fileName.equals(dialog.fileName)) {
+ return dialog;
+ }
+ }
+ }
+ return null;
+ }
+ }
+
+ /**
+ * Get the ProcedureDlg for the given fileName. If the fileName is null or if there is no open dialog, create a new ProcedureDlg.
+ *
+ * @param fileName
+ * @param p
+ * @param parent
+ * @return
+ */
+ public static ProcedureDlg getOrCreateDialog(String fileName, Procedure p,
+ Shell parent) {
+ synchronized (openDialogs) {
+ ProcedureDlg dialog = getDialog(fileName);
+ if (dialog == null) {
+ dialog = new ProcedureDlg(fileName, p, parent);
+ openDialogs.add(dialog);
+ }
+ return dialog;
+ }
+ }
}
diff --git a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/ProcedureListDlg.java b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/ProcedureListDlg.java
index 657be9c429..baea4279c1 100644
--- a/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/ProcedureListDlg.java
+++ b/cave/com.raytheon.uf.viz.d2d.ui/src/com/raytheon/uf/viz/d2d/ui/dialogs/procedures/ProcedureListDlg.java
@@ -54,6 +54,24 @@ import com.raytheon.uf.common.localization.LocalizationUtil;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
+/**
+ *
+ * A dialog which displays a list of procedures for opening, saving, or deleting.
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * ??? Initial creation
+ * 07/31/2012 DR 15036 D. Friedman Ensure current user's procedures
+ * are visible.
+ *
+ *
+ * @author unknown
+ * @version 1.0
+ */
public class ProcedureListDlg extends CaveSWTDialog {
protected boolean oneLevel = true;
@@ -317,10 +335,18 @@ public class ProcedureListDlg extends CaveSWTDialog {
if (treeViewer.getContentProvider() instanceof ProcedureTreeContentProvider) {
ProcedureTreeContentProvider content = (ProcedureTreeContentProvider) treeViewer
.getContentProvider();
- Object find = content.findItem(user);
+ final Object find = content.findItem(user);
if (find != null) {
treeViewer.setExpandedElements(new Object[] { find });
- treeViewer.reveal(find);
+ treeViewer.getTree().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ TreeItem[] items = treeViewer.getTree().getItems();
+ if (items != null && items.length > 0)
+ treeViewer.getTree().showItem(items[items.length - 1]);
+ treeViewer.reveal(find);
+ }
+ });
}
}
}
@@ -449,14 +475,25 @@ public class ProcedureListDlg extends CaveSWTDialog {
procedureTF.setText(procedureTF.getText().concat(".xml"));
}
if (dataListContains(procedureTF.getText())) {
- // Pop up a warning
- boolean result = MessageDialog.openQuestion(shell,
- "Confirm Overwrite",
- "The procedure " + procedureTF.getText()
- + " already exists. Overwrite anyways?");
- if (result == true) {
- fileName = procedureTF.getText();
- shell.dispose();
+ if (ProcedureDlg.getDialog(procedureTF.getText()) != null) {
+ // User cannot save if dialog is open.
+ MessageDialog
+ .openError(
+ shell,
+ "Cannot Save Procedure",
+ "The procedure "
+ + procedureTF.getText()
+ + " is currently open. It cannot be overwritten until it is closed or saved under another name.");
+ } else {
+ // Pop up a warning
+ boolean result = MessageDialog.openQuestion(shell,
+ "Confirm Overwrite",
+ "The procedure " + procedureTF.getText()
+ + " already exists. Overwrite anyways?");
+ if (result == true) {
+ fileName = procedureTF.getText();
+ shell.dispose();
+ }
}
} else {
fileName = procedureTF.getText();
diff --git a/cave/com.raytheon.uf.viz.derivparam/localization/derivedParameters/definitions/CCP.xml b/cave/com.raytheon.uf.viz.derivparam/localization/derivedParameters/definitions/CCP.xml
index 427b0b177f..0286ffc47a 100644
--- a/cave/com.raytheon.uf.viz.derivparam/localization/derivedParameters/definitions/CCP.xml
+++ b/cave/com.raytheon.uf.viz.derivparam/localization/derivedParameters/definitions/CCP.xml
@@ -24,15 +24,15 @@
-
+
-
+
-
+
diff --git a/cave/com.raytheon.uf.viz.derivparam/localization/derivedParameters/definitions/MnT12hr.xml b/cave/com.raytheon.uf.viz.derivparam/localization/derivedParameters/definitions/MnT12hr.xml
index c841e9824a..f7ed0115c1 100644
--- a/cave/com.raytheon.uf.viz.derivparam/localization/derivedParameters/definitions/MnT12hr.xml
+++ b/cave/com.raytheon.uf.viz.derivparam/localization/derivedParameters/definitions/MnT12hr.xml
@@ -18,4 +18,9 @@
See_the_AWIPS_II_Master_Rights_File_("Master_Rights_File.pdf")_for
further_licensing_information.
-->
-
\ No newline at end of file
+
+
+
+
+
\ No newline at end of file
diff --git a/cave/com.raytheon.uf.viz.derivparam/localization/derivedParameters/definitions/MxT12hr.xml b/cave/com.raytheon.uf.viz.derivparam/localization/derivedParameters/definitions/MxT12hr.xml
index f019fcc212..8db5cc4b07 100644
--- a/cave/com.raytheon.uf.viz.derivparam/localization/derivedParameters/definitions/MxT12hr.xml
+++ b/cave/com.raytheon.uf.viz.derivparam/localization/derivedParameters/definitions/MxT12hr.xml
@@ -18,4 +18,9 @@
See_the_AWIPS_II_Master_Rights_File_("Master_Rights_File.pdf")_for
further_licensing_information.
-->
-
\ No newline at end of file
+
+
+
+
+
\ No newline at end of file
diff --git a/cave/com.raytheon.uf.viz.derivparam/localization/derivedParameters/definitions/Wind.xml b/cave/com.raytheon.uf.viz.derivparam/localization/derivedParameters/definitions/Wind.xml
index 12c62202c1..550260cb4d 100644
--- a/cave/com.raytheon.uf.viz.derivparam/localization/derivedParameters/definitions/Wind.xml
+++ b/cave/com.raytheon.uf.viz.derivparam/localization/derivedParameters/definitions/Wind.xml
@@ -18,7 +18,7 @@
See_the_AWIPS_II_Master_Rights_File_("Master_Rights_File.pdf")_for
further_licensing_information.
-->
-
+
diff --git a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/FileTreeView.java b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/FileTreeView.java
index 6d66dbc462..d9b598edac 100644
--- a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/FileTreeView.java
+++ b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/FileTreeView.java
@@ -819,7 +819,7 @@ public class FileTreeView extends ViewPart implements IPartListener2,
// We can import into true directories, not group datas
mgr.add(new Separator());
mgr.add(new ImportFileAction(fdata.getPathData().getType(),
- fdata.getPath()));
+ fdata.getPath(), fdata.getPathData().getFilter()));
}
}
}
diff --git a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/ImportFileAction.java b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/ImportFileAction.java
index c597c8fdf4..f3d9d62c50 100644
--- a/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/ImportFileAction.java
+++ b/cave/com.raytheon.uf.viz.localization.perspective/src/com/raytheon/uf/viz/localization/perspective/view/actions/ImportFileAction.java
@@ -67,17 +67,36 @@ public class ImportFileAction extends Action {
private static final String FORMAT_STRING = "The file '%s' already exists at the %s level and "
+ "will be deleted. Proceed?";
+ private static final String ASTERISK = "*";
+
private String directoryPath;
private LocalizationType contextType;
+ private String[] fileExtensionFilterArr;
+
public ImportFileAction(LocalizationType contextType, String directoryPath) {
super("Import File...");
this.contextType = contextType;
this.directoryPath = directoryPath;
}
- /*
+ public ImportFileAction(LocalizationType contextType, String directoryPath, String[] filter) {
+ this(contextType, directoryPath);
+ if (filter != null) {
+ this.fileExtensionFilterArr = new String[filter.length];
+ for (int i = 0; i < filter.length; ++i) {
+ if (filter[i] != null && filter[i].startsWith(".")) {
+ // prepend an asterisk as required by FileDialog.
+ this.fileExtensionFilterArr[i] = ASTERISK + filter[i];
+ } else {
+ this.fileExtensionFilterArr[i] = filter[i];
+ }
+ }
+ }
+ }
+
+ /*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
@@ -87,6 +106,9 @@ public class ImportFileAction extends Action {
Shell parent = VizWorkbenchManager.getInstance().getCurrentWindow()
.getShell();
FileDialog dialog = new FileDialog(parent);
+ if (fileExtensionFilterArr != null) {
+ dialog.setFilterExtensions(fileExtensionFilterArr);
+ }
String fileToImport = dialog.open();
if (fileToImport != null) {
File importFile = new File(fileToImport);
diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/FFMPMonitor.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/FFMPMonitor.java
index b4acf0afe6..6e967c627b 100644
--- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/FFMPMonitor.java
+++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/FFMPMonitor.java
@@ -820,20 +820,15 @@ public class FFMPMonitor extends ResourceMonitor {
populateFFMPRecord(product, siteKey, dataKey, sourceName,
ptime, phuc, retrieveNew);
}
- } else {
- // special case where FFG is the primary source
- // check for special case with dual stand alone and table
- // display loaded
- SourceXML sourcexml = getSourceConfig().getSource(sourceName);
+ } else {
+ // special case where FFG is the primary source
+ // check for special case with dual stand alone and table
+ // display loaded
- if (sourcexml.getSourceType().equals(
- SOURCE_TYPE.GUIDANCE.getSourceType())) {
- sourceName = sourcexml.getDisplayName();
- } else {
- populateFFMPRecord(product, siteKey, dataKey, sourceName,
- ptime, phuc, retrieveNew);
- }
- }
+ populateFFMPRecord(product, siteKey, dataKey, sourceName,
+ ptime, phuc, retrieveNew);
+
+ }
record = ffmpData.get(siteKey).get(sourceName);
}
@@ -1109,6 +1104,8 @@ public class FFMPMonitor extends ResourceMonitor {
}
resourceListeners.remove(listener);
+ // clean up if we can
+ System.gc();
}
public ArrayList getResourceListenerList() {
diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ffti/FFTIControlDlg.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ffti/FFTIControlDlg.java
index c6833d5cfb..9ee15a3950 100644
--- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ffti/FFTIControlDlg.java
+++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ffti/FFTIControlDlg.java
@@ -279,8 +279,11 @@ public class FFTIControlDlg extends Dialog {
&& (thisItem.getQpeDurHr() == nextItem.getQpeDurHr())
&& (thisItem.getGuidDurHr() == nextItem.getGuidDurHr())
&& (thisItem.getQpfDurHr() == nextItem.getQpfDurHr())
- && (thisItem.getTotalDurHr() == nextItem.getTotalDurHr())) {
-
+ && (thisItem.getTotalDurHr() == nextItem.getTotalDurHr())
+ && (thisItem.getQpeSrc().length > 0 && nextItem.getQpeSrc().length > 0 && thisItem.getQpeSrc()[0].equals(nextItem.getQpeSrc()[0]))
+ && (thisItem.getQpfSrc().length > 0 && nextItem.getQpfSrc().length > 0 && thisItem.getQpfSrc()[0].equals(nextItem.getQpfSrc()[0]))
+ && (thisItem.getGuidSrc().length > 0 && nextItem.getGuidSrc().length > 0 && thisItem.getGuidSrc()[0].equals(nextItem.getGuidSrc()[0]))) {
+
duplicateLst.add(i + 1);
duplicateLst.add(j + 1);
}
@@ -295,8 +298,14 @@ public class FFTIControlDlg extends Dialog {
HashSet duplicates = getDuplicates();
if (duplicates.size() > 0) {
String setsStr = "";
- for (Integer setIndex : duplicates)
- setsStr += setIndex + "/";
+ int i = 0;
+ for (Integer setIndex : duplicates) {
+ setsStr += setIndex;
+ if (i != duplicates.size()-1) {
+ setsStr = setsStr + "/";
+ }
+ i++;
+ }
MessageBox messageBox = new MessageBox(shell, SWT.OK);
messageBox.setText("Warning: Duplicate Setting(s)!");
messageBox
diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ffti/SettingComp.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ffti/SettingComp.java
index d66d03f65e..23009cd527 100644
--- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ffti/SettingComp.java
+++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ffti/SettingComp.java
@@ -20,6 +20,7 @@
package com.raytheon.uf.viz.monitor.ffmp.ffti;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashSet;
import org.eclipse.swt.SWT;
@@ -45,6 +46,17 @@ import com.raytheon.uf.common.monitor.xml.ProductRunXML;
import com.raytheon.uf.common.monitor.xml.ProductXML;
import com.raytheon.uf.common.monitor.xml.SourceXML;
+/**
+ * FFTI Setting Composite.
+ *
+ *
+ * SOFTWARE HISTORY
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * 08/07/2012 578 mpduff FFTI now only a single selection and populates
+ * correctly.
+ *
+ */
public class SettingComp extends Composite implements DurationInterface {
/**
* Parent tab folder.
@@ -102,6 +114,8 @@ public class SettingComp extends Composite implements DurationInterface {
// temporary storage for qpf
private String selectedQpfVal = "0";
+
+ private FFTISettingXML fftiSetting;
public SettingComp(TabFolder parent) {
super(parent, 0);
@@ -115,7 +129,8 @@ public class SettingComp extends Composite implements DurationInterface {
super(parent, 0);
this.parent = parent;
-
+ this.fftiSetting = fftiSetting;
+
init();
// set the attributes
@@ -217,6 +232,8 @@ public class SettingComp extends Composite implements DurationInterface {
accumRdo.setEnabled(true);
accumAction(accumAttrib);
+
+ setSettings();
}
private void createAttributeControls() {
@@ -318,7 +335,7 @@ public class SettingComp extends Composite implements DurationInterface {
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
gd.widthHint = listWidth;
gd.heightHint = listHeight;
- qpeList = new List(precipSrcComp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
+ qpeList = new List(precipSrcComp, SWT.BORDER | SWT.V_SCROLL);
qpeList.setLayoutData(gd);
fillQpeList();
@@ -327,8 +344,7 @@ public class SettingComp extends Composite implements DurationInterface {
gd.horizontalSpan = 2;
gd.widthHint = listWidth - 75;
gd.heightHint = listHeight;
- guidList = new List(precipSrcComp, SWT.BORDER | SWT.MULTI
- | SWT.V_SCROLL);
+ guidList = new List(precipSrcComp, SWT.BORDER | SWT.V_SCROLL);
guidList.setLayoutData(gd);
fillGuidList();
@@ -337,7 +353,7 @@ public class SettingComp extends Composite implements DurationInterface {
gd.horizontalSpan = 2;
gd.widthHint = listWidth;
gd.heightHint = listHeight;
- qpfList = new List(precipSrcComp, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL);
+ qpfList = new List(precipSrcComp, SWT.BORDER | SWT.V_SCROLL);
qpfList.setLayoutData(gd);
fillQpfList();
@@ -393,9 +409,6 @@ public class SettingComp extends Composite implements DurationInterface {
guidSet.add(sourceName);
guidList.add(sourceName);
}
- if (guidList.getItemCount() > 0) {
- guidList.setSelection(0);
- }
guidList.addSelectionListener(new SelectionListener() {
@@ -438,9 +451,10 @@ public class SettingComp extends Composite implements DurationInterface {
if (source.isMosaic()) {
if (!qpeSet.contains(product.getProductKey())) {
- if (!qpeSet.contains(source.getDisplayName())) {
- qpeSet.add(source.getDisplayName());
- qpeList.add(source.getDisplayName());
+ String displayName = source.getDisplayName();
+ if (!qpeSet.contains(displayName)) {
+ qpeSet.add(displayName);
+ qpeList.add(displayName);
}
break;
}
@@ -460,10 +474,6 @@ public class SettingComp extends Composite implements DurationInterface {
}
}
}
-
- if (qpeList.getItemCount() > 0) {
- qpeList.setSelection(0);
- }
}
/**
@@ -516,10 +526,6 @@ public class SettingComp extends Composite implements DurationInterface {
}
}
}
-
- if (qpfList.getItemCount() > 0) {
- qpfList.setSelection(0);
- }
}
/**
@@ -598,6 +604,55 @@ public class SettingComp extends Composite implements DurationInterface {
SWT.COLOR_WHITE));
attrLbl.setLayoutData(gd);
}
+
+ /**
+ * Set the dialog to reflect the saved configuration.
+ */
+ private void setSettings() {
+ // Select the configured items, otherwise select the first
+
+ if (this.fftiSetting != null) {
+ // QPE
+ if (fftiSetting.getQpeSource().getDisplayNameList() == null ||
+ fftiSetting.getQpeSource().getDisplayNameList().isEmpty()) {
+ qpeList.setSelection(0);
+ } else {
+ // Only using the first one in the list to match A1
+ java.util.List items = Arrays.asList(qpeList.getItems());
+ String name = fftiSetting.getQpeSource().getDisplayNameList().get(0);
+ int idx = items.indexOf(name);
+ qpeList.select(idx);
+ qpeList.showSelection();
+ }
+
+ // GUID
+ if (fftiSetting.getGuidSource().getDisplayNameList() == null ||
+ fftiSetting.getGuidSource().getDisplayNameList().isEmpty()) {
+ guidList.setSelection(0);
+ } else {
+ // Only using the first one in the list to match A1
+ java.util.List items = Arrays.asList(guidList.getItems());
+ String name = fftiSetting.getGuidSource().getDisplayNameList().get(0);
+ int idx = items.indexOf(name);
+ guidList.select(idx);
+ guidList.showSelection();
+ }
+
+ // QPF
+ if (fftiSetting.getQpfSource().getDisplayNameList() == null ||
+ fftiSetting.getQpfSource().getDisplayNameList().isEmpty()) {
+ qpfList.setSelection(0);
+ } else {
+ // Only using the first one in the list to match A1
+ java.util.List items = Arrays.asList(qpfList.getItems());
+ String name = fftiSetting.getQpfSource().getDisplayNameList().get(0);
+ int idx = items.indexOf(name);
+ qpfList.select(idx);
+ qpfList.showSelection();
+ }
+
+ }
+ }
private void accumAction(FFTIAttribute attribVal) {
// change attribute values
diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FFMPConfig.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FFMPConfig.java
index dd17900eb3..04d9846250 100644
--- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FFMPConfig.java
+++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FFMPConfig.java
@@ -45,6 +45,22 @@ import com.raytheon.uf.viz.monitor.ffmp.ui.dialogs.FfmpTableConfigData.COLUMN_NA
import com.raytheon.uf.viz.monitor.ffmp.xml.FFMPConfigBasinXML;
import com.raytheon.uf.viz.monitor.ffmp.xml.FFMPTableColumnXML;
+/**
+ * FFMP GUI Config Object.
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * Aug 01, 2012 14168 mpduff Add convenience methods for
+ * getting ColorCell and ReverseFilter
+ *
+ *
+ *
+ * @author lvenable
+ * @version 1.0
+ */
public class FFMPConfig {
private static FFMPConfig classInstance = new FFMPConfig();
@@ -97,9 +113,9 @@ public class FFMPConfig {
private HashMap threshMgrMap;
private HashMap thresholdLookup;
-
+
private AttributesDlgData attrData = null;
-
+
private boolean reReadAttrData = false;
private FFMPConfig() {
@@ -357,7 +373,7 @@ public class FFMPConfig {
return null;
}
-
+
public void createAttributesDlgData(String siteKey) {
ArrayList columnData = ffmpCfgBasin
.getTableColumnData();
@@ -371,7 +387,7 @@ public class FFMPConfig {
for (int i = 0; i < columns.length; i++) {
String column = columns[i];
String displayName = null;
-
+
for (FFMPTableColumnXML tcXML : columnData) {
if (column.contains("_")) {
String[] parts = column.split("_");
@@ -380,10 +396,14 @@ public class FFMPConfig {
}
if (column.equalsIgnoreCase(tcXML.getColumnName())) {
boolean includedInTable = false;
- if (column.equalsIgnoreCase(COLUMN_NAME.GUID.getColumnName()) ||
- column.equalsIgnoreCase(COLUMN_NAME.RATIO.getColumnName()) ||
- column.equalsIgnoreCase(COLUMN_NAME.DIFF.getColumnName())) {
- if (ffmpCfgBasin.getIncludedGuids().contains(displayName)) {
+ if (column.equalsIgnoreCase(COLUMN_NAME.GUID
+ .getColumnName())
+ || column.equalsIgnoreCase(COLUMN_NAME.RATIO
+ .getColumnName())
+ || column.equalsIgnoreCase(COLUMN_NAME.DIFF
+ .getColumnName())) {
+ if (ffmpCfgBasin.getIncludedGuids().contains(
+ displayName)) {
includedInTable = true;
attrData.setGuidColumnIncluded(displayName,
includedInTable);
@@ -397,8 +417,9 @@ public class FFMPConfig {
}
}
}
-
- public AttributesDlgData getVisibleColumns(String siteKey, boolean reReadAttrData) {
+
+ public AttributesDlgData getVisibleColumns(String siteKey,
+ boolean reReadAttrData) {
this.reReadAttrData = reReadAttrData;
return getVisibleColumns(siteKey);
}
@@ -413,33 +434,46 @@ public class FFMPConfig {
public void setVisibleColumns(AttributesDlgData attrData) {
this.attrData = attrData;
-
+
ArrayList columnData = ffmpCfgBasin
.getTableColumnData();
-
for (FFMPTableColumnXML tcXML : columnData) {
- if (tcXML.getColumnName().equalsIgnoreCase(COLUMN_NAME.RATE.getColumnName())) {
- tcXML.setDisplayedInTable(attrData.isColumnVisible(COLUMN_NAME.RATE.getColumnName()));
- } else if (tcXML.getColumnName().equalsIgnoreCase(COLUMN_NAME.NAME.getColumnName())) {
- tcXML.setDisplayedInTable(attrData.isColumnVisible(COLUMN_NAME.NAME.getColumnName()));
- } else if (tcXML.getColumnName().equalsIgnoreCase(COLUMN_NAME.QPE.getColumnName())) {
- tcXML.setDisplayedInTable(attrData.isColumnVisible(COLUMN_NAME.QPE.getColumnName()));
- } else if (tcXML.getColumnName().equalsIgnoreCase(COLUMN_NAME.QPF.getColumnName())) {
- tcXML.setDisplayedInTable(attrData.isColumnVisible(COLUMN_NAME.QPF.getColumnName()));
- } else if (tcXML.getColumnName().equalsIgnoreCase(COLUMN_NAME.GUID.getColumnName())) {
- tcXML.setDisplayedInTable(attrData.isColumnVisible(COLUMN_NAME.GUID.getColumnName()));
- } else if (tcXML.getColumnName().equalsIgnoreCase(COLUMN_NAME.RATIO.getColumnName())) {
- tcXML.setDisplayedInTable(attrData.isColumnVisible(COLUMN_NAME.RATIO.getColumnName()));
- } else if (tcXML.getColumnName().equalsIgnoreCase(COLUMN_NAME.DIFF.getColumnName())) {
- tcXML.setDisplayedInTable(attrData.isColumnVisible(COLUMN_NAME.DIFF.getColumnName()));
+ if (tcXML.getColumnName().equalsIgnoreCase(
+ COLUMN_NAME.RATE.getColumnName())) {
+ tcXML.setDisplayedInTable(attrData
+ .isColumnVisible(COLUMN_NAME.RATE.getColumnName()));
+ } else if (tcXML.getColumnName().equalsIgnoreCase(
+ COLUMN_NAME.NAME.getColumnName())) {
+ tcXML.setDisplayedInTable(attrData
+ .isColumnVisible(COLUMN_NAME.NAME.getColumnName()));
+ } else if (tcXML.getColumnName().equalsIgnoreCase(
+ COLUMN_NAME.QPE.getColumnName())) {
+ tcXML.setDisplayedInTable(attrData
+ .isColumnVisible(COLUMN_NAME.QPE.getColumnName()));
+ } else if (tcXML.getColumnName().equalsIgnoreCase(
+ COLUMN_NAME.QPF.getColumnName())) {
+ tcXML.setDisplayedInTable(attrData
+ .isColumnVisible(COLUMN_NAME.QPF.getColumnName()));
+ } else if (tcXML.getColumnName().equalsIgnoreCase(
+ COLUMN_NAME.GUID.getColumnName())) {
+ tcXML.setDisplayedInTable(attrData
+ .isColumnVisible(COLUMN_NAME.GUID.getColumnName()));
+ } else if (tcXML.getColumnName().equalsIgnoreCase(
+ COLUMN_NAME.RATIO.getColumnName())) {
+ tcXML.setDisplayedInTable(attrData
+ .isColumnVisible(COLUMN_NAME.RATIO.getColumnName()));
+ } else if (tcXML.getColumnName().equalsIgnoreCase(
+ COLUMN_NAME.DIFF.getColumnName())) {
+ tcXML.setDisplayedInTable(attrData
+ .isColumnVisible(COLUMN_NAME.DIFF.getColumnName()));
}
}
-
+
HashMap guidanceMap = attrData.getGuidanceList();
String list = "";
boolean first = true;
- for (String key: guidanceMap.keySet()) {
+ for (String key : guidanceMap.keySet()) {
if (first == false) {
list.concat(",");
}
@@ -496,7 +530,8 @@ public class FFMPConfig {
* starts. If the column is not visible then default the sort column to be
* the name column.
*
- * @param siteKey The siteKey being used
+ * @param siteKey
+ * The siteKey being used
* @return Column index.
*/
public int getStartSortIndex(String siteKey) {
@@ -506,7 +541,7 @@ public class FFMPConfig {
FfmpTableConfig tableCfg = FfmpTableConfig.getInstance();
FFMPSourceConfigurationManager sourceConfigManager = FFMPSourceConfigurationManager
.getInstance();
-
+
FFMPRunXML runner = configManager.getRunner(monitor.getWfo());
ProductRunXML prodRunXml = runner.getProduct(siteKey);
String name = prodRunXml.getProductName();
@@ -514,7 +549,7 @@ public class FFMPConfig {
ProductXML productXml = sourceConfigManager.getProduct(name);
ArrayList guidTypes = productXml.getAvailableGuidanceTypes();
-
+
String guidRankSource = null;
if (guidTypes.size() > 1) {
String colSorted = ffmpCfgBasin.getColumnSorted();
@@ -523,7 +558,7 @@ public class FFMPConfig {
guidRankSource = parts[1];
}
}
-
+
FfmpTableConfigData tableCfgData = tableCfg.getTableConfigData(siteKey);
String[] tableColumns = tableCfgData.getTableColumnKeys();
String sortedColName = ffmpCfgBasin.getColumnSorted();
@@ -539,7 +574,7 @@ public class FFMPConfig {
column = parts[1];
guidType = parts[0];
}
-
+
if (column.equalsIgnoreCase(sortedColName)) {
if ((guidType != null) && (guidRankSource != null)) {
if (guidType.equalsIgnoreCase(guidRankSource)) {
@@ -554,7 +589,7 @@ public class FFMPConfig {
}
}
}
-
+
return 0;
}
@@ -562,10 +597,16 @@ public class FFMPConfig {
if (columnName.contains("_")) {
return true;
}
-
+
return false;
}
-
+
+ /**
+ * Get the filter value for this column.
+ *
+ * @param threshColName
+ * @return The filter value
+ */
public double getFilterValue(ThreshColNames threshColName) {
ArrayList columnData = ffmpCfgBasin
.getTableColumnData();
@@ -575,6 +616,36 @@ public class FFMPConfig {
return data.getFilter();
}
+ /**
+ * Get the ColorCell value for this column.
+ *
+ * @param threshColName
+ * @return The ColorCell value
+ */
+ public boolean isColorCell(ThreshColNames threshColName) {
+ ArrayList columnData = ffmpCfgBasin
+ .getTableColumnData();
+
+ FFMPTableColumnXML data = columnData.get(threshColName.getColIndex());
+
+ return data.getColorCell();
+ }
+
+ /**
+ * Get the reverse filter value for this column.
+ *
+ * @param threshColName
+ * @return The Reverse Filter value
+ */
+ public boolean isReverseFilter(ThreshColNames threshColName) {
+ ArrayList columnData = ffmpCfgBasin
+ .getTableColumnData();
+
+ FFMPTableColumnXML data = columnData.get(threshColName.getColIndex());
+
+ return data.getReverseFilter();
+ }
+
/**
* @return the attrData
*/
@@ -583,7 +654,8 @@ public class FFMPConfig {
}
/**
- * @param attrData the attrData to set
+ * @param attrData
+ * the attrData to set
*/
public void setAttrData(AttributesDlgData attrData) {
this.attrData = attrData;
@@ -597,12 +669,13 @@ public class FFMPConfig {
}
/**
- * @param reReadAttrData the reReadAttrData to set
+ * @param reReadAttrData
+ * the reReadAttrData to set
*/
public void setReReadAttrData(boolean reReadAttrData) {
this.reReadAttrData = reReadAttrData;
}
-
+
public String getIncludedGuids() {
return ffmpCfgBasin.getIncludedGuids();
}
diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FFMPTable.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FFMPTable.java
index 62a18c9fc8..00e9c2d972 100644
--- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FFMPTable.java
+++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FFMPTable.java
@@ -52,6 +52,7 @@ import com.raytheon.uf.common.monitor.data.CommonConfig;
import com.raytheon.uf.common.monitor.data.CommonConfig.AppName;
import com.raytheon.uf.viz.monitor.ffmp.ui.dialogs.FFMPConfig.ThreshColNames;
import com.raytheon.uf.viz.monitor.ffmp.ui.dialogs.FfmpTableConfigData.COLUMN_NAME;
+import com.raytheon.uf.viz.monitor.ffmp.xml.FFMPConfigBasinXML;
import com.raytheon.uf.viz.monitor.ffmp.xml.FFMPTableColumnXML;
/**
@@ -67,17 +68,20 @@ import com.raytheon.uf.viz.monitor.ffmp.xml.FFMPTableColumnXML;
* Apr 7, 2009 lvenable Initial creation
* Mar 15,2012 DR 14406 gzhang Fixing QPF Column Title Missing
* Mar 20,2012 DR 14250 gzhang Eliminating column Missing values
+ * Aug 01, 2012 14168 mpduff Only allow filtering if ColorCell is true
*
+ *
* @author lvenable
* @version 1.0
*/
public abstract class FFMPTable extends Composite {
/** Default column width */
- protected static final int DEFAULT_COLUMN_WIDTH = 95;//DR14406: old value: 75 too small
+ protected static final int DEFAULT_COLUMN_WIDTH = 95;// DR14406: old value:
+ // 75 too small
- /** DR14406: For columns with more words */
+ /** DR14406: For columns with more words */
protected static final int EXTRA_COLUMN_WIDTH = 28;
-
+
protected String currentPfaf = null;
/**
@@ -326,10 +330,10 @@ public abstract class FFMPTable extends Composite {
cols[j].setImage(null);
cols[j].setWidth(defaultColWidth);
}
-
+
// reset the tableIndex
tableIndex = -1;
-
+
/*
* Check of the column is sortable.
*/
@@ -377,17 +381,36 @@ public abstract class FFMPTable extends Composite {
int sortColIndex = table.indexOf(sortedTableColumn);
boolean isAFilterCol = false;
ThreshColNames sortedThreshCol = null;
+ boolean reverseFilter = false;
double filterNum = Double.NaN;
- String columnName = getColumnKeys()[sortColIndex];
+ String sortedColumnName = getColumnKeys()[sortColIndex];
+
+ FFMPConfigBasinXML ffmpCfgBasin = FFMPConfig.getInstance()
+ .getFFMPConfigData();
+
+ ArrayList ffmpTableCols = ffmpCfgBasin
+ .getTableColumnData();
+
+ for (ThreshColNames threshColName : ThreshColNames.values()) {
+ if (sortedColumnName.contains(threshColName.name())) {
+ sortedThreshCol = threshColName;
+ break;
+ }
+ }
+
// Check if the sorted column is a column that will contain a filter.
- if (!columnName.equalsIgnoreCase("NAME")) {
- isAFilterCol = true;
- for (ThreshColNames threshColName : ThreshColNames.values()) {
- if (columnName.contains(threshColName.name())) {
- sortedThreshCol = threshColName;
- filterNum = ffmpConfig.getFilterValue(threshColName);
+ // Check the gui config to see if colorCell is true. If false then do
+ // not apply filter
+ for (FFMPTableColumnXML xml : ffmpTableCols) {
+ if (xml.getColumnName().contains(sortedThreshCol.name())) {
+ if (ffmpConfig.isColorCell(sortedThreshCol)) {
+ // Only filter if colorCell is true
+ isAFilterCol = true;
+ filterNum = ffmpConfig.getFilterValue(sortedThreshCol);
+ reverseFilter = ffmpConfig.isReverseFilter(sortedThreshCol);
}
+ break;
}
}
@@ -414,38 +437,16 @@ public abstract class FFMPTable extends Composite {
extent.x);
/*
- * Check if the sorted column is a filter column.
+ * Check if the data value is Not A Number.
*/
- if (isAFilterCol == true) {
- /*
- * Check if the data value is Not A Number.
- */
- float dataVal = cellData[sortColIndex]
- .getValueAsFloat();
- //DR 14250 fix: any value not a number will be omitted
- if (/*sortedThreshCol.name().equalsIgnoreCase("RATIO") &&*/ Float.isNaN(dataVal)) {
- continue;
- }
-
- // if (sortedThreshCol.name().equalsIgnoreCase("RATIO") == false) {
-
- // If the data value is less/more than the filter value
- // continue
- // so we don't put the data in the table. Less for normal
- // filtering,
- // more for reverse filtering
- ArrayList tcList = ffmpConfig
- .getFFMPConfigData().getTableColumnData();
- boolean reverseFilter = false;
- for (FFMPTableColumnXML tc : tcList) {
- if (tc.getColumnName().equalsIgnoreCase(
- sortedThreshCol.name())) {
- reverseFilter = tc.getReverseFilter();
- break;
- }
- }
- // }
+ float dataVal = cellData[sortColIndex].getValueAsFloat();
+ // DR 14250 fix: any value not a number will be omitted
+ if (/* sortedThreshCol.name().equalsIgnoreCase("RATIO") && */Float
+ .isNaN(dataVal)) {
+ continue;
+ }
+ if (isAFilterCol) {
if (reverseFilter) {
if (dataVal > filterNum) {
continue;
@@ -458,7 +459,7 @@ public abstract class FFMPTable extends Composite {
}
indexArray.add(t);
-
+
// Check to see if this is the selected row
if (rowData.getPfaf().equals(currentPfaf)) {
tableIndex = indexArray.indexOf(t);
@@ -667,7 +668,10 @@ public abstract class FFMPTable extends Composite {
}
}
- imageWidth = maxTextLength * textWidth + EXTRA_COLUMN_WIDTH;//DR14406: old value 6 too small
+ imageWidth = maxTextLength * textWidth + EXTRA_COLUMN_WIDTH;// DR14406:
+ // old value
+ // 6 too
+ // small
imageHeight = textHeight * 2;
gc.dispose();
@@ -722,25 +726,34 @@ public abstract class FFMPTable extends Composite {
String[] tmpArray = colName.split("\n");
for (int j = 0; j < tmpArray.length; j++) {
-// if (tmpArray[j].length() > maxTextLen) {
-// maxTextLen = tmpArray[j].length();
-// }
-// }
+ // if (tmpArray[j].length() > maxTextLen) {
+ // maxTextLen = tmpArray[j].length();
+ // }
+ // }
- xCoord = Math.round((imageWidth / 2)- (tmpArray[j].length() /*DR14406: old value: maxTextLen*/* textWidth / 2));
- yCoord = j*(textHeight+1);//DR14406: old value 0 is only for the 1st line
- gc.drawText(tmpArray[j], xCoord, yCoord, true);//DR14406: draw each line separately
+ xCoord = Math.round((imageWidth / 2)
+ - (tmpArray[j].length() /*
+ * DR14406: old value:
+ * maxTextLen
+ */* textWidth / 2));
+ yCoord = j * (textHeight + 1);// DR14406: old value 0 is
+ // only for the 1st line
+ gc.drawText(tmpArray[j], xCoord, yCoord, true);// DR14406:
+ // draw each
+ // line
+ // separately
}
} else {
xCoord = Math.round((imageWidth / 2)
- (colName.length() * textWidth / 2));
yCoord = imageHeight / 2 - textHeight / 2 - 1;
- gc.drawText(colName, xCoord, yCoord, true);//DR14406: draw text with a single line
+ gc.drawText(colName, xCoord, yCoord, true);// DR14406: draw text
+ // with a single line
}
-// System.out.println("Column name = " + colName);
- //DR14406: move the below text drawing code into the if-else blocks
- //gc.drawText(colName, xCoord, yCoord, true);
+ // System.out.println("Column name = " + colName);
+ // DR14406: move the below text drawing code into the if-else blocks
+ // gc.drawText(colName, xCoord, yCoord, true);
gc.dispose();
tc.setImage(img);
@@ -794,9 +807,10 @@ public abstract class FFMPTable extends Composite {
tCols[i].setWidth(table.getColumn(i).getWidth());
} else {
tCols[i].setWidth(defaultColWidth);
- }
-
- setQPFColName(tCols[i], col);//DR14406: set QPF title with quicker response
+ }
+
+ setQPFColName(tCols[i], col);// DR14406: set QPF title with
+ // quicker response
} else {
tCols[i].setWidth(0);
}
@@ -876,27 +890,24 @@ public abstract class FFMPTable extends Composite {
*/
protected abstract int getColumnIndex(String sortCol);
-
-
-
-
/**
- * DR14406 code: QPF column's name should be re-set
- * when a user choose another type of QPF from the
- * Attributes... button.
+ * DR14406 code: QPF column's name should be re-set when a user choose
+ * another type of QPF from the Attributes... button.
*
* See FfmpTableConfigData.setQpfType() with ColumnAttribData
*
- * @param tCols: TableColumn
- * @param col: Column name
+ * @param tCols
+ * : TableColumn
+ * @param col
+ * : Column name
*/
- private void setQPFColName(TableColumn tCols, String col){
-
- if(COLUMN_NAME.QPF.getColumnName().equalsIgnoreCase(col)){
-
- setColumnImages();
- tCols.setWidth(defaultColWidth+EXTRA_COLUMN_WIDTH);//38);
-
- }
+ private void setQPFColName(TableColumn tCols, String col) {
+
+ if (COLUMN_NAME.QPF.getColumnName().equalsIgnoreCase(col)) {
+
+ setColumnImages();
+ tCols.setWidth(defaultColWidth + EXTRA_COLUMN_WIDTH);// 38);
+
+ }
}
}
\ No newline at end of file
diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FfmpBasinTableDlg.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FfmpBasinTableDlg.java
index e306edc226..0501df28d1 100644
--- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FfmpBasinTableDlg.java
+++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/dialogs/FfmpBasinTableDlg.java
@@ -84,6 +84,8 @@ import com.raytheon.uf.viz.monitor.ffmp.ui.rsc.FFMPLoaderStatus;
import com.raytheon.uf.viz.monitor.ffmp.ui.rsc.FFMPResource;
import com.raytheon.uf.viz.monitor.ffmp.ui.rsc.FFMPTableDataLoader;
import com.raytheon.uf.viz.monitor.ffmp.ui.rsc.FFMPTableDataUpdate;
+import com.raytheon.uf.viz.monitor.ffmp.xml.FFMPConfigBasinXML;
+import com.raytheon.uf.viz.monitor.ffmp.xml.FFMPTableColumnXML;
import com.raytheon.uf.viz.monitor.listeners.IMonitorListener;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
@@ -96,6 +98,10 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 30, 2009 lvenable Initial creation
+ * Jul 31, 2012 14517 mpduff Fix map blanking on updates and table updates
+ * for rapid slider changes.
+ * Aug 01, 2012 14168 mpduff Only allow items into the Thresholds menu if
+ * ColorCell is true.
*
*
*
@@ -110,7 +116,7 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements
.getHandler(FfmpBasinTableDlg.class);
private List retrievalQueue = new ArrayList();
-
+
private MenuItem linkToFrameMI;
private MenuItem worstCaseMI;
@@ -220,7 +226,7 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements
private Composite tableComp;
private FFMPTableDataLoader dataRetrieveThread = null;
-
+
private boolean sweet = true;
public FfmpBasinTableDlg(Shell parent, FFMPTableData tData,
@@ -496,10 +502,11 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements
mi.setSelection(true);
break;
}
- }
+ }
} else {
sourceMenuItems.get(0).setSelection(true);
- ffmpConfig.getFFMPConfigData().setGuidSrc(sourceMenuItems.get(0).getText());
+ ffmpConfig.getFFMPConfigData().setGuidSrc(
+ sourceMenuItems.get(0).getText());
}
fireFieldChangedEvent(FFMPRecord.FIELDS.RATIO, false);
@@ -561,7 +568,8 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements
for (int i = 0; i < sourceMenuItems.size(); i++) {
String rdo = sourceMenuItems.get(i).getText();
if (rdo.equals(guidSrc)) {
- ffmpConfig.getFFMPConfigData().setGuidSrc(guidSrc);
+ ffmpConfig.getFFMPConfigData().setGuidSrc(
+ guidSrc);
fireConfigUpdateEvent();
break;
}
@@ -1023,18 +1031,21 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements
// Loop over enum from config singleton to create menu items
for (ThreshColNames colName : ThreshColNames.values()) {
- MenuItem mi = new MenuItem(popupMenu, SWT.NONE);
- mi.setText(colName.name());
- mi.setData(colName);
- mi.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- MenuItem mi = (MenuItem) e.getSource();
- ThreshColNames colName = (ThreshColNames) mi.getData();
+ if (ffmpConfig.isColorCell(colName)) {
+ // only add a menu item if colorCell is true
+ MenuItem mi = new MenuItem(popupMenu, SWT.NONE);
+ mi.setText(colName.name());
+ mi.setData(colName);
+ mi.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ MenuItem mi = (MenuItem) e.getSource();
+ ThreshColNames colName = (ThreshColNames) mi.getData();
- displayThresholdsDialog(colName);
- }
- });
+ displayThresholdsDialog(colName);
+ }
+ });
+ }
}
// Set the pop-up menu as the pop-up for the shell
@@ -1267,27 +1278,27 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements
this.ffmpConfig.setAttrData(attrData);
this.ffmpTable.showHideTableColumns();
boolean changeSplit = false;
-
+
if (timeDurScale.split != ffmpConfig.isSplit()) {
- changeSplit = true;
+ changeSplit = true;
}
timeDurScale.setSplit(ffmpConfig.isSplit());
updateTimeDurationLabel(timeDurScale.getSelectedHoursValue(),
ffmpConfig.isSplit());
- if (updateData) {
+ if (updateData) {
- if (changeSplit) {
- fireTimeChangedEvent(timeDurScale.getSelectedHoursValue(),
- ffmpConfig.isSplit(), true);
- }
- resource.clearTables();
- resource.getDrawable(resource.getPaintTime()).setDirty(true);
- FFMPMonitor.getInstance().fireMonitorEvent(
- this.getClass().getName());
+ if (changeSplit) {
+ fireTimeChangedEvent(timeDurScale.getSelectedHoursValue(),
+ ffmpConfig.isSplit(), true);
+ }
+ resource.clearTables();
+ resource.getDrawable(resource.getPaintTime()).setDirty(true);
+ FFMPMonitor.getInstance().fireMonitorEvent(
+ this.getClass().getName());
- }
+ }
ffmpTable.calculateTableSize();
shell.pack();
@@ -1330,7 +1341,8 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements
ffmpListeners.remove(fl);
}
- public void fireTimeChangedEvent(double newTime, boolean split, boolean override) {
+ public void fireTimeChangedEvent(double newTime, boolean split,
+ boolean override) {
FFMPRecord.FIELDS field = FFMPRecord.FIELDS.QPE;
@@ -1381,7 +1393,7 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements
if (waitCursor == true) {
shell.setCursor(getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
}
-
+
FFMPFieldChangeEvent ffce = new FFMPFieldChangeEvent(field);
Iterator iter = ffmpListeners.iterator();
@@ -1420,9 +1432,9 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements
if (!selected) {
cwas.remove(cwa);
} else {
- if (!cwas.contains(cwa)) {
- cwas.add(cwa);
- }
+ if (!cwas.contains(cwa)) {
+ cwas.add(cwa);
+ }
}
FFMPCWAChangeEvent fcce = new FFMPCWAChangeEvent(cwas);
@@ -1659,23 +1671,22 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements
* @param tData
*/
public void resetData(FFMPTableData tData) {
-
if (!ffmpTable.isDisposed()) {
this.mainTableData = tData;
- //System.out.println("---" + tData.getTableRows().size());
+ // System.out.println("---" + tData.getTableRows().size());
ffmpTable.clearTableSelection();
- //long time = System.currentTimeMillis();
+ // long time = System.currentTimeMillis();
ffmpTable
.setCenteredAggregationKey(resource.centeredAggregationKey);
ffmpTable.setTableData(mainTableData);
- //long time1 = System.currentTimeMillis();
+ // long time1 = System.currentTimeMillis();
resetCursor();
shell.pack();
shell.redraw();
- //System.out
- // .println("Time to load Data into table " + (time1 - time));
+ // System.out
+ // .println("Time to load Data into table " + (time1 - time));
}
}
@@ -1689,7 +1700,7 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements
|| allOnlySmallBasinsMI.getSelection()) {
groupLbl.setText(name);
}
-
+
shell.setCursor(getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
fireScreenRecenterEvent(pfaf, 1);
}
@@ -1776,7 +1787,8 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements
*/
timeDurScale.setTimeDurationAndUpdate(ffmpConfig.getFFMPConfigData()
.getTimeFrame());
- fireTimeChangedEvent(ffmpConfig.getFFMPConfigData().getTimeFrame(), false, false);
+ fireTimeChangedEvent(ffmpConfig.getFFMPConfigData().getTimeFrame(),
+ false, false);
/*
* Layer
@@ -1847,7 +1859,7 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements
}
fireAutoRefreshEvent(false);
-
+
/*
* CWAs
*
@@ -2039,7 +2051,7 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements
resource, basinTrendDlg, allowNewTableUpdate, sourceUpdate,
date, this);
- synchronized (retrievalQueue) {
+ synchronized (retrievalQueue) {
if (dataRetrieveThread == null || dataRetrieveThread.isDone()) {
retrievalQueue.clear();
dataRetrieveThread = tableLoader;
@@ -2050,7 +2062,7 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements
}
}
}
-
+
/**
* Get the latest TableDataLoader and clear all previous loaders
*
@@ -2058,7 +2070,8 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements
*/
private FFMPTableDataLoader getLoader() {
synchronized (retrievalQueue) {
- FFMPTableDataLoader loader = retrievalQueue.get(retrievalQueue.size() - 1);
+ FFMPTableDataLoader loader = retrievalQueue.get(retrievalQueue
+ .size() - 1);
retrievalQueue.clear();
return loader;
}
@@ -2091,45 +2104,54 @@ public class FfmpBasinTableDlg extends CaveSWTDialog implements
public void tableDataUpdateComplete(FFMPTableDataUpdate updateData) {
final FFMPTableDataUpdate fupdateData = updateData;
-
+
if (!this.isDisposed()) {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
- allowNewTableUpdate = fupdateData.isAllowNewTableUpdate();
- sourceUpdate = fupdateData.isSourceUpdate();
-
- if (fupdateData.getTableData() != null && sweet) {
- resetData(fupdateData.getTableData());
- }
-
- if (fupdateData.isFireGraph()) {
- fireGraphDataEvent(fupdateData.getGraphPfaf(), false,
- fupdateData.getGraphTime());
- }
-
- setValidTime(fupdateData.getValidTime());
- updateGapValueLabel(fupdateData.getGapValueLabel());
-
- resetCursor();
- sweet = true;
-
- if (retrievalQueue.size() > 0) {
- dataRetrieveThread = getLoader();
- dataRetrieveThread.start();
- }
+ processUpdate(fupdateData);
}
});
}
}
+
/**
- * used to blank the group label when channging HUC
- * while in an aggregate.
+ * Process the update
+ */
+ private void processUpdate(FFMPTableDataUpdate fupdateData) {
+ allowNewTableUpdate = fupdateData.isAllowNewTableUpdate();
+ sourceUpdate = fupdateData.isSourceUpdate();
+
+ if (retrievalQueue.size() > 0) {
+ dataRetrieveThread = getLoader();
+ dataRetrieveThread.start();
+ return;
+ } else {
+ }
+
+ if (fupdateData.getTableData() != null && sweet) {
+ resetData(fupdateData.getTableData());
+ }
+
+ if (fupdateData.isFireGraph()) {
+ fireGraphDataEvent(fupdateData.getGraphPfaf(), false,
+ fupdateData.getGraphTime());
+ }
+
+ setValidTime(fupdateData.getValidTime());
+ updateGapValueLabel(fupdateData.getGapValueLabel());
+
+ resetCursor();
+ sweet = true;
+ }
+
+ /**
+ * used to blank the group label when channging HUC while in an aggregate.
*/
public void blankGroupLabel() {
- if (groupLbl != null) {
- groupLbl.setText("");
- }
+ if (groupLbl != null) {
+ groupLbl.setText("");
+ }
}
}
diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java
index e5e565d4c3..0a0dd588bb 100644
--- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java
+++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java
@@ -149,6 +149,8 @@ import com.vividsolutions.jts.geom.Point;
* ------------ ---------- ----------- --------------------------
* 29 June, 2009 2521 dhladky Initial creation
* 11 Apr. 2012 DR 14522 gzhang Fixing invalid thread error.
+ * 31 July 2012 14517 mpduff Fix for blanking map on update.
+ *
*
* @author dhladky
* @version 1.0
@@ -376,6 +378,9 @@ public class FFMPResource extends
/** force utility **/
private FFFGForceUtil forceUtil = null;
+ /** Restore Table flag */
+ private boolean restoreTable = false;
+
/**
* FFMP resource
*
@@ -2441,7 +2446,8 @@ public class FFMPResource extends
}
if ((cwaBasins.size() == 0)
|| !req.extent.equals(drawable.getExt())
- || !phuc.equals(drawable.getHuc())) {
+ || !phuc.equals(drawable.getHuc())
+ || restoreTable) {
Envelope env = null;
try {
Envelope e = req.descriptor.pixelToWorld(req.extent,
@@ -2466,7 +2472,7 @@ public class FFMPResource extends
templates, getSiteKey(), cwa, phuc);
for (Entry entry : envMap.entrySet()) {
- if (env.intersects(entry.getValue())) {
+ if (env.intersects(entry.getValue()) || env.contains(entry.getValue())) {
// add the individual basins
cwaBasins.add(entry.getKey());
}
@@ -2766,6 +2772,10 @@ public class FFMPResource extends
}
}
+ if (restoreTable) {
+ restoreTable = false;
+ }
+
drawable.setTime(req.time);
if (lowestCenter != ZOOM.BASIN) {
drawable.setCenterAggrKey(centeredAggregationKey);
@@ -3189,7 +3199,8 @@ public class FFMPResource extends
public void restoreTable() {
centeredAggregationKey = null;
centeredAggregatePfafList = null;
-
+ restoreTable = true;
+
lowestCenter = FFMPRecord.ZOOM.WFO;
getDescriptor().getRenderableDisplay().getExtent().reset();
zoom(1.0f);
diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPTableDataLoader.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPTableDataLoader.java
index 1d80cf92f8..7a62a2bff9 100644
--- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPTableDataLoader.java
+++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPTableDataLoader.java
@@ -41,7 +41,8 @@ import com.raytheon.uf.viz.monitor.ffmp.ui.dialogs.FfmpBasinTableDlg;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
- * Oct 13, 2011 dhladky Initial creation
+ * Oct 13, 2011 dhladky Initial creation.
+ * Jul 31, 2012 14517 mpduff Fix for Rapid slider changes
*
*
*
@@ -142,11 +143,13 @@ public class FFMPTableDataLoader extends Thread {
// System.out
// .println(" Cache MISSSSSSSSSSSS!!!!!");
+
+ double origDrawTime = resource.getTime();
FFMPDataGenerator dg = new FFMPDataGenerator(
ffmp, resource);
tData = dg.generateFFMPData();
drawable.setTableData(iHuc, tData);
- drawable.setDrawTime(resource.getTime());
+ drawable.setDrawTime(origDrawTime);
}
}
} catch (Exception e) {
diff --git a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/resource/ScanResource.java b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/resource/ScanResource.java
index 8c29ae880c..0b314f53ec 100644
--- a/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/resource/ScanResource.java
+++ b/cave/com.raytheon.uf.viz.monitor.scan/src/com/raytheon/uf/viz/monitor/scan/resource/ScanResource.java
@@ -79,6 +79,8 @@ import com.vividsolutions.jts.geom.Coordinate;
* ------------ ---------- ----------- --------------------------
* Oct 13, 2009 dhladky Initial creation
*
+ * Jul 24 2012 12996 Xiaochuan Compare with MidVal()
+ *
*
*
* @author dhladky
@@ -359,7 +361,7 @@ public class ScanResource extends
d = Double.valueOf(rank);
}
- if (d >= getScanDrawer().ddfc.getLowerVal()) {
+ if (d >= getScanDrawer().ddfc.getMidVal()) {
if (!getScanDrawer().ddfc.isOverlap()) {
if ((dtdr != null) && !dtdr.getOverlap()) {
isOverlap = false;
diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/TableUtil.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/TableUtil.java
index d6938540ae..146af00d7c 100644
--- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/TableUtil.java
+++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/data/TableUtil.java
@@ -902,192 +902,232 @@ public final class TableUtil {
return null;
}
- private static TableRowData getSnowMetarHistTableRowData(ObReport report) {
- TableRowData tblRowData = new TableRowData(8);
- tblRowData.setTableCellData(0, new TableCellData(report.getObservationTime(),"HH:mm MMM dd",CellType.ObsHist));
- tblRowData.setTableCellData(1,
- new TableCellData(Math.round(new Float(report.getWindDir())),
- CellType.ObsHist, true));
- tblRowData.setTableCellData(2,
- new TableCellData(Math.round(new Float(report.getWindSpeed())),
- CellType.ObsHist, true));
- tblRowData.setTableCellData(3,
- new TableCellData(Math.round(new Float(report.getWindGust())),
- CellType.ObsHist, true));
- tblRowData.setTableCellData(4, new TableCellData(report.getPressure(), CellType.ObsHist, CommonTableConfig.obsHistCols.P));
- tblRowData.setTableCellData(
- 5,
- new TableCellData(
- Math.round(new Float(report.getTemperature())),
- CellType.ObsHist, true));
- tblRowData.setTableCellData(6,
- new TableCellData(Math.round(new Float(report.getDewpoint())),
- CellType.ObsHist, true));
- tblRowData.setTableCellData(7, new TableCellData(report.getPressureChange(), CellType.ObsHist, CommonTableConfig.obsHistCols.PTend));
- return tblRowData;
- }
+ private static TableRowData getSnowMetarHistTableRowData(ObReport report) {
+ TableRowData tblRowData = new TableRowData(10);
+ tblRowData.setTableCellData(0,
+ new TableCellData(report.getObservationTime(), "HH:mm MMM dd",
+ CellType.ObsHist));
+ tblRowData.setTableCellData(1,
+ new TableCellData(new Float(report.getLatitude()),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(2,
+ new TableCellData(new Float(report.getLongitude()),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(3,
+ new TableCellData(Math.round(new Float(report.getWindDir())),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(4,
+ new TableCellData(Math.round(new Float(report.getWindSpeed())),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(5,
+ new TableCellData(Math.round(new Float(report.getWindGust())),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(6, new TableCellData(report.getPressure(),
+ CellType.ObsHist, CommonTableConfig.obsHistCols.P));
+ tblRowData.setTableCellData(7,
+ new TableCellData(
+ Math.round(new Float(report.getTemperature())),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(8,
+ new TableCellData(Math.round(new Float(report.getDewpoint())),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(9,
+ new TableCellData(report.getPressureChange(), CellType.ObsHist,
+ CommonTableConfig.obsHistCols.PTend));
+ return tblRowData;
+ }
private static TableRowData getSafeSeasMetarHistTableRowData(ObReport report) {
// same as getSnowHistTableRowData
return getSnowMetarHistTableRowData(report);
}
- private static TableRowData getSafeseasMaritimeHistTableRowData(ObReport report) {
- TableRowData tblRowData = new TableRowData(15);
- tblRowData.setTableCellData(0, new TableCellData(report.getObservationTime(),"HH:mm MMM dd",CellType.ObsHist));
- tblRowData.setTableCellData(1,
- new TableCellData(Math.round(new Float(report.getWindSpeed())),
- CellType.ObsHist, true));
- tblRowData.setTableCellData(
- 2,
- new TableCellData(
- Math.round(new Float(report.getMaxWindSpeed())),
- CellType.ObsHist, true));
- tblRowData.setTableCellData(3,
- new TableCellData(Math.round(new Float(report.getWindGust())),
- CellType.ObsHist, true));
- tblRowData.setTableCellData(4,
- new TableCellData(
- Math.round(new Float(report.getVisibility())),
- CellType.ObsHist, true));
- tblRowData.setTableCellData(5, new TableCellData(report.getPressure(), CellType.ObsHist, CommonTableConfig.obsHistCols.P));
- tblRowData.setTableCellData(
- 6,
- new TableCellData(Math.round(new Float(report
- .getPressureChange())), CellType.ObsHist, true));
- tblRowData.setTableCellData(
- 7,
- new TableCellData(
- Math.round(new Float(report.getTemperature())),
- CellType.ObsHist, true));
- tblRowData.setTableCellData(8,
- new TableCellData(Math.round(new Float(report.getDewpoint())),
- CellType.ObsHist, true));
- tblRowData.setTableCellData(
- 9,
- new TableCellData(Math.round(new Float(report
- .getSeaSurfaceTemp())), CellType.ObsHist, true));
- tblRowData.setTableCellData(
- 10,
- new TableCellData(Math.round(new Float(report
- .getHighResWaveHeight())), CellType.ObsHist, true));
- tblRowData.setTableCellData(
- 11,
- new TableCellData(Math.round(new Float(report
- .getWaveSteepness())), CellType.ObsHist, true));
- tblRowData.setTableCellData(
- 12,
- new TableCellData(
- Math.round(new Float(report.getPSwellHeight())),
- CellType.ObsHist, true));
- tblRowData.setTableCellData(
- 13,
- new TableCellData(
- Math.round(new Float(report.getPSwellPeriod())),
- CellType.ObsHist, true));
- tblRowData.setTableCellData(14,
- new TableCellData(Math.round(new Float(report.getPSwellDir())),
- CellType.ObsHist, true));
- return tblRowData;
- }
+ private static TableRowData getSafeseasMaritimeHistTableRowData(
+ ObReport report) {
+ TableRowData tblRowData = new TableRowData(17);
+ tblRowData.setTableCellData(0,
+ new TableCellData(report.getObservationTime(), "HH:mm MMM dd",
+ CellType.ObsHist));
+ tblRowData.setTableCellData(1,
+ new TableCellData(new Float(report.getLatitude()),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(2,
+ new TableCellData(new Float(report.getLongitude()),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(3,
+ new TableCellData(Math.round(new Float(report.getWindSpeed())),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(
+ 4,
+ new TableCellData(
+ Math.round(new Float(report.getMaxWindSpeed())),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(5,
+ new TableCellData(Math.round(new Float(report.getWindGust())),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(6,
+ new TableCellData(
+ Math.round(new Float(report.getVisibility())),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(7, new TableCellData(report.getPressure(),
+ CellType.ObsHist, CommonTableConfig.obsHistCols.P));
+ tblRowData.setTableCellData(
+ 8,
+ new TableCellData(Math.round(new Float(report
+ .getPressureChange())), CellType.ObsHist, true));
+ tblRowData.setTableCellData(
+ 9,
+ new TableCellData(
+ Math.round(new Float(report.getTemperature())),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(10,
+ new TableCellData(Math.round(new Float(report.getDewpoint())),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(
+ 11,
+ new TableCellData(Math.round(new Float(report
+ .getSeaSurfaceTemp())), CellType.ObsHist, true));
+ tblRowData.setTableCellData(
+ 12,
+ new TableCellData(Math.round(new Float(report
+ .getHighResWaveHeight())), CellType.ObsHist, true));
+ tblRowData.setTableCellData(
+ 13,
+ new TableCellData(Math.round(new Float(report
+ .getWaveSteepness())), CellType.ObsHist, true));
+ tblRowData.setTableCellData(
+ 14,
+ new TableCellData(
+ Math.round(new Float(report.getPSwellHeight())),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(
+ 15,
+ new TableCellData(
+ Math.round(new Float(report.getPSwellPeriod())),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(16,
+ new TableCellData(Math.round(new Float(report.getPSwellDir())),
+ CellType.ObsHist, true));
+ return tblRowData;
+ }
- private static TableRowData getFogMaritimeHistTableRowData(ObReport report) {
- TableRowData tblRowData = new TableRowData(16);
- tblRowData.setTableCellData(0, new TableCellData(report.getObservationTime(),"HH:mm MMM dd",CellType.ObsHist));
- tblRowData.setTableCellData(1,
- new TableCellData(Math.round(new Float(report.getWindSpeed())),
- CellType.ObsHist, true));
- tblRowData.setTableCellData(
- 2,
- new TableCellData(
- Math.round(new Float(report.getMaxWindSpeed())),
- CellType.ObsHist, true));
- tblRowData.setTableCellData(3,
- new TableCellData(Math.round(new Float(report.getWindGust())),
- CellType.ObsHist, true));
- tblRowData.setTableCellData(4,
- new TableCellData(
- Math.round(new Float(report.getVisibility())),
- CellType.ObsHist, true));
- tblRowData.setTableCellData(5, new TableCellData(report.getPressure(), CellType.ObsHist, CommonTableConfig.obsHistCols.P));
- tblRowData.setTableCellData(
- 6,
- new TableCellData(Math.round(new Float(report
- .getPressureChange())), CellType.ObsHist, true));
- tblRowData.setTableCellData(
- 7,
- new TableCellData(
- Math.round(new Float(report.getTemperature())),
- CellType.ObsHist, true));
- tblRowData.setTableCellData(8,
- new TableCellData(Math.round(new Float(report.getDewpoint())),
- CellType.ObsHist, true));
- tblRowData.setTableCellData(
- 9,
- new TableCellData(Math.round(new Float(report
- .getSeaSurfaceTemp())), CellType.ObsHist, true));
- tblRowData.setTableCellData(
- 10,
- new TableCellData(Math.round(new Float(report
- .getHighResWaveHeight())), CellType.ObsHist, true));
- tblRowData.setTableCellData(
- 11,
- new TableCellData(Math.round(new Float(report
- .getWaveSteepness())), CellType.ObsHist, true));
- tblRowData.setTableCellData(
- 12,
- new TableCellData(
- Math.round(new Float(report.getPSwellHeight())),
- CellType.ObsHist, true));
- tblRowData.setTableCellData(
- 13,
- new TableCellData(
- Math.round(new Float(report.getPSwellPeriod())),
- CellType.ObsHist, true));
- tblRowData.setTableCellData(14,
- new TableCellData(Math.round(new Float(report.getPSwellDir())),
- CellType.ObsHist, true));
- tblRowData.setTableCellData(
- 15,
- new TableCellData(Math.round(new Float(report
- .getRelativeHumidity())), CellType.ObsHist, true));
- return tblRowData;
- }
+ private static TableRowData getFogMaritimeHistTableRowData(ObReport report) {
+ TableRowData tblRowData = new TableRowData(18);
+ tblRowData.setTableCellData(0,
+ new TableCellData(report.getObservationTime(), "HH:mm MMM dd",
+ CellType.ObsHist));
+ tblRowData.setTableCellData(1,
+ new TableCellData(new Float(report.getLatitude()),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(2,
+ new TableCellData(new Float(report.getLongitude()),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(3,
+ new TableCellData(Math.round(new Float(report.getWindSpeed())),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(
+ 4,
+ new TableCellData(
+ Math.round(new Float(report.getMaxWindSpeed())),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(5,
+ new TableCellData(Math.round(new Float(report.getWindGust())),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(6,
+ new TableCellData(
+ Math.round(new Float(report.getVisibility())),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(7, new TableCellData(report.getPressure(),
+ CellType.ObsHist, CommonTableConfig.obsHistCols.P));
+ tblRowData.setTableCellData(
+ 8,
+ new TableCellData(Math.round(new Float(report
+ .getPressureChange())), CellType.ObsHist, true));
+ tblRowData.setTableCellData(
+ 9,
+ new TableCellData(
+ Math.round(new Float(report.getTemperature())),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(10,
+ new TableCellData(Math.round(new Float(report.getDewpoint())),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(
+ 11,
+ new TableCellData(Math.round(new Float(report
+ .getSeaSurfaceTemp())), CellType.ObsHist, true));
+ tblRowData.setTableCellData(
+ 12,
+ new TableCellData(Math.round(new Float(report
+ .getHighResWaveHeight())), CellType.ObsHist, true));
+ tblRowData.setTableCellData(
+ 13,
+ new TableCellData(Math.round(new Float(report
+ .getWaveSteepness())), CellType.ObsHist, true));
+ tblRowData.setTableCellData(
+ 14,
+ new TableCellData(
+ Math.round(new Float(report.getPSwellHeight())),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(
+ 15,
+ new TableCellData(
+ Math.round(new Float(report.getPSwellPeriod())),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(16,
+ new TableCellData(Math.round(new Float(report.getPSwellDir())),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(
+ 17,
+ new TableCellData(Math.round(new Float(report
+ .getRelativeHumidity())), CellType.ObsHist, true));
+ return tblRowData;
+ }
- private static TableRowData getFogMetarHistTableRowData(ObReport report) {
- TableRowData tblRowData = new TableRowData(12);
- tblRowData.setTableCellData(0, new TableCellData(report.getObservationTime(),"HH:mm MMM dd",CellType.ObsHist));
- tblRowData.setTableCellData(
- 1,
- new TableCellData(Math.round(new Float(report
- .getRelativeHumidity())), CellType.ObsHist, true));
- tblRowData.setTableCellData(2,
- new TableCellData(
- Math.round(new Float(report.getVisibility())),
- CellType.ObsHist, true));
- tblRowData.setTableCellData(3,
- new TableCellData(Math.round(new Float(report.getCeiling())),
- CellType.ObsHist, true));
- tblRowData.setTableCellData(4,
- new TableCellData(Math.round(new Float(report.getWindDir())),
- CellType.ObsHist, true));
- tblRowData.setTableCellData(5,
- new TableCellData(Math.round(new Float(report.getWindSpeed())),
- CellType.ObsHist, true));
- tblRowData.setTableCellData(6,
- new TableCellData(Math.round(new Float(report.getWindGust())),
- CellType.ObsHist, true));
- tblRowData.setTableCellData(7, new TableCellData(report.getPressure(), CellType.ObsHist, CommonTableConfig.obsHistCols.P));
- int tmph = Math.round(new Float(report.getTemperature()));
- int dpth = Math.round(new Float(report.getDewpoint()));
- tblRowData.setTableCellData(8, new TableCellData(tmph,
- CellType.ObsHist, true));
- tblRowData.setTableCellData(9, new TableCellData(dpth,
- CellType.ObsHist, true));
- tblRowData.setTableCellData(10, new TableCellData(tmph - dpth,
- CellType.ObsHist, true));
- tblRowData.setTableCellData(11, new TableCellData(report.getPressureChange(), CellType.ObsHist, CommonTableConfig.obsHistCols.PTend));
- return tblRowData;
- }
+ private static TableRowData getFogMetarHistTableRowData(ObReport report) {
+ TableRowData tblRowData = new TableRowData(14);
+ tblRowData.setTableCellData(0,
+ new TableCellData(report.getObservationTime(), "HH:mm MMM dd",
+ CellType.ObsHist));
+ tblRowData.setTableCellData(1,
+ new TableCellData(new Float(report.getLatitude()),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(2,
+ new TableCellData(new Float(report.getLongitude()),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(
+ 3,
+ new TableCellData(Math.round(new Float(report
+ .getRelativeHumidity())), CellType.ObsHist, true));
+ tblRowData.setTableCellData(4,
+ new TableCellData(
+ Math.round(new Float(report.getVisibility())),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(5,
+ new TableCellData(Math.round(new Float(report.getCeiling())),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(6,
+ new TableCellData(Math.round(new Float(report.getWindDir())),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(7,
+ new TableCellData(Math.round(new Float(report.getWindSpeed())),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(8,
+ new TableCellData(Math.round(new Float(report.getWindGust())),
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(9, new TableCellData(report.getPressure(),
+ CellType.ObsHist, CommonTableConfig.obsHistCols.P));
+ int tmph = Math.round(new Float(report.getTemperature()));
+ int dpth = Math.round(new Float(report.getDewpoint()));
+ tblRowData.setTableCellData(10, new TableCellData(tmph,
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(11, new TableCellData(dpth,
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(12, new TableCellData(tmph - dpth,
+ CellType.ObsHist, true));
+ tblRowData.setTableCellData(13,
+ new TableCellData(report.getPressureChange(), CellType.ObsHist,
+ CommonTableConfig.obsHistCols.PTend));
+ return tblRowData;
+ }
}
diff --git a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/StationTableComp.java b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/StationTableComp.java
index 0fda01f220..f15e3df3ac 100644
--- a/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/StationTableComp.java
+++ b/cave/com.raytheon.uf.viz.monitor/src/com/raytheon/uf/viz/monitor/ui/dialogs/StationTableComp.java
@@ -301,7 +301,7 @@ public class StationTableComp extends TableComp {
* @param name
*/
public void setIdLabel(String name) {
- idLbl.setText("Zone/County: " + name);
+ idLbl.setText("Zone/County: "+ this.id +" - "+ name);
controlComp.layout();
}
diff --git a/cave/com.raytheon.uf.viz.profiler/src/com/raytheon/uf/viz/profiler/ProfilerResource.java b/cave/com.raytheon.uf.viz.profiler/src/com/raytheon/uf/viz/profiler/ProfilerResource.java
index e1b43413f6..f75fd316c8 100644
--- a/cave/com.raytheon.uf.viz.profiler/src/com/raytheon/uf/viz/profiler/ProfilerResource.java
+++ b/cave/com.raytheon.uf.viz.profiler/src/com/raytheon/uf/viz/profiler/ProfilerResource.java
@@ -67,9 +67,12 @@ import com.vividsolutions.jts.geom.Coordinate;
* replaced deprecated function calls
* replaced deprecated function calls
* Feb 10, 2011 8030 bkowal access to the plots ArrayList is now synchronized
- * Feb 15, 2011 8036 bkowal magnification only affects the x-axis, wind bards, and
+ * Feb 15, 2011 8036 bkowal magnification only affects the x-axis, wind barbs, and
* the color bar.
- *
+ * ======================================
+ * AWIPS2 DR Work
+ * 08/10/2012 1035 jkorman Changed number of 'staffs' from 12 to 13 and changed time
+ * display to match AWIPS I.
*
*
* @author dhladky
@@ -81,6 +84,8 @@ public class ProfilerResource extends
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(ProfilerResource.class);
+ private static final int NUM_PROFILE_STAFFS = 13;
+
/* Graphic target */
private IGraphicsTarget target = null;
@@ -137,7 +142,7 @@ public class ProfilerResource extends
protected void initInternal(IGraphicsTarget target) throws VizException {
this.target = target;
dataTimes = new ArrayList();
- incX = (ProfilerUtils.profilerRectangle.width / 12);
+ incX = (ProfilerUtils.profilerRectangle.width / NUM_PROFILE_STAFFS);
incYheight = ProfilerUtils.profilerRectangle.height / maxY;
@@ -222,7 +227,7 @@ public class ProfilerResource extends
earliestTime = Math.min(earliestTime, validTime);
latestTime = Math.max(latestTime, validTime);
}
- long earliestRequestTime = earliestTime - 12 * 3600000;
+ long earliestRequestTime = earliestTime - NUM_PROFILE_STAFFS * 3600000;
List requestTimes = new ArrayList();
for (DataTime time : resourceData.getAvailableTimes()) {
long validTime = time.getValidTime().getTimeInMillis();
@@ -343,7 +348,7 @@ public class ProfilerResource extends
if (x < 0) {
continue;
}
- if (x >= 12) {
+ if (x >= NUM_PROFILE_STAFFS) {
continue;
}
ArrayList plots = entry.getValue();
@@ -463,9 +468,10 @@ public class ProfilerResource extends
}
Calendar c = paintProps.getDataTime().getValidTime();
- for (int i = 0; i < 12; i++) {
+ for (int i = 0; i < NUM_PROFILE_STAFFS; i++) {
- String d = String.format("%1$tH:%1$tM", c);
+// String d = String.format("%1$tH:%1$tM", c);
+ String d = String.format("%1$tH", c);
parameters.setText(d, ProfilerUtils.GRAPH_COLOR);
parameters.basics.x = ProfilerUtils.profilerRectangle.x
+ (i * incX) + (incX / 2);
diff --git a/cave/com.raytheon.uf.viz.radarapps.core/src/com/raytheon/uf/viz/radarapps/client/RcmClient.java b/cave/com.raytheon.uf.viz.radarapps.core/src/com/raytheon/uf/viz/radarapps/client/RcmClient.java
index 0a8a95501d..3887a91ecc 100644
--- a/cave/com.raytheon.uf.viz.radarapps.core/src/com/raytheon/uf/viz/radarapps/client/RcmClient.java
+++ b/cave/com.raytheon.uf.viz.radarapps.core/src/com/raytheon/uf/viz/radarapps/client/RcmClient.java
@@ -61,7 +61,6 @@ import com.raytheon.rcm.mqsrvr.ReqObj;
import com.raytheon.rcm.rmr.RmrEvent;
import com.raytheon.uf.common.dataplugin.radar.request.RadarServerConnectionRequest;
import com.raytheon.uf.viz.core.exception.VizException;
-import com.raytheon.uf.viz.core.preferences.JMSPreferences;
import com.raytheon.uf.viz.core.requests.ThriftClient;
// TODO: use of queueSession outside synchronized(stateLock) could cause
@@ -69,6 +68,23 @@ import com.raytheon.uf.viz.core.requests.ThriftClient;
// TODO: conflicts over setting fatalMsg
+/**
+ * Manages client connection to RadarServer
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ------------ --------------------------
+ * ???? D. Friedman Initial version
+ * 2012-07-27 DR 14896 D. Friedman Fix even topic name
+ *
+ *
+ *
+ * @author dfriedma
+ * @version 1.0
+ */
public class RcmClient implements MessageListener, ExceptionListener {
private String connectionURL;
@@ -211,6 +227,11 @@ public class RcmClient implements MessageListener, ExceptionListener {
return;
}
+ /*
+ * TODO: ActiveMQ is hard-coded. If switching to Qpid or another
+ * service, it may be necessary to use JMSPreferences.getPolicyString on
+ * the topic name below.
+ */
ActiveMQConnectionFactory connFac = new ActiveMQConnectionFactory(uri);
// This stuff can block...
try {
@@ -238,8 +259,7 @@ public class RcmClient implements MessageListener, ExceptionListener {
topicConn.setExceptionListener(this);
topicSession = topicConn.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
- topic = topicSession.createTopic(JMSPreferences
- .getPolicyString("RadarEvents"));
+ topic = topicSession.createTopic("RadarEvents");
queueConn.start();
topicConn.start();
diff --git a/cave/com.raytheon.uf.viz.xy.crosssection/src/com/raytheon/uf/viz/xy/crosssection/rsc/AbstractCrossSectionResource.java b/cave/com.raytheon.uf.viz.xy.crosssection/src/com/raytheon/uf/viz/xy/crosssection/rsc/AbstractCrossSectionResource.java
index 00e4e60017..1f22a67fc5 100644
--- a/cave/com.raytheon.uf.viz.xy.crosssection/src/com/raytheon/uf/viz/xy/crosssection/rsc/AbstractCrossSectionResource.java
+++ b/cave/com.raytheon.uf.viz.xy.crosssection/src/com/raytheon/uf/viz/xy/crosssection/rsc/AbstractCrossSectionResource.java
@@ -231,11 +231,13 @@ public abstract class AbstractCrossSectionResource extends
time = time.clone();
time.setLevelValue((double) i);
times.add(time);
+ sliceMap.put(time, null);
+ dataRetrievalJob.times.add(time);
}
}
dataTimes = new ArrayList(times);
Collections.sort(dataTimes);
- sliceMap.clear();
+ dataRetrievalJob.schedule();
}
protected void loadSlice(DataTime time) throws VizException {
diff --git a/cave/com.raytheon.uf.viz.xy.crosssection/src/com/raytheon/uf/viz/xy/crosssection/rsc/CrossSectionImageResource.java b/cave/com.raytheon.uf.viz.xy.crosssection/src/com/raytheon/uf/viz/xy/crosssection/rsc/CrossSectionImageResource.java
index 148e5e9228..9957941d55 100644
--- a/cave/com.raytheon.uf.viz.xy.crosssection/src/com/raytheon/uf/viz/xy/crosssection/rsc/CrossSectionImageResource.java
+++ b/cave/com.raytheon.uf.viz.xy.crosssection/src/com/raytheon/uf/viz/xy/crosssection/rsc/CrossSectionImageResource.java
@@ -138,10 +138,12 @@ public class CrossSectionImageResource extends AbstractCrossSectionResource
super.initInternal(target);
// defaults
- ImagingCapability imageCap = getCapability(ImagingCapability.class);
- imageCap.setInterpolationState(true);
- imageCap.setBrightness(1.0f);
- imageCap.setContrast(1.0f);
+ if (!hasCapability(ImagingCapability.class)) {
+ ImagingCapability imageCap = getCapability(ImagingCapability.class);
+ imageCap.setInterpolationState(true);
+ imageCap.setBrightness(1.0f);
+ imageCap.setContrast(1.0f);
+ }
}
private IImage constructImage(float[] floatData, IGraphicsTarget target)
diff --git a/cave/com.raytheon.uf.viz.xy.timeheight/src/com/raytheon/uf/viz/xy/timeheight/rsc/AbstractTimeHeightResource.java b/cave/com.raytheon.uf.viz.xy.timeheight/src/com/raytheon/uf/viz/xy/timeheight/rsc/AbstractTimeHeightResource.java
index b35100d512..b8cb40b58f 100644
--- a/cave/com.raytheon.uf.viz.xy.timeheight/src/com/raytheon/uf/viz/xy/timeheight/rsc/AbstractTimeHeightResource.java
+++ b/cave/com.raytheon.uf.viz.xy.timeheight/src/com/raytheon/uf/viz/xy/timeheight/rsc/AbstractTimeHeightResource.java
@@ -450,6 +450,7 @@ public abstract class AbstractTimeHeightResource extends
secondaryResource.setDescriptor(descriptor);
}
super.setDescriptor(descriptor);
+ interpolatedData = null;
loadDataJob.schedule();
}
diff --git a/cave/com.raytheon.uf.viz.xy.timeseries/src/com/raytheon/uf/viz/xy/timeseries/rsc/TimeSeriesResource.java b/cave/com.raytheon.uf.viz.xy.timeseries/src/com/raytheon/uf/viz/xy/timeseries/rsc/TimeSeriesResource.java
index 6be8e20194..9e8e7b17d0 100644
--- a/cave/com.raytheon.uf.viz.xy.timeseries/src/com/raytheon/uf/viz/xy/timeseries/rsc/TimeSeriesResource.java
+++ b/cave/com.raytheon.uf.viz.xy.timeseries/src/com/raytheon/uf/viz/xy/timeseries/rsc/TimeSeriesResource.java
@@ -26,6 +26,7 @@ import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
+import java.util.ListIterator;
import java.util.Set;
import java.util.TimeZone;
import java.util.TreeSet;
@@ -76,6 +77,7 @@ import com.raytheon.viz.core.graphing.util.GraphPrefsFactory;
import com.raytheon.viz.core.graphing.xy.XYData;
import com.raytheon.viz.core.graphing.xy.XYDataList;
import com.raytheon.viz.core.graphing.xy.XYImageData;
+import com.raytheon.viz.core.graphing.xy.XYWindImageData;
import com.raytheon.viz.core.rsc.ICombinedResourceData;
import com.raytheon.viz.core.rsc.ICombinedResourceData.CombineOperation;
import com.raytheon.viz.core.style.graph.GraphPreferences;
@@ -157,10 +159,22 @@ public class TimeSeriesResource extends
if (currentUnit.isCompatible(prefs.getDisplayUnits())) {
UnitConverter conv = currentUnit.getConverterTo(prefs
.getDisplayUnits());
- for (XYData d : data.getData()) {
- double converted = conv.convert(((Number) d.getY())
- .doubleValue());
- d.setY(converted);
+ ListIterator it = data.getData().listIterator();
+ while(it.hasNext()) {
+ XYData d = it.next();
+ if(d instanceof XYWindImageData){
+ XYWindImageData wind = (XYWindImageData) d;
+ double converted = conv.convert(wind.getWindSpd());
+ it.remove();
+ if(wind.getImage() != null){
+ wind.getImage().dispose();
+ }
+ it.add(new XYWindImageData(wind.getX(), wind.getY(), converted, wind.getWindDir()));
+ }else{
+ double converted = conv.convert(((Number) d.getY())
+ .doubleValue());
+ d.setY(converted);
+ }
}
units = prefs.getDisplayUnitLabel();
} else {
@@ -457,13 +471,6 @@ public class TimeSeriesResource extends
String lat = nf.format(Math.abs(y));
String stnID = "";
String source = resourceData.getSource();
- String unit = "";
-
- if (prefs != null && prefs.getDisplayUnits() != null) {
- unit = prefs.getDisplayUnitLabel();
- } else {
- unit = adapter.getDataUnit().toString();
- }
if (resourceData.getMetadataMap().get("location.stationId") != null) {
stnID = resourceData.getMetadataMap().get("location.stationId")
@@ -488,7 +495,7 @@ public class TimeSeriesResource extends
sb.append(" ").append(resourceData.getLevelKey());
}
sb.append(String.format(" %s %s %s", adapter.getParameterName(),
- "TSer", unit != null && unit.equals("") == false ? "(" + unit
+ "TSer", units != null && units.equals("") == false ? "(" + units
+ ")" : ""));
if (secondaryResource != null) {
diff --git a/cave/com.raytheon.uf.viz.xy.varheight/src/com/raytheon/uf/viz/xy/varheight/util/ScaleHandler.java b/cave/com.raytheon.uf.viz.xy.varheight/src/com/raytheon/uf/viz/xy/varheight/util/ScaleHandler.java
index d1e49fe28c..a669e8f8fb 100644
--- a/cave/com.raytheon.uf.viz.xy.varheight/src/com/raytheon/uf/viz/xy/varheight/util/ScaleHandler.java
+++ b/cave/com.raytheon.uf.viz.xy.varheight/src/com/raytheon/uf/viz/xy/varheight/util/ScaleHandler.java
@@ -26,6 +26,7 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
+import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.uf.viz.core.globals.VizGlobalsManager;
import com.raytheon.uf.viz.d2d.core.ID2DRenderableDisplay;
@@ -75,30 +76,29 @@ public class ScaleHandler extends AbstractHandler {
* @param scale
*/
static void setScale(IDisplayPaneContainer editor, String scale) {
- if (editor.getActiveDisplayPane().getRenderableDisplay() instanceof ID2DRenderableDisplay) {
- ID2DRenderableDisplay disp = (ID2DRenderableDisplay) editor
- .getActiveDisplayPane().getRenderableDisplay();
+ for (IDisplayPane pane : editor.getDisplayPanes()) {
+ if (pane.getRenderableDisplay() instanceof ID2DRenderableDisplay) {
+ ID2DRenderableDisplay disp = (ID2DRenderableDisplay) pane
+ .getRenderableDisplay();
+ if (scale.equals(disp.getScale())) {
+ // don't set the scale if it is the same as the display's
+ // current scale
+ return;
+ }
- if (scale.equals(disp.getScale())) {
- // don't set the scale if it is the same as the display's
- // current
- // scale
- return;
+ disp.setScale(scale);
+ if (pane == editor.getActiveDisplayPane()) {
+ VizGlobalsManager.getCurrentInstance().updateChanges(
+ editor.getActiveDisplayPane()
+ .getRenderableDisplay().getGlobalsMap());
+ }
}
-
- disp.setScale(scale);
-
- // update the scale button
- final ICommandService service = (ICommandService) PlatformUI
- .getWorkbench().getService(ICommandService.class);
-
- VizGlobalsManager.getCurrentInstance().updateChanges(
- editor.getActiveDisplayPane().getRenderableDisplay()
- .getGlobalsMap());
-
- service.refreshElements(
- "com.raytheon.uf.viz.xy.height.scalebutton", null);
}
+
+ ICommandService service = (ICommandService) PlatformUI.getWorkbench()
+ .getService(ICommandService.class);
+ service.refreshElements("com.raytheon.uf.viz.xy.height.scalebutton",
+ null);
}
}
diff --git a/cave/com.raytheon.viz.aviation/plugin.xml b/cave/com.raytheon.viz.aviation/plugin.xml
index 8d2737e59a..2a6e132304 100644
--- a/cave/com.raytheon.viz.aviation/plugin.xml
+++ b/cave/com.raytheon.viz.aviation/plugin.xml
@@ -87,5 +87,12 @@
value="aviation/config"
recursive="true">
+
+
diff --git a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/climatology/WindRosePlotDlg.java b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/climatology/WindRosePlotDlg.java
index bffc923418..db908b75f9 100755
--- a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/climatology/WindRosePlotDlg.java
+++ b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/climatology/WindRosePlotDlg.java
@@ -55,7 +55,6 @@ import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Spinner;
-
import com.raytheon.viz.avncommon.AvnMessageMgr.StatusMessageType;
import com.raytheon.viz.avnconfig.HelpUsageDlg;
import com.raytheon.viz.avnconfig.ITafSiteConfig;
@@ -80,6 +79,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* 9/12/2008 1444 grichard Accommodate separate message logs.
* 3/31/2011 8774 rferrel killProcess when doing a disposed
* 4/14/2011 8861 rferrel Use SaveImageDlg class
+ * 23JUL2012 15169 zhao Use Combo for 'Month' and 'Number of Months'
+ * & disabled site controls while drawing
*
*
*
@@ -101,14 +102,14 @@ public class WindRosePlotDlg extends CaveSWTDialog {
private List siteList;
/**
- * Month spinner.
+ * Month
*/
- private Spinner monthSpnr;
+ private Combo monthCbo;
/**
* Number of months.
*/
- private Spinner numMonthsSpnr;
+ private Combo numMonthsCbo;
/**
* Hours spinner.
@@ -427,20 +428,19 @@ public class WindRosePlotDlg extends CaveSWTDialog {
Label monthLbl = new Label(monthHourComp, SWT.NONE);
monthLbl.setText("Month:");
- gd = new GridData(40, SWT.DEFAULT);
- monthSpnr = new Spinner(monthHourComp, SWT.BORDER);
- monthSpnr.setDigits(0);
- monthSpnr.setIncrement(1);
- monthSpnr.setPageIncrement(3);
- monthSpnr.setMinimum(1);
- monthSpnr.setMaximum(12);
- monthSpnr.setSelection(cal.get(Calendar.MONTH) + 1);
- monthSpnr.setLayoutData(gd);
- monthSpnr.addSelectionListener(new SelectionAdapter() {
+ gd = new GridData(66, SWT.DEFAULT);
+ monthCbo = new Combo(monthHourComp, SWT.DROP_DOWN | SWT.READ_ONLY);
+ monthCbo.setLayoutData(gd);
+ for ( int i = 1; i <= 12; i++ ) {
+ monthCbo.add(""+i, i-1);
+ }
+ monthCbo.select(cal.get(Calendar.MONTH));
+ monthCbo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
+ //System.out.println(" *************** monthsCbo.getText() = " + monthCbo.getText() );
if (autoRedrawChk.getSelection()) {
- redrawWindRose();
+ redrawWindRose();
}
}
});
@@ -448,20 +448,19 @@ public class WindRosePlotDlg extends CaveSWTDialog {
Label numMonthLbl = new Label(monthHourComp, SWT.NONE);
numMonthLbl.setText("Num Months:");
- gd = new GridData(40, SWT.DEFAULT);
- numMonthsSpnr = new Spinner(monthHourComp, SWT.BORDER);
- numMonthsSpnr.setDigits(0);
- numMonthsSpnr.setIncrement(1);
- numMonthsSpnr.setPageIncrement(3);
- numMonthsSpnr.setMinimum(1);
- numMonthsSpnr.setMaximum(12);
- numMonthsSpnr.setSelection(1);
- numMonthsSpnr.setLayoutData(gd);
- numMonthsSpnr.addSelectionListener(new SelectionAdapter() {
+ gd = new GridData(66, SWT.DEFAULT);
+ numMonthsCbo = new Combo(monthHourComp, SWT.DROP_DOWN | SWT.READ_ONLY);
+ numMonthsCbo.setLayoutData(gd);
+ for ( int i = 1; i <= 12; i++ ) {
+ numMonthsCbo.add(""+i, i-1);
+ }
+ numMonthsCbo.select(0);
+ numMonthsCbo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
+ //System.out.println(" *************** numMonthsCbo.getText() = " + numMonthsCbo.getText() );
if (autoRedrawChk.getSelection()) {
- redrawWindRose();
+ redrawWindRose();
}
}
});
@@ -586,8 +585,10 @@ public class WindRosePlotDlg extends CaveSWTDialog {
generateWindRoseHeader();
windRoseCanvasComp.updateAndRedraw(windRoseConfigData.cloneData(),
- windRoseHeader, monthSpnr.getText(),
- numMonthsSpnr.getText(), hourSpnr.getText(),
+ windRoseHeader,
+ monthCbo.getText(),
+ numMonthsCbo.getText(),
+ hourSpnr.getText(),
numHoursSpnr.getText(), flightCatCbo.getSelectionIndex(),
siteList.getItem(siteList.getSelectionIndex()), this);
}
@@ -599,11 +600,21 @@ public class WindRosePlotDlg extends CaveSWTDialog {
if (state == true) {
++busyCount;
shell.setCursor(waitCursor);
+ monthCbo.setEnabled(false);
+ numMonthsCbo.setEnabled(false);
+ hourSpnr.setEnabled(false);
+ numHoursSpnr.setEnabled(false);
+ flightCatCbo.setEnabled(false);
drawBtn.setEnabled(false);
} else {
--busyCount;
if (busyCount == 0) {
shell.setCursor(defaultCursor);
+ monthCbo.setEnabled(true);
+ numMonthsCbo.setEnabled(true);
+ hourSpnr.setEnabled(true);
+ numHoursSpnr.setEnabled(true);
+ flightCatCbo.setEnabled(true);
drawBtn.setEnabled(true);
}
}
@@ -634,23 +645,21 @@ public class WindRosePlotDlg extends CaveSWTDialog {
header.append(siteList.getItem(siteList.getSelectionIndex()));
header.append(" ");
- header.append(MONTHS[monthSpnr.getSelection() - 1]);
+ header.append(MONTHS[monthCbo.getSelectionIndex()]);
- if (numMonthsSpnr.getSelection() == 1) {
+ if ( numMonthsCbo.getSelectionIndex() == 0 ) {
header.append(" ");
} else {
header.append("-");
int endMonth = 0;
- if (((numMonthsSpnr.getSelection() - 1) + monthSpnr.getSelection()) > 12) {
- endMonth = (numMonthsSpnr.getSelection() - 1)
- + monthSpnr.getSelection() - 12;
- header.append(MONTHS[endMonth - 1]);
+ if ( ( numMonthsCbo.getSelectionIndex() + monthCbo.getSelectionIndex() ) > 11 ) {
+ endMonth = numMonthsCbo.getSelectionIndex() + monthCbo.getSelectionIndex() - 12;
+ header.append(MONTHS[endMonth]);
} else {
- endMonth = (numMonthsSpnr.getSelection() - 1)
- + monthSpnr.getSelection();
- header.append(MONTHS[endMonth - 1]);
+ endMonth = numMonthsCbo.getSelectionIndex() + monthCbo.getSelectionIndex();
+ header.append(MONTHS[endMonth]);
}
header.append(" ");
}
diff --git a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/editor/TafViewerEditorDlg.java b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/editor/TafViewerEditorDlg.java
index 247f812f67..527abe027c 100644
--- a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/editor/TafViewerEditorDlg.java
+++ b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/editor/TafViewerEditorDlg.java
@@ -213,6 +213,7 @@ import com.raytheon.viz.texteditor.msgs.IAviationObserver;
* 08/12/2011 10612 rferrel saveFile will now always push file back to the server.
* 11/29/2011 11612 rferrel Added getViewerTabList.
* 20JUL2012 14570 gzhang/zhao Highlight correct time groups in TAF Viewer
+ * 08AGU2012 15613 zhao Modified highlightTAF()
*
*
*
@@ -3674,8 +3675,11 @@ public class TafViewerEditorDlg extends Dialog implements ITafSettable,
}
ResourceConfigMgr configMgr = ResourceConfigMgr.getInstance();
- String taf = tafViewerStTxt.getText();
+ String taf = tafViewerStTxt.getText();
int offset = taf.indexOf("TAF");
+ if ( showHeadersChk.getSelection() ) {
+ offset = taf.indexOf("TAF", offset + 3);
+ }
try {
int end = taf.indexOf("TAF", offset + 3);
if (end > 0) {
@@ -3705,7 +3709,7 @@ public class TafViewerEditorDlg extends Dialog implements ITafSettable,
for (String alertKey : tempoMap.keySet()) {
//System.out.println("2___alertKey: "+ alertKey);
for (String value : tempoMap.get(alertKey)) {
- System.out.println("3___value: "+ value);
+ //System.out.println("3___value: "+ value);
str.setLength(1);
str.append(value);
int len = str.length();
@@ -3745,6 +3749,11 @@ public class TafViewerEditorDlg extends Dialog implements ITafSettable,
str.setLength(len);
str.append("\n");
startIndex = taf.indexOf(str.toString());
+ if (startIndex < 0) {
+ str.setLength(len);
+ str.append("=");
+ startIndex = taf.indexOf(str.toString());
+ }
}
if (startIndex >= 0 /*within the same line*/&& startIndex < endIndex) {
@@ -3983,11 +3992,11 @@ public class TafViewerEditorDlg extends Dialog implements ITafSettable,
// Only load the latest TAF, and assume it is the first one in
// the Viewer.
sb.append(TafUtil.safeFormatTaf(tafsInViewer[0], false));
- String bbb = "";
+ String originalBbb = "";
String[] header = tafsInViewer[0].getWmoHeader().split(" ");
if (header.length > 3) {
- bbb = header[3];
+ originalBbb = header[3];
}
ITafSiteConfig config = TafSiteConfigFactory.getInstance();
@@ -3997,6 +4006,7 @@ public class TafViewerEditorDlg extends Dialog implements ITafSettable,
String stationId = siteData.wmo.split(" ")[1];
String issueTime = header[2];
+ String bbb = "";
if (type == null) {
// Do nothing
} else if (type == TafSettings.OPEN_AMD) {
diff --git a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/guidance/MetarViewer.java b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/guidance/MetarViewer.java
index ab01929c16..bbd0b85599 100644
--- a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/guidance/MetarViewer.java
+++ b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/guidance/MetarViewer.java
@@ -63,7 +63,7 @@ import com.raytheon.viz.aviation.resource.ResourceConfigMgr.ResourceTag;
* and set default value for check hours.
* 04/28/2011 8065 rferrel Add flag to indicate display is current
* and implement data caching
- * 20JUL2012 14570 gzhang/zhao Added "tempo" to alertMap
+ * 31JUL2012 14570 zhao Highlight Metar alert for case of 'cat'
*
*
*
@@ -127,6 +127,7 @@ public class MetarViewer extends ViewerTab implements
*/
private static final HashMap alertMap = new HashMap();
static {
+ //alertMap.put("cat", new String[] { "", " ", "", " " }); // 14570
alertMap.put("tempo", new String[] { "", " ", "", " ", "", " ", "", " " }); // 14570
alertMap.put("vsby", new String[] { "", " " });
alertMap.put("wind", new String[] { "", " " });
@@ -410,7 +411,12 @@ public class MetarViewer extends ViewerTab implements
if (alertMap != null && alertMap.size() > 0) {
for (String key : alertMap.keySet()) {
- colorViewerAlert(key, configMgr);
+ if ( key.equals("cat") ) { // "cat" involves "visibility" and "sky condition"
+ colorViewerAlert("vsby", configMgr);
+ colorViewerAlert("sky", configMgr);
+ } else {
+ colorViewerAlert(key, configMgr);
+ }
}
}
}
diff --git a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/monitor/SiteMonitor.java b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/monitor/SiteMonitor.java
index ad6f475855..aefc1f5df2 100644
--- a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/monitor/SiteMonitor.java
+++ b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/monitor/SiteMonitor.java
@@ -63,7 +63,7 @@ import com.raytheon.viz.aviation.xml.MonitorCfg;
* May 13, 2011 8611 rferrel Added type to help determine blink state.
* Apr 30, 2012 14717 zhao Indicators turn gray when Metar is outdated
* 20JUL2012 14570 gzhang/zhao Modified for highlighting correct time groups in TAF Viewer
- *
+ * 11AUG2012 14570 zhao Added 'cat' to alert_key_map
*
*
* @author lvenable
@@ -126,7 +126,8 @@ public class SiteMonitor implements IRequestCompleteListener> {
*/
private static final Map ALERT_KEY_MAP = new HashMap();
{
- ALERT_KEY_MAP.put("tempo", new String[] { "wind", "vsby", "pcp", "obv", "vcnty", "sky" } ); // 14570
+ ALERT_KEY_MAP.put("cat", new String[] { "vsby", "sky" }); // 14570
+ //ALERT_KEY_MAP.put("tempo", new String[] { "wind", "vsby", "pcp", "obv", "vcnty", "sky" } ); // 14570
ALERT_KEY_MAP.put("vsby", new String[] { "vsby" });
ALERT_KEY_MAP.put("wind", new String[] { "wind" });
ALERT_KEY_MAP.put("wx", new String[] { "pcp", "obv", "vcnty" });
diff --git a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/monitor/TafUtil.java b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/monitor/TafUtil.java
index b17b58b198..556459afad 100644
--- a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/monitor/TafUtil.java
+++ b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/monitor/TafUtil.java
@@ -49,6 +49,7 @@ import com.raytheon.uf.viz.core.exception.VizException;
* Jul 6, 2010 5792 rferrel getLatestTafs now returns tafs
* sorted by issue date newest at
* the start of the array.
+ * 08AUG2012 15613 zhao Modified safeFormatTaf()
*
*
*
@@ -161,12 +162,13 @@ public class TafUtil {
*/
public static String safeFormatTaf(TafRecord t, boolean includeHeader) {
StringBuilder sb = new StringBuilder();
- if (includeHeader) {
- sb.append(t.getWmoHeader());
- sb.append(LINE_BREAK);
- }
if (t != null) {
String[] text = t.getTafText().split("[\r\n]");
+ if (includeHeader) {
+ sb.append(t.getWmoHeader());
+ sb.append(LINE_BREAK);
+ sb.append("TAF").append(t.getStationId().substring(1,4)).append(LINE_BREAK);
+ }
String firstLine = text[0];
if (firstLine.startsWith("TAF AMD")
|| firstLine.startsWith("TAF COR")) {
@@ -191,6 +193,7 @@ public class TafUtil {
sb.append(LINE_BREAK);
}
}
+ sb.append(LINE_BREAK);
}
return sb.toString();
}
diff --git a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/observer/SendDialog.java b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/observer/SendDialog.java
index 1f643714eb..4866319bec 100755
--- a/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/observer/SendDialog.java
+++ b/cave/com.raytheon.viz.aviation/src/com/raytheon/viz/aviation/observer/SendDialog.java
@@ -68,6 +68,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* 28 FEB 2008 938 lvenable Initial creation.
* 4/15/2009 1982 grichard Provide feedback when saving a working TAF.
* 12/08/2011 11745 rferrel Updated header time to transmission time.
+ * 08AUG2012 15613 zhao Determine proper BBB for transmission
*
*
*
@@ -364,7 +365,7 @@ public class SendDialog extends CaveSWTDialog {
String siteWmoId = tabComp.getWmoId();
// WMO Site
String siteNode = null;
- java.util.List stationIds = new ArrayList();
+ //java.util.List stationIds = new ArrayList();
ArrayList tafs = new ArrayList();
ArrayList updatedTafs = new ArrayList();
@@ -402,6 +403,16 @@ public class SendDialog extends CaveSWTDialog {
// Site ID
String siteId = fourLetterId.substring(1);
+ /*
+ * If "AAX" or "CCX" or "RRX", determine BBB for transmission
+ */
+ String xmitBbb = bbb;
+ if ( bbb.equals("AAX") || bbb.equals("CCX") || bbb.equals("RRX") ) {
+ String type = bbb.substring(0, 2);
+ xmitBbb = getXmitBbb( type, siteId);
+ }
+
+
// Update Header Time to transmission time.
tafText = TIMESTAMP_PATTERN.matcher(tafText).replaceFirst(
xmitTimestamp);
@@ -418,7 +429,7 @@ public class SendDialog extends CaveSWTDialog {
}
TafQueueRecord record = new TafQueueRecord(forecasterId,
- xmitTime.getTime(), tafText, bbb, siteId, siteWmoId,
+ xmitTime.getTime(), tafText, xmitBbb, siteId, siteWmoId,
siteNode, xmitTime.getTime());
records.add(record);
}
@@ -455,4 +466,41 @@ public class SendDialog extends CaveSWTDialog {
tabComp.setTafSent(tafsQeueued);
shell.dispose();
}
+
+ @SuppressWarnings("unchecked")
+ private String getXmitBbb(String type, String siteId) {
+
+ try {
+ TafQueueRequest request = new TafQueueRequest();
+ request.setType(Type.GET_LIST);
+ request.setState(TafQueueRecord.TafQueueState.SENT);
+ ServerResponse> response = (ServerResponse>) ThriftClient.sendRequest(request);
+ java.util.List payload = response.getPayload();
+ String [] records = (String []) payload.toArray(new String[0]);
+ int numRecords = records.length;
+ for ( int i = numRecords-1; i >=0; i-- ) {
+ if ( records[i].contains(siteId) ) {
+ String [] texts = records[i].split("-");
+ String bbb = texts[texts.length-2];
+ if ( bbb.equals(" ") ) {
+ return type+"A";
+ }
+ if ( bbb.subSequence(0, 2).equals(type) ) {
+ char[] newX = new char[] { bbb.charAt(2) };
+ if ( newX[0] == 'X' ) {
+ newX[0] = 'A';
+ } else {
+ newX[0]++;
+ }
+ return type + new String( newX );
+ }
+ }
+ }
+ } catch (VizException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return type + "A";
+ }
}
diff --git a/cave/com.raytheon.viz.bcd/src/com/raytheon/viz/bcd/BCDResource.java b/cave/com.raytheon.viz.bcd/src/com/raytheon/viz/bcd/BCDResource.java
index 063bebf687..ee088160f1 100644
--- a/cave/com.raytheon.viz.bcd/src/com/raytheon/viz/bcd/BCDResource.java
+++ b/cave/com.raytheon.viz.bcd/src/com/raytheon/viz/bcd/BCDResource.java
@@ -26,6 +26,7 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
import java.nio.channels.FileChannel;
import java.nio.channels.FileChannel.MapMode;
import java.util.ArrayList;
@@ -69,6 +70,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* 7/1/06 chammack Initial Creation.
* 1/10/08 562 bphillip Modified to handle .bcx files
* 02/11/09 njensen Refactored to new rsc architecture
+ * 07/31/12 DR 14935 D. Friedman Handle little-endian files
*
*
*
@@ -190,6 +192,14 @@ public class BCDResource extends
ByteBuffer buffer = fc.map(MapMode.READ_ONLY, 0, file.length());
+ // Determine byte order of data
+ if (buffer.remaining() >= 4) {
+ // Whether BCX or not, first value is an int.
+ // Note: Different from A1 which tests >31 or >500
+ if (buffer.getInt(0) > Short.MAX_VALUE)
+ buffer.order(ByteOrder.LITTLE_ENDIAN);
+ }
+
int i = 0;
double minLat = Double.MAX_VALUE;
diff --git a/cave/com.raytheon.viz.feature.awips.developer/feature.xml b/cave/com.raytheon.viz.feature.awips.developer/feature.xml
index f892126f88..ff7e3c0570 100644
--- a/cave/com.raytheon.viz.feature.awips.developer/feature.xml
+++ b/cave/com.raytheon.viz.feature.awips.developer/feature.xml
@@ -50,10 +50,6 @@
id="com.raytheon.uf.viz.d2d.core.feature"
version="0.0.0"/>
-
-
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/PythonPreferenceStore.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/PythonPreferenceStore.java
index bd2a643dc7..5015cb67da 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/PythonPreferenceStore.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/PythonPreferenceStore.java
@@ -34,6 +34,7 @@ import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.util.SafeRunnable;
+import com.raytheon.uf.common.dataplugin.gfe.python.GfePyIncludeUtil;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
@@ -76,7 +77,6 @@ public class PythonPreferenceStore implements IPreferenceStore,
private String configName;
- @SuppressWarnings("unchecked")
public PythonPreferenceStore(String configName) {
this.propertyChangeListeners = new ArrayList();
this.configurationChangeListeners = new ArrayList();
@@ -84,7 +84,8 @@ public class PythonPreferenceStore implements IPreferenceStore,
this.loadConfiguration(configName);
}
- public void loadConfiguration(String configName) {
+ @SuppressWarnings("unchecked")
+ public void loadConfiguration(String configName) {
IPathManager pathMgr = PathManagerFactory.getPathManager();
String utilityDir = pathMgr.getFile(
pathMgr.getContext(LocalizationType.CAVE_STATIC,
@@ -92,23 +93,14 @@ public class PythonPreferenceStore implements IPreferenceStore,
com.raytheon.uf.common.util.FileUtil.join("gfe", "utility"))
.getPath();
- String configDir = com.raytheon.uf.common.util.FileUtil.join("gfe",
- "userPython", "gfeConfig");
- String baseDir = pathMgr.getFile(
- pathMgr.getContext(LocalizationType.CAVE_STATIC,
- LocalizationLevel.BASE), configDir).getPath();
- String siteDir = pathMgr.getFile(
- pathMgr.getContext(LocalizationType.CAVE_STATIC,
- LocalizationLevel.SITE), configDir).getPath();
- String userDir = pathMgr.getFile(
- pathMgr.getContext(LocalizationType.CAVE_STATIC,
- LocalizationLevel.USER), configDir).getPath();
+ String configPath = GfePyIncludeUtil.getConfigIncludePath();
+ String vtecPath = GfePyIncludeUtil.getVtecIncludePath();
PythonScript py = null;
try {
py = new PythonScript(
utilityDir + File.separator + "loadConfig.py",
- PyUtil.buildJepIncludePath(userDir, siteDir, baseDir));
+ PyUtil.buildJepIncludePath(configPath, vtecPath));
} catch (JepException e) {
statusHandler.handle(Priority.CRITICAL,
"Unable to load GFE config", e);
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/config/ConfigCatalog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/config/ConfigCatalog.java
index 83a05ff985..fb440bd456 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/config/ConfigCatalog.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/config/ConfigCatalog.java
@@ -121,10 +121,11 @@ public class ConfigCatalog extends AbstractScriptCatalog {
// Look for HideConfigFile = True in the file
PythonScript pscript = null;
try {
- String includePath = PyUtil
- .buildJepIncludePath(GfePyIncludeUtil
- .getConfigIncludePath());
- pscript = new PythonScript(file.getAbsolutePath(), includePath,
+ String configPath = GfePyIncludeUtil.getConfigIncludePath();
+ String vtecPath = GfePyIncludeUtil.getVtecIncludePath();
+
+ pscript = new PythonScript(file.getAbsolutePath(),
+ PyUtil.buildJepIncludePath(configPath, vtecPath),
getClass().getClassLoader(), preEvals);
Boolean scriptValue = (Boolean) pscript.execute(
"checkHideConfigFile", null);
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/ISelectTimeRangeManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/ISelectTimeRangeManager.java
index 173551c912..9beaf6d463 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/ISelectTimeRangeManager.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/ISelectTimeRangeManager.java
@@ -19,8 +19,8 @@
**/
package com.raytheon.viz.gfe.core;
-import com.raytheon.viz.gfe.core.time.SelectTimeRange;
-import com.raytheon.viz.gfe.core.time.SelectTimeRange.Mode;
+import com.raytheon.uf.common.dataplugin.gfe.time.SelectTimeRange;
+import com.raytheon.uf.common.dataplugin.gfe.time.SelectTimeRange.Mode;
/**
* TODO Add Description
@@ -31,6 +31,7 @@ import com.raytheon.viz.gfe.core.time.SelectTimeRange.Mode;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 3, 2009 randerso Initial creation
+ * Aug 1, 2012 #965 dgilling Change location of SelectTimeRange.
*
*
*
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/AbstractGridData.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/AbstractGridData.java
index 50df7c16a5..c9650039c1 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/AbstractGridData.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/AbstractGridData.java
@@ -79,12 +79,12 @@ public abstract class AbstractGridData implements IGridData {
protected boolean iscCapable = true;
- protected Date lastAccessTime;
+ protected long lastAccessTime;
protected Grid2DBit changedPoints;
protected AbstractGridData(Parm aParm, IGridSlice aSlice) {
- this.lastAccessTime = SimulatedTime.getSystemTime().getTime();
+ this.lastAccessTime = System.currentTimeMillis();
this.parm = aParm;
this.gridSlice = aSlice;
// this.gridSlice.setUseCache(true);
@@ -135,7 +135,7 @@ public abstract class AbstractGridData implements IGridData {
}
@Override
- public Date getLastAccessTime() {
+ public long getLastAccessTime() {
return this.lastAccessTime;
}
@@ -184,7 +184,7 @@ public abstract class AbstractGridData implements IGridData {
}
}
- this.lastAccessTime = SimulatedTime.getSystemTime().getTime();
+ this.lastAccessTime = System.currentTimeMillis();
}
@Override
@@ -458,7 +458,7 @@ public abstract class AbstractGridData implements IGridData {
public boolean applyDelta(Date time, float delta, boolean taper,
Grid2DBit pointsToChange) {
if (delta == 0.0) {
- return false; // nothing to change
+ return true; // nothing to change
}
populate();
checkOkayForEdit();
@@ -863,12 +863,12 @@ public abstract class AbstractGridData implements IGridData {
if (!this.isPopulated()) {
return;
}
- String msg = "Depopulating " + getParm().getParmID() + " tr="
- + getGridTime();
- statusHandler.handle(Priority.DEBUG, msg, new Exception("Debug: "
- + msg));
+ // String msg = "Depopulating " + getParm().getParmID() + " tr="
+ // + getGridTime();
+ // statusHandler.handle(Priority.DEBUG, msg, new Exception("Debug: "
+ // + msg));
- this.lastAccessTime = SimulatedTime.getSystemTime().getTime();
+ this.lastAccessTime = 0;
setGridSliceDataToNull();
}
}
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/IGridData.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/IGridData.java
index bbc4e48220..ffb59f56c4 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/IGridData.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/griddata/IGridData.java
@@ -158,7 +158,7 @@ public interface IGridData extends Comparable {
*
* @return time the grid was last accessed
*/
- public Date getLastAccessTime();
+ public long getLastAccessTime();
/**
* Returns the time range associated with this grid.
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/SelectTimeRangeManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/SelectTimeRangeManager.java
index d55affa041..2b2f10887d 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/SelectTimeRangeManager.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/SelectTimeRangeManager.java
@@ -32,6 +32,8 @@ import java.util.List;
import java.util.Map;
import java.util.TimeZone;
+import com.raytheon.uf.common.dataplugin.gfe.time.SelectTimeRange;
+import com.raytheon.uf.common.dataplugin.gfe.time.SelectTimeRange.Mode;
import com.raytheon.uf.common.localization.FileUpdatedMessage;
import com.raytheon.uf.common.localization.ILocalizationFileObserver;
import com.raytheon.uf.common.localization.IPathManager;
@@ -47,8 +49,6 @@ import com.raytheon.viz.gfe.GFEServerException;
import com.raytheon.viz.gfe.core.DataManager;
import com.raytheon.viz.gfe.core.ISelectTimeRangeManager;
import com.raytheon.viz.gfe.core.msgs.SelectTimeRangesChangedMsg;
-import com.raytheon.viz.gfe.core.time.SelectTimeRange;
-import com.raytheon.viz.gfe.core.time.SelectTimeRange.Mode;
/**
* Class which manages the selection time range definitions that are stored on
@@ -60,6 +60,7 @@ import com.raytheon.viz.gfe.core.time.SelectTimeRange.Mode;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 3, 2009 #3135 randerso Initial creation
+ * Aug 1, 2012 #965 dgilling Change location of SelectTimeRange.
*
*
*
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 5722909063..1e92636a5f 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
@@ -718,10 +718,7 @@ public class DbParm extends Parm {
continue; // grid overlaps spatial editor time -- skip it
}
- long lastAccess = 0;
- if (grid.getLastAccessTime() != null) {
- lastAccess = grid.getLastAccessTime().getTime();
- }
+ long lastAccess = grid.getLastAccessTime();
long delta = now - lastAccess;
if (delta < milliseconds) {
@@ -735,9 +732,10 @@ public class DbParm extends Parm {
// only deallocate unlocked grids
if (!locked) {
- String msg = "Deallocating " + getParmID() + " tr=" + gTime;
- statusHandler.handle(Priority.DEBUG, msg, new Exception(
- "Debug: " + msg));
+ // String msg = "Deallocating " + getParmID() + " tr=" +
+ // gTime;
+ // statusHandler.handle(Priority.DEBUG, msg, new Exception(
+ // "Debug: " + msg));
grid.depopulate();
}
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/VCParm.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/VCParm.java
index 71cf6c9270..d9f70456a5 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/VCParm.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/parm/VCParm.java
@@ -304,10 +304,7 @@ public class VCParm extends VParm implements IParmListChangedListener,
continue;
} // grid overlaps spatial editor time -- skip it
- long lastAccess = 0;
- if (grid.getLastAccessTime() != null) {
- lastAccess = grid.getLastAccessTime().getTime();
- }
+ long lastAccess = grid.getLastAccessTime();
long delta = now - lastAccess;
if (delta < milliseconds) {
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/AbstractSaveParameterDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/AbstractSaveParameterDialog.java
index a11e9be7e0..857d4da0af 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/AbstractSaveParameterDialog.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/AbstractSaveParameterDialog.java
@@ -158,77 +158,84 @@ public abstract class AbstractSaveParameterDialog extends CaveJFACEDialog
@Override
protected IStatus run(IProgressMonitor monitor) {
long t0 = System.currentTimeMillis();
- final CountDownLatch latch = new CountDownLatch(
- MAX_CONCURRENT_SAVES);
final AtomicBoolean allSuccessful = new AtomicBoolean(true);
-
- // spawn separate jobs top save parms
- for (int i = 0; i < MAX_CONCURRENT_SAVES; i++) {
- new Job("Saving Parms") {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- Parm parm = null;
- while ((parm = parms.poll()) != null) {
- String parmString = parm.getParmID()
- .toString();
- try {
- // save data
- if (statusHandler
- .isPriorityEnabled(Priority.DEBUG)) {
- statusHandler.handle(
- Priority.DEBUG, "Save: "
- + parmString);
- }
- if (!parm.saveParameter(true)) {
- allSuccessful.set(false);
- }
- } catch (Exception e) {
- allSuccessful.set(false);
- statusHandler.handle(Priority.ERROR,
- "Error occurred saving parm "
- + parmString, e);
- }
- }
- } finally {
- latch.countDown();
- }
-
- return Status.OK_STATUS;
- }
- }.schedule();
- }
-
try {
- latch.await();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
+ final CountDownLatch latch = new CountDownLatch(
+ MAX_CONCURRENT_SAVES);
- if (!allSuccessful.get()) {
- statusHandler.handle(Priority.PROBLEM,
- "Some grids were not saved. See log for details.");
- } else {
- statusHandler.handle(Priority.DEBUG, "Save Complete");
- }
+ // spawn separate jobs top save parms
+ for (int i = 0; i < MAX_CONCURRENT_SAVES; i++) {
+ new Job("Saving Parms") {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ Parm parm = null;
+ while ((parm = parms.poll()) != null) {
+ String parmString = parm.getParmID()
+ .toString();
+ try {
+ // save data
+ if (statusHandler
+ .isPriorityEnabled(Priority.DEBUG)) {
+ statusHandler.handle(
+ Priority.DEBUG,
+ "Save: " + parmString);
+ }
+ if (!parm.saveParameter(true)) {
+ allSuccessful.set(false);
+ }
+ } catch (Throwable e) {
+ allSuccessful.set(false);
+ statusHandler.handle(
+ Priority.ERROR,
+ "Error occurred saving parm "
+ + parmString, e);
+ }
+ }
+ } catch (Throwable e) {
+ allSuccessful.set(false);
+ statusHandler.handle(Priority.ERROR,
+ e.getLocalizedMessage(), e);
+ } finally {
+ latch.countDown();
+ }
- VizApp.runAsync(new Runnable() {
-
- @Override
- public void run() {
- AbstractSaveParameterDialog.this.getShell().setCursor(
- origCursor);
- AbstractSaveParameterDialog.this
- .saveFinished(allSuccessful.get());
+ return Status.OK_STATUS;
+ }
+ }.schedule();
}
- });
- long t1 = System.currentTimeMillis();
- System.out.println("GFE Save Forecast took: " + (t1 - t0)
- + " ms");
+ latch.await();
+ } catch (Throwable e) {
+ allSuccessful.set(false);
+ statusHandler.handle(Priority.PROBLEM,
+ e.getLocalizedMessage(), e);
+ } finally {
+ if (!allSuccessful.get()) {
+ statusHandler
+ .handle(Priority.PROBLEM,
+ "Some grids were not saved. See log for details.");
+ } else {
+ statusHandler.handle(Priority.DEBUG, "Save Complete");
+ }
+
+ VizApp.runAsync(new Runnable() {
+
+ @Override
+ public void run() {
+ AbstractSaveParameterDialog.this.getShell()
+ .setCursor(origCursor);
+ AbstractSaveParameterDialog.this
+ .saveFinished(allSuccessful.get());
+ }
+ });
+
+ long t1 = System.currentTimeMillis();
+ System.out.println("GFE Save Forecast took: " + (t1 - t0)
+ + " ms");
+ }
return Status.OK_STATUS;
}
-
};
saveJob.setSystem(true);
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/DefineRefSetDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/DefineRefSetDialog.java
index 7e19625468..4324498a8d 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/DefineRefSetDialog.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/DefineRefSetDialog.java
@@ -811,7 +811,13 @@ public class DefineRefSetDialog extends CaveJFACEDialog implements
@Override
public void referenceSetChanged(ReferenceData refSet,
ArrayList domains) {
- activeChanged();
+ VizApp.runAsync(new Runnable() {
+
+ @Override
+ public void run() {
+ activeChanged();
+ }
+ });
}
/*
@@ -822,7 +828,13 @@ public class DefineRefSetDialog extends CaveJFACEDialog implements
*/
@Override
public void referenceSetIDChanged(ReferenceID refID) {
- activeChanged();
+ VizApp.runAsync(new Runnable() {
+
+ @Override
+ public void run() {
+ activeChanged();
+ }
+ });
}
/*
@@ -838,7 +850,13 @@ public class DefineRefSetDialog extends CaveJFACEDialog implements
java.util.List deletions,
java.util.List changes) {
- this.refreshRefsets();
+ VizApp.runAsync(new Runnable() {
+
+ @Override
+ public void run() {
+ refreshRefsets();
+ }
+ });
}
/*
@@ -849,7 +867,13 @@ public class DefineRefSetDialog extends CaveJFACEDialog implements
*/
@Override
public void editAreaGroupInvChanged() {
- this.refreshRefsets();
+ VizApp.runAsync(new Runnable() {
+
+ @Override
+ public void run() {
+ refreshRefsets();
+ }
+ });
}
/*
@@ -863,36 +887,35 @@ public class DefineRefSetDialog extends CaveJFACEDialog implements
@Override
public void displayedParmListChanged(Parm[] parms, Parm[] deletions,
Parm[] additions) {
- refreshParms();
- }
-
- private void activeChanged() {
VizApp.runAsync(new Runnable() {
@Override
public void run() {
- // Update display when active refset changes
- ReferenceData refData = refSetMgr.getActiveRefSet();
-
- // Fix active refset display
- if (!activeDisplay.isDisposed()) {
- activeDisplay.setText(getActiveRefDesc(refData));
- }
-
- // Enable/Disable Undo button
- if (!undoButton.isDisposed()) {
- undoButton.setEnabled(!refData.refType().equals(
- RefType.NONE));
- }
-
- // Enable/Disable Convert to Location button
- if (!convertButton.isDisposed()) {
- convertButton.setEnabled(refData.isQuery());
- }
+ refreshParms();
}
});
}
+ private void activeChanged() {
+ // Update display when active refset changes
+ ReferenceData refData = refSetMgr.getActiveRefSet();
+
+ // Fix active refset display
+ if (!activeDisplay.isDisposed()) {
+ activeDisplay.setText(getActiveRefDesc(refData));
+ }
+
+ // Enable/Disable Undo button
+ if (!undoButton.isDisposed()) {
+ undoButton.setEnabled(!refData.refType().equals(RefType.NONE));
+ }
+
+ // Enable/Disable Convert to Location button
+ if (!convertButton.isDisposed()) {
+ convertButton.setEnabled(refData.isQuery());
+ }
+ }
+
private String getActiveRefDesc(ReferenceData refData) {
String s = "";
@@ -947,37 +970,29 @@ public class DefineRefSetDialog extends CaveJFACEDialog implements
}
private void refreshRefsets() {
- VizApp.runAsync(new Runnable() {
+ if (groupList.isDisposed() || editAreasList.isDisposed()) {
+ return;
+ }
- @Override
- public void run() {
- if (groupList.isDisposed() || editAreasList.isDisposed()) {
- return;
- }
+ String[] groups = groupList.getSelection();
- String[] groups = groupList.getSelection();
+ // Refresh the Group and Areas lists
+ java.util.List availGroups = refSetMgr.getGroupInventory();
+ availGroups.add("Misc");
+ groupList.setItems(availGroups.toArray(new String[availGroups.size()]));
- // Refresh the Group and Areas lists
- java.util.List availGroups = refSetMgr
- .getGroupInventory();
- availGroups.add("Misc");
- groupList.setItems(availGroups.toArray(new String[availGroups
- .size()]));
-
- // update selection
- groupList.deselectAll();
- for (String group : groups) {
- int index = groupList.indexOf(group);
- if (index >= 0) {
- groupList.select(index);
- }
- }
-
- groups = groupList.getSelection();
- String[] areaNames = getAreaNames(groups);
- editAreasList.setItems(areaNames);
+ // update selection
+ groupList.deselectAll();
+ for (String group : groups) {
+ int index = groupList.indexOf(group);
+ if (index >= 0) {
+ groupList.select(index);
}
- });
+ }
+
+ groups = groupList.getSelection();
+ String[] areaNames = getAreaNames(groups);
+ editAreasList.setItems(areaNames);
}
private void refreshParms() {
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/FormatterLauncherDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/FormatterLauncherDialog.java
index e1d95dadb0..9f123d61a4 100755
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/FormatterLauncherDialog.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/FormatterLauncherDialog.java
@@ -88,6 +88,7 @@ import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
* practice and test modes
* Sep 16, 2010 6831 ryu Show same product for different areas on a sub-menu
* Nov 22, 2011 8781 mli remove Processor menu
+ * Jul 26, 2012 15165 ryu Set default db source when formatter has no db defined.
*
*
*
@@ -776,6 +777,8 @@ public class FormatterLauncherDialog extends CaveJFACEDialog implements
ProductDefinition prodDef = textProductMgr
.getProductDefinition(productName);
String dataSource = (String) prodDef.get("database");
+ if (dataSource == null)
+ dataSource = "Official";
if (dataSource.equals("ISC")) {
selectedDataSource = getIscDataSource();
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/SaveDeleteSelectTRDialog.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/SaveDeleteSelectTRDialog.java
index a36f733657..72a83422b2 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/SaveDeleteSelectTRDialog.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/dialogs/SaveDeleteSelectTRDialog.java
@@ -41,17 +41,15 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+import com.raytheon.uf.common.dataplugin.gfe.time.SelectTimeRange;
+import com.raytheon.uf.common.dataplugin.gfe.time.SelectTimeRange.Mode;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
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.common.time.SimulatedTime;
-import com.raytheon.viz.gfe.Activator;
import com.raytheon.viz.gfe.GFEServerException;
-import com.raytheon.viz.gfe.constants.StatusConstants;
import com.raytheon.viz.gfe.core.DataManager;
-import com.raytheon.viz.gfe.core.time.SelectTimeRange;
-import com.raytheon.viz.gfe.core.time.SelectTimeRange.Mode;
import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
import com.raytheon.viz.ui.widgets.SpinScale;
@@ -64,6 +62,7 @@ import com.raytheon.viz.ui.widgets.SpinScale;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 7, 2009 randerso Initial creation
+ * Aug 1, 2012 #965 dgilling Change location of SelectTimeRange.
*
*
*
@@ -72,7 +71,8 @@ import com.raytheon.viz.ui.widgets.SpinScale;
*/
public class SaveDeleteSelectTRDialog extends CaveJFACEDialog {
- private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(SaveDeleteSelectTRDialog.class);
+ private static final transient IUFStatusHandler statusHandler = UFStatus
+ .getHandler(SaveDeleteSelectTRDialog.class);
private DataManager dataManager;
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/edittool/contour/ContourTool.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/edittool/contour/ContourTool.java
index b8f43e364d..aa25309507 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/edittool/contour/ContourTool.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/edittool/contour/ContourTool.java
@@ -115,6 +115,8 @@ import com.vividsolutions.jts.geom.LineString;
* Jul 29, 2009 randerso Initial creation
* Jul 02, 2010 6285 mpduff Fixed contours to update after
* drawing and calculating new grid.
+ * Aug 08, 2012 #621 dgilling Fix ConcurrentModificationException
+ * in handling of renderables field.
*
*
*
@@ -323,6 +325,9 @@ public class ContourTool extends AbstractFreeformTool implements
*/
private void replaceCLines(List contours) {
clearRenderables();
+
+ List renderables = new ArrayList(
+ this.renderables);
renderables.add(freeformRenderable);
if (currentGrid != null) {
@@ -353,26 +358,34 @@ public class ContourTool extends AbstractFreeformTool implements
}
}
renderables.add(renderable);
- refresh();
}
+
+ this.renderables = renderables;
+ refresh();
}
private void disposeRenderables() {
+ List renderables = new ArrayList(
+ this.renderables);
for (IRenderable renderable : renderables) {
if (renderable instanceof JTSRenderable) {
((JTSRenderable) renderable).dispose();
}
}
renderables.clear();
+ this.renderables = renderables;
}
private void clearRenderables() {
+ List renderables = new ArrayList(
+ this.renderables);
for (IRenderable renderable : renderables) {
if (renderable instanceof JTSRenderable) {
((JTSRenderable) renderable).clear();
}
}
renderables.clear();
+ this.renderables = renderables;
}
private void initializeContourData(IGridData grid) {
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/edittool/sample/SamplePainter.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/edittool/sample/SamplePainter.java
index bae55eb71d..03d528d974 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/edittool/sample/SamplePainter.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/edittool/sample/SamplePainter.java
@@ -66,6 +66,8 @@ import com.vividsolutions.jts.geom.Coordinate;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 04/08/2008 chammack Initial Port from AWIPS I (minus ISC support)
+ * 07/23/2012 #936 dgilling Reinstate config-handling code to
+ * calcGridLabels().
*
*
*
@@ -253,7 +255,7 @@ public class SamplePainter {
private void calcGridLabels(Coordinate worldLoc, final List grids,
final GridID imageGrid, List sampleLabels, List colors) {
- if (grids.size() == 0) {
+ if (grids.isEmpty()) {
return;
}
@@ -261,9 +263,9 @@ public class SamplePainter {
// all parms
List limitSamples = Arrays.asList(Activator.getDefault()
.getPreferenceStore().getStringArray("SampleParms"));
+
// assumes all grids shared same grid location.
boolean inGrid = false;
-
Coordinate gridCoordinate = MapUtil.latLonToGridCoordinate(worldLoc,
PixelOrientation.UPPER_LEFT, grids.get(0).getParm()
.getGridInfo().getGridLoc());
@@ -280,27 +282,41 @@ public class SamplePainter {
inGrid = true;
}
- // sample label color
- RGB labelColor = new RGB(255, 255, 255);
-
// get the list of samples that should be painted and in the
// order
for (GridID grid : grids) {
String pName = grid.getParm().getParmID().compositeNameUI();
// do we plot this weather element?
- if ((limitSamples.size() != 0) && !limitSamples.contains(pName)) {
+ if ((!limitSamples.isEmpty()) && !limitSamples.contains(pName)) {
continue; // skip
}
+ // calculate color
+ RGB labelColor = grid.getParm().getDisplayAttributes()
+ .getBaseColor();
+
+ if (grid.equals(imageGrid)) {
+ RGB color = new RGB(255, 255, 255);
+ String colorName = Activator.getDefault().getPreferenceStore()
+ .getString("ImageLegend_color");
+ if (!colorName.isEmpty()) {
+ color = RGBColors.getRGBColor(colorName);
+ }
+ labelColor = color;
+ }
+ String parmColorName = Activator.getDefault().getPreferenceStore()
+ .getString(pName + "_Sample_color");
+ if (!parmColorName.isEmpty()) {
+ labelColor = RGBColors.getRGBColor(parmColorName);
+ }
+
// get the data value
String label = NO_DATA_LABEL;
if (inGrid) {
-
// isc mode or grid from isc database
if (showISC || grid.getParm().getParmState().isIscParm()) {
label = iscSampleLabel(grid, gridCoordinate);
-
} else if (showDataValues) {
final IGridData gridData = grid.grid();
if (gridData != null) {
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/edittool/sample/SampleRenderable.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/edittool/sample/SampleRenderable.java
index 4a9f2b70e0..675a712363 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/edittool/sample/SampleRenderable.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/edittool/sample/SampleRenderable.java
@@ -38,6 +38,7 @@ 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;
import com.raytheon.viz.gfe.core.parm.Parm;
+import com.raytheon.viz.gfe.core.parm.ParmDisplayAttributes.VisMode;
import com.raytheon.viz.gfe.edittool.EditToolPaintProperties;
import com.raytheon.viz.gfe.edittool.GridID;
import com.raytheon.viz.gfe.rsc.GFEFonts;
@@ -45,16 +46,18 @@ import com.vividsolutions.jts.geom.Coordinate;
/**
* Handles the display for on-demand sampling capability.
- *
- * Roughly based on AWIPS I class of the same name.
+ *
+ * Roughly based on AWIPS I class SampleVisual.
*
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 04/08/2008 chammack Initial Creation.
- * 11Jun2008 #1193 ebabin Updates for toggling lat/lon for sample set.
+ * 06/11/2008 #1193 ebabin Updates for toggling lat/lon for sample set.
* 07/21/2009 bphillip Removed the points field
+ * 07/23/2012 #936 dgilling Properly retrieve imageGrid for paintMarkers()
+ * and paintSamples().
*
*
*
@@ -148,13 +151,17 @@ public class SampleRenderable implements IRenderable, IMessageClient {
imageGrid = qvGrid;
} else {
Parm[] parms = sdm.getCurrentlyEnabledParms();
- Parm imageParm = sdm.getActivatedParm();
+ Parm imageParm = null;
Arrays.sort(parms);
gids = new ArrayList(parms.length);
-
Date date = sdm.getSpatialEditorTime();
- for (int i = 0; i < parms.length; i++) {
- gids.add(new GridID(parms[i], date));
+
+ for (Parm p : parms) {
+ gids.add(new GridID(p, date));
+
+ if (p.getDisplayAttributes().getVisMode() == VisMode.IMAGE) {
+ imageParm = p;
+ }
}
imageGrid = new GridID(imageParm, date);
@@ -184,12 +191,16 @@ public class SampleRenderable implements IRenderable, IMessageClient {
Date date = sdm.getSpatialEditorTime();
Parm[] parms = sdm.getCurrentlyEnabledParms();
- Parm imageParm = sdm.getActivatedParm();
+ Parm imageParm = null;
Arrays.sort(parms);
GridID[] grids = new GridID[parms.length];
for (int i = 0; i < parms.length; i++) {
grids[i] = new GridID(parms[i], date);
+
+ if (parms[i].getDisplayAttributes().getVisMode() == VisMode.IMAGE) {
+ imageParm = parms[i];
+ }
}
GridID imageGrid = new GridID(imageParm, date);
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/gridmanager/GridBar.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/gridmanager/GridBar.java
index 4151787349..558e5f1cbb 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/gridmanager/GridBar.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/gridmanager/GridBar.java
@@ -647,13 +647,14 @@ public class GridBar implements IMessageClient, IParmInventoryChangedListener,
Rectangle rect = computeRect(dataTR);
gc.setFont(timeBlockSourceFont);
+ gc.setTextAntialias(SWT.OFF);
String s = truncateLabelToFit(gc, text, rect.width);
Point textSize = gc.stringExtent(s);
if (textSize.x < rect.width + DATA_BLOCK_HORIZONTAL_MARGIN) {
int xOffset = (rect.width - textSize.x) / 2;
int yOffset = (rect.height - textSize.y) / 2;
- gc.drawString(s, rect.x + xOffset, rect.y + yOffset, false);
+ gc.drawString(s, rect.x + xOffset, rect.y + yOffset, true);
}
}
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/Tool.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/Tool.java
index 70ed2e10ef..f5f1fbd529 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/Tool.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/smarttool/Tool.java
@@ -603,7 +603,9 @@ public class Tool {
parmToEdit.startParmEdit(new Date[] { timeInfluence });
} catch (GFEOperationFailedException e) {
statusHandler.handle(Priority.PROBLEM,
- "Error during start parm edit", e);
+ "Error during start parm edit for " + toolName + " - already running." +
+ " Please wait for the operation to complete and try again.",
+ e);
return;
}
startedParmEdit = true;
diff --git a/cave/com.raytheon.viz.grid/localization/styleRules/gridImageryStyleRules.xml b/cave/com.raytheon.viz.grid/localization/styleRules/gridImageryStyleRules.xml
index 3a65243be8..da570400d3 100644
--- a/cave/com.raytheon.viz.grid/localization/styleRules/gridImageryStyleRules.xml
+++ b/cave/com.raytheon.viz.grid/localization/styleRules/gridImageryStyleRules.xml
@@ -2422,12 +2422,12 @@
%
- 5
+ -1
105
Grid/warm to cold
- 20
+ 20 40 60 80 100
diff --git a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/GridResourceData.java b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/GridResourceData.java
index 875a7612a2..474a6b69aa 100644
--- a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/GridResourceData.java
+++ b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/GridResourceData.java
@@ -162,6 +162,7 @@ public class GridResourceData extends AbstractRequestableResourceData implements
sampling = sampling == null ? false : sampling;
return new GridIconResource(this, loadProperties);
case BARB:
+ sampling = sampling == null ? false : sampling;
case ARROW:
case DUALARROW:
case STREAMLINE:
@@ -170,7 +171,7 @@ public class GridResourceData extends AbstractRequestableResourceData implements
// grib data in D2D is in one location. There are only a few
// products that do not work correctly, contours of vector
// direction, and data mapped images.
- sampling = sampling == null ? false : sampling;
+ sampling = sampling == null ? true : sampling;
return new D2DGribGridResource(this, loadProperties);
case CONTOUR:
default:
diff --git a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/GridVectorResource.java b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/GridVectorResource.java
index 662e9a92ec..41783bd7c4 100644
--- a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/GridVectorResource.java
+++ b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/GridVectorResource.java
@@ -109,6 +109,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* 05/16/2012 14993 D. Friedman Fix "blocky" contours
* 06/19/2012 14988 D. Friedman Reproject based on conformality
* 07/09/2012 14940 M. Porricelli Apply reprojection to streamlines
+ * 07/23/2012 14968 M. Porricelli Changed wording of streamline legend
*
*
*
@@ -491,7 +492,7 @@ public class GridVectorResource extends AbstractMapVectorResource implements
legendParams.dataTime = getDisplayedDataTime();
if (displayType == DisplayType.STREAMLINE) {
- legendParams.type = " Streamlines";
+ legendParams.type = " Strmlns";
} else if (displayType == DisplayType.BARB) {
legendParams.type = "Wind Barbs";
} else if (displayType == DisplayType.ARROW) {
@@ -526,7 +527,7 @@ public class GridVectorResource extends AbstractMapVectorResource implements
legendParams.dataTime = getDisplayedDataTime();
if (displayType == DisplayType.STREAMLINE) {
- legendParams.type = " Streamlines";
+ legendParams.type = " Strmlns";
} else if (displayType == DisplayType.BARB) {
legendParams.type = "Wind Barbs";
} else if (displayType == DisplayType.ARROW) {
diff --git a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/general/D2DGribGridResource.java b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/general/D2DGribGridResource.java
index 28888ed1a6..99df74b47f 100644
--- a/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/general/D2DGribGridResource.java
+++ b/cave/com.raytheon.viz.grid/src/com/raytheon/viz/grid/rsc/general/D2DGribGridResource.java
@@ -74,6 +74,8 @@ import com.vividsolutions.jts.geom.Coordinate;
* ------------ ---------- ----------- --------------------------
* Mar 9, 2011 bsteffen Initial creation
* 06/19/2012 14988 D. Friedman Reproject based on conformality
+ * 07/23/2012 14968 M. Porricelli Changed wording of streamline
+ * legend
*
*
*
@@ -258,7 +260,7 @@ public class D2DGribGridResource extends GribGridResource
// The default type does not display in the legend
legendParams.type = "";
} else if (displayType == DisplayType.STREAMLINE) {
- legendParams.type = "Streamlines";
+ legendParams.type = "Strmlns";
} else if (displayType == DisplayType.BARB) {
legendParams.type = "Wind Barbs";
} else if (displayType == DisplayType.ARROW) {
diff --git a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/flashfloodguidance/FlashFloodGuidanceDlg.java b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/flashfloodguidance/FlashFloodGuidanceDlg.java
index 953d9b0b1b..b91ddd7bbb 100644
--- a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/flashfloodguidance/FlashFloodGuidanceDlg.java
+++ b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/flashfloodguidance/FlashFloodGuidanceDlg.java
@@ -237,7 +237,7 @@ public class FlashFloodGuidanceDlg extends CaveSWTDialog {
/**
* The duration in millis being displayed.
*/
- private int duration;
+ private int duration = 3600;
/**
* Holds the display string and insert time for later use.
@@ -1126,7 +1126,7 @@ public class FlashFloodGuidanceDlg extends CaveSWTDialog {
String day = parts[2];
String date = parts[3];
String hour = parts[4];
- duration = Integer.parseInt(durationStr) * FFGConstants.MILLIS_PER_HOUR;
+ duration = Integer.parseInt(durationStr) * FFGConstants.SECONDS_PER_HOUR;
String paramAbr = "FFG" + durationStr + "24hr";
diff --git a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/resource/MultiPointResource.java b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/resource/MultiPointResource.java
index 3e95444f0f..bb592a4dca 100644
--- a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/resource/MultiPointResource.java
+++ b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/resource/MultiPointResource.java
@@ -343,24 +343,21 @@ public class MultiPointResource extends
Coordinate xy = new Coordinate(gage.getLon(), gage.getLat());
gage.setCoordinate(xy);
- double latInc = .05;
- double lonInc = .03;
+ /* Create a small envelope around the point */
+ double shiftHeightValue = getShiftHeight(gage);
+ double shiftWidthValue = getShiftWidth(gage);
if (existing != null) {
- Coordinate p1 = new Coordinate(existing.getLon() + lonInc,
- existing.getLat() + latInc);
- Coordinate p2 = new Coordinate(existing.getLon() - lonInc,
- existing.getLat() - latInc);
- Envelope oldEnv = new Envelope(p1, p2);
+ PixelExtent pe = getPixelExtent(existing, getShiftWidth(existing),
+ getShiftHeight(existing));
+ Envelope oldEnv = descriptor.pixelToWorld(pe);
strTree.remove(oldEnv, existing);
}
/* Create a small envelope around the point */
- Coordinate p1 = new Coordinate(gage.getLon() + lonInc,
- gage.getLat() + latInc);
- Coordinate p2 = new Coordinate(gage.getLon() - lonInc,
- gage.getLat() - latInc);
- Envelope newEnv = new Envelope(p1, p2);
+ PixelExtent pe = getPixelExtent(gage, getShiftWidth(gage),
+ getShiftHeight(gage));
+ Envelope newEnv = descriptor.pixelToWorld(pe);
strTree.insert(newEnv, gage);
dataMap.put(lid, gage);
@@ -871,12 +868,19 @@ public class MultiPointResource extends
Envelope env = new Envelope(coord.asLatLon());
List> elements = strTree.query(env);
if (elements.size() > 0) {
+ StringBuffer sb = new StringBuffer();
+ boolean first = true;
Iterator> iter = elements.iterator();
while (iter.hasNext()) {
GageData gage = (GageData) iter.next();
- return "GAGE: " + gage.getName() + " VALUE: "
- + gage.getGageValue();
+ if (!first) {
+ sb.append("\n");
+ }
+ sb.append("GAGE: " + gage.getName() + " VALUE: "
+ + gage.getGageValue());
+ first = false;
}
+ return sb.toString();
}
} catch (Exception e) {
throw new VizException(e);
diff --git a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDisplayDlg.java b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDisplayDlg.java
index cdb7102a22..d034dafafe 100644
--- a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDisplayDlg.java
+++ b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDisplayDlg.java
@@ -87,8 +87,9 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* so that it would place the
* entire time series within the
* printable area of the page.
- * 04 Mar 2011 7644 lbousaid fixed Zoom in feature
- * 30 May 2012 14967 wkwock fix insert deleted data to rejecteddata table
+ * 04 Mar 2011 7644 lbousaid fixed Zoom in feature
+ * 30 May 2012 14967 wkwock fix insert deleted data to rejecteddata table
+ * 23 Jul 2012 15195 mpduff Fix dates for displaying groups
*
*
*
@@ -1360,22 +1361,9 @@ public class TimeSeriesDisplayDlg extends CaveSWTDialog {
linesMI.setSelection(true);
}
- /* Get time data from group info */
- int pastHours = groupInfo.getPastHours();
- int futureHours = groupInfo.getFutureHours();
-
- Calendar futureCal = Calendar.getInstance(TimeZone
- .getTimeZone("GMT"));
- Date d = SimulatedTime.getSystemTime().getTime();
- futureCal.setTime(d);
- futureCal.add(Calendar.HOUR_OF_DAY, futureHours);
- Calendar pastCal = Calendar.getInstance(TimeZone
- .getTimeZone("GMT"));
- pastCal.setTime(d);
- pastCal.add(Calendar.HOUR_OF_DAY, pastHours * -1);
displayCanvas = new TimeSeriesDisplayCanvas(this,
- canvasComp, gd, pastCal.getTime(),
- futureCal.getTime(), groupInfo.isGroupSelected());
+ canvasComp, gd, beginDate,
+ endDate, groupInfo.isGroupSelected());
displayCanvas.setHorizontalSpan(gd.getXsize());
displayCanvas.setVerticalSpan(gd.getYsize());
displayCanvas.showGridLines(groupInfo.isGridLines());
diff --git a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDlg.java b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDlg.java
index c473e39c1c..9500bea336 100644
--- a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDlg.java
+++ b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDlg.java
@@ -111,6 +111,11 @@ import com.raytheon.viz.hydrocommon.util.StnClassSyncUtil;
* be ran as a standalone application
* without starting CAVE.
* 01 June 2011 9499 djingtao update openGraph()
+ * 23 Jul 2012 15180 mpduff Auto select the first group in the predefined group list
+ * 23 Jul 2012 15195 mpduff Fix Group graphing to use the date widgets.
+ * 08 Aug 2012 570 mpduff Fix a Ctrl-F in Station list causing IndexOutOfBounds error.
+ * 08 Aug 2012 657 mpduff Fix error when selecting a TS while no selection has been made
+ * in the Station List.
*
*
* @author lvenable
@@ -437,6 +442,9 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
/** Holds the Group Information */
private GroupInfo groupInfo;
+
+ /** Holds the last graphed GroupInfo object */
+ private GroupInfo prevGroupInfo;
/** Holds the page information */
private PageInfo pageInfo = null;
@@ -1156,10 +1164,12 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
tsOrderCbo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
- String line = topDataList.getItem(topDataList
- .getSelectionIndex());
- String selectedLid = line.substring(0, line.indexOf(" "));
- populateBottomList(selectedLid, tsOrderCbo.getSelectionIndex());
+ if (topDataList.getSelectionIndex() != -1) {
+ String line = topDataList.getItem(topDataList
+ .getSelectionIndex());
+ String selectedLid = line.substring(0, line.indexOf(" "));
+ populateBottomList(selectedLid, tsOrderCbo.getSelectionIndex());
+ }
}
});
tsOrderCbo.select(1);
@@ -1202,9 +1212,11 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
topDataList.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
- populateBottomList(
- lidList.get(topDataList.getSelectionIndex()),
- tsOrderCbo.getSelectionIndex());
+ if (topDataList.getSelectionIndex() != -1) {
+ populateBottomList(
+ lidList.get(topDataList.getSelectionIndex()),
+ tsOrderCbo.getSelectionIndex());
+ }
}
});
}
@@ -1365,6 +1377,20 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
endDayBtn.setText(String.valueOf(endCal.get(Calendar.DAY_OF_MONTH)));
endHourBtn.setText(String.valueOf(endCal.get(Calendar.HOUR_OF_DAY)));
}
+
+ private void updateTimeButtons() {
+ beginYearBtn.setText(String.valueOf(beginCal.get(Calendar.YEAR)));
+ beginMonthBtn.setText(String.valueOf(beginCal.get(Calendar.MONTH) + 1));
+ beginDayBtn
+ .setText(String.valueOf(beginCal.get(Calendar.DAY_OF_MONTH)));
+ beginHourBtn
+ .setText(String.valueOf(beginCal.get(Calendar.HOUR_OF_DAY)));
+
+ endYearBtn.setText(String.valueOf(endCal.get(Calendar.YEAR)));
+ endMonthBtn.setText(String.valueOf(endCal.get(Calendar.MONTH) + 1));
+ endDayBtn.setText(String.valueOf(endCal.get(Calendar.DAY_OF_MONTH)));
+ endHourBtn.setText(String.valueOf(endCal.get(Calendar.HOUR_OF_DAY)));
+ }
/**
* Populates the station list box.
@@ -1962,7 +1988,12 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
} else {
// TODO log error here, invalid value
System.err.println("Error in Group Definition Config file: " + line);
- }
+ }
+
+ // select the first item in the list
+ if (groupDataList.getItemCount() > 0) {
+ groupDataList.select(0);
+ }
}
/**
@@ -2225,32 +2256,26 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
GroupInfo groupInfo = groupList.get(groupDataList
.getSelectionIndex());
- int pastHours = groupInfo.getPastHours();
- int futureHours = groupInfo.getFutureHours();
-
-// long beginMillis = beginDate.getTime();
-// long endMillis = endDate.getTime();
-// long currentMillis = SimulatedTime.getSystemTime().getTime().getTime();
-//
-// long hoursBack = (currentMillis - beginMillis) / (1000*60*60);
-// long hoursAhead = (endMillis - currentMillis) / (1000*60*60);
-// groupInfo.setPastHours((int) hoursBack);
-// groupInfo.setFutureHours((int) hoursAhead);
- groupInfo.setPastHours(pastHours);
- groupInfo.setFutureHours(futureHours);
-
-// Calendar futureCal = Calendar.getInstance(TimeZone
-// .getTimeZone("GMT"));
-// Date d = SimulatedTime.getSystemTime().getTime();
-// futureCal.setTime(d);
-// futureCal.add(Calendar.HOUR_OF_DAY, futureHours);
-// Calendar pastCal = Calendar.getInstance(TimeZone
-// .getTimeZone("GMT"));
-// pastCal.setTime(d);
-// pastCal.add(Calendar.HOUR_OF_DAY, pastHours * -1);
-
-
+ if (prevGroupInfo == null || !prevGroupInfo.equals(groupInfo)) {
+ int pastHours = groupInfo.getPastHours();
+ int futureHours = groupInfo.getFutureHours();
+ beginCal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+ beginCal.add(Calendar.HOUR_OF_DAY, pastHours * -1);
+
+ endCal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+ endCal.add(Calendar.HOUR_OF_DAY, futureHours);
+
+ beginDate = beginCal.getTime();
+ endDate = endCal.getTime();
+
+ updateTimeButtons();
+
+ groupInfo.setPastHours(pastHours);
+ groupInfo.setFutureHours(futureHours);
+ }
timeSeriesDisplayDlg.setGroupInfo(groupInfo);
+
+ prevGroupInfo = groupInfo;
}
timeSeriesDisplayDlg.setBeginDate(beginDate);
timeSeriesDisplayDlg.setEndDate(endDate);
diff --git a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/graph/TimeSeriesGraphCanvas.java b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/graph/TimeSeriesGraphCanvas.java
index 7461fd3279..d2bc279daf 100644
--- a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/graph/TimeSeriesGraphCanvas.java
+++ b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/graph/TimeSeriesGraphCanvas.java
@@ -62,7 +62,8 @@ import com.raytheon.viz.hydrocommon.HydroConstants;
* Apr 18, 2011 8963 jpiatt Removed Left Scale call to scale manager.
* July 12 2011 9709 djingtao draw right Y axis for showPP is true. add new
* function adjust_pcymax()
- * Aug. 10, 2011 10457 djingtao allow the red rubberband box to be drawn for setMissing in Edit
+ * Aug. 10, 2011 10457 djingtao allow the red rubberband box to be drawn for setMissing in Edit
+ * Jul. 24, 2012 15195 mpduff Fix x axis scales.
*
*
*
@@ -492,7 +493,7 @@ public class TimeSeriesGraphCanvas extends Canvas {
}
// Check canvas width. if small then need to skip extra days
- if (this.canvasWidth < 600) {
+ if (this.canvasWidth < 500) {
daysSkip++;
}
@@ -537,8 +538,8 @@ public class TimeSeriesGraphCanvas extends Canvas {
/* ******************** */
/* Hour annotation */
/* ******************** */
- dy = 10;
- if (ndays < 4) {
+ dy = 10;
+ if (ndays < 8 && this.canvasWidth > 450) {
if (hour < 10) {
gc.drawText("0" + hour, x + leftBorder - dx, bottomBorder + 22);
} else {
diff --git a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/cresthistory/CrestHistoryCanvas.java b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/cresthistory/CrestHistoryCanvas.java
index 5179e342d3..c7bf0af623 100644
--- a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/cresthistory/CrestHistoryCanvas.java
+++ b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/cresthistory/CrestHistoryCanvas.java
@@ -63,684 +63,732 @@ import com.raytheon.viz.hydrocommon.HydroConstants;
* @version 1.0
*/
public class CrestHistoryCanvas extends Canvas {
- /**
- * Parent component.
- */
- private Composite parentComp;
-
- /**
- * Text font on the canvas.
- */
- private Font canvasFont;
-
- /**
- * Canvas width.
- */
- private final int CANVAS_WIDTH = 700;
-
- /**
- * Canvas height.
- */
- private final int CANVAS_HEIGHT = 520;
-
- /**
- * Y coordinate of the horizontal axis line.
- */
- private final int HLINE_YCOORD = CANVAS_HEIGHT - 40;
-
- /**
- * X coordinate of the vertical axis line.
- */
- private final int VLINE_XCOORD = 80;
-
- private final int HLINE_LEFT_OFFSET = 20;
-
- /**
- * Length of the horizontal axis line.
- */
- private final int HLINE_LENGTH = CANVAS_WIDTH - VLINE_XCOORD
- - HLINE_LEFT_OFFSET;
-
- /**
- * Length of the vertical axis line.
- */
- private final int VLINE_LENGTH = 450;
-
- /**
- * The number of pixels the vertical lines is from the top of the canvas.
- */
- private final int VLINE_PIXELS_FROM_TOP = CANVAS_HEIGHT - 40 - VLINE_LENGTH;
-
- /**
- * "STAGE IN FEET" text.
- */
- private final String STAGE_IN_FEET = "STAGE IN FEET";
-
- /**
- * Hash mark length.
- */
- private final int HASH_MARK = 10;
-
- /**
- * Small hash mark length.
- */
- private final int SMALL_HASH_MARK = 5;
-
- /**
- * Label Y coordinate offset.
- */
- private final int LABEL_Y_OFFSET = 15;
-
- /**
- * Label X coordinate offset.
- */
- private final int LABEL_X_OFFSET = 5;
-
- /**
- * Starting X coordinate for the year hash mark.
- */
- private final int YEAR_HASH_X_COORD_START = VLINE_XCOORD + 15;
-
- /**
- * Maximum stage value.
- */
- private double stageMaxVal = 0.0;
-
- /**
- * Minimum stage value.
- */
- private double stageMinVal = 0.0;
-
- /**
- * Number of MAJOR data items.
- */
- private int majorCount = 0;
-
- /**
- * Number of MODERATE data items.
- */
- private int modCount = 0;
-
- /**
- * Number of ACTION data items.
- */
- private int actionCount = 0;
-
- /**
- * Number of MINOR data items.
- */
- private int minorCount = 0;
-
- /**
- * Crest history data.
- */
- private CrestHistoryData crestHistoryData;
-
- /**
- * Map of the crest data (value) and the rectangle area on the canvas the
- * data occupies (key).
- */
- private HashMap crestDataMap;
-
- /**
- * Callback for selecting crest data.
- */
- private ISelectedCrestData selectCrestDataCB;
-
- /**
- * Constructor.
- *
- * @param parent
- * Parent composite.
- * @param crestHistoryData
- * Crest history data.
- * @param callback
- * Crest data selection callback.
- */
- public CrestHistoryCanvas(Composite parent,
- CrestHistoryData crestHistoryData, ISelectedCrestData callback) {
- super(parent, SWT.DOUBLE_BUFFERED);
-
- parentComp = parent;
- this.crestHistoryData = crestHistoryData;
- // work around for missing data
- if (crestHistoryData != null) {
- selectCrestDataCB = callback;
- stageMaxVal = crestHistoryData.getMaxStageLevel();
- stageMinVal = 0.0;
- } else {
- stageMaxVal = 0.0;
- stageMinVal = 0.0;
- }
- // another work around
- if ((crestHistoryData.getEndingYear() == 0)
- || (crestHistoryData.getStartingYear() == 0)) {
- Calendar cal = new GregorianCalendar();
- cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
- Date date = SimulatedTime.getSystemTime().getTime();
- cal.setTime(date);
- crestHistoryData.setStartingYear(1900);
- crestHistoryData.setEndingYear(cal.get(Calendar.YEAR));
- }
-
- init();
- }
-
- /**
- * Initialize method.
- */
- private void init() {
- if (crestHistoryData != null) {
- generateCrestDataMap();
- }
-
- canvasFont = new Font(parentComp.getDisplay(), "Monospace", 9,
- SWT.NORMAL);
-
- setupCanvas();
-
- addMouseListener(new MouseAdapter() {
- @Override
- public void mouseDown(MouseEvent e) {
- processMouseEvent(e);
- }
- });
- }
-
- /**
- * Regenerate the Crest history canvas
- *
- * @param crestHistoryData
- */
- public void updateCrestHistotryData(CrestHistoryData crestHistoryData) {
- this.crestHistoryData = crestHistoryData;
-
- if (crestHistoryData != null) {
- stageMaxVal = crestHistoryData.getMaxStageLevel();
- stageMinVal = 0.0;
- } else {
- stageMaxVal = 0.0;
- stageMinVal = 0.0;
- }
-
- generateCrestDataMap();
- redraw();
- }
-
- /**
- * Setup the drawing canvas.
- */
- private void setupCanvas() {
- GridData gd = new GridData(SWT.DEFAULT, SWT.TOP, false, true);
- gd.heightHint = CANVAS_HEIGHT;
- gd.widthHint = CANVAS_WIDTH;
-
- this.setSize(CANVAS_WIDTH, CANVAS_HEIGHT);
-
- setLayoutData(gd);
- addPaintListener(new PaintListener() {
- public void paintControl(PaintEvent e) {
- drawCrestHistory(e);
- }
- });
-
- addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- canvasFont.dispose();
- }
- });
- }
-
- /**
- * Draw the crest history data and the graph lines & labels on the canvas.
- *
- * @param e
- * Paint event.
- */
- private void drawCrestHistory(PaintEvent e) {
- e.gc.setFont(canvasFont);
- int fontHeightMid = (e.gc.getFontMetrics().getHeight() / 2);
- int fontHeight = (e.gc.getFontMetrics().getHeight());
-
- e.gc.setBackground(parentComp.getDisplay().getSystemColor(
- SWT.COLOR_BLACK));
-
- e.gc.fillRectangle(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
-
- e.gc.setForeground(parentComp.getDisplay().getSystemColor(
- SWT.COLOR_WHITE));
-
- // ----------------------------------------
- // Draw horizontal and vertical axis lines
- // ----------------------------------------
-
- e.gc.drawLine(VLINE_XCOORD, HLINE_YCOORD, VLINE_XCOORD, HLINE_YCOORD
- - VLINE_LENGTH);
-
- e.gc.drawLine(VLINE_XCOORD, HLINE_YCOORD, VLINE_XCOORD + HLINE_LENGTH,
- HLINE_YCOORD);
-
- // ------------------------------------------------
- // Draw STAGE IN FEET vertical label
- // ------------------------------------------------
- char[] charArray = STAGE_IN_FEET.toCharArray();
-
- int tmpY = 120;
- for (int i = 0; i < charArray.length; i++) {
- e.gc.drawString(String.valueOf(charArray[i]), 5, tmpY, true);
- tmpY += fontHeight;
- }
-
- if (crestHistoryData != null) {
- // ------------------------------------------------
- // Draw the years and the hash marks
- // ------------------------------------------------
- int startyear = crestHistoryData.getStartingYear();
- int endyear = crestHistoryData.getEndingYear();
- int years = (endyear - startyear);
- double pixelsPerIncX;
- if (years == 0) {
- pixelsPerIncX = 0;
- } else {
- pixelsPerIncX = HLINE_LENGTH / years;
- }
-
- int yearXcoord = VLINE_XCOORD;
- int yearHashXcoord = YEAR_HASH_X_COORD_START;
- DecimalFormat df = new DecimalFormat();
- df.setMinimumIntegerDigits(1);
- df.setMaximumFractionDigits(0);
- df.setGroupingUsed(false);
-
- for (int i = 0; i <= years; i++) {
- int inc = new Double(Math.rint(pixelsPerIncX * i)).intValue();
- yearXcoord = YEAR_HASH_X_COORD_START + inc - 15;
- yearHashXcoord = YEAR_HASH_X_COORD_START + inc;
- if (years < 75) {
- if (i % 5 == 0) {
- e.gc.drawString(df.format(startyear + i), yearXcoord,
- CANVAS_HEIGHT - fontHeight - 3, true);
- e.gc.drawLine(yearHashXcoord, HLINE_YCOORD, yearHashXcoord,
- HLINE_YCOORD + HASH_MARK);
- }
- } else {
- if (i % 10 == 0) {
- e.gc.drawString(df.format(startyear + i), yearXcoord,
- CANVAS_HEIGHT - fontHeight - 3, true);
- e.gc.drawLine(yearHashXcoord, HLINE_YCOORD, yearHashXcoord,
- HLINE_YCOORD + HASH_MARK);
- }
- }
- }
-
- // -----------------------------------------
- // Draw stage hash marks
- // -----------------------------------------
-
- double maxPixValue = VLINE_LENGTH + VLINE_PIXELS_FROM_TOP;
- double numHashsY = stageMaxVal;
- double pixelsPerIncY = VLINE_LENGTH / numHashsY;
-
- for (int x = 0; x <= stageMaxVal; ++x) {
- int yCoord = HLINE_YCOORD
- - new Double(Math.round(x * pixelsPerIncY)).intValue();
-
- if (x % 5 == 0) {
- // draw little hash
- e.gc.drawLine(VLINE_XCOORD, yCoord, VLINE_XCOORD
- - SMALL_HASH_MARK, yCoord);
-
- String recStr = String.format("%5.1f", new Float(x)
- .floatValue());
- e.gc.drawString(recStr, 35, yCoord - fontHeightMid, true);
- }
- }
-
- // -----------------------------------------
- // Draw MAJOR line and label
- // -----------------------------------------
-
- double majorLevel = crestHistoryData.getMajorLevel();
-
- e.gc.setForeground(parentComp.getDisplay().getSystemColor(
- SWT.COLOR_MAGENTA));
-
- int majorYCoord = (int) (maxPixValue - Math
- .round(((majorLevel - stageMinVal) * pixelsPerIncY)));
-
- e.gc.drawLine(VLINE_XCOORD + 1, majorYCoord, VLINE_XCOORD
- + HLINE_LENGTH, majorYCoord);
-
- String majorLabel = String.format("%5.1f MAJOR (%d)", majorLevel,
- majorCount);
- e.gc.drawString(majorLabel, VLINE_XCOORD + LABEL_X_OFFSET,
- majorYCoord - LABEL_Y_OFFSET, true);
-
- // -----------------------------------------
- // Draw MODERATE line and label
- // -----------------------------------------
-
- double moderateLevel = crestHistoryData.getModerateLevel();
-
- e.gc.setForeground(parentComp.getDisplay().getSystemColor(
- SWT.COLOR_BLUE));
-
- int modYCoord = (int) (maxPixValue - Math
- .round(((moderateLevel - stageMinVal) * pixelsPerIncY)));
-
- e.gc.drawLine(VLINE_XCOORD + 1, modYCoord, VLINE_XCOORD
- + HLINE_LENGTH, modYCoord);
-
- String modLabel = String.format("%5.1f MODERATE (%d)",
- moderateLevel, modCount);
- e.gc.drawString(modLabel, VLINE_XCOORD + LABEL_X_OFFSET, modYCoord
- - LABEL_Y_OFFSET, true);
-
- // -----------------------------------------
- // Draw MINOR line and label
- // -----------------------------------------
-
- double minorLevel = crestHistoryData.getMinorLevel();
-
- e.gc.setForeground(parentComp.getDisplay().getSystemColor(
- SWT.COLOR_RED));
-
- int minorYCoord = (int) (maxPixValue - Math
- .round(((minorLevel - stageMinVal) * pixelsPerIncY)));
-
- e.gc.drawLine(VLINE_XCOORD + 1, minorYCoord, VLINE_XCOORD
- + HLINE_LENGTH, minorYCoord);
-
- String minorLabel = String.format("%5.1f MINOR (%d)", minorLevel,
- minorCount);
- e.gc.drawString(minorLabel, VLINE_XCOORD + LABEL_X_OFFSET,
- minorYCoord - LABEL_Y_OFFSET, true);
-
- e.gc.drawString("FLOOD", VLINE_XCOORD + HLINE_LENGTH - 40,
- minorYCoord - LABEL_Y_OFFSET, true);
-
- // -----------------------------------------
- // Draw ACTION line and label
- // -----------------------------------------
-
- double actionLevel = crestHistoryData.getActionLevel();
-
- e.gc.setForeground(parentComp.getDisplay().getSystemColor(
- SWT.COLOR_YELLOW));
-
- int actionYCoord = (int) (maxPixValue - Math
- .round(((actionLevel - stageMinVal) * pixelsPerIncY)));
-
- e.gc.drawLine(VLINE_XCOORD + 1, actionYCoord, VLINE_XCOORD
- + HLINE_LENGTH, actionYCoord);
-
- String actionLabel = String.format("%5.1f ACTION (%d)",
- actionLevel, actionCount);
- e.gc.drawString(actionLabel, VLINE_XCOORD + LABEL_X_OFFSET,
- actionYCoord - LABEL_Y_OFFSET, true);
-
- // -------------------------------------------
- // Draw crest data
- // -------------------------------------------
-
- CrestDrawData drawData;
- Rectangle rec;
-
- Set keys = crestDataMap.keySet();
-
- for (Iterator iterator = keys.iterator(); iterator
- .hasNext();) {
- rec = iterator.next();
- drawData = crestDataMap.get(rec);
-
- if (drawData.getDrawData() == false) {
- continue;
- }
-
- if (drawData.isSelected() == true) {
- e.gc.setBackground(parentComp.getDisplay().getSystemColor(
- SWT.COLOR_WHITE));
- } else {
- e.gc.setBackground(drawData.getColor());
- }
-
- e.gc.fillRectangle(rec.x, rec.y, rec.width, rec.height);
- }
- }
- }
-
- /**
- * Generate the map of crest data (value) and the rectangle areas on the
- * canvas (key).
- */
- private void generateCrestDataMap() {
- crestDataMap = new HashMap();
- CrestDrawData drawData;
- Rectangle rec;
-
- int circleWidth = 8;
- int circleHeight = 8;
-
- double maxPixValue = VLINE_LENGTH + VLINE_PIXELS_FROM_TOP;
- double numHashs = crestHistoryData.getMaxStageLevel();
- double pixelsPerIncY = VLINE_LENGTH / numHashs;
- int startyear = crestHistoryData.getStartingYear();
- int endyear = crestHistoryData.getEndingYear();
- int years = endyear - startyear;
- int pixelsPerIncX;
- if (years == 0) {
- pixelsPerIncX = 0;
- } else {
- pixelsPerIncX = HLINE_LENGTH / years;
- }
-
- //Init the counts
- this.majorCount=0;
- this.minorCount=0;
- this.actionCount=0;
- this.modCount=0;
-
- for (CrestData crestData : crestHistoryData.getCrestDataArray()) {
-
- int yCoord = (int) (maxPixValue - Math
- .round((crestData.getStage() * pixelsPerIncY)));
-
- double yearXOffset = crestData.getYear() - startyear;
- int xCoord = YEAR_HASH_X_COORD_START
- + new Double(Math.round(yearXOffset * pixelsPerIncX))
- .intValue();
-
- rec = new Rectangle(xCoord - circleWidth / 2, yCoord - circleHeight
- / 2, circleWidth, circleHeight);
-
- drawData = new CrestDrawData(crestData.getStage(), crestData
- .getYear(), calculateDataColor(crestData.getStage()));
-
- crestDataMap.put(rec, drawData);
- }
- }
-
- /**
- * Calculate color of the crest data.
- *
- * @param stage
- * Stage (in feet).
- * @return The color associated with the data.
- */
- private Color calculateDataColor(double stage) {
- if ((stage > crestHistoryData.getMajorLevel()) &&
- (crestHistoryData.getMajorLevel() != HydroConstants.MISSING_VALUE)) {
- ++majorCount;
- return parentComp.getDisplay().getSystemColor(SWT.COLOR_MAGENTA);
- } else if ((stage > crestHistoryData.getModerateLevel()) &&
- (crestHistoryData.getModerateLevel() != HydroConstants.MISSING_VALUE)) {
- ++modCount;
- return parentComp.getDisplay().getSystemColor(SWT.COLOR_BLUE);
- } else if ((stage > crestHistoryData.getMinorLevel()) &&
- (crestHistoryData.getMinorLevel() != HydroConstants.MISSING_VALUE)) {
- ++minorCount;
- return parentComp.getDisplay().getSystemColor(SWT.COLOR_RED);
- } else if ((stage > crestHistoryData.getActionLevel()) &&
- (crestHistoryData.getActionLevel() != HydroConstants.MISSING_VALUE)) {
- ++actionCount;
- return parentComp.getDisplay().getSystemColor(SWT.COLOR_YELLOW);
- }
-
- return parentComp.getDisplay().getSystemColor(SWT.COLOR_GREEN);
- }
-
- /**
- * Select the crest data if the mouse click is in the data rectangle.
- *
- * @param e
- * Mouse event.
- */
- public void processMouseEvent(MouseEvent e) {
- Rectangle rec;
- Rectangle foundRec = null;
- Rectangle selectedRec = null;
-
- Set keys = crestDataMap.keySet();
-
- for (Iterator iterator = keys.iterator(); iterator.hasNext();) {
- rec = iterator.next();
-
- // Check if the mouse's x & y coords is in the rectangle area or on
- // the
- // edge of the rectangle
- if (recContains(e.x, e.y, rec)) {
- foundRec = rec;
- // crestDataMap.get(rec).setSelected(true);
- } else if (crestDataMap.get(rec).isSelected() == true) {
- selectedRec = rec;
- }
-
- if (foundRec != null) {
- crestDataMap.get(foundRec).setSelected(true);
-
- if (selectedRec != null) {
- crestDataMap.get(selectedRec).setSelected(false);
- }
-
- if (selectCrestDataCB != null) {
- selectCrestDataCB.crestDataSelected(crestDataMap.get(
- foundRec).getStage(), crestDataMap.get(foundRec)
- .getYear());
- }
- }
- }
- this.redraw();
- }
-
- /**
- * This method is used in place of the Rectangle.contains() method. The
- * contains method only checks if the x,y is inside the rectangle area. This
- * method accounts for the x,y being on the edges of the rectangle.
- *
- * @param x
- * Mouse's x coordinate.
- * @param y
- * Mouse's y coordinate.
- * @param rec
- * Rectangle the mouse coordinates will be checked against.
- * @return True if the mouse's x & y coordinates are in/on the rectangle.
- */
- private boolean recContains(int x, int y, Rectangle rec) {
- if ((x < rec.x) || (x > (rec.x + rec.width))) {
- return false;
- }
-
- if ((y < rec.y) || (y > (rec.y + rec.height))) {
- return false;
- }
-
- return true;
- }
-
- /**
- * Select the crest data based on the stage nad year passed in.
- *
- * @param stage
- * Stage in feet.
- * @param year
- * Year.
- */
- public void selectCrestData(double stage, int year) {
- Rectangle rec;
-
- Set keys = crestDataMap.keySet();
-
- for (Iterator iterator = keys.iterator(); iterator.hasNext();) {
- rec = iterator.next();
-
- crestDataMap.get(rec).setSelected(false);
-
- if ((crestDataMap.get(rec).getStage() == stage)
- && (crestDataMap.get(rec).getYear() == year)) {
- crestDataMap.get(rec).setSelected(true);
- }
- }
- this.redraw();
- }
-
- /**
- * Draw all of the crest data on the canvas.
- */
- public void drawAllCrestData() {
- Rectangle rec;
-
- Set keys = crestDataMap.keySet();
-
- for (Iterator iterator = keys.iterator(); iterator.hasNext();) {
- rec = iterator.next();
-
- crestDataMap.get(rec).setDrawData(true);
- }
-
- this.redraw();
- }
-
- /**
- * Draw only the crest data below the action stage.
- */
- public void drawDataBelowActionStage() {
- Rectangle rec;
-
- Set keys = crestDataMap.keySet();
-
- for (Iterator iterator = keys.iterator(); iterator.hasNext();) {
- rec = iterator.next();
-
- if (crestDataMap.get(rec).getStage() > crestHistoryData
- .getActionLevel()) {
- crestDataMap.get(rec).setDrawData(false);
- } else {
- crestDataMap.get(rec).setDrawData(true);
- }
- }
-
- this.redraw();
- }
-
- /**
- * Draw only the crest data above the action stage.
- */
- public void drawDataAboveActionStage() {
- Rectangle rec;
-
- Set keys = crestDataMap.keySet();
-
- for (Iterator iterator = keys.iterator(); iterator.hasNext();) {
- rec = iterator.next();
-
- if (crestDataMap.get(rec).getStage() < crestHistoryData
- .getActionLevel()) {
- crestDataMap.get(rec).setDrawData(false);
- } else {
- crestDataMap.get(rec).setDrawData(true);
- }
- }
-
- this.redraw();
- }
+ /**
+ * Parent component.
+ */
+ private Composite parentComp;
+
+ /**
+ * Text font on the canvas.
+ */
+ private Font canvasFont;
+
+ /**
+ * Canvas width.
+ */
+ private final int CANVAS_WIDTH = 700;
+
+ /**
+ * Canvas height.
+ */
+ private final int CANVAS_HEIGHT = 520;
+
+ /**
+ * Y coordinate of the horizontal axis line.
+ */
+ private final int HLINE_YCOORD = CANVAS_HEIGHT - 40;
+
+ /**
+ * X coordinate of the vertical axis line.
+ */
+ private final int VLINE_XCOORD = 80;
+
+ private final int HLINE_LEFT_OFFSET = 20;
+
+ /**
+ * Length of the horizontal axis line.
+ */
+ private final int HLINE_LENGTH = CANVAS_WIDTH - VLINE_XCOORD
+ - HLINE_LEFT_OFFSET;
+
+ /**
+ * Length of the vertical axis line.
+ */
+ private final int VLINE_LENGTH = 450;
+
+ /**
+ * The number of pixels the vertical lines is from the top of the canvas.
+ */
+ private final int VLINE_PIXELS_FROM_TOP = CANVAS_HEIGHT - 40 - VLINE_LENGTH;
+
+ /**
+ * "STAGE IN FEET" text.
+ */
+ private final String STAGE_IN_FEET = "STAGE IN FEET";
+
+ /**
+ * Hash mark length.
+ */
+ private final int HASH_MARK = 10;
+
+ /**
+ * Small hash mark length.
+ */
+ private final int SMALL_HASH_MARK = 5;
+
+ /**
+ * Label Y coordinate offset.
+ */
+ private final int LABEL_Y_OFFSET = 15;
+
+ /**
+ * Label X coordinate offset.
+ */
+ private final int LABEL_X_OFFSET = 5;
+
+ /**
+ * Starting X coordinate for the year hash mark.
+ */
+ private final int YEAR_HASH_X_COORD_START = VLINE_XCOORD + 15;
+
+ /**
+ * number of intervals on the y-axis
+ */
+ private final int NUM_VERTICAL_INTERVALS = 5;
+ /**
+ * Maximum stage value.
+ */
+ private double stageMaxVal = 0.0;
+
+ /**
+ * Minimum stage value.
+ */
+ private double stageMinVal = 0.0;
+
+ /**
+ * Number of MAJOR data items.
+ */
+ private int majorCount = 0;
+
+ /**
+ * Number of MODERATE data items.
+ */
+ private int modCount = 0;
+
+ /**
+ * Number of ACTION data items.
+ */
+ private int actionCount = 0;
+
+ /**
+ * Number of MINOR data items.
+ */
+ private int minorCount = 0;
+
+ /**
+ * Crest history data.
+ */
+ private CrestHistoryData crestHistoryData;
+
+ /**
+ * Map of the crest data (value) and the rectangle area on the canvas the
+ * data occupies (key).
+ */
+ private HashMap crestDataMap;
+
+ /**
+ * Callback for selecting crest data.
+ */
+ private ISelectedCrestData selectCrestDataCB;
+
+ /**
+ * Constructor.
+ *
+ * @param parent
+ * Parent composite.
+ * @param crestHistoryData
+ * Crest history data.
+ * @param callback
+ * Crest data selection callback.
+ */
+ public CrestHistoryCanvas(Composite parent,
+ CrestHistoryData crestHistoryData, ISelectedCrestData callback) {
+ super(parent, SWT.DOUBLE_BUFFERED);
+
+ parentComp = parent;
+ this.crestHistoryData = crestHistoryData;
+ // work around for missing data
+ if (crestHistoryData != null) {
+ selectCrestDataCB = callback;
+ stageMaxVal = crestHistoryData.getMaxStageLevel();
+ stageMinVal = crestHistoryData.getMinStageLevel();
+ } else {
+ stageMaxVal = 0.0;
+ stageMinVal = 0.0;
+ }
+ setYAxisMaxMin();
+ // another work around
+ if ((crestHistoryData.getEndingYear() == 0)
+ || (crestHistoryData.getStartingYear() == 0)) {
+ Calendar cal = new GregorianCalendar();
+ cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+ Date date = SimulatedTime.getSystemTime().getTime();
+ cal.setTime(date);
+ crestHistoryData.setStartingYear(1900);
+ crestHistoryData.setEndingYear(cal.get(Calendar.YEAR));
+ }
+
+ init();
+ }
+
+ /**
+ * Initialize method.
+ */
+ private void init() {
+ if (crestHistoryData != null) {
+ generateCrestDataMap();
+ }
+
+ canvasFont = new Font(parentComp.getDisplay(), "Monospace", 9,
+ SWT.NORMAL);
+
+ setupCanvas();
+
+ addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseDown(MouseEvent e) {
+ processMouseEvent(e);
+ }
+ });
+ }
+
+ /**
+ * Regenerate the Crest history canvas
+ *
+ * @param crestHistoryData
+ */
+ public void updateCrestHistotryData(CrestHistoryData crestHistoryData) {
+ this.crestHistoryData = crestHistoryData;
+
+ if (crestHistoryData != null) {
+ stageMaxVal = crestHistoryData.getMaxStageLevel();
+ stageMinVal = crestHistoryData.getMinStageLevel();
+ } else {
+ stageMaxVal = 0.0;
+ stageMinVal = 0.0;
+ }
+
+ setYAxisMaxMin();
+ generateCrestDataMap();
+ redraw();
+ }
+
+ /**
+ * Setup the drawing canvas.
+ */
+ private void setupCanvas() {
+ GridData gd = new GridData(SWT.DEFAULT, SWT.TOP, false, true);
+ gd.heightHint = CANVAS_HEIGHT;
+ gd.widthHint = CANVAS_WIDTH;
+
+ this.setSize(CANVAS_WIDTH, CANVAS_HEIGHT);
+
+ setLayoutData(gd);
+ addPaintListener(new PaintListener() {
+ public void paintControl(PaintEvent e) {
+ drawCrestHistory(e);
+ }
+ });
+
+ addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ canvasFont.dispose();
+ }
+ });
+ }
+
+ /**
+ * Calculate for the max. and min. Y axis value
+ */
+ private void setYAxisMaxMin() {
+ int roundFactor = 5;
+ long lmax, lmin;
+
+ /*
+ * Round min down. If the original min data > 0, then don't round below
+ * 0.
+ */
+ lmin = (long) (stageMinVal / roundFactor);
+
+ if (lmin >= 0) {
+ stageMinVal = (lmin - 1) * roundFactor;
+ if (stageMinVal < 0)
+ stageMinVal = 0;
+ } else /* lmin < 0 */
+ {
+ stageMinVal = (lmin - 1) * roundFactor;
+ }
+
+ /*
+ * Round max up.
+ */
+ lmax = (long) (stageMaxVal / roundFactor);
+
+ /*
+ * If the difference between max_y and min_y < 10, round max_y up again.
+ */
+ if ((stageMaxVal - stageMaxVal) < 10) {
+ stageMaxVal = (lmax + 2) * roundFactor;
+ }
+
+ if (stageMinVal < 0) {
+ stageMinVal=0;
+ }
+
+ }
+
+ /**
+ * Draw the crest history data and the graph lines & labels on the canvas.
+ *
+ * @param e
+ * Paint event.
+ */
+ private void drawCrestHistory(PaintEvent e) {
+ e.gc.setFont(canvasFont);
+ int fontHeightMid = (e.gc.getFontMetrics().getHeight() / 2);
+ int fontHeight = (e.gc.getFontMetrics().getHeight());
+
+ e.gc.setBackground(parentComp.getDisplay().getSystemColor(
+ SWT.COLOR_BLACK));
+
+ e.gc.fillRectangle(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
+
+ e.gc.setForeground(parentComp.getDisplay().getSystemColor(
+ SWT.COLOR_WHITE));
+
+ // ----------------------------------------
+ // Draw horizontal and vertical axis lines
+ // ----------------------------------------
+
+ e.gc.drawLine(VLINE_XCOORD, HLINE_YCOORD, VLINE_XCOORD, HLINE_YCOORD
+ - VLINE_LENGTH);
+
+ e.gc.drawLine(VLINE_XCOORD, HLINE_YCOORD, VLINE_XCOORD + HLINE_LENGTH,
+ HLINE_YCOORD);
+
+ // ------------------------------------------------
+ // Draw STAGE IN FEET vertical label
+ // ------------------------------------------------
+ char[] charArray = STAGE_IN_FEET.toCharArray();
+
+ int tmpY = 120;
+ for (int i = 0; i < charArray.length; i++) {
+ e.gc.drawString(String.valueOf(charArray[i]), 5, tmpY, true);
+ tmpY += fontHeight;
+ }
+
+ if (crestHistoryData != null) {
+ // ------------------------------------------------
+ // Draw the years and the hash marks
+ // ------------------------------------------------
+ int startyear = crestHistoryData.getStartingYear();
+ int endyear = crestHistoryData.getEndingYear();
+ int years = (endyear - startyear);
+ double pixelsPerIncX;
+ if (years == 0) {
+ pixelsPerIncX = 0;
+ } else {
+ pixelsPerIncX = HLINE_LENGTH / years;
+ }
+
+ int yearXcoord = VLINE_XCOORD;
+ int yearHashXcoord = YEAR_HASH_X_COORD_START;
+ DecimalFormat df = new DecimalFormat();
+ df.setMinimumIntegerDigits(1);
+ df.setMaximumFractionDigits(0);
+ df.setGroupingUsed(false);
+
+ for (int i = 0; i <= years; i++) {
+ int inc = new Double(Math.rint(pixelsPerIncX * i)).intValue();
+ yearXcoord = YEAR_HASH_X_COORD_START + inc - 15;
+ yearHashXcoord = YEAR_HASH_X_COORD_START + inc;
+ if (years < 75) {
+ if (i % 5 == 0) {
+ e.gc.drawString(df.format(startyear + i), yearXcoord,
+ CANVAS_HEIGHT - fontHeight - 3, true);
+ e.gc.drawLine(yearHashXcoord, HLINE_YCOORD,
+ yearHashXcoord, HLINE_YCOORD + HASH_MARK);
+ }
+ } else {
+ if (i % 10 == 0) {
+ e.gc.drawString(df.format(startyear + i), yearXcoord,
+ CANVAS_HEIGHT - fontHeight - 3, true);
+ e.gc.drawLine(yearHashXcoord, HLINE_YCOORD,
+ yearHashXcoord, HLINE_YCOORD + HASH_MARK);
+ }
+ }
+ }
+
+ // -----------------------------------------
+ // Draw stage hash marks
+ // -----------------------------------------
+
+ double maxPixValue = VLINE_LENGTH + VLINE_PIXELS_FROM_TOP;
+ double numHashsY = stageMaxVal - stageMinVal;
+ double valInc = (stageMaxVal - stageMinVal)
+ / NUM_VERTICAL_INTERVALS;
+
+ double pixelsPerIncY = VLINE_LENGTH / numHashsY;
+
+ for (int x = (int) (stageMinVal); x <= stageMaxVal; x += valInc) {
+ int yCoord = HLINE_YCOORD
+ - new Double(Math.round((x - stageMinVal)
+ * pixelsPerIncY)).intValue();
+
+ e.gc.drawLine(VLINE_XCOORD, yCoord, VLINE_XCOORD
+ - SMALL_HASH_MARK, yCoord);
+
+ String recStr = String.format("%5.1f",
+ new Float(x).floatValue());
+ e.gc.drawString(recStr, 35, yCoord - fontHeightMid, true);
+ }
+
+ // -----------------------------------------
+ // Draw MAJOR line and label
+ // -----------------------------------------
+
+ double majorLevel = crestHistoryData.getMajorLevel();
+
+ e.gc.setForeground(parentComp.getDisplay().getSystemColor(
+ SWT.COLOR_MAGENTA));
+
+ int majorYCoord = (int) (maxPixValue - Math
+ .round(((majorLevel - stageMinVal) * pixelsPerIncY)));
+
+ e.gc.drawLine(VLINE_XCOORD + 1, majorYCoord, VLINE_XCOORD
+ + HLINE_LENGTH, majorYCoord);
+
+ String majorLabel = String.format("%5.1f MAJOR (%d)", majorLevel,
+ majorCount);
+ e.gc.drawString(majorLabel, VLINE_XCOORD + LABEL_X_OFFSET,
+ majorYCoord - LABEL_Y_OFFSET, true);
+
+ // -----------------------------------------
+ // Draw MODERATE line and label
+ // -----------------------------------------
+
+ double moderateLevel = crestHistoryData.getModerateLevel();
+
+ e.gc.setForeground(parentComp.getDisplay().getSystemColor(
+ SWT.COLOR_BLUE));
+
+ int modYCoord = (int) (maxPixValue - Math
+ .round(((moderateLevel - stageMinVal) * pixelsPerIncY)));
+
+ e.gc.drawLine(VLINE_XCOORD + 1, modYCoord, VLINE_XCOORD
+ + HLINE_LENGTH, modYCoord);
+
+ String modLabel = String.format("%5.1f MODERATE (%d)",
+ moderateLevel, modCount);
+ e.gc.drawString(modLabel, VLINE_XCOORD + LABEL_X_OFFSET, modYCoord
+ - LABEL_Y_OFFSET, true);
+
+ // -----------------------------------------
+ // Draw MINOR line and label
+ // -----------------------------------------
+
+ double minorLevel = crestHistoryData.getMinorLevel();
+
+ e.gc.setForeground(parentComp.getDisplay().getSystemColor(
+ SWT.COLOR_RED));
+
+ int minorYCoord = (int) (maxPixValue - Math
+ .round(((minorLevel - stageMinVal) * pixelsPerIncY)));
+
+ e.gc.drawLine(VLINE_XCOORD + 1, minorYCoord, VLINE_XCOORD
+ + HLINE_LENGTH, minorYCoord);
+
+ String minorLabel = String.format("%5.1f MINOR (%d)", minorLevel,
+ minorCount);
+ e.gc.drawString(minorLabel, VLINE_XCOORD + LABEL_X_OFFSET,
+ minorYCoord - LABEL_Y_OFFSET, true);
+
+ e.gc.drawString("FLOOD", VLINE_XCOORD + HLINE_LENGTH - 40,
+ minorYCoord - LABEL_Y_OFFSET, true);
+
+ // -----------------------------------------
+ // Draw ACTION line and label
+ // -----------------------------------------
+
+ double actionLevel = crestHistoryData.getActionLevel();
+
+ e.gc.setForeground(parentComp.getDisplay().getSystemColor(
+ SWT.COLOR_YELLOW));
+
+ int actionYCoord = (int) (maxPixValue - Math
+ .round(((actionLevel - stageMinVal) * pixelsPerIncY)));
+
+ e.gc.drawLine(VLINE_XCOORD + 1, actionYCoord, VLINE_XCOORD
+ + HLINE_LENGTH, actionYCoord);
+
+ String actionLabel = String.format("%5.1f ACTION (%d)",
+ actionLevel, actionCount);
+ e.gc.drawString(actionLabel, VLINE_XCOORD + LABEL_X_OFFSET,
+ actionYCoord - LABEL_Y_OFFSET, true);
+
+ // -------------------------------------------
+ // Draw crest data
+ // -------------------------------------------
+
+ CrestDrawData drawData;
+ Rectangle rec;
+
+ Set keys = crestDataMap.keySet();
+
+ for (Iterator iterator = keys.iterator(); iterator
+ .hasNext();) {
+ rec = iterator.next();
+ drawData = crestDataMap.get(rec);
+
+ if (drawData.getDrawData() == false) {
+ continue;
+ }
+
+ if (drawData.isSelected() == true) {
+ e.gc.setBackground(parentComp.getDisplay().getSystemColor(
+ SWT.COLOR_WHITE));
+ } else {
+ e.gc.setBackground(drawData.getColor());
+ }
+
+ e.gc.fillRectangle(rec.x, rec.y, rec.width, rec.height);
+ }
+ }
+ }
+
+ /**
+ * Generate the map of crest data (value) and the rectangle areas on the
+ * canvas (key).
+ */
+ private void generateCrestDataMap() {
+ crestDataMap = new HashMap();
+ CrestDrawData drawData;
+ Rectangle rec;
+
+ int circleWidth = 8;
+ int circleHeight = 8;
+
+ double maxPixValue = VLINE_LENGTH + VLINE_PIXELS_FROM_TOP;
+ double numHashs = stageMaxVal - stageMinVal;
+ double pixelsPerIncY = VLINE_LENGTH / numHashs;
+ int startyear = crestHistoryData.getStartingYear();
+ int endyear = crestHistoryData.getEndingYear();
+ int years = endyear - startyear;
+ int pixelsPerIncX;
+ if (years == 0) {
+ pixelsPerIncX = 0;
+ } else {
+ pixelsPerIncX = HLINE_LENGTH / years;
+ }
+
+ // Init the counts
+ this.majorCount = 0;
+ this.minorCount = 0;
+ this.actionCount = 0;
+ this.modCount = 0;
+
+ for (CrestData crestData : crestHistoryData.getCrestDataArray()) {
+
+ int yCoord = (int) (maxPixValue - Math
+ .round(((crestData.getStage() - stageMinVal) * pixelsPerIncY)));
+
+ double yearXOffset = crestData.getYear() - startyear;
+ int xCoord = YEAR_HASH_X_COORD_START
+ + new Double(Math.round(yearXOffset * pixelsPerIncX))
+ .intValue();
+
+ rec = new Rectangle(xCoord - circleWidth / 2, yCoord - circleHeight
+ / 2, circleWidth, circleHeight);
+
+ drawData = new CrestDrawData(crestData.getStage(),
+ crestData.getYear(),
+ calculateDataColor(crestData.getStage()));
+
+ crestDataMap.put(rec, drawData);
+ }
+ }
+
+ /**
+ * Calculate color of the crest data.
+ *
+ * @param stage
+ * Stage (in feet).
+ * @return The color associated with the data.
+ */
+ private Color calculateDataColor(double stage) {
+ if ((stage > crestHistoryData.getMajorLevel())
+ && (crestHistoryData.getMajorLevel() != HydroConstants.MISSING_VALUE)) {
+ ++majorCount;
+ return parentComp.getDisplay().getSystemColor(SWT.COLOR_MAGENTA);
+ } else if ((stage > crestHistoryData.getModerateLevel())
+ && (crestHistoryData.getModerateLevel() != HydroConstants.MISSING_VALUE)) {
+ ++modCount;
+ return parentComp.getDisplay().getSystemColor(SWT.COLOR_BLUE);
+ } else if ((stage > crestHistoryData.getMinorLevel())
+ && (crestHistoryData.getMinorLevel() != HydroConstants.MISSING_VALUE)) {
+ ++minorCount;
+ return parentComp.getDisplay().getSystemColor(SWT.COLOR_RED);
+ } else if ((stage > crestHistoryData.getActionLevel())
+ && (crestHistoryData.getActionLevel() != HydroConstants.MISSING_VALUE)) {
+ ++actionCount;
+ return parentComp.getDisplay().getSystemColor(SWT.COLOR_YELLOW);
+ }
+
+ return parentComp.getDisplay().getSystemColor(SWT.COLOR_GREEN);
+ }
+
+ /**
+ * Select the crest data if the mouse click is in the data rectangle.
+ *
+ * @param e
+ * Mouse event.
+ */
+ public void processMouseEvent(MouseEvent e) {
+ Rectangle rec;
+ Rectangle foundRec = null;
+ Rectangle selectedRec = null;
+
+ Set keys = crestDataMap.keySet();
+
+ for (Iterator iterator = keys.iterator(); iterator.hasNext();) {
+ rec = iterator.next();
+
+ // Check if the mouse's x & y coords is in the rectangle area or on
+ // the
+ // edge of the rectangle
+ if (recContains(e.x, e.y, rec)) {
+ foundRec = rec;
+ // crestDataMap.get(rec).setSelected(true);
+ } else if (crestDataMap.get(rec).isSelected() == true) {
+ selectedRec = rec;
+ }
+
+ if (foundRec != null) {
+ crestDataMap.get(foundRec).setSelected(true);
+
+ if (selectedRec != null) {
+ crestDataMap.get(selectedRec).setSelected(false);
+ }
+
+ if (selectCrestDataCB != null) {
+ selectCrestDataCB.crestDataSelected(
+ crestDataMap.get(foundRec).getStage(), crestDataMap
+ .get(foundRec).getYear());
+ }
+ }
+ }
+ this.redraw();
+ }
+
+ /**
+ * This method is used in place of the Rectangle.contains() method. The
+ * contains method only checks if the x,y is inside the rectangle area. This
+ * method accounts for the x,y being on the edges of the rectangle.
+ *
+ * @param x
+ * Mouse's x coordinate.
+ * @param y
+ * Mouse's y coordinate.
+ * @param rec
+ * Rectangle the mouse coordinates will be checked against.
+ * @return True if the mouse's x & y coordinates are in/on the rectangle.
+ */
+ private boolean recContains(int x, int y, Rectangle rec) {
+ if ((x < rec.x) || (x > (rec.x + rec.width))) {
+ return false;
+ }
+
+ if ((y < rec.y) || (y > (rec.y + rec.height))) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Select the crest data based on the stage nad year passed in.
+ *
+ * @param stage
+ * Stage in feet.
+ * @param year
+ * Year.
+ */
+ public void selectCrestData(double stage, int year) {
+ Rectangle rec;
+
+ Set keys = crestDataMap.keySet();
+
+ for (Iterator iterator = keys.iterator(); iterator.hasNext();) {
+ rec = iterator.next();
+
+ crestDataMap.get(rec).setSelected(false);
+
+ if ((crestDataMap.get(rec).getStage() == stage)
+ && (crestDataMap.get(rec).getYear() == year)) {
+ crestDataMap.get(rec).setSelected(true);
+ }
+ }
+ this.redraw();
+ }
+
+ /**
+ * Draw all of the crest data on the canvas.
+ */
+ public void drawAllCrestData() {
+ Rectangle rec;
+
+ Set keys = crestDataMap.keySet();
+
+ for (Iterator iterator = keys.iterator(); iterator.hasNext();) {
+ rec = iterator.next();
+
+ crestDataMap.get(rec).setDrawData(true);
+ }
+
+ this.redraw();
+ }
+
+ /**
+ * Draw only the crest data below the action stage.
+ */
+ public void drawDataBelowActionStage() {
+ Rectangle rec;
+
+ Set keys = crestDataMap.keySet();
+
+ for (Iterator iterator = keys.iterator(); iterator.hasNext();) {
+ rec = iterator.next();
+
+ if (crestDataMap.get(rec).getStage() > crestHistoryData
+ .getActionLevel()) {
+ crestDataMap.get(rec).setDrawData(false);
+ } else {
+ crestDataMap.get(rec).setDrawData(true);
+ }
+ }
+
+ this.redraw();
+ }
+
+ /**
+ * Draw only the crest data above the action stage.
+ */
+ public void drawDataAboveActionStage() {
+ Rectangle rec;
+
+ Set keys = crestDataMap.keySet();
+
+ for (Iterator iterator = keys.iterator(); iterator.hasNext();) {
+ rec = iterator.next();
+
+ if (crestDataMap.get(rec).getStage() < crestHistoryData
+ .getActionLevel()) {
+ crestDataMap.get(rec).setDrawData(false);
+ } else {
+ crestDataMap.get(rec).setDrawData(true);
+ }
+ }
+
+ this.redraw();
+ }
}
diff --git a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/RiverDataManager.java b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/RiverDataManager.java
index 64d9492796..691aa82a6f 100644
--- a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/RiverDataManager.java
+++ b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/datamanager/RiverDataManager.java
@@ -66,683 +66,679 @@ import com.raytheon.viz.hydrocommon.data.RiverDataPoint;
public class RiverDataManager {
- /** Singleton instance of this class */
- private static RiverDataManager riverManager = null;
-
- /* Private Constructor */
- private RiverDataManager() {
- }
-
- /**
- * Get an instance of this singleton.
- *
- * @return Instance of this class
- */
- public static synchronized RiverDataManager getInstance() {
- if (riverManager == null) {
- riverManager = new RiverDataManager();
- }
- return riverManager;
- }
-
- private static final transient IUFStatusHandler statusHandler = UFStatus
- .getHandler(RiverDataManager.class);
-
- private LinkedHashMap crestData = null;
-
- private LinkedHashMap> riverData = null;
-
- private static String locationQuery = "SELECT name, county, state, elev, hsa, lat, lon, rb from location WHERE lid =";
-
- private static String riverStatQuery = "SELECT stream, mile, zd, tide, bf, wstg, fs, fq, action_flow, primary_pe FROM riverstat WHERE lid =";
-
- private static String descriptionQuery = "SELECT proximity, reach FROM descrip WHERE lid =";
-
- private static String crestQuery = "select stage, q, datcrst, timcrst, cremark, hw, jam, olddatum, suppress, prelim from crest where lid = '";
-
- private static String floodCatQuery = "SELECT minor_stage, moderate_stage, major_stage, minor_flow, moderate_flow, major_flow from floodcat WHERE lid = ";
-
- private static String riverInfoQuery = "SELECT rivermonlocation.group_id, rivermongroup.group_name FROM rivermongroup, rivermonlocation WHERE rivermongroup.group_id = rivermonlocation.group_id AND rivermonlocation.lid = ";
-
- private static String riverPointQuery = "SELECT l.lid, l.name, l.county, l.state, l.elev, l.hsa, l.lat, l.lon, "
- + "rml.group_id, "
- + "rmg.group_name, "
- + "r.stream, r.mile, r.zd AS zero, r.tide, r.bf AS bankfull, r.wstg AS action_stage, r.fs AS flood_stage, r.fq AS flood_flow, r.action_flow, r.primary_pe, "
- + "d.proximity, d.reach, "
- + "f.minor_stage AS minor, f.moderate_stage AS moderate, f.major_stage AS major, f.minor_flow AS minor, f.moderate_flow AS moderate, f.major_flow AS major "
- + "FROM location l "
- + "LEFT JOIN floodcat f ON l.lid::text = f.lid::text "
- + "LEFT JOIN descrip d ON l.lid::text = d.lid::text, riverstat r, rivermonlocation rml "
- + "LEFT JOIN rivermongroup rmg ON rml.group_id::text = rmg.group_id::text "
- + "WHERE l.lid::text = r.lid::text and r.lid::text = rml.lid::text "
- + "ORDER BY rml.group_id, r.mile desc";
-
- private static String riverObsvalueQueryFront = "SELECT distinct(foo.lid), foo.value, foo.maxtime from "
- + "(SELECT distinct height.lid, height.value, max(height.obstime) as maxtime "
- + "FROM height "
- + "WHERE height.lid in "
- + "(select distinct(lid) "
- + "from rivermonlocation "
- + "where rivermonlocation.group_id = ";
-
- private static String riverObsvalueQueryBack = ") GROUP BY height.lid, height.value) "
- + "AS foo "
- + "GROUP BY foo.lid, foo.value, foo.maxtime order by foo.lid, foo.maxtime desc";
-
- private static String riverFcstvalueQueryFront = "SELECT distinct(foo.lid), foo.value, foo.maxtime from "
- + "(SELECT distinct fcstheight.lid, fcstheight.value, max(fcstheight.validtime) as maxtime "
- + "FROM fcstheight "
- + "WHERE fcstheight.lid in "
- + "(select distinct(lid) "
- + "from rivermonlocation "
- + "where rivermonlocation.group_id = ";
-
- private static String riverFcstvalueQueryBack = ") GROUP BY fcstheight.lid, fcstheight.value) "
- + "AS foo "
- + "GROUP BY foo.lid, foo.value, foo.maxtime order by foo.lid, foo.maxtime desc";
-
- private static String riverIDQuery = "SELECT group_id FROM rivermonlocation where lid =";
-
- /**
- * River Query Crest
- *
- * @param lid
- * @return CrestHistoryData
- */
- public CrestHistoryData getRiverCrests(RiverDataPoint rdp, int allFlag) {
- CrestHistoryData crests = null;
-
- if (crestData == null) {
- crestData = new LinkedHashMap();
- }
-
- crests = new CrestHistoryData();
- String query = null;
-
- /* get crest data depending on action stage */
- if (rdp != null) {
- String sql = "select stage, q, datcrst, timcrst, cremark, hw, jam, olddatum, suppress, prelim "
- + "from crest where lid = '" + rdp.getLid();
-
- if (allFlag == 1) {
- query = sql + "' and stage >'" + rdp.getActionStage()
- + "' ORDER BY stage, q";
- } else if (allFlag == 2) {
- query = sql + "' and stage <'" + rdp.getActionStage()
- + "' ORDER BY stage, q";
- } else {
- query = sql + "' ORDER BY stage, q";
- }
-
- ArrayList objects = null;
-
- try {
- objects = (ArrayList) DirectDbQuery.executeQuery(
- query, HydroConstants.IHFS, QueryLanguage.SQL);
- if (objects != null) {
- for (Object[] crestob : objects) {
- crests.addCrestData(new CrestData(crestob));
- }
- }
- } catch (Exception e) {
- statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
- e);
- }
- }
-
- if (crests.getCrestDataArray().size() > 0) {
- // max stage level, default sort mode
- // There is a problem when the stage is not set in the db.
- // Added this work around here to manually find the max stage value
- double maxStag = 0;
- for (int i = 0; i < crests.getCrestDataArray().size(); i++) {
- if (crests.getCrestDataArray().get(i).getStage() > maxStag) {
- maxStag = crests.getCrestDataArray().get(i).getStage();
- }
- }
- crests.setMaxStageLevel(maxStag);
-
- // set the values to gage by
- crests.setActionLevel(rdp.getActionStage());
- crests.setMajorLevel(rdp.getMajorStage());
- crests.setMinorLevel(rdp.getMinorStage());
- crests.setModerateLevel(rdp.getModerateStage());
-
- // we assume a top of zero at all times, find oldest record
- crests.sortByDate();
- CrestData cd5 = crests.getCrestDataArray().get(
- crests.getCrestDataArray().size() - 1);
-
- Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
- Date now = SimulatedTime.getSystemTime().getTime();
- cal.setTime(now);
-
- if (cd5.getCrestDate() != null) {
- crests.setStartingYear(cd5.getCrestDate().get(Calendar.YEAR));
- } else {
- crests.setStartingYear(HydroConstants.DEFAULT_YEAR);
- }
- crests.setEndingYear(cal.get(Calendar.YEAR));
-
- crests.sortByStage();
-
- crestData.put(rdp.getLid(), crests);
- }
-
- return crests;
- }
-
- /**
- * Gets the crest data for just the record flood, flow
- *
- * @param rdp
- * @return
- */
- public RiverDataPoint getRiverCrest(RiverDataPoint rdp) {
- Date date = SimulatedTime.getSystemTime().getTime();
- int allFlag = 0;
- CrestHistoryData crests = getRiverCrests(rdp, allFlag);
- ArrayList temp = crests.getCrestDataArray();
- if (temp.size() > 0) {
- // maximum stage value
- crests.sortByStage();
- CrestData cd = temp.get(0);
- rdp.setCrestValue(cd.getStage());
-
- // maximum flow (q) value for max stage value
- rdp.setCrestFlow(cd.getFlow());
-
- // Stage Crest date
- rdp.setCrestTime(cd.getCrestDate());
-
- } else {
- // maximum stage value
- rdp.setCrestValue(HydroConstants.MISSING_VALUE);
-
- // maximum flow value
- rdp.setCrestFlow(HydroConstants.MISSING_VALUE);
-
- // sort by date
- Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
- cal.setTime(date);
- rdp.setCrestTime(cal);
- }
-
- return rdp;
- }
-
- /**
- * data structure to house the river water shed data
- *
- * @return HashMap>
- */
- public LinkedHashMap> getRiverSummaryData() {
- ArrayList data = null;
-
- try {
- data = (ArrayList) DirectDbQuery.executeQuery(
- riverPointQuery, HydroConstants.IHFS, QueryLanguage.SQL);
- if (data != null) {
- riverData = new LinkedHashMap>();
- String riverID = null;
- LinkedHashMap riverPoints = null;
- for (Object[] point : data) {
- RiverDataPoint rdp = new RiverDataPoint(point);
- // start
- if (riverID == null) {
- riverID = rdp.getRiverID();
- riverPoints = new LinkedHashMap();
- riverPoints.put(rdp.getLid(), rdp);
- }
- // new river switch
- else if (!rdp.getRiverID().equals(riverID)) {
- // sock away the old one
- riverData.put(riverID, riverPoints);
- // rename Name
- riverID = rdp.getRiverID();
- // create new
- riverPoints = new LinkedHashMap();
- riverPoints.put(rdp.getLid(), rdp);
- }
- // in river run
- else {
- riverPoints.put(rdp.getLid(), rdp);
- }
- }
- // take care of last river
- riverData.put(riverID, riverPoints);
- }
- } catch (VizException e) {
- statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
- e);
- }
-
- return riverData;
- }
-
- /**
- * Populate the Data for time and point obs and fcst, really not pretty
- * avert your eyes.
- *
- * @param riverPoints
- * @param riverID
- * @return HashMap
- */
- public LinkedHashMap populateRiverData(
- String riverID, LinkedHashMap riverPoints) {
-
- ArrayList obsdata = null;
- ArrayList fcstdata = null;
-
- try {
- String obsquery = riverObsvalueQueryFront + "'" + riverID + "'"
- + riverObsvalueQueryBack;
- String fcstquery = riverFcstvalueQueryFront + "'" + riverID + "'"
- + riverFcstvalueQueryBack;
- obsdata = (ArrayList) DirectDbQuery.executeQuery(
- obsquery, HydroConstants.IHFS, QueryLanguage.SQL);
- fcstdata = (ArrayList) DirectDbQuery.executeQuery(
- fcstquery, HydroConstants.IHFS, QueryLanguage.SQL);
- if (obsdata != null) {
- String lid = null;
- Calendar obstime = null;
-
- for (Object[] obspoint : obsdata) {
- if (obspoint[0] != null) {
- String newlid = (String) obspoint[0];
- // into
- if (!newlid.equals(lid) || (lid == null)) {
- lid = newlid;
- // we care about this data
- if (obspoint[1] != null) {
- riverPoints.get(lid).setObsValue(
- (Double) obspoint[1]);
- }
- if (obspoint[2] != null) {
- obstime = Calendar.getInstance(TimeZone
- .getTimeZone("GMT"));
- obstime.setTimeInMillis(((Timestamp) obspoint[2])
- .getTime());
- riverPoints.get(lid).setObsTime(obstime);
- }
- }
- }
- }
- }
- if (fcstdata != null) {
- String lid = null;
- Calendar fcsttime = null;
-
- for (Object[] fcstpoint : fcstdata) {
- if (fcstpoint[0] != null) {
- String newlid = (String) fcstpoint[0];
- // into
- if (!newlid.equals(lid) || (lid == null)) {
- lid = newlid;
- // we care about this data
- if (fcstpoint[1] != null) {
- riverPoints.get(lid).setFcstValue(
- (Double) fcstpoint[1]);
- }
- if (fcstpoint[2] != null) {
- fcsttime = Calendar.getInstance(TimeZone
- .getTimeZone("GMT"));
- fcsttime.setTimeInMillis(((Timestamp) fcstpoint[2])
- .getTime());
- riverPoints.get(lid).setFcstTime(fcsttime);
- }
- }
- }
- }
- }
- } catch (VizException e) {
- statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
- e);
- }
-
- return riverPoints;
- }
-
- /**
- * Gets the RiverID for the GageData
- *
- * @param lid
- * @return
- */
- public String getRiverID(String lid) {
- String riverID = null;
-
- try {
- ArrayList riverObject = (ArrayList) DirectDbQuery
- .executeQuery(riverIDQuery + "'" + lid + "'",
- HydroConstants.IHFS, QueryLanguage.SQL);
-
- if (riverObject.size() > 0) {
- riverID = (String) (riverObject.get(0))[0];
- }
- } catch (VizException e) {
- statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
- e);
- }
-
- return riverID;
- }
-
- /**
- * Get an individual River Data Point
- *
- * @param lid
- * @return
- */
- public RiverDataPoint getRiverDataPoint(String lid) {
-
- // Get the location information first
- RiverDataPoint rdp = new RiverDataPoint(lid);
- try {
- ArrayList locationObject = (ArrayList) DirectDbQuery
- .executeQuery(locationQuery + "'" + lid + "'",
- HydroConstants.IHFS, QueryLanguage.SQL);
- if (locationObject.size() == 1) {
- Object[] location = locationObject.get(0);
- if ((String) location[0] != null) {
- rdp.setLocName((String) location[0]);
- }
- if ((String) location[1] != null) {
- rdp.setCounty((String) location[1]);
- }
- if ((String) location[2] != null) {
- rdp.setState((String) location[2]);
- }
- if ((Double) location[3] != null) {
- rdp.setElevation((Double) location[3]);
- }
- if ((String) location[4] != null) {
- rdp.setHsa((String) location[4]);
- }
- if ((Double) location[5] != null) {
- rdp.setLat((Double) location[5]);
- }
- if ((Double) location[6] != null) {
- rdp.setLon((Double) location[6]);
- }
- if ((String) location[7] != null) {
- rdp.setRiverName((String) location[7]);
- }
- }
- } catch (VizException e) {
- statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
- e);
- }
- // next find the river stat values
- try {
- ArrayList statObject = (ArrayList) DirectDbQuery
- .executeQuery(riverStatQuery + "'" + lid + "'",
- HydroConstants.IHFS, QueryLanguage.SQL);
- if (statObject.size() == 1) {
- Object[] stat = statObject.get(0);
- if ((String) stat[0] != null) {
- rdp.setStreamName((String) stat[0]);
- }
- if ((Double) stat[1] != null) {
- rdp.setMile((Double) stat[1]);
- }
- if ((Double) stat[2] != null) {
- rdp.setZeroDatum((Double) stat[2]);
- }
- if ((String) stat[3] != null) {
- rdp.setTide((String) stat[3]);
- }
- if ((Double) stat[4] != null) {
- rdp.setBankFull((Double) stat[4]);
- }
- if ((Double) stat[5] != null) {
- rdp.setActionStage((Double) stat[5]);
- }
- if ((Double) stat[6] != null) {
- rdp.setFloodStage((Double) stat[6]);
- }
- if ((Double) stat[7] != null) {
- rdp.setFloodFlow((Double) stat[7]);
- }
- if ((Double) stat[8] != null) {
- rdp.setActionFlow((Double) stat[8]);
- }
- if ((String) stat[9] != null) {
- rdp.setPrimaryPE((String) stat[9]);
- }
- }
- } catch (VizException e) {
- statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
- e);
- }
- // next find the description values
- try {
- ArrayList descripObject = (ArrayList) DirectDbQuery
- .executeQuery(descriptionQuery + "'" + lid + "'",
- HydroConstants.IHFS, QueryLanguage.SQL);
- if (descripObject.size() == 1) {
- Object[] descrip = descripObject.get(0);
- if ((String) descrip[0] != null) {
- rdp.setProximity((String) descrip[0]);
- }
- if ((String) descrip[1] != null) {
- rdp.setReach((String) descrip[1]);
- }
- }
- } catch (VizException e) {
- statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
- e);
- }
- // get data for the flood categories
- try {
- ArrayList floodObject = (ArrayList) DirectDbQuery
- .executeQuery(floodCatQuery + "'" + lid + "'",
- HydroConstants.IHFS, QueryLanguage.SQL);
- if (floodObject.size() == 1) {
- Object[] flood = floodObject.get(0);
- if ((Double) flood[0] != null) {
- rdp.setMinorStage((Double) flood[0]);
- }
- if ((Double) flood[1] != null) {
- rdp.setModerateStage((Double) flood[1]);
- }
- if ((Double) flood[2] != null) {
- rdp.setMajorStage((Double) flood[2]);
- }
- if ((Double) flood[3] != null) {
- rdp.setMinorFlow((Double) flood[3]);
- }
- if ((Double) flood[4] != null) {
- rdp.setModerateFlow((Double) flood[4]);
- }
- if ((Double) flood[5] != null) {
- rdp.setMajorFlow((Double) flood[5]);
- }
- }
- } catch (Exception e) {
- statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
- e);
- }
- // Get data for Crest information
- try {
- CrestHistoryData crests = new CrestHistoryData();
- ArrayList crestList = crests.getCrestDataArray();
-
- ArrayList crestObject = (ArrayList) DirectDbQuery
- .executeQuery(crestQuery + lid + "' ORDER BY stage, q",
- HydroConstants.IHFS, QueryLanguage.SQL);
-
- if (crestObject != null) {
- for (Object[] crestob : crestObject) {
- crests.addCrestData(new CrestData(crestob));
- }
- }
- if (crestList.size() > 0) {
- crests.sortByStage();
- CrestData cd = crestList.get(0);
-
- rdp.setCrestValue(cd.getStage());
- rdp.setCrestFlow(cd.getFlow());
- rdp.setCrestTime(cd.getCrestDate());
- }
-
- } catch (Exception e) {
- statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
- e);
- }
- // get data for the river information
- try {
- ArrayList riverInfoObject = (ArrayList) DirectDbQuery
- .executeQuery(riverInfoQuery + "'" + lid + "'",
- HydroConstants.IHFS, QueryLanguage.SQL);
- if (riverInfoObject.size() == 1) {
- Object[] riverInfo = riverInfoObject.get(0);
- if ((String) riverInfo[0] != null) {
- rdp.setRiverID((String) riverInfo[0]);
- }
- }
- } catch (Exception e) {
- statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
- e);
- }
-
- return rdp;
- }
-
- public String getStreamName(String lid) {
- List results = null;
- String stream = null;
- try {
- results = DirectDbQuery.executeQuery(
- "select stream from riverstat where lid = '" + lid + "'",
- HydroConstants.IHFS, QueryLanguage.SQL);
- if ((results != null) && (results.size() > 0)) {
- stream = (String) results.get(0)[0];
- }
- } catch (VizException e) {
- statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
- e);
- }
-
- return stream;
- }
-
- /**
- * Get the Statprof data for the specified stream.
- *
- * @param stream
- * The stream
- * @return The statprof data for the stream.
- */
- public List getStatProf(String stream) {
-// String query = "from "
-// + com.raytheon.edex.plugin.shef.objects.Statprof.class
-// .getName();
-// query += " where stream = '" + stream + "' order by mile desc";
- String query = "select lid, name, primary_pe, stream, fs, wstg, fq, " +
- "action_flow, zd, mile, reach, proximity from statprof " +
- "where stream = '" + stream + "' order by mile desc";
-
- List dataList = new ArrayList();
- try {
- List results = DirectDbQuery.executeQuery(query,
- HydroConstants.IHFS, QueryLanguage.SQL);
- if ((results != null) && (results.size() > 0)) {
- for (Object[] oa : results) {
- if (oa[0] != null) {
-// dataList.add((Statprof) oa[0]);
- Statprof sp = new Statprof();
- StatprofId spid = new StatprofId();
- spid.setLid((String) oa[0]);
- spid.setName((String) oa[1]);
- spid.setPrimaryPe((String) oa[2]);
- spid.setStream((String) oa[3]);
- spid.setFs((Double) oa[4]);
- spid.setWstg((Double) oa[5]);
- spid.setFq((Double) oa[6]);
- spid.setActionFlow((Double) oa[7]);
- spid.setZd((Double) oa[8]);
- spid.setMile((Double) oa[9]);
- spid.setReach((String) oa[10]);
- spid.setProximity((String) oa[11]);
- sp.setId(spid);
-
- // Check for missing data values
- if (spid.getPrimaryPe() == null) {
- continue;
- } else if (spid.getPrimaryPe().startsWith("H")) {
- if ((spid.getFs() == null) || (spid.getWstg() == null)) {
- continue;
- }
- } else {
- if ((spid.getFq() == null) || (spid.getActionFlow() == null)) {
- continue;
- }
- }
- dataList.add(sp);
- }
- }
- }
- } catch (VizException e) {
- statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
- e);
- }
-
- return dataList;
- }
-
- public ArrayList getRiverStatus(String lid, String pe,
- long validTime, long basisTime) {
-
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- Date validTimeDate = new Date();
- validTimeDate.setTime(validTime);
- String validTimeStr = sdf.format(validTimeDate);
- Date basisTimeDate = new Date();
- basisTimeDate.setTime(basisTime);
- String basisTimeStr = sdf.format(basisTimeDate);
-
- String where = " where lid = '" + lid + "' " + "and pe = '" + pe
- + "' and (validTime > '" + validTimeStr
- + "' or ts like 'F%%') and "
- + "basisTime is null or basistime >= '" + basisTimeStr + "')";
-
- String query = "from "
- + com.raytheon.uf.common.dataplugin.shef.tables.Riverstatus.class
- .getName();
- query += where;
-
- ArrayList dataList = null;
- try {
- List results = DirectDbQuery.executeQuery(query,
- HydroConstants.IHFS, QueryLanguage.HQL);
- if ((results != null) && (results.size() > 0)) {
- dataList = new ArrayList();
- for (Object[] oa : results) {
- dataList.add((Riverstatus) oa[0]);
- }
- }
- } catch (VizException e) {
- statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
- e);
- }
-
- return dataList;
- }
-
- public List getTsList() {
- List rs = null;
-
- String query = "select distinct(ts), ts_rank from ingestfilter";
-
- try {
- rs = DirectDbQuery.executeQuery(query, HydroConstants.IHFS,
- QueryLanguage.SQL);
- } catch (VizException e) {
- statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
- e);
- }
-
- return rs;
- }
+ /** Singleton instance of this class */
+ private static RiverDataManager riverManager = null;
+
+ /* Private Constructor */
+ private RiverDataManager() {
+ }
+
+ /**
+ * Get an instance of this singleton.
+ *
+ * @return Instance of this class
+ */
+ public static synchronized RiverDataManager getInstance() {
+ if (riverManager == null) {
+ riverManager = new RiverDataManager();
+ }
+ return riverManager;
+ }
+
+ private static final transient IUFStatusHandler statusHandler = UFStatus
+ .getHandler(RiverDataManager.class);
+
+ private LinkedHashMap crestData = null;
+
+ private LinkedHashMap> riverData = null;
+
+ private static String locationQuery = "SELECT name, county, state, elev, hsa, lat, lon, rb from location WHERE lid =";
+
+ private static String riverStatQuery = "SELECT stream, mile, zd, tide, bf, wstg, fs, fq, action_flow, primary_pe FROM riverstat WHERE lid =";
+
+ private static String descriptionQuery = "SELECT proximity, reach FROM descrip WHERE lid =";
+
+ private static String crestQuery = "select stage, q, datcrst, timcrst, cremark, hw, jam, olddatum, suppress, prelim from crest where lid = '";
+
+ private static String floodCatQuery = "SELECT minor_stage, moderate_stage, major_stage, minor_flow, moderate_flow, major_flow from floodcat WHERE lid = ";
+
+ private static String riverInfoQuery = "SELECT rivermonlocation.group_id, rivermongroup.group_name FROM rivermongroup, rivermonlocation WHERE rivermongroup.group_id = rivermonlocation.group_id AND rivermonlocation.lid = ";
+
+ private static String riverPointQuery = "SELECT l.lid, l.name, l.county, l.state, l.elev, l.hsa, l.lat, l.lon, "
+ + "rml.group_id, "
+ + "rmg.group_name, "
+ + "r.stream, r.mile, r.zd AS zero, r.tide, r.bf AS bankfull, r.wstg AS action_stage, r.fs AS flood_stage, r.fq AS flood_flow, r.action_flow, r.primary_pe, "
+ + "d.proximity, d.reach, "
+ + "f.minor_stage AS minor, f.moderate_stage AS moderate, f.major_stage AS major, f.minor_flow AS minor, f.moderate_flow AS moderate, f.major_flow AS major "
+ + "FROM location l "
+ + "LEFT JOIN floodcat f ON l.lid::text = f.lid::text "
+ + "LEFT JOIN descrip d ON l.lid::text = d.lid::text, riverstat r, rivermonlocation rml "
+ + "LEFT JOIN rivermongroup rmg ON rml.group_id::text = rmg.group_id::text "
+ + "WHERE l.lid::text = r.lid::text and r.lid::text = rml.lid::text "
+ + "ORDER BY rml.group_id, r.mile desc";
+
+ private static String riverObsvalueQueryFront = "SELECT distinct(foo.lid), foo.value, foo.maxtime from "
+ + "(SELECT distinct height.lid, height.value, max(height.obstime) as maxtime "
+ + "FROM height "
+ + "WHERE height.lid in "
+ + "(select distinct(lid) "
+ + "from rivermonlocation "
+ + "where rivermonlocation.group_id = ";
+
+ private static String riverObsvalueQueryBack = ") GROUP BY height.lid, height.value) "
+ + "AS foo "
+ + "GROUP BY foo.lid, foo.value, foo.maxtime order by foo.lid, foo.maxtime desc";
+
+ private static String riverFcstvalueQueryFront = "SELECT distinct(foo.lid), foo.value, foo.maxtime from "
+ + "(SELECT distinct fcstheight.lid, fcstheight.value, max(fcstheight.validtime) as maxtime "
+ + "FROM fcstheight "
+ + "WHERE fcstheight.lid in "
+ + "(select distinct(lid) "
+ + "from rivermonlocation "
+ + "where rivermonlocation.group_id = ";
+
+ private static String riverFcstvalueQueryBack = ") GROUP BY fcstheight.lid, fcstheight.value) "
+ + "AS foo "
+ + "GROUP BY foo.lid, foo.value, foo.maxtime order by foo.lid, foo.maxtime desc";
+
+ private static String riverIDQuery = "SELECT group_id FROM rivermonlocation where lid =";
+
+ /**
+ * River Query Crest
+ *
+ * @param lid
+ * @return CrestHistoryData
+ */
+ public CrestHistoryData getRiverCrests(RiverDataPoint rdp, int allFlag) {
+ CrestHistoryData crests = null;
+
+ if (crestData == null) {
+ crestData = new LinkedHashMap();
+ }
+
+ crests = new CrestHistoryData();
+ String query = null;
+
+ /* get crest data depending on action stage */
+ if (rdp != null) {
+ String sql = "select stage, q, datcrst, timcrst, cremark, hw, jam, olddatum, suppress, prelim "
+ + "from crest where lid = '" + rdp.getLid();
+
+ if (allFlag == 1) {
+ query = sql + "' and stage >'" + rdp.getActionStage()
+ + "' ORDER BY stage, q";
+ } else if (allFlag == 2) {
+ query = sql + "' and stage <'" + rdp.getActionStage()
+ + "' ORDER BY stage, q";
+ } else {
+ query = sql + "' ORDER BY stage, q";
+ }
+
+ ArrayList objects = null;
+
+ try {
+ objects = (ArrayList) DirectDbQuery.executeQuery(
+ query, HydroConstants.IHFS, QueryLanguage.SQL);
+ if (objects != null) {
+ for (Object[] crestob : objects) {
+ crests.addCrestData(new CrestData(crestob));
+ }
+ }
+ } catch (Exception e) {
+ statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
+ e);
+ }
+ }
+
+ if (crests.getCrestDataArray().size() > 0) {
+ // max stage level, default sort mode
+ // There is a problem when the stage is not set in the db.
+ // Added this work around here to manually find the max stage value
+ double maxStag = 0;
+ double minStag = Double.MAX_VALUE;
+ for (int i = 0; i < crests.getCrestDataArray().size(); i++) {
+ if (crests.getCrestDataArray().get(i).getStage() > maxStag) {
+ maxStag = crests.getCrestDataArray().get(i).getStage();
+ }
+ if (crests.getCrestDataArray().get(i).getStage() < minStag &&
+ crests.getCrestDataArray().get(i).getStage() >= 0) {
+ minStag = crests.getCrestDataArray().get(i).getStage();
+ }
+
+ }
+ crests.setMaxStageLevel(maxStag);
+ crests.setMinStageLevel(minStag);
+
+ // set the values to gage by
+ crests.setActionLevel(rdp.getActionStage());
+ crests.setMajorLevel(rdp.getMajorStage());
+ crests.setMinorLevel(rdp.getMinorStage());
+ crests.setModerateLevel(rdp.getModerateStage());
+
+ // we assume a top of zero at all times, find oldest record
+ crests.sortByDate();
+ CrestData cd5 = crests.getCrestDataArray().get(
+ crests.getCrestDataArray().size() - 1);
+
+ Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+ Date now = SimulatedTime.getSystemTime().getTime();
+ cal.setTime(now);
+
+ if (cd5.getCrestDate() != null) {
+ crests.setStartingYear(cd5.getCrestDate().get(Calendar.YEAR));
+ } else {
+ crests.setStartingYear(HydroConstants.DEFAULT_YEAR);
+ }
+ crests.setEndingYear(cal.get(Calendar.YEAR));
+
+ crests.sortByStage();
+
+ crestData.put(rdp.getLid(), crests);
+ }
+
+ return crests;
+ }
+
+ /**
+ * Gets the crest data for just the record flood, flow
+ *
+ * @param rdp
+ * @return
+ */
+ public RiverDataPoint getRiverCrest(RiverDataPoint rdp) {
+ Date date = SimulatedTime.getSystemTime().getTime();
+ int allFlag = 0;
+ CrestHistoryData crests = getRiverCrests(rdp, allFlag);
+ ArrayList temp = crests.getCrestDataArray();
+ if (temp.size() > 0) {
+ // maximum stage value
+ crests.sortByStage();
+ CrestData cd = temp.get(0);
+ rdp.setCrestValue(cd.getStage());
+
+ // maximum flow (q) value for max stage value
+ rdp.setCrestFlow(cd.getFlow());
+
+ // Stage Crest date
+ rdp.setCrestTime(cd.getCrestDate());
+
+ } else {
+ // maximum stage value
+ rdp.setCrestValue(HydroConstants.MISSING_VALUE);
+
+ // maximum flow value
+ rdp.setCrestFlow(HydroConstants.MISSING_VALUE);
+
+ // sort by date
+ Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+ cal.setTime(date);
+ rdp.setCrestTime(cal);
+ }
+
+ return rdp;
+ }
+
+ /**
+ * data structure to house the river water shed data
+ *
+ * @return HashMap>
+ */
+ public LinkedHashMap> getRiverSummaryData() {
+ ArrayList data = null;
+
+ try {
+ data = (ArrayList) DirectDbQuery.executeQuery(
+ riverPointQuery, HydroConstants.IHFS, QueryLanguage.SQL);
+ if (data != null) {
+ riverData = new LinkedHashMap>();
+ String riverID = null;
+ LinkedHashMap riverPoints = null;
+ for (Object[] point : data) {
+ RiverDataPoint rdp = new RiverDataPoint(point);
+ // start
+ if (riverID == null) {
+ riverID = rdp.getRiverID();
+ riverPoints = new LinkedHashMap();
+ riverPoints.put(rdp.getLid(), rdp);
+ }
+ // new river switch
+ else if (!rdp.getRiverID().equals(riverID)) {
+ // sock away the old one
+ riverData.put(riverID, riverPoints);
+ // rename Name
+ riverID = rdp.getRiverID();
+ // create new
+ riverPoints = new LinkedHashMap();
+ riverPoints.put(rdp.getLid(), rdp);
+ }
+ // in river run
+ else {
+ riverPoints.put(rdp.getLid(), rdp);
+ }
+ }
+ // take care of last river
+ riverData.put(riverID, riverPoints);
+ }
+ } catch (VizException e) {
+ statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
+ }
+
+ return riverData;
+ }
+
+ /**
+ * Populate the Data for time and point obs and fcst, really not pretty
+ * avert your eyes.
+ *
+ * @param riverPoints
+ * @param riverID
+ * @return HashMap
+ */
+ public LinkedHashMap populateRiverData(
+ String riverID, LinkedHashMap riverPoints) {
+
+ ArrayList obsdata = null;
+ ArrayList fcstdata = null;
+
+ try {
+ String obsquery = riverObsvalueQueryFront + "'" + riverID + "'"
+ + riverObsvalueQueryBack;
+ String fcstquery = riverFcstvalueQueryFront + "'" + riverID + "'"
+ + riverFcstvalueQueryBack;
+ obsdata = (ArrayList) DirectDbQuery.executeQuery(
+ obsquery, HydroConstants.IHFS, QueryLanguage.SQL);
+ fcstdata = (ArrayList) DirectDbQuery.executeQuery(
+ fcstquery, HydroConstants.IHFS, QueryLanguage.SQL);
+ if (obsdata != null) {
+ String lid = null;
+ Calendar obstime = null;
+
+ for (Object[] obspoint : obsdata) {
+ if (obspoint[0] != null) {
+ String newlid = (String) obspoint[0];
+ // into
+ if (!newlid.equals(lid) || (lid == null)) {
+ lid = newlid;
+ // we care about this data
+ if (obspoint[1] != null) {
+ riverPoints.get(lid).setObsValue(
+ (Double) obspoint[1]);
+ }
+ if (obspoint[2] != null) {
+ obstime = Calendar.getInstance(TimeZone
+ .getTimeZone("GMT"));
+ obstime.setTimeInMillis(((Timestamp) obspoint[2])
+ .getTime());
+ riverPoints.get(lid).setObsTime(obstime);
+ }
+ }
+ }
+ }
+ }
+ if (fcstdata != null) {
+ String lid = null;
+ Calendar fcsttime = null;
+
+ for (Object[] fcstpoint : fcstdata) {
+ if (fcstpoint[0] != null) {
+ String newlid = (String) fcstpoint[0];
+ // into
+ if (!newlid.equals(lid) || (lid == null)) {
+ lid = newlid;
+ // we care about this data
+ if (fcstpoint[1] != null) {
+ riverPoints.get(lid).setFcstValue(
+ (Double) fcstpoint[1]);
+ }
+ if (fcstpoint[2] != null) {
+ fcsttime = Calendar.getInstance(TimeZone
+ .getTimeZone("GMT"));
+ fcsttime.setTimeInMillis(((Timestamp) fcstpoint[2])
+ .getTime());
+ riverPoints.get(lid).setFcstTime(fcsttime);
+ }
+ }
+ }
+ }
+ }
+ } catch (VizException e) {
+ statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
+ }
+
+ return riverPoints;
+ }
+
+ /**
+ * Gets the RiverID for the GageData
+ *
+ * @param lid
+ * @return
+ */
+ public String getRiverID(String lid) {
+ String riverID = null;
+
+ try {
+ ArrayList riverObject = (ArrayList) DirectDbQuery
+ .executeQuery(riverIDQuery + "'" + lid + "'",
+ HydroConstants.IHFS, QueryLanguage.SQL);
+
+ if (riverObject.size() > 0) {
+ riverID = (String) (riverObject.get(0))[0];
+ }
+ } catch (VizException e) {
+ statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
+ }
+
+ return riverID;
+ }
+
+ /**
+ * Get an individual River Data Point
+ *
+ * @param lid
+ * @return
+ */
+ public RiverDataPoint getRiverDataPoint(String lid) {
+
+ // Get the location information first
+ RiverDataPoint rdp = new RiverDataPoint(lid);
+ try {
+ ArrayList locationObject = (ArrayList) DirectDbQuery
+ .executeQuery(locationQuery + "'" + lid + "'",
+ HydroConstants.IHFS, QueryLanguage.SQL);
+ if (locationObject.size() == 1) {
+ Object[] location = locationObject.get(0);
+ if ((String) location[0] != null) {
+ rdp.setLocName((String) location[0]);
+ }
+ if ((String) location[1] != null) {
+ rdp.setCounty((String) location[1]);
+ }
+ if ((String) location[2] != null) {
+ rdp.setState((String) location[2]);
+ }
+ if ((Double) location[3] != null) {
+ rdp.setElevation((Double) location[3]);
+ }
+ if ((String) location[4] != null) {
+ rdp.setHsa((String) location[4]);
+ }
+ if ((Double) location[5] != null) {
+ rdp.setLat((Double) location[5]);
+ }
+ if ((Double) location[6] != null) {
+ rdp.setLon((Double) location[6]);
+ }
+ if ((String) location[7] != null) {
+ rdp.setRiverName((String) location[7]);
+ }
+ }
+ } catch (VizException e) {
+ statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
+ }
+ // next find the river stat values
+ try {
+ ArrayList statObject = (ArrayList) DirectDbQuery
+ .executeQuery(riverStatQuery + "'" + lid + "'",
+ HydroConstants.IHFS, QueryLanguage.SQL);
+ if (statObject.size() == 1) {
+ Object[] stat = statObject.get(0);
+ if ((String) stat[0] != null) {
+ rdp.setStreamName((String) stat[0]);
+ }
+ if ((Double) stat[1] != null) {
+ rdp.setMile((Double) stat[1]);
+ }
+ if ((Double) stat[2] != null) {
+ rdp.setZeroDatum((Double) stat[2]);
+ }
+ if ((String) stat[3] != null) {
+ rdp.setTide((String) stat[3]);
+ }
+ if ((Double) stat[4] != null) {
+ rdp.setBankFull((Double) stat[4]);
+ }
+ if ((Double) stat[5] != null) {
+ rdp.setActionStage((Double) stat[5]);
+ }
+ if ((Double) stat[6] != null) {
+ rdp.setFloodStage((Double) stat[6]);
+ }
+ if ((Double) stat[7] != null) {
+ rdp.setFloodFlow((Double) stat[7]);
+ }
+ if ((Double) stat[8] != null) {
+ rdp.setActionFlow((Double) stat[8]);
+ }
+ if ((String) stat[9] != null) {
+ rdp.setPrimaryPE((String) stat[9]);
+ }
+ }
+ } catch (VizException e) {
+ statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
+ }
+ // next find the description values
+ try {
+ ArrayList descripObject = (ArrayList) DirectDbQuery
+ .executeQuery(descriptionQuery + "'" + lid + "'",
+ HydroConstants.IHFS, QueryLanguage.SQL);
+ if (descripObject.size() == 1) {
+ Object[] descrip = descripObject.get(0);
+ if ((String) descrip[0] != null) {
+ rdp.setProximity((String) descrip[0]);
+ }
+ if ((String) descrip[1] != null) {
+ rdp.setReach((String) descrip[1]);
+ }
+ }
+ } catch (VizException e) {
+ statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
+ }
+ // get data for the flood categories
+ try {
+ ArrayList floodObject = (ArrayList) DirectDbQuery
+ .executeQuery(floodCatQuery + "'" + lid + "'",
+ HydroConstants.IHFS, QueryLanguage.SQL);
+ if (floodObject.size() == 1) {
+ Object[] flood = floodObject.get(0);
+ if ((Double) flood[0] != null) {
+ rdp.setMinorStage((Double) flood[0]);
+ }
+ if ((Double) flood[1] != null) {
+ rdp.setModerateStage((Double) flood[1]);
+ }
+ if ((Double) flood[2] != null) {
+ rdp.setMajorStage((Double) flood[2]);
+ }
+ if ((Double) flood[3] != null) {
+ rdp.setMinorFlow((Double) flood[3]);
+ }
+ if ((Double) flood[4] != null) {
+ rdp.setModerateFlow((Double) flood[4]);
+ }
+ if ((Double) flood[5] != null) {
+ rdp.setMajorFlow((Double) flood[5]);
+ }
+ }
+ } catch (Exception e) {
+ statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
+ }
+ // Get data for Crest information
+ try {
+ CrestHistoryData crests = new CrestHistoryData();
+ ArrayList crestList = crests.getCrestDataArray();
+
+ ArrayList crestObject = (ArrayList) DirectDbQuery
+ .executeQuery(crestQuery + lid + "' ORDER BY stage, q",
+ HydroConstants.IHFS, QueryLanguage.SQL);
+
+ if (crestObject != null) {
+ for (Object[] crestob : crestObject) {
+ crests.addCrestData(new CrestData(crestob));
+ }
+ }
+ if (crestList.size() > 0) {
+ crests.sortByStage();
+ CrestData cd = crestList.get(0);
+
+ rdp.setCrestValue(cd.getStage());
+ rdp.setCrestFlow(cd.getFlow());
+ rdp.setCrestTime(cd.getCrestDate());
+ }
+
+ } catch (Exception e) {
+ statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
+ }
+ // get data for the river information
+ try {
+ ArrayList riverInfoObject = (ArrayList) DirectDbQuery
+ .executeQuery(riverInfoQuery + "'" + lid + "'",
+ HydroConstants.IHFS, QueryLanguage.SQL);
+ if (riverInfoObject.size() == 1) {
+ Object[] riverInfo = riverInfoObject.get(0);
+ if ((String) riverInfo[0] != null) {
+ rdp.setRiverID((String) riverInfo[0]);
+ }
+ }
+ } catch (Exception e) {
+ statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
+ }
+
+ return rdp;
+ }
+
+ public String getStreamName(String lid) {
+ List results = null;
+ String stream = null;
+ try {
+ results = DirectDbQuery.executeQuery(
+ "select stream from riverstat where lid = '" + lid + "'",
+ HydroConstants.IHFS, QueryLanguage.SQL);
+ if ((results != null) && (results.size() > 0)) {
+ stream = (String) results.get(0)[0];
+ }
+ } catch (VizException e) {
+ statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
+ }
+
+ return stream;
+ }
+
+ /**
+ * Get the Statprof data for the specified stream.
+ *
+ * @param stream
+ * The stream
+ * @return The statprof data for the stream.
+ */
+ public List getStatProf(String stream) {
+ // String query = "from "
+ // + com.raytheon.edex.plugin.shef.objects.Statprof.class
+ // .getName();
+ // query += " where stream = '" + stream + "' order by mile desc";
+ String query = "select lid, name, primary_pe, stream, fs, wstg, fq, "
+ + "action_flow, zd, mile, reach, proximity from statprof "
+ + "where stream = '" + stream + "' order by mile desc";
+
+ List dataList = new ArrayList();
+ try {
+ List results = DirectDbQuery.executeQuery(query,
+ HydroConstants.IHFS, QueryLanguage.SQL);
+ if ((results != null) && (results.size() > 0)) {
+ for (Object[] oa : results) {
+ if (oa[0] != null) {
+ // dataList.add((Statprof) oa[0]);
+ Statprof sp = new Statprof();
+ StatprofId spid = new StatprofId();
+ spid.setLid((String) oa[0]);
+ spid.setName((String) oa[1]);
+ spid.setPrimaryPe((String) oa[2]);
+ spid.setStream((String) oa[3]);
+ spid.setFs((Double) oa[4]);
+ spid.setWstg((Double) oa[5]);
+ spid.setFq((Double) oa[6]);
+ spid.setActionFlow((Double) oa[7]);
+ spid.setZd((Double) oa[8]);
+ spid.setMile((Double) oa[9]);
+ spid.setReach((String) oa[10]);
+ spid.setProximity((String) oa[11]);
+ sp.setId(spid);
+
+ // Check for missing data values
+ if (spid.getPrimaryPe() == null) {
+ continue;
+ } else if (spid.getPrimaryPe().startsWith("H")) {
+ if ((spid.getFs() == null)
+ || (spid.getWstg() == null)) {
+ continue;
+ }
+ } else {
+ if ((spid.getFq() == null)
+ || (spid.getActionFlow() == null)) {
+ continue;
+ }
+ }
+ dataList.add(sp);
+ }
+ }
+ }
+ } catch (VizException e) {
+ statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
+ }
+
+ return dataList;
+ }
+
+ public ArrayList getRiverStatus(String lid, String pe,
+ long validTime, long basisTime) {
+
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ Date validTimeDate = new Date();
+ validTimeDate.setTime(validTime);
+ String validTimeStr = sdf.format(validTimeDate);
+ Date basisTimeDate = new Date();
+ basisTimeDate.setTime(basisTime);
+ String basisTimeStr = sdf.format(basisTimeDate);
+
+ String where = " where lid = '" + lid + "' " + "and pe = '" + pe
+ + "' and (validTime > '" + validTimeStr
+ + "' or ts like 'F%%') and "
+ + "basisTime is null or basistime >= '" + basisTimeStr + "')";
+
+ String query = "from "
+ + com.raytheon.uf.common.dataplugin.shef.tables.Riverstatus.class
+ .getName();
+ query += where;
+
+ ArrayList dataList = null;
+ try {
+ List results = DirectDbQuery.executeQuery(query,
+ HydroConstants.IHFS, QueryLanguage.HQL);
+ if ((results != null) && (results.size() > 0)) {
+ dataList = new ArrayList();
+ for (Object[] oa : results) {
+ dataList.add((Riverstatus) oa[0]);
+ }
+ }
+ } catch (VizException e) {
+ statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
+ }
+
+ return dataList;
+ }
+
+ public List getTsList() {
+ List rs = null;
+
+ String query = "select distinct(ts), ts_rank from ingestfilter";
+
+ try {
+ rs = DirectDbQuery.executeQuery(query, HydroConstants.IHFS,
+ QueryLanguage.SQL);
+ } catch (VizException e) {
+ statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
+ }
+
+ return rs;
+ }
}
diff --git a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/ratingcurve/IRatingCurveSort.java b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/ratingcurve/IRatingCurveSort.java
deleted file mode 100644
index e4d299537c..0000000000
--- a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/ratingcurve/IRatingCurveSort.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * 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.viz.hydrocommon.ratingcurve;
-
-/**
- * Interface for getting the sort type for the rating curve data.
- *
- *
- *
- * SOFTWARE HISTORY
- *
- * Date Ticket# Engineer Description
- * ------------ ---------- ----------- --------------------------
- *24 Nov, 2008 1628 dhladky Initial creation
- *
- *
- *
- * @author dhladky
- * @version 1.0
- */
-public interface IRatingCurveSort
-{
- /**
- * Get the sort type.
- * @return The sort type.
- */
- String getSortType();
-}
\ No newline at end of file
diff --git a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/ratingcurve/RatingCurveData.java b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/ratingcurve/RatingCurveData.java
index 3ec557f301..d917f3a8e9 100644
--- a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/ratingcurve/RatingCurveData.java
+++ b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/ratingcurve/RatingCurveData.java
@@ -167,4 +167,44 @@ public class RatingCurveData implements Comparable
return ret;
}
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ long temp;
+ temp = Double.doubleToLongBits(discharge);
+ result = prime * result + (int) (temp ^ (temp >>> 32));
+ temp = Double.doubleToLongBits(stage);
+ result = prime * result + (int) (temp ^ (temp >>> 32));
+ return result;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ RatingCurveData other = (RatingCurveData) obj;
+ if (Double.doubleToLongBits(discharge) != Double
+ .doubleToLongBits(other.discharge))
+ return false;
+ if (Double.doubleToLongBits(stage) != Double
+ .doubleToLongBits(other.stage))
+ return false;
+ return true;
+ }
}
diff --git a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/ratingcurve/RatingCurveDlg.java b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/ratingcurve/RatingCurveDlg.java
index 1fbe6264bc..12f37e144c 100644
--- a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/ratingcurve/RatingCurveDlg.java
+++ b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/ratingcurve/RatingCurveDlg.java
@@ -38,12 +38,12 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Font;
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.Display;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Layout;
@@ -77,7 +77,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* @author lvenable
* @version 1.0
*/
-public class RatingCurveDlg extends CaveSWTDialog implements IRatingCurveSort {
+public class RatingCurveDlg extends CaveSWTDialog {
/**
* Control font.
@@ -229,18 +229,6 @@ public class RatingCurveDlg extends CaveSWTDialog implements IRatingCurveSort {
*/
private Button saveBtn;
- /**
- * Sort by enumeration.
- */
- private enum sortBy {
- Stage, Discharge
- };
-
- /**
- * Sort by
- */
- private sortBy sortKey;
-
/**
* Dialog lid information.
*/
@@ -285,11 +273,6 @@ public class RatingCurveDlg extends CaveSWTDialog implements IRatingCurveSort {
*/
private RatingCurveShiftData selectedRatingShift = null;
- /**
- * The current selected rating point
- */
- private RatingCurveData selectedRatingPoint = null;
-
/**
* Shift amount
*/
@@ -488,91 +471,6 @@ public class RatingCurveDlg extends CaveSWTDialog implements IRatingCurveSort {
df.setMaximumFractionDigits(2);
df.setMaximumIntegerDigits(3);
- shiftDataList.addSelectionListener(new SelectionListener() {
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- int index = 0; // default
- RatingCurveShiftData rcsd = shiftData.get(index);
-
- shiftValueTF.setText(df.format(rcsd.getValue()));
- shiftDateTF.setText(sdf.format(rcsd.getDate().getTime()));
- shiftActiveChk.setSelection(rcsd.isActive());
- generateShiftList(rcsd);
- setSelectedShift(rcsd);
-
- if (shiftActiveChk.getSelection()) {
- // redraw the canvas with shifted data
- ratingCurveCanvas.updateCurveData(shiftCurveArray,
- floodDbl, recordDbl, shiftAmount);
- } else {
- ratingCurveCanvas.updateCurveData(noShiftCurveArray,
- floodDbl, recordDbl, shiftAmount);
- }
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- int index = shiftDataList.getSelectionIndex();
- setSelectedShift(shiftData.get(index));
- RatingCurveShiftData rcsd = shiftData.get(index);
-
- shiftValueTF.setText(df.format(rcsd.getValue()));
- shiftDateTF.setText(sdf.format(rcsd.getDate().getTime()));
- shiftActiveChk.setSelection(rcsd.isActive());
-
- if (shiftActiveChk.getSelection()) {
- // redraw the canvas with shifted data
- generateShiftList(getEditingShiftData());
- ratingCurveCanvas.updateCurveData(shiftCurveArray,
- floodDbl, recordDbl, shiftAmount);
- } else {
- ratingCurveCanvas.updateCurveData(noShiftCurveArray,
- floodDbl, recordDbl, shiftAmount);
- }
- }
-
- });
-
- shiftActiveChk.addSelectionListener(new SelectionListener() {
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- // redraw the canvas with shifted data
- if ((shiftData.size() > 0) && (shiftDataList != null)) {
- int index = 0;
- RatingCurveShiftData rcsd = shiftData.get(index);
- if (rcsd.isActive()) {
- ratingCurveCanvas.updateCurveData(shiftCurveArray,
- floodDbl, recordDbl, shiftAmount);
- shiftActiveChk.setSelection(rcsd.isActive());
- } else {
- ratingCurveCanvas.updateCurveData(noShiftCurveArray,
- floodDbl, recordDbl, shiftAmount);
- }
- }
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- // redraw the canvas with shifted data
- if ((shiftData.size() > 0)
- && (shiftDataList.getSelectionIndex() != -1)) {
- RatingCurveShiftData rcsd = shiftData.get(shiftDataList
- .getSelectionIndex());
- generateShiftList(rcsd);
- if (rcsd.isActive()) {
- ratingCurveCanvas.updateCurveData(shiftCurveArray,
- floodDbl, recordDbl, shiftAmount);
- } else {
- ratingCurveCanvas.updateCurveData(noShiftCurveArray,
- floodDbl, recordDbl, shiftAmount);
- }
- }
- }
-
- });
-
// --------------------------------------------------------
// Create the Shift Remove & Update/Insert buttons
// --------------------------------------------------------
@@ -589,25 +487,7 @@ public class RatingCurveDlg extends CaveSWTDialog implements IRatingCurveSort {
shftRemoveBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
- if (getEditingShiftData() != null) {
- int index = shiftDataList.getSelectionIndex();
- removedCurveShifts.add(getEditingShiftData());
- shiftData.remove(index);
- selectedRatingShift = null;
-
- shiftDataList.removeAll();
- for (RatingCurveShiftData rcsd : shiftData) {
- shiftDataList.add(getShiftListString(rcsd));
- }
- shiftDataList.redraw();
-
- shiftValueTF.setText("");
- shiftDateTF.setText("");
- shiftActiveChk.setSelection(false);
- // default without shifting
- ratingCurveCanvas.updateCurveData(noShiftCurveArray,
- floodDbl, recordDbl, shiftAmount);
- }
+ removeShift();
}
});
@@ -656,25 +536,31 @@ public class RatingCurveDlg extends CaveSWTDialog implements IRatingCurveSort {
curveClearAllBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
- // get rid of every point
- removedPoints = noShiftCurveArray;
- noShiftCurveArray.clear();
- noShiftCurveDataList.removeAll();
- noShiftCurveDataList.redraw();
+ MessageBox messageDialog = new MessageBox(shell, SWT.OK | SWT.CANCEL);
+ messageDialog.setText("Clear Confirmation");
+ messageDialog.setMessage("This will clear the list for " + lid + ".");
+ int response = messageDialog.open();
- if (shiftCurveArray != null) {
- shiftCurveArray.clear();
- shiftCurveDataList.removeAll();
- shiftCurveDataList.redraw();
+ if (response == SWT.OK) {
+ // get rid of every point
+ removedPoints = noShiftCurveArray;
+ noShiftCurveArray.clear();
+ noShiftCurveDataList.removeAll();
+ noShiftCurveDataList.redraw();
+
+ if (shiftCurveArray != null) {
+ shiftCurveArray.clear();
+ }
+ shiftCurveDataList.removeAll();
+ shiftCurveDataList.redraw();
+
+ stageTF.setText("");
+ dischargeTF.setText("");
+ selectedRatingShift = null;
+
+ ratingCurveCanvas.updateCurveData(noShiftCurveArray, floodDbl,
+ recordDbl, shiftAmount);
}
-
- stageTF.setText("");
- dischargeTF.setText("");
- selectedRatingShift = null;
- selectedRatingPoint = null;
-
- ratingCurveCanvas.updateCurveData(noShiftCurveArray, floodDbl,
- recordDbl, shiftAmount);
}
});
@@ -686,20 +572,28 @@ public class RatingCurveDlg extends CaveSWTDialog implements IRatingCurveSort {
@Override
public void widgetSelected(SelectionEvent event) {
if (noShiftCurveDataList.getSelectionIndex() != -1) {
- // get rid of this point
- int index = noShiftCurveDataList.getSelectionIndex();
- removedPoints.add(noShiftCurveArray.remove(index));
- remakeRatingCurveDataList();
+ MessageBox mb = new MessageBox(shell, SWT.ICON_QUESTION
+ | SWT.OK | SWT.CANCEL);
+ mb.setText("Remove Base Rating Point Confirmation");
+ mb.setMessage("This will remove the highlighted pair.");
+ int response = mb.open();
- stageTF.setText("");
- dischargeTF.setText("");
+ if (response == SWT.OK) {
+ // get rid of this point
+ int index = noShiftCurveDataList.getSelectionIndex();
+ removedPoints.add(noShiftCurveArray.remove(index));
+ remakeRatingCurveDataList();
- if (getEditingShiftData() != null) {
- generateShiftList(getEditingShiftData());
- }
+ stageTF.setText("");
+ dischargeTF.setText("");
- ratingCurveCanvas.updateCurveData(noShiftCurveArray,
- floodDbl, recordDbl, shiftAmount);
+ if (getEditingShiftData() != null) {
+ generateShiftList(getEditingShiftData());
+ }
+
+ ratingCurveCanvas.updateCurveData(noShiftCurveArray,
+ floodDbl, recordDbl, shiftAmount);
+ }
}
}
});
@@ -712,47 +606,10 @@ public class RatingCurveDlg extends CaveSWTDialog implements IRatingCurveSort {
@Override
public void widgetSelected(SelectionEvent event) {
if (verifyDouble(stageTF) && verifyInt(dischargeTF)) {
-
RatingCurveData rcd = new RatingCurveData(new Double(
stageTF.getText().trim()), new Double(dischargeTF
.getText().trim()));
-
- if (noShiftCurveDataList != null) {
- if (getEditingCurveData() != null) {
- int index = noShiftCurveDataList
- .getSelectionIndex();
- if (index > -1) {
- noShiftCurveArray.remove(index);
- noShiftCurveDataList.remove(index);
- }
- }
- }
-
- if (!addedPoints.contains(rcd)) {
- addedPoints.add(rcd);
- } else {
- addedPoints.remove(rcd);
- addedPoints.add(rcd);
- }
-
- noShiftCurveArray.add(rcd);
- remakeRatingCurveDataList();
-
- if (getEditingShiftData() != null) {
- if (getEditingShiftData().isActive()) {
- int index = shiftDataList.getSelectionIndex();
- generateShiftList(shiftData.get(index));
- ratingCurveCanvas.updateCurveData(shiftCurveArray,
- floodDbl, recordDbl, shiftAmount);
- } else {
- ratingCurveCanvas.updateCurveData(
- noShiftCurveArray, floodDbl, recordDbl,
- shiftAmount);
- }
- } else {
- ratingCurveCanvas.updateCurveData(noShiftCurveArray,
- floodDbl, recordDbl, shiftAmount);
- }
+ insertBaseCurvePoint(rcd);
}
}
});
@@ -769,6 +626,49 @@ public class RatingCurveDlg extends CaveSWTDialog implements IRatingCurveSort {
shiftValueTF.setEditable(true);
}
}
+
+ private void insertBaseCurvePoint(RatingCurveData rcd) {
+ if (!noShiftCurveArray.contains(rcd)) {
+ // Check for a matching stage value
+ RatingCurveData data = null;
+ for (RatingCurveData d: noShiftCurveArray) {
+ if (d.getStage() == rcd.getStage()) {
+ data = d;
+ break;
+ }
+ }
+
+ if (data != null) {
+ noShiftCurveArray.remove(data);
+ }
+
+ noShiftCurveArray.add(rcd);
+ if (!addedPoints.contains(rcd)) {
+ addedPoints.add(rcd);
+ } else {
+ addedPoints.remove(rcd);
+ addedPoints.add(rcd);
+ }
+
+ remakeRatingCurveDataList();
+
+ if (getEditingShiftData() != null) {
+ if (getEditingShiftData().isActive()) {
+ int index = shiftDataList.getSelectionIndex();
+ generateShiftList(shiftData.get(index));
+ ratingCurveCanvas.updateCurveData(shiftCurveArray,
+ floodDbl, recordDbl, shiftAmount);
+ } else {
+ ratingCurveCanvas.updateCurveData(
+ noShiftCurveArray, floodDbl, recordDbl,
+ shiftAmount);
+ }
+ } else {
+ ratingCurveCanvas.updateCurveData(noShiftCurveArray,
+ floodDbl, recordDbl, shiftAmount);
+ }
+ }
+ }
/**
* Create the controls on the right side of the dialog.
@@ -789,10 +689,17 @@ public class RatingCurveDlg extends CaveSWTDialog implements IRatingCurveSort {
createStageDischargeLabels(rightComp);
gd = new GridData(220, 400);
- shiftCurveDataList = new List(rightComp, SWT.BORDER | SWT.SINGLE
- | SWT.V_SCROLL);
+ shiftCurveDataList = new List(rightComp, SWT.BORDER | SWT.V_SCROLL);
shiftCurveDataList.setFont(controlFont);
shiftCurveDataList.setLayoutData(gd);
+ shiftCurveDataList.deselectAll();
+ shiftCurveDataList.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GRAY));
+ shiftCurveDataList.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ shiftCurveDataList.deselectAll();
+ }
+ });
gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
ratingLbl = new Label(rightComp, SWT.CENTER);
@@ -804,17 +711,6 @@ public class RatingCurveDlg extends CaveSWTDialog implements IRatingCurveSort {
| SWT.V_SCROLL);
noShiftCurveDataList.setFont(controlFont);
noShiftCurveDataList.setLayoutData(gd);
-
- if (noShiftCurveArray != null) {
- // populate the list
- for (RatingCurveData curve : noShiftCurveArray) {
- noShiftCurveDataList.add(curve.toString());
- }
- noShiftCurveDataList.setEnabled(true);
- } else {
- noShiftCurveDataList.setEnabled(false);
- }
-
noShiftCurveDataList.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
@@ -823,10 +719,27 @@ public class RatingCurveDlg extends CaveSWTDialog implements IRatingCurveSort {
stageTF.setText(String.format("%7.2f", data.getStage()));
dischargeTF
.setText(String.format("%7.1f", data.getDischarge()));
- setSelectedCurveData(data);
}
});
+ if (noShiftCurveArray != null) {
+ // populate the list
+ RatingCurveShiftData currentShift = null;
+ if (shiftData != null && shiftData.size() > 0) {
+ if (shiftData.get(0).isActive()) {
+ currentShift = shiftData.get(0);
+ }
+ }
+
+ for (RatingCurveData curve : noShiftCurveArray) {
+ noShiftCurveDataList.add(curve.toString());
+ }
+ if (noShiftCurveDataList.getItemCount() > 0) {
+ noShiftCurveDataList.select(0);
+ generateShiftList(currentShift);
+ }
+ }
+
createStageDischargeTextFields(rightComp);
}
@@ -987,7 +900,12 @@ public class RatingCurveDlg extends CaveSWTDialog implements IRatingCurveSort {
if (label != null) {
ratingLbl.setText(label);
}
-
+
+ if (noShiftCurveArray.size() > 0) {
+ RatingCurveData rcd = noShiftCurveArray.get(0);
+ this.stageTF.setText(String.valueOf(rcd.getStage()));
+ this.dischargeTF.setText(String.valueOf(rcd.getDischarge()));
+ }
}
/**
@@ -1052,10 +970,10 @@ public class RatingCurveDlg extends CaveSWTDialog implements IRatingCurveSort {
* @param rcsd
*/
public void generateShiftList(RatingCurveShiftData rcsd) {
+ shiftCurveDataList.removeAll();
if (rcsd != null) {
shiftAmount = rcsd.getValue();
- shiftCurveDataList.removeAll();
shiftCurveArray = new ArrayList();
// remake the rating curve with shift data
@@ -1067,38 +985,14 @@ public class RatingCurveDlg extends CaveSWTDialog implements IRatingCurveSort {
}
// redraw for the full effect
shiftCurveDataList.redraw();
+ } else {
+ // make the rating curve with no shift data
+ for (RatingCurveData curve : noShiftCurveArray) {
+ shiftCurveDataList.add(curve.toString());
+ }
}
}
- @Override
- public String getSortType() {
- // TODO Auto-generated method stub
- return "Stage";
- }
-
- /**
- * Sort the crest data by stage value.
- */
- public void sortByStage() {
- sortKey = sortBy.Stage;
- sortCurveData();
- }
-
- /**
- * Sort the crest data by flow value.
- */
- public void sortByDischarge() {
- sortKey = sortBy.Discharge;
- sortCurveData();
- }
-
- /**
- * Sort the curve data.
- */
- private void sortCurveData() {
- Collections.sort(noShiftCurveArray);
- }
-
/**
* Imports a rating curve
*
@@ -1268,51 +1162,101 @@ public class RatingCurveDlg extends CaveSWTDialog implements IRatingCurveSort {
RatingCurveShiftData rcsd = new RatingCurveShiftData(lid, cal,
new Double(shiftValueTF.getText()), shiftActiveChk
.getSelection());
- // remove old
- if (shiftDataList != null) {
- int index = shiftDataList.getSelectionIndex();
- if (index != -1) {
- if (rcsd.getDate().getTime().equals(
- shiftData.get(index).getDate().getTime())) {
- shiftDataList.remove(index);
- shiftData.remove(index);
- }
- } else {
- for (int i = 0; i < shiftData.size(); i++) {
- RatingCurveShiftData data = shiftData.get(i);
- if (data.getDate().getTime().equals(cal.getTime())) {
- shiftData.remove(i);
- shiftDataList.remove(i);
- i--;
- }
- }
- }
+
+ if (shiftData.size() > 0 && shiftData.contains(rcsd)) {
+ for (RatingCurveShiftData sd: shiftData) {
+ if (rcsd.toString().equals(sd.toString())) {
+ sd.setActive(rcsd.isActive());
+ sd.setDate(rcsd.getDate());
+ sd.setLid(rcsd.getLid());
+ sd.setValue(rcsd.getValue());
+ break;
+ }
+ }
+ } else {
+ shiftData.add(rcsd);
}
-
+
if (!addedCurveShifts.contains(rcsd)) {
- addedCurveShifts.add(rcsd);
+ addedCurveShifts.add(rcsd);
} else {
- addedCurveShifts.remove(rcsd);
- addedCurveShifts.add(rcsd);
+ addedCurveShifts.remove(rcsd);
+ addedCurveShifts.add(rcsd);
}
- shiftData.add(rcsd);
- shiftDataList.add(getShiftListString(rcsd));
- shiftDataList.redraw();
+ shiftDataList.removeAll();
+ Collections.sort(shiftData);
- if (shiftActiveChk.getSelection()) {
- generateShiftList(rcsd);
- ratingCurveCanvas.updateCurveData(shiftCurveArray,
- floodDbl, recordDbl, shiftAmount);
+ for (RatingCurveShiftData sd: shiftData) {
+ shiftDataList.add(getShiftListString(sd));
+ }
+
+ // Display the latest shift
+ RatingCurveShiftData currentShift = shiftData.get(0);
+ if (currentShift.isActive()) {
+ generateShiftList(currentShift);
+ ratingCurveCanvas.updateCurveData(shiftCurveArray,
+ floodDbl, recordDbl, currentShift.getValue());
} else {
- ratingCurveCanvas.updateCurveData(noShiftCurveArray,
- floodDbl, recordDbl, shiftAmount);
+ ratingCurveCanvas.updateCurveData(noShiftCurveArray,
+ floodDbl, recordDbl, 0);
}
}
+
+ shiftValueTF.setText("");
+ shiftDateTF.setText("");
+ shiftActiveChk.setSelection(false);
} catch (Exception e) {
e.printStackTrace();
}
}
+
+ private void removeShift() {
+ if (shiftDataList.getItemCount() > 0 && shiftDataList.getSelectionCount() > 0) {
+ MessageBox messageDialog = new MessageBox(shell, SWT.OK | SWT.CANCEL);
+ messageDialog.setText("Shift Remove Confirmation");
+ messageDialog.setMessage("This will remove the highlighted shift.");
+ int response = messageDialog.open();
+
+ if (response == SWT.OK) {
+ String selection = shiftDataList.getItem(shiftDataList.getSelectionIndex());
+ for (RatingCurveShiftData sd: shiftData) {
+ if (getShiftListString(sd).equals(selection)) {
+ removedCurveShifts.add(sd);
+ break;
+ }
+ }
+
+ shiftData.removeAll(removedCurveShifts);
+ shiftDataList.removeAll();
+ Collections.sort(shiftData);
+ for (RatingCurveShiftData rcsd : shiftData) {
+ shiftDataList.add(getShiftListString(rcsd));
+ }
+ shiftDataList.redraw();
+
+ if (shiftData.size() > 0) {
+ shiftAmount = shiftData.get(0).getValue();
+ } else {
+ shiftAmount = 0;
+ }
+
+ ratingCurveCanvas.updateCurveData(noShiftCurveArray,
+ floodDbl, recordDbl, shiftAmount);
+
+ if (shiftData.size() > 0) {
+ RatingCurveShiftData currentShift = shiftData.get(0);
+ if (currentShift.isActive()) {
+ generateShiftList(currentShift);
+ } else {
+ generateShiftList(null);
+ }
+ } else {
+ generateShiftList(null);
+ }
+ }
+ }
+ }
/**
* Verify validity of input
@@ -1371,44 +1315,40 @@ public class RatingCurveDlg extends CaveSWTDialog implements IRatingCurveSort {
return selectedRatingShift;
}
- /**
- * set the current curve shift
- *
- * @param selectedRatingShift
- */
- private void setSelectedShift(RatingCurveShiftData selectedRatingShift) {
- this.selectedRatingShift = selectedRatingShift;
- }
-
- /**
- * Get the editing curve data
- *
- * @return
- */
- private RatingCurveData getEditingCurveData() {
- return selectedRatingPoint;
- }
-
- /**
- * Sets the selected curve data
- *
- * @param selectedRatingPoint
- */
- private void setSelectedCurveData(RatingCurveData selectedRatingPoint) {
- this.selectedRatingPoint = selectedRatingPoint;
- }
-
/**
* update the noShiftCurveDataList
*/
private void remakeRatingCurveDataList() {
-
- sortCurveData();
+ Collections.sort(noShiftCurveArray);
+ int index = noShiftCurveDataList.getSelectionIndex();
noShiftCurveDataList.removeAll();
+ shiftCurveDataList.removeAll();
for (RatingCurveData rcd : noShiftCurveArray) {
noShiftCurveDataList.add(rcd.toString());
}
- noShiftCurveDataList.redraw();
+
+ if (shiftData.size() > 0) {
+ RatingCurveShiftData currentShift = shiftData.get(0);
+ if (currentShift.isActive()) {
+ generateShiftList(currentShift);
+ } else {
+ remakeRatingCurveDataList();
+ }
+ } else {
+ remakeRatingCurveDataList();
+ }
+
+ if (noShiftCurveDataList.getItemCount() > 0) {
+ if (index >= noShiftCurveDataList.getItemCount()) {
+ noShiftCurveDataList.select(noShiftCurveDataList.getItemCount() - 1);
+ } else if (index >= 0 && index < noShiftCurveArray.size()) {
+ noShiftCurveDataList.select(index);
+ } else {
+ noShiftCurveDataList.select(0);
+ }
+ noShiftCurveDataList.showSelection();
+
+ }
}
/**
diff --git a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/ratingcurve/RatingCurveShiftData.java b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/ratingcurve/RatingCurveShiftData.java
index 564b6474d3..756993d02f 100644
--- a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/ratingcurve/RatingCurveShiftData.java
+++ b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/ratingcurve/RatingCurveShiftData.java
@@ -40,7 +40,7 @@ import java.util.TimeZone;
* @version 1.0
*/
-public class RatingCurveShiftData {
+public class RatingCurveShiftData implements Comparable {
private String lid = null;
@@ -90,18 +90,34 @@ public class RatingCurveShiftData {
public String getLid() {
return lid;
}
+
+ public void setLid(String lid) {
+ this.lid = lid;
+ }
public Calendar getDate() {
return date;
}
+
+ public void setDate(Calendar date) {
+ this.date = date;
+ }
public double getValue() {
return value;
}
+ public void setValue(double value) {
+ this.value = value;
+ }
+
public boolean isActive() {
return active;
}
+
+ public void setActive(boolean active) {
+ this.active = active;
+ }
/**
* Get the date in a MM/DD/YYYY format.
@@ -125,4 +141,16 @@ public class RatingCurveShiftData {
return sb.toString();
}
+
+ @Override
+ public int compareTo(RatingCurveShiftData o) {
+ if (this.date.getTime().equals(o.getDate().getTime())) {
+ return 0;
+ } else if (this.date.getTime().before(o.getDate().getTime())) {
+ return 1;
+ } else if (this.date.getTime().after(o.getDate().getTime())) {
+ return -1;
+ }
+ return 0;
+ }
}
diff --git a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/resource/FFGGridResource.java b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/resource/FFGGridResource.java
index 4afad9088b..6d12ba1311 100644
--- a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/resource/FFGGridResource.java
+++ b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/resource/FFGGridResource.java
@@ -141,7 +141,7 @@ public class FFGGridResource extends
String user_id = System.getProperty("user.name");
this.duration = data.getDuration();
colorSet = HydroDisplayManager.getInstance().getFFGColorMap(user_id,
- "FFG", duration * 60 * 1000);
+ "FFG", duration);
loadData();
}
@@ -260,7 +260,7 @@ public class FFGGridResource extends
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
int hours = this.resourceData.getDuration()
- / HydroConstants.MILLIS_PER_HOUR;
+ / HydroConstants.SECONDS_PER_HOUR;
String hourStr = "hour";
if (hours != 1) {
hourStr = hourStr.concat("s");
diff --git a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/whfslib/GagePPWrite.java b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/whfslib/GagePPWrite.java
index 0b00304560..40267ea053 100644
--- a/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/whfslib/GagePPWrite.java
+++ b/cave/com.raytheon.viz.hydrocommon/src/com/raytheon/viz/hydrocommon/whfslib/GagePPWrite.java
@@ -54,6 +54,7 @@ import com.raytheon.viz.hydrocommon.whfslib.GagePPOptions.upd_action;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 5, 2008 1649 snaples Initial creation
+ * Aug 8, 2012 15271 snaples Updated hourly slot
*
*
*
@@ -140,12 +141,6 @@ public final class GagePPWrite {
String obstime = sdf.format(dto);
GagePPOptions opts = options;
int hr = dt.get(Calendar.HOUR_OF_DAY);
- if (hr == 0) {
- hr = 24;
- dt.add(Calendar.HOUR_OF_DAY, -1);
- obstime = sdf.format(dt);
- dto = dt.getTime();
- }
int min = dt.get(Calendar.MINUTE);
char sixhroffset = get_offset_code(min);
char sixhrqc = 'M';
@@ -212,7 +207,7 @@ public final class GagePPWrite {
pHourpp.setSixhroffset(String.valueOf(sixhr_offset));
pHourpp.setSixhrqc(String.valueOf(sixhr_qc));
set_hour_slot_value(pHourpp, hr, new_hourly_value);
- set_6hour_slot_value(pHourpp, six + 1, pp_value);
+ set_6hour_slot_value(pHourpp, six, pp_value);
update_gage_rec(pHourpp);
}
@@ -283,7 +278,7 @@ public final class GagePPWrite {
if (hpp.getSixhrqc() != null) {
old_six_qc = hpp.getSixhrqc().toCharArray();
}
- Short sixval = get_6hour_slot_value(hpp, six + 1);
+ Short sixval = get_6hour_slot_value(hpp, six);
prev_sixhroff = old_sixhroffset[six];
prev_sixqc = old_six_qc[six];
@@ -363,7 +358,7 @@ public final class GagePPWrite {
pHourpp.setSixhroffset(String.valueOf(sixhr_offset));
pHourpp.setSixhrqc(String.valueOf(six_hr_qc));
set_hour_slot_value(pHourpp, hr, hr_value);
- set_6hour_slot_value(pHourpp, six + 1, six_hr_slot_val);
+ set_6hour_slot_value(pHourpp, six, six_hr_slot_val);
update_gage_rec(pHourpp);
}
}
@@ -733,22 +728,22 @@ public final class GagePPWrite {
* the HourPC structure.
*/
switch (hour) {
- case 1: /* 00z - 06z */
+ case 0: /* 00z - 06z */
precip_value = pHourlyPP.getSixhr06();
break;
- case 2: /* 06z - 12z */
+ case 1: /* 06z - 12z */
precip_value = pHourlyPP.getSixhr12();
break;
- case 3: /* 12z - 18z */
+ case 2: /* 12z - 18z */
precip_value = pHourlyPP.getSixhr18();
break;
- case 4: /* 18z - 00z */
+ case 3: /* 18z - 00z */
precip_value = pHourlyPP.getSixhr24();
break;
@@ -773,25 +768,25 @@ public final class GagePPWrite {
* the HourPC structure.
*/
switch (hour) {
- case 1: /* 00z - 06z */
+ case 0: /* 00z - 06z */
precip_value = new Short((short) val);
pHourlyPP.setSixhr06(precip_value);
break;
- case 2: /* 06z - 12z */
+ case 1: /* 06z - 12z */
precip_value = new Short((short) val);
pHourlyPP.setSixhr12(precip_value);
break;
- case 3: /* 12z - 18z */
+ case 2: /* 12z - 18z */
precip_value = new Short((short) val);
pHourlyPP.setSixhr18(precip_value);
break;
- case 4: /* 18z - 00z */
+ case 3: /* 18z - 00z */
precip_value = new Short((short) val);
pHourlyPP.setSixhr24(precip_value);
@@ -927,7 +922,7 @@ public final class GagePPWrite {
precip_value = pHourlyPP.getHour23();
break;
- case 24:
+ case 0:
precip_value = pHourlyPP.getHour24();
break;
@@ -1068,12 +1063,13 @@ public final class GagePPWrite {
pHourly.setHour23(precip_value);
break;
- case 24:
+ case 0:
precip_value = new Short((short) val);
pHourly.setHour24(precip_value);
break;
default:
+ precip_value = new Short((short) MISSING_PRECIP);
break;
}
diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/MPEDisplayManager.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/MPEDisplayManager.java
index 4c06832a89..7c51dc064c 100644
--- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/MPEDisplayManager.java
+++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/MPEDisplayManager.java
@@ -104,6 +104,7 @@ import com.raytheon.viz.ui.editor.IMultiPaneEditor;
* Dec 1, 2008 1748 snaples Added enum for Gage Color
* Aug 11, 2010 5733 jwang Removed Polygon Edit and Gages
* legend from MPE perspective
+ * Aug 8, 2012 15271 snaples Updated hourly slot
*
*
* @author randerso
@@ -536,7 +537,7 @@ public class MPEDisplayManager {
clearMPEData();
try {
dm.readRadarData(newDate);
- dm.readGageData(newDate);
+ dm.readGageData(newDate, newDate);
if (gageTableDlg != null) {
gageTableDlg.updateDate(newDate);
diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/gagetable/GageTableDlg.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/gagetable/GageTableDlg.java
index c4f37e91d2..019cd22112 100644
--- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/gagetable/GageTableDlg.java
+++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/dialogs/gagetable/GageTableDlg.java
@@ -586,8 +586,6 @@ public class GageTableDlg extends JFrame {
int columnCount = table.getModel().getColumnCount();
- // List columnList = null;
- // columnList = dataManager.getColumnDataList();
ColumnHeaderToolTips tips = new ColumnHeaderToolTips();
for (int i = 0; i < columnCount; i++) {
@@ -636,7 +634,6 @@ public class GageTableDlg extends JFrame {
Vector> data = model.getDataVector();
Collections.sort(data, new ColumnSorter(colIndex, ascending));
model.setDataVector(data);
- // model.fireTableStructureChanged();
}
/**
@@ -766,8 +763,7 @@ public class GageTableDlg extends JFrame {
GageTableSettings settings = null;
if (f.exists()) {
-// settings = JAXB.unmarshal(path, GageTableSettings.class);
- settings = JAXB.unmarshal(f, GageTableSettings.class);
+ settings = JAXB.unmarshal(f, GageTableSettings.class);
} else {
settings = getDefaultSettings();
}
@@ -817,7 +813,6 @@ public class GageTableDlg extends JFrame {
dataManager.setColumnDataList(columnDataList);
dataManager.setColumnWidthMap(columnWidthMap);
} catch (Exception e) {
- e.printStackTrace();
System.out.println("MPE Settings file not found");
}
}
diff --git a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEGageResource.java b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEGageResource.java
index 2e79a7355e..69baa84367 100644
--- a/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEGageResource.java
+++ b/cave/com.raytheon.viz.mpe.ui/src/com/raytheon/viz/mpe/ui/rsc/MPEGageResource.java
@@ -94,6 +94,7 @@ import com.vividsolutions.jts.index.strtree.STRtree;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 8, 2011 mschenke Initial creation
+ * Aug 8, 2012 15271 snaples Updated hourly slot
*
*
*
@@ -152,7 +153,7 @@ public class MPEGageResource extends AbstractMPEInputResource {
fontFactory = new MPEFontFactory(target, this);
loadColors();
lastDate = displayMgr.getCurrentDate();
- addPoints(MPEDataManager.getInstance().readGageData(lastDate));
+ addPoints(MPEDataManager.getInstance().readGageData(lastDate, lastDate));
}
@Override
@@ -206,7 +207,7 @@ public class MPEGageResource extends AbstractMPEInputResource {
synchronized (mutex) {
if (curDate != null && curDate.equals(lastDate) == false) {
lastDate = curDate;
- addPoints(MPEDataManager.getInstance().readGageData(lastDate));
+ addPoints(MPEDataManager.getInstance().readGageData(lastDate, lastDate));
}
}
diff --git a/cave/com.raytheon.viz.mpe/src/com/raytheon/viz/mpe/core/MpeFieldGenJob.java b/cave/com.raytheon.viz.mpe/src/com/raytheon/viz/mpe/core/MpeFieldGenJob.java
index 0da0eb648c..5117cb61ea 100644
--- a/cave/com.raytheon.viz.mpe/src/com/raytheon/viz/mpe/core/MpeFieldGenJob.java
+++ b/cave/com.raytheon.viz.mpe/src/com/raytheon/viz/mpe/core/MpeFieldGenJob.java
@@ -47,6 +47,7 @@ import com.raytheon.viz.mpe.Activator;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 1/08/09 1674 bphillip Initial creation
+ * 08/09/12 15307 snaples Updated job to use postStreamingByteArray.
*
*
* @author bphillip
@@ -78,11 +79,12 @@ public class MpeFieldGenJob extends Job {
protected IStatus run(IProgressMonitor monitor) {
final Integer[] mpeExitValue = new Integer[1];
- String httpAddress = VizApp.getHttpServer();
-
+ String httpAddress = VizApp.getHttpServer() + ENDPOINT_NAME;
+ String args = fieldGenArg;
+ byte[] ba = args.getBytes();
+
try {
- HttpClient.getInstance().postStreamingString(
- httpAddress + ENDPOINT_NAME, fieldGenArg,
+ HttpClient.getInstance().postStreamingByteArray(httpAddress, ba,
new HttpClient.IStreamHandler() {
/*
@@ -113,15 +115,7 @@ public class MpeFieldGenJob extends Job {
return new Status(Status.ERROR, Activator.PLUGIN_ID,
"MPE Field Gen execution failed with exit code: "
+ mpeExitValue[0]);
- } catch (UnsupportedEncodingException e) {
- // TODO Auto-generated catch block. Please revise as appropriate.
- handler.handle(Priority.CRITICAL, e.getLocalizedMessage(), e);
-
- // copied from above
- return new Status(Status.ERROR, Activator.PLUGIN_ID,
- "MPE Field Gen execution failed with exit code: "
- + mpeExitValue[0]);
- }
+ }
if (mpeExitValue[0] != null && mpeExitValue[0] == 0) {
return Status.OK_STATUS;
diff --git a/cave/com.raytheon.viz.mpe/src/com/raytheon/viz/mpe/core/RegenHrFlds.java b/cave/com.raytheon.viz.mpe/src/com/raytheon/viz/mpe/core/RegenHrFlds.java
index e5838698b4..e8cdad8fc6 100644
--- a/cave/com.raytheon.viz.mpe/src/com/raytheon/viz/mpe/core/RegenHrFlds.java
+++ b/cave/com.raytheon.viz.mpe/src/com/raytheon/viz/mpe/core/RegenHrFlds.java
@@ -54,6 +54,7 @@ import com.raytheon.viz.mpe.core.MPEDataManager.MPEGageData;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 30, 2008 snaples Initial creation
+ * Aug 8, 2012 15271 snaples Updated hourly slot
*
*
* @author snaples
@@ -301,7 +302,7 @@ public class RegenHrFlds {
e.printStackTrace();
}
- MPEDataManager.getInstance().readGageData(datetime);
+ MPEDataManager.getInstance().readGageData(datetime, datetime);
/* Read radar data */
MPEDataManager.getInstance().readRadarData(datetime);
MPEDataManager.getInstance().clearEditGages();
diff --git a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotResource.java b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotResource.java
index d0feff35d4..fa0e6bccf3 100644
--- a/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotResource.java
+++ b/cave/com.raytheon.viz.pointdata/src/com/raytheon/viz/pointdata/rsc/PlotResource.java
@@ -85,6 +85,9 @@ import com.vividsolutions.jts.geom.Envelope;
* 04/13/2009 2251 jsanchez Plot profilers.
* 05/12/2009 2338 jsanchez Updated resourceChanged. Registered units.
* 06/08/2009 2450 jsanchez Updated inpsect method to find closest plot.
+ * ======================================
+ * AWIPS2 DR Work
+ * 08/09/2012 1011 jkorman Added screenToWorldRatio calc to paintInternal.
*
*
*
@@ -230,6 +233,8 @@ public class PlotResource extends
if (this.stationsToParse.size() > 0) {
this.updateRecords();
}
+ this.screenToWorldRatio = paintProps.getCanvasBounds().width
+ / paintProps.getView().getExtent().getWidth();
boolean delayLoop = false;
DataTime thisFrameTime = this.displayedObsTime;
if (thisFrameTime != null) {
@@ -847,14 +852,18 @@ public class PlotResource extends
ArrayList availableCoord) {
double x1 = latlon.x;
double y1 = latlon.y;
- double minDistance = MAX_SAMPLE_DISANCE;
+// double minDistance = MAX_SAMPLE_DISANCE;
+ double minDistance = MAX_SAMPLE_DISANCE * MAX_SAMPLE_DISANCE;
int minIndex = -1;
for (int i = 0; i < availableCoord.size(); i++) {
Coordinate coord = availableCoord.get(i);
double x2 = coord.x;
double y2 = coord.y;
- double d = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
+// double d = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
+ double dx = x2 - x1;
+ double dy = y2 - y1;
+ double d = (dx * dx) + (dy * dy);
if (d < minDistance) {
minDistance = d;
diff --git a/cave/com.raytheon.viz.radar/localization/menus/radar/baseTerminal4Panel.xml b/cave/com.raytheon.viz.radar/localization/menus/radar/baseTerminal4Panel.xml
index 969d6942df..b6a428a02d 100644
--- a/cave/com.raytheon.viz.radar/localization/menus/radar/baseTerminal4Panel.xml
+++ b/cave/com.raytheon.viz.radar/localization/menus/radar/baseTerminal4Panel.xml
@@ -24,8 +24,8 @@
@@ -38,17 +38,17 @@
-
-
-
-
+
+
+
+
@@ -61,10 +61,10 @@
-
-
-
-
+
+
+
+
-
\ No newline at end of file
+
diff --git a/cave/com.raytheon.viz.radar/localization/menus/radar/baseTerminalReflVel.xml b/cave/com.raytheon.viz.radar/localization/menus/radar/baseTerminalReflVel.xml
index 149cf60dc8..a4158266f6 100644
--- a/cave/com.raytheon.viz.radar/localization/menus/radar/baseTerminalReflVel.xml
+++ b/cave/com.raytheon.viz.radar/localization/menus/radar/baseTerminalReflVel.xml
@@ -29,17 +29,7 @@
-
-
-
-
-
-
-
-
-
-
+
@@ -289,20 +279,10 @@
-
+
-
-
-
-
-
-
-
-
-
@@ -552,7 +532,7 @@
-
+
-
\ No newline at end of file
+
diff --git a/cave/com.raytheon.viz.radar/localization/menus/radar/baseTerminalReflectivityMotion.xml b/cave/com.raytheon.viz.radar/localization/menus/radar/baseTerminalReflectivityMotion.xml
index 6c36c917d4..d98f3891e1 100644
--- a/cave/com.raytheon.viz.radar/localization/menus/radar/baseTerminalReflectivityMotion.xml
+++ b/cave/com.raytheon.viz.radar/localization/menus/radar/baseTerminalReflectivityMotion.xml
@@ -21,22 +21,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -443,22 +427,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -862,4 +830,4 @@
-
\ No newline at end of file
+
diff --git a/cave/com.raytheon.viz.radar/localization/menus/radar/baseTerminalSRMSpecWidth.xml b/cave/com.raytheon.viz.radar/localization/menus/radar/baseTerminalSRMSpecWidth.xml
index c000445c52..bc2752d053 100644
--- a/cave/com.raytheon.viz.radar/localization/menus/radar/baseTerminalSRMSpecWidth.xml
+++ b/cave/com.raytheon.viz.radar/localization/menus/radar/baseTerminalSRMSpecWidth.xml
@@ -21,16 +21,6 @@
-
-
-
-
-
-
-
-
-
@@ -284,12 +274,6 @@
-
-
-
-
-
@@ -435,4 +419,4 @@
-
\ No newline at end of file
+
diff --git a/cave/com.raytheon.viz.satellite/localization/bundles/DefaultSatellite.xml b/cave/com.raytheon.viz.satellite/localization/bundles/DefaultSatellite.xml
index f484bc9e18..378e53b0e6 100644
--- a/cave/com.raytheon.viz.satellite/localization/bundles/DefaultSatellite.xml
+++ b/cave/com.raytheon.viz.satellite/localization/bundles/DefaultSatellite.xml
@@ -34,7 +34,6 @@
- 12
diff --git a/cave/com.raytheon.viz.satellite/localization/bundles/DerivedPOESSatellite.xml b/cave/com.raytheon.viz.satellite/localization/bundles/DerivedPOESSatellite.xml
index 9eb5f9b308..7c19d6c02e 100644
--- a/cave/com.raytheon.viz.satellite/localization/bundles/DerivedPOESSatellite.xml
+++ b/cave/com.raytheon.viz.satellite/localization/bundles/DerivedPOESSatellite.xml
@@ -31,7 +31,6 @@
- 12
diff --git a/cave/com.raytheon.viz.satellite/localization/bundles/DerivedSatellite.xml b/cave/com.raytheon.viz.satellite/localization/bundles/DerivedSatellite.xml
index fc3f481e85..5898a9cc83 100644
--- a/cave/com.raytheon.viz.satellite/localization/bundles/DerivedSatellite.xml
+++ b/cave/com.raytheon.viz.satellite/localization/bundles/DerivedSatellite.xml
@@ -37,7 +37,6 @@
- 12
diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/AfosBrowserModel.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/AfosBrowserModel.java
index 5df303dc08..0c9b3c9f1c 100755
--- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/AfosBrowserModel.java
+++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/AfosBrowserModel.java
@@ -64,7 +64,10 @@ import com.raytheon.uf.viz.core.localization.LocalizationManager;
* 11/8/2007 520 grichard Implemented build 11 features.
* 11/26/2007 520 grichard Implemented SuperSite in preparation for JiBX'ng.
* 12/14/2007 582 grichard Implemented build 12 features.
- *
+ * ======================================
+ * AWIPS2 DR Work
+ * 07/24/2012 939 jkorman Modified parseAfosMasterPil() handle blank lines as well
+ * as lines with trailing whitespace.
*
*
* @author grichard
@@ -73,6 +76,21 @@ public final class AfosBrowserModel {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(AfosBrowserModel.class);
+ // Need at least this many characters in an afosMasterPIL entry
+ // Need the CCCNNN and at least a 1 character XXX
+ private static final int MIN_MASTPIL_LEN = 7;
+ // but no more than 9 characters.
+ private static final int MAX_MASTPIL_LEN = 9;
+
+ private static final int CCC_PIL_POS = 0;
+
+ private static final int NNN_PIL_POS = 3;
+
+ private static final int XXX_PIL_POS = 6;
+
+ private static final String SITE_WILDCARD = "@@@";
+
+ private static final String COMMENT_DELIM = "#";
/**
* The VTEC Afos Product enumeration
*/
@@ -265,7 +283,7 @@ public final class AfosBrowserModel {
br = new BufferedReader(new FileReader(fileToParse));
while ((line = br.readLine()) != null) {
// skip comments.
- if (line.startsWith("#")) {
+ if (line.startsWith(COMMENT_DELIM)) {
continue;
}
@@ -294,7 +312,7 @@ public final class AfosBrowserModel {
br = new BufferedReader(new FileReader(fileToParse));
while ((line = br.readLine()) != null) {
// skip comments.
- if (line.startsWith("#")) {
+ if (line.startsWith(COMMENT_DELIM)) {
continue;
}
@@ -324,7 +342,7 @@ public final class AfosBrowserModel {
br = new BufferedReader(new FileReader(fileToParse));
while ((line = br.readLine()) != null) {
// skip comments.
- if (line.startsWith("#")) {
+ if (line.startsWith(COMMENT_DELIM)) {
continue;
}
@@ -351,42 +369,69 @@ public final class AfosBrowserModel {
return cccOriginMap;
}
+ /**
+ * Read and parse an afos PIL list. In the event of processing multiple
+ * files, the most recent entry overwrites a current entry.
+ *
+ * @param fileToParse
+ * File reference containing the PIL list.
+ */
private void parseAfosMasterPil(File fileToParse) {
if (fileToParse != null && fileToParse.exists()) {
BufferedReader br = null;
String line = null;
+ String localCCC = SiteMap.getInstance()
+ .getCCCFromXXXCode(localSite);
try {
br = new BufferedReader(new FileReader(fileToParse));
while ((line = br.readLine()) != null) {
- // skip comments.
- if (line.startsWith("#")) {
+ // Remove any trailing spaces.
+ line = line.trim();
+ // skip blank lines or comments.
+ if ((line.length() == 0) || line.startsWith(COMMENT_DELIM)) {
continue;
}
- String ccc = line.substring(0, 3);
+ if (line.length() >= MIN_MASTPIL_LEN) {
+ String ccc = line.substring(CCC_PIL_POS, NNN_PIL_POS);
+ if (ccc.equals(SITE_WILDCARD)) {
+ ccc = localCCC;
+ }
+ String nnn = line.substring(NNN_PIL_POS, XXX_PIL_POS);
+ String xxx;
+ if(line.length() > MAX_MASTPIL_LEN) {
+ // Only take the first 9 characters of the line.
+ // Trim in case there are any internal spaces.
+ xxx = line.substring(XXX_PIL_POS, MAX_MASTPIL_LEN + 1).trim();
+ } else {
+ // Just grab the remainder of the input line.
+ // Its already been trimmed.
+ xxx = line.substring(6);
+ }
- if (ccc.equals("@@@")) {
- ccc = SiteMap.getInstance()
- .getCCCFromXXXCode(localSite);
+ Map> nnnxxx = masterPil
+ .get(ccc);
+ if (nnnxxx == null) {
+ nnnxxx = new HashMap>();
+ masterPil.put(ccc, nnnxxx);
+ }
+
+ SortedSet xxxList = nnnxxx.get(nnn);
+ if (xxxList == null) {
+ xxxList = new TreeSet();
+ nnnxxx.put(nnn, xxxList);
+ }
+
+ xxxList.add(xxx);
+ } else {
+ String msg = String.format(
+ "Line [%s] in file %s incorrect", line,
+ fileToParse.getPath());
+
+ statusHandler.handle(Priority.SIGNIFICANT, msg);
}
- String nnn = line.substring(3, 6);
- String xxx = line.substring(6);
-
- Map> nnnxxx = masterPil.get(ccc);
- if (nnnxxx == null) {
- nnnxxx = new HashMap>();
- masterPil.put(ccc, nnnxxx);
- }
-
- SortedSet xxxList = nnnxxx.get(nnn);
- if (xxxList == null) {
- xxxList = new TreeSet();
- nnnxxx.put(nnn, xxxList);
- }
-
- xxxList.add(xxx);
} // while
} catch (IOException e) {
statusHandler.handle(Priority.PROBLEM,
@@ -519,7 +564,7 @@ public final class AfosBrowserModel {
public boolean contains(String ccc, String nnn, String xxx) {
boolean rval = false;
Map> catMap = masterPil.get(ccc);
- if (catMap != null) {
+ if ((catMap != null) && (xxx != null)) {
SortedSet desList = catMap.get(nnn);
if (desList != null) {
rval = desList.contains(xxx);
diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertBell.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertBell.java
index 18d5075f78..099e8c73c6 100644
--- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertBell.java
+++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertBell.java
@@ -67,6 +67,7 @@ import com.raytheon.viz.texteditor.alarmalert.util.FlashBellJob;
* Dec 23, 2010 7375 cjeanbap Force dialog ON TOP of over Dialog/Windows.
* 03/19/2012 D. Friedman Fix alarming. Disable runloop in open().
* May 18, 2012 jkorman Added flashing alarm image.
+ * Jul 25, 2012 15122 rferrel Add sound delay interval.
*
*
* @author mnash
@@ -75,10 +76,15 @@ import com.raytheon.viz.texteditor.alarmalert.util.FlashBellJob;
public class AlarmAlertBell extends Dialog implements MouseMoveListener,
MouseListener {
-
+
// delay in milliseconds - flash every 1 1/2 seconds
private static final int FLASH_DELAY = 1500;
-
+
+ /**
+ * Repeat the alarm sound every minute.
+ */
+ private static final long SOUND_DELAY = 60 * 1000L;
+
private Shell parentShell;
private Shell alarmShell;
@@ -90,15 +96,15 @@ public class AlarmAlertBell extends Dialog implements MouseMoveListener,
private String bellPath;
private FlashBellJob flasher;
-
+
private Image norm_bell;
private Image revs_bell;
private boolean invert = false;
-
+
private boolean active = false;
-
+
private Button button;
private AlarmBeepJob abj = null;
@@ -196,9 +202,9 @@ public class AlarmAlertBell extends Dialog implements MouseMoveListener,
}
public Object open(boolean alarm) {
- if (alarm) {
+ if (alarm && abj == null) {
// provides the beep to alert the user that an alarm has come in
- abj = new AlarmBeepJob("AlarmBeepJob");
+ abj = new AlarmBeepJob("AlarmBeepJob", SOUND_DELAY);
abj.schedule();
}
@@ -216,28 +222,33 @@ public class AlarmAlertBell extends Dialog implements MouseMoveListener,
alarmShell.setActive();
active = true;
// Start a new flash job only if one isn't currently running!
- if(flasher == null) {
+ if (flasher == null) {
invert = false;
flasher = new FlashBellJob("FlashBell", this, FLASH_DELAY);
}
+
return null;
}
/**
- * Close the AlarmAlertBell and turn off the "flasher" job
- * if running.
+ * Close the AlarmAlertBell and turn off the "flasher" and "abj" job if
+ * running.
*/
public void close() {
- if(!alarmShell.isDisposed()) {
+ if (!alarmShell.isDisposed()) {
alarmShell.setVisible(false);
}
active = false;
- if(flasher != null) {
+ if (flasher != null) {
flasher.cancel();
flasher = null;
}
+ if (abj != null) {
+ abj.cancel();
+ abj = null;
+ }
}
-
+
private void setInitialDialogLocation() {
if (locationX < 0) {
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
@@ -263,7 +274,7 @@ public class AlarmAlertBell extends Dialog implements MouseMoveListener,
bellPath = imageFile.getFile().getAbsolutePath();
norm_bell = new Image(display, bellPath);
button = new Button(alarmShell, SWT.IMAGE_GIF);
- if(norm_bell != null) {
+ if (norm_bell != null) {
createInvertImage(bellPath);
button.setImage(norm_bell);
}
@@ -330,12 +341,12 @@ public class AlarmAlertBell extends Dialog implements MouseMoveListener,
private void createInvertImage(String path) {
if (norm_bell != null) {
ImageData id = new ImageData(path);
- for(int i = 0;i < id.width;i++) {
- for(int j = 0;j < id.height;j++) {
- if(id.getPixel(i,j) == 0) {
- id.setPixel(i,j,1);
+ for (int i = 0; i < id.width; i++) {
+ for (int j = 0; j < id.height; j++) {
+ if (id.getPixel(i, j) == 0) {
+ id.setPixel(i, j, 1);
} else {
- id.setPixel(i,j,0);
+ id.setPixel(i, j, 0);
}
}
}
@@ -345,17 +356,18 @@ public class AlarmAlertBell extends Dialog implements MouseMoveListener,
/**
* Check to see if the dialog is active.
+ *
* @return
*/
public boolean isActive() {
return active;
}
-
+
/**
* Alternate between normal and reverse images.
*/
public void flash() {
- if(invert) {
+ if (invert) {
button.setImage(revs_bell);
} else {
button.setImage(norm_bell);
diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertSaveLoadDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertSaveLoadDlg.java
index ee467d4ba4..d36cf44d40 100644
--- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertSaveLoadDlg.java
+++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmAlertSaveLoadDlg.java
@@ -20,6 +20,7 @@
package com.raytheon.viz.texteditor.alarmalert.dialogs;
import java.io.File;
+import java.util.ArrayList;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
@@ -37,6 +38,10 @@ import org.eclipse.swt.widgets.Text;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationFile;
import com.raytheon.uf.common.localization.PathManagerFactory;
+import com.raytheon.uf.common.localization.exception.LocalizationOpFailedException;
+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.viz.texteditor.alarmalert.util.AlarmAlertFunctions;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
@@ -49,6 +54,10 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 17, 2009 mnash Initial creation
+ * ======================================
+ * AWIPS2 DR Work
+ * 07/25/2012 953 jkorman Modified file "search" to return LocalizationFile
+ * instead of File so references are deleted in all locations.
*
*
*
@@ -58,6 +67,9 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
public class AlarmAlertSaveLoadDlg extends CaveSWTDialog {
+ private static final transient IUFStatusHandler statusHandler = UFStatus
+ .getHandler(AlarmAlertSaveLoadDlg.class);
+
private Font font;
private Composite shellComp;
@@ -136,13 +148,21 @@ public class AlarmAlertSaveLoadDlg extends CaveSWTDialog {
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
lists.setLayoutData(gd);
LocalizationContext lc = AlarmAlertFunctions.initUserLocalization();
- LocalizationFile fileDir = PathManagerFactory.getPathManager()
- .getLocalizationFile(lc, "alarms");
- File file = fileDir.getFile();
- final File[] fileList = file.listFiles();
- for (File locFile : fileList) {
- if (locFile.getName().endsWith(".xml")) {
- lists.add(locFile.getName());
+
+ // Get a list of localization files!
+ LocalizationFile[] fList = PathManagerFactory.getPathManager()
+ .listFiles(lc, "alarms", new String[] { "xml" }, false, true);
+
+ final java.util.List fileList = new ArrayList();
+ for (LocalizationFile locFile : fList) {
+ // We only want the filename in the display list.
+ String[] s = locFile.getName().split("/");
+ // Make sure we have some data!
+ if (s.length > 0) {
+ // The last element is the filename.
+ lists.add(s[s.length - 1]);
+ // Complete file reference here.
+ fileList.add(locFile);
}
}
@@ -170,17 +190,30 @@ public class AlarmAlertSaveLoadDlg extends CaveSWTDialog {
// loads the
loadButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
+ // Set the filename to be returned through getFileName()
fileName = lists.getSelection()[0];
- // TODO load the file
shell.close();
}
});
- // delete the file from the list and from the file system
+ // delete the file from the display list and from the file system
deleteButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
int num = lists.getSelectionIndex();
- fileList[num].delete();
+ LocalizationFile f = fileList.get(num);
+ try {
+ if (!f.delete()) {
+ String msg = String.format(
+ "ALARM/ALERT:Failed deleting file %s", f
+ .getFile().getPath());
+ statusHandler.handle(Priority.PROBLEM, msg);
+ }
+ } catch (LocalizationOpFailedException e) {
+ String msg = String.format(
+ "ALARM/ALERT:Failed deleting file %s", f.getFile()
+ .getPath());
+ statusHandler.handle(Priority.PROBLEM, msg, e);
+ }
lists.remove(num);
}
});
@@ -250,8 +283,8 @@ public class AlarmAlertSaveLoadDlg extends CaveSWTDialog {
// get the file name
saveButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
+ // Set the filename to be returned through getFileName()
fileName = textBox.getText();
- // TODO load the file
shell.close();
}
});
diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmDisplayWindow.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmDisplayWindow.java
index 01d6dc1b7e..f6c7545f1d 100644
--- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmDisplayWindow.java
+++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/dialogs/AlarmDisplayWindow.java
@@ -188,15 +188,17 @@ public class AlarmDisplayWindow extends CaveSWTDialog {
lines.append(text.getLine(lineIndex)).append("\n");
}
- PrintDisplay.print(true, lines.toString(),
- UFStatus.getHandler(AlarmDisplayWindow.class));
+ PrintDisplay.print(lines.toString(), text.getFont()
+ .getFontData()[0], UFStatus
+ .getHandler(AlarmDisplayWindow.class));
}
});
printBuffer.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
- PrintDisplay.print(true, text.getText(),
+ PrintDisplay.print(text.getText(),
+ text.getFont().getFontData()[0],
UFStatus.getHandler(AlarmDisplayWindow.class));
}
});
diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/util/AlarmAlertFunctions.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/util/AlarmAlertFunctions.java
index 8b1290ff2a..5092709723 100644
--- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/util/AlarmAlertFunctions.java
+++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/util/AlarmAlertFunctions.java
@@ -27,8 +27,6 @@ import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import javax.xml.bind.JAXB;
@@ -76,7 +74,7 @@ public class AlarmAlertFunctions {
private static final AlarmAlertProduct.ProductType AA = AlarmAlertProduct.ProductType.Alarm_Alert;
private static final AlarmAlertProduct.ProductType PA = AlarmAlertProduct.ProductType.Proximity_Alarm;
-
+
private static final Object configFileLock = new Object();
private static final String ALARM_ALERT_PATH = "alarms" + File.separator;
@@ -130,50 +128,52 @@ public class AlarmAlertFunctions {
*/
public static void isInAlarmList(AlarmAlertProduct prod) {
AlarmAlertLists instance = AlarmAlertLists.getInstance();
-
+
List currentAlarms = instance.getFilteredProducts();
boolean alarm = false;
- List prods = findMatches(prod.getProductId(), currentAlarms);
+ List prods = findMatches(prod.getProductId(),
+ currentAlarms);
// did we match anything?
boolean alertAlarm = (prods.size() > 0);
- if(alertAlarm) {
+ if (alertAlarm) {
String pId = prods.get(0).getProductId();
- // first go get the product. All of the matching product identifiers are
+ // first go get the product. All of the matching product identifiers
+ // are
// the same so just get the first.
List prodList = getProduct(pId);
AlarmAlertProduct productFound = null;
- if(prodList.size() > 0) {
+ if (prodList.size() > 0) {
String s = prodList.get(0).getProduct();
- for(AlarmAlertProduct p : prods) {
+ for (AlarmAlertProduct p : prods) {
String search = p.getSearchString();
-
+
boolean match = false;
- if((search != null) && (search.length() > 0)) {
- if(s.indexOf(search) >= 0) {
- match = true;
+ if ((search != null) && (search.length() > 0)) {
+ if (s.indexOf(search) >= 0) {
+ match = true;
}
} else {
- match = true;
+ match = true;
}
if (match) {
- if (productFound == null)
- productFound = p;
- if ("Alarm".equals(p.getAlarmType()) && p.isAlarm()) {
- alarm = true;
- productFound = p;
- }
- if (alarm)
- break;
+ if (productFound == null)
+ productFound = p;
+ if ("Alarm".equals(p.getAlarmType()) && p.isAlarm()) {
+ alarm = true;
+ productFound = p;
+ }
+ if (alarm)
+ break;
}
}
}
- if(productFound != null) {
+ if (productFound != null) {
prod.setAlarm(productFound.isAlarm());
prod.setAlarmType(productFound.getAlarmType());
-
+
instance.getCurrentAlarms().add(prod);
instance.fireNewCurrentAlarmEvent(prod);
-
+
ringBell(alarm);
}
}
@@ -184,46 +184,51 @@ public class AlarmAlertFunctions {
}
/**
- * Retrieve a text product from the text database based on its productId.
- * @param productId AFOS ProductId to retrieve from the text database.
+ * Retrieve a text product from the text database based on its productId.
+ *
+ * @param productId
+ * AFOS ProductId to retrieve from the text database.
* @return A list of text products. Will always return a not null reference.
*/
private static List getProduct(String productId) {
List productList = null;
-
+
ICommand command = CommandFactory.getAfosCommand(productId);
try {
- productList = command.executeCommand(TextEditorUtil.getTextDbsrvTransport());
+ productList = command.executeCommand(TextEditorUtil
+ .getTextDbsrvTransport());
} catch (CommandFailedException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
- if(productList == null) {
+ if (productList == null) {
productList = new ArrayList();
}
return productList;
}
-
-
+
/**
* Return a list of all alarms that match the incoming product identifier.
+ *
* @param productId
* @param currentAlarms
* @return
*/
- private static List findMatches(String productId, List currentAlarms) {
+ private static List findMatches(String productId,
+ List currentAlarms) {
List prods = new ArrayList();
- if(productId != null) {
- productId = productId.toUpperCase();
+ if (productId != null) {
+ productId = productId.trim().toUpperCase();
for (AlarmAlertProduct a : currentAlarms) {
- //**************
+ // **************
// TODO : For now disable Proximity Alerts
- //**************
- if(AA.equals(a.getProductType())) {
+ // **************
+ if (AA.equals(a.getProductType())) {
String s = a.getProductId();
- if(s != null) {
- s = s.toUpperCase();
- if(s.equals(productId)) {
- // Reset the productId so we know we're dealing with uppercase
+ if (s != null) {
+ s = s.trim().toUpperCase();
+ if (s.equals(productId)) {
+ // Reset the productId so we know we're dealing with
+ // uppercase
a.setProductId(s);
prods.add(a);
}
@@ -233,8 +238,7 @@ public class AlarmAlertFunctions {
}
return prods;
}
-
-
+
/**
* initialize the localization for user with the save/load functions
*
diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/util/AlarmBeepJob.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/util/AlarmBeepJob.java
index 8c558b288a..b4d7a89ec3 100644
--- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/util/AlarmBeepJob.java
+++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/alarmalert/util/AlarmBeepJob.java
@@ -24,7 +24,7 @@ import java.awt.Toolkit;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.ui.progress.UIJob;
/**
* TODO Add Description
@@ -35,6 +35,7 @@ import org.eclipse.core.runtime.jobs.Job;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 19, 2009 mnash Initial creation
+ * Jul 25, 2012 15122 rferrel Add sound repeat interval.
*
*
*
@@ -42,17 +43,29 @@ import org.eclipse.core.runtime.jobs.Job;
* @version 1.0
*/
-public class AlarmBeepJob extends Job {
+public class AlarmBeepJob extends UIJob {
+
+ private static final int BEEP_COUNT = 5;
+
+ private static final long BEEP_INTERVAL = 1000L;
private boolean disposed;
+ private long delay;
+
private int count = 0;
/**
* @param name
*/
- public AlarmBeepJob(String name) {
+ public AlarmBeepJob(String name, long delay) {
super(name);
+
+ if (delay > (BEEP_COUNT * BEEP_INTERVAL)) {
+ this.delay = delay;
+ } else {
+ this.delay = (BEEP_COUNT + 1) * BEEP_INTERVAL;
+ }
}
/*
@@ -62,27 +75,21 @@ public class AlarmBeepJob extends Job {
* IProgressMonitor)
*/
@Override
- protected IStatus run(IProgressMonitor monitor) {
+ public IStatus runInUIThread(IProgressMonitor monitor) {
IStatus status = Status.OK_STATUS;
- if (count < 5) {
+ if (count < BEEP_COUNT) {
Toolkit.getDefaultToolkit().beep();
- reSchedule();
+ if (!disposed) {
+ this.schedule(BEEP_INTERVAL);
+ }
count++;
- } else {
- dispose();
+ } else if (!disposed) {
+ schedule(delay - (BEEP_COUNT * BEEP_INTERVAL));
+ count = 0;
}
return status;
}
- /**
- * Schedule this job to run after the desired interval
- */
- public void reSchedule() {
- if (!disposed) {
- this.schedule(1 * 1000);
- }
- }
-
/**
* Cancel this job and release its reference to the DataManager
*/
diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AWIPSHeaderBlockDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AWIPSHeaderBlockDlg.java
index c709f65720..c577058570 100644
--- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AWIPSHeaderBlockDlg.java
+++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AWIPSHeaderBlockDlg.java
@@ -90,6 +90,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* 01/26/2012 14468 D.Friedman Fix initial BBB field selection.
* 05/30/2012 15046 D.Friedman Always set addressee field to ALL.
* 06/19/2012 14975 D.Friedman Run callback when dialog is dismissed.
+ * 07/26/2012 15171 rferrel Disable editor's send and clear AFOS PIL fields when
+ * invalid product Id and user want to edit it anyway,
*
*
* @author lvenable
@@ -202,11 +204,11 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements
@Override
public void widgetDisposed(DisposeEvent e) {
if (parentEditor != null)
- parentEditor.headerBlockDlgDismissed(
- Boolean.TRUE.equals(getReturnValue()));
+ parentEditor.headerBlockDlgDismissed(Boolean.TRUE
+ .equals(getReturnValue()));
}
});
-
+
setReturnValue(false);
createWmoIdFields();
@@ -274,7 +276,7 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements
// Create the message/indicator group combo box.
gd = new GridData(70, SWT.DEFAULT);
- bbbCboBx = new Combo(wmoIdComp, SWT.DROP_DOWN|SWT.READ_ONLY);
+ bbbCboBx = new Combo(wmoIdComp, SWT.DROP_DOWN | SWT.READ_ONLY);
bbbCboBx.setItems(BBB_LIST);
bbbCboBx.select(3);
bbbCboBx.setLayoutData(gd);
@@ -298,7 +300,7 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements
// Create the message/indicator version group combo box.
gd = new GridData(70, SWT.DEFAULT);
- bbbVerCboBx = new Combo(wmoIdComp, SWT.DROP_DOWN|SWT.READ_ONLY);
+ bbbVerCboBx = new Combo(wmoIdComp, SWT.DROP_DOWN | SWT.READ_ONLY);
bbbVerCboBx.setItems(CHAR_LIST);
bbbVerCboBx.select(0);
bbbVerCboBx.setLayoutData(gd);
@@ -473,7 +475,7 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements
.getTextLimit()) {
wmoTtaaiiTF.setFocus();
}
-
+
handleAddresseeModified();
}
});
@@ -595,6 +597,7 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements
enterBtn.setEnabled(true);
enterBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
+ boolean sendEnabled = true;
if (!isProductValid()) {
// Notify the user that the product may not be valid.
//
@@ -614,15 +617,25 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog implements
if (mb.open() == SWT.NO) {
return;
}
+ parentEditor.enableSend(false);
+ sendEnabled = false;
+ } else {
+ parentEditor.enableSend(true);
}
// call the set methods
parentEditor.setCurrentWmoId(wmoTtaaiiTF.getText());
parentEditor.setCurrentSiteId(ccccTF.getText());
- parentEditor.setCurrentWsfoId(wsfoIdTF.getText());
- parentEditor.setCurrentProdCategory(prodCatTF.getText());
- parentEditor.setCurrentProdDesignator(prodDesignatorTF
- .getText());
+ if (sendEnabled) {
+ parentEditor.setCurrentWsfoId(wsfoIdTF.getText());
+ parentEditor.setCurrentProdCategory(prodCatTF.getText());
+ parentEditor.setCurrentProdDesignator(prodDesignatorTF
+ .getText());
+ } else {
+ parentEditor.setCurrentWsfoId("");
+ parentEditor.setCurrentProdCategory("");
+ parentEditor.setCurrentProdDesignator("");
+ }
parentEditor.setAddressee(addresseeTF.getText());
setBbbId();
setReturnValue(true);
diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AfosBrowserDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AfosBrowserDlg.java
index 6a03971590..325ab00017 100755
--- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AfosBrowserDlg.java
+++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AfosBrowserDlg.java
@@ -535,22 +535,9 @@ public class AfosBrowserDlg extends CaveSWTDialog implements
loadContinueBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
- /*
- * if ((nodeList.getSelectionIndex() > -1) &&
- * (categoryList.getSelectionIndex() > -1) &&
- * designatorList.getSelectionIndex() > -1) {
- */
- /*
- * TextDisplayModel.getInstance().setProductNode(token,
- * selectedNode);
- * TextDisplayModel.getInstance().setProductCategory(token,
- * selectedCategory);
- * TextDisplayModel.getInstance().setProductDesignator(token,
- * selectedDesignator);
- */
callbackClient.executeCommand(CommandFactory
.getAfosCommand(currentAfosCommand));
- // }
+ loadContinueBtn.setFocus();
}
});
@@ -563,20 +550,8 @@ public class AfosBrowserDlg extends CaveSWTDialog implements
loadCloseBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
- /*
- * if ((nodeList.getSelectionIndex() > -1) &&
- * (categoryList.getSelectionIndex() > -1) &&
- * designatorList.getSelectionIndex() > -1) {
- * TextDisplayModel.getInstance().setProductNode(token,
- * selectedNode);
- * TextDisplayModel.getInstance().setProductCategory(token,
- * selectedCategory);
- * TextDisplayModel.getInstance().setProductDesignator(token,
- * selectedDesignator);
- */
callbackClient.executeCommand(CommandFactory
.getAfosCommand(currentAfosCommand));
- // }
setReturnValue(false);
shell.setVisible(false);
@@ -778,7 +753,7 @@ public class AfosBrowserDlg extends CaveSWTDialog implements
// Get the designator list - ensure that the entries are three
// characters in length.
for (String s : xxx) {
- if(s.length() == 1) {
+ if (s.length() == 1) {
s = s + " ";
} else if (s.length() == 2) {
s = s + " ";
diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java
index 4d59bd155a..cc4ef078e7 100644
--- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java
+++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java
@@ -44,6 +44,7 @@ import java.util.Scanner;
import java.util.TimeZone;
import java.util.Timer;
import java.util.TimerTask;
+import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -67,8 +68,6 @@ import org.eclipse.swt.custom.VerifyKeyListener;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.FocusAdapter;
@@ -87,6 +86,7 @@ import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.events.VerifyListener;
import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
@@ -279,6 +279,9 @@ import com.raytheon.viz.ui.dialogs.SWTMessageBox;
* 24Apr2012 14548 rferrel Merging lines for wrap places a space beween words when needed.
* 27Apr2012 14902 rferrel No longer have blank line between AWIPS ID and UGC line.
* 06/19/2012 14975 D.Friedman Prevent zeroed-out WMO header times.
+ * 18JUL2012 14457 rferrel Add mouse listener to clear site's update obs when clicked on.
+ * 25JUL2012 14459 rferrel Strip WMH headers when getting all METARs.
+ * 13AUG2012 14613 M.Gamazaychikov Ensured the WMO and MND header times are the same.
*
*
* @author lvenable
@@ -308,6 +311,10 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
private static final int END_ELEMENT_TAG_LEN = END_ELEMENT_TAG.length();
+ private static final String METAR_LINE = "^(METAR |SPECI |\\s+\\S)";
+
+ private static final Pattern METAR_PATTERN = Pattern.compile(METAR_LINE);
+
private final List displayedPils = new ArrayList();
private Pattern obsRegex = null;
@@ -943,13 +950,13 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
/**
* flag to indicate it a product request is from the GUI or an updated ob.
*/
- private boolean updating = false;
+ private AtomicInteger updateCount = new AtomicInteger(0);
private NotifyExpiration notify;
private NotifyExpiration queuedNotify = null;
- private String queuedAfos = null;
+ private String queuedProduct = null;
/**
* The Warngen work product id for draft PILs.
@@ -1090,9 +1097,13 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
private RemoteRetrievalRequest lastRemoteRetrievalRequest;
private Clipboard clipboard;
-
- private enum HeaderEditSession { CLOSE_ON_EXIT, IN_EDITOR }
-
+
+ private MouseListener updateObsListener = null;
+
+ private enum HeaderEditSession {
+ CLOSE_ON_EXIT, IN_EDITOR
+ }
+
private HeaderEditSession headerEditSession;
static {
@@ -1192,7 +1203,6 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
@Override
protected void initializeComponents(final Shell shell) {
- shell.setSize(MIN_WIDTH, MIN_HEIGHT);
Display display = getDisplay();
clipboard = new Clipboard(getDisplay());
@@ -1201,32 +1211,6 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
medFont = new Font(display, "Courier", 11, SWT.NORMAL);
lrgFont = new Font(display, "Courier", 13, SWT.NORMAL);
- // this.shell = shell;
- shell.addControlListener(new ControlAdapter() {
- public void controlResized(ControlEvent e) {
- if (canRedraw == false) {
- return;
- }
-
- final Shell resizedShell = (Shell) e.getSource();
- final Point point = resizedShell.getSize();
-
- if (point.x != MIN_WIDTH || point.y < (MIN_HEIGHT / 2)) {
- canRedraw = false;
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- if (point.y < (MIN_HEIGHT / 2)) {
- point.y = (MIN_HEIGHT / 2);
- }
-
- resizedShell.setSize(MIN_WIDTH, point.y);
- canRedraw = true;
- }
- });
- }
- }
- });
-
if (textWorkstationFlag || isWarnGenDlg) {
shell.addShellListener(new ShellAdapter() {
@Override
@@ -2632,8 +2616,6 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
if (rv == true) {
recompileRegex();
wordWrapEnabled = true;
- // textEditor.setWordWrap(true);
- // sizeTextEditor();
}
}
@@ -2650,10 +2632,10 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
smallFontItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
- textEditor.setFont(smlFont);
- // textEditorComp.layout();
- sizeTextEditor();
- headerTF.setFont(smlFont);
+ if (smallFontItem.getSelection()) {
+ textEditor.setFont(smlFont);
+ headerTF.setFont(smlFont);
+ }
}
});
@@ -2663,10 +2645,10 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
mediumFontItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
- textEditor.setFont(medFont);
- // textEditorComp.layout();
- sizeTextEditor();
- headerTF.setFont(medFont);
+ if (mediumFontItem.getSelection()) {
+ textEditor.setFont(medFont);
+ headerTF.setFont(medFont);
+ }
}
});
@@ -2675,10 +2657,10 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
largeFontItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
- textEditor.setFont(lrgFont);
- // textEditorComp.layout();
- sizeTextEditor();
- headerTF.setFont(lrgFont);
+ if (largeFontItem.getSelection()) {
+ textEditor.setFont(lrgFont);
+ headerTF.setFont(lrgFont);
+ }
}
});
}
@@ -2816,6 +2798,10 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
@Override
public void widgetSelected(SelectionEvent event) {
clearTextEditor();
+ if (updateObsListener != null) {
+ textEditor.removeMouseListener(updateObsListener);
+ updateObsListener = null;
+ }
}
});
}
@@ -2871,7 +2857,6 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
}
public void widgetDefaultSelected(SelectionEvent event) {
-
String tmp = afosCmdTF.getText();
tmp = tmp.trim();
afosCmdTF.setText(tmp);
@@ -2959,7 +2944,6 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
}
public void widgetDefaultSelected(SelectionEvent event) {
- textEditor.setFocus();
wmoTtaaiiTF.setText(wmoTtaaiiTF.getText().toUpperCase());
ccccTF.setText(ccccTF.getText().toUpperCase());
wmoSearch();
@@ -3018,7 +3002,6 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
}
public void widgetDefaultSelected(SelectionEvent event) {
- textEditor.setFocus();
wmoTtaaiiTF.setText(wmoTtaaiiTF.getText().toUpperCase());
ccccTF.setText(ccccTF.getText().toUpperCase());
wmoSearch();
@@ -3080,22 +3063,15 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
}
public void widgetDefaultSelected(SelectionEvent event) {
- textEditor.setFocus();
awipsIdTF.setText(awipsIdTF.getText().trim().toUpperCase());
int charCount = awipsIdTF.getCharCount();
if (charCount < 4 || charCount > 6) {
- // System.out
- // .printf("Must enter a 6 or 9 character AFOS PIL%n");
- // System.out.printf("Character Count = %d%n", charCount);
userInformation("Must enter a 4 to 6 character AWIPS ID");
awipsIdTF.setFocus();
return;
} else {
- // System.out.printf("NNN = %s%n", awipsIdTF.getText(0, 2));
TextDisplayModel.getInstance().setProductCategory(token,
awipsIdTF.getText(0, 2));
- // System.out.printf("XXX = %s%n",
- // awipsIdTF.getText(3, charCount - 1));
TextDisplayModel.getInstance().setProductDesignator(token,
awipsIdTF.getText(3, charCount - 1));
}
@@ -3151,10 +3127,33 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
* state of the check box
*/
private void handleUpdateObsChkBtn(boolean checked) {
- // String pil = TextDisplayModel.getInstance().getAfosPil(token);
- // System.out.println("Update Obs: state = " + checked + ", AFOS PIL = "
- // + pil);
if (checked) {
+ if (updateObsListener == null) {
+ updateObsListener = new MouseListener() {
+
+ @Override
+ public void mouseUp(MouseEvent e) {
+ try {
+ int offset = textEditor
+ .getOffsetAtLocation(new Point(e.x, e.y));
+ clearUpdateFlag(offset);
+ } catch (IllegalArgumentException ex) {
+ // bad mouse location ignore
+ }
+ }
+
+ @Override
+ public void mouseDown(MouseEvent e) {
+ // Ignore
+ }
+
+ @Override
+ public void mouseDoubleClick(MouseEvent e) {
+ // Ignore
+ }
+ };
+ textEditor.addMouseListener(updateObsListener);
+ }
NotificationManagerJob.addObserver(ALARM_ALERT_TOPIC, this);
} else {
NotificationManagerJob.removeObserver(ALARM_ALERT_TOPIC, this);
@@ -3162,6 +3161,18 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
}
+ private void clearUpdateFlag(int offset) {
+ for (StyleRange range : textEditor.getStyleRanges()) {
+ if (range.start <= offset && offset < (range.start + range.length)) {
+ StyleRange lock = (StyleRange) range.clone();
+ lock.background = null;
+ lock.foreground = null;
+ textEditor.setStyleRange(lock);
+ break;
+ }
+ }
+ }
+
private void clearAfosCmdTF() {
if (!afosCmdTF.isDisposed()) {
afosCmdTF.setText("");
@@ -3364,7 +3375,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
* Create the text editor (styled text) control.
*/
private void createTextAreaEditor() {
- GridData gd = new GridData(GridData.FILL_BOTH);
+ GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
textEditorComp = new Composite(shell, SWT.NONE);
GridLayout gridLayout = new GridLayout(1, false);
textEditorComp.setLayout(gridLayout);
@@ -3372,8 +3383,16 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
textEditor = new StyledText(textEditorComp, SWT.BORDER | SWT.MULTI
| SWT.V_SCROLL | SWT.H_SCROLL);
- textEditor.setWordWrap(false);
+ gd = new GridData(SWT.FILL, SWT.FILL, true, true);
textEditor.setFont(medFont);
+ GC gc = new GC(textEditor);
+ FontMetrics fm = gc.getFontMetrics();
+ gc.dispose();
+ int width = EDITOR_WIDTH * fm.getAverageCharWidth();
+ gd.widthHint = width;
+
+ textEditor.setLayoutData(gd);
+ textEditor.setWordWrap(false);
textEditor.setEditable(false);
textEditor.setKeyBinding(SWT.INSERT, SWT.NULL); // DR 7826
@@ -3436,22 +3455,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
// }
// });
- sizeTextEditor();
-
textEditor.addVerifyKeyListener(new VerifyKeyListener() {
public void verifyKey(VerifyEvent event) {
-
- // System.out.println("event.keyCode = " + event.keyCode);
- // System.out.println("event.character = <" + event.character
- // + ">");
- //
- // System.out.println("String.valueOf(event.character) = <"
- // + String.valueOf(event.character) + ">");
- //
- // System.out.println("String.valueOf(event.character).length =
- // <"
- // + String.valueOf(event.character).length() + ">");
-
if (event.keyCode == SWT.DEL || event.character == SWT.BS
|| event.keyCode == SWT.SHIFT) {
// Do nothing...
@@ -3667,20 +3672,6 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
statusBarLabel.setLayoutData(gd);
}
- /**
- * Size the text editor based on the text font size.
- */
- private void sizeTextEditor() {
- GC gc = new GC(textEditor);
- FontMetrics fm = gc.getFontMetrics();
- gc.dispose();
- int width = EDITOR_WIDTH * fm.getAverageCharWidth();
- GridData data = new GridData(GridData.FILL_VERTICAL);
- data.widthHint = width;
- textEditor.setLayoutData(data);
- textEditorComp.layout();
- }
-
/**
* Enter the text editor mode.
*/
@@ -3764,12 +3755,12 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
stopAutoSave();
- if (warnGenFlag && queuedAfos != null) {
+ if (warnGenFlag && queuedProduct != null) {
// Display the WarnGen in the queue, perform the popup and stop the
// cancel.
- showWarngenProduct(queuedAfos, queuedNotify);
+ showWarngenProduct(queuedProduct, queuedNotify);
queuedNotify = null;
- queuedAfos = null;
+ queuedProduct = null;
return false;
}
// Set the edit mode flag
@@ -3866,14 +3857,14 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
// Create and display the AWIPS header block dialog.
AWIPSHeaderBlockDlg awipsHeaderBlockDlg = new AWIPSHeaderBlockDlg(
shell, this);
-
- headerEditSession = closeEditorOnCancel ?
- HeaderEditSession.CLOSE_ON_EXIT : HeaderEditSession.IN_EDITOR;
+
+ headerEditSession = closeEditorOnCancel ? HeaderEditSession.CLOSE_ON_EXIT
+ : HeaderEditSession.IN_EDITOR;
awipsHeaderBlockDlg.open();
// headerBlockDlgDismissed() is called when the dialog is dismissed.
}
-
+
/**
* Called by AWIPSHeaderBlockDlg when it is dismissed.
*
@@ -3884,23 +3875,24 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
public void headerBlockDlgDismissed(boolean dialogResult) {
HeaderEditSession lastSession = headerEditSession;
headerEditSession = null;
-
+
// If the user cancels the AWIPS header block dialog then
// get out of edit mode.
// Otherwise use the node, product category, and product designator.
-
+
boolean editing = false;
-
+
if (dialogResult == true) {
TextDisplayModel tdm = TextDisplayModel.getInstance();
-
+
// Update the buttonology.
updateButtonology(tdm.getAfosPil(token));
String bbbid = tdm.getBbbId(token);
-
+
String nnnxxx = workProductId != null ? workProductId : tdm
- .getProductCategory(token) + tdm.getProductDesignator(token);
+ .getProductCategory(token)
+ + tdm.getProductDesignator(token);
// Set the header text field.
if (bbbid.equals("NOR")) {
String wmoId = tdm.getWmoId(token);
@@ -3912,25 +3904,26 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
setHeaderTextField(tdm.getWmoId(token), tdm.getSiteId(token),
currentDateId + " " + bbbid, "\n", nnnxxx);
}
-
+
// Update the "now editing" title of the text editor window.
updateNowEditingTitle();
-
+
editing = true;
} else {
if (lastSession == HeaderEditSession.CLOSE_ON_EXIT)
- editing = !cancelEditor(false);
+ editing = !cancelEditor(false);
}
-
+
if (lastSession == HeaderEditSession.CLOSE_ON_EXIT)
if (editing) {
StdTextProduct product = TextDisplayModel.getInstance()
- .getStdTextProduct(token);
+ .getStdTextProduct(token);
if (product == null)
return;
if (autoSave == null) {
// user can cancel the edit immediately when the header is
- // displayed, verify it was not cancelled before starting the
+ // displayed, verify it was not cancelled before starting
+ // the
// autoSave task.
autoSave = new AutoSaveTask(product.getWmoid(),
product.getSite());
@@ -4080,7 +4073,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
* Print all text from the text editor to the default printer.
*/
private void printAllText() {
- PrintDisplay.print(true, textEditor.getText(), statusHandler);
+ FontData fontData = textEditor.getFont().getFontData()[0];
+ PrintDisplay.print(textEditor.getText(), fontData, statusHandler);
}
/**
@@ -4102,7 +4096,8 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
if (mb.open() == SWT.YES) {
String tmpText = textEditor.getText();
Point point = textEditor.getSelection();
- PrintDisplay.print(true, textEditor.getSelectionText(),
+ FontData fontData = textEditor.getFont().getFontData()[0];
+ PrintDisplay.print(textEditor.getSelectionText(), fontData,
statusHandler);
textEditor.setText(tmpText);
textEditor.setSelection(point);
@@ -4609,10 +4604,16 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
}
boolean successful = false;
- // Convert the text in the text editor to uppercase
- String currentDate = getCurrentDate();
+ /*
+ * DR14613 - string currectDate is derived from Date now
+ * ensuring the same time in WMO heading and in the
+ * MND heading.
+ */
+ Date now = SimulatedTime.getSystemTime().getTime();
+ String currentDate = getCurrentDate(now);
TextDisplayModel tdmInst = TextDisplayModel.getInstance();
+ // Convert the text in the text editor to uppercase
if (!isAutoSave) {
if (!verifyRequiredFields()) {
return false;
@@ -4642,17 +4643,19 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
}
if (!isAutoSave) {
- if (! resend) {
+ if (!resend) {
// If not a resend, set the DDHHMM field to the current time
productText = replaceDDHHMM(productText, currentDate);
-
+
VtecObject vtecObj = VtecUtil.parseMessage(productText);
if (warnGenFlag) {
- // TODO: Pass in some flavor of currentDate to use to set the
- // times. Currently roll over to the next minute between getting
- // currentDate and getting the times in this method will cause
- // them to be different.
- productText = updateVtecTimes(productText, vtecObj);
+ /*
+ * DR14613 - string currectDate is derived from Date now
+ * ensuring the same time in WMO heading and in the
+ * MND heading.
+ */
+ productText = updateVtecTimes(productText, vtecObj, now);
+ productText = updateHeaderTimes(productText, now);
// Update editor so the proper send times are displayed.
String[] b = productText.split("\n");
StringBuilder body = new StringBuilder();
@@ -4726,10 +4729,14 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
return successful;
}
-
- /** Replaces the WMO heading DDHHMM field with the given text.
- * @param productText Product text which includes the WMO heading
- * @param ddhhmm Replacement text
+
+ /**
+ * Replaces the WMO heading DDHHMM field with the given text.
+ *
+ * @param productText
+ * Product text which includes the WMO heading
+ * @param ddhhmm
+ * Replacement text
* @return The modified product text
*/
private static String replaceDDHHMM(String productText, String ddhhmm) {
@@ -4748,8 +4755,10 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
sb.append(' ');
sb.append(s);
}
- if (parts.length > 1)
- sb.append('\n').append(parts[1]);
+ if (parts.length > 1) {
+ sb.append('\n').append(parts[1]);
+ }
+
productText = sb.toString();
}
@@ -4889,14 +4898,11 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
// Capture the input from the styled text widget.
StringBuffer sb = new StringBuffer(st.getText());
String errMsg = null;
- // System.out.println("Initial: " + sb);
- // int counter = 0;
int currentIndex = 0;
int startIndex = 0;
int endIndex = 0;
try {
while (sb.indexOf(BEGIN_ELEMENT_TAG, 0) >= 0) {
- // System.out.println("Trial " + counter++ + ": " + sb);
currentIndex = 0;
startIndex = 0;
endIndex = 0;
@@ -4956,7 +4962,6 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
*/
@Override
public void verifyText(VerifyEvent event) {
- // System.out.println("verify text event.start="+event.star0t);
int length = event.end - event.start;
try {
if (length == 0) {
@@ -5110,19 +5115,28 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
headerTF.setText("");
}
- private String getCurrentDate() {
- Date now = SimulatedTime.getSystemTime().getTime();
+ private String getCurrentDate(Date now) {
+ /*
+ * DR14613 - pass the Date now as an argument
+ */
SimpleDateFormat formatter = new SimpleDateFormat("ddHHmm");
formatter.setTimeZone(TimeZone.getTimeZone("GMT"));
return (formatter.format(now));
}
- private String updateVtecTimes(String product, VtecObject vtecObj) {
+ /**
+ * Update the VTEC time using the Date now.
+ *
+ * @param product
+ * @param vtecObj
+ * @param now
+ * @return
+ */
+ private String updateVtecTimes(String product, VtecObject vtecObj, Date now) {
if (vtecObj == null || vtecObj.getAction().equals("COR")) {
return product;
}
- Date now = SimulatedTime.getSystemTime().getTime();
// Update the vtec start time
if (vtecObj.getAction().equals("NEW")) {
SimpleDateFormat vtecFormatter = new SimpleDateFormat(
@@ -5131,9 +5145,20 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
product = product.replace(
vtecFormatter.format(vtecObj.getStartTime().getTime()),
vtecFormatter.format(now));
- }
+ }
- // Update the header time
+ return product;
+ }
+
+ /**
+ * Update the MND header time using the Date now.
+ *
+ * @param product
+ * @param now
+ * @return
+ */
+ private String updateHeaderTimes(String product, Date now) {
+ // Update the header time
Matcher m = datePtrn.matcher(product);
if (m.find()) {
SimpleDateFormat headerFormat = new SimpleDateFormat(
@@ -5144,9 +5169,9 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
product = product.replace(m.group(1), headerFormat.format(now)
.toUpperCase());
}
-
- return product;
+ return product;
}
+
public void setCurrentWmoId(String wmoId) {
TextDisplayModel.getInstance().setWmoId(token, wmoId);
@@ -5203,6 +5228,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
statusBarLabel.update();
boolean hasAttachment = false;
String attachedFilename = new String();
+ boolean validExecuteCommand = true;
try {
if (queryTransport == null) {
@@ -5237,7 +5263,17 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
hasAttachment = true;
}
- if (updating) {
+ String commandText = command.getCommandTextFields()[0];
+ StdTextProductId stdProdId = prod.getProdId();
+
+ if ("MTR".equals(stdProdId.getNnnid())
+ && (commandText.startsWith("ALL:")
+ || commandText.startsWith("A:") || commandText
+ .endsWith("000"))) {
+ stripWMOHeaders(prod);
+ }
+
+ if (updateCount.get() > 0) {
updateDisplayedProduct(prod);
} else {
setDisplayedProduct(prod);
@@ -5293,10 +5329,12 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
if (!accumChkBtn.getSelection()) {
textEditor.setText("");
}
+ validExecuteCommand = false;
}
} catch (CommandFailedException e) {
statusHandler.handle(Priority.PROBLEM,
"Error retrieving metatdata", e);
+ validExecuteCommand = false;
}
if (!this.isDisposed()) {
@@ -5312,104 +5350,104 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
} else {
resendWarningProductnItem.setEnabled(true);
}
+
+ // Always give focus to textEditor after populating it.
+ if (validExecuteCommand) {
+ textEditor.setFocus();
+ }
}
}
- public void showWarngenProduct(String afosId, NotifyExpiration notify) {
+ private void stripWMOHeaders(StdTextProduct prod) {
+ String[] lines = prod.getProduct().split("\n");
+ StringBuilder sb = new StringBuilder();
+ for (String line : lines) {
+ Matcher m = METAR_PATTERN.matcher(line);
+ if (m.find()) {
+ sb.append(line).append("\n");
+ }
+ }
+ prod.setProduct(sb.toString());
+ }
+
+ public void showWarngenProduct(String product, NotifyExpiration notify) {
inEditMode = true;
this.notify = notify;
- StdTextProduct tmp = null;
- final SimpleDateFormat sdf = new SimpleDateFormat(
- "yyyy-MM-dd HH:mm:ss.SSS");
- sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
- long t0 = System.currentTimeMillis();
- try {
- if (queryTransport == null) {
- queryTransport = TextEditorUtil.getTextDbsrvTransport();
- }
- long t2 = System.currentTimeMillis();
- System.out
- .println("Time getting TextDbSrv transport: " + (t2 - t0));
- ICommand cmd = CommandFactory.getAfosCommand(afosId);
- long t3 = System.currentTimeMillis();
- System.out.println("Time getting afos command: " + (t3 - t2));
- tmp = cmd.executeCommand(queryTransport).get(0);
- long t4 = System.currentTimeMillis();
- System.out.println("Time executing afos cmd: " + (t4 - t3));
- } catch (CommandFailedException e) {
- e.printStackTrace();
- }
- long t1 = System.currentTimeMillis();
- System.out
- .println(sdf.format(new Date())
- + ": Text Workstation retrieving work product from database in "
- + (t1 - t0) + "ms.");
+ String[] tokens = product.split(":", 2);
- String warning = tmp.getProduct();
- String[] nnnxxx = TextDisplayModel.getNnnXxx(warning);
- String siteNode = SiteAbbreviationUtil.getSiteNode(nnnxxx[1]);
- String ttaaii = SiteAbbreviationUtil.getTtaaii(siteNode + nnnxxx[0]
- + nnnxxx[1]);
- final String w = warning.replace(TextWarningConstants.TTAAII, ttaaii);
+ if (tokens.length == 2) {
+ String afosId = tokens[0];
+ String warning = tokens[1];
- TextDisplayModel.getInstance().createStdTextProduct(token, w, siteNode);
+ String[] nnnxxx = TextDisplayModel.getNnnXxx(warning);
+ String siteNode = SiteAbbreviationUtil.getSiteNode(nnnxxx[1]);
+ String ttaaii = SiteAbbreviationUtil.getTtaaii(siteNode + nnnxxx[0]
+ + nnnxxx[1]);
+ final String w = warning.replace(TextWarningConstants.TTAAII,
+ ttaaii);
- workProductId = afosId.substring(3);
- warnGenFlag = true;
- VizApp.runAsync(new Runnable() {
- @Override
- public void run() {
- long t0 = System.currentTimeMillis();
- // For VTEC related warning messages, turn off wordwrap by
- // default.
- if (textEditor == null) {
- openDialog();
- }
+ TextDisplayModel.getInstance().createStdTextProduct(token, w,
+ siteNode);
- if (textEditor.isDisposed()) {
- return;
- }
+ workProductId = afosId.substring(3);
+ warnGenFlag = true;
+ VizApp.runAsync(new Runnable() {
+ @Override
+ public void run() {
+ long t0 = System.currentTimeMillis();
+ // For VTEC related warning messages, turn off wordwrap by
+ // default.
+ if (textEditor == null) {
+ openDialog();
+ }
- // textEditor.setWordWrap(false);
+ if (textEditor.isDisposed()) {
+ return;
+ }
- // Set the text editor's contents to the warning message.
- textEditor.removeVerifyListener(TextEditorDialog.this);
- textEditor.setText(w);
- //
- // // Mark the uneditable warning text
- // if (markUneditableText(textEditor)) {
- // // Add listener to monitor attempt to edit locked text
- // textEditor.addVerifyListener(TextEditorDialog.this);
- // }
- showDialog();
- long t1 = System.currentTimeMillis();
+ // textEditor.setWordWrap(false);
- System.out.println(sdf.format(new Date())
- + ": Text Workstation took " + (t1 - t0)
- + "ms to show dialog");
- enterEditor();
+ // Set the text editor's contents to the warning message.
+ textEditor.removeVerifyListener(TextEditorDialog.this);
+ textEditor.setText(w);
+ //
+ // // Mark the uneditable warning text
+ // if (markUneditableText(textEditor)) {
+ // // Add listener to monitor attempt to edit locked text
+ // textEditor.addVerifyListener(TextEditorDialog.this);
+ // }
+ showDialog();
+ long t1 = System.currentTimeMillis();
+ SimpleDateFormat sdf = new SimpleDateFormat(
+ "yyyy-MM-dd HH:mm:ss.SSS");
+ sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
+ System.out.println(sdf.format(new Date())
+ + ": Text Workstation took " + (t1 - t0)
+ + "ms to show dialog");
+ enterEditor();
- if (autoWrapMenuItem != null) {
- Menu menu = autoWrapMenuItem.getMenu();
- for (MenuItem item : menu.getItems()) {
- if (item.getSelection()) {
- Object obj = item.getData();
- if (obj instanceof WrapButtonCfg) {
- WrapButtonCfg buttonCfg = (WrapButtonCfg) obj;
- if (buttonCfg.isWrapEnabled()) {
- charWrapCol = buttonCfg.getWrapCol();
- wordWrapEnabled = true;
- recompileRegex();
- } else {
- wordWrapEnabled = false;
+ if (autoWrapMenuItem != null) {
+ Menu menu = autoWrapMenuItem.getMenu();
+ for (MenuItem item : menu.getItems()) {
+ if (item.getSelection()) {
+ Object obj = item.getData();
+ if (obj instanceof WrapButtonCfg) {
+ WrapButtonCfg buttonCfg = (WrapButtonCfg) obj;
+ if (buttonCfg.isWrapEnabled()) {
+ charWrapCol = buttonCfg.getWrapCol();
+ wordWrapEnabled = true;
+ recompileRegex();
+ } else {
+ wordWrapEnabled = false;
+ }
}
}
}
}
+ saved = false;
}
- saved = false;
- }
- });
+ });
+ }
}
private void replaceWorkProductId() {
@@ -5574,7 +5612,6 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
}
// open the script output window
scriptOutput.open();
- System.out.println("output window closed...");
// update the menu following close
if (scriptsShowOutputItem != null
&& !scriptsShowOutputItem.isDisposed()) {
@@ -5779,7 +5816,6 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
@Override
public void windowClosing() {
- System.out.println("script editor window closing");
if (scriptRunner == null) {
setScriptMenuControls(true);
}
@@ -5882,17 +5918,27 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
regex = "(METAR |SPECI )K" + product.getXxxid();
}
+ boolean haveWMOHeader = false;
+
if (regex != null) {
// Find METAR to replace.
// This assumes the product's METAR is the latest METAR and not a
- // duplicate or older then the display. If not the case a check of
+ // duplicate or older in the display. If not the case a check of
// the timestamp can be performed adjusting for possible roll over
// to the next month.
Pattern pattern = Pattern.compile(regex);
for (int i = 0; i < noOfLines; ++i) {
if (pattern.matcher(textEditor.getLine(i)).find()) {
- // Adjust to the METAR's Wmo Header line.
- lineIndex = i - 1;
+ lineIndex = i;
+ if (i > 0) {
+ Matcher m = METAR_PATTERN.matcher(textEditor
+ .getLine(i - 1));
+ if (!m.find()) {
+ // Adjust to the METAR's Wmo Header line.
+ --lineIndex;
+ haveWMOHeader = true;
+ }
+ }
break;
}
}
@@ -5903,11 +5949,9 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
}
} else {
String prefix = product.getWmoid() + " " + product.getSite();
- // System.out.println("new header" + prefix);
for (int i = 0; i < noOfLines; i++) {
if (textEditor.getLine(i).startsWith(prefix)) {
// found replacement point
- // System.out.println("found " + prefix + " at line " + i);
lineIndex = i;
break;
}
@@ -5916,46 +5960,61 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
if (lineIndex == -1) {
lineIndex = noOfLines;
}
- // note: this returns the number of lines in the text display area
- // Since lines are zero indexed, this points to the second line
- // of the product. Assuming a WMO header, this is the first line
- // of the product
- // System.out.println("inserting text at: " + lineIndex);
+
+ String productText = product.getProduct();
+
if (lineIndex == noOfLines) {
textEditor.append("\n");
- textEditor.append(product.getProduct());
+ textEditor.append(productText);
} else {
// need to find end of current product, then replace.
int nextProductLoc = -1;
- for (int i = lineIndex + 2; i < noOfLines; i++) {
- String temp = textEditor.getLine(i);
- if (!temp.startsWith(" ")) {
+ if (haveWMOHeader) {
+ // Assume next product also has WMO header
+ for (int i = lineIndex + 2; i < noOfLines; i++) {
+ String temp = textEditor.getLine(i);
+ if (!temp.startsWith(" ")) {
+ if (temp.startsWith("METAR")
+ || temp.startsWith("SPECI")) {
+ continue;
+ } else {
+ // found next product
+ nextProductLoc = i;
+ break;
+ }
+ }
+ }
+ } else {
+ // Remove WMO header
+ productText = productText
+ .substring(productText.indexOf('\n') + 1);
+ // Assume next product does not have a WMO header
+ for (int i = lineIndex + 1; i < noOfLines; ++i) {
+ String temp = textEditor.getLine(i);
if (temp.startsWith("METAR") || temp.startsWith("SPECI")) {
- continue;
- } else {
- // found next product
nextProductLoc = i;
break;
}
}
}
+
int start = textEditor.getOffsetAtLine(lineIndex);
int end = textEditor.getCharCount();
if (nextProductLoc != -1) {
end = textEditor.getOffsetAtLine(nextProductLoc);
- textEditor.replaceTextRange(start, end - start,
- product.getProduct() + "\n");
+ textEditor.replaceTextRange(start, end - start, productText
+ + "\n");
} else {
- textEditor.replaceTextRange(start, end - start,
- product.getProduct());
+ textEditor.replaceTextRange(start, end - start, productText);
}
}
// if updating, we need to highlight the site name. If the first word of
// the line is "METAR" or "SPECI", we need to highlight the second word
- lineIndex++; // need to skip the WMO header
+ if (haveWMOHeader) {
+ lineIndex++; // need to skip the WMO header
+ }
String line = textEditor.getLine(lineIndex);
- // System.out.println(line);
int startIndex = textEditor.getOffsetAtLine(lineIndex);
if (line.startsWith("METAR") || line.startsWith("SPECI")) {
startIndex += 6; // skip first word plus a space
@@ -5970,7 +6029,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
// retrieved for display in this text editor dialog
// instance.
TextDisplayModel.getInstance().setStdTextProduct(token, product);
- updating = false;
+ updateCount.addAndGet(-1);
}
@Override
@@ -6280,7 +6339,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
msgPIL = "";
}
if (isObsDisplayed(msgPIL)) {
- updating = true;
+ updateCount.addAndGet(1);
ICommand command = CommandFactory.getAfosCommand(msgPIL);
UpdateObsRun run = new UpdateObsRun(command);
VizApp.runSync(run);
@@ -7182,9 +7241,13 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
}
}
+ public void enableSend(boolean state) {
+ editorSendBtn.setEnabled(state);
+ }
+
public void enqueue(String afosId, NotifyExpiration notify2) {
queuedNotify = notify2;
- queuedAfos = afosId;
+ queuedProduct = afosId;
}
private boolean gfeForbidden(String ccc, String nnn) {
diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/print/PrintDisplay.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/print/PrintDisplay.java
index 6825f617cc..bb83845693 100644
--- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/print/PrintDisplay.java
+++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/print/PrintDisplay.java
@@ -19,13 +19,15 @@
**/
package com.raytheon.viz.texteditor.print;
-import java.awt.Color;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.print.PageFormat;
-import java.awt.print.Printable;
-import java.awt.print.PrinterException;
-import java.awt.print.PrinterJob;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.printing.Printer;
+import org.eclipse.swt.printing.PrinterData;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus.Priority;
@@ -39,6 +41,8 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 15, 2011 10557 rferrel Initial creation
+ * Jul 17, 2012 14274 rferrel Now use eclipse Printer instead of awt.
+ * Text is printed using same font as the GUI
*
*
*
@@ -47,107 +51,182 @@ import com.raytheon.uf.common.status.UFStatus.Priority;
*/
public class PrintDisplay {
- /**
- * Print the text/document to the default print.
- *
- * @param autoPrint
- * true send text directly to printer without prompting user for
- * selecting a different printer.
- * @param printedText
- * the text to print.
- */
- public static void print(boolean autoPrint, String printedText,
+ public static void print(final String printedText, final FontData fontData,
IUFStatusHandler statusHandler) {
- if (printedText == null || printedText.trim().length() == 0) {
- // Do not waste paper on blank text.
+ PrinterData data = Printer.getDefaultPrinterData();
+ if (data == null) {
+ statusHandler.handle(Priority.PROBLEM,
+ "No default printer specified.");
return;
}
- PrintDisplay printer = new PrintDisplay(autoPrint, statusHandler);
- printer.printIt(printedText);
+ if (printedText == null || printedText.trim().length() == 0) {
+ // Do not waste paper when nothing to print.
+ return;
+ }
+
+ final Printer printer = new Printer(data);
+ PrintDisplay pd = new PrintDisplay(printer, printedText, fontData);
+ pd.printJob();
}
- private boolean autoPrint;
+ private Printer printer;
- private IUFStatusHandler statusHandler;
+ private String textToPrint;
- private PrintDisplay(boolean autoPrint, IUFStatusHandler statusHandler) {
- this.autoPrint = autoPrint;
- this.statusHandler = statusHandler;
+ private FontData printerFontData;
+
+ private int leftMargin;
+
+ private int rightMargin;
+
+ private int topMargin;
+
+ private int bottomMargin;
+
+ private String tabs;
+
+ private GC gc;
+
+ private int tabWidth;
+
+ private int lineHeight;
+
+ StringBuilder wordBuffer;
+
+ int x;
+
+ int y;
+
+ int index;
+
+ int end;
+
+ private PrintDisplay(Printer printer, String text, FontData fontData) {
+ this.printer = printer;
+ this.textToPrint = text;
+ this.printerFontData = fontData;
}
- private void printIt(String printedText) {
- PrinterJob printerJob = PrinterJob.getPrinterJob();
-
- if (autoPrint || printerJob.printDialog()) {
- printerJob.setPrintable(new Document(printedText));
- try {
- printerJob.print();
- } catch (PrinterException e) {
- statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
- e);
+ private void printJob() {
+ Thread thread = new Thread("Printing") {
+ public void run() {
+ printIt();
+ printer.dispose();
}
+ };
+ thread.start();
+ }
+
+ private void printIt() {
+ if (printer.startJob("Text")) { // the string is the job name - shows up
+ // in the printer's job list
+ Rectangle clientArea = printer.getClientArea();
+ Rectangle trim = printer.computeTrim(0, 0, 0, 0);
+ Point dpi = printer.getDPI();
+
+ // one inch from left side of paper
+ leftMargin = dpi.x + trim.x;
+ // one inch from right side of paper
+ rightMargin = clientArea.width - dpi.x + trim.x + trim.width;
+ topMargin = dpi.y + trim.y; // one inch from top edge of paper
+ // one inch from bottom edge of paper
+ bottomMargin = clientArea.height - dpi.y + trim.y + trim.height;
+
+ // Create a buffer for computing tab width.
+ int tabSize = 4;
+ StringBuilder tabBuffer = new StringBuilder(tabSize);
+ for (int i = 0; i < tabSize; i++)
+ tabBuffer.append(' ');
+ tabs = tabBuffer.toString();
+
+ /*
+ * Create printer GC, and create and set the printer font &
+ * foreground color.
+ */
+ gc = new GC(printer);
+ Font printerFont = new Font(printer, printerFontData);
+ Color printerForegroundColor = new Color(printer, new RGB(0, 0, 0));
+ Color printerBackgroundColor = new Color(printer, new RGB(255, 255,
+ 255));
+
+ gc.setFont(printerFont);
+ gc.setForeground(printerForegroundColor);
+ gc.setBackground(printerBackgroundColor);
+ tabWidth = gc.stringExtent(tabs).x;
+ lineHeight = gc.getFontMetrics().getHeight();
+
+ // Print text to current gc using word wrap
+ printText();
+ printer.endJob();
+
+ // Cleanup graphics resources used in printing
+ printerFont.dispose();
+ printerForegroundColor.dispose();
+ printerBackgroundColor.dispose();
+ gc.dispose();
}
}
- private class Document implements Printable {
-
- private final String[] printedText;
-
- private int numPages = 0;
-
- public Document(String printedText) {
- super();
- this.printedText = printedText.split("\n");
+ private void printText() {
+ printer.startPage();
+ wordBuffer = new StringBuilder();
+ x = leftMargin;
+ y = topMargin;
+ index = 0;
+ end = textToPrint.length();
+ while (index < end) {
+ char c = textToPrint.charAt(index);
+ index++;
+ if (c != 0) {
+ if (c == 0x0a || c == 0x0d) {
+ if (c == 0x0d && index < end
+ && textToPrint.charAt(index) == 0x0a) {
+ index++; // if this is cr-lf, skip the lf
+ }
+ printWordBuffer();
+ newline();
+ } else {
+ if (c != '\t') {
+ wordBuffer.append(c);
+ }
+ if (Character.isWhitespace(c)) {
+ printWordBuffer();
+ if (c == '\t') {
+ x += tabWidth;
+ }
+ }
+ }
+ }
}
+ if (y + lineHeight <= bottomMargin) {
+ printer.endPage();
+ }
+ }
- @Override
- public int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
- throws PrinterException {
- // --- Create the Graphics2D object
- Graphics2D g2d = (Graphics2D) graphics;
-
- // --- Set the drawing color to black
- g2d.setPaint(Color.black);
- java.awt.Font font = g2d.getFont();
- String name = font.getName();
- int style = font.getStyle();
- int size = font.getSize();
-
- g2d.setFont(new java.awt.Font(name, style, size - 2));
-
- // --- Translate the origin to 0,0 for the top left corner
- g2d.translate(pageFormat.getImageableX(),
- pageFormat.getImageableY());
-
- // Determine the lines per page and number of pages to print.
- java.awt.FontMetrics metrics = g2d.getFontMetrics();
- int lineHeight = metrics.getHeight();
- int linesPerPage = (int) Math.floor(pageFormat.getImageableHeight()
- / lineHeight);
- numPages = ((printedText.length - 1) / linesPerPage) + 1;
-
- // Calculate the start line for this page.
- int startLine = pageIndex * linesPerPage;
- int endLine = startLine + linesPerPage - 1;
- if (endLine >= printedText.length) {
- endLine = printedText.length - 1;
+ private void printWordBuffer() {
+ if (wordBuffer.length() > 0) {
+ String word = wordBuffer.toString();
+ int wordWidth = gc.stringExtent(word).x;
+ if (x + wordWidth > rightMargin) {
+ // word doesn't fit on current line, so wrap
+ newline();
}
+ gc.drawString(word, x, y, false);
+ x += wordWidth;
+ wordBuffer.setLength(0);
+ }
+ }
- // Tell the PrinterJob if the page number is not a legal one.
- if (pageIndex >= numPages) {
- return NO_SUCH_PAGE;
+ private void newline() {
+ x = leftMargin;
+ y += lineHeight;
+ if (y + lineHeight > bottomMargin) {
+ printer.endPage();
+ if (index + 1 < end) {
+ y = topMargin;
+ printer.startPage();
}
-
- int y = 0;
- for (int i = startLine; i <= endLine; i++) {
- y += lineHeight;
- g2d.drawString(printedText[i], 0, y);
- }
-
- g2d.dispose();
- // --- Validate the page
- return (PAGE_EXISTS);
}
}
}
\ No newline at end of file
diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/qc/IQCCheck.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/qc/IQCCheck.java
index eda6d4048d..0a5d9d1365 100644
--- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/qc/IQCCheck.java
+++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/qc/IQCCheck.java
@@ -32,6 +32,8 @@ import java.util.regex.Pattern;
* ------------ ---------- ----------- --------------------------
* Initial creation
* Aug 25, 2011 10719 rferrel Removed the no longer common ugcPtrn.
+ * Aug 6, 2012 15219 Qinglu Lin For tmlPtrn, changed d{1,3}DEG to d{3}DEG.
+
*
*
* @version 1.0
@@ -72,7 +74,7 @@ public interface IQCCheck {
.compile("\\s{1,}\\d{3,4}\\s\\d{3,5}(|(\\s\\d{3,4}\\s\\d{3,5}){1,})");
public static final Pattern tmlPtrn = Pattern
- .compile("TIME...MOT...LOC \\d{3,4}Z\\s\\d{1,3}DEG\\s\\d{1,3}KT((\\s\\d{3,4}\\s\\d{3,5}){1,})");
+ .compile("TIME...MOT...LOC \\d{3,4}Z\\s\\d{3}DEG\\s\\d{1,3}KT((\\s\\d{3,4}\\s\\d{3,5}){1,})");
public static final Pattern subTMLPtrn = Pattern
.compile("(\\d{3,5}\\s){1,}");
diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/util/SiteAbbreviationUtil.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/util/SiteAbbreviationUtil.java
index f131873652..f6d37b613b 100644
--- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/util/SiteAbbreviationUtil.java
+++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/util/SiteAbbreviationUtil.java
@@ -25,6 +25,7 @@ import com.raytheon.uf.common.site.SiteMap;
import com.raytheon.uf.viz.core.catalog.DirectDbQuery;
import com.raytheon.uf.viz.core.catalog.DirectDbQuery.QueryLanguage;
import com.raytheon.uf.viz.core.exception.VizException;
+import com.raytheon.uf.viz.core.localization.LocalizationManager;
import com.raytheon.viz.texteditor.TextWarningConstants;
/**
@@ -45,6 +46,22 @@ import com.raytheon.viz.texteditor.TextWarningConstants;
public class SiteAbbreviationUtil {
+ private static String mySiteNode;
+
+ /**
+ * Returns the 3 letter site node for the current localization.
+ *
+ * @return
+ */
+ public static String getMySiteNode() {
+ if (mySiteNode == null) {
+ mySiteNode = getSiteNode(LocalizationManager.getInstance()
+ .getCurrentSite());
+ }
+
+ return mySiteNode;
+ }
+
/**
* Grabs the site node from the FXA database afoslookup table.
*
diff --git a/cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/TextWorkstationDlg.java b/cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/TextWorkstationDlg.java
index b72e6e73b4..d6a77e7f38 100755
--- a/cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/TextWorkstationDlg.java
+++ b/cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/TextWorkstationDlg.java
@@ -22,6 +22,7 @@ package com.raytheon.viz.textworkstation;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
import java.util.Timer;
@@ -110,9 +111,9 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
private Label utcTimeLabel;
- private Label gmtTimeLabel;
+ private Label localTimeLabel;
- SimpleDateFormat sdfGMT = new SimpleDateFormat("EEE dd MMM yyyy HH:mm z");
+ SimpleDateFormat sdfLocal = new SimpleDateFormat("EEE dd MMM yyyy HH:mm z");
SimpleDateFormat sdfUTC = new SimpleDateFormat("EEE dd MMM yyyy HH:mm z");
@@ -197,8 +198,8 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
}
private void initializeComponents() {
- sdfGMT.setTimeZone(TimeZone.getTimeZone("GMT"));
sdfUTC.setTimeZone(TimeZone.getTimeZone("UTC"));
+ sdfLocal.setTimeZone(Calendar.getInstance().getTimeZone());
createMenus();
new Label(shell, SWT.NONE).setText("host: "
@@ -365,16 +366,18 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
}
private void createTimeLabels() {
- GridData gd = new GridData(300, SWT.DEFAULT);
- gmtTimeLabel = new Label(shell, SWT.CENTER);
- gmtTimeLabel.setLayoutData(gd);
+ GridData gd = null;
gd = new GridData(300, SWT.DEFAULT);
utcTimeLabel = new Label(shell, SWT.CENTER);
utcTimeLabel.setLayoutData(gd);
+ gd = new GridData(300, SWT.DEFAULT);
+ localTimeLabel = new Label(shell, SWT.CENTER);
+ localTimeLabel.setLayoutData(gd);
+
date = SimulatedTime.getSystemTime().getTime();
- gmtTimeLabel.setText(sdfGMT.format(date));
+ localTimeLabel.setText(sdfLocal.format(date));
utcTimeLabel.setText(sdfUTC.format(date));
}
@@ -510,7 +513,7 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
private void updateTimeLabels() {
date = SimulatedTime.getSystemTime().getTime();
- gmtTimeLabel.setText(sdfGMT.format(date));
+ localTimeLabel.setText(sdfLocal.format(date));
utcTimeLabel.setText(sdfUTC.format(date));
}
@@ -596,14 +599,14 @@ public class TextWorkstationDlg extends CaveSWTDialog implements
// messages.
delta += TextWorkstationDlg.incDelta;
} else if (message.isNotExpired()) {
- String afosId = message.getMessagePayload().toString();
+ String product = message.getMessagePayload().toString();
if (wgDlg == null) {
- productToDisplay = afosId;
+ productToDisplay = product;
} else {
if (!wgDlg.isEditMode()) {
- wgDlg.showWarngenProduct(afosId, notify);
+ wgDlg.showWarngenProduct(product, notify);
} else {
- wgDlg.enqueue(afosId, notify);
+ wgDlg.enqueue(product, notify);
}
}
}
diff --git a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/VizWorkbenchManager.java b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/VizWorkbenchManager.java
index a45c3b9d47..de749799bb 100644
--- a/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/VizWorkbenchManager.java
+++ b/cave/com.raytheon.viz.ui/src/com/raytheon/viz/ui/VizWorkbenchManager.java
@@ -394,6 +394,9 @@ public class VizWorkbenchManager implements IPartListener, IPartListener2,
}
activeEditorMap
.put(part.getSite().getWorkbenchWindow(), active);
+ if (active instanceof IDisplayPaneContainer) {
+ notifyListeners();
+ }
}
}
}
diff --git a/cave/com.raytheon.viz.volumebrowser/localization/menus/xml/fieldsMenus.xml b/cave/com.raytheon.viz.volumebrowser/localization/menus/xml/fieldsMenus.xml
index 1a7d1e5442..b1021f011f 100644
--- a/cave/com.raytheon.viz.volumebrowser/localization/menus/xml/fieldsMenus.xml
+++ b/cave/com.raytheon.viz.volumebrowser/localization/menus/xml/fieldsMenus.xml
@@ -529,9 +529,9 @@
-
-
diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/comm/WarningSender.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/comm/WarningSender.java
index b985c4cdc7..0eeb06932a 100644
--- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/comm/WarningSender.java
+++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/comm/WarningSender.java
@@ -33,12 +33,12 @@ import javax.jms.MessageProducer;
import javax.jms.Session;
import com.raytheon.uf.common.dataplugin.text.request.InsertStdTextProductRequest;
-import com.raytheon.uf.common.serialization.DynamicSerializationManager;
-import com.raytheon.uf.common.serialization.DynamicSerializationManager.SerializationType;
+import com.raytheon.uf.common.serialization.SerializationUtil;
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.comm.JMSConnection;
+import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.localization.LocalizationManager;
import com.raytheon.uf.viz.core.requests.ThriftClient;
import com.raytheon.viz.core.mode.CAVEMode;
@@ -65,173 +65,209 @@ import com.raytheon.viz.texteditor.util.SiteAbbreviationUtil;
*/
public class WarningSender implements IWarngenObserver {
- private static final transient IUFStatusHandler statusHandler = UFStatus
- .getHandler(WarningSender.class);
+ private static final transient IUFStatusHandler statusHandler = UFStatus
+ .getHandler(WarningSender.class);
- private String hostName = null;
+ private String hostName = null;
- private boolean notifyError;
+ private boolean notifyError;
- private static final long MILLISECONDS_PER_SECOND = 1000;
+ private static final long MILLISECONDS_PER_SECOND = 1000;
- private static final long SECONDS_PER_MINUTE = 60;
+ private static final long SECONDS_PER_MINUTE = 60;
- private static final long TTL_MINUTES = 5;
+ private static final long TTL_MINUTES = 5;
- private static Pattern PATTERN = Pattern.compile("(\\d{1,1})");
+ private static Pattern PATTERN = Pattern.compile("(\\d{1,1})");
- private static final SimpleDateFormat sdf;
+ private static final SimpleDateFormat sdf;
- static {
- sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
- sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
- }
+ static {
+ sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
+ sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
+ }
- /*
- * (non-Javadoc) Incoming message was not a binary
- *
- * @see
- * com.raytheon.viz.texteditor.msgs.IWarngenObserver#setTextWarngenDisplay
- * (java.lang.String)
- */
- @Override
- public void setTextWarngenDisplay(String warning, boolean ne) {
- this.notifyError = ne;
+ /*
+ * (non-Javadoc) Incoming message was not a binary
+ *
+ * @see
+ * com.raytheon.viz.texteditor.msgs.IWarngenObserver#setTextWarngenDisplay
+ * (java.lang.String)
+ */
+ @Override
+ public void setTextWarngenDisplay(String warning, boolean ne) {
+ this.notifyError = ne;
- String number = "0";
- String host = TextWorkstationConstants.getId();
- long t0 = System.currentTimeMillis();
- String siteNode = SiteAbbreviationUtil.getSiteNode(LocalizationManager
- .getInstance().getCurrentSite());
- System.out.println("Get site node time: "
- + (System.currentTimeMillis() - t0));
- if (host == null) {
- statusHandler.handle(Priority.ERROR,
- "Text Workstation host not set in preferences.");
- } else {
- Matcher m = PATTERN.matcher(host);
- if (m.find()) {
- number = m.group();
- }
- }
+ String number = "0";
+ String host = TextWorkstationConstants.getId();
+ long t0 = System.currentTimeMillis();
+ String siteNode = SiteAbbreviationUtil.getSiteNode(LocalizationManager
+ .getInstance().getCurrentSite());
+ System.out.println("Get site node time: "
+ + (System.currentTimeMillis() - t0));
+ if (host == null) {
+ statusHandler.handle(Priority.ERROR,
+ "Text Workstation host not set in preferences.");
+ } else {
+ Matcher m = PATTERN.matcher(host);
+ if (m.find()) {
+ number = m.group();
+ }
+ }
- String id = siteNode + "WRKWG" + number;
+ String id = siteNode + "WRKWG" + number;
+ boolean sentToTextDatabase = false;
- try {
- CAVEMode mode = CAVEMode.getMode();
- boolean operationalMode = (CAVEMode.OPERATIONAL.equals(mode)
- || CAVEMode.TEST.equals(mode) ? true : false);
+ try {
+ boolean messageNotSent = true;
+ int connectCount = 0;
+ t0 = System.currentTimeMillis();
+ byte[] data = SerializationUtil.transformToThrift(id + ":"
+ + warning);
+ while (messageNotSent && connectCount < 4) {
+ Session s = null;
+ MessageProducer mp = null;
+ Connection conn = null;
+ try {
+ conn = JMSConnection.getInstance().getFactory()
+ .createConnection();
+ s = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+ mp = s.createProducer(s
+ .createQueue(TextWorkstationConstants
+ .getDestinationTextWorkstationQueueName()));
+ mp.setTimeToLive(TTL_MINUTES * SECONDS_PER_MINUTE
+ * MILLISECONDS_PER_SECOND);
+ BytesMessage m = s.createBytesMessage();
+ m.writeBytes(data);
+ mp.send(m);
+ long t1 = System.currentTimeMillis();
+ System.out.println(WarningSender.getCurTimeString() + ": "
+ + id + " sent to text workstation in " + (t1 - t0)
+ + "ms in " + (connectCount + 1)
+ + (connectCount > 0 ? " tries" : " try"));
+ messageNotSent = false;
+ } catch (JMSException e) {
+ if (notifyError) {
+ statusHandler
+ .handle(Priority.PROBLEM,
+ "Error trying to send product ["
+ + id
+ + "] to Text Workstation. Attempting to reconnect. ",
+ e);
+ notifyError = false;
+ }
+ } finally {
+ if (mp != null) {
+ try {
+ mp.close();
+ mp = null;
+ } catch (Exception e) {
+ mp = null;
+ }
+ }
+ if (s != null) {
+ try {
+ s.close();
+ s = null;
+ } catch (Exception e) {
+ s = null;
+ }
+ }
+ if (conn != null) {
+ try {
+ conn.close();
+ conn = null;
+ } catch (Exception e) {
+ conn = null;
+ }
+ }
+ }
+ if (messageNotSent) {
+ if (!sentToTextDatabase) {
+ try {
+ sendToTextDatabase(id, warning);
+ sentToTextDatabase = true;
+ } catch (Exception e) {
+ statusHandler.handle(Priority.PROBLEM,
+ "Error trying to save product [" + id
+ + "] to Text Database: ", e);
+ }
+ }
- // Generate StdTextProduct and insert into db
- t0 = System.currentTimeMillis();
- ThriftClient.sendRequest(new InsertStdTextProductRequest(id,
- warning, operationalMode));
+ connectCount++;
+ switch (connectCount) {
+ case 1:
+ Thread.sleep(1000);
+ break;
+ case 2:
+ Thread.sleep(5 * 1000);
+ break;
+ case 3:
+ Thread.sleep(30 * 1000);
+ break;
+ case 4:
+ statusHandler.handle(Priority.PROBLEM,
+ "Could not reconnect (" + id
+ + ") after 3 tries: ", null);
+ break;
+ }
+ }
+ }
- System.out.println(WarningSender.getCurTimeString() + ": " + id
- + " saved to textdb in "
- + (System.currentTimeMillis() - t0) + "ms");
+ if (!sentToTextDatabase) {
+ try {
+ sendToTextDatabase(id, warning);
+ sentToTextDatabase = true;
+ } catch (Exception e) {
+ statusHandler.handle(Priority.PROBLEM,
+ "Error trying to save product [" + id
+ + "] to Text Database: ", e);
+ }
+ }
+ } catch (UnknownHostException uhe) {
+ if (notifyError) {
+ statusHandler.handle(Priority.PROBLEM,
+ "unable to map hostname, " + hostName
+ + ", to an ip address", uhe);
+ notifyError = false;
+ }
- boolean messageNotSent = true;
- int connectCount = 0;
- t0 = System.currentTimeMillis();
- while (messageNotSent && connectCount < 4) {
- Session s = null;
- MessageProducer mp = null;
- Connection conn = null;
- try {
- conn = JMSConnection.getInstance().getFactory()
- .createConnection();
- s = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE);
- mp = s.createProducer(s
- .createQueue(TextWorkstationConstants
- .getDestinationTextWorkstationQueueName()));
- mp.setTimeToLive(TTL_MINUTES * SECONDS_PER_MINUTE
- * MILLISECONDS_PER_SECOND);
- BytesMessage m = s.createBytesMessage();
- m.writeBytes(DynamicSerializationManager.getManager(
- SerializationType.Thrift).serialize(id));
- mp.send(m);
- System.out.println(WarningSender.getCurTimeString() + ": "
- + id + " sent to text workstation in "
- + (System.currentTimeMillis() - t0) + "ms");
- messageNotSent = false;
- } catch (JMSException e) {
- if (notifyError) {
- statusHandler
- .handle(Priority.PROBLEM,
- "Error trying to send message ("
- + id
- + ") to Text Workstation. Attempting to reconnect. ",
- e);
- notifyError = false;
- }
- } finally {
- if (mp != null) {
- try {
- mp.close();
- mp = null;
- } catch (Exception e) {
- mp = null;
- }
- }
- if (s != null) {
- try {
- s.close();
- s = null;
- } catch (Exception e) {
- s = null;
- }
- }
- if (conn != null) {
- try {
- conn.close();
- conn = null;
- } catch (Exception e) {
- conn = null;
- }
- }
- }
- if (messageNotSent) {
- connectCount++;
- switch (connectCount) {
- case 1:
- Thread.sleep(1000);
- break;
- case 2:
- Thread.sleep(5 * 1000);
- break;
- case 3:
- Thread.sleep(30 * 1000);
- break;
- case 4:
- statusHandler.handle(Priority.PROBLEM,
- "Could not reconnect (" + id
- + ") after 3 tries: ", null);
- break;
- }
- }
- }
- } catch (UnknownHostException uhe) {
- if (notifyError) {
- statusHandler.handle(Priority.PROBLEM,
- "unable to map hostname, " + hostName
- + ", to an ip address", uhe);
- notifyError = false;
- }
+ } catch (Exception e) {
+ statusHandler.handle(Priority.PROBLEM,
+ "Error trying to send product [" + id
+ + "] to Text Workstation: ", e);
+ }
- } catch (Exception e) {
- statusHandler.handle(Priority.PROBLEM,
- "Error trying to send message (" + id
- + ") to Text Workstation: ", e);
- }
+ }
- }
+ /**
+ * Saves a product to the text database.
+ *
+ * @param id
+ * @param warning
+ * @throws VizException
+ */
+ public static void sendToTextDatabase(String id, String warning)
+ throws VizException {
+ CAVEMode mode = CAVEMode.getMode();
+ boolean operationalMode = (CAVEMode.OPERATIONAL.equals(mode)
+ || CAVEMode.TEST.equals(mode) ? true : false);
- public static String getCurTimeString() {
- String rval = null;
- synchronized (sdf) {
- rval = sdf.format(new Date());
- }
- return rval;
- }
+ // Generate StdTextProduct and insert into db
+ long t0 = System.currentTimeMillis();
+ ThriftClient.sendRequest(new InsertStdTextProductRequest(id, warning,
+ operationalMode));
+
+ System.out.println(WarningSender.getCurTimeString() + ": " + id
+ + " saved to textdb in " + (System.currentTimeMillis() - t0)
+ + "ms");
+ }
+
+ public static String getCurTimeString() {
+ String rval = null;
+ synchronized (sdf) {
+ rval = sdf.format(new Date());
+ }
+ return rval;
+ }
}
diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/config/DbPointSourceDataAdaptor.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/config/DbPointSourceDataAdaptor.java
index 351224ce2c..fd530137b8 100644
--- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/config/DbPointSourceDataAdaptor.java
+++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/config/DbPointSourceDataAdaptor.java
@@ -19,15 +19,20 @@
**/
package com.raytheon.viz.warngen.config;
+import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.apache.commons.lang.StringUtils;
+
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.geospatial.SpatialQueryResult;
+import com.raytheon.uf.viz.core.maps.rsc.DbMapQueryFactory;
import com.raytheon.viz.warngen.PreferenceUtil;
import com.raytheon.viz.warngen.gis.ClosestPoint;
import com.vividsolutions.jts.geom.Coordinate;
diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/Area.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/Area.java
index d9a6e9f085..1448711c68 100644
--- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/Area.java
+++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/Area.java
@@ -336,7 +336,9 @@ public class Area {
for (int i = 0; i < warnArea.getNumGeometries(); i++) {
Geometry geom = warnArea.getGeometryN(i);
if (f.geometry.intersects(geom)) {
- GeometryUtil.buildGeometryList(geoms, f.geometry);
+ Geometry intersect = f.geometry.intersection(geom);
+ intersect.setUserData(f.geometry.getUserData());
+ GeometryUtil.buildGeometryList(geoms, intersect);
break;
}
}
diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/Wx.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/Wx.java
index f182519702..f7fc246d90 100644
--- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/Wx.java
+++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/Wx.java
@@ -53,6 +53,8 @@ import com.raytheon.uf.common.dataplugin.warning.config.PathcastConfiguration;
import com.raytheon.uf.common.dataplugin.warning.config.PointSourceConfiguration;
import com.raytheon.uf.common.dataplugin.warning.config.PointSourceConfiguration.SearchMethod;
import com.raytheon.uf.common.dataplugin.warning.config.WarngenConfiguration;
+import com.raytheon.uf.common.dataplugin.warning.gis.GeospatialData;
+import com.raytheon.uf.common.dataplugin.warning.gis.GeospatialFactory;
import com.raytheon.uf.common.dataplugin.warning.util.FileUtil;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.geospatial.DestinationGeodeticCalculator;
@@ -264,6 +266,7 @@ public class Wx {
Date start = DateUtil.roundDate(new Date(wwaStartTime + delta),
pathcastConfiguration.getInterval());
Date stormTime = new Date(wwaStartTime);
+ DestinationGeodeticCalculator gc = new DestinationGeodeticCalculator();
while (start.getTime() <= wwaStopTime) {
PathCast cast = new PathCast();
cast.time = new Date(start.getTime());
@@ -277,7 +280,6 @@ public class Wx {
Coordinate[] pathCoords = new Coordinate[stormLocations.length];
for (int i = 0; i < pathCoords.length; ++i) {
Coordinate loc = stormLocations[i];
- DestinationGeodeticCalculator gc = new DestinationGeodeticCalculator();
gc.setStartingGeographicPoint(loc.x, loc.y);
long time = (cast.time.getTime() - stormTime.getTime()) / 1000;
double distance = stormTrackState.speed * time;
@@ -363,11 +365,9 @@ public class Wx {
null, false, SearchMode.INTERSECTS);
}
- SpatialQueryResult[] timeZoneFeatures = SpatialQueryFactory
- .create().query(timezoneTable,
- new String[] { timezoneField },
- bufferedPathCastArea, null, false,
- SearchMode.INTERSECTS);
+ // timeZones are limited, use data for whole CWA and further
+ // intersection later
+ GeospatialData[] timeZones = GeospatialFactory.getTimezones();
Map> pcPoints = new HashMap>();
for (PathCast pc : pathcasts) {
@@ -383,7 +383,8 @@ public class Wx {
Point centroid = pcGeom != null ? pcGeom.getCentroid()
: warningPolygon.getCentroid();
- SpatialQueryResult myArea = null, myTz = null;
+ SpatialQueryResult myArea = null;
+ GeospatialData myTz = null;
if (areaFeatures != null) {
// Find area and parent area
@@ -395,13 +396,13 @@ public class Wx {
}
}
- if (timeZoneFeatures != null) {
+ if (timeZones != null) {
// Find time zone
- if (timeZoneFeatures.length == 1) {
- myTz = timeZoneFeatures[0];
+ if (timeZones.length == 1) {
+ myTz = timeZones[0];
} else {
- for (SpatialQueryResult tzResult : timeZoneFeatures) {
- if (tzResult.geometry.contains(centroid)) {
+ for (GeospatialData tzResult : timeZones) {
+ if (tzResult.prepGeom.contains(centroid)) {
myTz = tzResult;
break;
}
@@ -435,7 +436,9 @@ public class Wx {
}
// Find closest points
- List points = new ArrayList();
+ GeodeticCalculator gc = new GeodeticCalculator();
+ List points = new ArrayList(
+ ptFeatures.length);
for (SpatialQueryResult pointRslt : ptFeatures) {
Geometry localPt = (Geometry) pointRslt.attributes
.get(transformedKey);
@@ -467,7 +470,6 @@ public class Wx {
cp.distance = minDist;
cp.roundedDistance = (int) metersToDistance
.convert(minDist);
- GeodeticCalculator gc = new GeodeticCalculator();
gc.setStartingGeographicPoint(cp.point.x, cp.point.y);
gc.setDestinationGeographicPoint(closestCoord.x,
closestCoord.y);
@@ -529,8 +531,7 @@ public class Wx {
// check for same point in other pathcast objects. If same point
// exists, remove from which ever pathcast is furthest away
Set closestPtNames = new HashSet(30);
- List tmpPoints = new ArrayList(
- maxCount);
+ List tmpPoints = new ArrayList(maxCount);
Queue tmp = new ArrayDeque(pathcasts);
while (tmp.isEmpty() == false) {
PathCast pc = tmp.remove();
@@ -560,14 +561,14 @@ public class Wx {
tmpPoints.clear();
for (int i = 0; i < points.size() && i < maxCount; ++i) {
- ClosestPoint point = points.get(i);
- String name = point.getName();
- if (!closestPtNames.contains(name)) {
- // To prevent duplicate cities in pathcast,
- // only unused point is added to tmpPoints
- tmpPoints.add(point);
- closestPtNames.add(name);
- }
+ ClosestPoint point = points.get(i);
+ String name = point.getName();
+ if (!closestPtNames.contains(name)) {
+ // To prevent duplicate cities in pathcast,
+ // only unused point is added to tmpPoints
+ tmpPoints.add(point);
+ closestPtNames.add(name);
+ }
}
if (tmpPoints.size() > 0) {
pc.points = tmpPoints.toArray(new ClosestPoint[tmpPoints
@@ -711,7 +712,7 @@ public class Wx {
// Sort by fields should have been validated to be same as well
List fields = pointConfigs[0].getSortBy() != null ? Arrays
- .asList(pointConfigs[0].getSortBy()) : new ArrayList();
+ .asList(pointConfigs[0].getSortBy()) : new ArrayList(0);
Geometry searchArea = null;
double bufferVal = thresholdInMeters;
@@ -734,9 +735,9 @@ public class Wx {
stormCoords.length + endStormCoords.length);
allCoords.addAll(Arrays.asList(stormCoords));
long time = (wwaStopTime - wwaStartTime) / 1000;
+ DestinationGeodeticCalculator gc = new DestinationGeodeticCalculator();
for (int i = stormCoords.length - 1; i >= 0; --i) {
Coordinate loc = stormCoords[i];
- DestinationGeodeticCalculator gc = new DestinationGeodeticCalculator();
gc.setStartingGeographicPoint(loc.x, loc.y);
double distance = stormTrackState.speed * time;
gc.setDirection(StormTrackDisplay
@@ -769,25 +770,32 @@ public class Wx {
List availablePoints = new ArrayList();
for (PointSourceConfiguration pointConfig : pointConfigs) {
+ long t0 = System.currentTimeMillis();
availablePoints.addAll(DataAdaptorFactory.createPointSource(
pointConfig).getData(config, pointConfig,
bufferedSearchArea, localizedSite));
+ long t1 = System.currentTimeMillis();
+ System.out.println("getClosestPoint.dbQuery took " + (t1 - t0)
+ + " for point source " + pointConfig.getPointSource());
}
// Convert searchArea to a local projection
Geometry localSearchArea = JTS.transform(searchArea, latLonToLocal);
- List> points = new ArrayList>();
Coordinate[] localCoords = localSearchArea.getCoordinates();
Coordinate[] coords = searchArea.getCoordinates();
+ List> points = new ArrayList>(
+ coords.length);
+ GeodeticCalculator gc = new GeodeticCalculator();
+ Map nameMap = new HashMap(
+ (int) (availablePoints.size() * 1.3));
for (int i = 0; i < coords.length; ++i) {
Coordinate coord = localCoords[i];
Geometry localDistanceGeom = dimensions == 1 ? localSearchArea : gf
.createPoint(coord);
Geometry distanceGeom = dimensions == 1 ? searchArea : gf
.createPoint(coords[i]);
- List pts = new ArrayList();
- Map nameMap = new HashMap();
+ nameMap.clear();
for (ClosestPoint cp : availablePoints) {
Geometry localPt = JTS.transform(gf.createPoint(cp.point),
@@ -800,16 +808,10 @@ public class Wx {
ClosestPoint existingPt = nameMap.get(cp.name);
if (existingPt == null || distance < existingPt.distance) {
// Set the distances
- ClosestPoint cp2 = new ClosestPoint(cp);
- cp2.distance = distance;
+ ClosestPoint cp2 = new ClosestPoint(cp);
+ cp2.distance = distance;
cp2.roundedDistance = (int) metersToDistance
.convert(distance);
- // No point by name or we are better at this location
- if (existingPt != null) {
- // There was an existing point, remove it
- pts.remove(existingPt);
- }
- GeodeticCalculator gc = new GeodeticCalculator();
gc.setStartingGeographicPoint(cp2.point.x, cp2.point.y);
Coordinate cen = distanceGeom.getCentroid()
.getCoordinate();
@@ -822,11 +824,12 @@ public class Wx {
cp2.oppositeRoundedAzimuth = ClosestPoint
.adjustAngle(cp2.roundedAzimuth + 180);
nameMap.put(cp2.name, cp2);
- pts.add(cp2);
}
}
}
+ List pts = new ArrayList(
+ nameMap.values());
if (fields.isEmpty() == false) {
// Sort the points based on sortBy fields
Collections.sort(pts, new ClosestPointComparator(fields));
@@ -839,38 +842,52 @@ public class Wx {
}
// Filter to maxCount (Somewhat duplicate logic as pathcast)
- Queue> tmp = new ArrayDeque>(
- points);
- while (tmp.isEmpty() == false) {
- List pts = tmp.remove();
- for (int i = 0; i < pts.size() && i < maxCount; ++i) {
- // For each point, look for duplicate points in another
- ClosestPoint cp = pts.get(i);
- for (List pts2 : tmp) {
- if (pts2 != pts) {
- ClosestPoint found = find(cp, pts2, maxCount);
- if (found != null) {
- // We found a point within maxCount in this
- // list.
- if (found.distance < cp.distance) {
- // This point is closer to the other
- pts.remove(i--);
- break;
- } else {
- // Remove from other pathcast, we are closer
- pts2.remove(found);
+ if (points.size() == 1) {
+ // optimized for single instance
+ List pts = points.get(0);
+ if (pts.size() > maxCount) {
+ // need to reduce points
+ pts.subList(maxCount, pts.size()).clear();
+ }
+ } else if (points.size() > 1) {
+ Queue> tmp = new ArrayDeque>(
+ points);
+ while (!tmp.isEmpty()) {
+ List