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 5d743cc132..1224f01e10 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 @@ -28,6 +28,8 @@ import org.eclipse.ui.handlers.HandlerUtil; import com.raytheon.uf.common.localization.LocalizationFile; import com.raytheon.uf.common.localization.LocalizationUtil; +import com.raytheon.uf.common.status.IUFStatusHandler; +import com.raytheon.uf.common.status.UFStatus; import com.raytheon.uf.viz.core.procedures.Procedure; import com.raytheon.uf.viz.d2d.ui.dialogs.procedures.OpenProcedureListDlg; import com.raytheon.uf.viz.d2d.ui.dialogs.procedures.ProcedureDlg; @@ -47,7 +49,8 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * Sep 13, 2007 chammack Initial Creation. * Oct 16, 2012 1229 rferrel Change to use ProcedureDlg.displayDialog. * Oct 16, 2012 1229 rferrel Changes for non-blocking ProcedureListDlg. - * Jun 7, 2013 2074 mnash Don't open the dialog if no procedures are deserialized + * Jun 07, 2013 2074 mnash Don't open the dialog if no procedures are deserialized + * Aug 11, 2014 3480 bclement added logging * * * @author chammack @@ -57,6 +60,9 @@ public class OpenAWIPSProcedure extends AbstractHandler { private OpenProcedureListDlg dialog; + private static final IUFStatusHandler log = UFStatus + .getHandler(OpenAWIPSProcedure.class); + /* * (non-Javadoc) * @@ -78,6 +84,8 @@ public class OpenAWIPSProcedure extends AbstractHandler { Procedure p = (Procedure) LoadSerializedXml .deserialize(f); if (p != null) { + log.info("Loading display file: " + + f.getAbsolutePath()); ProcedureDlg.displayDialog(LocalizationUtil .extractName(selectedFile.getName()), p, VizWorkbenchManager.getInstance() 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 f50665e65d..eb58ca14ea 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 @@ -102,6 +102,7 @@ import com.raytheon.viz.ui.editor.AbstractEditor; * Jan 16, 2013 DR 15367 D. Friedman Enable save button for Up/Down changes. * Feb 25, 2013 1640 bsteffen Dispose old display in BundleLoader * Jun 7, 2013 2074 mnash Remove resource if doesn't instantiate correctly + * Aug 11, 2014 3480 bclement added info logging when procedure is loaded * * * @author unknown @@ -863,6 +864,7 @@ public class ProcedureDlg extends CaveSWTDialog { } private void load(final Bundle b) { + statusHandler.info("Loading bundle: " + b.getName()); String editorName = null; if (b.getDisplays().length > 0) { editorName = DescriptorMap.getEditorId(b.getDisplays()[0] diff --git a/cave/com.raytheon.uf.viz.ncep.dataplugins.feature/feature.xml b/cave/com.raytheon.uf.viz.ncep.dataplugins.feature/feature.xml index 9a259e2ea3..9514d0d640 100644 --- a/cave/com.raytheon.uf.viz.ncep.dataplugins.feature/feature.xml +++ b/cave/com.raytheon.uf.viz.ncep.dataplugins.feature/feature.xml @@ -189,7 +189,7 @@ download-size="0" install-size="0" version="0.0.0" - unpack="false"/> + unpack="false"/> + + diff --git a/cave/com.raytheon.uf.viz.ncep.displays.feature/feature.xml b/cave/com.raytheon.uf.viz.ncep.displays.feature/feature.xml index 03e7b90a7d..38078f2d41 100644 --- a/cave/com.raytheon.uf.viz.ncep.displays.feature/feature.xml +++ b/cave/com.raytheon.uf.viz.ncep.displays.feature/feature.xml @@ -312,4 +312,11 @@ version="0.0.0" unpack="false"/> + + diff --git a/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResource.java b/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResource.java index 37f8acc4e5..9868571682 100644 --- a/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResource.java +++ b/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResource.java @@ -90,6 +90,7 @@ import com.raytheon.viz.lightning.cache.LightningFrameRetriever; * Jul 07, 2014 3333 bclement removed lightSource field * Jul 10, 2014 3333 bclement moved cache object inner classes to own package * moved name formatting to static method + * Aug 19, 2014 3542 bclement fixed strike count clipping issue * * * @@ -282,7 +283,13 @@ public class LightningResource extends if (magnification == 0.0) magnification=(float) 0.01; - IExtent extent = paintProps.getView().getExtent(); + /* + * we only want strikes that are visible so we have to filter any + * strikes that aren't in both the clipping pane and the view + */ + IExtent viewExtent = paintProps.getView().getExtent(); + IExtent clipExtent = paintProps.getClippingPane(); + IExtent extent = viewExtent.intersection(clipExtent); CacheObject cacheObject = cacheObjectMap .get(this.lastPaintedTime); diff --git a/edexOsgi/build.edex/build.xml b/edexOsgi/build.edex/build.xml index e2f1d8e301..e912f7c0c9 100644 --- a/edexOsgi/build.edex/build.xml +++ b/edexOsgi/build.edex/build.xml @@ -118,6 +118,10 @@ + + + diff --git a/edexOsgi/com.raytheon.edex.feature.uframe/feature.xml b/edexOsgi/com.raytheon.edex.feature.uframe/feature.xml index 2f833b67e6..5513565f86 100644 --- a/edexOsgi/com.raytheon.edex.feature.uframe/feature.xml +++ b/edexOsgi/com.raytheon.edex.feature.uframe/feature.xml @@ -132,4 +132,8 @@ id="com.raytheon.uf.edex.registry.feature" version="0.0.0"/> + + diff --git a/edexOsgi/com.raytheon.edex.plugin.grib/utility/common_static/base/grid/datasetInfo/gribDatasets_NCEP-7.xml b/edexOsgi/com.raytheon.edex.plugin.grib/utility/common_static/base/grid/datasetInfo/gribDatasets_NCEP-7.xml index 660785b62e..a6b3691151 100644 --- a/edexOsgi/com.raytheon.edex.plugin.grib/utility/common_static/base/grid/datasetInfo/gribDatasets_NCEP-7.xml +++ b/edexOsgi/com.raytheon.edex.plugin.grib/utility/common_static/base/grid/datasetInfo/gribDatasets_NCEP-7.xml @@ -60,6 +60,11 @@ GFS201
6
+ + GFS1degGbl + GFS229 +
3
+
gfsLR mrfNH diff --git a/edexOsgi/com.raytheon.edex.plugin.grib/utility/edex_static/base/grib/models/gribModels_NCEP-7.xml b/edexOsgi/com.raytheon.edex.plugin.grib/utility/edex_static/base/grib/models/gribModels_NCEP-7.xml index c3167b0953..43a13d5516 100644 --- a/edexOsgi/com.raytheon.edex.plugin.grib/utility/edex_static/base/grib/models/gribModels_NCEP-7.xml +++ b/edexOsgi/com.raytheon.edex.plugin.grib/utility/edex_static/base/grib/models/gribModels_NCEP-7.xml @@ -1610,7 +1610,7 @@ - gfs + GFS229
7
0 229 diff --git a/edexOsgi/com.raytheon.uf.common.remote.script/.classpath b/edexOsgi/com.raytheon.uf.common.remote.script/.classpath new file mode 100644 index 0000000000..5dabe46779 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.remote.script/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/edexOsgi/com.raytheon.uf.common.remote.script/.project b/edexOsgi/com.raytheon.uf.common.remote.script/.project new file mode 100644 index 0000000000..15c9625731 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.remote.script/.project @@ -0,0 +1,28 @@ + + + com.raytheon.uf.common.remote.script + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/edexOsgi/com.raytheon.uf.common.remote.script/.settings/org.eclipse.jdt.core.prefs b/edexOsgi/com.raytheon.uf.common.remote.script/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..8000cd6ca6 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.remote.script/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/edexOsgi/com.raytheon.uf.common.remote.script/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.common.remote.script/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..7b7b7ab21c --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.remote.script/META-INF/MANIFEST.MF @@ -0,0 +1,14 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Common +Bundle-SymbolicName: com.raytheon.uf.common.remote.script +Bundle-Version: 1.14.0.qualifier +Bundle-Vendor: RATHEON +Require-Bundle: com.raytheon.uf.common.serialization;bundle-version="1.12.1174", + com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174", + com.raytheon.uf.common.localization;bundle-version="1.12.1174", + com.raytheon.uf.common.auth;bundle-version="1.12.1174", + org.apache.commons.lang;bundle-version="2.3.0" +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-ActivationPolicy: lazy +Export-Package: com.raytheon.uf.common.remote.script diff --git a/edexOsgi/com.raytheon.uf.common.remote.script/build.properties b/edexOsgi/com.raytheon.uf.common.remote.script/build.properties new file mode 100644 index 0000000000..34d2e4d2da --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.remote.script/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/edexOsgi/com.raytheon.uf.common.remote.script/src/com/raytheon/uf/common/remote/script/RemoteScriptConstants.java b/edexOsgi/com.raytheon.uf.common.remote.script/src/com/raytheon/uf/common/remote/script/RemoteScriptConstants.java new file mode 100644 index 0000000000..c14a8239c1 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.remote.script/src/com/raytheon/uf/common/remote/script/RemoteScriptConstants.java @@ -0,0 +1,114 @@ +/** + * 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.common.remote.script; + +/** + * Useful constants for remote scripts. + *

+ * The resource defaults noted here are the ones defined in this class and are + * used when the a property value is not defined. These values can be overridden + * for the EDEX server by defining a property value in the EDEX resources file: + * com.raytheon.uf.edex.remote.script.properties. + *

+ * Except where noted a given run request may override a value. See + * {@link RemoteScriptRunRequest#putProperty(String, String)}. + * + *

+ * Resource properties:
+ * 
+ * KEY                        VALUES DESCRIPTION
+ * ======================================================
+ * remote.script.directory    Localized directories to search for scripts. (default
+ *                             remoteScripts). Cannot be overridden in a request.
+ * remote.script.timeout      Kill script process if it doesn't finish by this
+ *                             number of seconds (default 30).
+ * remote.script.use.stderr   When true separate standard out and standard error
+ *                             (default false).
+ * remote.script.setup.error  Exit error to use when unable to run a script
+ *                             (default 99).
+ * 
+ * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 12, 2014 #2742      rferrel     Initial creation
+ * 
+ * 
+ * + * @author rferrel + * @version 1.0 + */ + +public class RemoteScriptConstants { + /** + * Resource key to obtain script directory. Cannot be overridden in script + * properties. See + * {@link RemoteScriptRunRequest#putProperty(String, String)}. . + */ + public static final String scriptDirectoryKey = "remote.script.directory"; + + /** + * Resource/Property key to obtain execution timeout in seconds. See @{link + * {@link RemoteScriptRunRequest#putProperty(String, String)}. + */ + public static final String scriptTimeoutKey = "remote.script.timeout"; + + /** + * Resource/Property key to obtain boolean to separate standard error from + * the standard out stream. See + * {@link RemoteScriptRunRequest#putProperty(String, String)}. + */ + public static final String scriptUseStdErrKey = "remote.script.use.stderr"; + + /** + * Resource/Property key to obtain exit value to use when unable to run the + * script. + */ + public static final String scriptSetupErrrorKey = "remote.script.setup.error"; + + /** + * Default common static directory for remote scripts. See + * {@link RemoteScriptRunRequest#putProperty(String, String)}. + */ + public static final String scriptDirectoryDefault = "remoteScripts"; + + /** + * Default time out value in seconds. See + * {@link RemoteScriptRunRequest#putProperty(String, String)}. + */ + public static final String scriptTimeoutDefault = "30"; + + /** + * Default flag to separate standard error from the standard out stream. See + * {@link RemoteScriptRunRequest#putProperty(String, String)}. + */ + public static final String scriptUseStdErrDefault = "false"; + + /** + * Error exit value to use when unable to run the script. + */ + public static final String scriptSetUpErrorDefault = "99"; + + private RemoteScriptConstants() { + } +} diff --git a/edexOsgi/com.raytheon.uf.common.remote.script/src/com/raytheon/uf/common/remote/script/RemoteScriptListRequest.java b/edexOsgi/com.raytheon.uf.common.remote.script/src/com/raytheon/uf/common/remote/script/RemoteScriptListRequest.java new file mode 100644 index 0000000000..c0f1d41680 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.remote.script/src/com/raytheon/uf/common/remote/script/RemoteScriptListRequest.java @@ -0,0 +1,106 @@ +/** + * 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.common.remote.script; + +import com.raytheon.uf.common.localization.LocalizationContext; +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; + +/** + * This class is a request to obtain listing of remote scripts from desired + * localization directories. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 13, 2014 2742       rferrel     Initial creation
+ * 
+ * 
+ * + * @author rferrel + * @version 1.0 + */ + +@DynamicSerialize +public class RemoteScriptListRequest extends RemoteScriptRequest { + + /** + * The contexts to search for scripts. + */ + @DynamicSerializeElement + private LocalizationContext[] contexts; + + /** + * Default constructor. + */ + public RemoteScriptListRequest() { + } + + /** + * Constructor. + * + * @param userId + */ + public RemoteScriptListRequest(String userId, LocalizationContext[] contexts) { + this(); + setUserId(userId); + setContexts(contexts); + } + + /** + * Getter. + * + * @return contexts + */ + public LocalizationContext[] getContexts() { + return contexts; + } + + /** + * Setter. + * + * @param contexts + * - when null contexts is cleared. + */ + public void setContexts(LocalizationContext[] contexts) { + if (contexts != null) { + this.contexts = contexts; + } else { + contexts = new LocalizationContext[0]; + } + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder("RemoteScriptListRequest {"); + sb.append("userId: ").append(getUserId()); + sb.append(", contexts: ").append(getContexts()); + sb.append("}"); + return sb.toString(); + } +} diff --git a/edexOsgi/com.raytheon.uf.common.remote.script/src/com/raytheon/uf/common/remote/script/RemoteScriptListResponse.java b/edexOsgi/com.raytheon.uf.common.remote.script/src/com/raytheon/uf/common/remote/script/RemoteScriptListResponse.java new file mode 100644 index 0000000000..3170d31999 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.remote.script/src/com/raytheon/uf/common/remote/script/RemoteScriptListResponse.java @@ -0,0 +1,163 @@ +/** + * 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.common.remote.script; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +import com.raytheon.uf.common.localization.IPathManager; +import com.raytheon.uf.common.localization.LocalizationContext; +import com.raytheon.uf.common.localization.LocalizationFile; +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; + +/** + * This contains Localization Context map that is the result of a remote script + * list request. The keys are sorted list of the script file names. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 11, 2014 2742       rferrel     Initial creation
+ * 
+ * 
+ * + * @author rferrel + * @version 1.0 + */ + +@DynamicSerialize +public class RemoteScriptListResponse { + /** + * Map of contexts with sorted list of scripts as keys. + */ + @DynamicSerializeElement + private Map> scripts = new TreeMap>( + String.CASE_INSENSITIVE_ORDER); + + /** + * Default Constructor. + */ + public RemoteScriptListResponse() { + } + + /** + * Constructor. + * + * @param scripts + */ + public RemoteScriptListResponse( + Map> scripts) { + setScripts(scripts); + } + + /** + * Getter map of scripts' context lists the script keys are sorted. + * + * @return scripts + */ + public Map> getScripts() { + return scripts; + } + + /** + * Setter. + * + * @param scripts + * - when null scripts are cleared. + */ + public void setScripts(Map> scripts) { + this.scripts.clear(); + if (scripts != null) { + this.scripts.putAll(scripts); + } + } + + /** + * Convince method to a add file's script name and context to scripts. + * + * @param lFile + * @return true if not already in the set + */ + public boolean add(LocalizationFile lFile) { + String script = getName(lFile); + LocalizationContext context = lFile.getContext(); + + List contexts = scripts.get(script); + if (contexts == null) { + contexts = new ArrayList(); + scripts.put(script, contexts); + } + + if (!contexts.contains(context)) { + contexts.add(context); + return true; + } + return false; + } + + /** + * Convince method to remove the file's context from scripts. + * + * @param true - if file's script and context was in scripts. + */ + public boolean remove(LocalizationFile lFile) { + String name = getName(lFile); + List contexts = scripts.get(name); + if (contexts == null) { + return false; + } + + if (contexts.remove(contexts)) { + if (contexts.size() == 0) { + scripts.remove(name); + } + return true; + } + + return false; + } + + /** + * Get the script name of the localized file. + * + * @param lFile + * @return name + */ + private String getName(LocalizationFile lFile) { + String name = lFile.getName().trim(); + return name.substring(name.lastIndexOf(IPathManager.SEPARATOR) + 1); + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + public String toString() { + return String.format("RemoteScriptListResponse: {scripts: %s}", + getScripts()); + } +} diff --git a/edexOsgi/com.raytheon.uf.common.remote.script/src/com/raytheon/uf/common/remote/script/RemoteScriptRequest.java b/edexOsgi/com.raytheon.uf.common.remote.script/src/com/raytheon/uf/common/remote/script/RemoteScriptRequest.java new file mode 100644 index 0000000000..28e9842dfc --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.remote.script/src/com/raytheon/uf/common/remote/script/RemoteScriptRequest.java @@ -0,0 +1,88 @@ +/** + * 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.common.remote.script; + +import com.raytheon.uf.common.auth.req.AbstractPrivilegedRequest; +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; + +/** + * Class with common elements for the remote script requests, + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 11, 2014 2742       rferrel     Initial creation
+ * 
+ * 
+ * + * @author rferrel + * @version 1.0 + */ +@DynamicSerialize +public class RemoteScriptRequest extends AbstractPrivilegedRequest { + + /** User making the request. */ + @DynamicSerializeElement + private String userId; + + /** not authorized message. */ + @DynamicSerializeElement + private String notAuthorizedMessage = "Not Authorized"; + + /** + * Getter. + * + * @return userId + */ + public String getUserId() { + return userId; + } + + /** + * Setter. + * + * @param userId + */ + public void setUserId(String userId) { + this.userId = userId; + } + + /** + * Getter. + * + * @return notAuthorizedMessage + */ + public String getNotAuthorizedMessage() { + return notAuthorizedMessage; + } + + /** + * Setter. + * + * @param notAuthorizedMessage + */ + public void setNotAuthorizedMessage(String notAuthorizedMessage) { + this.notAuthorizedMessage = notAuthorizedMessage; + } +} diff --git a/edexOsgi/com.raytheon.uf.common.remote.script/src/com/raytheon/uf/common/remote/script/RemoteScriptRunRequest.java b/edexOsgi/com.raytheon.uf.common.remote.script/src/com/raytheon/uf/common/remote/script/RemoteScriptRunRequest.java new file mode 100644 index 0000000000..ad58f806b2 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.remote.script/src/com/raytheon/uf/common/remote/script/RemoteScriptRunRequest.java @@ -0,0 +1,263 @@ +/** + * 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.common.remote.script; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang.text.StrMatcher; +import org.apache.commons.lang.text.StrTokenizer; + +import com.raytheon.uf.common.localization.LocalizationContext; +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; + +/** + * This class is a request to run a remote script from desired localization + * directory. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 19, 2014 2743       rferrel     Initial creation
+ * 
+ * 
+ * + * @author rferrel + * @version 1.0 + */ + +@DynamicSerialize +public class RemoteScriptRunRequest extends RemoteScriptRequest { + @DynamicSerializeElement + String script; + + @DynamicSerializeElement + LocalizationContext context; + + /** + * Mapping of resource properties to override. See + * {@link RemoteScriptConstants}. + */ + @DynamicSerializeElement + private Map propertyMap = new HashMap(); + + /** + * Command line arguments for the remote script. + */ + @DynamicSerializeElement + private List scriptArguments = new ArrayList(); + + /** + * Default constructor. + */ + public RemoteScriptRunRequest() { + } + + /** + * Constructor. + * + * @param userId + * - user to run the script + * @param filename + * - script's filename located in the script directory. See + * {@link RemoteScriptConstants}. + * @param context + * - The localize directory's context that contains the script. + * See {@link RemoteScriptListResponse#get(String)} + */ + public RemoteScriptRunRequest(String userId, String script, + LocalizationContext context) { + this(); + setUserId(userId); + setScript(script); + setContext(context); + } + + /** + * Get the context associated with the script's filename. See + * {@link RemoteScriptListResponse#get(String)}. + * + * @return context + */ + public LocalizationContext getContext() { + return context; + } + + /** + * Set the context associated with the script's filename. See + * {@link RemoteScriptListResponse#get(String)}. + * + * @param context + */ + public void setContext(LocalizationContext context) { + this.context = context; + } + + /** + * Getter for script property map. Recommend this only be used for + * serialization, see {@link RemoteScriptConstants}. + * + * @return propertyMap + */ + public Map getPropertyMap() { + return propertyMap; + } + + /** + * Setter for script property map. This is used to override the script + * property values for handling the script. Recommend this only be used for + * serialization, see {@link RemoteScriptConstants}. + * + * @param propertyMap + * - when null map cleared so default values will be used + */ + public void setPropertyMap(Map propertyMap) { + this.propertyMap.clear(); + if (propertyMap != null) { + this.propertyMap.putAll(propertyMap); + } + } + + /** + * Override the default resource property, see {@link RemoteScriptConstants} + * . + * + * @param key + * @param value + * @return oldValue - previous value for key + */ + public String putProperty(String key, String value) { + return propertyMap.put(key, value); + } + + /** + * Remove property. + * + * @param key + * - property to remove + * @return value - Value removed or null if none + */ + public String removeProperty(String key) { + return propertyMap.remove(key); + } + + /** + * Get list of command line arguments for the script in the order sent to + * the process builder. See {@link java.lang.ProcessBuilder#command(List)}. + * Note the full path name to the script to run will be added by the handler + * when sending the request. + * + * @return scriptArguments + */ + public List getScriptArguments() { + return scriptArguments; + } + + public String getScript() { + return script; + } + + public void setScript(String script) { + this.script = script; + } + + /** + * Set the list of command line arguments for the script in the order they + * are to be sent to the process builder. See + * {@link java.lang.ProcessBuilder#command(List)}. Note the full path name + * to the script to run will be added by the handler when sending the + * request. + * + * @param scriptArguments + */ + public void setScriptArguments(List scriptArguments) { + this.scriptArguments.clear(); + if (scriptArguments != null) { + this.scriptArguments.addAll(scriptArguments); + } + } + + /** + * Append an argument to the script's argument list. + * + * @param argument + * @return success - true when added to the list + */ + public boolean addScriptArgument(String argument) { + return scriptArguments.add(argument); + } + + /** + * This clears the script argument list and breaks arguments into a list + * which becomes the new script argument list. The arguments is split into + * tokens delimited by whitespace. A token may be surrounded by single or + * double quotes. A quote may be escaped within a quoted section by + * duplicating itself. + * + *
+     * Examples of lists from java strings:
+     * "a b c"                  - Three arguments [a, b, c]
+     * "1 'a b c'd 3"           - Three arguments [1, a b cd, 3]
+     * "1 \"a b c\"d 3"         - Three arguments [1, a b cd, 3]
+     * "1 'a b ''c'''d 3"       - Three arguments [1, a b 'c'd, 3]
+     * "1 \"a b \"\"c\"\"\"d 3" - Three arguments [1, a b "c"d, 3]
+     * 
+ */ + public void parseAndSetScriptArguments(String arguments) { + if (arguments == null || (arguments.trim().length() == 0)) { + clearScriptArguements(); + return; + } + String[] args = (new StrTokenizer(arguments, StrMatcher.spaceMatcher(), + StrMatcher.quoteMatcher())).getTokenArray(); + setScriptArguments(Arrays.asList(args)); + } + + /** + * Remove all arguments from the script's argument list. + */ + public void clearScriptArguements() { + scriptArguments.clear(); + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(getClass().getName()); + sb.append("[ userId: ").append(getUserId()); + sb.append(", script: ").append(getScript()); + sb.append(", context: ").append(getContext()); + sb.append(", propertyMap: ").append(propertyMap); + sb.append(", scriptArguments: ").append(getScriptArguments()); + sb.append("]"); + return sb.toString(); + } +} diff --git a/edexOsgi/com.raytheon.uf.common.remote.script/src/com/raytheon/uf/common/remote/script/RemoteScriptRunResponse.java b/edexOsgi/com.raytheon.uf.common.remote.script/src/com/raytheon/uf/common/remote/script/RemoteScriptRunResponse.java new file mode 100644 index 0000000000..81010ae3e3 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.common.remote.script/src/com/raytheon/uf/common/remote/script/RemoteScriptRunResponse.java @@ -0,0 +1,172 @@ +/** + * 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.common.remote.script; + +import com.raytheon.uf.common.serialization.annotations.DynamicSerialize; +import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement; + +/** + * This contains the results from running a remote script. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 19, 2014 2743       rferrel     Initial creation
+ * 
+ * 
+ * + * @author rferrel + * @version 1.0 + */ + +@DynamicSerialize +public class RemoteScriptRunResponse { + /** + * The exit status for the script. + */ + @DynamicSerializeElement + private Integer exitStatus; + + /** + * The scripts output either just stdout or a combination of stadout and + * stderr. See {@link RemoteScriptConstants}. + */ + @DynamicSerializeElement + private String output = ""; + + /** + * When requested a separate sting with stderr. See + * {@link RemoteScriptConstants}. + */ + @DynamicSerializeElement + private String error = ""; + + /** + * When true script process timed out and was killed otherwise false. See + * {@link RemoteScriptConstants}. + */ + @DynamicSerializeElement + private boolean timedOut = false; + + /** + * Default Constructor. + */ + public RemoteScriptRunResponse() { + } + + /** + * Get the exit status for the process running the script. + * + * @return exitStatus + */ + public Integer getExitStatus() { + return exitStatus; + } + + /** + * Set the exit status for script's process. Should only be used by the + * handler and serialization. + * + * @param exitStatus + */ + public void setExitStatus(Integer exitStatus) { + this.exitStatus = exitStatus; + } + + /** + * Get the script's output. Based on the request properties this is either + * just stdout or a combination of stdout and stderr. See + * {@link RemoteScriptConstants}. + * + * @return output - never null + */ + public String getOutput() { + return output; + } + + /** + * Set the script's output. Based on the request properties this is either + * just stdout or a combination of stdout and stderr. Should only be used by + * the handler and serialization. See {@link RemoteScriptConstants}. + * + * @param output + */ + public void setOutput(String output) { + this.output = (output == null) ? "" : output; + } + + /** + * Get script's stderr when not placed in output. + * + * @return error - never null + */ + public String getError() { + return error; + } + + /** + * Set script's stderr when not place in output. Should only be used by the + * handler and serialization. + * + * @param error + */ + public void setError(String error) { + this.error = (error == null) ? "" : error; + } + + /** + * Flag to indicate script did not finish in the desired number of seconds. + * See {@link RemoteScriptConstants}. + * + * @return true when script process is killed otherwise false + */ + public boolean isTimedOut() { + return timedOut; + } + + /** + * Set the timed out flag. Should only be used by the handler and + * serialization. See {@link RemoteScriptConstants}. + * + * @param timeOut + */ + public void setTimedOut(boolean timedOut) { + this.timedOut = timedOut; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + public String toString() { + StringBuilder sb = new StringBuilder(this.getClass().getName()); + sb.append("["); + sb.append("exitStatus: ").append(getExitStatus()); + sb.append(", timedOut: ").append(isTimedOut()); + sb.append(", error: \"").append(getError()).append("\""); + sb.append(", output: \"").append(getOutput()).append("\""); + sb.append("]"); + return sb.toString(); + } +} diff --git a/edexOsgi/com.raytheon.uf.edex.remote.script.feature/.project b/edexOsgi/com.raytheon.uf.edex.remote.script.feature/.project new file mode 100644 index 0000000000..a5f433fa4b --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.remote.script.feature/.project @@ -0,0 +1,17 @@ + + + com.raytheon.uf.edex.remote.script.feature + + + + + + org.eclipse.pde.FeatureBuilder + + + + + + org.eclipse.pde.FeatureNature + + diff --git a/edexOsgi/com.raytheon.uf.edex.remote.script.feature/build.properties b/edexOsgi/com.raytheon.uf.edex.remote.script.feature/build.properties new file mode 100644 index 0000000000..64f93a9f0b --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.remote.script.feature/build.properties @@ -0,0 +1 @@ +bin.includes = feature.xml diff --git a/edexOsgi/com.raytheon.uf.edex.remote.script.feature/com.raytheon.uf.edex.remote.script.feature.ecl b/edexOsgi/com.raytheon.uf.edex.remote.script.feature/com.raytheon.uf.edex.remote.script.feature.ecl new file mode 100644 index 0000000000..e69de29bb2 diff --git a/edexOsgi/com.raytheon.uf.edex.remote.script.feature/feature.xml b/edexOsgi/com.raytheon.uf.edex.remote.script.feature/feature.xml new file mode 100644 index 0000000000..1805e7b3a2 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.remote.script.feature/feature.xml @@ -0,0 +1,34 @@ + + + + + [Enter Feature Description here.] + + + + [Enter Copyright Description here.] + + + + [Enter License Description here.] + + + + + + + diff --git a/edexOsgi/com.raytheon.uf.edex.remote.script/.classpath b/edexOsgi/com.raytheon.uf.edex.remote.script/.classpath new file mode 100644 index 0000000000..ad32c83a78 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.remote.script/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/edexOsgi/com.raytheon.uf.edex.remote.script/.project b/edexOsgi/com.raytheon.uf.edex.remote.script/.project new file mode 100644 index 0000000000..4abe6eabcd --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.remote.script/.project @@ -0,0 +1,28 @@ + + + com.raytheon.uf.edex.remote.script + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/edexOsgi/com.raytheon.uf.edex.remote.script/.settings/org.eclipse.jdt.core.prefs b/edexOsgi/com.raytheon.uf.edex.remote.script/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..8000cd6ca6 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.remote.script/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/edexOsgi/com.raytheon.uf.edex.remote.script/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.remote.script/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..2bc201a02f --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.remote.script/META-INF/MANIFEST.MF @@ -0,0 +1,18 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: RemoteScript +Bundle-SymbolicName: com.raytheon.uf.edex.remote.script +Bundle-Version: 1.14.0.qualifier +Bundle-Vendor: RAYTHEON +Require-Bundle: com.raytheon.uf.common.serialization;bundle-version="1.12.1174", + com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174", + com.raytheon.uf.common.localization;bundle-version="1.12.1174", + com.raytheon.uf.common.remote.script;bundle-version="1.0.0", + com.raytheon.uf.common.status;bundle-version="1.12.1174", + com.raytheon.uf.edex.auth;bundle-version="1.12.1174", + com.raytheon.uf.common.auth;bundle-version="1.12.1174", + com.raytheon.uf.common.time;bundle-version="1.12.1174", + com.raytheon.uf.common.util;bundle-version="1.12.1174", + com.raytheon.uf.common.comm;bundle-version="1.12.1174" +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Export-Package: com.raytheon.uf.edex.remote.script diff --git a/edexOsgi/com.raytheon.uf.edex.remote.script/build.properties b/edexOsgi/com.raytheon.uf.edex.remote.script/build.properties new file mode 100644 index 0000000000..5791d48d5f --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.remote.script/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + res/ diff --git a/edexOsgi/com.raytheon.uf.edex.remote.script/res/spring/remotescript-request.xml b/edexOsgi/com.raytheon.uf.edex.remote.script/res/spring/remotescript-request.xml new file mode 100644 index 0000000000..2f90605999 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.remote.script/res/spring/remotescript-request.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/edexOsgi/com.raytheon.uf.edex.remote.script/resources/com.raytheon.uf.edex.remote.script.properties b/edexOsgi/com.raytheon.uf.edex.remote.script/resources/com.raytheon.uf.edex.remote.script.properties new file mode 100644 index 0000000000..6a0c8d853a --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.remote.script/resources/com.raytheon.uf.edex.remote.script.properties @@ -0,0 +1,21 @@ +# The values shown here are the default values in the RemoteScriptConstants class. +# To change a property's default value for the EDEX server do the following: +# 1 - Edit this file and uncomment the desired property line(s). +# (remove the # at the start of the line.) +# 2 - Change the property's value +# 3 - Save the Changes +# 4 - Restart EDEX request. + +# The localized directory that contains scripts. +remote.script.directory=ncep/remoteScripts + +# Number of seconds to wait for script's process to complete before handler kills the process. +# Note the value will be adjusted to be less then the HttpClient's socket timeout value. +#remote.script.timeout=30 + +# Default use of standard error. When true Separate the standard output and error streams; +# otherwise combine them into standard out. +#remote.script.use.stderr=false + +# Exit error to use when unable to run a script. Must be an integer. +#remote.script.setup.error=99 diff --git a/edexOsgi/com.raytheon.uf.edex.remote.script/src/com/raytheon/uf/edex/remote/script/AbstractRemoteScriptHandler.java b/edexOsgi/com.raytheon.uf.edex.remote.script/src/com/raytheon/uf/edex/remote/script/AbstractRemoteScriptHandler.java new file mode 100644 index 0000000000..30205f60e0 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.remote.script/src/com/raytheon/uf/edex/remote/script/AbstractRemoteScriptHandler.java @@ -0,0 +1,174 @@ +/** + * 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.edex.remote.script; + +import com.raytheon.uf.common.auth.exception.AuthorizationException; +import com.raytheon.uf.common.auth.user.IUser; +import com.raytheon.uf.common.localization.IPathManager; +import com.raytheon.uf.common.remote.script.RemoteScriptConstants; +import com.raytheon.uf.common.remote.script.RemoteScriptRequest; +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.util.ITimer; +import com.raytheon.uf.common.time.util.TimeUtil; +import com.raytheon.uf.common.util.FileUtil; +import com.raytheon.uf.edex.auth.AuthManager; +import com.raytheon.uf.edex.auth.AuthManagerFactory; +import com.raytheon.uf.edex.auth.req.AbstractPrivilegedRequestHandler; +import com.raytheon.uf.edex.auth.resp.AuthorizationResponse; +import com.raytheon.uf.edex.auth.roles.IRoleStorage; + +/** + * Abstract class for the remote script handlers. Performs authorization and + * timing of requests. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 12, 2014 2742       rferrel     Initial creation
+ * 
+ * 
+ * + * @author rferrel + * @version 1.0 + */ + +public abstract class AbstractRemoteScriptHandler extends + AbstractPrivilegedRequestHandler { + + /** Status handler of the handling class using this class. */ + protected final transient IUFStatusHandler statusHandler; + + /** Common static directory for scripts. */ + protected final String scriptsDirectory; + + /** The handler's roleId defined in the common remoteScriptAdminRoles.xml */ + protected final String roleId; + + /** + * Application name. This must match the application tag in the user role + * file. + */ + private static final String APPLICATION = "Remote Script"; + + /** + * Construct. + * + * @param statusHandler + */ + public AbstractRemoteScriptHandler(String roleId) { + this.statusHandler = UFStatus.getHandler(this.getClass()); + this.roleId = roleId; + + String scriptsDirectory = FileUtil.edexPath(System.getProperty( + RemoteScriptConstants.scriptDirectoryKey, + RemoteScriptConstants.scriptDirectoryDefault)); + + // Strip tailing separators. + if (scriptsDirectory.endsWith(IPathManager.SEPARATOR)) { + StringBuilder sb = new StringBuilder(scriptsDirectory); + do { + sb.setLength(sb.length() - 1); + } while ((sb.length() > 0) + && (sb.lastIndexOf(IPathManager.SEPARATOR) == (sb.length() - 1))); + scriptsDirectory = sb.toString(); + } + this.scriptsDirectory = scriptsDirectory; + } + + /** + * The method a subclass must implement to perform the work for the desired + * request. + * + * @param request + * @return results + */ + abstract protected Object performRequest(RemoteScriptRequest request); + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.common.serialization.comm.IRequestHandler#handleRequest + * (com.raytheon.uf.common.serialization.comm.IServerRequest) + */ + @Override + public Object handleRequest(RemoteScriptRequest request) throws Exception { + Object result = null; + + if (statusHandler.isPriorityEnabled(Priority.INFO)) { + statusHandler.handle(Priority.INFO, String.format( + "Start for %s, do %s", request.getUserId(), getRoleId())); + } + + ITimer timer = TimeUtil.getTimer(); + timer.start(); + result = performRequest(request); + timer.stop(); + + if (statusHandler.isPriorityEnabled(Priority.INFO)) { + statusHandler.handle( + Priority.INFO, + String.format("Finish for %s, do %s, took %s", + request.getUserId(), getRoleId(), + TimeUtil.prettyDuration(timer.getElapsedTime()))); + } + + return result; + } + + protected String getRoleId() { + return roleId; + } + + /** + * Performs the authorization work for the handlers. + * + * @param user + * @param request + * @return authorizationResponse + * @throws AuthorizationException + */ + public AuthorizationResponse authorized(IUser user, + RemoteScriptRequest request) throws AuthorizationException { + AuthManager manager = AuthManagerFactory.getInstance().getManager(); + IRoleStorage roleStorage = manager.getRoleStorage(); + + String roleId = getRoleId(); + + boolean authorized = roleStorage.isAuthorized(roleId, user.uniqueId() + .toString(), APPLICATION); + + if (authorized) { + return new AuthorizationResponse(authorized); + } else { + String message = "Not Authorized to run " + roleId; + if (statusHandler.isPriorityEnabled(Priority.INFO)) { + statusHandler.handle(Priority.INFO, + String.format("%s, %s", user.uniqueId(), message)); + } + return new AuthorizationResponse(message); + } + } +} diff --git a/edexOsgi/com.raytheon.uf.edex.remote.script/src/com/raytheon/uf/edex/remote/script/RemoteScriptListHandler.java b/edexOsgi/com.raytheon.uf.edex.remote.script/src/com/raytheon/uf/edex/remote/script/RemoteScriptListHandler.java new file mode 100644 index 0000000000..2c100e3b74 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.remote.script/src/com/raytheon/uf/edex/remote/script/RemoteScriptListHandler.java @@ -0,0 +1,103 @@ +/** + * 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.edex.remote.script; + +import com.raytheon.uf.common.localization.IPathManager; +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.remote.script.RemoteScriptListRequest; +import com.raytheon.uf.common.remote.script.RemoteScriptListResponse; +import com.raytheon.uf.common.remote.script.RemoteScriptRequest; +import com.raytheon.uf.common.status.UFStatus.Priority; + +/** + * Handler to get the remote script list. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 14, 2014 2742       rferrel     Initial creation
+ *                                      Exclude files with md5 checksum extension.
+ * 
+ * 
+ * + * @author rferrel + * @version 1.0 + */ + +public class RemoteScriptListHandler extends AbstractRemoteScriptHandler { + + /** Extension for check sum files to remove from listing. */ + private final String MD5_EXT = ".md5"; + + /** + * Constructor. + */ + public RemoteScriptListHandler() { + // The role id in the common remoteScriptAdminRoles.xml + super("remote.script.list"); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.remote.script.RemoteScriptHandler#performRequest + * (com.raytheon.uf.common.remote.script.RemoteScriptRequest) + */ + public Object performRequest(RemoteScriptRequest request) { + IPathManager pm = PathManagerFactory.getPathManager(); + RemoteScriptListRequest req = (RemoteScriptListRequest) request; + + if (statusHandler.isPriorityEnabled(Priority.DEBUG)) { + statusHandler.handle(Priority.DEBUG, + String.format("Request: %s", req)); + } + + LocalizationContext[] ctxs = req.getContexts(); + + RemoteScriptListResponse result = new RemoteScriptListResponse(); + + for (LocalizationContext ctx : ctxs) { + LocalizationFile[] lFiles = pm.listFiles(ctx, scriptsDirectory, + null, false, true); + if ((lFiles != null) && (lFiles.length > 0)) { + for (LocalizationFile lFile : lFiles) { + if (!lFile.getName().trim().endsWith(MD5_EXT)) { + result.add(lFile); + System.out.println(lFile.getFile().getAbsolutePath()); + } + } + } + } + + if (statusHandler.isPriorityEnabled(Priority.DEBUG)) { + statusHandler.handle(Priority.DEBUG, + String.format("Results: %s", result)); + } + + return result; + } + +} diff --git a/edexOsgi/com.raytheon.uf.edex.remote.script/src/com/raytheon/uf/edex/remote/script/RemoteScriptRunHandler.java b/edexOsgi/com.raytheon.uf.edex.remote.script/src/com/raytheon/uf/edex/remote/script/RemoteScriptRunHandler.java new file mode 100644 index 0000000000..390b28c7d0 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.remote.script/src/com/raytheon/uf/edex/remote/script/RemoteScriptRunHandler.java @@ -0,0 +1,303 @@ +/** + * 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.edex.remote.script; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import com.raytheon.uf.common.comm.HttpClient; +import com.raytheon.uf.common.localization.IPathManager; +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.remote.script.RemoteScriptConstants; +import com.raytheon.uf.common.remote.script.RemoteScriptRequest; +import com.raytheon.uf.common.remote.script.RemoteScriptRunRequest; +import com.raytheon.uf.common.remote.script.RemoteScriptRunResponse; +import com.raytheon.uf.common.status.UFStatus.Priority; +import com.raytheon.uf.common.time.util.TimeUtil; +import com.raytheon.uf.common.util.RunProcess; + +/** + * Handler to Run a remote script and return the results. + * + *
+ * 
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    Engineer    Description
+ * ------------ ---------- ----------- --------------------------
+ * Mar 19, 2014 2743       rferrel     Initial creation
+ * 
+ * 
+ * + * @author rferrel + * @version 1.0 + */ + +public class RemoteScriptRunHandler extends AbstractRemoteScriptHandler { + + /** + * Time to back off from socket time out to allow completion of a timeout + * script. + */ + private static final int BACKOFF_MSEC = 100; + + /** + * Resource timeout. + */ + private final int defaultTimeoutSec; + + /** + * Resource flag value. + */ + private final boolean defaultUseStdErrFlag; + + /** + * Resource set up exit status. + */ + private final int defaultSetupExit; + + /** + * Constructor setup roleId and resource property values. + */ + public RemoteScriptRunHandler() { + // The role id in the common remoteScriptAdminRoles.xml + super("remote.script.run"); + + // Set up default values. + String defaultTimeoutStr = System.getProperty( + RemoteScriptConstants.scriptTimeoutKey, + RemoteScriptConstants.scriptTimeoutDefault); + int defaultTimeoutSec = -1; + try { + defaultTimeoutSec = Integer.parseInt(defaultTimeoutStr); + } catch (NumberFormatException ex) { + defaultTimeoutSec = -1; + } finally { + if (defaultTimeoutSec <= 0) { + defaultTimeoutSec = Integer + .parseInt(RemoteScriptConstants.scriptTimeoutDefault); + } + this.defaultTimeoutSec = defaultTimeoutSec; + } + + String defaultUseStdErr = System.getProperty( + RemoteScriptConstants.scriptUseStdErrKey, + RemoteScriptConstants.scriptUseStdErrDefault); + this.defaultUseStdErrFlag = Boolean.parseBoolean(defaultUseStdErr); + + String defaultSetupErrorStr = System.getProperty( + RemoteScriptConstants.scriptSetupErrrorKey, + RemoteScriptConstants.scriptUseStdErrDefault); + int defaultSetupExit = 0; + try { + defaultSetupExit = Integer.parseInt(defaultSetupErrorStr); + + } catch (NumberFormatException ex) { + defaultSetupExit = 0; + } finally { + if (defaultSetupExit <= 0) { + defaultSetupExit = Integer + .parseInt(RemoteScriptConstants.scriptSetUpErrorDefault); + } + this.defaultSetupExit = defaultSetupExit; + } + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.common.serialization.comm.IRequestHandler#handleRequest + * (com.raytheon.uf.common.serialization.comm.IServerRequest) + */ + @Override + public Object handleRequest(RemoteScriptRequest request) throws Exception { + return super.handleRequest(request); + } + + /* + * (non-Javadoc) + * + * @see + * com.raytheon.uf.edex.remote.script.RemoteScriptHandler#performRequest + * (com.raytheon.uf.common.remote.script.RemoteScriptRequest) + */ + public Object performRequest(RemoteScriptRequest request) { + RemoteScriptRunRequest req = (RemoteScriptRunRequest) request; + RemoteScriptRunResponse result = new RemoteScriptRunResponse(); + + Map propMap = req.getPropertyMap(); + + String timeoutValue = propMap + .get(RemoteScriptConstants.scriptTimeoutKey); + int timeoutSec = -1; + if (timeoutValue == null) { + timeoutSec = defaultTimeoutSec; + } else { + try { + timeoutSec = Integer.parseInt(timeoutValue); + if (timeoutSec <= 0) { + timeoutSec = defaultTimeoutSec; + } + } catch (NumberFormatException ex) { + statusHandler.handle(Priority.PROBLEM, + String.format("Bad timeout value %s", timeoutValue)); + timeoutSec = defaultTimeoutSec; + } finally { + if (timeoutSec <= 0) { + timeoutSec = defaultTimeoutSec; + } + } + } + + long timeout = timeoutSec * TimeUtil.MILLIS_PER_SECOND; + + String useStdErrString = propMap + .get(RemoteScriptConstants.scriptUseStdErrKey); + + boolean useStdErr = defaultUseStdErrFlag; + if (useStdErrString != null) { + useStdErr = Boolean.parseBoolean(useStdErrString); + } + + String setupExitValue = propMap + .get(RemoteScriptConstants.scriptSetupErrrorKey); + int setupExit = -1; + + if (setupExitValue == null) { + setupExit = defaultSetupExit; + } else { + + try { + setupExit = Integer.parseInt(setupExitValue); + } catch (NumberFormatException ex) { + statusHandler.handle(Priority.PROBLEM, String.format( + "Bad setup Error exit value %s", setupExitValue)); + setupExit = defaultSetupExit; + } finally { + if (setupExit <= 0) { + setupExit = defaultSetupExit; + } + } + } + + List arguments = req.getScriptArguments(); + String script = req.getScript(); + LocalizationContext context = req.getContext(); + + IPathManager pm = PathManagerFactory.getPathManager(); + String name = scriptsDirectory + IPathManager.SEPARATOR + script; + LocalizationFile lFile = pm.getLocalizationFile(context, name); + File file = lFile.getFile(); + File dir = file.getParentFile(); + + if (!file.canExecute()) { + String message = String.format("Not an executable script: \"%s\".", + lFile); + return sendMessage(result, message, useStdErr, setupExit); + } + + int maxTimeout = HttpClient.getInstance().getSocketTimeout() + - BACKOFF_MSEC; + if (maxTimeout <= 0) { + String message = String + .format("HttpClient's socket timeout of %d msec not enough time to run a remote script.", + HttpClient.getInstance().getSocketTimeout()); + return sendMessage(result, message, useStdErr, setupExit); + } else if (timeout > maxTimeout) { + timeout = maxTimeout; + } + + List args = new ArrayList(); + args.add(file.getAbsolutePath()); + if (arguments != null && (arguments.size() > 0)) { + args.addAll(arguments); + } + + ProcessBuilder pb = new ProcessBuilder(args); + pb.redirectErrorStream(!useStdErr); + pb.directory(dir); + Process p = null; + RunProcess rp = RunProcess.getRunProcess(); + String errorMessage = null; + + // TODO - The timeout/destroy should be placed in RunProcess along with + // limiting the size of stdout/stderr. + try { + p = pb.start(); + rp.setProcess(p); + synchronized (rp) { + rp.wait(timeout); + if (!rp.isExecComplete()) { + p.destroy(); + result.setTimedOut(true); + rp.notify(); + errorMessage = "Script timed out."; + } + } + } catch (Exception ex) { + errorMessage = "Problem running script: " + + ex.getLocalizedMessage().trim(); + statusHandler.handle(Priority.PROBLEM, errorMessage, ex); + + } finally { + if (p != null) { + result.setOutput(rp.getStdout()); + result.setError(rp.getStderr()); + } + result.setExitStatus(rp.waitFor()); + if (errorMessage != null) { + if (useStdErr) { + result.setError(result.getError() + "\n" + errorMessage); + } else { + result.setOutput(result.getOutput() + "\n" + errorMessage); + } + } + } + return result; + } + + /** + * Report a problem in running the script. + * + * @param result + * @param message + * @param useStdErr + * @param setupExit + * @return result + */ + private RemoteScriptRunResponse sendMessage(RemoteScriptRunResponse result, + String message, boolean useStdErr, int setupExit) { + statusHandler.handle(Priority.PROBLEM, message); + + if (useStdErr) { + result.setError(message); + } else { + result.setOutput(message); + } + + result.setExitStatus(setupExit); + return result; + } +} diff --git a/edexOsgi/com.raytheon.uf.edex.remote.script/utility/common_static/base/roles/remoteScriptAdminRoles.xml b/edexOsgi/com.raytheon.uf.edex.remote.script/utility/common_static/base/roles/remoteScriptAdminRoles.xml new file mode 100644 index 0000000000..acecfb9c98 --- /dev/null +++ b/edexOsgi/com.raytheon.uf.edex.remote.script/utility/common_static/base/roles/remoteScriptAdminRoles.xml @@ -0,0 +1,20 @@ + + + Remote Script + + + + This permission allows the user to retrive a listing of remote scripts. + + + + + + This permission allows the user to execute a remote script. + + + + remote.script.list + remote.script.run + + \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.edex.common/utility/common_static/base/ncep/remoteScripts/baseScript-1 b/ncep/gov.noaa.nws.ncep.edex.common/utility/common_static/base/ncep/remoteScripts/baseScript-1 new file mode 100755 index 0000000000..e69de29bb2 diff --git a/ncep/gov.noaa.nws.ncep.edex.common/utility/common_static/base/ncep/remoteScripts/test_script b/ncep/gov.noaa.nws.ncep.edex.common/utility/common_static/base/ncep/remoteScripts/test_script new file mode 100755 index 0000000000..918423117c --- /dev/null +++ b/ncep/gov.noaa.nws.ncep.edex.common/utility/common_static/base/ncep/remoteScripts/test_script @@ -0,0 +1,32 @@ +#!/bin/sh + +usage(){ + cat <: number of seconds to sleep. + --help print out usage + +EOF + exit +} + +if [ $# -lt 1 ]; then + usage +fi + +if [ "$1" == "--help" ]; then + usage +else + sleep $1 + if [ "$?" == 0 ]; then + echo Sleeping...$1 seconds...Done! + exit 0 + else + exit -1 + fi +fi \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/META-INF/MANIFEST.MF b/ncep/gov.noaa.nws.ncep.ui.nsharp/META-INF/MANIFEST.MF index 3693e3d7cd..c310149a30 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/META-INF/MANIFEST.MF +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/META-INF/MANIFEST.MF @@ -35,6 +35,9 @@ Import-Package: com.raytheon.uf.common.serialization.comm, com.raytheon.uf.viz.d2d.ui.perspectives, com.raytheon.uf.viz.sounding, com.vividsolutions.jts.geom, + gov.noaa.nws.ncep.common.dataplugin.gpd, + gov.noaa.nws.ncep.common.dataplugin.gpd.product, + gov.noaa.nws.ncep.common.dataplugin.gpd.query, gov.noaa.nws.ncep.common.dataplugin.ncuair, gov.noaa.nws.ncep.edex.common.ncinventory, gov.noaa.nws.ncep.edex.common.sounding, diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/NsharpConstants.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/NsharpConstants.java index 9e49061ee0..7a790590c7 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/NsharpConstants.java +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/NsharpConstants.java @@ -1,4 +1,5 @@ package gov.noaa.nws.ncep.ui.nsharp; + /** * * gov.noaa.nws.ncep.ui.nsharp.NsharpConstants @@ -9,9 +10,9 @@ package gov.noaa.nws.ncep.ui.nsharp; *
  * SOFTWARE HISTORY
  * 
- * Date         Ticket#    	Engineer    Description
- * -------		------- 	-------- 	-----------
- * 05/23/2010	229			Chin Chen	Initial coding
+ * Date         Ticket#     Engineer    Description
+ * -------      -------     --------    -----------
+ * 05/23/2010   229         Chin Chen   Initial coding
  *
  * 
* @@ -35,71 +36,100 @@ import org.eclipse.swt.graphics.Rectangle; import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle; public class NsharpConstants { - public static Rectangle NSHARP_SkewTRectangle = new Rectangle(0, 0, 3200, 1850); + public static Rectangle NSHARP_SkewTRectangle = new Rectangle(0, 0, 3200, + 1850); + public static Rectangle NSHARP_HodoRectangle = new Rectangle(0, 0, 100, 100); - public static final int DEFAULT_CANVAS_HEIGHT=700; - public static final int DEFAULT_CANVAS_WIDTH=1100; - //public static double TEMPERATURE_MIN = -115.0; - public static float KnotsToMetersPerSecond = 0.5144444F; + + public static final int DEFAULT_CANVAS_HEIGHT = 700; + + public static final int DEFAULT_CANVAS_WIDTH = 1100; + + // public static double TEMPERATURE_MIN = -115.0; + public static float KnotsToMetersPerSecond = 0.5144444F; + public static final UnitConverter kelvinToCelsius = SI.KELVIN - .getConverterTo(SI.CELSIUS); + .getConverterTo(SI.CELSIUS); + public static final UnitConverter metersToFeet = SI.METER - .getConverterTo(NonSI.FOOT); + .getConverterTo(NonSI.FOOT); public static final UnitConverter feetToMeters = NonSI.FOOT - .getConverterTo(SI.METRE); + .getConverterTo(SI.METRE); - //public static double WIND_SPEED_MIN = 0.0; + // public static double WIND_SPEED_MIN = 0.0; - //public static double WIND_SPEED_MAX = 250.0; + // public static double WIND_SPEED_MAX = 250.0; - // public static double WIND_DIR_MIN = 0.0; + // public static double WIND_DIR_MIN = 0.0; + + // public static double WIND_DIR_MAX = 360.0; + + public static final int WINDBARB_DISTANCE_DEFAULT = 600; // in meters - //public static double WIND_DIR_MAX = 360.0; - - public static final int WINDBARB_DISTANCE_DEFAULT= 600; // in meters public static final float WINDBARB_WIDTH = 2; + public static final float WINDBARB_SIZE = 2.5f; public static double PRESSURE_MIN = 100.0; public static double PRESSURE_MAX = 973.0; - - public static final double MAX_PRESSURE = 1050; - public static final double MIN_PRESSURE = 100; - // horizontal pressure line that will be drawn. - public static final Integer[] PRESSURE_MAIN_LEVELS = { 1000, 850, - 700, 500, 300, 200,150}; - public static final int[] PRESSURE_MARK_LEVELS = { 1000, 950, 900, 850, 800, - 750, 700, 650, 600, 550, 500, 450, 400, 350, 300, 250, 200, 150 - }; - public static final int[] PRESSURE_NUMBERING_LEVELS = { 1000, 850, - 700, 500, 300, 200, 150 }; - //Icing pressure level 1000, 900,800,700,600, 500,400, 300 + public static final double MAX_PRESSURE = 1050; + + public static final double MIN_PRESSURE = 100; + + // horizontal pressure line that will be drawn. + public static final Integer[] PRESSURE_MAIN_LEVELS = { 1000, 850, 700, 500, + 300, 200, 150 }; + + public static final int[] PRESSURE_MARK_LEVELS = { 1000, 950, 900, 850, + 800, 750, 700, 650, 600, 550, 500, 450, 400, 350, 300, 250, 200, + 150 }; + + public static final int[] PRESSURE_NUMBERING_LEVELS = { 1000, 850, 700, + 500, 300, 200, 150 }; + + // Icing pressure level 1000, 900,800,700,600, 500,400, 300 public static final double ICING_PRESSURE_LEVEL_BOTTOM = 1000; + public static final double ICING_PRESSURE_LEVEL_TOP = 300; + public static final double ICING_PRESSURE_LEVEL_INC = 100; - //Icing relative humidity 100, 90,80,70,60, 50,40, 30,20,10,0 + + // Icing relative humidity 100, 90,80,70,60, 50,40, 30,20,10,0 public static final double ICING_RELATIVE_HUMIDITY_LEFT = 0; + public static final double ICING_RELATIVE_HUMIDITY_RIGHT = 100; + public static final double ICING_RELATIVE_HUMIDITY_INC = 10; - //Icing temperature (C) 25,20,15,10,5,0,-5,-10, -15,-20,-25 + + // Icing temperature (C) 25,20,15,10,5,0,-5,-10, -15,-20,-25 public static final double ICING_TEMPERATURE_RIGHT = 25; + public static final double ICING_TEMPERATURE_LEFT = -25; + public static final double ICING_TEMPERATURE_INC = 5; - //Turbulence pressure level 1000, 900,800,700,600, 500,400, 300, 200, 100 - public static final double TURBULENCE_PRESSURE_LEVEL_TOP =100; - public static final double TURBULENCE_PRESSURE_LEVEL_BOTTOM =1000; - public static final double TURBULENCE_PRESSURE_LEVEL_INC =100; - //Turbulence LN Richardson Number -2,-1, 0, 1,2,3,4,5,6,7,8 - public static final double TURBULENCE_LN_RICHARDSON_NUMBER_LEFT =8; - public static final double TURBULENCE_LN_RICHARDSON_NUMBER_RIGHT =-2; - public static final double TURBULENCE_LN_RICHARDSON_NUMBER_INC =-1; - //Turbulence wind shear TKE 50,45,40,35,30,25,20,15,10,5,0 + // Turbulence pressure level 1000, 900,800,700,600, 500,400, 300, 200, 100 + public static final double TURBULENCE_PRESSURE_LEVEL_TOP = 100; + + public static final double TURBULENCE_PRESSURE_LEVEL_BOTTOM = 1000; + + public static final double TURBULENCE_PRESSURE_LEVEL_INC = 100; + + // Turbulence LN Richardson Number -2,-1, 0, 1,2,3,4,5,6,7,8 + public static final double TURBULENCE_LN_RICHARDSON_NUMBER_LEFT = 8; + + public static final double TURBULENCE_LN_RICHARDSON_NUMBER_RIGHT = -2; + + public static final double TURBULENCE_LN_RICHARDSON_NUMBER_INC = -1; + + // Turbulence wind shear TKE 50,45,40,35,30,25,20,15,10,5,0 public static final double TURBULENCE_WIND_SHEAR_TKE_LEFT = 0; + public static final double TURBULENCE_WIND_SHEAR_TKE_RIGHT = 50; + public static final double TURBULENCE_WIND_SHEAR_TKE_INC = 5; // lightGray. @@ -109,12 +139,13 @@ public class NsharpConstants { * Color for moist adiabat lines */ public static final RGB moistAdiabatColor = new RGB(0, 127, 255); - public static final RGB degreeSpokeColor = new RGB(238,238,238); + + public static final RGB degreeSpokeColor = new RGB(238, 238, 238); /** * Color for dry adiabat lines */ - public static final RGB dryAdiabatColor = new RGB(70,130,180); + public static final RGB dryAdiabatColor = new RGB(70, 130, 180); /** * Color for mixing ratio lines @@ -124,7 +155,7 @@ public class NsharpConstants { /** * Color for temperature lines */ - public static final RGB temperatureColor = new RGB(0,102,255); + public static final RGB temperatureColor = new RGB(0, 102, 255); /** * Color for pressure lines @@ -165,8 +196,11 @@ public class NsharpConstants { public static DecimalFormat windFormat = new DecimalFormat("###.#"); public static char DEGREE_SYMBOL = '\u00B0'; + public static char SQUARE_SYMBOL = '\u00B2'; + public static char THETA_SYMBOL = '\u03D1'; + public static char PERCENT_SYMBOL = '\u0025'; public static double endpointRadius = 4; @@ -179,638 +213,1151 @@ public class NsharpConstants { public static double height = top - bottom; - public static double left = -height*0.45;//(-height / 2) - 1; + public static double left = -height * 0.45;// (-height / 2) - 1; - public static double right = height*0.55;//(height / 2) + 1; + public static double right = height * 0.55;// (height / 2) + 1; public static double center = (left + right) / 2; - public static RGB color_vanilla = new RGB(255,239,206); - public static RGB color_red = new RGB(255,0,0);//red - public static RGB color_green = new RGB(0,255,0);//green - public static RGB color_darkgreen = new RGB(0x2f,0x4f,0x2f);//green - public static RGB color_mdgreen = new RGB(0x34,0x80,0x17);//green - public static RGB color_coral = new RGB(0xf0,0x80,0x80); - public static RGB color_lawngreen = new RGB(119,255,0);//green - public static RGB color_yellow_green = new RGB(154,205,50);//green - public static RGB color_yellow = new RGB(255,255,0);//yellow - public static RGB color_yellow_DK = new RGB(238,238,0);//yellow - public static RGB color_cyan = new RGB(0,255,255); //cyan - public static RGB color_cyan_md = new RGB(0,238,238); //cyan_md, cyan2 - public static RGB color_navy = new RGB(0,0,128); //navy - public static RGB color_apricot = new RGB(251,206,177); - public static RGB color_plum = new RGB(0xB9,0x3B,0x8F); - public static RGB color_purple = new RGB(0x8E,0x35,0xEF); - public static RGB color_violet = new RGB(125,0,255);//violet - public static RGB color_violet_red = new RGB(208,32,144);//violet - public static RGB color_violet_md = new RGB(208,32,144);//md-violet - public static RGB color_white = new RGB(255,255,255);//white - public static RGB color_brown = new RGB(166,104,41);//brown - public static RGB color_black = new RGB(0,0,0);//black - public static RGB color_orangered = new RGB(255,0x45, 0);//orangered - public static RGB color_orange = new RGB(255,122, 66);//orange - public static RGB color_darkorange = new RGB(255,140, 0);//orange - public static RGB color_babypink = new RGB(249,207, 221);// - public static RGB color_deeppink = new RGB(255,20, 147);// - public static RGB color_hotpink = new RGB(255,105, 180);// - public static RGB color_pink = new RGB(255, 192, 203); - public static RGB color_blue = new RGB(0,0,255); - public static RGB color_stellblue = new RGB(70,130,180); - public static RGB color_royalblue = new RGB(65,105,225); - public static RGB color_skyblue = new RGB(135,206,235); - public static RGB color_lightblue = new RGB(173, 223,255); - public static RGB color_dodgerblue = new RGB(30,144,255); - public static RGB color_chocolate = new RGB(210,105,30); - public static RGB color_firebrick = new RGB(178,34,34); - public static RGB color_gold = new RGB(255,215,0); - public static RGB color_magenta = new RGB(255,0,255); - public static RGB color_maroon = new RGB(0x80,0,0); - public static final RGB[] COLOR_ARRAY = {color_green, color_violet,color_yellow,color_hotpink, - color_stellblue,color_yellow_green,color_royalblue,color_violet_red,color_orange,color_deeppink, - color_dodgerblue, color_chocolate,color_navy}; - - public static final HashMap gempakColorToRGB = new HashMap(){ - /** - * - */ - private static final long serialVersionUID = 1L; - { - put(1,NsharpConstants.color_vanilla); - put(2,NsharpConstants.color_red); - put(3,NsharpConstants.color_green); - put(4,NsharpConstants.color_blue); - put(5,NsharpConstants.color_yellow); - put(6,NsharpConstants.color_cyan); - put(7,NsharpConstants.color_magenta); - put(8,NsharpConstants.color_brown); - put(9,NsharpConstants.color_coral); - put(10,NsharpConstants.color_apricot); - put(11,NsharpConstants.color_pink); - put(12,NsharpConstants.color_deeppink); - put(13,NsharpConstants.color_violet_md); - put(14,NsharpConstants.color_maroon); - put(15,NsharpConstants.color_firebrick); - put(16,NsharpConstants.color_orangered); - put(17,NsharpConstants.color_orange); - put(18,NsharpConstants.color_darkorange); - put(19,NsharpConstants.color_gold); - put(20,NsharpConstants.color_yellow_DK); - put(21,NsharpConstants.color_lawngreen); - put(22,NsharpConstants.color_mdgreen); - put(23,NsharpConstants.color_darkgreen); - put(24,NsharpConstants.color_blue); - put(25,NsharpConstants.color_lightblue); - put(26,NsharpConstants.color_skyblue); - put(27,NsharpConstants.color_cyan_md); - put(28,NsharpConstants.color_violet); - put(29,NsharpConstants.color_purple); - put(30,NsharpConstants.color_plum); - put(31,NsharpConstants.color_white); - put(32,NsharpConstants.color_black); - } - }; + public static RGB color_vanilla = new RGB(255, 239, 206); + + public static RGB color_red = new RGB(255, 0, 0);// red + + public static RGB color_green = new RGB(0, 255, 0);// green + + public static RGB color_darkgreen = new RGB(0x2f, 0x4f, 0x2f);// green + + public static RGB color_mdgreen = new RGB(0x34, 0x80, 0x17);// green + + public static RGB color_coral = new RGB(0xf0, 0x80, 0x80); + + public static RGB color_lawngreen = new RGB(119, 255, 0);// green + + public static RGB color_yellow_green = new RGB(154, 205, 50);// green + + public static RGB color_yellow = new RGB(255, 255, 0);// yellow + + public static RGB color_yellow_DK = new RGB(238, 238, 0);// yellow + + public static RGB color_cyan = new RGB(0, 255, 255); // cyan + + public static RGB color_cyan_md = new RGB(0, 238, 238); // cyan_md, cyan2 + + public static RGB color_navy = new RGB(0, 0, 128); // navy + + public static RGB color_apricot = new RGB(251, 206, 177); + + public static RGB color_plum = new RGB(0xB9, 0x3B, 0x8F); + + public static RGB color_purple = new RGB(0x8E, 0x35, 0xEF); + + public static RGB color_violet = new RGB(125, 0, 255);// violet + + public static RGB color_violet_red = new RGB(208, 32, 144);// violet + + public static RGB color_violet_md = new RGB(208, 32, 144);// md-violet + + public static RGB color_white = new RGB(255, 255, 255);// white + + public static RGB color_brown = new RGB(166, 104, 41);// brown + + public static RGB color_black = new RGB(0, 0, 0);// black + + public static RGB color_orangered = new RGB(255, 0x45, 0);// orangered + + public static RGB color_orange = new RGB(255, 122, 66);// orange + + public static RGB color_darkorange = new RGB(255, 140, 0);// orange + + public static RGB color_babypink = new RGB(249, 207, 221);// + + public static RGB color_deeppink = new RGB(255, 20, 147);// + + public static RGB color_hotpink = new RGB(255, 105, 180);// + + public static RGB color_pink = new RGB(255, 192, 203); + + public static RGB color_blue = new RGB(0, 0, 255); + + public static RGB color_stellblue = new RGB(70, 130, 180); + + public static RGB color_royalblue = new RGB(65, 105, 225); + + public static RGB color_skyblue = new RGB(135, 206, 235); + + public static RGB color_lightblue = new RGB(173, 223, 255); + + public static RGB color_dodgerblue = new RGB(30, 144, 255); + + public static RGB color_chocolate = new RGB(210, 105, 30); + + public static RGB color_firebrick = new RGB(178, 34, 34); + + public static RGB color_gold = new RGB(255, 215, 0); + + public static RGB color_magenta = new RGB(255, 0, 255); + + public static RGB color_maroon = new RGB(0x80, 0, 0); + + public static final RGB[] COLOR_ARRAY = { color_green, color_violet, + color_yellow, color_hotpink, color_stellblue, color_yellow_green, + color_royalblue, color_violet_red, color_orange, color_deeppink, + color_dodgerblue, color_chocolate, color_navy }; + + public static final HashMap gempakColorToRGB = new HashMap() { + /** + * + */ + private static final long serialVersionUID = 1L; + { + put(1, NsharpConstants.color_vanilla); + put(2, NsharpConstants.color_red); + put(3, NsharpConstants.color_green); + put(4, NsharpConstants.color_blue); + put(5, NsharpConstants.color_yellow); + put(6, NsharpConstants.color_cyan); + put(7, NsharpConstants.color_magenta); + put(8, NsharpConstants.color_brown); + put(9, NsharpConstants.color_coral); + put(10, NsharpConstants.color_apricot); + put(11, NsharpConstants.color_pink); + put(12, NsharpConstants.color_deeppink); + put(13, NsharpConstants.color_violet_md); + put(14, NsharpConstants.color_maroon); + put(15, NsharpConstants.color_firebrick); + put(16, NsharpConstants.color_orangered); + put(17, NsharpConstants.color_orange); + put(18, NsharpConstants.color_darkorange); + put(19, NsharpConstants.color_gold); + put(20, NsharpConstants.color_yellow_DK); + put(21, NsharpConstants.color_lawngreen); + put(22, NsharpConstants.color_mdgreen); + put(23, NsharpConstants.color_darkgreen); + put(24, NsharpConstants.color_blue); + put(25, NsharpConstants.color_lightblue); + put(26, NsharpConstants.color_skyblue); + put(27, NsharpConstants.color_cyan_md); + put(28, NsharpConstants.color_violet); + put(29, NsharpConstants.color_purple); + put(30, NsharpConstants.color_plum); + put(31, NsharpConstants.color_white); + put(32, NsharpConstants.color_black); + } + }; + // horizontal height line that will be drawn. - public static final int[] HEIGHT_LEVEL_METERS = {/*16000,*/ 15000, 12000, 9000, 6000, 3000, 2000 }; - public static final int[] HEIGHT_LEVEL_FEET = {50000, 45000, 40000, 35000, 30000, 25000, 20000, 15000, 10000, 5000, 2500 }; + public static final int[] HEIGHT_LEVEL_METERS = {/* 16000, */15000, 12000, + 9000, 6000, 3000, 2000 }; + + public static final int[] HEIGHT_LEVEL_FEET = { 50000, 45000, 40000, 35000, + 30000, 25000, 20000, 15000, 10000, 5000, 2500 }; /*** - * Chin: this implementation will be obsoleted when D2D changes its D2D Nsharp implementation to use - * multiple panes design. - * SINGLE PANE IMPLEMENTATIONS start - * Obsoleting implementation + * Chin: this implementation will be obsoleted when D2D changes its D2D + * Nsharp implementation to use multiple panes design. SINGLE PANE + * IMPLEMENTATIONS start Obsoleting implementation * ****/ public static final int OMEGA_X_TOP = -40; - public static final int OMEGA_Y_TOP = 200;//225; - public static final int SKEWT_REC_X_ORIG = OMEGA_X_TOP + 160; - public static final int SKEWT_REC_Y_ORIG = OMEGA_Y_TOP-75; + + public static final int OMEGA_Y_TOP = 200;// 225; + + public static final int SKEWT_REC_X_ORIG = OMEGA_X_TOP + 160; + + public static final int SKEWT_REC_Y_ORIG = OMEGA_Y_TOP - 75; + public static final int SKEWT_REC_WIDTH = 1000; + public static final int SKEWT_REC_HEIGHT = 1002; - public static final int SKEWT_VIEW_X_END = SKEWT_REC_X_ORIG + SKEWT_REC_WIDTH; - public static final int SKEWT_VIEW_Y_END = SKEWT_REC_Y_ORIG + SKEWT_REC_HEIGHT; - public static final int OMEGA_Y_BOT = SKEWT_VIEW_Y_END-15; - public static final int ICING_REC_X_ORIG =SKEWT_REC_X_ORIG; + + public static final int SKEWT_VIEW_X_END = SKEWT_REC_X_ORIG + + SKEWT_REC_WIDTH; + + public static final int SKEWT_VIEW_Y_END = SKEWT_REC_Y_ORIG + + SKEWT_REC_HEIGHT; + + public static final int OMEGA_Y_BOT = SKEWT_VIEW_Y_END - 15; + + public static final int ICING_REC_X_ORIG = SKEWT_REC_X_ORIG; + public static final int ICING_REC_Y_ORIG = SKEWT_REC_Y_ORIG; + public static final int ICING_REC_WIDTH = SKEWT_REC_WIDTH; - public static final int ICING_REC_HEIGHT = SKEWT_REC_HEIGHT-50; - public static final int ICING_VIEW_X_END = ICING_REC_X_ORIG + ICING_REC_WIDTH; - public static final int ICING_VIEW_Y_END = ICING_REC_Y_ORIG + ICING_REC_HEIGHT; - public static final int TURB_REC_X_ORIG =SKEWT_REC_X_ORIG; - public static final int TURB_REC_Y_ORIG = SKEWT_REC_Y_ORIG ; + + public static final int ICING_REC_HEIGHT = SKEWT_REC_HEIGHT - 50; + + public static final int ICING_VIEW_X_END = ICING_REC_X_ORIG + + ICING_REC_WIDTH; + + public static final int ICING_VIEW_Y_END = ICING_REC_Y_ORIG + + ICING_REC_HEIGHT; + + public static final int TURB_REC_X_ORIG = SKEWT_REC_X_ORIG; + + public static final int TURB_REC_Y_ORIG = SKEWT_REC_Y_ORIG; + public static final int TURB_REC_WIDTH = SKEWT_REC_WIDTH; - public static final int TURB_REC_HEIGHT = SKEWT_REC_HEIGHT -50; + + public static final int TURB_REC_HEIGHT = SKEWT_REC_HEIGHT - 50; + public static final int TURB_VIEW_X_END = TURB_REC_X_ORIG + TURB_REC_WIDTH; + public static final int TURB_VIEW_Y_END = TURB_REC_Y_ORIG + TURB_REC_HEIGHT; + public static final int DATAPANEL_REC_WIDTH = 750; + public static final int DATAPANEL_REC_HEIGHT = 630; - public static final int INSET_REC_WIDTH = DATAPANEL_REC_WIDTH/2;//250;//300; - public static final int INSET_REC_HEIGHT = DATAPANEL_REC_HEIGHT/2;//SKEWT_REC_HEIGHT/3;; + + public static final int INSET_REC_WIDTH = DATAPANEL_REC_WIDTH / 2;// 250;//300; + + public static final int INSET_REC_HEIGHT = DATAPANEL_REC_HEIGHT / 2;// SKEWT_REC_HEIGHT/3;; + public static final int WIND_BOX_WIDTH = 175; + public static final int WIND_BOX_HEIGHT = SKEWT_REC_HEIGHT; - public static final int WIND_BOX_X_ORIG = SKEWT_REC_X_ORIG+SKEWT_REC_WIDTH; + + public static final int WIND_BOX_X_ORIG = SKEWT_REC_X_ORIG + + SKEWT_REC_WIDTH; + public static final int WIND_BOX_Y_ORIG = SKEWT_REC_Y_ORIG; - + public static final int VERTICAL_WIND_WIDTH = 175; + public static final int VERTICAL_WIND_HEIGHT = SKEWT_REC_HEIGHT; - public static final int VERTICAL_WIND_X_ORIG = WIND_BOX_X_ORIG+ WIND_BOX_WIDTH; + + public static final int VERTICAL_WIND_X_ORIG = WIND_BOX_X_ORIG + + WIND_BOX_WIDTH; + public static final int VERTICAL_WIND_Y_ORIG = SKEWT_REC_Y_ORIG; - - public static final int HODO_REC_X_ORIG = VERTICAL_WIND_X_ORIG + VERTICAL_WIND_WIDTH; + + public static final int HODO_REC_X_ORIG = VERTICAL_WIND_X_ORIG + + VERTICAL_WIND_WIDTH; + public static final int HODO_REC_Y_ORIG = SKEWT_REC_Y_ORIG; - public static final int HODO_REC_WIDTH = SKEWT_REC_WIDTH;//750;//1000; - public static final int HODO_REC_HEIGHT = SKEWT_REC_HEIGHT;///3 * 2; + + public static final int HODO_REC_WIDTH = SKEWT_REC_WIDTH;// 750;//1000; + + public static final int HODO_REC_HEIGHT = SKEWT_REC_HEIGHT;// /3 * 2; + public static final int HODO_VIEW_X_END = HODO_REC_X_ORIG + HODO_REC_WIDTH; - //public static final int HODO_VIEW_Y_END = HODO_REC_Y_ORIG + HODO_REC_HEIGHT; - public static final float HODO_CENTER_X = HODO_REC_X_ORIG + (float)(5.00/12.00) * HODO_REC_WIDTH; - public static final float HODO_CENTER_Y = HODO_REC_Y_ORIG + (float)(1.00/2.00) * HODO_REC_HEIGHT; + + // public static final int HODO_VIEW_Y_END = HODO_REC_Y_ORIG + + // HODO_REC_HEIGHT; + public static final float HODO_CENTER_X = HODO_REC_X_ORIG + + (float) (5.00 / 12.00) * HODO_REC_WIDTH; + + public static final float HODO_CENTER_Y = HODO_REC_Y_ORIG + + (float) (1.00 / 2.00) * HODO_REC_HEIGHT; + public static final int WIND_MOTION_REC_X_ORIG = HODO_REC_X_ORIG; + public static final int WIND_MOTION_REC_Y_ORIG = HODO_REC_Y_ORIG; + public static final int WIND_MOTION_REC_WIDTH = 175; + public static final int WIND_MOTION_REC_HEIGHT = 150; - public static final int WIND_MOTION_VIEW_X_END = WIND_MOTION_REC_X_ORIG+WIND_MOTION_REC_WIDTH; - public static final int WIND_MOTION_VIEW_Y_END = WIND_MOTION_REC_Y_ORIG+WIND_MOTION_REC_HEIGHT; + + public static final int WIND_MOTION_VIEW_X_END = WIND_MOTION_REC_X_ORIG + + WIND_MOTION_REC_WIDTH; + + public static final int WIND_MOTION_VIEW_Y_END = WIND_MOTION_REC_Y_ORIG + + WIND_MOTION_REC_HEIGHT; public static final int DATA_TIMELINE_REC_X_ORIG = HODO_VIEW_X_END; + public static final int DATA_TIMELINE_REC_Y_ORIG = HODO_REC_Y_ORIG; - public static final int DATA_TIMELINE_REC_WIDTH =350;//280; - public static final int DATA_TIMELINE_REC_HEIGHT = SKEWT_REC_HEIGHT-100; - public static final int DATA_TIMELINE_VIEW_X_END = DATA_TIMELINE_REC_X_ORIG+DATA_TIMELINE_REC_WIDTH; - public static final int DATA_TIMELINE_VIEW_Y_END = DATA_TIMELINE_REC_Y_ORIG+DATA_TIMELINE_REC_HEIGHT; - public static final int DATA_TIMELINE_NEXT_PAGE_END = DATA_TIMELINE_REC_Y_ORIG+ 30; - public static final int DATA_TIMELINE_NOTATION_Y_START = DATA_TIMELINE_VIEW_Y_END;//- 100; - //public static final int DATA_TIMELINE_SORT_X_START = DATA_TIMELINE_REC_X_ORIG+(7*DATA_TIMELINE_REC_WIDTH/18); + + public static final int DATA_TIMELINE_REC_WIDTH = 350;// 280; + + public static final int DATA_TIMELINE_REC_HEIGHT = SKEWT_REC_HEIGHT - 100; + + public static final int DATA_TIMELINE_VIEW_X_END = DATA_TIMELINE_REC_X_ORIG + + DATA_TIMELINE_REC_WIDTH; + + public static final int DATA_TIMELINE_VIEW_Y_END = DATA_TIMELINE_REC_Y_ORIG + + DATA_TIMELINE_REC_HEIGHT; + + public static final int DATA_TIMELINE_NEXT_PAGE_END = DATA_TIMELINE_REC_Y_ORIG + 30; + + public static final int DATA_TIMELINE_NOTATION_Y_START = DATA_TIMELINE_VIEW_Y_END;// - + // 100; + + // public static final int DATA_TIMELINE_SORT_X_START = + // DATA_TIMELINE_REC_X_ORIG+(7*DATA_TIMELINE_REC_WIDTH/18); public static final int STATION_ID_REC_X_ORIG = DATA_TIMELINE_VIEW_X_END; + public static final int STATION_ID_REC_Y_ORIG = DATA_TIMELINE_REC_Y_ORIG; + public static final int STATION_ID_REC_WIDTH = 300; + public static final int STATION_ID_REC_HEIGHT = DATA_TIMELINE_REC_HEIGHT; - public static final int STATION_ID_VIEW_X_END = STATION_ID_REC_X_ORIG+STATION_ID_REC_WIDTH; - public static final int STATION_ID_VIEW_Y_END = STATION_ID_REC_Y_ORIG+STATION_ID_REC_HEIGHT; - //public static final int STATION_ID_NOTATION_Y_START = STATION_ID_VIEW_Y_END-90; + + public static final int STATION_ID_VIEW_X_END = STATION_ID_REC_X_ORIG + + STATION_ID_REC_WIDTH; + + public static final int STATION_ID_VIEW_Y_END = STATION_ID_REC_Y_ORIG + + STATION_ID_REC_HEIGHT; + + // public static final int STATION_ID_NOTATION_Y_START = + // STATION_ID_VIEW_Y_END-90; public static final int COLOR_NOTATION_REC_X_ORIG = DATA_TIMELINE_REC_X_ORIG; + public static final int COLOR_NOTATION_REC_Y_ORIG = DATA_TIMELINE_VIEW_Y_END; - public static final int COLOR_NOTATION_REC_WIDTH = DATA_TIMELINE_REC_WIDTH+STATION_ID_REC_WIDTH; - public static final int COLOR_NOTATION_REC_HEIGHT = SKEWT_REC_HEIGHT-DATA_TIMELINE_REC_HEIGHT; - public static final int COLOR_NOTATION_VIEW_X_END = COLOR_NOTATION_REC_X_ORIG+COLOR_NOTATION_REC_WIDTH; - public static final int COLOR_NOTATION_VIEW_Y_END = COLOR_NOTATION_REC_Y_ORIG+COLOR_NOTATION_REC_HEIGHT; - - - - public static final int DATAPANEL1_REC_X_ORIG = OMEGA_X_TOP+150; + + public static final int COLOR_NOTATION_REC_WIDTH = DATA_TIMELINE_REC_WIDTH + + STATION_ID_REC_WIDTH; + + public static final int COLOR_NOTATION_REC_HEIGHT = SKEWT_REC_HEIGHT + - DATA_TIMELINE_REC_HEIGHT; + + public static final int COLOR_NOTATION_VIEW_X_END = COLOR_NOTATION_REC_X_ORIG + + COLOR_NOTATION_REC_WIDTH; + + public static final int COLOR_NOTATION_VIEW_Y_END = COLOR_NOTATION_REC_Y_ORIG + + COLOR_NOTATION_REC_HEIGHT; + + public static final int DATAPANEL1_REC_X_ORIG = OMEGA_X_TOP + 150; + public static final int DATAPANEL1_REC_Y_ORIG = SKEWT_VIEW_Y_END + 50; + public static final int DATAPANEL1_REC_WIDTH = DATAPANEL_REC_WIDTH; + public static final int DATAPANEL1_REC_HEIGHT = DATAPANEL_REC_HEIGHT; - public static final int DATAPANEL1_VIEW_X_END = DATAPANEL1_REC_X_ORIG+DATAPANEL1_REC_WIDTH; - public static final int DATAPANEL1_VIEW_Y_END = DATAPANEL1_REC_Y_ORIG+DATAPANEL1_REC_HEIGHT; + + public static final int DATAPANEL1_VIEW_X_END = DATAPANEL1_REC_X_ORIG + + DATAPANEL1_REC_WIDTH; + + public static final int DATAPANEL1_VIEW_Y_END = DATAPANEL1_REC_Y_ORIG + + DATAPANEL1_REC_HEIGHT; public static final int DATAPANEL2_REC_X_ORIG = DATAPANEL1_VIEW_X_END; + public static final int DATAPANEL2_REC_Y_ORIG = DATAPANEL1_REC_Y_ORIG; + public static final int DATAPANEL2_REC_WIDTH = DATAPANEL_REC_WIDTH; + public static final int DATAPANEL2_REC_HEIGHT = DATAPANEL_REC_HEIGHT; - public static final int DATAPANEL2_VIEW_X_END = DATAPANEL2_REC_X_ORIG+DATAPANEL2_REC_WIDTH; - public static final int DATAPANEL2_VIEW_Y_END = DATAPANEL2_REC_Y_ORIG+DATAPANEL2_REC_HEIGHT; + + public static final int DATAPANEL2_VIEW_X_END = DATAPANEL2_REC_X_ORIG + + DATAPANEL2_REC_WIDTH; + + public static final int DATAPANEL2_VIEW_Y_END = DATAPANEL2_REC_Y_ORIG + + DATAPANEL2_REC_HEIGHT; public static final int DATAPANEL3_REC_X_ORIG = DATAPANEL2_VIEW_X_END; + public static final int DATAPANEL3_REC_Y_ORIG = DATAPANEL1_REC_Y_ORIG; + public static final int DATAPANEL3_REC_WIDTH = DATAPANEL_REC_WIDTH; + public static final int DATAPANEL3_REC_HEIGHT = DATAPANEL_REC_HEIGHT; - public static final int DATAPANEL3_VIEW_X_END = DATAPANEL3_REC_X_ORIG+DATAPANEL3_REC_WIDTH; - public static final int DATAPANEL3_VIEW_Y_END = DATAPANEL3_REC_Y_ORIG+DATAPANEL3_REC_HEIGHT; + + public static final int DATAPANEL3_VIEW_X_END = DATAPANEL3_REC_X_ORIG + + DATAPANEL3_REC_WIDTH; + + public static final int DATAPANEL3_VIEW_Y_END = DATAPANEL3_REC_Y_ORIG + + DATAPANEL3_REC_HEIGHT; public static final int DATAPANEL4_REC_X_ORIG = DATAPANEL3_VIEW_X_END; + public static final int DATAPANEL4_REC_Y_ORIG = DATAPANEL1_REC_Y_ORIG; + public static final int DATAPANEL4_REC_WIDTH = DATAPANEL_REC_WIDTH; + public static final int DATAPANEL4_REC_HEIGHT = DATAPANEL_REC_HEIGHT; - public static final int DATAPANEL4_VIEW_X_END = DATAPANEL4_REC_X_ORIG+DATAPANEL4_REC_WIDTH; - public static final int DATAPANEL4_VIEW_Y_END = DATAPANEL4_REC_Y_ORIG+DATAPANEL4_REC_HEIGHT; - + + public static final int DATAPANEL4_VIEW_X_END = DATAPANEL4_REC_X_ORIG + + DATAPANEL4_REC_WIDTH; + + public static final int DATAPANEL4_VIEW_Y_END = DATAPANEL4_REC_Y_ORIG + + DATAPANEL4_REC_HEIGHT; + public static final int SRWINDS_REC_X_ORIG = DATAPANEL2_VIEW_X_END; + public static final int SRWINDS_REC_Y_ORIG = DATAPANEL1_REC_Y_ORIG; + public static final int SRWINDS_REC_WIDTH = INSET_REC_WIDTH; + public static final int SRWINDS_REC_HEIGHT = INSET_REC_HEIGHT; - public static final int SRWINDS_VIEW_X_END = SRWINDS_REC_X_ORIG+SRWINDS_REC_WIDTH; - public static final int SRWINDS_VIEW_Y_END = SRWINDS_REC_Y_ORIG+SRWINDS_REC_HEIGHT; - + + public static final int SRWINDS_VIEW_X_END = SRWINDS_REC_X_ORIG + + SRWINDS_REC_WIDTH; + + public static final int SRWINDS_VIEW_Y_END = SRWINDS_REC_Y_ORIG + + SRWINDS_REC_HEIGHT; + public static final int STORMSLINKY_REC_X_ORIG = SRWINDS_VIEW_X_END; + public static final int STORMSLINKY_REC_Y_ORIG = DATAPANEL1_REC_Y_ORIG; + public static final int STORMSLINKY_REC_WIDTH = INSET_REC_WIDTH; + public static final int STORMSLINKY_REC_HEIGHT = INSET_REC_HEIGHT; - public static final int STORMSLINKY_VIEW_X_END = STORMSLINKY_REC_X_ORIG+STORMSLINKY_REC_WIDTH; - public static final int STORMSLINKY_VIEW_Y_END = STORMSLINKY_REC_Y_ORIG+STORMSLINKY_REC_HEIGHT; - + + public static final int STORMSLINKY_VIEW_X_END = STORMSLINKY_REC_X_ORIG + + STORMSLINKY_REC_WIDTH; + + public static final int STORMSLINKY_VIEW_Y_END = STORMSLINKY_REC_Y_ORIG + + STORMSLINKY_REC_HEIGHT; + public static final int THETAP_REC_X_ORIG = SRWINDS_REC_X_ORIG; - public static final int THETAP_REC_Y_ORIG = SRWINDS_VIEW_Y_END; + + public static final int THETAP_REC_Y_ORIG = SRWINDS_VIEW_Y_END; + public static final int THETAP_REC_WIDTH = INSET_REC_WIDTH; + public static final int THETAP_REC_HEIGHT = INSET_REC_HEIGHT; - public static final int THETAP_VIEW_X_END = THETAP_REC_X_ORIG+THETAP_REC_WIDTH; - public static final int THETAP_VIEW_Y_END = THETAP_REC_Y_ORIG+THETAP_REC_HEIGHT; - - //same position as THETAP_REC + + public static final int THETAP_VIEW_X_END = THETAP_REC_X_ORIG + + THETAP_REC_WIDTH; + + public static final int THETAP_VIEW_Y_END = THETAP_REC_Y_ORIG + + THETAP_REC_HEIGHT; + + // same position as THETAP_REC public static final int THETAH_REC_X_ORIG = SRWINDS_REC_X_ORIG; + public static final int THETAH_REC_Y_ORIG = SRWINDS_VIEW_Y_END; + public static final int THETAH_REC_WIDTH = INSET_REC_WIDTH; + public static final int THETAH_REC_HEIGHT = INSET_REC_HEIGHT; - public static final int THETAH_VIEW_X_END = THETAH_REC_X_ORIG+THETAH_REC_WIDTH; - public static final int THETAH_VIEW_Y_END = THETAH_REC_Y_ORIG+THETAH_REC_HEIGHT; - + + public static final int THETAH_VIEW_X_END = THETAH_REC_X_ORIG + + THETAH_REC_WIDTH; + + public static final int THETAH_VIEW_Y_END = THETAH_REC_Y_ORIG + + THETAH_REC_HEIGHT; + public static final int PSBLWATCH_REC_X_ORIG = THETAP_VIEW_X_END; + public static final int PSBLWATCH_REC_Y_ORIG = THETAP_REC_Y_ORIG; + public static final int PSBLWATCH_REC_WIDTH = INSET_REC_WIDTH; + public static final int PSBLWATCH_REC_HEIGHT = INSET_REC_HEIGHT; - public static final int PSBLWATCH_VIEW_X_END = PSBLWATCH_REC_X_ORIG+PSBLWATCH_REC_WIDTH; - public static final int PSBLWATCH_VIEW_Y_END = PSBLWATCH_REC_Y_ORIG+PSBLWATCH_REC_HEIGHT; - - //same position as PSBLWATCH_REC + + public static final int PSBLWATCH_VIEW_X_END = PSBLWATCH_REC_X_ORIG + + PSBLWATCH_REC_WIDTH; + + public static final int PSBLWATCH_VIEW_Y_END = PSBLWATCH_REC_Y_ORIG + + PSBLWATCH_REC_HEIGHT; + + // same position as PSBLWATCH_REC public static final int SRWINDVTRS_REC_X_ORIG = THETAP_VIEW_X_END; + public static final int SRWINDVTRS_REC_Y_ORIG = THETAP_REC_Y_ORIG; + public static final int SRWINDVTRS_REC_WIDTH = INSET_REC_WIDTH; + public static final int SRWINDVTRS_REC_HEIGHT = INSET_REC_HEIGHT; - public static final int SRWINDVTRS_VIEW_X_END = SRWINDVTRS_REC_X_ORIG+SRWINDVTRS_REC_WIDTH; - public static final int SRWINDVTRS_VIEW_Y_END = SRWINDVTRS_REC_Y_ORIG+SRWINDVTRS_REC_HEIGHT; + + public static final int SRWINDVTRS_VIEW_X_END = SRWINDVTRS_REC_X_ORIG + + SRWINDVTRS_REC_WIDTH; + + public static final int SRWINDVTRS_VIEW_Y_END = SRWINDVTRS_REC_Y_ORIG + + SRWINDVTRS_REC_HEIGHT; public static final int CHAR_HEIGHT = 25; + /**** * SINGLE PANE IMPLEMENTATIONS end * ******/ - - + /*** * * MULTIPLE PANES IMPLEMENTATIONS start * * ****/ - /*public static final int DISPLAY_SKEWT=0; - public static final int DISPLAY_WITO= DISPLAY_SKEWT+1; //Wind box + InferredTemp + Omega - public static final int DISPLAY_INSET= DISPLAY_WITO+1; - public static final int DISPLAY_HODO= DISPLAY_INSET+1; - public static final int DISPLAY_TIMESTN= DISPLAY_HODO+1; - public static final int DISPLAY_DATA=DISPLAY_TIMESTN+1; - public static final int DISPLAY_SPC_GRAPHS= DISPLAY_DATA+1; - public static final int DISPLAY_TOTAL= DISPLAY_SPC_GRAPHS+1;*/ - public static final int CHAR_HEIGHT_ = 15; - - //note: dimensions are used as reference for its components inside its pane and only relative within its own pane. - //Sizes defined here have no significant meaning between two different panes. - public static final int DISPLAY_WIDTH= 1600; - public static final int DISPLAY_HEIGHT= 820; - public static final int SKEWT_PANE_REC_WIDTH = DISPLAY_WIDTH/2 * 11 /16; //800 *11/16=550 - public static final int SKEWT_PANE_REC_HEIGHT = DISPLAY_HEIGHT * 8 /10; // 820*0.8 =656; - public static final int WITO_PANE_REC_WIDTH = DISPLAY_WIDTH/2 - SKEWT_PANE_REC_WIDTH; //800-550=250 - public static final int WITO_PANE_REC_HEIGHT = DISPLAY_HEIGHT * 8 /10; // 820*0.8 =656; - public static final int HODO_PANE_REC_WIDTH = (DISPLAY_WIDTH/2) * 13/20;//800x0.65=520;; - public static final int HODO_PANE_REC_HEIGHT = DISPLAY_HEIGHT * 7 /10; // 820*0.7 =574; - public static final int TIMESTN_PANE_REC_WIDTH = DISPLAY_WIDTH/2 - HODO_PANE_REC_WIDTH;//800-520=280 - public static final int TIMESTN_PANE_REC_HEIGHT = HODO_PANE_REC_HEIGHT; //574 - public static final int INSET_PANE_REC_WIDTH = DISPLAY_WIDTH/2; - public static final int INSET_PANE_REC_HEIGHT = DISPLAY_HEIGHT * 2 /10; // 820*0.2 =164; - public static final int DATA_PANE_REC_WIDTH = DISPLAY_WIDTH/2; //800 - public static final int DATA_PANE_REC_HEIGHT = DISPLAY_HEIGHT * 3 /10; // 820*0.3 =246; - public static Rectangle SKEWT_DISPLAY_REC = new Rectangle(0, 0, SKEWT_PANE_REC_WIDTH, SKEWT_PANE_REC_HEIGHT); - public static Rectangle WITO_DISPLAY_REC = new Rectangle(0, 0, WITO_PANE_REC_WIDTH, WITO_PANE_REC_HEIGHT); - public static Rectangle HODO_DISPLAY_REC = new Rectangle(0, 0, HODO_PANE_REC_WIDTH, HODO_PANE_REC_HEIGHT); - public static Rectangle TIMESTN_DISPLAY_REC = new Rectangle(0, 0, TIMESTN_PANE_REC_WIDTH, TIMESTN_PANE_REC_HEIGHT); - public static Rectangle FUTURE_DISPLAY_REC = new Rectangle(0, 0, TIMESTN_PANE_REC_WIDTH, TIMESTN_PANE_REC_HEIGHT); - public static Rectangle DATA_DISPLAY_REC = new Rectangle(0, 0, DATA_PANE_REC_WIDTH, DATA_PANE_REC_HEIGHT); - public static Rectangle INSET_DISPLAY_REC = new Rectangle(0, 0, INSET_PANE_REC_WIDTH, INSET_PANE_REC_HEIGHT); - public static Rectangle SPC_GRAPH_DISPLAY_REC = new Rectangle(0, 0, DATA_PANE_REC_WIDTH, DATA_PANE_REC_HEIGHT); - public static final int SKEWT_WIDTH = SKEWT_PANE_REC_WIDTH;//=550 - public static final int SKEWT_HEIGHT = SKEWT_PANE_REC_HEIGHT;//570 + /* + * public static final int DISPLAY_SKEWT=0; public static final int + * DISPLAY_WITO= DISPLAY_SKEWT+1; //Wind box + InferredTemp + Omega public + * static final int DISPLAY_INSET= DISPLAY_WITO+1; public static final int + * DISPLAY_HODO= DISPLAY_INSET+1; public static final int DISPLAY_TIMESTN= + * DISPLAY_HODO+1; public static final int DISPLAY_DATA=DISPLAY_TIMESTN+1; + * public static final int DISPLAY_SPC_GRAPHS= DISPLAY_DATA+1; public static + * final int DISPLAY_TOTAL= DISPLAY_SPC_GRAPHS+1; + */ + public static final int CHAR_HEIGHT_ = 15; + + // note: dimensions are used as reference for its components inside its pane + // and only relative within its own pane. + // Sizes defined here have no significant meaning between two different + // panes. + public static final int DISPLAY_WIDTH = 1600; + + public static final int DISPLAY_HEIGHT = 820; + + public static final int SKEWT_PANE_REC_WIDTH = DISPLAY_WIDTH / 2 * 11 / 16; // 800 + // *11/16=550 + + public static final int SKEWT_PANE_REC_HEIGHT = DISPLAY_HEIGHT * 8 / 10; // 820*0.8 + // =656; + + public static final int WITO_PANE_REC_WIDTH = DISPLAY_WIDTH / 2 + - SKEWT_PANE_REC_WIDTH; // 800-550=250 + + public static final int WITO_PANE_REC_HEIGHT = DISPLAY_HEIGHT * 8 / 10; // 820*0.8 + // =656; + + public static final int HODO_PANE_REC_WIDTH = (DISPLAY_WIDTH / 2) * 13 / 20;// 800x0.65=520;; + + public static final int HODO_PANE_REC_HEIGHT = DISPLAY_HEIGHT * 7 / 10; // 820*0.7 + // =574; + + public static final int TIMESTN_PANE_REC_WIDTH = DISPLAY_WIDTH / 2 + - HODO_PANE_REC_WIDTH;// 800-520=280 + + public static final int TIMESTN_PANE_REC_HEIGHT = HODO_PANE_REC_HEIGHT; // 574 + + public static final int INSET_PANE_REC_WIDTH = DISPLAY_WIDTH / 2; + + public static final int INSET_PANE_REC_HEIGHT = DISPLAY_HEIGHT * 2 / 10; // 820*0.2 + // =164; + + public static final int DATA_PANE_REC_WIDTH = DISPLAY_WIDTH / 2; // 800 + + public static final int DATA_PANE_REC_HEIGHT = DISPLAY_HEIGHT * 3 / 10; // 820*0.3 + // =246; + + public static Rectangle SKEWT_DISPLAY_REC = new Rectangle(0, 0, + SKEWT_PANE_REC_WIDTH, SKEWT_PANE_REC_HEIGHT); + + public static Rectangle WITO_DISPLAY_REC = new Rectangle(0, 0, + WITO_PANE_REC_WIDTH, WITO_PANE_REC_HEIGHT); + + public static Rectangle HODO_DISPLAY_REC = new Rectangle(0, 0, + HODO_PANE_REC_WIDTH, HODO_PANE_REC_HEIGHT); + + public static Rectangle TIMESTN_DISPLAY_REC = new Rectangle(0, 0, + TIMESTN_PANE_REC_WIDTH, TIMESTN_PANE_REC_HEIGHT); + + public static Rectangle FUTURE_DISPLAY_REC = new Rectangle(0, 0, + TIMESTN_PANE_REC_WIDTH, TIMESTN_PANE_REC_HEIGHT); + + public static Rectangle DATA_DISPLAY_REC = new Rectangle(0, 0, + DATA_PANE_REC_WIDTH, DATA_PANE_REC_HEIGHT); + + public static Rectangle INSET_DISPLAY_REC = new Rectangle(0, 0, + INSET_PANE_REC_WIDTH, INSET_PANE_REC_HEIGHT); + + public static Rectangle SPC_GRAPH_DISPLAY_REC = new Rectangle(0, 0, + DATA_PANE_REC_WIDTH, DATA_PANE_REC_HEIGHT); + + public static final int SKEWT_WIDTH = SKEWT_PANE_REC_WIDTH;// =550 + + public static final int SKEWT_HEIGHT = SKEWT_PANE_REC_HEIGHT;// 570 + public static final int SKEWT_X_ORIG = 0; - public static final int SKEWT_Y_ORIG = 0;//70; + + public static final int SKEWT_Y_ORIG = 0;// 70; + public static final int SKEWT_X_END = SKEWT_X_ORIG + SKEWT_WIDTH; + public static final int SKEWT_Y_END = SKEWT_Y_ORIG + SKEWT_HEIGHT; - public static final int ICING_X_ORIG =SKEWT_X_ORIG; + + public static final int ICING_X_ORIG = SKEWT_X_ORIG; + public static final int ICING_Y_ORIG = SKEWT_Y_ORIG; + public static final int ICING_WIDTH = SKEWT_WIDTH; - public static final int ICING_HEIGHT = SKEWT_HEIGHT-25; + + public static final int ICING_HEIGHT = SKEWT_HEIGHT - 25; + public static final int ICING_X_END = ICING_X_ORIG + ICING_WIDTH; + public static final int ICING_Y_END = ICING_Y_ORIG + ICING_HEIGHT; - public static final int TURB_X_ORIG =SKEWT_X_ORIG; - public static final int TURB_Y_ORIG = SKEWT_Y_ORIG ; + + public static final int TURB_X_ORIG = SKEWT_X_ORIG; + + public static final int TURB_Y_ORIG = SKEWT_Y_ORIG; + public static final int TURB_WIDTH = SKEWT_WIDTH; - public static final int TURB_HEIGHT = SKEWT_HEIGHT -25; + + public static final int TURB_HEIGHT = SKEWT_HEIGHT - 25; + public static final int TURB_X_END = TURB_X_ORIG + TURB_WIDTH; + public static final int TURB_Y_END = TURB_Y_ORIG + TURB_HEIGHT; - public static final int WIND_BX_WIDTH = WITO_PANE_REC_WIDTH/3;; + + public static final int WIND_BX_WIDTH = WITO_PANE_REC_WIDTH / 3;; + public static final int WIND_BX_HEIGHT = SKEWT_HEIGHT; + public static final int WIND_BX_X_ORIG = 0; + public static final int WIND_BX_Y_ORIG = SKEWT_Y_ORIG; - public static final int VRTCAL_WIND_WIDTH = WITO_PANE_REC_WIDTH/3;; + + public static final int VRTCAL_WIND_WIDTH = WITO_PANE_REC_WIDTH / 3;; + public static final int VRTCAL_WIND_HEIGHT = SKEWT_HEIGHT; - public static final int VRTCAL_WIND_X_ORIG = WIND_BX_X_ORIG+ WIND_BX_WIDTH; + + public static final int VRTCAL_WIND_X_ORIG = WIND_BX_X_ORIG + WIND_BX_WIDTH; + public static final int VRTCAL_WIND_Y_ORIG = SKEWT_Y_ORIG; - public static final int VRTCAL_WIND_X_END = VRTCAL_WIND_X_ORIG + VRTCAL_WIND_WIDTH; - public static final int VRTCAL_WIND_Y_END = VRTCAL_WIND_Y_ORIG + VRTCAL_WIND_HEIGHT; + + public static final int VRTCAL_WIND_X_END = VRTCAL_WIND_X_ORIG + + VRTCAL_WIND_WIDTH; + + public static final int VRTCAL_WIND_Y_END = VRTCAL_WIND_Y_ORIG + + VRTCAL_WIND_HEIGHT; + public static final int OMEGA_X_ORIG = VRTCAL_WIND_X_END; + public static final int OMEGA_Y_ORIG = SKEWT_Y_ORIG; - public static final int OMEGA_WIDTH = WITO_PANE_REC_WIDTH/3; + + public static final int OMEGA_WIDTH = WITO_PANE_REC_WIDTH / 3; + public static final int OMEGA_HEIGHT = SKEWT_HEIGHT; + public static final int OMEGA_Y_END = SKEWT_Y_END; + public static final int OMEGA_MAGNIFICATION_FACTOR = 20; + public static final int HODO_X_ORIG = 0; - public static final int HODO_Y_ORIG = 0;//40; + + public static final int HODO_Y_ORIG = 0;// 40; + public static final int HODO_WIDTH = HODO_PANE_REC_WIDTH; + public static final int HODO_HEIGHT = HODO_PANE_REC_HEIGHT - HODO_Y_ORIG; + public static final int HODO_X_END = HODO_X_ORIG + HODO_WIDTH; - public static final float HODO_CENTER_X_ = HODO_X_ORIG + (float)(5.00/12.00) * HODO_WIDTH; - public static final float HODO_CENTER_Y_ = HODO_Y_ORIG + (float)(1.00/2.00) * HODO_HEIGHT; + + public static final float HODO_CENTER_X_ = HODO_X_ORIG + + (float) (5.00 / 12.00) * HODO_WIDTH; + + public static final float HODO_CENTER_Y_ = HODO_Y_ORIG + + (float) (1.00 / 2.00) * HODO_HEIGHT; + public static final int HODO_COORDINATE_X1 = -50; + public static final int HODO_COORDINATE_X1_STD = -90; - public static final int HODO_COORDINATE_Y1 = 75; + + public static final int HODO_COORDINATE_Y1 = 75; + public static final int HODO_COORDINATE_X2 = 70; + public static final int HODO_COORDINATE_Y2 = -95; - + public static final int DATA_TIMELINE_X_ORIG = 0; + public static final int DATA_TIMELINE_Y_ORIG = 40; - public static final int DATA_TIMELINE_WIDTH = TIMESTN_PANE_REC_WIDTH * 40 /100; + + public static final int DATA_TIMELINE_WIDTH = TIMESTN_PANE_REC_WIDTH * 35 / 100;// FixMark:nearByStnCompSnd + // d2dlite + public static final int COLOR_NOTATION_HEIGHT = 165; - public static final int DATA_TIMELINE_HEIGHT = TIMESTN_PANE_REC_HEIGHT-DATA_TIMELINE_Y_ORIG-COLOR_NOTATION_HEIGHT; - public static final int DATA_TIMELINE_X_END = DATA_TIMELINE_X_ORIG+DATA_TIMELINE_WIDTH; - public static final int DATA_TIMELINE_Y_END = DATA_TIMELINE_Y_ORIG+DATA_TIMELINE_HEIGHT; - public static final int DATA_TIMELINE_NEXT_PAGE_END_ = DATA_TIMELINE_Y_ORIG+ CHAR_HEIGHT_; + + public static final int DATA_TIMELINE_HEIGHT = TIMESTN_PANE_REC_HEIGHT + - DATA_TIMELINE_Y_ORIG - COLOR_NOTATION_HEIGHT; + + public static final int DATA_TIMELINE_X_END = DATA_TIMELINE_X_ORIG + + DATA_TIMELINE_WIDTH; + + public static final int DATA_TIMELINE_Y_END = DATA_TIMELINE_Y_ORIG + + DATA_TIMELINE_HEIGHT; + + public static final int DATA_TIMELINE_NEXT_PAGE_END_ = DATA_TIMELINE_Y_ORIG + + CHAR_HEIGHT_; + public static final int STATION_ID_X_ORIG = DATA_TIMELINE_X_END; + public static final int STATION_ID_Y_ORIG = DATA_TIMELINE_Y_ORIG; - public static final int STATION_ID_WIDTH = (TIMESTN_PANE_REC_WIDTH - DATA_TIMELINE_WIDTH)/2; + + public static final int STATION_ID_WIDTH = TIMESTN_PANE_REC_WIDTH * 30 / 100; + public static final int STATION_ID_HEIGHT = DATA_TIMELINE_HEIGHT; - public static final int STATION_ID_X_END = STATION_ID_X_ORIG+STATION_ID_WIDTH; - public static final int STATION_ID_Y_END = STATION_ID_Y_ORIG+STATION_ID_HEIGHT; + + public static final int STATION_ID_X_END = STATION_ID_X_ORIG + + STATION_ID_WIDTH; + + public static final int STATION_ID_Y_END = STATION_ID_Y_ORIG + + STATION_ID_HEIGHT; + public static final int SND_TYPE_X_ORIG = STATION_ID_X_END; + public static final int SND_TYPE_Y_ORIG = DATA_TIMELINE_Y_ORIG; - public static final int SND_TYPE_WIDTH = STATION_ID_WIDTH; + + public static final int SND_TYPE_WIDTH = TIMESTN_PANE_REC_WIDTH * 35 / 100;; + public static final int SND_TYPE_HEIGHT = DATA_TIMELINE_HEIGHT; - public static final int SND_TYPE_X_END = SND_TYPE_X_ORIG+SND_TYPE_WIDTH; - public static final int SND_TYPE_Y_END = SND_TYPE_Y_ORIG+ SND_TYPE_HEIGHT; + + public static final int SND_TYPE_X_END = SND_TYPE_X_ORIG + SND_TYPE_WIDTH; + + public static final int SND_TYPE_Y_END = SND_TYPE_Y_ORIG + SND_TYPE_HEIGHT; + public static final int COLOR_NOTATION_X_ORIG = DATA_TIMELINE_X_ORIG; + public static final int COLOR_NOTATION_Y_ORIG = DATA_TIMELINE_Y_END; - public static final int COLOR_NOTATION_WIDTH = DATA_TIMELINE_WIDTH+STATION_ID_WIDTH; - public static final int COLOR_NOTATION_X_END = COLOR_NOTATION_X_ORIG+COLOR_NOTATION_WIDTH; - public static final int COLOR_NOTATION_Y_END = COLOR_NOTATION_Y_ORIG+COLOR_NOTATION_HEIGHT; + + public static final int COLOR_NOTATION_WIDTH = DATA_TIMELINE_WIDTH + + STATION_ID_WIDTH; + + public static final int COLOR_NOTATION_X_END = COLOR_NOTATION_X_ORIG + + COLOR_NOTATION_WIDTH; + + public static final int COLOR_NOTATION_Y_END = COLOR_NOTATION_Y_ORIG + + COLOR_NOTATION_HEIGHT; + public static final int DATAPANEL1_X_ORIG = 0; + public static final int DATAPANEL1_Y_ORIG = 0; - public static final int DATAPANEL1_WIDTH = DATA_PANE_REC_WIDTH/2; + + public static final int DATAPANEL1_WIDTH = DATA_PANE_REC_WIDTH / 2; + public static final int DATAPANEL1_HEIGHT = DATA_PANE_REC_HEIGHT; - public static final int DATAPANEL1_X_END = DATAPANEL1_X_ORIG+DATAPANEL1_WIDTH; - public static final int DATAPANEL1_Y_END = DATAPANEL1_Y_ORIG+DATAPANEL1_HEIGHT; + + public static final int DATAPANEL1_X_END = DATAPANEL1_X_ORIG + + DATAPANEL1_WIDTH; + + public static final int DATAPANEL1_Y_END = DATAPANEL1_Y_ORIG + + DATAPANEL1_HEIGHT; + public static final int DATAPANEL2_X_ORIG = DATAPANEL1_X_END; + public static final int DATAPANEL2_Y_ORIG = DATAPANEL1_Y_ORIG; + public static final int DATAPANEL2_WIDTH = DATAPANEL1_WIDTH; + public static final int DATAPANEL2_HEIGHT = DATAPANEL1_HEIGHT; - public static final int DATAPANEL2_X_END = DATAPANEL2_X_ORIG+DATAPANEL2_WIDTH; - public static final int DATAPANEL2_Y_END = DATAPANEL2_Y_ORIG+DATAPANEL2_HEIGHT; + + public static final int DATAPANEL2_X_END = DATAPANEL2_X_ORIG + + DATAPANEL2_WIDTH; + + public static final int DATAPANEL2_Y_END = DATAPANEL2_Y_ORIG + + DATAPANEL2_HEIGHT; + public static final int INSET_X_ORIG = 0; + public static final int INSET_Y_ORIG = 0; - public static final int INSET_WIDTH = INSET_PANE_REC_WIDTH/4; + + public static final int INSET_WIDTH = INSET_PANE_REC_WIDTH / 4; + public static final int INSET_HEIGHT = INSET_PANE_REC_HEIGHT; - + public static final int SRWINDS_X_ORIG = INSET_X_ORIG; + public static final int SRWINDS_Y_ORIG = INSET_Y_ORIG; - public static final int SRWINDS_X_END = SRWINDS_X_ORIG+INSET_WIDTH; - public static final int SRWINDS_Y_END = SRWINDS_Y_ORIG+INSET_HEIGHT; - + + public static final int SRWINDS_X_END = SRWINDS_X_ORIG + INSET_WIDTH; + + public static final int SRWINDS_Y_END = SRWINDS_Y_ORIG + INSET_HEIGHT; + public static final int STORMSLINKY_X_ORIG = SRWINDS_X_END; + public static final int STORMSLINKY_Y_ORIG = SRWINDS_Y_ORIG; - public static final int STORMSLINKY_X_END = STORMSLINKY_X_ORIG+INSET_WIDTH; - public static final int STORMSLINKY_Y_END = STORMSLINKY_Y_ORIG+INSET_HEIGHT; - + + public static final int STORMSLINKY_X_END = STORMSLINKY_X_ORIG + + INSET_WIDTH; + + public static final int STORMSLINKY_Y_END = STORMSLINKY_Y_ORIG + + INSET_HEIGHT; + public static final int THETAP_X_ORIG = STORMSLINKY_X_END; - public static final int THETAP_Y_ORIG = STORMSLINKY_Y_ORIG; - public static final int THETAP_X_END = THETAP_X_ORIG+INSET_WIDTH; - public static final int THETAP_Y_END = THETAP_Y_ORIG+INSET_HEIGHT; - - //same position as THETAP + + public static final int THETAP_Y_ORIG = STORMSLINKY_Y_ORIG; + + public static final int THETAP_X_END = THETAP_X_ORIG + INSET_WIDTH; + + public static final int THETAP_Y_END = THETAP_Y_ORIG + INSET_HEIGHT; + + // same position as THETAP public static final int THETAH_X_ORIG = STORMSLINKY_X_END; + public static final int THETAH_Y_ORIG = STORMSLINKY_Y_ORIG; - public static final int THETAH_X_END = THETAH_X_ORIG+INSET_WIDTH; - public static final int THETAH_Y_END = THETAH_Y_ORIG+INSET_HEIGHT; - + + public static final int THETAH_X_END = THETAH_X_ORIG + INSET_WIDTH; + + public static final int THETAH_Y_END = THETAH_Y_ORIG + INSET_HEIGHT; + public static final int PSBLWATCH_X_ORIG = THETAP_X_END; + public static final int PSBLWATCH_Y_ORIG = THETAP_Y_ORIG; - public static final int PSBLWATCH_X_END = PSBLWATCH_X_ORIG+INSET_WIDTH; - public static final int PSBLWATCH_Y_END = PSBLWATCH_Y_ORIG+INSET_HEIGHT; - - //same position as PSBLWATCH + + public static final int PSBLWATCH_X_END = PSBLWATCH_X_ORIG + INSET_WIDTH; + + public static final int PSBLWATCH_Y_END = PSBLWATCH_Y_ORIG + INSET_HEIGHT; + + // same position as PSBLWATCH public static final int SRWINDVTRS_X_ORIG = THETAP_X_END; + public static final int SRWINDVTRS_Y_ORIG = THETAP_Y_ORIG; - public static final int SRWINDVTRS_X_END = SRWINDVTRS_X_ORIG+INSET_WIDTH; - public static final int SRWINDVTRS_Y_END = SRWINDVTRS_Y_ORIG+INSET_HEIGHT; - - //public static final String PANE_LEGACY_CFG_STR = "Legacy Configuration (obsoleting)"; + + public static final int SRWINDVTRS_X_END = SRWINDVTRS_X_ORIG + INSET_WIDTH; + + public static final int SRWINDVTRS_Y_END = SRWINDVTRS_Y_ORIG + INSET_HEIGHT; + + // public static final String PANE_LEGACY_CFG_STR = + // "Legacy Configuration (obsoleting)"; public static final String PANE_DEF_CFG_1_STR = "Default Configuration 1"; + public static final String PANE_DEF_CFG_2_STR = "Default Configuration 2"; + public static final String PANE_SPCWS_CFG_STR = "SPC Wide Screen Configuration"; + public static final String PANE_SIMPLE_D2D_CFG_STR = "D2D Skewt Standard Screen Configuration"; - public static final String[] PANE_CONFIGURATION_NAME = {/*PANE_DEF_CFG_1_STR, PANE_DEF_CFG_2_STR,*/PANE_SPCWS_CFG_STR,PANE_SIMPLE_D2D_CFG_STR};//, PANE_LEGACY_CFG_STR}; - - //pane width and height ratio to full canvas size - // pane default configuration 1 - // full canvas consists of left group and right group - // left group has left top and bottom groups + + public static final String PANE_LITE_D2D_CFG_STR = "D2D Lite Screen Configuration"; // d2dlite + + public static final String[] PANE_CONFIGURATION_NAME = { + PANE_SPCWS_CFG_STR, PANE_SIMPLE_D2D_CFG_STR, PANE_LITE_D2D_CFG_STR }; // d2dlite + + // pane width and height ratio to full canvas size + // pane default configuration 1 + // full canvas consists of left group and right group + // left group has left top and bottom groups // left top group contains skewt and wito panes // left bottom group contains time/stn and insets panes // right group has hodo and data panes public static final double PANE_DEF_CFG_1_LEFT_GP_WIDTH_RATIO = 0.75; + public static final double PANE_DEF_CFG_1_LEFT_TOP_GP_HEIGHT_RATIO = 0.8; + public static final double PANE_DEF_CFG_1_RIGHT_TOP_GP_HEIGHT_RATIO = 0.4; + public static final double PANE_DEF_CFG_1_SKEWT_WIDTH_RATIO = 0.8; + public static final double PANE_DEF_CFG_1_SKEWT_HEIGHT_RATIO = PANE_DEF_CFG_1_LEFT_TOP_GP_HEIGHT_RATIO; - public static final double PANE_DEF_CFG_1_WITO_WIDTH_RATIO = 1-PANE_DEF_CFG_1_SKEWT_WIDTH_RATIO; + + public static final double PANE_DEF_CFG_1_WITO_WIDTH_RATIO = 1 - PANE_DEF_CFG_1_SKEWT_WIDTH_RATIO; + public static final double PANE_DEF_CFG_1_WITO_HEIGHT_RATIO = PANE_DEF_CFG_1_SKEWT_HEIGHT_RATIO; + public static final double PANE_DEF_CFG_1_HODO_WIDTH_RATIO = 1; + public static final double PANE_DEF_CFG_1_HODO_HEIGHT_RATIO = PANE_DEF_CFG_1_RIGHT_TOP_GP_HEIGHT_RATIO; + public static final double PANE_DEF_CFG_1_INSET_WIDTH_RATIO = 0.5; - public static final double PANE_DEF_CFG_1_INSET_HEIGHT_RATIO = 1-PANE_DEF_CFG_1_SKEWT_HEIGHT_RATIO; - public static final double PANE_DEF_CFG_1_TIMESTN_WIDTH_RATIO = 1-PANE_DEF_CFG_1_INSET_WIDTH_RATIO; + + public static final double PANE_DEF_CFG_1_INSET_HEIGHT_RATIO = 1 - PANE_DEF_CFG_1_SKEWT_HEIGHT_RATIO; + + public static final double PANE_DEF_CFG_1_TIMESTN_WIDTH_RATIO = 1 - PANE_DEF_CFG_1_INSET_WIDTH_RATIO; + public static final double PANE_DEF_CFG_1_TIMESTN_HEIGHT_RATIO = PANE_DEF_CFG_1_INSET_HEIGHT_RATIO; + public static final double PANE_DEF_CFG_1_DATA_WIDTH_RATIO = 1; - public static final double PANE_DEF_CFG_1_DATA_HEIGHT_RATIO = 1-PANE_DEF_CFG_1_HODO_HEIGHT_RATIO; - // pane default configuration 2 - // full canvas consists of left group and right group - // both groups contains top and bottom groups + + public static final double PANE_DEF_CFG_1_DATA_HEIGHT_RATIO = 1 - PANE_DEF_CFG_1_HODO_HEIGHT_RATIO; + + // pane default configuration 2 + // full canvas consists of left group and right group + // both groups contains top and bottom groups // left top group contains skewt and wito panes // left bottom group contains insets panes // right top group has hodo and time/stn panes // right bottom contains data panes public static final double PANE_DEF_CFG_2_LEFT_GP_WIDTH_RATIO = 0.5; + public static final double PANE_DEF_CFG_2_LEFT_TOP_GP_HEIGHT_RATIO = 0.8; + public static final double PANE_DEF_CFG_2_RIGHT_TOP_GP_HEIGHT_RATIO = 0.7; + public static final double PANE_DEF_CFG_2_SKEWT_WIDTH_RATIO = 0.85; + public static final double PANE_DEF_CFG_2_SKEWT_HEIGHT_RATIO = PANE_DEF_CFG_2_LEFT_TOP_GP_HEIGHT_RATIO; - public static final double PANE_DEF_CFG_2_WITO_WIDTH_RATIO = 1-PANE_DEF_CFG_2_SKEWT_WIDTH_RATIO; + + public static final double PANE_DEF_CFG_2_WITO_WIDTH_RATIO = 1 - PANE_DEF_CFG_2_SKEWT_WIDTH_RATIO; + public static final double PANE_DEF_CFG_2_WITO_HEIGHT_RATIO = PANE_DEF_CFG_2_SKEWT_HEIGHT_RATIO; + public static final double PANE_DEF_CFG_2_HODO_WIDTH_RATIO = 0.65; + public static final double PANE_DEF_CFG_2_HODO_HEIGHT_RATIO = PANE_DEF_CFG_2_RIGHT_TOP_GP_HEIGHT_RATIO; + public static final double PANE_DEF_CFG_2_INSET_WIDTH_RATIO = 1; - public static final double PANE_DEF_CFG_2_INSET_HEIGHT_RATIO = 1-PANE_DEF_CFG_2_SKEWT_HEIGHT_RATIO; + + public static final double PANE_DEF_CFG_2_INSET_HEIGHT_RATIO = 1 - PANE_DEF_CFG_2_SKEWT_HEIGHT_RATIO; + public static final double PANE_DEF_CFG_2_TIMESTN_WIDTH_RATIO = 0.35; + public static final double PANE_DEF_CFG_2_TIMESTN_HEIGHT_RATIO = PANE_DEF_CFG_2_HODO_HEIGHT_RATIO; + public static final double PANE_DEF_CFG_2_DATA_WIDTH_RATIO = 1; - public static final double PANE_DEF_CFG_2_DATA_HEIGHT_RATIO = 1-PANE_DEF_CFG_2_HODO_HEIGHT_RATIO; - - // pane SPC wide screen configuration - public static final double PANE_SPCWS_CFG_TOP_GP_HEIGHT_RATIO = 0.714; //5/7 - public static final double PANE_SPCWS_CFG_BOT_GP_HEIGHT_RATIO = 1-PANE_SPCWS_CFG_TOP_GP_HEIGHT_RATIO; - //skewt, wito, hodo/inset (hodo stack on inset) panes are located on top group - public static final double PANE_SPCWS_CFG_SKEWT_WIDTH_RATIO = 0.4938;//5/10.125; + + public static final double PANE_DEF_CFG_2_DATA_HEIGHT_RATIO = 1 - PANE_DEF_CFG_2_HODO_HEIGHT_RATIO; + + // pane SPC wide screen configuration + public static final double PANE_SPCWS_CFG_TOP_GP_HEIGHT_RATIO = 0.714; // 5/7 + + public static final double PANE_SPCWS_CFG_BOT_GP_HEIGHT_RATIO = 1 - PANE_SPCWS_CFG_TOP_GP_HEIGHT_RATIO; + + // skewt, wito, hodo/inset (hodo stack on inset) panes are located on top + // group + public static final double PANE_SPCWS_CFG_SKEWT_WIDTH_RATIO = 0.4938;// 5/10.125; + public static final double PANE_SPCWS_CFG_SKEWT_HEIGHT_RATIO = 1; - public static final double PANE_SPCWS_CFG_WITO_WIDTH_RATIO = 0.1111;//1.125/10.125; + + public static final double PANE_SPCWS_CFG_WITO_WIDTH_RATIO = 0.1111;// 1.125/10.125; + public static final double PANE_SPCWS_CFG_WITO_HEIGHT_RATIO = 1; - public static final double PANE_SPCWS_CFG_HODO_WIDTH_RATIO = 1- PANE_SPCWS_CFG_SKEWT_WIDTH_RATIO-PANE_SPCWS_CFG_WITO_WIDTH_RATIO; - public static final double PANE_SPCWS_CFG_HODO_HEIGHT_RATIO = 0.825;//4.125/5; + + public static final double PANE_SPCWS_CFG_HODO_WIDTH_RATIO = 1 + - PANE_SPCWS_CFG_SKEWT_WIDTH_RATIO + - PANE_SPCWS_CFG_WITO_WIDTH_RATIO; + + public static final double PANE_SPCWS_CFG_HODO_HEIGHT_RATIO = 0.825;// 4.125/5; + public static final double PANE_SPCWS_CFG_INSET_WIDTH_RATIO = PANE_SPCWS_CFG_HODO_WIDTH_RATIO; - public static final double PANE_SPCWS_CFG_INSET_HEIGHT_RATIO = 1- PANE_SPCWS_CFG_HODO_HEIGHT_RATIO; - //data and other graphs panes are located on bottom group + + public static final double PANE_SPCWS_CFG_INSET_HEIGHT_RATIO = 1 - PANE_SPCWS_CFG_HODO_HEIGHT_RATIO; + + // data and other graphs panes are located on bottom group public static final double PANE_SPCWS_CFG_DATA_WIDTH_RATIO = 0.5; + public static final double PANE_SPCWS_CFG_DATA_HEIGHT_RATIO = 1; + public static final double PANE_SPCWS_CFG_SPC_GRAPHS_WIDTH_RATIO = 0.5; + public static final double PANE_SPCWS_CFG_SPC_GRAPHS_HEIGHT_RATIO = 1; - //simple D2D pane configuration. - // full canvas consists of top and bottom group + // simple D2D pane configuration. + // full canvas consists of top and bottom group public static final double PANE_SIMPLE_D2D_CFG_TOP_GP_HEIGHT_RATIO = 0.71; - public static final double PANE_SIMPLE_D2D_CFG_BOT_GP_HEIGHT_RATIO = 1-PANE_SIMPLE_D2D_CFG_TOP_GP_HEIGHT_RATIO; - // top group contains left (skewt) and right groups (time/stn stack on future pane) + + public static final double PANE_SIMPLE_D2D_CFG_BOT_GP_HEIGHT_RATIO = 1 - PANE_SIMPLE_D2D_CFG_TOP_GP_HEIGHT_RATIO; + + // top group contains left (skewt) and right groups (time/stn stack on + // future pane) public static final double PANE_SIMPLE_D2D_CFG_SKEWT_WIDTH_RATIO = 0.75; + public static final double PANE_SIMPLE_D2D_CFG_SKEWT_HEIGHT_RATIO = 1; - public static final double PANE_SIMPLE_D2D_CFG_TIMESTN_WIDTH_RATIO = 1-PANE_SIMPLE_D2D_CFG_SKEWT_WIDTH_RATIO; - public static final double PANE_SIMPLE_D2D_CFG_TIMESTN_HEIGHT_RATIO = 0.5; + + public static final double PANE_SIMPLE_D2D_CFG_TIMESTN_WIDTH_RATIO = 1 - PANE_SIMPLE_D2D_CFG_SKEWT_WIDTH_RATIO; + + public static final double PANE_SIMPLE_D2D_CFG_TIMESTN_HEIGHT_RATIO = 1; // d2dlite + public static final double PANE_SIMPLE_D2D_CFG_FUTURE_WIDTH_RATIO = PANE_SIMPLE_D2D_CFG_TIMESTN_WIDTH_RATIO; - public static final double PANE_SIMPLE_D2D_CFG_FUTURE_HEIGHT_RATIO = 1-PANE_SIMPLE_D2D_CFG_TIMESTN_HEIGHT_RATIO; + + public static final double PANE_SIMPLE_D2D_CFG_FUTURE_HEIGHT_RATIO = 1 - PANE_SIMPLE_D2D_CFG_TIMESTN_HEIGHT_RATIO; + // bottom group has hodo on left and data pane on right public static final double PANE_SIMPLE_D2D_CFG_HODO_WIDTH_RATIO = 0.34; - public static final double PANE_SIMPLE_D2D_CFG_HODO_HEIGHT_RATIO = 1; - public static final double PANE_SIMPLE_D2D_CFG_DATA_WIDTH_RATIO = 1-PANE_SIMPLE_D2D_CFG_HODO_WIDTH_RATIO; + + public static final double PANE_SIMPLE_D2D_CFG_HODO_HEIGHT_RATIO = 1; + + public static final double PANE_SIMPLE_D2D_CFG_DATA_WIDTH_RATIO = 1 - PANE_SIMPLE_D2D_CFG_HODO_WIDTH_RATIO; + public static final double PANE_SIMPLE_D2D_CFG_DATA_HEIGHT_RATIO = 1; + + // d2dlite start + // D2D lite pane configuration. + // full canvas consists of left (skewt) and right groups (time/stn/src) + // stack on data pane + public static final double PANE_LITE_D2D_CFG_SKEWT_WIDTH_RATIO = 0.75; + + public static final double PANE_LITE_D2D_CFG_SKEWT_HEIGHT_RATIO = 1; + + public static final double PANE_LITE_D2D_CFG_HODO_WIDTH_RATIO = 0.75; + + public static final double PANE_LITE_D2D_CFG_HODO_HEIGHT_RATIO = 1; + + public static final double PANE_LITE_D2D_CFG_TIMESTN_WIDTH_RATIO = 1 - PANE_LITE_D2D_CFG_SKEWT_WIDTH_RATIO; + + public static final double PANE_LITE_D2D_CFG_TIMESTN_HEIGHT_RATIO = 0.5; + + public static final double PANE_LITE_D2D_CFG_DATA_WIDTH_RATIO = PANE_LITE_D2D_CFG_TIMESTN_WIDTH_RATIO; + + public static final double PANE_LITE_D2D_CFG_DATA_HEIGHT_RATIO = 1 - PANE_LITE_D2D_CFG_TIMESTN_HEIGHT_RATIO; + + // d2dlite end /*** * * MULTIPLE PANES IMPLEMENTATIONS end * * ****/ - - - //Dialog - //public static final int dialogX = 300; + + // Dialog + // public static final int dialogX = 300; public static int btnWidth = 120; - public static int btnHeight = 20; - public static int labelGap = 20; - public static int btnGapX = 5; - public static int btnGapY = 5; - public static int listWidth = 160; - public static int listHeight = 80; - public static int filelistWidth = 120; - public static int filelistHeight = 100; - public static int dsiplayPanelSize = 2; - - public static int GRAPH_SKEWT = 0; - public static int GRAPH_ICING = 1; - public static int GRAPH_TURB = 2; - public static int MAX_GRAPH_MODE = 3; - - public static int SKEWT_EDIT_MODE_EDITPOINT = 0; - public static int SKEWT_EDIT_MODE_MOVELINE = 1; - public static int SKEWT_EDIT_MODE_MODIFYRANGE = 2; - - public static String getNlistFile() { - return NcPathManager.getInstance().getStaticFile( - NcPathConstants.NSHARP_NLIST_FILE ).getAbsolutePath(); + + public static int btnHeight = 20; + + public static int labelGap = 20; + + public static int btnGapX = 5; + + public static int btnGapY = 5; + + public static int listWidth = 160; + + public static int listHeight = 80; + + public static int filelistWidth = 120; + + public static int filelistHeight = 100; + + public static int dsiplayPanelSize = 2; + + public static int GRAPH_SKEWT = 0; + + public static int GRAPH_HODO = 1; + + public static int GRAPH_ICING = 2; + + public static int GRAPH_TURB = 3; + + public static int MAX_GRAPH_MODE = 4; + + public static int SKEWT_EDIT_MODE_EDITPOINT = 0; + + public static int SKEWT_EDIT_MODE_MOVELINE = 1; + + public static int SKEWT_EDIT_MODE_MODIFYRANGE = 2; + + public static String getNlistFile() { + return NcPathManager.getInstance() + .getStaticFile(NcPathConstants.NSHARP_NLIST_FILE) + .getAbsolutePath(); } - public static String getSupFile() { - return NcPathManager.getInstance().getStaticFile( - NcPathConstants.NSHARP_SUP_FILE ).getAbsolutePath(); + + public static String getSupFile() { + return NcPathManager.getInstance() + .getStaticFile(NcPathConstants.NSHARP_SUP_FILE) + .getAbsolutePath(); } - - //Line configuration. Line name listing order in this array should be in order with constant defined below it. - public static String[] lineNameArray= {"Temperature", "Dew Point", "Parcel Tv","Parcel","DCAPE","Virtual Temp","Wetbulb","Wind Barb","Overlay 1", "Overlay 2", "Compare 1", "Compare 2","Compare 3","Compare 4","Compare 5","Compare 6","Compare 7","Compare 8","Compare 9","Compare 10", - "Icing RH", "Icing Temp", "Icing EPI", "Turbulence Ln", "Turbulence WindShear"}; - public static int LINE_TEMP = 0; - public static int LINE_DEWP = LINE_TEMP+1; - public static int LINE_PARCEL_TV = LINE_DEWP+1; - public static int LINE_PARCEL = LINE_PARCEL_TV+1; - public static int LINE_DCAPE =LINE_PARCEL+1; - public static int LINE_VIRTUAL_TEMP =LINE_DCAPE+1; - public static int LINE_WETBULB = LINE_VIRTUAL_TEMP+1; - public static int LINE_WIND_BARB = LINE_WETBULB+1; - public static int LINE_OVERLAY1 = LINE_WIND_BARB+1; - public static int LINE_OVERLAY2= LINE_OVERLAY1+1; - public static int LINE_COMP1 = LINE_OVERLAY2+1; - public static int LINE_COMP2 = LINE_COMP1+1; - public static int LINE_COMP3 = LINE_COMP2+1; - public static int LINE_COMP4 = LINE_COMP3+1; - public static int LINE_COMP5 = LINE_COMP4+1; - public static int LINE_COMP6 = LINE_COMP5+1; - public static int LINE_COMP7 = LINE_COMP6+1; - public static int LINE_COMP8 = LINE_COMP7+1; - public static int LINE_COMP9 = LINE_COMP8+1; - public static int LINE_COMP10 = LINE_COMP9+1; - public static int LINE_ICING_RH = LINE_COMP10+1; - public static int LINE_ICING_TEMP= LINE_ICING_RH+1; - public static int LINE_ICING_EPI= LINE_ICING_TEMP+1; - public static int LINE_TURBULENCE_LN = LINE_ICING_EPI+1; - public static int LINE_TURBULENCE_WS = LINE_TURBULENCE_LN+1; - - //defaultLineProperty should be listed in sync with lineNameArray for each line - public static NsharpLineProperty[] defaultLineProperty = - { - new NsharpLineProperty(LineStyle.SOLID, 2,color_red ), - new NsharpLineProperty(LineStyle.SOLID, 2,color_green ), - new NsharpLineProperty(LineStyle.SHORT_DASHED, 1,color_white ), - new NsharpLineProperty(LineStyle.DOTS, 1,color_darkorange ), - new NsharpLineProperty(LineStyle.DOTS, 2,color_white ), - new NsharpLineProperty(LineStyle.SHORT_DASHED, 2,color_red ), - new NsharpLineProperty(LineStyle.SOLID, 1,wetBulbColor ), - new NsharpLineProperty(LineStyle.SOLID, 1,color_yellow ), - new NsharpLineProperty(LineStyle.SOLID, 2,color_red ), - new NsharpLineProperty(LineStyle.SOLID, 2,color_green ), - new NsharpLineProperty(LineStyle.SOLID, 2,color_red ), - new NsharpLineProperty(LineStyle.SOLID, 2,color_green ), - new NsharpLineProperty(LineStyle.SOLID, 2, new RGB (155, 0, 220) ), - new NsharpLineProperty(LineStyle.SOLID, 2,new RGB (30, 144, 255) ), - new NsharpLineProperty(LineStyle.SOLID, 2,new RGB (255, 215, 0) ), - new NsharpLineProperty(LineStyle.SOLID, 2,new RGB (0, 255, 255) ), - new NsharpLineProperty(LineStyle.SOLID, 2,new RGB (139, 71, 38) ), - new NsharpLineProperty(LineStyle.SOLID, 2,new RGB (139, 0, 139) ), - new NsharpLineProperty(LineStyle.SOLID, 2,new RGB (0, 139, 0) ), - new NsharpLineProperty(LineStyle.SOLID, 2,new RGB (144, 238, 144) ), - new NsharpLineProperty(LineStyle.SOLID, 2,color_green ), - new NsharpLineProperty(LineStyle.SOLID, 2,color_red ), - new NsharpLineProperty(LineStyle.SOLID, 2,color_magenta ), - new NsharpLineProperty(LineStyle.SOLID, 2,color_magenta ), - new NsharpLineProperty(LineStyle.SOLID, 2,new RGB (255, 174, 185) ) - - }; - //data page name and its plotting function key definitions - public final static int PAGE_SUMMARY1 = 1; - public final static int PAGE_SUMMARY2 = 2; - public final static int PAGE_PARCEL_DATA = 3; - public final static int PAGE_THERMODYNAMIC_DATA = 4; - public final static int PAGE_OPC_DATA = 5; - public final static int PAGE_MIXING_HEIGHT = 6; - public final static int PAGE_STORM_RELATIVE = 7; - public final static int PAGE_MEAN_WIND = 8; - public final static int PAGE_CONVECTIVE_INITIATION = 9; - public final static int PAGE_SEVERE_POTENTIAL = 10; - public final static int PAGE_MAX_NUMBER = PAGE_SEVERE_POTENTIAL; - public static String[] PAGE_NAME_ARRAY = { - "", //a dummy one - "Summary 1 Page", - "Summary 2 Page", - "Parcel Data Page", - "Thermodynamic Data Page", - "Opc Low Level Stability Page", - "Mixing Height Page", - "Storm Relative Page", - "Mean Wind Page", - "Convective Initiation Page", - "Severe Potential Page" - }; - public enum State { - CURRENT, ACTIVE, INACTIVE,NOTAVAIL , AVAIL, ACTIVE_SRC_COMP, INACTIVE_SRC_COMP,ACTIVE_TM_COMP, INACTIVE_TM_COMP - } - //public enum LoadState { NOTAVAIL , AVAIL} - public enum ActState {CURRENT, ACTIVE, INACTIVE}//, ACTIVE_SRC_COMP, INACTIVE_SRC_COMP,ACTIVE_TM_COMP, INACTIVE_TM_COMP} - public enum SPCGraph { - EBS, STP, SHIP, WINTER, FIRE, HAIL, SARS - } - + + // Line configuration. Line name listing order in this array should be in + // order with constant defined below it. + public static String[] lineNameArray = { "Temperature", "Dew Point", + "Parcel Tv", "Parcel", "DCAPE", "Virtual Temp", "Wetbulb", + "Wind Barb", "Overlay 1", "Overlay 2", "Compare 1", "Compare 2", + "Compare 3", "Compare 4", "Compare 5", "Compare 6", "Compare 7", + "Compare 8", "Compare 9", "Compare 10", "Icing RH", "Icing Temp", + "Icing EPI", "Turbulence Ln", "Turbulence WindShear" }; + + public static int LINE_TEMP = 0; + + public static int LINE_DEWP = LINE_TEMP + 1; + + public static int LINE_PARCEL_TV = LINE_DEWP + 1; + + public static int LINE_PARCEL = LINE_PARCEL_TV + 1; + + public static int LINE_DCAPE = LINE_PARCEL + 1; + + public static int LINE_VIRTUAL_TEMP = LINE_DCAPE + 1; + + public static int LINE_WETBULB = LINE_VIRTUAL_TEMP + 1; + + public static int LINE_WIND_BARB = LINE_WETBULB + 1; + + public static int LINE_OVERLAY1 = LINE_WIND_BARB + 1; + + public static int LINE_OVERLAY2 = LINE_OVERLAY1 + 1; + + public static int LINE_COMP1 = LINE_OVERLAY2 + 1; + + public static int LINE_COMP2 = LINE_COMP1 + 1; + + public static int LINE_COMP3 = LINE_COMP2 + 1; + + public static int LINE_COMP4 = LINE_COMP3 + 1; + + public static int LINE_COMP5 = LINE_COMP4 + 1; + + public static int LINE_COMP6 = LINE_COMP5 + 1; + + public static int LINE_COMP7 = LINE_COMP6 + 1; + + public static int LINE_COMP8 = LINE_COMP7 + 1; + + public static int LINE_COMP9 = LINE_COMP8 + 1; + + public static int LINE_COMP10 = LINE_COMP9 + 1; + + public static int LINE_ICING_RH = LINE_COMP10 + 1; + + public static int LINE_ICING_TEMP = LINE_ICING_RH + 1; + + public static int LINE_ICING_EPI = LINE_ICING_TEMP + 1; + + public static int LINE_TURBULENCE_LN = LINE_ICING_EPI + 1; + + public static int LINE_TURBULENCE_WS = LINE_TURBULENCE_LN + 1; + + // defaultLineProperty should be listed in sync with lineNameArray for each + // line + public static NsharpLineProperty[] defaultLineProperty = { + new NsharpLineProperty(LineStyle.SOLID, 2, color_red), + new NsharpLineProperty(LineStyle.SOLID, 2, color_green), + new NsharpLineProperty(LineStyle.SHORT_DASHED, 1, color_white), + new NsharpLineProperty(LineStyle.DOTS, 1, color_darkorange), + new NsharpLineProperty(LineStyle.DOTS, 2, color_white), + new NsharpLineProperty(LineStyle.SHORT_DASHED, 2, color_red), + new NsharpLineProperty(LineStyle.SOLID, 1, wetBulbColor), + new NsharpLineProperty(LineStyle.SOLID, 1, color_yellow), + new NsharpLineProperty(LineStyle.SOLID, 2, color_red), + new NsharpLineProperty(LineStyle.SOLID, 2, color_green), + new NsharpLineProperty(LineStyle.SOLID, 2, color_red), + new NsharpLineProperty(LineStyle.SOLID, 2, color_green), + new NsharpLineProperty(LineStyle.SOLID, 2, new RGB(155, 0, 220)), + new NsharpLineProperty(LineStyle.SOLID, 2, new RGB(30, 144, 255)), + new NsharpLineProperty(LineStyle.SOLID, 2, new RGB(255, 215, 0)), + new NsharpLineProperty(LineStyle.SOLID, 2, new RGB(0, 255, 255)), + new NsharpLineProperty(LineStyle.SOLID, 2, new RGB(139, 71, 38)), + new NsharpLineProperty(LineStyle.SOLID, 2, new RGB(139, 0, 139)), + new NsharpLineProperty(LineStyle.SOLID, 2, new RGB(0, 139, 0)), + new NsharpLineProperty(LineStyle.SOLID, 2, new RGB(144, 238, 144)), + new NsharpLineProperty(LineStyle.SOLID, 2, color_green), + new NsharpLineProperty(LineStyle.SOLID, 2, color_red), + new NsharpLineProperty(LineStyle.SOLID, 2, color_magenta), + new NsharpLineProperty(LineStyle.SOLID, 2, color_magenta), + new NsharpLineProperty(LineStyle.SOLID, 2, new RGB(255, 174, 185)) + + }; + + // data page name and its plotting function key definitions + public final static int PAGE_SUMMARY1 = 1; + + public final static int PAGE_SUMMARY2 = 2; + + public final static int PAGE_PARCEL_DATA = 3; + + public final static int PAGE_THERMODYNAMIC_DATA = 4; + + public final static int PAGE_OPC_DATA = 5; + + public final static int PAGE_MIXING_HEIGHT = 6; + + public final static int PAGE_STORM_RELATIVE = 7; + + public final static int PAGE_MEAN_WIND = 8; + + public final static int PAGE_CONVECTIVE_INITIATION = 9; + + public final static int PAGE_SEVERE_POTENTIAL = 10; + + public final static int PAGE_D2DLITE = 11; // d2dlite + + public final static int PAGE_FUTURE = 12; // d2dlite, a dummy page, for when + // showing 2 pages per time + + public final static int PAGE_MAX_NUMBER = PAGE_FUTURE; + + public static String[] PAGE_NAME_ARRAY = { + "", // a dummy one + "Summary 1 Page", "Summary 2 Page", "Parcel Data Page", + "Thermodynamic Data Page", "Opc Low Level Stability Page", + "Mixing Height Page", "Storm Relative Page", "Mean Wind Page", + "Convective Initiation Page", "Severe Potential Page", + "D2D Lite Page", "future page" }; + + public enum State { + CURRENT, ACTIVE, INACTIVE, NOTAVAIL, AVAIL, ACTIVE_SRC_COMP, INACTIVE_SRC_COMP, ACTIVE_TM_COMP, INACTIVE_TM_COMP + } + + // public enum LoadState { NOTAVAIL , AVAIL} + public enum ActState { + CURRENT, ACTIVE, INACTIVE + }// , ACTIVE_SRC_COMP, INACTIVE_SRC_COMP,ACTIVE_TM_COMP, INACTIVE_TM_COMP} + + public enum SPCGraph { + EBS, STP, SHIP, WINTER, FIRE, HAIL, SARS + } + + public static final int MAX_SOUNDING_SOURCE_STR_LENGTH = 8; } diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/NsharpDataPageProperty.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/NsharpDataPageProperty.java index ca5523c036..d8f0ba68eb 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/NsharpDataPageProperty.java +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/NsharpDataPageProperty.java @@ -1,4 +1,5 @@ package gov.noaa.nws.ncep.ui.nsharp; + /** * * gov.noaa.nws.ncep.ui.nsharp.NsharpDataPageProperty @@ -24,128 +25,153 @@ import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlRootElement; import com.raytheon.uf.common.serialization.ISerializableObject; + @XmlRootElement(name = "NsharpDataPageProperty") @XmlAccessorType(XmlAccessType.NONE) -public class NsharpDataPageProperty implements ISerializableObject{ - @XmlAttribute - private int summary1Page=NsharpConstants.PAGE_SUMMARY1; - - @XmlAttribute - private int summary2Page=NsharpConstants.PAGE_SUMMARY2; +public class NsharpDataPageProperty implements ISerializableObject { + @XmlAttribute + private int summary1Page = NsharpConstants.PAGE_SUMMARY1; - @XmlAttribute - private int parcelDataPage=NsharpConstants.PAGE_PARCEL_DATA; - - @XmlAttribute - private int thermodynamicDataPage=NsharpConstants.PAGE_THERMODYNAMIC_DATA; - - @XmlAttribute - private int opcDataPage=NsharpConstants.PAGE_OPC_DATA; - - @XmlAttribute - private int mixingHeightPage=NsharpConstants.PAGE_MIXING_HEIGHT; - - @XmlAttribute - private int stormRelativePage=NsharpConstants.PAGE_STORM_RELATIVE; - - @XmlAttribute - private int meanWindPage=NsharpConstants.PAGE_MEAN_WIND; - - @XmlAttribute - private int convectiveInitiationPage=NsharpConstants.PAGE_CONVECTIVE_INITIATION; - - @XmlAttribute - private int severePotentialPage=NsharpConstants.PAGE_SEVERE_POTENTIAL; + @XmlAttribute + private int summary2Page = NsharpConstants.PAGE_SUMMARY2; - @XmlAttribute - private int numberPagePerDisplay = 1; - - public int getSummary1Page() { - return summary1Page; - } + @XmlAttribute + private int parcelDataPage = NsharpConstants.PAGE_PARCEL_DATA; - public void setSummary1Page(int summary1Page) { - this.summary1Page = summary1Page; - } + @XmlAttribute + private int thermodynamicDataPage = NsharpConstants.PAGE_THERMODYNAMIC_DATA; - public int getSummary2Page() { - return summary2Page; - } + @XmlAttribute + private int opcDataPage = NsharpConstants.PAGE_OPC_DATA; - public void setSummary2Page(int summary2Page) { - this.summary2Page = summary2Page; - } + @XmlAttribute + private int mixingHeightPage = NsharpConstants.PAGE_MIXING_HEIGHT; - public int getParcelDataPage() { - return parcelDataPage; - } + @XmlAttribute + private int stormRelativePage = NsharpConstants.PAGE_STORM_RELATIVE; - public void setParcelDataPage(int parcelDataPage) { - this.parcelDataPage = parcelDataPage; - } + @XmlAttribute + private int meanWindPage = NsharpConstants.PAGE_MEAN_WIND; - public int getThermodynamicDataPage() { - return thermodynamicDataPage; - } + @XmlAttribute + private int convectiveInitiationPage = NsharpConstants.PAGE_CONVECTIVE_INITIATION; - public void setThermodynamicDataPage(int thermodynamicDataPage) { - this.thermodynamicDataPage = thermodynamicDataPage; - } + @XmlAttribute + private int severePotentialPage = NsharpConstants.PAGE_SEVERE_POTENTIAL; - public int getOpcDataPage() { - return opcDataPage; - } + // d2dlite + @XmlAttribute + private int d2dLitePage = NsharpConstants.PAGE_D2DLITE; - public void setOpcDataPage(int opcDataPage) { - this.opcDataPage = opcDataPage; - } + // d2dlite + @XmlAttribute + private int futurePage = NsharpConstants.PAGE_FUTURE; - public int getMixingHeightPage() { - return mixingHeightPage; - } + @XmlAttribute + private int numberPagePerDisplay = 1; - public void setMixingHeightPage(int mixingHeightPage) { - this.mixingHeightPage = mixingHeightPage; - } + public int getSummary1Page() { + return summary1Page; + } - public int getStormRelativePage() { - return stormRelativePage; - } + public void setSummary1Page(int summary1Page) { + this.summary1Page = summary1Page; + } - public void setStormRelativePage(int stormRelativePage) { - this.stormRelativePage = stormRelativePage; - } + public int getSummary2Page() { + return summary2Page; + } - public int getMeanWindPage() { - return meanWindPage; - } + public void setSummary2Page(int summary2Page) { + this.summary2Page = summary2Page; + } - public void setMeanWindPage(int meanWindPage) { - this.meanWindPage = meanWindPage; - } + public int getParcelDataPage() { + return parcelDataPage; + } - public int getConvectiveInitiationPage() { - return convectiveInitiationPage; - } + public void setParcelDataPage(int parcelDataPage) { + this.parcelDataPage = parcelDataPage; + } - public void setConvectiveInitiationPage(int convectiveInitiationPage) { - this.convectiveInitiationPage = convectiveInitiationPage; - } + public int getThermodynamicDataPage() { + return thermodynamicDataPage; + } - public int getSeverePotentialPage() { - return severePotentialPage; - } + public void setThermodynamicDataPage(int thermodynamicDataPage) { + this.thermodynamicDataPage = thermodynamicDataPage; + } - public void setSeverePotentialPage(int severePotentialPage) { - this.severePotentialPage = severePotentialPage; - } + public int getOpcDataPage() { + return opcDataPage; + } - public int getNumberPagePerDisplay() { - return numberPagePerDisplay; - } + public void setOpcDataPage(int opcDataPage) { + this.opcDataPage = opcDataPage; + } - public void setNumberPagePerDisplay(int numberPagePerDisplay) { - this.numberPagePerDisplay = numberPagePerDisplay; - } - + public int getMixingHeightPage() { + return mixingHeightPage; + } + + public void setMixingHeightPage(int mixingHeightPage) { + this.mixingHeightPage = mixingHeightPage; + } + + public int getStormRelativePage() { + return stormRelativePage; + } + + public void setStormRelativePage(int stormRelativePage) { + this.stormRelativePage = stormRelativePage; + } + + public int getMeanWindPage() { + return meanWindPage; + } + + public void setMeanWindPage(int meanWindPage) { + this.meanWindPage = meanWindPage; + } + + public int getConvectiveInitiationPage() { + return convectiveInitiationPage; + } + + public void setConvectiveInitiationPage(int convectiveInitiationPage) { + this.convectiveInitiationPage = convectiveInitiationPage; + } + + public int getSeverePotentialPage() { + return severePotentialPage; + } + + public void setSeverePotentialPage(int severePotentialPage) { + this.severePotentialPage = severePotentialPage; + } + + public int getNumberPagePerDisplay() { + return numberPagePerDisplay; + } + + public void setNumberPagePerDisplay(int numberPagePerDisplay) { + this.numberPagePerDisplay = numberPagePerDisplay; + } + + // d2dlite + public int getD2dLitePage() { + return d2dLitePage; + } + + public void setD2dLitePage(int d2dLitePage) { + this.d2dLitePage = d2dLitePage; + } + + public int getFuturePage() { + return futurePage; + } + + public void setFuturePage(int futurePage) { + this.futurePage = futurePage; + } } diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/NsharpGraphProperty.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/NsharpGraphProperty.java index a7ac7e0f54..b8a180a2a1 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/NsharpGraphProperty.java +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/NsharpGraphProperty.java @@ -1,4 +1,5 @@ package gov.noaa.nws.ncep.ui.nsharp; + /** * * gov.noaa.nws.ncep.ui.nsharp.NsharpGraphProperty @@ -33,330 +34,342 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.eclipse.swt.graphics.RGB; import com.raytheon.uf.common.serialization.ISerializableObject; + @XmlRootElement(name = "NsharpGraphProperty") @XmlAccessorType(XmlAccessType.NONE) -public class NsharpGraphProperty implements ISerializableObject{ - @XmlAttribute - private boolean temp=true; - - @XmlAttribute - private boolean dewp=true; - - @XmlAttribute - private boolean parcelTv=true; - - @XmlAttribute - private boolean parcel=true; - - @XmlAttribute - private boolean dcape=true; - - @XmlAttribute - private boolean VTemp=true; - - @XmlAttribute - private boolean wetBulb=true; - - @XmlAttribute - private boolean mixratio=false; - - @XmlAttribute - private boolean dryAdiabat=true; - - @XmlAttribute - private boolean moistAdiabat=false; - - @XmlAttribute - private boolean effLayer=true; - - @XmlAttribute - private boolean cloud=false; - - @XmlAttribute - private boolean hodo=true; - - @XmlAttribute - private boolean meanWind=true; - - @XmlAttribute - private boolean smv3075=false; - - @XmlAttribute - private boolean smv1585=false; - - @XmlAttribute - private boolean smvBunkersR=true; - - @XmlAttribute - private boolean smvBunkersL=true; - - @XmlAttribute - private boolean omega=true; - - @XmlAttribute - private boolean corfidiV=false; - - @XmlAttribute - private boolean windBarb=true; - - @XmlAttribute - private int windBarbDistance=NsharpConstants.WINDBARB_DISTANCE_DEFAULT; - - @XmlAttribute - private int tempOffset=0; - - @XmlAttribute - private String paneConfigurationName= NsharpConstants.PANE_DEF_CFG_1_STR; - - @XmlAttribute - private List gribModelTypeList = new ArrayList(); - - @XmlAttribute - private float windBarbLineWidth=NsharpConstants.WINDBARB_WIDTH; - - @XmlAttribute - private float windBarbSize=NsharpConstants.WINDBARB_SIZE; - - @XmlElement +public class NsharpGraphProperty implements ISerializableObject { + @XmlAttribute + private boolean temp = true; + + @XmlAttribute + private boolean dewp = true; + + @XmlAttribute + private boolean parcelTv = true; + + @XmlAttribute + private boolean parcel = true; + + @XmlAttribute + private boolean dcape = true; + + @XmlAttribute + private boolean VTemp = true; + + @XmlAttribute + private boolean wetBulb = true; + + @XmlAttribute + private boolean mixratio = false; + + @XmlAttribute + private boolean dryAdiabat = true; + + @XmlAttribute + private boolean moistAdiabat = false; + + @XmlAttribute + private boolean effLayer = true; + + @XmlAttribute + private boolean cloud = false; + + @XmlAttribute + private boolean hodo = true; + + @XmlAttribute + private boolean meanWind = true; + + @XmlAttribute + private boolean smv3075 = false; + + @XmlAttribute + private boolean smv1585 = false; + + @XmlAttribute + private boolean smvBunkersR = true; + + @XmlAttribute + private boolean smvBunkersL = true; + + @XmlAttribute + private boolean omega = true; + + @XmlAttribute + private boolean corfidiV = false; + + @XmlAttribute + private boolean windBarb = true; + + @XmlAttribute + private int windBarbDistance = NsharpConstants.WINDBARB_DISTANCE_DEFAULT; + + @XmlAttribute + private int tempOffset = 0; + + @XmlAttribute + private String paneConfigurationName = NsharpConstants.PANE_DEF_CFG_1_STR; + + @XmlAttribute + private List gribModelTypeList = new ArrayList(); + + @XmlAttribute + private float windBarbLineWidth = NsharpConstants.WINDBARB_WIDTH; + + @XmlAttribute + private float windBarbSize = NsharpConstants.WINDBARB_SIZE; + + @XmlElement @XmlJavaTypeAdapter(RGBColorAdapter.class) - private RGB windBarbColor= NsharpConstants.color_yellow; - - @XmlAttribute - private boolean showFilteredWindInCircle=false; - - public boolean isTemp() { - return temp; - } + private RGB windBarbColor = NsharpConstants.color_yellow; - public void setTemp(boolean temp) { - this.temp = temp; - } + @XmlAttribute + private boolean showFilteredWindInCircle = false; - public boolean isDewp() { - return dewp; - } + @XmlAttribute + private int sndCompRadius = 0; // FixMark:nearByStnCompSnd - public void setDewp(boolean dewp) { - this.dewp = dewp; - } + public boolean isTemp() { + return temp; + } - - public boolean isParcelTv() { - return parcelTv; - } + public void setTemp(boolean temp) { + this.temp = temp; + } - public void setParcelTv(boolean parcelTv) { - this.parcelTv = parcelTv; - } + public boolean isDewp() { + return dewp; + } - public boolean isParcel() { - return parcel; - } + public void setDewp(boolean dewp) { + this.dewp = dewp; + } - public void setParcel(boolean parcel) { - this.parcel = parcel; - } + public boolean isParcelTv() { + return parcelTv; + } - public boolean isDcape() { - return dcape; - } + public void setParcelTv(boolean parcelTv) { + this.parcelTv = parcelTv; + } - public void setDcape(boolean dcape) { - this.dcape = dcape; - } + public boolean isParcel() { + return parcel; + } - public boolean isVTemp() { - return VTemp; - } + public void setParcel(boolean parcel) { + this.parcel = parcel; + } - public void setVTemp(boolean vTemp) { - VTemp = vTemp; - } + public boolean isDcape() { + return dcape; + } - public boolean isWetBulb() { - return wetBulb; - } + public void setDcape(boolean dcape) { + this.dcape = dcape; + } - public void setWetBulb(boolean wetBulb) { - this.wetBulb = wetBulb; - } + public boolean isVTemp() { + return VTemp; + } - public boolean isMixratio() { - return mixratio; - } + public void setVTemp(boolean vTemp) { + VTemp = vTemp; + } - public void setMixratio(boolean mixratio) { - this.mixratio = mixratio; - } + public boolean isWetBulb() { + return wetBulb; + } - public boolean isDryAdiabat() { - return dryAdiabat; - } + public void setWetBulb(boolean wetBulb) { + this.wetBulb = wetBulb; + } - public void setDryAdiabat(boolean dryAdiabat) { - this.dryAdiabat = dryAdiabat; - } + public boolean isMixratio() { + return mixratio; + } - public boolean isMoistAdiabat() { - return moistAdiabat; - } + public void setMixratio(boolean mixratio) { + this.mixratio = mixratio; + } - public void setMoistAdiabat(boolean moistAdiabat) { - this.moistAdiabat = moistAdiabat; - } + public boolean isDryAdiabat() { + return dryAdiabat; + } - public boolean isEffLayer() { - return effLayer; - } + public void setDryAdiabat(boolean dryAdiabat) { + this.dryAdiabat = dryAdiabat; + } - public void setEffLayer(boolean effLayer) { - this.effLayer = effLayer; - } + public boolean isMoistAdiabat() { + return moistAdiabat; + } - public boolean isCloud() { - return cloud; - } + public void setMoistAdiabat(boolean moistAdiabat) { + this.moistAdiabat = moistAdiabat; + } - public void setCloud(boolean cloud) { - this.cloud = cloud; - } + public boolean isEffLayer() { + return effLayer; + } - public boolean isHodo() { - return hodo; - } + public void setEffLayer(boolean effLayer) { + this.effLayer = effLayer; + } - public void setHodo(boolean hodo) { - this.hodo = hodo; - } + public boolean isCloud() { + return cloud; + } - public boolean isMeanWind() { - return meanWind; - } + public void setCloud(boolean cloud) { + this.cloud = cloud; + } - public void setMeanWind(boolean meanWind) { - this.meanWind = meanWind; - } + public boolean isHodo() { + return hodo; + } - public boolean isSmv3075() { - return smv3075; - } + public void setHodo(boolean hodo) { + this.hodo = hodo; + } - public void setSmv3075(boolean smv3075) { - this.smv3075 = smv3075; - } + public boolean isMeanWind() { + return meanWind; + } - public boolean isSmv1585() { - return smv1585; - } + public void setMeanWind(boolean meanWind) { + this.meanWind = meanWind; + } - public void setSmv1585(boolean smv1585) { - this.smv1585 = smv1585; - } + public boolean isSmv3075() { + return smv3075; + } - public boolean isSmvBunkersR() { - return smvBunkersR; - } + public void setSmv3075(boolean smv3075) { + this.smv3075 = smv3075; + } - public void setSmvBunkersR(boolean smvBunkersR) { - this.smvBunkersR = smvBunkersR; - } + public boolean isSmv1585() { + return smv1585; + } - public boolean isSmvBunkersL() { - return smvBunkersL; - } + public void setSmv1585(boolean smv1585) { + this.smv1585 = smv1585; + } - public void setSmvBunkersL(boolean smvBunkersL) { - this.smvBunkersL = smvBunkersL; - } + public boolean isSmvBunkersR() { + return smvBunkersR; + } - public boolean isOmega() { - return omega; - } + public void setSmvBunkersR(boolean smvBunkersR) { + this.smvBunkersR = smvBunkersR; + } - public void setOmega(boolean omega) { - this.omega = omega; - } + public boolean isSmvBunkersL() { + return smvBunkersL; + } + public void setSmvBunkersL(boolean smvBunkersL) { + this.smvBunkersL = smvBunkersL; + } - public boolean isCorfidiV() { - return corfidiV; - } + public boolean isOmega() { + return omega; + } - public void setCorfidiV(boolean corfidiV) { - this.corfidiV = corfidiV; - } + public void setOmega(boolean omega) { + this.omega = omega; + } - public boolean isWindBarb() { - return windBarb; - } + public boolean isCorfidiV() { + return corfidiV; + } - public void setWindBarb(boolean windBarb) { - this.windBarb = windBarb; - } + public void setCorfidiV(boolean corfidiV) { + this.corfidiV = corfidiV; + } - public int getWindBarbDistance() { - return windBarbDistance; - } + public boolean isWindBarb() { + return windBarb; + } - public void setWindBarbDistance(int windBarbDistance) { - this.windBarbDistance = windBarbDistance; - } + public void setWindBarb(boolean windBarb) { + this.windBarb = windBarb; + } - public int getTempOffset() { - return tempOffset; - } + public int getWindBarbDistance() { + return windBarbDistance; + } - public void setTempOffset(int tempOffset) { - this.tempOffset = tempOffset; - } + public void setWindBarbDistance(int windBarbDistance) { + this.windBarbDistance = windBarbDistance; + } - public String getPaneConfigurationName() { - return paneConfigurationName; - } + public int getTempOffset() { + return tempOffset; + } - public void setPaneConfigurationName(String paneConfigurationName) { - this.paneConfigurationName = paneConfigurationName; - } + public void setTempOffset(int tempOffset) { + this.tempOffset = tempOffset; + } - public List getGribModelTypeList() { - return gribModelTypeList; - } + // FixMark:nearByStnCompSnd + public int getSndCompRadius() { + return sndCompRadius; + } - public void setGribModelTypeList(List gribModelTypeList) { - this.gribModelTypeList = gribModelTypeList; - } + public void setSndCompRadius(int sndCompRadius) { + this.sndCompRadius = sndCompRadius; + } - public float getWindBarbLineWidth() { - return windBarbLineWidth; - } + // end FixMark:nearByStnCompSnd - public void setWindBarbLineWidth(float windBarbLineWidth) { - this.windBarbLineWidth = windBarbLineWidth; - } + public String getPaneConfigurationName() { + return paneConfigurationName; + } - public float getWindBarbSize() { - return windBarbSize; - } + public void setPaneConfigurationName(String paneConfigurationName) { + this.paneConfigurationName = paneConfigurationName; + } - public void setWindBarbSize(float windBarbSize) { - this.windBarbSize = windBarbSize; - } + public List getGribModelTypeList() { + return gribModelTypeList; + } - public RGB getWindBarbColor() { - return windBarbColor; - } + public void setGribModelTypeList(List gribModelTypeList) { + this.gribModelTypeList = gribModelTypeList; + } - public void setWindBarbColor(RGB windBarbColor) { - this.windBarbColor = windBarbColor; - } + public float getWindBarbLineWidth() { + return windBarbLineWidth; + } - public boolean isShowFilteredWindInCircle() { - return showFilteredWindInCircle; - } + public void setWindBarbLineWidth(float windBarbLineWidth) { + this.windBarbLineWidth = windBarbLineWidth; + } - public void setShowFilteredWindInCircle(boolean showFilteredWindInCircle) { - this.showFilteredWindInCircle = showFilteredWindInCircle; - } + public float getWindBarbSize() { + return windBarbSize; + } + + public void setWindBarbSize(float windBarbSize) { + this.windBarbSize = windBarbSize; + } + + public RGB getWindBarbColor() { + return windBarbColor; + } + + public void setWindBarbColor(RGB windBarbColor) { + this.windBarbColor = windBarbColor; + } + + public boolean isShowFilteredWindInCircle() { + return showFilteredWindInCircle; + } + + public void setShowFilteredWindInCircle(boolean showFilteredWindInCircle) { + this.showFilteredWindInCircle = showFilteredWindInCircle; + } - } diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/background/NsharpIcingPaneBackground.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/background/NsharpIcingPaneBackground.java index ddd2344e6e..6710f89e08 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/background/NsharpIcingPaneBackground.java +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/background/NsharpIcingPaneBackground.java @@ -43,347 +43,408 @@ import com.raytheon.viz.core.graphing.WGraphics; import com.vividsolutions.jts.geom.Coordinate; public class NsharpIcingPaneBackground extends NsharpGenericPaneBackground { - //private NsharpSkewTPaneDescriptor desc; - - private IWireframeShape linesNumbersShape; - private IWireframeShape RHLabelShape; - private IWireframeShape tempLabelShape; - private IWireframeShape EPILabelShape;//Equivalent Potential Instability - private double currentZoomLevel=1; - private final float defaultLabelSpace = 50; - private float labelSpace = defaultLabelSpace; - private int iceXOrig=NsharpConstants.ICING_X_ORIG; - private int iceYOrig=NsharpConstants.ICING_Y_ORIG+(int)labelSpace; - private int iceXEnd=NsharpConstants.ICING_X_END; - private int iceWidth=NsharpConstants.ICING_WIDTH; - private int iceYEnd=iceYOrig+NsharpConstants.ICING_HEIGHT; - private int paneHeight = NsharpConstants.SKEWT_HEIGHT; - private float yMagFactor=1; - private float xMagFactor=1; - private NsharpGraphProperty graphConfigProperty; - public NsharpIcingPaneBackground(NsharpSkewTPaneDescriptor desc) { + // private NsharpSkewTPaneDescriptor desc; + + private IWireframeShape linesNumbersShape; + + private IWireframeShape RHLabelShape; + + private IWireframeShape tempLabelShape; + + private IWireframeShape EPILabelShape;// Equivalent Potential Instability + + private double currentZoomLevel = 1; + + private final float defaultLabelSpace = 50; + + private float labelSpace = defaultLabelSpace; + + private int iceXOrig = NsharpConstants.ICING_X_ORIG; + + private int iceYOrig = NsharpConstants.ICING_Y_ORIG + (int) labelSpace; + + private int iceXEnd = NsharpConstants.ICING_X_END; + + private int iceWidth = NsharpConstants.ICING_WIDTH; + + private int iceYEnd = iceYOrig + NsharpConstants.ICING_HEIGHT; + + private int paneHeight = NsharpConstants.SKEWT_HEIGHT; + + private float yMagFactor = 1; + + private float xMagFactor = 1; + + private NsharpGraphProperty graphConfigProperty; + + public NsharpIcingPaneBackground(NsharpSkewTPaneDescriptor desc) { super(); - this.rectangle = new Rectangle(iceXOrig, iceYOrig, - iceWidth, NsharpConstants.ICING_HEIGHT); + this.rectangle = new Rectangle(iceXOrig, iceYOrig, iceWidth, + NsharpConstants.ICING_HEIGHT); pe = new PixelExtent(this.rectangle); world = new WGraphics(this.rectangle); NsharpConfigManager configMgr = NsharpConfigManager.getInstance(); - graphConfigProperty = configMgr.retrieveNsharpConfigStoreFromFs().getGraphProperty(); - //System.out.println("NsharpIcingPaneBackground created"); + graphConfigProperty = configMgr.retrieveNsharpConfigStoreFromFs() + .getGraphProperty(); + // System.out.println("NsharpIcingPaneBackground created"); this.desc = desc; } - - - @Override - protected WGraphics computeWorld() { - // TODO Auto-generated method stub - return null; - } - private void createAllShapes(){ - IExtent ext = desc.getRenderableDisplay().getExtent(); - double xmin = ext.getMinX(); //Extent's viewable envelope min x and y - double ymax = ext.getMaxY(); + @Override + protected WGraphics computeWorld() { + // TODO Auto-generated method stub + return null; + } + + private void createAllShapes() { + IExtent ext = desc.getRenderableDisplay().getExtent(); + double xmin = ext.getMinX(); // Extent's viewable envelope min x and y + double ymax = ext.getMaxY(); double ymin = ext.getMinY(); - double dispX,pX=0; - double dispY, pY=0; + double dispX, pX = 0; + double dispY, pY = 0; String s = ""; - linesNumbersShape = target.createWireframeShape(false,desc ); - tempLabelShape = target.createWireframeShape(false,desc ); - RHLabelShape = target.createWireframeShape(false,desc ); - EPILabelShape = target.createWireframeShape(false,desc ); + linesNumbersShape = target.createWireframeShape(false, desc); + tempLabelShape = target.createWireframeShape(false, desc); + RHLabelShape = target.createWireframeShape(false, desc); + EPILabelShape = target.createWireframeShape(false, desc); linesNumbersShape.allocate(100); tempLabelShape.allocate(20); RHLabelShape.allocate(20); EPILabelShape.allocate(4); - //set world based on pressure/RH - world.setWorldCoordinates(NsharpConstants.ICING_RELATIVE_HUMIDITY_LEFT, toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_TOP), - NsharpConstants.ICING_RELATIVE_HUMIDITY_RIGHT, toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_BOTTOM)); - pX= world.mapX( NsharpConstants.ICING_RELATIVE_HUMIDITY_LEFT); - if(pX < xmin) - dispX = xmin + 20 * currentZoomLevel*xMagFactor; + // set world based on pressure/RH + world.setWorldCoordinates(NsharpConstants.ICING_RELATIVE_HUMIDITY_LEFT, + toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_TOP), + NsharpConstants.ICING_RELATIVE_HUMIDITY_RIGHT, + toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_BOTTOM)); + pX = world.mapX(NsharpConstants.ICING_RELATIVE_HUMIDITY_LEFT); + if (pX < xmin) + dispX = xmin + 20 * currentZoomLevel * xMagFactor; else - dispX = pX + 20 * currentZoomLevel*xMagFactor; - - //pressure lines and labels - for (double i = NsharpConstants.ICING_PRESSURE_LEVEL_TOP; i <= NsharpConstants.ICING_PRESSURE_LEVEL_BOTTOM; i=i+ NsharpConstants.ICING_PRESSURE_LEVEL_INC) { - //Pressure lines - double [][] lines = {{iceXOrig, world.mapY(toLogScale(i))},{iceXEnd, world.mapY(toLogScale(i))}}; - linesNumbersShape.addLineSegment(lines); - s = NsharpConstants.pressFormat.format(i); - //pressure labels - dispY = world.mapY(toLogScale(i))+5; - double [] lblXy = {dispX,dispY}; - linesNumbersShape.addLabel(s, lblXy); + dispX = pX + 20 * currentZoomLevel * xMagFactor; + + // pressure lines and labels + for (double i = NsharpConstants.ICING_PRESSURE_LEVEL_TOP; i <= NsharpConstants.ICING_PRESSURE_LEVEL_BOTTOM; i = i + + NsharpConstants.ICING_PRESSURE_LEVEL_INC) { + // Pressure lines + double[][] lines = { { iceXOrig, world.mapY(toLogScale(i)) }, + { iceXEnd, world.mapY(toLogScale(i)) } }; + linesNumbersShape.addLineSegment(lines); + s = NsharpConstants.pressFormat.format(i); + // pressure labels + dispY = world.mapY(toLogScale(i)) + 5; + double[] lblXy = { dispX, dispY }; + linesNumbersShape.addLabel(s, lblXy); } - //RHLabel - //double [] lblRhXy = {iceXOrig+ iceWidth/2, iceYOrig-45}; - //RHLabelShape.addLabel("*****ICING Display*****", lblRhXy); - double [] lblRhXy1 = {iceXOrig+iceWidth/2,iceYOrig-35*yMagFactor}; - RHLabelShape.addLabel("*****ICING Display***** RELATIVE HUMIDITY", lblRhXy1); - double [][] lineRH = {{0,0},{0,0}}; - RHLabelShape.addLineSegment(lineRH);//add dummy line - pY = world.mapY(toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_TOP)); - if(ymin < pY) - dispY = pY + 20 * currentZoomLevel*yMagFactor; - else - dispY = ymin + 20 * currentZoomLevel*yMagFactor; - for (double i = NsharpConstants.ICING_RELATIVE_HUMIDITY_LEFT; i <= NsharpConstants.ICING_RELATIVE_HUMIDITY_RIGHT; i= i+NsharpConstants.ICING_RELATIVE_HUMIDITY_INC) { - // temperature/humidity vertical lines - double [][] lines = {{world.mapX(i), iceYOrig},{world.mapX(i), iceYEnd}}; - linesNumbersShape.addLineSegment(lines); - //RH label - s = NsharpConstants.pressFormat.format(i); - - double [] lblXy = {world.mapX(i), dispY}; - RHLabelShape.addLabel(s, lblXy); + // RHLabel + // double [] lblRhXy = {iceXOrig+ iceWidth/2, iceYOrig-45}; + // RHLabelShape.addLabel("*****ICING Display*****", lblRhXy); + double[] lblRhXy1 = { iceXOrig + iceWidth / 2, + iceYOrig - 35 * yMagFactor }; + RHLabelShape.addLabel("*****ICING Display***** RELATIVE HUMIDITY", + lblRhXy1); + double[][] lineRH = { { 0, 0 }, { 0, 0 } }; + RHLabelShape.addLineSegment(lineRH);// add dummy line + pY = world.mapY(toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_TOP)); + if (ymin < pY) + dispY = pY + 20 * currentZoomLevel * yMagFactor; + else + dispY = ymin + 20 * currentZoomLevel * yMagFactor; + for (double i = NsharpConstants.ICING_RELATIVE_HUMIDITY_LEFT; i <= NsharpConstants.ICING_RELATIVE_HUMIDITY_RIGHT; i = i + + NsharpConstants.ICING_RELATIVE_HUMIDITY_INC) { + // temperature/humidity vertical lines + double[][] lines = { { world.mapX(i), iceYOrig }, + { world.mapX(i), iceYEnd } }; + linesNumbersShape.addLineSegment(lines); + // RH label + s = NsharpConstants.pressFormat.format(i); + + double[] lblXy = { world.mapX(i), dispY }; + RHLabelShape.addLabel(s, lblXy); } - //temperature label - double [] lblTXy = {iceXOrig+ iceWidth/2, iceYEnd+20*yMagFactor}; + // temperature label + double[] lblTXy = { iceXOrig + iceWidth / 2, iceYEnd + 20 * yMagFactor }; tempLabelShape.addLabel("TEMPERATURE (C)", lblTXy); - double [][] lineT = {{0,0},{0,0}}; - tempLabelShape.addLineSegment(lineT);//add dummy line - //set world based on pressure/twmp - world.setWorldCoordinates(NsharpConstants.ICING_TEMPERATURE_LEFT, toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_TOP), - NsharpConstants.ICING_TEMPERATURE_RIGHT, toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_BOTTOM)); - pY = world.mapY(toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_BOTTOM)); - if(ymax > pY) - dispY = pY - 10 * currentZoomLevel*yMagFactor; - else - dispY = ymax - 10 * currentZoomLevel*yMagFactor; - for (double i = NsharpConstants.ICING_TEMPERATURE_LEFT; i <= NsharpConstants.ICING_TEMPERATURE_RIGHT; i= i+NsharpConstants.ICING_TEMPERATURE_INC) { - // temperature label - s = NsharpConstants.pressFormat.format(i); - - double [] lblXy = {world.mapX(i),dispY};// iceYEnd+10}; - tempLabelShape.addLabel(s, lblXy); + double[][] lineT = { { 0, 0 }, { 0, 0 } }; + tempLabelShape.addLineSegment(lineT);// add dummy line + // set world based on pressure/twmp + world.setWorldCoordinates(NsharpConstants.ICING_TEMPERATURE_LEFT, + toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_TOP), + NsharpConstants.ICING_TEMPERATURE_RIGHT, + toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_BOTTOM)); + pY = world + .mapY(toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_BOTTOM)); + if (ymax > pY) + dispY = pY - 10 * currentZoomLevel * yMagFactor; + else + dispY = ymax - 10 * currentZoomLevel * yMagFactor; + for (double i = NsharpConstants.ICING_TEMPERATURE_LEFT; i <= NsharpConstants.ICING_TEMPERATURE_RIGHT; i = i + + NsharpConstants.ICING_TEMPERATURE_INC) { + // temperature label + s = NsharpConstants.pressFormat.format(i); + + double[] lblXy = { world.mapX(i), dispY };// iceYEnd+10}; + tempLabelShape.addLabel(s, lblXy); } - //EPI label - double [] lblEPIXy = {iceXOrig+ iceWidth/2, iceYEnd+35*yMagFactor}; - EPILabelShape.addLabel("EQUIVALENT POTENTIAL INSTABILITY x 1E-3 K/m", lblEPIXy); - double [][] lineE = {{0,0},{0,0}}; - EPILabelShape.addLineSegment(lineE);//add dummy line + // EPI label + double[] lblEPIXy = { iceXOrig + iceWidth / 2, + iceYEnd + 35 * yMagFactor }; + EPILabelShape.addLabel("EQUIVALENT POTENTIAL INSTABILITY x 1E-3 K/m", + lblEPIXy); + double[][] lineE = { { 0, 0 }, { 0, 0 } }; + EPILabelShape.addLineSegment(lineE);// add dummy line linesNumbersShape.compile(); RHLabelShape.compile(); tempLabelShape.compile(); EPILabelShape.compile(); - } - @Override - public synchronized void initInternal(IGraphicsTarget target) { - // TODO Auto-generated method stub - super.initInternal(target); - createAllShapes(); - } + } - @Override - protected void paintInternal(IGraphicsTarget target, - PaintProperties paintProps) throws VizException { - // TODO Auto-generated method stub - //super.paintInternal(target, paintProps); - target.setupClippingPlane(pe); - target.drawRect(pe, NsharpConstants.backgroundColor, 1.0f, 1.0f); - target.clearClippingPlane(); - double zoomLevel = paintProps.getZoomLevel(); - if(zoomLevel > 1.0f) - zoomLevel = 1.0f; - if(zoomLevel != currentZoomLevel) - { - currentZoomLevel = zoomLevel; - if(linesNumbersShape!= null){ - linesNumbersShape.dispose(); - } - if(RHLabelShape!= null){ - RHLabelShape.dispose(); - } - if(tempLabelShape!= null){ - tempLabelShape.dispose(); - } - if(EPILabelShape!= null){ - EPILabelShape.dispose(); - } - createAllShapes(); - } - this.smallFont.setSmoothing(false); - this.smallFont.setScaleFont(false); - target.drawWireframeShape(linesNumbersShape, NsharpConstants.pressureColor, 1, LineStyle.SOLID,smallFont); - HashMap lpMap = ((NsharpSkewTPaneDescriptor)desc).getSkewtResource().getLinePropertyMap(); - if(lpMap!=null){ - NsharpLineProperty lp =lpMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_ICING_RH]); - target.drawWireframeShape(RHLabelShape, lp.getLineColor(), 1, LineStyle.SOLID,smallFont); - lp =lpMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_ICING_TEMP]); - target.drawWireframeShape(tempLabelShape,lp.getLineColor(), 1, LineStyle.SOLID,smallFont); - lp =lpMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_ICING_EPI]); - target.drawWireframeShape(EPILabelShape, lp.getLineColor(), 1, LineStyle.SOLID,smallFont); - } - else { - target.drawWireframeShape(RHLabelShape, NsharpConstants.color_green, 1, LineStyle.SOLID,smallFont); - target.drawWireframeShape(tempLabelShape, NsharpConstants.color_red, 1, LineStyle.SOLID,smallFont); - target.drawWireframeShape(EPILabelShape, NsharpConstants.color_violet_red, 1, LineStyle.SOLID,smallFont); - } - - } - @Override - public void disposeInternal() { - // TODO Auto-generated method stub - super.disposeInternal(); - if(linesNumbersShape!= null){ - linesNumbersShape.dispose(); - } - if(RHLabelShape!= null){ - RHLabelShape.dispose(); - } - if(tempLabelShape!= null){ - tempLabelShape.dispose(); - } - if(EPILabelShape!= null){ - EPILabelShape.dispose(); - } - } - @Override - public double getViewableMaxPressure(){ - IExtent ext = desc.getRenderableDisplay().getExtent(); - double ymax = ext.getMaxY(); - double xmin = ext.getMinX(); - world.setWorldCoordinates(NsharpConstants.ICING_RELATIVE_HUMIDITY_LEFT, toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_TOP), - NsharpConstants.ICING_RELATIVE_HUMIDITY_RIGHT, toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_BOTTOM)); - //Coordinate c = world.unMap(xmin, ymax); - double viewablePmax = reverseLogScale(world.unMap(xmin, ymax).y); + @Override + public synchronized void initInternal(IGraphicsTarget target) { + // TODO Auto-generated method stub + super.initInternal(target); + createAllShapes(); + } + + @Override + protected void paintInternal(IGraphicsTarget target, + PaintProperties paintProps) throws VizException { + // TODO Auto-generated method stub + // super.paintInternal(target, paintProps); + target.setupClippingPlane(pe); + target.drawRect(pe, NsharpConstants.backgroundColor, 1.0f, 1.0f); + target.clearClippingPlane(); + double zoomLevel = paintProps.getZoomLevel(); + if (zoomLevel > 1.0f) + zoomLevel = 1.0f; + if (zoomLevel != currentZoomLevel) { + currentZoomLevel = zoomLevel; + if (linesNumbersShape != null) { + linesNumbersShape.dispose(); + } + if (RHLabelShape != null) { + RHLabelShape.dispose(); + } + if (tempLabelShape != null) { + tempLabelShape.dispose(); + } + if (EPILabelShape != null) { + EPILabelShape.dispose(); + } + createAllShapes(); + } + this.smallFont.setSmoothing(false); + this.smallFont.setScaleFont(false); + target.drawWireframeShape(linesNumbersShape, + NsharpConstants.pressureColor, 1, LineStyle.SOLID, smallFont); + HashMap lpMap = ((NsharpSkewTPaneDescriptor) desc) + .getSkewtResource().getLinePropertyMap(); + if (lpMap != null) { + NsharpLineProperty lp = lpMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_ICING_RH]); + target.drawWireframeShape(RHLabelShape, lp.getLineColor(), 1, + LineStyle.SOLID, smallFont); + lp = lpMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_ICING_TEMP]); + target.drawWireframeShape(tempLabelShape, lp.getLineColor(), 1, + LineStyle.SOLID, smallFont); + lp = lpMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_ICING_EPI]); + target.drawWireframeShape(EPILabelShape, lp.getLineColor(), 1, + LineStyle.SOLID, smallFont); + } else { + target.drawWireframeShape(RHLabelShape, + NsharpConstants.color_green, 1, LineStyle.SOLID, smallFont); + target.drawWireframeShape(tempLabelShape, + NsharpConstants.color_red, 1, LineStyle.SOLID, smallFont); + target.drawWireframeShape(EPILabelShape, + NsharpConstants.color_violet_red, 1, LineStyle.SOLID, + smallFont); + } + + } + + @Override + public void disposeInternal() { + // TODO Auto-generated method stub + super.disposeInternal(); + if (linesNumbersShape != null) { + linesNumbersShape.dispose(); + } + if (RHLabelShape != null) { + RHLabelShape.dispose(); + } + if (tempLabelShape != null) { + tempLabelShape.dispose(); + } + if (EPILabelShape != null) { + EPILabelShape.dispose(); + } + } + + @Override + public double getViewableMaxPressure() { + IExtent ext = desc.getRenderableDisplay().getExtent(); + double ymax = ext.getMaxY(); + double xmin = ext.getMinX(); + world.setWorldCoordinates(NsharpConstants.ICING_RELATIVE_HUMIDITY_LEFT, + toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_TOP), + NsharpConstants.ICING_RELATIVE_HUMIDITY_RIGHT, + toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_BOTTOM)); + // Coordinate c = world.unMap(xmin, ymax); + double viewablePmax = reverseLogScale(world.unMap(xmin, ymax).y); return viewablePmax; } + @Override - public double getViewableMinPressure(){ - IExtent ext = desc.getRenderableDisplay().getExtent(); - double ymin = ext.getMinY(); - double xmin = ext.getMinX(); - world.setWorldCoordinates(NsharpConstants.ICING_RELATIVE_HUMIDITY_LEFT, toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_TOP), - NsharpConstants.ICING_RELATIVE_HUMIDITY_RIGHT, toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_BOTTOM)); + public double getViewableMinPressure() { + IExtent ext = desc.getRenderableDisplay().getExtent(); + double ymin = ext.getMinY(); + double xmin = ext.getMinX(); + world.setWorldCoordinates(NsharpConstants.ICING_RELATIVE_HUMIDITY_LEFT, + toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_TOP), + NsharpConstants.ICING_RELATIVE_HUMIDITY_RIGHT, + toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_BOTTOM)); double viewablePmin = reverseLogScale(world.unMap(xmin, ymin).y); return viewablePmin; } + @Override - public double getYPositionRatioByPressure(double pressure){ - double pY= world.mapY(toLogScale(pressure)); - IExtent ext = desc.getRenderableDisplay().getExtent(); - double ymin = ext.getMinY(); - double ymax = ext.getMaxY(); - double ratio = (pY-ymin) / (ymax-ymin); - //System.out.println("ratio="+ratio+ "rtP="+rtP+" maxP="+maxP+" minP="+minP); + public double getYPositionRatioByPressure(double pressure) { + double pY = world.mapY(toLogScale(pressure)); + IExtent ext = desc.getRenderableDisplay().getExtent(); + double ymin = ext.getMinY(); + double ymax = ext.getMaxY(); + double ratio = (pY - ymin) / (ymax - ymin); + // System.out.println("ratio="+ratio+ + // "rtP="+rtP+" maxP="+maxP+" minP="+minP); return ratio; } + @Override - public ViewablePressureContainer getViewablePressureLinesContainer(){ - ViewablePressureContainer vpc = new ViewablePressureContainer(); - IExtent ext = desc.getRenderableDisplay().getExtent(); - float ymax = (float)ext.getMaxY(); - float ymin =(float) ext.getMinY(); - double vPmax = getViewableMaxPressure(); - double vPmin = getViewableMinPressure(); - vpc.maxVIewablePressure = (float)vPmax; - vpc.minVIewablePressure = (float)vPmin; - for (float pressure = 300; pressure <= 1000;pressure= pressure+100) { - if(pressure >= vPmin &&pressure <= vPmax){ - double pY= world.mapY(toLogScale(pressure)); - float ratio = (float) (pY-ymin) / (ymax-ymin); - vpc.pyMap.put(pressure, ratio); - //System.out.println("Icing press="+pressure+" ratio="+ratio+ " pY="+pY+" maxPy="+ymax+" minPy="+ymin); - } - } - return vpc; + public ViewablePressureContainer getViewablePressureLinesContainer() { + ViewablePressureContainer vpc = new ViewablePressureContainer(); + IExtent ext = desc.getRenderableDisplay().getExtent(); + float ymax = (float) ext.getMaxY(); + float ymin = (float) ext.getMinY(); + double vPmax = getViewableMaxPressure(); + double vPmin = getViewableMinPressure(); + vpc.maxVIewablePressure = (float) vPmax; + vpc.minVIewablePressure = (float) vPmin; + for (float pressure = 300; pressure <= 1000; pressure = pressure + 100) { + if (pressure >= vPmin && pressure <= vPmax) { + double pY = world.mapY(toLogScale(pressure)); + float ratio = (float) (pY - ymin) / (ymax - ymin); + vpc.pyMap.put(pressure, ratio); + // System.out.println("Icing press="+pressure+" ratio="+ratio+ + // " pY="+pY+" maxPy="+ymax+" minPy="+ymin); + } + } + return vpc; } + @Override - public ViewablePressureContainer getViewablePressureContainer(List soundingLys){ - world.setWorldCoordinates(NsharpConstants.ICING_RELATIVE_HUMIDITY_LEFT, toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_TOP), - NsharpConstants.ICING_RELATIVE_HUMIDITY_RIGHT, toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_BOTTOM)); - ViewablePressureContainer vpc = new ViewablePressureContainer(); - IExtent ext = desc.getRenderableDisplay().getExtent(); - float ymax = (float)ext.getMaxY(); - float ymin =(float) ext.getMinY(); - double vPmax = getViewableMaxPressure(); - double vPmin = getViewableMinPressure(); - vpc.maxVIewablePressure = (float)vPmax; - vpc.minVIewablePressure = (float)vPmin; - for(NcSoundingLayer ly: soundingLys){ - float pressure = ly.getPressure(); - if(pressure >= vPmin &&pressure <= vPmax){ - double pY= world.mapY(toLogScale(pressure)); - float ratio = (float) (pY-ymin) / (ymax-ymin); - vpc.pyMap.put(pressure, ratio); - //System.out.println("Icing press="+pressure+" ratio="+ratio+ " pY="+pY+" maxPy="+ymax+" minPy="+ymin); - } - } - return vpc; + public ViewablePressureContainer getViewablePressureContainer( + List soundingLys) { + world.setWorldCoordinates(NsharpConstants.ICING_RELATIVE_HUMIDITY_LEFT, + toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_TOP), + NsharpConstants.ICING_RELATIVE_HUMIDITY_RIGHT, + toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_BOTTOM)); + ViewablePressureContainer vpc = new ViewablePressureContainer(); + IExtent ext = desc.getRenderableDisplay().getExtent(); + float ymax = (float) ext.getMaxY(); + float ymin = (float) ext.getMinY(); + double vPmax = getViewableMaxPressure(); + double vPmin = getViewableMinPressure(); + vpc.maxVIewablePressure = (float) vPmax; + vpc.minVIewablePressure = (float) vPmin; + for (NcSoundingLayer ly : soundingLys) { + float pressure = ly.getPressure(); + if (pressure >= vPmin && pressure <= vPmax) { + double pY = world.mapY(toLogScale(pressure)); + float ratio = (float) (pY - ymin) / (ymax - ymin); + vpc.pyMap.put(pressure, ratio); + // System.out.println("Icing press="+pressure+" ratio="+ratio+ + // " pY="+pY+" maxPy="+ymax+" minPy="+ymin); + } + } + return vpc; } + /* * Called from handleResize() in skewTPaneResource only */ - public void handleResize(IExtent ext){ - if(target==null) - return; - //IExtent ext = desc.getRenderableDisplay().getExtent(); - //ext.reset(); - float prevHeight = paneHeight; - float prevWidth = iceWidth; - paneHeight = (int) (ext.getHeight()); - yMagFactor = yMagFactor*((float)paneHeight/prevHeight); - labelSpace = defaultLabelSpace * yMagFactor; - iceXOrig=(int) (ext.getMinX()); - iceYOrig=(int) (ext.getMinY())+ (int)labelSpace; - iceXEnd=iceXOrig+(int) (ext.getWidth()); - iceYEnd=iceYOrig+(int) (ext.getHeight()) - 2*(int)labelSpace; - iceWidth = (int) (ext.getWidth()); - xMagFactor = xMagFactor* ((float)iceWidth/prevWidth); - this.rectangle = new Rectangle(iceXOrig, iceYOrig, - iceWidth, (int) ext.getHeight()-2*(int)labelSpace); + public void handleResize(IExtent ext) { + if (target == null) + return; + // IExtent ext = desc.getRenderableDisplay().getExtent(); + // ext.reset(); + float prevHeight = paneHeight; + float prevWidth = iceWidth; + paneHeight = (int) (ext.getHeight()); + yMagFactor = yMagFactor * ((float) paneHeight / prevHeight); + labelSpace = defaultLabelSpace * yMagFactor; + iceXOrig = (int) (ext.getMinX()); + iceYOrig = (int) (ext.getMinY()) + (int) labelSpace; + iceXEnd = iceXOrig + (int) (ext.getWidth()); + iceYEnd = iceYOrig + (int) (ext.getHeight()) - 2 * (int) labelSpace; + iceWidth = (int) (ext.getWidth()); + xMagFactor = xMagFactor * ((float) iceWidth / prevWidth); + this.rectangle = new Rectangle(iceXOrig, iceYOrig, iceWidth, + (int) ext.getHeight() - 2 * (int) labelSpace); pe = new PixelExtent(this.rectangle); - //desc.setNewPe(pe); + // desc.setNewPe(pe); world = new WGraphics(this.rectangle); - - if(linesNumbersShape!= null){ - linesNumbersShape.dispose(); - } - if(RHLabelShape!= null){ - RHLabelShape.dispose(); - } - if(tempLabelShape!= null){ - tempLabelShape.dispose(); - } - if(EPILabelShape!= null){ - EPILabelShape.dispose(); - } + + if (linesNumbersShape != null) { + linesNumbersShape.dispose(); + } + if (RHLabelShape != null) { + RHLabelShape.dispose(); + } + if (tempLabelShape != null) { + tempLabelShape.dispose(); + } + if (EPILabelShape != null) { + EPILabelShape.dispose(); + } createAllShapes(); } - public void handleZooming(){ - if(linesNumbersShape!= null){ - linesNumbersShape.dispose(); - } - if(RHLabelShape!= null){ - RHLabelShape.dispose(); - } - if(tempLabelShape!= null){ - tempLabelShape.dispose(); - } - if(EPILabelShape!= null){ - EPILabelShape.dispose(); - } + + public void handleZooming() { + if (linesNumbersShape != null) { + linesNumbersShape.dispose(); + } + if (RHLabelShape != null) { + RHLabelShape.dispose(); + } + if (tempLabelShape != null) { + tempLabelShape.dispose(); + } + if (EPILabelShape != null) { + EPILabelShape.dispose(); + } createAllShapes(); } - public double getWindBarbXPosition(){ - IExtent ext = desc.getRenderableDisplay().getExtent(); - double xmax = ext.getMaxX(); //Extent's viewable envelope min x and y + + public double getWindBarbXPosition() { + IExtent ext = desc.getRenderableDisplay().getExtent(); + double xmax = ext.getMaxX(); // Extent's viewable envelope min x and y double ymax = ext.getMaxY(); - double pX= world.mapX( NsharpConstants.ICING_RELATIVE_HUMIDITY_RIGHT); - if(pX < xmax) - xmax = pX; - - double windBarbSizfactor = graphConfigProperty.getWindBarbSize()/2.2f; - if(windBarbSizfactor < 1) - windBarbSizfactor=1; - double dispX = xmax - 50 * currentZoomLevel * xMagFactor* windBarbSizfactor; - - Coordinate cumap = world.unMap(dispX,ymax); - + double pX = world.mapX(NsharpConstants.ICING_RELATIVE_HUMIDITY_RIGHT); + if (pX < xmax) + xmax = pX; + + double windBarbSizfactor = graphConfigProperty.getWindBarbSize() / 2.2f; + if (windBarbSizfactor < 1) + windBarbSizfactor = 1; + double dispX = xmax - 50 * currentZoomLevel * xMagFactor + * windBarbSizfactor; + + Coordinate cumap = world.unMap(dispX, ymax); + return cumap.x; - } + } } diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/NsharpEditor.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/NsharpEditor.java index 3799824a9f..f8a020eab7 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/NsharpEditor.java +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/NsharpEditor.java @@ -1,4 +1,5 @@ package gov.noaa.nws.ncep.ui.nsharp.display; + /** * * gov.noaa.nws.ncep.ui.nsharp.skewt.NsharpEditor @@ -79,98 +80,176 @@ import com.raytheon.viz.ui.panes.PaneManager; import com.raytheon.viz.ui.panes.VizDisplayPane; import com.vividsolutions.jts.geom.Coordinate; -public class NsharpEditor extends AbstractEditor implements IRenderableDisplayChangedListener { - private boolean restarting= false; - private final int DISPLAY_SKEWT =0; // always set it as first display, dont change it - private int DISPLAY_WITO; - private int DISPLAY_INSET; - private int DISPLAY_HODO; - private int DISPLAY_TIMESTN; - private int DISPLAY_DATA; - private int DISPLAY_SPC_GRAPHS; - private int DISPLAY_FUTURE; - private int DISPLAY_TOTAL; +public class NsharpEditor extends AbstractEditor implements + IRenderableDisplayChangedListener { + private boolean restarting = false; + + private static int DISPLAY_Head = 0; + + private int DISPLAY_SKEWT; + + private int DISPLAY_WITO; + + private int DISPLAY_INSET; + + private int DISPLAY_HODO; + + private int DISPLAY_TIMESTN; + + private int DISPLAY_DATA; + + private int DISPLAY_SPC_GRAPHS; + + private int DISPLAY_FUTURE; + + private int DISPLAY_TOTAL; + public static final String EDITOR_ID = "gov.noaa.nws.ncep.ui.nsharp.display.NsharpEditor"; -// private int editorNum=0; - private NsharpResourceHandler rscHandler; + + // private int editorNum=0; + private NsharpResourceHandler rscHandler; + private int baseWidth; + private int baseHeight; + private double skewTHeightHintRatio; + private double skewTWidthHintRatio; + private double witoHeightHintRatio; + private double witoWidthHintRatio; + private double hodoHeightHintRatio; + private double hodoWidthHintRatio; + private double insetHeightHintRatio; + private double insetWidthHintRatio; + private double timeStnHeightHintRatio; + private double timeStnWidthHintRatio; + + private double futureHeightHintRatio; // d2dlite + + private double futureWidthHintRatio; // d2dlite + private double dataHeightHintRatio; + private double dataWidthHintRatio; + private double leftGroupWidthRatio; - private double leftTopGroupHeightRatio;//, rightTopGroupHeightRatio; + + private double leftTopGroupHeightRatio; + private double topGroupHeightRatio, botGroupHeightRatio; + private int skewTHeightHint; + private int skewTWidthHint; + private int witoHeightHint; + private int witoWidthHint; + private int hodoHeightHint; + private int hodoWidthHint; + private int insetHeightHint; + private int insetWidthHint; + private int timeStnHeightHint; + private int timeStnWidthHint; + private int dataHeightHint; + private int dataWidthHint; + private int spcHeightHint; + private int spcWidthHint; + private int futureHeightHint; + private int futureWidthHint; - private String paneConfigurationName; - private IRenderableDisplay[] displayArray; + + private String paneConfigurationName; + + private IRenderableDisplay[] displayArray; + private ResizeListener resizeLsner; - public NsharpResourceHandler getRscHandler() { - return rscHandler; - } - //Note: nsharpComp used to store composite for each pane. + + public NsharpResourceHandler getRscHandler() { + return rscHandler; + } + + // Note: nsharpComp used to store composite for each pane. private Composite[] nsharpComp;// = new Composite[DISPLAY_TOTAL]; - private GridData leftGpGd,topGpGd, botGpGd; + + private GridData leftGpGd, topGpGd, botGpGd; + private GridData rightGpGd; - private GridData rightTopGpGd,leftTopGpGd, leftBotGpGd; - private Composite parantComp, baseComposite; - private Group rightTopGp=null, leftTopGp=null, leftBotGp=null, leftGp, rightGp, topGp, botGp; - /** input managers */ + + private GridData rightTopGpGd, leftTopGpGd, leftBotGpGd; + + private Composite parantComp, baseComposite; + + private Group rightTopGp = null, leftTopGp = null, leftBotGp = null, + leftGp, rightGp, topGp, botGp; + + /** input managers */ protected InputManager skewtInputManager; - //protected InputManager witoInputManager; + + // protected InputManager witoInputManager; protected InputManager hodoInputManager; + protected InputManager timeStnInputManager; + protected InputManager dataInputManager; + protected InputManager insetInputManager; + protected InputManager spcGraphsInputManager; + /** The activated context, else null if not activated. */ - //protected IContextActivation contextActivation; + // protected IContextActivation contextActivation; private NsharpSkewTPaneMouseHandler skewtPaneMouseHandler = null; - //private NsharpAbstractMouseHandler witoPaneMouseHandler = null; + + // private NsharpAbstractMouseHandler witoPaneMouseHandler = null; private NsharpHodoPaneMouseHandler hodoPaneMouseHandler = null; + private NsharpTimeStnPaneMouseHandler timeStnPaneMouseHandler = null; + private NsharpDataPaneMouseHandler dataPaneMouseHandler = null; + private NsharpAbstractMouseHandler insetPaneMouseHandler = null; + private NsharpAbstractMouseHandler spcGraphsPaneMouseHandler = null; - - protected VizDisplayPane displayPane[];//= new VizDisplayPane[DISPLAY_TOTAL]; + + protected VizDisplayPane displayPane[];// = new + // VizDisplayPane[DISPLAY_TOTAL]; + protected VizDisplayPane selectedPane; + public static NsharpEditor getActiveNsharpEditor() { IEditorPart ep = EditorUtil.getActiveEditor(); if (ep instanceof NsharpEditor) { - //System.out.println("getActiveNsharpEditor return ep from EditorUtil.getActiveEditor()"); + // System.out.println("getActiveNsharpEditor return ep from EditorUtil.getActiveEditor()"); return (NsharpEditor) ep; } - + // It might be desirable to stop here so that we only have an "active" // editor if it really is active. - if(PlatformUI.getWorkbench()==null || PlatformUI.getWorkbench().getActiveWorkbenchWindow() ==null ) - return null; + if (PlatformUI.getWorkbench() == null + || PlatformUI.getWorkbench().getActiveWorkbenchWindow() == null) + return null; IWorkbenchPage activePage = PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getActivePage(); IEditorReference[] references = new IEditorReference[0]; @@ -181,12 +260,13 @@ public class NsharpEditor extends AbstractEditor implements IRenderableDisplayC for (IEditorReference ref : references) { ep = ref.getEditor(false); if (ep instanceof NsharpEditor) { - //System.out.println("getActiveNsharpEditor return ep from IEditorReference.getEditor"); + // System.out.println("getActiveNsharpEditor return ep from IEditorReference.getEditor"); return (NsharpEditor) ep; } } return null; - } + } + /* * (non-Javadoc) * @@ -196,143 +276,169 @@ public class NsharpEditor extends AbstractEditor implements IRenderableDisplayC */ @Override public void createPartControl(Composite comp) { - parantComp = comp; - if(baseComposite!= null) - baseComposite.dispose(); - baseComposite = new Composite(comp, SWT.NONE); - final GridLayout mainGL; + parantComp = comp; + if (baseComposite != null) + baseComposite.dispose(); + baseComposite = new Composite(comp, SWT.NONE); + final GridLayout mainGL; baseHeight = baseComposite.getSize().y; baseWidth = baseComposite.getSize().x; - //System.out.println("createPartControl...baseComposite w= " + baseWidth + " h= "+ baseHeight); - - //TBD for testing, hard code now - //paneCfgNum= NsharpConstants.PANE_CONFIGURATION_1; + // System.out.println("createPartControl...baseComposite w= " + + // baseWidth + " h= "+ baseHeight); + + // TBD for testing, hard code now + // paneCfgNum= NsharpConstants.PANE_CONFIGURATION_1; resizeLsner = new ResizeListener(paneConfigurationName); - baseComposite.addListener(SWT.Resize, resizeLsner); - if(paneConfigurationName.equals(NsharpConstants.PANE_DEF_CFG_2_STR)){ - mainGL = new GridLayout(2, false); - baseComposite.setLayout(mainGL); - mainGL.horizontalSpacing = 0; - mainGL.marginHeight = 0; - leftGroupWidthRatio =NsharpConstants.PANE_DEF_CFG_2_LEFT_GP_WIDTH_RATIO; - leftTopGroupHeightRatio = NsharpConstants.PANE_DEF_CFG_2_LEFT_TOP_GP_HEIGHT_RATIO; - //rightTopGroupHeightRatio = NsharpConstants.PANE_DEF_CFG_2_RIGHT_TOP_GP_HEIGHT_RATIO; - skewTHeightHintRatio=NsharpConstants.PANE_DEF_CFG_2_SKEWT_HEIGHT_RATIO; - skewTWidthHintRatio=NsharpConstants.PANE_DEF_CFG_2_SKEWT_WIDTH_RATIO; - witoHeightHintRatio=NsharpConstants.PANE_DEF_CFG_2_WITO_HEIGHT_RATIO; - witoWidthHintRatio=NsharpConstants.PANE_DEF_CFG_2_WITO_WIDTH_RATIO; - hodoHeightHintRatio=NsharpConstants.PANE_DEF_CFG_2_HODO_HEIGHT_RATIO; - hodoWidthHintRatio=NsharpConstants.PANE_DEF_CFG_2_HODO_WIDTH_RATIO; - insetHeightHintRatio=NsharpConstants.PANE_DEF_CFG_2_INSET_HEIGHT_RATIO; - insetWidthHintRatio=NsharpConstants.PANE_DEF_CFG_2_INSET_WIDTH_RATIO; - timeStnHeightHintRatio=NsharpConstants.PANE_DEF_CFG_2_TIMESTN_HEIGHT_RATIO; - timeStnWidthHintRatio=NsharpConstants.PANE_DEF_CFG_2_TIMESTN_WIDTH_RATIO; - dataHeightHintRatio=NsharpConstants.PANE_DEF_CFG_2_DATA_HEIGHT_RATIO; - dataWidthHintRatio=NsharpConstants.PANE_DEF_CFG_2_DATA_WIDTH_RATIO; - createDefConfig2( baseComposite) ; - } else if(paneConfigurationName.equals(NsharpConstants.PANE_DEF_CFG_1_STR)){ - mainGL = new GridLayout(2, false); - mainGL.horizontalSpacing = 0; - mainGL.marginHeight = 0; - baseComposite.setLayout(mainGL); - leftGroupWidthRatio =NsharpConstants.PANE_DEF_CFG_1_LEFT_GP_WIDTH_RATIO; - leftTopGroupHeightRatio = NsharpConstants.PANE_DEF_CFG_1_LEFT_TOP_GP_HEIGHT_RATIO; - //rightTopGroupHeightRatio = NsharpConstants.PANE_DEF_CFG_1_RIGHT_TOP_GP_HEIGHT_RATIO; - skewTHeightHintRatio=NsharpConstants.PANE_DEF_CFG_1_SKEWT_HEIGHT_RATIO; - skewTWidthHintRatio=NsharpConstants.PANE_DEF_CFG_1_SKEWT_WIDTH_RATIO; - witoHeightHintRatio=NsharpConstants.PANE_DEF_CFG_1_WITO_HEIGHT_RATIO; - witoWidthHintRatio=NsharpConstants.PANE_DEF_CFG_1_WITO_WIDTH_RATIO; - hodoHeightHintRatio=NsharpConstants.PANE_DEF_CFG_1_HODO_HEIGHT_RATIO; - hodoWidthHintRatio=NsharpConstants.PANE_DEF_CFG_1_HODO_WIDTH_RATIO; - insetHeightHintRatio=NsharpConstants.PANE_DEF_CFG_1_INSET_HEIGHT_RATIO; - insetWidthHintRatio=NsharpConstants.PANE_DEF_CFG_1_INSET_WIDTH_RATIO; - timeStnHeightHintRatio=NsharpConstants.PANE_DEF_CFG_1_TIMESTN_HEIGHT_RATIO; - timeStnWidthHintRatio=NsharpConstants.PANE_DEF_CFG_1_TIMESTN_WIDTH_RATIO; - dataHeightHintRatio=NsharpConstants.PANE_DEF_CFG_1_DATA_HEIGHT_RATIO; - dataWidthHintRatio=NsharpConstants.PANE_DEF_CFG_1_DATA_WIDTH_RATIO; - createDefConfig1( baseComposite) ; - } else if(paneConfigurationName.equals(NsharpConstants.PANE_SPCWS_CFG_STR)){ - mainGL = new GridLayout(1, true); - mainGL.horizontalSpacing = 0; - mainGL.marginHeight = 0; - baseComposite.setLayout(mainGL); - topGroupHeightRatio =NsharpConstants.PANE_SPCWS_CFG_TOP_GP_HEIGHT_RATIO; - botGroupHeightRatio = NsharpConstants.PANE_SPCWS_CFG_BOT_GP_HEIGHT_RATIO; - skewTHeightHintRatio=NsharpConstants.PANE_SPCWS_CFG_SKEWT_HEIGHT_RATIO; - skewTWidthHintRatio=NsharpConstants.PANE_SPCWS_CFG_SKEWT_WIDTH_RATIO; - witoHeightHintRatio=NsharpConstants.PANE_SPCWS_CFG_WITO_HEIGHT_RATIO; - witoWidthHintRatio=NsharpConstants.PANE_SPCWS_CFG_WITO_WIDTH_RATIO; - hodoHeightHintRatio=NsharpConstants.PANE_SPCWS_CFG_HODO_HEIGHT_RATIO; - hodoWidthHintRatio=NsharpConstants.PANE_SPCWS_CFG_HODO_WIDTH_RATIO; - insetHeightHintRatio=NsharpConstants.PANE_SPCWS_CFG_INSET_HEIGHT_RATIO; - insetWidthHintRatio=NsharpConstants.PANE_SPCWS_CFG_INSET_WIDTH_RATIO; - dataHeightHintRatio=NsharpConstants.PANE_SPCWS_CFG_DATA_HEIGHT_RATIO; - dataWidthHintRatio=NsharpConstants.PANE_SPCWS_CFG_DATA_WIDTH_RATIO; - createSPCWsConfig( baseComposite) ; - } else if(paneConfigurationName.equals(NsharpConstants.PANE_SIMPLE_D2D_CFG_STR)){ - mainGL = new GridLayout(1, true); - mainGL.horizontalSpacing = 0; - mainGL.marginHeight = 0; - baseComposite.setLayout(mainGL); - topGroupHeightRatio =NsharpConstants.PANE_SIMPLE_D2D_CFG_TOP_GP_HEIGHT_RATIO; - botGroupHeightRatio = 1-topGroupHeightRatio; - skewTHeightHintRatio=NsharpConstants.PANE_SIMPLE_D2D_CFG_SKEWT_HEIGHT_RATIO; - skewTWidthHintRatio=NsharpConstants.PANE_SIMPLE_D2D_CFG_SKEWT_WIDTH_RATIO; - timeStnHeightHintRatio=NsharpConstants.PANE_SIMPLE_D2D_CFG_TIMESTN_HEIGHT_RATIO; - timeStnWidthHintRatio=NsharpConstants.PANE_SIMPLE_D2D_CFG_TIMESTN_WIDTH_RATIO; - hodoHeightHintRatio=NsharpConstants.PANE_SIMPLE_D2D_CFG_HODO_HEIGHT_RATIO; - hodoWidthHintRatio=NsharpConstants.PANE_SIMPLE_D2D_CFG_HODO_WIDTH_RATIO; - dataHeightHintRatio=NsharpConstants.PANE_SIMPLE_D2D_CFG_DATA_HEIGHT_RATIO; - dataWidthHintRatio=NsharpConstants.PANE_SIMPLE_D2D_CFG_DATA_WIDTH_RATIO; - createSimpleD2DConfig(baseComposite); - } - skewtInputManager = new InputManager(this); - //witoInputManager = new InputManager(this); - timeStnInputManager = new InputManager(this); - hodoInputManager = new InputManager(this); - dataInputManager = new InputManager(this); - insetInputManager = new InputManager(this); - spcGraphsInputManager = new InputManager(this); - try { - for(int i=0; i < displayPane.length; i++){ - if (displayPane[i] == null && nsharpComp [i]!=null) { - displayPane[i] = new VizDisplayPane(this, nsharpComp[i], - displaysToLoad[i]); - - displayPane[i].setRenderableDisplay(displaysToLoad[i]); - } - } - registerHandlers(); - //set default selected pane to skewT pane - selectedPane = displayPane[DISPLAY_SKEWT]; - for(int i=0; i < displayPane.length; i++){ - if(displayPane[i] != null) - displayPane[i].addListener( SWT.MouseEnter, new PaneMouseListener(i)); - } - } - catch (Exception e) { + baseComposite.addListener(SWT.Resize, resizeLsner); + if (paneConfigurationName.equals(NsharpConstants.PANE_DEF_CFG_2_STR)) { + mainGL = new GridLayout(2, false); + baseComposite.setLayout(mainGL); + mainGL.horizontalSpacing = 0; + mainGL.marginHeight = 0; + leftGroupWidthRatio = NsharpConstants.PANE_DEF_CFG_2_LEFT_GP_WIDTH_RATIO; + leftTopGroupHeightRatio = NsharpConstants.PANE_DEF_CFG_2_LEFT_TOP_GP_HEIGHT_RATIO; + // rightTopGroupHeightRatio = + // NsharpConstants.PANE_DEF_CFG_2_RIGHT_TOP_GP_HEIGHT_RATIO; + skewTHeightHintRatio = NsharpConstants.PANE_DEF_CFG_2_SKEWT_HEIGHT_RATIO; + skewTWidthHintRatio = NsharpConstants.PANE_DEF_CFG_2_SKEWT_WIDTH_RATIO; + witoHeightHintRatio = NsharpConstants.PANE_DEF_CFG_2_WITO_HEIGHT_RATIO; + witoWidthHintRatio = NsharpConstants.PANE_DEF_CFG_2_WITO_WIDTH_RATIO; + hodoHeightHintRatio = NsharpConstants.PANE_DEF_CFG_2_HODO_HEIGHT_RATIO; + hodoWidthHintRatio = NsharpConstants.PANE_DEF_CFG_2_HODO_WIDTH_RATIO; + insetHeightHintRatio = NsharpConstants.PANE_DEF_CFG_2_INSET_HEIGHT_RATIO; + insetWidthHintRatio = NsharpConstants.PANE_DEF_CFG_2_INSET_WIDTH_RATIO; + timeStnHeightHintRatio = NsharpConstants.PANE_DEF_CFG_2_TIMESTN_HEIGHT_RATIO; + timeStnWidthHintRatio = NsharpConstants.PANE_DEF_CFG_2_TIMESTN_WIDTH_RATIO; + dataHeightHintRatio = NsharpConstants.PANE_DEF_CFG_2_DATA_HEIGHT_RATIO; + dataWidthHintRatio = NsharpConstants.PANE_DEF_CFG_2_DATA_WIDTH_RATIO; + createDefConfig2(baseComposite); + } else if (paneConfigurationName + .equals(NsharpConstants.PANE_DEF_CFG_1_STR)) { + mainGL = new GridLayout(2, false); + mainGL.horizontalSpacing = 0; + mainGL.marginHeight = 0; + baseComposite.setLayout(mainGL); + leftGroupWidthRatio = NsharpConstants.PANE_DEF_CFG_1_LEFT_GP_WIDTH_RATIO; + leftTopGroupHeightRatio = NsharpConstants.PANE_DEF_CFG_1_LEFT_TOP_GP_HEIGHT_RATIO; + // rightTopGroupHeightRatio = + // NsharpConstants.PANE_DEF_CFG_1_RIGHT_TOP_GP_HEIGHT_RATIO; + skewTHeightHintRatio = NsharpConstants.PANE_DEF_CFG_1_SKEWT_HEIGHT_RATIO; + skewTWidthHintRatio = NsharpConstants.PANE_DEF_CFG_1_SKEWT_WIDTH_RATIO; + witoHeightHintRatio = NsharpConstants.PANE_DEF_CFG_1_WITO_HEIGHT_RATIO; + witoWidthHintRatio = NsharpConstants.PANE_DEF_CFG_1_WITO_WIDTH_RATIO; + hodoHeightHintRatio = NsharpConstants.PANE_DEF_CFG_1_HODO_HEIGHT_RATIO; + hodoWidthHintRatio = NsharpConstants.PANE_DEF_CFG_1_HODO_WIDTH_RATIO; + insetHeightHintRatio = NsharpConstants.PANE_DEF_CFG_1_INSET_HEIGHT_RATIO; + insetWidthHintRatio = NsharpConstants.PANE_DEF_CFG_1_INSET_WIDTH_RATIO; + timeStnHeightHintRatio = NsharpConstants.PANE_DEF_CFG_1_TIMESTN_HEIGHT_RATIO; + timeStnWidthHintRatio = NsharpConstants.PANE_DEF_CFG_1_TIMESTN_WIDTH_RATIO; + dataHeightHintRatio = NsharpConstants.PANE_DEF_CFG_1_DATA_HEIGHT_RATIO; + dataWidthHintRatio = NsharpConstants.PANE_DEF_CFG_1_DATA_WIDTH_RATIO; + createDefConfig1(baseComposite); + } else if (paneConfigurationName + .equals(NsharpConstants.PANE_SPCWS_CFG_STR)) { + mainGL = new GridLayout(1, true); + mainGL.horizontalSpacing = 0; + mainGL.marginHeight = 0; + baseComposite.setLayout(mainGL); + topGroupHeightRatio = NsharpConstants.PANE_SPCWS_CFG_TOP_GP_HEIGHT_RATIO; + botGroupHeightRatio = NsharpConstants.PANE_SPCWS_CFG_BOT_GP_HEIGHT_RATIO; + skewTHeightHintRatio = NsharpConstants.PANE_SPCWS_CFG_SKEWT_HEIGHT_RATIO; + skewTWidthHintRatio = NsharpConstants.PANE_SPCWS_CFG_SKEWT_WIDTH_RATIO; + witoHeightHintRatio = NsharpConstants.PANE_SPCWS_CFG_WITO_HEIGHT_RATIO; + witoWidthHintRatio = NsharpConstants.PANE_SPCWS_CFG_WITO_WIDTH_RATIO; + hodoHeightHintRatio = NsharpConstants.PANE_SPCWS_CFG_HODO_HEIGHT_RATIO; + hodoWidthHintRatio = NsharpConstants.PANE_SPCWS_CFG_HODO_WIDTH_RATIO; + insetHeightHintRatio = NsharpConstants.PANE_SPCWS_CFG_INSET_HEIGHT_RATIO; + insetWidthHintRatio = NsharpConstants.PANE_SPCWS_CFG_INSET_WIDTH_RATIO; + dataHeightHintRatio = NsharpConstants.PANE_SPCWS_CFG_DATA_HEIGHT_RATIO; + dataWidthHintRatio = NsharpConstants.PANE_SPCWS_CFG_DATA_WIDTH_RATIO; + createSPCWsConfig(baseComposite); + } else if (paneConfigurationName + .equals(NsharpConstants.PANE_SIMPLE_D2D_CFG_STR)) { + mainGL = new GridLayout(1, true); + mainGL.horizontalSpacing = 0; + mainGL.marginHeight = 0; + baseComposite.setLayout(mainGL); + topGroupHeightRatio = NsharpConstants.PANE_SIMPLE_D2D_CFG_TOP_GP_HEIGHT_RATIO; + botGroupHeightRatio = 1 - topGroupHeightRatio; + skewTHeightHintRatio = NsharpConstants.PANE_SIMPLE_D2D_CFG_SKEWT_HEIGHT_RATIO; + skewTWidthHintRatio = NsharpConstants.PANE_SIMPLE_D2D_CFG_SKEWT_WIDTH_RATIO; + timeStnHeightHintRatio = NsharpConstants.PANE_SIMPLE_D2D_CFG_TIMESTN_HEIGHT_RATIO; + timeStnWidthHintRatio = NsharpConstants.PANE_SIMPLE_D2D_CFG_TIMESTN_WIDTH_RATIO; + futureHeightHintRatio = NsharpConstants.PANE_SIMPLE_D2D_CFG_FUTURE_WIDTH_RATIO; + futureWidthHintRatio = NsharpConstants.PANE_SIMPLE_D2D_CFG_FUTURE_HEIGHT_RATIO; + hodoHeightHintRatio = NsharpConstants.PANE_SIMPLE_D2D_CFG_HODO_HEIGHT_RATIO; + hodoWidthHintRatio = NsharpConstants.PANE_SIMPLE_D2D_CFG_HODO_WIDTH_RATIO; + dataHeightHintRatio = NsharpConstants.PANE_SIMPLE_D2D_CFG_DATA_HEIGHT_RATIO; + dataWidthHintRatio = NsharpConstants.PANE_SIMPLE_D2D_CFG_DATA_WIDTH_RATIO; + createSimpleD2DConfig(baseComposite); + } // d2dlite start + else if (paneConfigurationName + .equals(NsharpConstants.PANE_LITE_D2D_CFG_STR)) { + mainGL = new GridLayout(1, true); + mainGL.horizontalSpacing = 0; + mainGL.marginHeight = 0; + baseComposite.setLayout(mainGL); + topGroupHeightRatio = 1; + botGroupHeightRatio = 0; + skewTHeightHintRatio = NsharpConstants.PANE_LITE_D2D_CFG_SKEWT_HEIGHT_RATIO; + skewTWidthHintRatio = NsharpConstants.PANE_LITE_D2D_CFG_SKEWT_WIDTH_RATIO; + hodoHeightHintRatio = NsharpConstants.PANE_LITE_D2D_CFG_HODO_HEIGHT_RATIO; + hodoWidthHintRatio = NsharpConstants.PANE_LITE_D2D_CFG_HODO_WIDTH_RATIO; + timeStnHeightHintRatio = NsharpConstants.PANE_LITE_D2D_CFG_TIMESTN_HEIGHT_RATIO; + timeStnWidthHintRatio = NsharpConstants.PANE_LITE_D2D_CFG_TIMESTN_WIDTH_RATIO; + dataWidthHintRatio = NsharpConstants.PANE_LITE_D2D_CFG_DATA_WIDTH_RATIO; + dataHeightHintRatio = NsharpConstants.PANE_LITE_D2D_CFG_DATA_HEIGHT_RATIO; + createLiteD2DConfig(baseComposite); + } // d2dlite end + skewtInputManager = new InputManager(this); + // witoInputManager = new InputManager(this); + timeStnInputManager = new InputManager(this); + // hodoInputManager = new InputManager(this); + dataInputManager = new InputManager(this); + insetInputManager = new InputManager(this); + spcGraphsInputManager = new InputManager(this); + try { + for (int i = 0; i < displayPane.length; i++) { + if (displayPane[i] == null && nsharpComp[i] != null) { + displayPane[i] = new VizDisplayPane(this, nsharpComp[i], + displaysToLoad[i]); + + displayPane[i].setRenderableDisplay(displaysToLoad[i]); + } + } + registerHandlers(); + // set default selected pane to skewT pane + selectedPane = displayPane[0]; + + for (int i = 0; i < displayPane.length; i++) { + if (displayPane[i] != null) + displayPane[i].addListener(SWT.MouseEnter, + new PaneMouseListener(i)); + } + } catch (Exception e) { final String errMsg = "Error setting up NsharpEditor"; - UFStatus.getHandler().handle(Priority.SIGNIFICANT, errMsg, e); + UFStatus.getHandler().handle(Priority.SIGNIFICANT, errMsg, e); } - if(!restarting) - contributePerspectiveActions(); + if (!restarting) + contributePerspectiveActions(); } - private void createSPCWsConfig(Composite comp) { + + private void createSPCWsConfig(Composite comp) { topGp = new Group(baseComposite, SWT.NONE); - topGpGd = new GridData(SWT.FILL, SWT.FILL, true, - true); + topGpGd = new GridData(SWT.FILL, SWT.FILL, true, true); topGp.setLayoutData(topGpGd); GridLayout topGpLayout = new GridLayout(3, false); topGpLayout.marginWidth = 0; topGpLayout.marginHeight = 0; topGpLayout.verticalSpacing = 0; topGp.setLayout(topGpLayout); - - // skewt composite + + // skewt composite Composite skewtComp = new Composite(topGp, SWT.NONE); - GridData skewtGd = new GridData(SWT.FILL, SWT.FILL, true, - true); + GridData skewtGd = new GridData(SWT.FILL, SWT.FILL, true, true); skewtComp.setLayoutData(skewtGd); GridLayout skewtLayout = new GridLayout(1, true); skewtLayout.marginWidth = 0; @@ -342,8 +448,7 @@ public class NsharpEditor extends AbstractEditor implements IRenderableDisplayC nsharpComp[DISPLAY_SKEWT] = skewtComp; // wito composite Composite witoComp = new Composite(topGp, SWT.NONE); - GridData witoGd = new GridData(SWT.FILL, SWT.FILL, true, - true); + GridData witoGd = new GridData(SWT.FILL, SWT.FILL, true, true); witoComp.setLayoutData(witoGd); GridLayout witoLayout = new GridLayout(1, true); witoLayout.marginWidth = 0; @@ -351,88 +456,80 @@ public class NsharpEditor extends AbstractEditor implements IRenderableDisplayC witoLayout.verticalSpacing = 0; witoComp.setLayout(witoLayout); nsharpComp[DISPLAY_WITO] = witoComp; - - - // right-top group : right part of top group + + // right-top group : right part of top group rightTopGp = new Group(topGp, SWT.NONE); - rightTopGpGd = new GridData(SWT.FILL, SWT.FILL, true, - true); + rightTopGpGd = new GridData(SWT.FILL, SWT.FILL, true, true); rightTopGp.setLayoutData(rightTopGpGd); GridLayout rightTopGpLayout = new GridLayout(1, true); rightTopGpLayout.marginWidth = 0; rightTopGpLayout.marginHeight = 0; - rightTopGpLayout.verticalSpacing=0; + rightTopGpLayout.verticalSpacing = 0; rightTopGp.setLayout(rightTopGpLayout); - - //hodo composite + + // hodo composite Composite hodoComp = new Composite(rightTopGp, SWT.NONE); - GridData hodoGd = new GridData(SWT.FILL, SWT.FILL, true, - true); + GridData hodoGd = new GridData(SWT.FILL, SWT.FILL, true, true); hodoComp.setLayoutData(hodoGd); GridLayout hodoLayout = new GridLayout(1, true); - hodoLayout.marginHeight =0; - hodoLayout.marginWidth=0; - hodoLayout.verticalSpacing=0; + hodoLayout.marginHeight = 0; + hodoLayout.marginWidth = 0; + hodoLayout.verticalSpacing = 0; hodoComp.setLayout(hodoLayout); - nsharpComp[DISPLAY_HODO] = hodoComp; - - //inset composite + nsharpComp[DISPLAY_HODO] = hodoComp; + + // inset composite Composite insetComp = new Composite(rightTopGp, SWT.NONE); - GridData insetGd = new GridData(SWT.FILL, SWT.FILL, true, - true); - //insetGd.heightHint = 1; + GridData insetGd = new GridData(SWT.FILL, SWT.FILL, true, true); + // insetGd.heightHint = 1; insetComp.setLayoutData(insetGd); GridLayout insetLayout = new GridLayout(1, true); insetLayout.marginHeight = 0; insetLayout.marginWidth = 0; - insetComp.setLayout(insetLayout); - nsharpComp[DISPLAY_INSET] = insetComp; - - botGp = new Group(baseComposite, SWT.NONE); - botGpGd = new GridData(SWT.FILL, SWT.FILL, true, - true); + insetComp.setLayout(insetLayout); + nsharpComp[DISPLAY_INSET] = insetComp; + + botGp = new Group(baseComposite, SWT.NONE); + botGpGd = new GridData(SWT.FILL, SWT.FILL, true, true); botGp.setLayoutData(botGpGd); GridLayout botGpLayout = new GridLayout(2, true); botGpLayout.marginWidth = 0; botGpLayout.marginHeight = 0; botGpLayout.verticalSpacing = 0; botGp.setLayout(botGpLayout); - //data composite + // data composite Composite dataComp = new Composite(botGp, SWT.NONE); - GridData dataGd = new GridData(SWT.FILL, SWT.FILL, true, - false); + GridData dataGd = new GridData(SWT.FILL, SWT.FILL, true, false); dataComp.setLayoutData(dataGd); GridLayout dataLayout = new GridLayout(1, true); dataLayout.marginHeight = 0; - dataLayout.marginWidth=0; + dataLayout.marginWidth = 0; dataComp.setLayout(dataLayout); - nsharpComp[DISPLAY_DATA] = dataComp; - //spc composite + nsharpComp[DISPLAY_DATA] = dataComp; + // spc composite Composite spcComp = new Composite(botGp, SWT.NONE); - GridData spcGd = new GridData(SWT.FILL, SWT.FILL, true, - false); + GridData spcGd = new GridData(SWT.FILL, SWT.FILL, true, false); spcComp.setLayoutData(spcGd); GridLayout spcLayout = new GridLayout(1, true); spcLayout.marginHeight = 0; - spcLayout.marginWidth=0; + spcLayout.marginWidth = 0; spcComp.setLayout(spcLayout); - nsharpComp[DISPLAY_SPC_GRAPHS] = spcComp; + nsharpComp[DISPLAY_SPC_GRAPHS] = spcComp; } - private void createSimpleD2DConfig(Composite comp) { - topGp = new Group(baseComposite, SWT.NONE); - topGpGd = new GridData(SWT.FILL, SWT.FILL, true, - true); + + private void createSimpleD2DConfig(Composite comp) { + topGp = new Group(baseComposite, SWT.NONE); + topGpGd = new GridData(SWT.FILL, SWT.FILL, true, true); topGp.setLayoutData(topGpGd); GridLayout topGpLayout = new GridLayout(2, false); topGpLayout.marginWidth = 0; topGpLayout.marginHeight = 0; topGpLayout.verticalSpacing = 0; topGp.setLayout(topGpLayout); - + // skewt composite Composite skewtComp = new Composite(topGp, SWT.NONE); - GridData skewtGd = new GridData(SWT.FILL, SWT.FILL, true, - true); + GridData skewtGd = new GridData(SWT.FILL, SWT.FILL, true, true); skewtComp.setLayoutData(skewtGd); GridLayout skewtLayout = new GridLayout(1, true); skewtLayout.marginWidth = 0; @@ -440,100 +537,158 @@ public class NsharpEditor extends AbstractEditor implements IRenderableDisplayC skewtLayout.verticalSpacing = 0; skewtComp.setLayout(skewtLayout); nsharpComp[DISPLAY_SKEWT] = skewtComp; - - // right-top group : right part of top group + + // right-top group : right part of top group rightTopGp = new Group(topGp, SWT.NONE); - rightTopGpGd = new GridData(SWT.FILL, SWT.FILL, true, - true); + rightTopGpGd = new GridData(SWT.FILL, SWT.FILL, true, true); rightTopGp.setLayoutData(rightTopGpGd); GridLayout rightTopGpLayout = new GridLayout(1, true); rightTopGpLayout.marginWidth = 0; rightTopGpLayout.marginHeight = 0; - rightTopGpLayout.verticalSpacing=0; + rightTopGpLayout.verticalSpacing = 0; rightTopGp.setLayout(rightTopGpLayout); - - //time-stn composite + + // time-stn composite Composite timeStnComp = new Composite(rightTopGp, SWT.NONE); - GridData timeStnGd = new GridData(SWT.FILL, SWT.FILL, true, - true); + GridData timeStnGd = new GridData(SWT.FILL, SWT.FILL, true, true); timeStnComp.setLayoutData(timeStnGd); GridLayout timeStnLayout = new GridLayout(1, true); - timeStnLayout.marginHeight =0; - timeStnLayout.marginWidth=0; - timeStnLayout.verticalSpacing=0; + timeStnLayout.marginHeight = 0; + timeStnLayout.marginWidth = 0; + timeStnLayout.verticalSpacing = 0; timeStnComp.setLayout(timeStnLayout); - nsharpComp[DISPLAY_TIMESTN] = timeStnComp; - - //future composite + nsharpComp[DISPLAY_TIMESTN] = timeStnComp; + + // future composite Composite futureComp = new Composite(rightTopGp, SWT.NONE); - GridData fuGd = new GridData(SWT.FILL, SWT.FILL, true, - true); + GridData fuGd = new GridData(SWT.FILL, SWT.FILL, true, true); futureComp.setLayoutData(fuGd); GridLayout futureLayout = new GridLayout(1, true); futureLayout.marginHeight = 0; - futureLayout.marginWidth=0; + futureLayout.marginWidth = 0; futureComp.setLayout(futureLayout); - nsharpComp[DISPLAY_FUTURE] = futureComp; - + nsharpComp[DISPLAY_FUTURE] = futureComp; + botGp = new Group(baseComposite, SWT.NONE); - botGpGd = new GridData(SWT.FILL, SWT.FILL, true, - true); + botGpGd = new GridData(SWT.FILL, SWT.FILL, true, true); botGp.setLayoutData(botGpGd); GridLayout botGpLayout = new GridLayout(2, false); botGpLayout.marginWidth = 0; botGpLayout.marginHeight = 0; botGpLayout.verticalSpacing = 0; botGp.setLayout(botGpLayout); - - //hodo composite + + // hodo composite Composite hodoComp = new Composite(botGp, SWT.NONE); - GridData hodoGd = new GridData(SWT.FILL, SWT.FILL, true, - false); + GridData hodoGd = new GridData(SWT.FILL, SWT.FILL, true, false); hodoComp.setLayoutData(hodoGd); GridLayout hodoLayout = new GridLayout(1, true); - hodoLayout.marginHeight =0; - hodoLayout.marginWidth=0; - hodoLayout.verticalSpacing=0; + hodoLayout.marginHeight = 0; + hodoLayout.marginWidth = 0; + hodoLayout.verticalSpacing = 0; hodoComp.setLayout(hodoLayout); - nsharpComp[DISPLAY_HODO] = hodoComp; - - //data composite + nsharpComp[DISPLAY_HODO] = hodoComp; + + // data composite Composite dataComp = new Composite(botGp, SWT.NONE); - GridData dataGd = new GridData(SWT.FILL, SWT.FILL, true, - false); + GridData dataGd = new GridData(SWT.FILL, SWT.FILL, true, false); dataComp.setLayoutData(dataGd); GridLayout dataLayout = new GridLayout(1, true); dataLayout.marginHeight = 0; - dataLayout.marginWidth=0; + dataLayout.marginWidth = 0; dataComp.setLayout(dataLayout); - nsharpComp[DISPLAY_DATA] = dataComp; + nsharpComp[DISPLAY_DATA] = dataComp; } - private void createDefConfig2(Composite comp) { + + private void createLiteD2DConfig(Composite comp) { + topGp = new Group(baseComposite, SWT.NONE); + topGpGd = new GridData(SWT.FILL, SWT.FILL, true, true); + topGp.setLayoutData(topGpGd); + GridLayout topGpLayout = new GridLayout(2, false); + topGpLayout.marginWidth = 0; + topGpLayout.marginHeight = 0; + topGpLayout.verticalSpacing = 0; + topGp.setLayout(topGpLayout); + if (rscHandler.getCurrentGraphMode() != NsharpConstants.GRAPH_HODO) { + // skewt composite + Composite skewtComp = new Composite(topGp, SWT.NONE); + GridData skewtGd = new GridData(SWT.FILL, SWT.FILL, true, true); + skewtComp.setLayoutData(skewtGd); + GridLayout skewtLayout = new GridLayout(1, true); + skewtLayout.marginWidth = 0; + skewtLayout.marginHeight = 0; + skewtLayout.verticalSpacing = 0; + skewtComp.setLayout(skewtLayout); + nsharpComp[DISPLAY_SKEWT] = skewtComp; + } else { + // hodo composite + Composite hodoComp = new Composite(topGp, SWT.NONE); + GridData hodoGd = new GridData(SWT.FILL, SWT.FILL, true, false); + hodoComp.setLayoutData(hodoGd); + GridLayout hodoLayout = new GridLayout(1, true); + hodoLayout.marginHeight = 0; + hodoLayout.marginWidth = 0; + hodoLayout.verticalSpacing = 0; + hodoComp.setLayout(hodoLayout); + nsharpComp[DISPLAY_HODO] = hodoComp; + } + + // only has right group + rightTopGp = new Group(topGp, SWT.NONE); + rightTopGpGd = new GridData(SWT.FILL, SWT.FILL, true, true); + rightTopGp.setLayoutData(rightTopGpGd); + GridLayout rightTopGpLayout = new GridLayout(1, true); + rightTopGpLayout.marginWidth = 0; + rightTopGpLayout.marginHeight = 0; + rightTopGpLayout.verticalSpacing = 0; + rightTopGp.setLayout(rightTopGpLayout); + + // time-stn composite + Composite timeStnComp = new Composite(rightTopGp, SWT.NONE); + GridData timeStnGd = new GridData(SWT.FILL, SWT.FILL, true, true); + timeStnComp.setLayoutData(timeStnGd); + GridLayout timeStnLayout = new GridLayout(1, true); + timeStnLayout.marginHeight = 0; + timeStnLayout.marginWidth = 0; + timeStnLayout.verticalSpacing = 0; + timeStnComp.setLayout(timeStnLayout); + nsharpComp[DISPLAY_TIMESTN] = timeStnComp; + + // data composite + Composite dataComp = new Composite(rightTopGp, SWT.NONE); + GridData dataGd = new GridData(SWT.FILL, SWT.FILL, true, false); + dataComp.setLayoutData(dataGd); + GridLayout dataLayout = new GridLayout(1, true); + dataLayout.marginHeight = 0; + dataLayout.marginWidth = 0; + dataComp.setLayout(dataLayout); + nsharpComp[DISPLAY_DATA] = dataComp; + + } + + private void createDefConfig2(Composite comp) { leftGp = new Group(baseComposite, SWT.NONE); - leftGpGd = new GridData(SWT.FILL, SWT.FILL, true, - true); + leftGpGd = new GridData(SWT.FILL, SWT.FILL, true, true); leftGp.setLayoutData(leftGpGd); GridLayout leftGpLayout = new GridLayout(1, true); leftGpLayout.marginWidth = 0; leftGpLayout.marginHeight = 0; leftGpLayout.verticalSpacing = 0; leftGp.setLayout(leftGpLayout); - - //left-top group : upper part of left group + + // left-top group : upper part of left group leftTopGp = new Group(leftGp, SWT.NONE); - leftTopGpGd = new GridData(SWT.FILL, SWT.FILL, true, - true); + leftTopGpGd = new GridData(SWT.FILL, SWT.FILL, true, true); leftTopGp.setLayoutData(leftTopGpGd); GridLayout leftTopGpLayout = new GridLayout(2, false); leftTopGpLayout.marginWidth = 0; leftTopGpLayout.marginHeight = 0; - leftTopGpLayout.verticalSpacing=0; + leftTopGpLayout.verticalSpacing = 0; leftTopGp.setLayout(leftTopGpLayout); - + // skewt composite Composite skewtComp = new Composite(leftTopGp, SWT.NONE); - GridData skewtGd = new GridData(SWT.FILL, SWT.FILL, true, - true); + GridData skewtGd = new GridData(SWT.FILL, SWT.FILL, true, true); skewtComp.setLayoutData(skewtGd); GridLayout skewtLayout = new GridLayout(1, true); skewtLayout.marginWidth = 0; @@ -543,8 +698,7 @@ public class NsharpEditor extends AbstractEditor implements IRenderableDisplayC nsharpComp[DISPLAY_SKEWT] = skewtComp; // wito composite Composite witoComp = new Composite(leftTopGp, SWT.NONE); - GridData witoGd = new GridData(SWT.END, SWT.FILL, false, - true); + GridData witoGd = new GridData(SWT.END, SWT.FILL, false, true); witoComp.setLayoutData(witoGd); GridLayout witoLayout = new GridLayout(1, true); witoLayout.marginWidth = 0; @@ -552,98 +706,90 @@ public class NsharpEditor extends AbstractEditor implements IRenderableDisplayC witoLayout.verticalSpacing = 0; witoComp.setLayout(witoLayout); nsharpComp[DISPLAY_WITO] = witoComp; - //inset composite + // inset composite Composite insetComp = new Composite(leftGp, SWT.NONE); - GridData insetGd = new GridData(SWT.FILL, SWT.FILL, true, - false); - //insetGd.heightHint = 1; + GridData insetGd = new GridData(SWT.FILL, SWT.FILL, true, false); + // insetGd.heightHint = 1; insetComp.setLayoutData(insetGd); GridLayout insetLayout = new GridLayout(1, true); insetLayout.marginHeight = 0; insetLayout.marginWidth = 0; - insetComp.setLayout(insetLayout); - nsharpComp[DISPLAY_INSET] = insetComp; - //right group + insetComp.setLayout(insetLayout); + nsharpComp[DISPLAY_INSET] = insetComp; + // right group rightGp = new Group(baseComposite, SWT.NONE); - rightGpGd = new GridData(SWT.FILL, SWT.FILL, true, - true); + rightGpGd = new GridData(SWT.FILL, SWT.FILL, true, true); rightGp.setLayoutData(rightGpGd); GridLayout rightGpLayout = new GridLayout(1, true); rightGpLayout.marginWidth = 0; rightGpLayout.marginHeight = 0; - rightGpLayout.verticalSpacing=0; + rightGpLayout.verticalSpacing = 0; rightGp.setLayout(rightGpLayout); - - //right-top group : upper part of right group + + // right-top group : upper part of right group rightTopGp = new Group(rightGp, SWT.NONE); - rightTopGpGd = new GridData(SWT.FILL, SWT.FILL, true, - true); + rightTopGpGd = new GridData(SWT.FILL, SWT.FILL, true, true); rightTopGp.setLayoutData(rightTopGpGd); GridLayout rightTopGpLayout = new GridLayout(2, false); rightTopGpLayout.marginWidth = 0; rightTopGpLayout.marginHeight = 0; - rightTopGpLayout.verticalSpacing=0; + rightTopGpLayout.verticalSpacing = 0; rightTopGp.setLayout(rightTopGpLayout); - //hodo composite + // hodo composite Composite hodoComp = new Composite(rightTopGp, SWT.NONE); - GridData hodoGd = new GridData(SWT.FILL, SWT.FILL, true, - true); + GridData hodoGd = new GridData(SWT.FILL, SWT.FILL, true, true); hodoComp.setLayoutData(hodoGd); GridLayout hodoLayout = new GridLayout(1, true); - hodoLayout.marginHeight =0; - hodoLayout.marginWidth=0; - hodoLayout.verticalSpacing=0; + hodoLayout.marginHeight = 0; + hodoLayout.marginWidth = 0; + hodoLayout.verticalSpacing = 0; hodoComp.setLayout(hodoLayout); - nsharpComp[DISPLAY_HODO] = hodoComp; - //time-stn composite + nsharpComp[DISPLAY_HODO] = hodoComp; + // time-stn composite Composite timeStnComp = new Composite(rightTopGp, SWT.NONE); - GridData timeStnGd = new GridData(SWT.END, SWT.FILL, false, - true); + GridData timeStnGd = new GridData(SWT.END, SWT.FILL, false, true); timeStnComp.setLayoutData(timeStnGd); GridLayout timeStnLayout = new GridLayout(1, true); - timeStnLayout.marginHeight =0; - timeStnLayout.marginWidth=0; - timeStnLayout.verticalSpacing=0; + timeStnLayout.marginHeight = 0; + timeStnLayout.marginWidth = 0; + timeStnLayout.verticalSpacing = 0; timeStnComp.setLayout(timeStnLayout); - nsharpComp[DISPLAY_TIMESTN] = timeStnComp; - //data composite + nsharpComp[DISPLAY_TIMESTN] = timeStnComp; + // data composite Composite dataComp = new Composite(rightGp, SWT.NONE); - GridData dataGd = new GridData(SWT.FILL, SWT.FILL, true, - false); + GridData dataGd = new GridData(SWT.FILL, SWT.FILL, true, false); dataComp.setLayoutData(dataGd); GridLayout dataLayout = new GridLayout(1, true); dataLayout.marginHeight = 0; - dataLayout.marginWidth=0; + dataLayout.marginWidth = 0; dataComp.setLayout(dataLayout); - nsharpComp[DISPLAY_DATA] = dataComp; + nsharpComp[DISPLAY_DATA] = dataComp; } + private void createDefConfig1(Composite comp) { leftGp = new Group(baseComposite, SWT.NONE); - leftGpGd = new GridData(SWT.FILL, SWT.FILL, true, - true); - + leftGpGd = new GridData(SWT.FILL, SWT.FILL, true, true); + leftGp.setLayoutData(leftGpGd); GridLayout leftGpLayout = new GridLayout(1, true); leftGpLayout.marginWidth = 0; leftGpLayout.marginHeight = 0; leftGpLayout.verticalSpacing = 0; leftGp.setLayout(leftGpLayout); - - //left-top group : upper part of left group + + // left-top group : upper part of left group leftTopGp = new Group(leftGp, SWT.NONE); - leftTopGpGd = new GridData(SWT.FILL, SWT.FILL, true, - true); + leftTopGpGd = new GridData(SWT.FILL, SWT.FILL, true, true); leftTopGp.setLayoutData(leftTopGpGd); GridLayout leftTopGpLayout = new GridLayout(2, false); leftTopGpLayout.marginWidth = 0; leftTopGpLayout.marginHeight = 0; - leftTopGpLayout.verticalSpacing=0; + leftTopGpLayout.verticalSpacing = 0; leftTopGp.setLayout(leftTopGpLayout); - + // skewt composite Composite skewtComp = new Composite(leftTopGp, SWT.NONE); - GridData skewtGd = new GridData(SWT.FILL, SWT.FILL, true, - true); + GridData skewtGd = new GridData(SWT.FILL, SWT.FILL, true, true); skewtComp.setLayoutData(skewtGd); GridLayout skewtLayout = new GridLayout(1, true); skewtLayout.marginWidth = 0; @@ -653,8 +799,7 @@ public class NsharpEditor extends AbstractEditor implements IRenderableDisplayC nsharpComp[DISPLAY_SKEWT] = skewtComp; // wito composite Composite witoComp = new Composite(leftTopGp, SWT.NONE); - GridData witoGd = new GridData(SWT.FILL, SWT.FILL, true, - true); + GridData witoGd = new GridData(SWT.FILL, SWT.FILL, true, true); witoComp.setLayoutData(witoGd); GridLayout witoLayout = new GridLayout(1, true); witoLayout.marginWidth = 0; @@ -662,239 +807,247 @@ public class NsharpEditor extends AbstractEditor implements IRenderableDisplayC witoLayout.verticalSpacing = 0; witoComp.setLayout(witoLayout); nsharpComp[DISPLAY_WITO] = witoComp; - //left-bottom group + // left-bottom group leftBotGp = new Group(leftGp, SWT.NONE); - leftBotGpGd = new GridData(SWT.FILL, SWT.FILL, true, - true); + leftBotGpGd = new GridData(SWT.FILL, SWT.FILL, true, true); leftBotGp.setLayoutData(leftBotGpGd); GridLayout leftBotGpLayout = new GridLayout(2, true); leftBotGpLayout.marginWidth = 0; leftBotGpLayout.marginHeight = 0; - leftBotGpLayout.verticalSpacing=0; + leftBotGpLayout.verticalSpacing = 0; leftBotGp.setLayout(leftBotGpLayout); - //time-stn composite + // time-stn composite Composite timeStnComp = new Composite(leftBotGp, SWT.NONE); - GridData timeStnGd = new GridData(SWT.FILL, SWT.FILL, true, - true); + GridData timeStnGd = new GridData(SWT.FILL, SWT.FILL, true, true); timeStnComp.setLayoutData(timeStnGd); GridLayout timeStnLayout = new GridLayout(1, true); - timeStnLayout.marginHeight =0; - timeStnLayout.marginWidth=0; - timeStnLayout.verticalSpacing=0; + timeStnLayout.marginHeight = 0; + timeStnLayout.marginWidth = 0; + timeStnLayout.verticalSpacing = 0; timeStnComp.setLayout(timeStnLayout); - nsharpComp[DISPLAY_TIMESTN] = timeStnComp; - //inset composite + nsharpComp[DISPLAY_TIMESTN] = timeStnComp; + // inset composite Composite insetComp = new Composite(leftBotGp, SWT.NONE); - GridData insetGd = new GridData(SWT.FILL, SWT.FILL, true, - true); - //insetGd.heightHint = 1; + GridData insetGd = new GridData(SWT.FILL, SWT.FILL, true, true); + // insetGd.heightHint = 1; insetComp.setLayoutData(insetGd); GridLayout insetLayout = new GridLayout(1, true); insetLayout.marginHeight = 0; insetLayout.marginWidth = 0; - insetComp.setLayout(insetLayout); - nsharpComp[DISPLAY_INSET] = insetComp; - //right group + insetComp.setLayout(insetLayout); + nsharpComp[DISPLAY_INSET] = insetComp; + // right group rightGp = new Group(baseComposite, SWT.NONE); - rightGpGd = new GridData(SWT.END, SWT.FILL, true, - true); - + rightGpGd = new GridData(SWT.END, SWT.FILL, true, true); + rightGp.setLayoutData(rightGpGd); GridLayout rightGpLayout = new GridLayout(1, true); rightGpLayout.marginWidth = 0; rightGpLayout.marginHeight = 0; - rightGpLayout.verticalSpacing=0; + rightGpLayout.verticalSpacing = 0; rightGp.setLayout(rightGpLayout); - - //hodo composite + + // hodo composite Composite hodoComp = new Composite(rightGp, SWT.NONE); - GridData hodoGd = new GridData(SWT.FILL, SWT.FILL, true, - true); + GridData hodoGd = new GridData(SWT.FILL, SWT.FILL, true, true); hodoComp.setLayoutData(hodoGd); GridLayout hodoLayout = new GridLayout(1, true); - hodoLayout.marginHeight =0; - hodoLayout.marginWidth=0; - hodoLayout.verticalSpacing=0; + hodoLayout.marginHeight = 0; + hodoLayout.marginWidth = 0; + hodoLayout.verticalSpacing = 0; hodoComp.setLayout(hodoLayout); - nsharpComp[DISPLAY_HODO] = hodoComp; - //data composite + nsharpComp[DISPLAY_HODO] = hodoComp; + // data composite Composite dataComp = new Composite(rightGp, SWT.NONE); - GridData dataGd = new GridData(SWT.FILL, SWT.FILL, true, - true); + GridData dataGd = new GridData(SWT.FILL, SWT.FILL, true, true); dataComp.setLayoutData(dataGd); GridLayout dataLayout = new GridLayout(1, true); dataLayout.marginHeight = 1; - dataLayout.marginWidth=0; + dataLayout.marginWidth = 0; dataComp.setLayout(dataLayout); - nsharpComp[DISPLAY_DATA] = dataComp; + nsharpComp[DISPLAY_DATA] = dataComp; } protected void registerHandlers() { - for(int i=0; i < displayPane.length; i++){ - if(displayPane[i]!=null){ - IDisplayPane pane = displayPane[i]; - InputHandlerDefaultImpl mouseHandler=null; - InputManager inputMgr; - // Enable the mouse inspect adapter - if(i == DISPLAY_SKEWT){ - skewtPaneMouseHandler = new NsharpSkewTPaneMouseHandler(this, pane); - mouseHandler = skewtPaneMouseHandler; - inputMgr = skewtInputManager; - } - else if(i == DISPLAY_HODO) { + for (int i = 0; i < displayPane.length; i++) { + if (displayPane[i] != null) { + IDisplayPane pane = displayPane[i]; + InputHandlerDefaultImpl mouseHandler = null; + InputManager inputMgr; + // Enable the mouse inspect adapter + if (i == DISPLAY_SKEWT) { + skewtPaneMouseHandler = new NsharpSkewTPaneMouseHandler( + this, pane); + mouseHandler = skewtPaneMouseHandler; + inputMgr = skewtInputManager; + } else if (i == DISPLAY_HODO) { + hodoInputManager = new InputManager(this); + hodoPaneMouseHandler = new NsharpHodoPaneMouseHandler(this, + pane); + mouseHandler = hodoPaneMouseHandler; + inputMgr = hodoInputManager; + } else if (i == DISPLAY_TIMESTN) { + timeStnPaneMouseHandler = new NsharpTimeStnPaneMouseHandler( + this, pane); + mouseHandler = timeStnPaneMouseHandler; + inputMgr = timeStnInputManager; + } else if (i == DISPLAY_INSET) { + insetPaneMouseHandler = new NsharpAbstractMouseHandler( + this, pane); + mouseHandler = insetPaneMouseHandler; + inputMgr = insetInputManager; + } else if (i == DISPLAY_SPC_GRAPHS) { + spcGraphsPaneMouseHandler = new NsharpAbstractMouseHandler( + this, pane); + mouseHandler = spcGraphsPaneMouseHandler; + inputMgr = spcGraphsInputManager; + } else if (i == DISPLAY_DATA) { + dataPaneMouseHandler = new NsharpDataPaneMouseHandler(this, + pane); + mouseHandler = dataPaneMouseHandler; + inputMgr = dataInputManager; + } else + continue; - hodoPaneMouseHandler = new NsharpHodoPaneMouseHandler(this,pane); - mouseHandler =hodoPaneMouseHandler; - inputMgr =hodoInputManager; - } - else if(i== DISPLAY_TIMESTN) { - timeStnPaneMouseHandler = new NsharpTimeStnPaneMouseHandler(this,pane); - mouseHandler =timeStnPaneMouseHandler; - inputMgr =timeStnInputManager; - } - else if(i== DISPLAY_INSET) { - insetPaneMouseHandler = new NsharpAbstractMouseHandler(this,pane); - mouseHandler =insetPaneMouseHandler; - inputMgr =insetInputManager; - } - else if(i== DISPLAY_SPC_GRAPHS) { - spcGraphsPaneMouseHandler = new NsharpAbstractMouseHandler(this,pane); - mouseHandler =spcGraphsPaneMouseHandler; - inputMgr =spcGraphsInputManager; - } - else if(i== DISPLAY_DATA){ - dataPaneMouseHandler = new NsharpDataPaneMouseHandler(this,pane); - mouseHandler =dataPaneMouseHandler; - inputMgr =dataInputManager; - } - else - continue; + inputMgr.registerMouseHandler(mouseHandler); - inputMgr.registerMouseHandler(mouseHandler); - - pane.addListener(SWT.MouseUp, inputMgr); - pane.addListener(SWT.MouseDown, inputMgr); - pane.addListener(SWT.MouseMove, inputMgr); - pane.addListener(SWT.MouseWheel, inputMgr); - pane.addListener(SWT.MouseHover, inputMgr); - pane.addListener(SWT.MouseEnter, inputMgr); - pane.addListener(SWT.MouseExit, inputMgr); - pane.addListener(SWT.MenuDetect, inputMgr); - pane.addListener(SWT.KeyUp, inputMgr); - pane.addListener(SWT.KeyDown, inputMgr); - } - } + pane.addListener(SWT.MouseUp, inputMgr); + pane.addListener(SWT.MouseDown, inputMgr); + pane.addListener(SWT.MouseMove, inputMgr); + pane.addListener(SWT.MouseWheel, inputMgr); + pane.addListener(SWT.MouseHover, inputMgr); + pane.addListener(SWT.MouseEnter, inputMgr); + pane.addListener(SWT.MouseExit, inputMgr); + pane.addListener(SWT.MenuDetect, inputMgr); + pane.addListener(SWT.KeyUp, inputMgr); + pane.addListener(SWT.KeyDown, inputMgr); + } + } } - @Override public void init(IEditorSite site, IEditorInput editorInput) throws PartInitException { - //System.out.println("NsharpEditor init!! " + this.toString() ); - NsharpConfigManager configMgr = NsharpConfigManager.getInstance(); - NsharpConfigStore configStore = configMgr.retrieveNsharpConfigStoreFromFs(); - NsharpGraphProperty graphConfigProperty = configStore.getGraphProperty(); - paneConfigurationName = graphConfigProperty.getPaneConfigurationName(); - if(!paneConfigurationName.equals(NsharpConstants.PANE_SPCWS_CFG_STR) && !paneConfigurationName.equals(NsharpConstants.PANE_SIMPLE_D2D_CFG_STR)) - paneConfigurationName = NsharpConstants.PANE_SIMPLE_D2D_CFG_STR; - initDisplayPublicParms(); - createRenderableDisplayArray(); - /* - * Chin note: we ignore "Renderable displays" sent with "editorInput" parameter here, as in D2D - * application the "Renderable displays" only contains skewTPaneDisplay. - * We recreate displayArray and reset them to EditorInput here based on current "paneConfigurationName" - * - */ - - EditorInput edInput = (EditorInput)editorInput; + // System.out.println("NsharpEditor init!! " + this.toString() ); + NsharpConfigManager configMgr = NsharpConfigManager.getInstance(); + NsharpConfigStore configStore = configMgr + .retrieveNsharpConfigStoreFromFs(); + NsharpGraphProperty graphConfigProperty = configStore + .getGraphProperty(); + paneConfigurationName = graphConfigProperty.getPaneConfigurationName(); + if (!paneConfigurationName.equals(NsharpConstants.PANE_SPCWS_CFG_STR) + && !paneConfigurationName + .equals(NsharpConstants.PANE_SIMPLE_D2D_CFG_STR) + && !paneConfigurationName + .equals(NsharpConstants.PANE_LITE_D2D_CFG_STR)) // d2dlite + paneConfigurationName = NsharpConstants.PANE_SIMPLE_D2D_CFG_STR; + initDisplayPublicParms(); + createRenderableDisplayArray(); + /* + * Chin note: we ignore "Renderable displays" sent with "editorInput" + * parameter here, as in D2D application the "Renderable displays" only + * contains skewTPaneDisplay. We recreate displayArray and reset them to + * EditorInput here based on current "paneConfigurationName" + */ + + EditorInput edInput = (EditorInput) editorInput; boolean getRscHandlerDone = false; - // bsteffen: reuse any displays that already exist in the current editorInput - for(IRenderableDisplay display : edInput.getRenderableDisplays()){ + // bsteffen: reuse any displays that already exist in the current + // editorInput + for (IRenderableDisplay display : edInput.getRenderableDisplays()) { int index = -1; - if(display instanceof NsharpSkewTPaneDisplay ){ + if (display instanceof NsharpSkewTPaneDisplay) { index = DISPLAY_SKEWT; - }else if(display instanceof NsharpWitoPaneDisplay ){ + } else if (display instanceof NsharpWitoPaneDisplay) { index = DISPLAY_WITO; - }else if(display instanceof NsharpInsetPaneDisplay ){ + } else if (display instanceof NsharpInsetPaneDisplay) { index = DISPLAY_INSET; - }else if(display instanceof NsharpHodoPaneDisplay ){ + } else if (display instanceof NsharpHodoPaneDisplay) { index = DISPLAY_HODO; - }else if(display instanceof NsharpTimeStnPaneDisplay ){ + } else if (display instanceof NsharpTimeStnPaneDisplay) { index = DISPLAY_TIMESTN; - }else if(display instanceof NsharpDataPaneDisplay ){ + } else if (display instanceof NsharpDataPaneDisplay) { index = DISPLAY_DATA; - }else if(display instanceof NsharpSpcGraphsPaneDisplay ){ + } else if (display instanceof NsharpSpcGraphsPaneDisplay) { index = DISPLAY_SPC_GRAPHS; - }else if(display instanceof NsharpAbstractPaneDisplay ){ + } else if (display instanceof NsharpAbstractPaneDisplay) { index = DISPLAY_FUTURE; } - if(index >= 0){ - //System.out.println("displayArray["+index+"] was "+ displayArray[index]+" set to "+display.toString()); - displayArray[index].dispose(); + if (index >= 0) { + // System.out.println("displayArray["+index+"] was "+ + // displayArray[index]+" set to "+display.toString()); + displayArray[index].dispose(); displayArray[index] = display; - //Chin: only do this once - if(!getRscHandlerDone){ - - // attempt to find and reuse rscHandler if possible - List paneRscs = display.getDescriptor() - .getResourceList().getResourcesByTypeAsType( - NsharpAbstractPaneResource.class); - for (NsharpAbstractPaneResource paneRsc : paneRscs) { - NsharpResourceHandler handler = paneRsc.getRscHandler(); - if (handler != null) { - rscHandler = handler; - getRscHandlerDone = true; - - } - } - // bsteffen: not sure if this is necessary, getPaneNumber is never used -// IDescriptor descriptor = display.getDescriptor(); -// if(descriptor instanceof NsharpAbstractPaneDescriptor){ -// ((NsharpAbstractPaneDescriptor) descriptor).setPaneNumber(index); -// } + // Chin: only do this once + if (!getRscHandlerDone) { + + // attempt to find and reuse rscHandler if possible + List paneRscs = display + .getDescriptor() + .getResourceList() + .getResourcesByTypeAsType( + NsharpAbstractPaneResource.class); + for (NsharpAbstractPaneResource paneRsc : paneRscs) { + NsharpResourceHandler handler = paneRsc.getRscHandler(); + if (handler != null) { + rscHandler = handler; + getRscHandlerDone = true; + + } + } + // bsteffen: not sure if this is necessary, getPaneNumber is + // never used + // IDescriptor descriptor = display.getDescriptor(); + // if(descriptor instanceof NsharpAbstractPaneDescriptor){ + // ((NsharpAbstractPaneDescriptor) + // descriptor).setPaneNumber(index); + // } } } } - - edInput.setRenderableDisplays(displayArray); - super.init(site, edInput); + edInput.setRenderableDisplays(displayArray); + + super.init(site, edInput); + + // if (editorNum == 0 ){ + // editorNum = EditorManager.getEditorNumber(); + // + // } + // // a new instance, do the registration + // EditorManager.registerEditorNumber(editorNum); + this.setTabTitle(/* editorNum+ */"NsharpEditor"); + + // Note: NsharpResourceHandler should be created after editor is + // created, so all display pane properties and + // pane resource are also constructed + // bsteffen: only create rscHandler if it doesn't exist already + if (rscHandler == null) { + rscHandler = new NsharpResourceHandler(displayArray, this); + } else { + rscHandler.updateDisplay(displayArray, paneConfigurationName); + + } + NsharpPaletteWindow paletteWin = NsharpPaletteWindow.getInstance(); + if (paletteWin != null) { + paletteWin.restorePaletteWindow(paneConfigurationName, + rscHandler.getCurrentGraphMode(), + rscHandler.isInterpolateIsOn(), rscHandler.isOverlayIsOn(), + rscHandler.isCompareStnIsOn(), + rscHandler.isCompareTmIsOn(), rscHandler.isEditGraphOn(), + rscHandler.isCompareSndIsOn()); + } + createPaneResource(); + + rscHandler.resetData(); + // listen for changes to renderable displays + addRenderableDisplayChangedListener(this); + // add a new part listener if not added yet + NsharpPartListener.addPartListener(); -// if (editorNum == 0 ){ -// editorNum = EditorManager.getEditorNumber(); -// -// } -// // a new instance, do the registration -// EditorManager.registerEditorNumber(editorNum); - this.setTabTitle(/*editorNum+*/"NsharpEditor"); - - //Note: NsharpResourceHandler should be created after editor is created, so all display pane properties and - // pane resource are also constructed - // bsteffen: only create rscHandler if it doesn't exist already - if(rscHandler == null){ - rscHandler = new NsharpResourceHandler(displayArray,this); - }else{ - rscHandler.updateDisplay(displayArray, paneConfigurationName); - - } - NsharpPaletteWindow paletteWin = NsharpPaletteWindow.getInstance(); - if(paletteWin!=null){ - paletteWin.restorePaletteWindow(paneConfigurationName, rscHandler.getCurrentGraphMode(), - rscHandler.isInterpolateIsOn(), rscHandler.isOverlayIsOn(), - rscHandler.isCompareStnIsOn(),rscHandler.isCompareTmIsOn(),rscHandler.isEditGraphOn(), rscHandler.isCompareSndIsOn()); - } - createPaneResource(); - - rscHandler.resetData(); - // listen for changes to renderable displays - addRenderableDisplayChangedListener(this); - //add a new part listener if not added yet - NsharpPartListener.addPartListener(); - } - /* * (non-Javadoc) * @@ -902,8 +1055,8 @@ public class NsharpEditor extends AbstractEditor implements IRenderableDisplayC */ @Override public void setFocus() { - if(selectedPane!= null) - selectedPane.setFocus(); + if (selectedPane != null) + selectedPane.setFocus(); } /* @@ -913,149 +1066,163 @@ public class NsharpEditor extends AbstractEditor implements IRenderableDisplayC */ @Override public void dispose() { - //System.out.println("NsharpEditor disposed!! " ); -// if (EditorManager.unregisterEditorNumber(editorNum) ==0 ){ - super.dispose(); - synchronized (this) { - if (skewtPaneMouseHandler != null && skewtInputManager != null) { - skewtPaneMouseHandler.setEditor(null); - skewtPaneMouseHandler.disposeCursor(); - skewtInputManager.unregisterMouseHandler(skewtPaneMouseHandler); - skewtPaneMouseHandler = null; - skewtInputManager = null; - } - if (hodoPaneMouseHandler != null && hodoInputManager != null) { - hodoPaneMouseHandler.setEditor(null); - hodoInputManager.unregisterMouseHandler(hodoPaneMouseHandler); - hodoPaneMouseHandler = null; - hodoInputManager = null; - } - if (dataPaneMouseHandler != null && dataInputManager != null) { - dataPaneMouseHandler.setEditor(null); - dataInputManager.unregisterMouseHandler(dataPaneMouseHandler); - dataPaneMouseHandler = null; - dataInputManager = null; - } - if (insetPaneMouseHandler != null && insetInputManager != null) { - insetPaneMouseHandler.setEditor(null); - insetInputManager.unregisterMouseHandler(insetPaneMouseHandler); - insetPaneMouseHandler = null; - insetInputManager = null; - } - if (spcGraphsPaneMouseHandler != null && spcGraphsInputManager != null) { - spcGraphsPaneMouseHandler.setEditor(null); - spcGraphsInputManager.unregisterMouseHandler(spcGraphsPaneMouseHandler); - spcGraphsPaneMouseHandler = null; - spcGraphsInputManager = null; - } - if (timeStnPaneMouseHandler != null && timeStnInputManager != null) { - timeStnPaneMouseHandler.setEditor(null); - timeStnInputManager.unregisterMouseHandler(timeStnPaneMouseHandler); - timeStnPaneMouseHandler = null; - timeStnInputManager = null; - } + // System.out.println("NsharpEditor disposed!! " ); + // if (EditorManager.unregisterEditorNumber(editorNum) ==0 ){ + super.dispose(); + synchronized (this) { + if (skewtPaneMouseHandler != null && skewtInputManager != null) { + skewtPaneMouseHandler.setEditor(null); + skewtPaneMouseHandler.disposeCursor(); + skewtInputManager.unregisterMouseHandler(skewtPaneMouseHandler); + skewtPaneMouseHandler = null; + skewtInputManager = null; + } + if (hodoPaneMouseHandler != null && hodoInputManager != null) { + hodoPaneMouseHandler.setEditor(null); + hodoInputManager.unregisterMouseHandler(hodoPaneMouseHandler); + hodoPaneMouseHandler = null; + hodoInputManager = null; + } + if (dataPaneMouseHandler != null && dataInputManager != null) { + dataPaneMouseHandler.setEditor(null); + dataInputManager.unregisterMouseHandler(dataPaneMouseHandler); + dataPaneMouseHandler = null; + dataInputManager = null; + } + if (insetPaneMouseHandler != null && insetInputManager != null) { + insetPaneMouseHandler.setEditor(null); + insetInputManager.unregisterMouseHandler(insetPaneMouseHandler); + insetPaneMouseHandler = null; + insetInputManager = null; + } + if (spcGraphsPaneMouseHandler != null + && spcGraphsInputManager != null) { + spcGraphsPaneMouseHandler.setEditor(null); + spcGraphsInputManager + .unregisterMouseHandler(spcGraphsPaneMouseHandler); + spcGraphsPaneMouseHandler = null; + spcGraphsInputManager = null; + } + if (timeStnPaneMouseHandler != null && timeStnInputManager != null) { + timeStnPaneMouseHandler.setEditor(null); + timeStnInputManager + .unregisterMouseHandler(timeStnPaneMouseHandler); + timeStnPaneMouseHandler = null; + timeStnInputManager = null; + } + + // editorNum=0; + // bsteffen only dispose the rscHandler if not swapping. + // d2dlite if (!displayArray[DISPLAY_SKEWT].isSwapping()) { + if (!displayArray[DISPLAY_Head].isSwapping()) { + if (rscHandler != null) { + rscHandler.disposeInternal(); + } + } + rscHandler = null; + } + // } + try { + IWorkbenchPage wpage = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getActivePage(); + IViewPart vpart = wpage + .findView("gov.noaa.nws.ncep.ui.nsharp.defaultview1"); + wpage.hideView(vpart); + } catch (Exception e) { + + } -// editorNum=0; - // bsteffen only dispose the rscHandler if not swapping. - if(!displayArray[DISPLAY_SKEWT].isSwapping()){ - if(rscHandler!=null){ - rscHandler.disposeInternal(); - } - } - rscHandler = null; - } -// } - try{ - IWorkbenchPage wpage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - IViewPart vpart = wpage.findView( "gov.noaa.nws.ncep.ui.nsharp.defaultview1" ); - wpage.hideView(vpart); - } - catch(Exception e){ - - } - - } public void restartEditor(String paneConfigurationName) { - //System.out.println("reStartEditor! " ); - this.paneConfigurationName = paneConfigurationName ; - if (skewtPaneMouseHandler != null && skewtInputManager != null) { - skewtPaneMouseHandler.setEditor(null); - skewtInputManager.unregisterMouseHandler(skewtPaneMouseHandler); - skewtPaneMouseHandler = null; - skewtInputManager = null; - } - if (hodoPaneMouseHandler != null && hodoInputManager != null) { - hodoPaneMouseHandler.setEditor(null); - hodoInputManager.unregisterMouseHandler(hodoPaneMouseHandler); - hodoPaneMouseHandler = null; - hodoInputManager = null; - } - if (dataPaneMouseHandler != null && dataInputManager != null) { - dataPaneMouseHandler.setEditor(null); - dataInputManager.unregisterMouseHandler(dataPaneMouseHandler); - dataPaneMouseHandler = null; - dataInputManager = null; - } - if (insetPaneMouseHandler != null && insetInputManager != null) { - insetPaneMouseHandler.setEditor(null); - insetInputManager.unregisterMouseHandler(insetPaneMouseHandler); - insetPaneMouseHandler = null; - insetInputManager = null; - } - if (spcGraphsPaneMouseHandler != null && spcGraphsInputManager != null) { - spcGraphsPaneMouseHandler.setEditor(null); - spcGraphsInputManager.unregisterMouseHandler(spcGraphsPaneMouseHandler); - spcGraphsPaneMouseHandler = null; - spcGraphsInputManager = null; - } - if (timeStnPaneMouseHandler != null && timeStnInputManager != null) { - timeStnPaneMouseHandler.setEditor(null); - timeStnInputManager.unregisterMouseHandler(timeStnPaneMouseHandler); - timeStnPaneMouseHandler = null; - timeStnInputManager = null; - } - baseComposite.removeListener(SWT.Resize, resizeLsner); - displayArray = null; - nsharpComp=null; - if(displayPane!=null){ - for (VizDisplayPane pane: displayPane){ - if(pane!=null) - pane.dispose(); - } - } - displayPane = null; - rightTopGp= leftTopGp= leftBotGp= leftGp= rightGp= topGp= botGp=null; - //createOrUpdateEditor(true); - updateEditor(); - restarting = true; - createPartControl(parantComp); - editorInput.setRenderableDisplays(getRenderableDisplays()); - //Chin: note: after reset all resource in editor, editor displays an empty screen. Refresh() does not work. - //Therefore, play the following trick. I.e. bring map editor to top and then this editor to top. After this trick, - // editor displays normally. - parantComp.layout(); // from ben - //NsharpMapResource.bringMapEditorToTop(); - //bringEditorToTop(); - NsharpPaletteWindow paletteWin = NsharpPaletteWindow.getInstance(); - if(paletteWin!=null){ - paletteWin.updateSpcGraphBtn(paneConfigurationName); - } + // System.out.println("reStartEditor! " ); + if (rscHandler != null + && !this.paneConfigurationName.equals(paneConfigurationName)) { + rscHandler.setPaneConfigurationName(paneConfigurationName); + } + this.paneConfigurationName = paneConfigurationName; + + if (skewtPaneMouseHandler != null && skewtInputManager != null) { + skewtPaneMouseHandler.setEditor(null); + skewtInputManager.unregisterMouseHandler(skewtPaneMouseHandler); + skewtPaneMouseHandler = null; + skewtInputManager = null; + } + if (hodoPaneMouseHandler != null && hodoInputManager != null) { + hodoPaneMouseHandler.setEditor(null); + hodoInputManager.unregisterMouseHandler(hodoPaneMouseHandler); + hodoPaneMouseHandler = null; + hodoInputManager = null; + } + if (dataPaneMouseHandler != null && dataInputManager != null) { + dataPaneMouseHandler.setEditor(null); + dataInputManager.unregisterMouseHandler(dataPaneMouseHandler); + dataPaneMouseHandler = null; + dataInputManager = null; + } + if (insetPaneMouseHandler != null && insetInputManager != null) { + insetPaneMouseHandler.setEditor(null); + insetInputManager.unregisterMouseHandler(insetPaneMouseHandler); + insetPaneMouseHandler = null; + insetInputManager = null; + } + if (spcGraphsPaneMouseHandler != null && spcGraphsInputManager != null) { + spcGraphsPaneMouseHandler.setEditor(null); + spcGraphsInputManager + .unregisterMouseHandler(spcGraphsPaneMouseHandler); + spcGraphsPaneMouseHandler = null; + spcGraphsInputManager = null; + } + if (timeStnPaneMouseHandler != null && timeStnInputManager != null) { + timeStnPaneMouseHandler.setEditor(null); + timeStnInputManager.unregisterMouseHandler(timeStnPaneMouseHandler); + timeStnPaneMouseHandler = null; + timeStnInputManager = null; + } + baseComposite.removeListener(SWT.Resize, resizeLsner); + displayArray = null; + nsharpComp = null; + if (displayPane != null) { + for (VizDisplayPane pane : displayPane) { + if (pane != null) + pane.dispose(); + } + } + displayPane = null; + rightTopGp = leftTopGp = leftBotGp = leftGp = rightGp = topGp = botGp = null; + // createOrUpdateEditor(true); + updateEditor(); + restarting = true; + createPartControl(parantComp); + editorInput.setRenderableDisplays(getRenderableDisplays()); + // Chin: note: after reset all resource in editor, editor displays an + // empty screen. Refresh() does not work. + // Therefore, play the following trick. I.e. bring map editor to top and + // then this editor to top. After this trick, + // editor displays normally. + parantComp.layout(); // from ben + // NsharpMapResource.bringMapEditorToTop(); + // bringEditorToTop(); + NsharpPaletteWindow paletteWin = NsharpPaletteWindow.getInstance(); + if (paletteWin != null) { + paletteWin.updateSpecialGraphBtn(paneConfigurationName); + } } + /** * Perform a refresh asynchronously * */ @Override public void refresh() { - if(displayPane!= null) - for (IDisplayPane pane : displayPane) { - if(pane!=null) - pane.refresh(); - } - //System.out.println("NsharpEditor refresh called"); + if (displayPane != null) + for (IDisplayPane pane : displayPane) { + if (pane != null) + pane.refresh(); + } + // System.out.println("NsharpEditor refresh called"); } + @Override public Coordinate translateClick(double x, double y) { double[] grid = getActiveDisplayPane().screenToGrid(x, y, 0); @@ -1063,7 +1230,7 @@ public class NsharpEditor extends AbstractEditor implements IRenderableDisplayC return new Coordinate(grid[0], grid[1], grid[2]); } - @Override + @Override public double[] translateInverseClick(Coordinate c) { if (Double.isNaN(c.z)) { @@ -1073,26 +1240,28 @@ public class NsharpEditor extends AbstractEditor implements IRenderableDisplayC new double[] { c.x, c.y, c.z }); } - public void resetGraph(){ - for(int i=0; i < DISPLAY_TOTAL; i++){ - if(displayPane[i]!=null){ - displayPane[i].getRenderableDisplay().getExtent().reset(); - displayPane[i].getRenderableDisplay().zoom(1.0); - displayPane[i].getRenderableDisplay().refresh(); - } - } - if(rscHandler!=null) { - if(rscHandler.getWitoPaneRsc()!=null){ - rscHandler.getWitoPaneRsc().createAllWireFrameShapes(); - } - //rscHandler.getSkewtPaneRsc().handleZooming(); - } + public void resetGraph() { + for (int i = 0; i < DISPLAY_TOTAL; i++) { + if (displayPane[i] != null) { + displayPane[i].getRenderableDisplay().getExtent().reset(); + displayPane[i].getRenderableDisplay().zoom(1.0); + displayPane[i].getRenderableDisplay().refresh(); + } + } + if (rscHandler != null) { + if (rscHandler.getWitoPaneRsc() != null) { + rscHandler.getWitoPaneRsc().createAllWireFrameShapes(); + } + // rscHandler.getSkewtPaneRsc().handleZooming(); + } } - public void registerMouseHandler(IInputHandler handler, IInputHandler.InputPriority priority) { - if(skewtInputManager!=null) - skewtInputManager.registerMouseHandler(handler, priority); + + public void registerMouseHandler(IInputHandler handler, + IInputHandler.InputPriority priority) { + if (skewtInputManager != null) + skewtInputManager.registerMouseHandler(handler, priority); } - + /** * Register a mouse handler to a map * @@ -1101,8 +1270,8 @@ public class NsharpEditor extends AbstractEditor implements IRenderableDisplayC */ @Override public void registerMouseHandler(IInputHandler handler) { - if(skewtInputManager != null) - skewtInputManager.registerMouseHandler(handler); + if (skewtInputManager != null) + skewtInputManager.registerMouseHandler(handler); } /** @@ -1118,37 +1287,41 @@ public class NsharpEditor extends AbstractEditor implements IRenderableDisplayC skewtInputManager.unregisterMouseHandler(handler); } } + @Override public IDisplayPane[] getDisplayPanes() { - //System.out.println("SkewtEditor getDisplayPanes called"); - //return getDisplayPaneArray();//this.displayPane; - // changed for D2D - if(displayPane.length <=0) - try { - throw new VizException("Display pane is not available!"); - } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - IDisplayPane[] pan = { displayPane[DISPLAY_SKEWT]}; - return pan; - - + // System.out.println("SkewtEditor getDisplayPanes called"); + // return getDisplayPaneArray();//this.displayPane; + // changed for D2D + if (displayPane.length <= 0) + try { + throw new VizException("Display pane is not available!"); + } catch (VizException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + IDisplayPane[] pan = { displayPane[DISPLAY_Head] };// d2dlite + // DISPLAY_SKEWT] }; + return pan; + } + public IRenderableDisplay[] getRenderableDisplays() { IRenderableDisplay[] displays = new IRenderableDisplay[displayPane.length]; int i = 0; for (IDisplayPane pane : displayPane) { - displays[i++] = pane.getRenderableDisplay(); + if (pane != null) + displays[i++] = pane.getRenderableDisplay(); } return displays; } - + @Override public IEditorInput getEditorInput() { - // editorInput.setRenderableDisplays(getRenderableDisplays()); + // editorInput.setRenderableDisplays(getRenderableDisplays()); return editorInput; } + /** * Returns the mouse manager * @@ -1165,219 +1338,341 @@ public class NsharpEditor extends AbstractEditor implements IRenderableDisplayC */ @Override public IDisplayPane getActiveDisplayPane() { - return selectedPane; - //return this.displayPane[0]; + return selectedPane; + // return this.displayPane[0]; } - + @Override - public NCLoopProperties getLoopProperties(){ - // bsteffen added check for type and force it to NCLoopProperties + public NCLoopProperties getLoopProperties() { + // bsteffen added check for type and force it to NCLoopProperties LoopProperties loopProperties = this.editorInput.getLoopProperties(); - if(!(loopProperties instanceof NCLoopProperties)) { + if (!(loopProperties instanceof NCLoopProperties)) { this.editorInput.setLoopProperties(new NCLoopProperties()); } - return (NCLoopProperties)this.editorInput.getLoopProperties(); + return (NCLoopProperties) this.editorInput.getLoopProperties(); } - @Override - protected PaneManager getNewPaneManager() { - //return new PaneManager(); - return null; - } - private void initDisplayPublicParms(){ - if(paneConfigurationName.equals(NsharpConstants.PANE_SPCWS_CFG_STR)){ - //DISPLAY_SKEWT = 0; - DISPLAY_WITO= DISPLAY_SKEWT+1; - DISPLAY_INSET= DISPLAY_WITO+1; - DISPLAY_HODO= DISPLAY_INSET+1; - DISPLAY_DATA= DISPLAY_HODO+1; - DISPLAY_SPC_GRAPHS= DISPLAY_DATA+1; - DISPLAY_TOTAL= DISPLAY_SPC_GRAPHS+1; - DISPLAY_FUTURE = -1; - DISPLAY_TIMESTN = -1; - } else if(paneConfigurationName.equals(NsharpConstants.PANE_SIMPLE_D2D_CFG_STR)){ - //DISPLAY_SKEWT = 0; - DISPLAY_TIMESTN= DISPLAY_SKEWT+1; - DISPLAY_HODO= DISPLAY_TIMESTN+1; - DISPLAY_DATA=DISPLAY_HODO+1; - DISPLAY_FUTURE= DISPLAY_DATA+1; - DISPLAY_TOTAL= DISPLAY_FUTURE+1; - DISPLAY_WITO= -1; - DISPLAY_INSET= -1; - DISPLAY_SPC_GRAPHS = -1; - } - else { // case of default1 and default 2 pane configurations - //DISPLAY_SKEWT = 0; - DISPLAY_WITO= DISPLAY_SKEWT+1; - DISPLAY_INSET= DISPLAY_WITO+1; - DISPLAY_HODO= DISPLAY_INSET+1; - DISPLAY_TIMESTN= DISPLAY_HODO+1; - DISPLAY_DATA=DISPLAY_TIMESTN+1; - DISPLAY_TOTAL= DISPLAY_DATA+1; - DISPLAY_FUTURE = -1; - DISPLAY_SPC_GRAPHS = -1; - } - nsharpComp = new Composite[DISPLAY_TOTAL]; - displayPane = new VizDisplayPane[DISPLAY_TOTAL]; - displayArray = new IRenderableDisplay[DISPLAY_TOTAL]; - } - /* - * Note: initDisplayPublicParms() should be called before calling this function - */ - private IRenderableDisplay[] createRenderableDisplayArray(){ - if(paneConfigurationName.equals(NsharpConstants.PANE_SPCWS_CFG_STR)){ - - displayArray[DISPLAY_SKEWT]= new NsharpSkewTPaneDisplay(new PixelExtent(NsharpConstants.SKEWT_DISPLAY_REC),DISPLAY_SKEWT); - displayArray[DISPLAY_WITO]= new NsharpWitoPaneDisplay(new PixelExtent(NsharpConstants.WITO_DISPLAY_REC),DISPLAY_WITO); - displayArray[DISPLAY_HODO]= new NsharpHodoPaneDisplay(new PixelExtent(NsharpConstants.HODO_DISPLAY_REC),DISPLAY_HODO); - displayArray[DISPLAY_DATA]= new NsharpDataPaneDisplay(new PixelExtent(NsharpConstants.DATA_DISPLAY_REC),DISPLAY_DATA); - displayArray[DISPLAY_INSET]= new NsharpInsetPaneDisplay(new PixelExtent(NsharpConstants.INSET_DISPLAY_REC),DISPLAY_INSET); - displayArray[DISPLAY_SPC_GRAPHS]= new NsharpSpcGraphsPaneDisplay(new PixelExtent(NsharpConstants.SPC_GRAPH_DISPLAY_REC),DISPLAY_SPC_GRAPHS); - } else if(paneConfigurationName.equals(NsharpConstants.PANE_SIMPLE_D2D_CFG_STR)){ - displayArray[DISPLAY_SKEWT]= new NsharpSkewTPaneDisplay(new PixelExtent(NsharpConstants.SKEWT_DISPLAY_REC),DISPLAY_SKEWT); - displayArray[DISPLAY_HODO]= new NsharpHodoPaneDisplay(new PixelExtent(NsharpConstants.HODO_DISPLAY_REC),DISPLAY_HODO); - displayArray[DISPLAY_DATA]= new NsharpDataPaneDisplay(new PixelExtent(NsharpConstants.DATA_DISPLAY_REC),DISPLAY_DATA); - displayArray[DISPLAY_TIMESTN]= new NsharpTimeStnPaneDisplay(new PixelExtent(NsharpConstants.TIMESTN_DISPLAY_REC),DISPLAY_TIMESTN); - displayArray[DISPLAY_FUTURE]= new NsharpAbstractPaneDisplay(new PixelExtent(NsharpConstants.FUTURE_DISPLAY_REC),DISPLAY_FUTURE); - } - else { // case of default1 and default 2 pane configurations - displayArray[DISPLAY_SKEWT]= new NsharpSkewTPaneDisplay(new PixelExtent(NsharpConstants.SKEWT_DISPLAY_REC),DISPLAY_SKEWT); - displayArray[DISPLAY_WITO]= new NsharpWitoPaneDisplay(new PixelExtent(NsharpConstants.WITO_DISPLAY_REC),DISPLAY_WITO); - displayArray[DISPLAY_HODO]= new NsharpHodoPaneDisplay(new PixelExtent(NsharpConstants.HODO_DISPLAY_REC),DISPLAY_HODO); - displayArray[DISPLAY_DATA]= new NsharpDataPaneDisplay(new PixelExtent(NsharpConstants.DATA_DISPLAY_REC),DISPLAY_DATA); - displayArray[DISPLAY_INSET]= new NsharpInsetPaneDisplay(new PixelExtent(NsharpConstants.INSET_DISPLAY_REC),DISPLAY_INSET); - displayArray[DISPLAY_TIMESTN]= new NsharpTimeStnPaneDisplay(new PixelExtent(NsharpConstants.TIMESTN_DISPLAY_REC),DISPLAY_TIMESTN); - } - return displayArray; - } - /* - * Note: initDisplayPublicParms() and createRenderableDisplayArray() should be called before calling this function - */ - private void createPaneResource(){ - - ResourcePair skewtRscPair = displayArray[DISPLAY_SKEWT].getDescriptor().getResourceList().get(0); - NsharpSkewTPaneResource skewtPaneRsc=null; - if (skewtRscPair.getResource() instanceof NsharpSkewTPaneResource){ - skewtPaneRsc = (NsharpSkewTPaneResource)skewtRscPair.getResource() ; - skewtPaneRsc.setRscHandler(rscHandler); - } - ResourcePair dataRscPair = displayArray[DISPLAY_DATA].getDescriptor().getResourceList().get(0); - if (dataRscPair.getResource() instanceof NsharpDataPaneResource){ - NsharpDataPaneResource dataPaneRsc = (NsharpDataPaneResource)dataRscPair.getResource() ; - dataPaneRsc.setRscHandler(rscHandler); - } + @Override + protected PaneManager getNewPaneManager() { + // return new PaneManager(); + return null; + } - ResourcePair hodoRscPair = displayArray[DISPLAY_HODO].getDescriptor().getResourceList().get(0); - if (hodoRscPair.getResource() instanceof NsharpHodoPaneResource){ - NsharpHodoPaneResource hodoPaneRsc = (NsharpHodoPaneResource)hodoRscPair.getResource() ; - hodoPaneRsc.setRscHandler(rscHandler); - } + private void initDisplayPublicParms() { + if (paneConfigurationName.equals(NsharpConstants.PANE_SPCWS_CFG_STR)) { + DISPLAY_SKEWT = 0; + DISPLAY_WITO = DISPLAY_SKEWT + 1; + DISPLAY_INSET = DISPLAY_WITO + 1; + DISPLAY_HODO = DISPLAY_INSET + 1; + DISPLAY_DATA = DISPLAY_HODO + 1; + DISPLAY_SPC_GRAPHS = DISPLAY_DATA + 1; + DISPLAY_TOTAL = DISPLAY_SPC_GRAPHS + 1; + DISPLAY_FUTURE = -1; + DISPLAY_TIMESTN = -1; + } else if (paneConfigurationName + .equals(NsharpConstants.PANE_SIMPLE_D2D_CFG_STR)) { + DISPLAY_SKEWT = 0; + DISPLAY_TIMESTN = DISPLAY_SKEWT + 1; + DISPLAY_HODO = DISPLAY_TIMESTN + 1; + DISPLAY_DATA = DISPLAY_HODO + 1; + DISPLAY_FUTURE = DISPLAY_DATA + 1; + DISPLAY_TOTAL = DISPLAY_FUTURE + 1; + DISPLAY_WITO = -1; + DISPLAY_INSET = -1; + DISPLAY_SPC_GRAPHS = -1; + } else if (paneConfigurationName // d2dlite start + .equals(NsharpConstants.PANE_LITE_D2D_CFG_STR)) { + if (rscHandler != null + && rscHandler.getCurrentGraphMode() == NsharpConstants.GRAPH_HODO) { + DISPLAY_HODO = 0; + DISPLAY_TIMESTN = DISPLAY_HODO + 1; + DISPLAY_SKEWT = -1; + } else { + DISPLAY_SKEWT = 0; + DISPLAY_TIMESTN = DISPLAY_SKEWT + 1; + DISPLAY_HODO = -1; + } + DISPLAY_DATA = DISPLAY_TIMESTN + 1; + DISPLAY_TOTAL = DISPLAY_DATA + 1; + DISPLAY_FUTURE = -1; + DISPLAY_WITO = -1; + DISPLAY_INSET = -1; + DISPLAY_SPC_GRAPHS = -1; // d2dlite end + } else { // case of default1 and default 2 pane configurations + DISPLAY_SKEWT = 0; + DISPLAY_WITO = DISPLAY_SKEWT + 1; + DISPLAY_INSET = DISPLAY_WITO + 1; + DISPLAY_HODO = DISPLAY_INSET + 1; + DISPLAY_TIMESTN = DISPLAY_HODO + 1; + DISPLAY_DATA = DISPLAY_TIMESTN + 1; + DISPLAY_TOTAL = DISPLAY_DATA + 1; + DISPLAY_FUTURE = -1; + DISPLAY_SPC_GRAPHS = -1; + } + nsharpComp = new Composite[DISPLAY_TOTAL]; + displayPane = new VizDisplayPane[DISPLAY_TOTAL]; + displayArray = new IRenderableDisplay[DISPLAY_TOTAL]; + } - if(paneConfigurationName.equals(NsharpConstants.PANE_SPCWS_CFG_STR)|| - paneConfigurationName.equals(NsharpConstants.PANE_DEF_CFG_1_STR)|| - paneConfigurationName.equals(NsharpConstants.PANE_DEF_CFG_2_STR)){ - ResourcePair witoRscPair = displayArray[DISPLAY_WITO].getDescriptor().getResourceList().get(0); - if (witoRscPair.getResource() instanceof NsharpWitoPaneResource){ - NsharpWitoPaneResource witoPaneRsc = (NsharpWitoPaneResource)witoRscPair.getResource() ; - witoPaneRsc.setRscHandler(rscHandler); - } + /* + * Note: initDisplayPublicParms() should be called before calling this + * function + */ + private IRenderableDisplay[] createRenderableDisplayArray() { + if (paneConfigurationName.equals(NsharpConstants.PANE_SPCWS_CFG_STR)) { + displayArray[DISPLAY_SKEWT] = new NsharpSkewTPaneDisplay( + new PixelExtent(NsharpConstants.SKEWT_DISPLAY_REC), + DISPLAY_SKEWT); + displayArray[DISPLAY_WITO] = new NsharpWitoPaneDisplay( + new PixelExtent(NsharpConstants.WITO_DISPLAY_REC), + DISPLAY_WITO); + displayArray[DISPLAY_HODO] = new NsharpHodoPaneDisplay( + new PixelExtent(NsharpConstants.HODO_DISPLAY_REC), + DISPLAY_HODO); + displayArray[DISPLAY_DATA] = new NsharpDataPaneDisplay( + new PixelExtent(NsharpConstants.DATA_DISPLAY_REC), + DISPLAY_DATA); + displayArray[DISPLAY_INSET] = new NsharpInsetPaneDisplay( + new PixelExtent(NsharpConstants.INSET_DISPLAY_REC), + DISPLAY_INSET); + displayArray[DISPLAY_SPC_GRAPHS] = new NsharpSpcGraphsPaneDisplay( + new PixelExtent(NsharpConstants.SPC_GRAPH_DISPLAY_REC), + DISPLAY_SPC_GRAPHS); + } else if (paneConfigurationName + .equals(NsharpConstants.PANE_SIMPLE_D2D_CFG_STR)) { + displayArray[DISPLAY_SKEWT] = new NsharpSkewTPaneDisplay( + new PixelExtent(NsharpConstants.SKEWT_DISPLAY_REC), + DISPLAY_SKEWT); + displayArray[DISPLAY_HODO] = new NsharpHodoPaneDisplay( + new PixelExtent(NsharpConstants.HODO_DISPLAY_REC), + DISPLAY_HODO); + displayArray[DISPLAY_DATA] = new NsharpDataPaneDisplay( + new PixelExtent(NsharpConstants.DATA_DISPLAY_REC), + DISPLAY_DATA); + displayArray[DISPLAY_TIMESTN] = new NsharpTimeStnPaneDisplay( + new PixelExtent(NsharpConstants.TIMESTN_DISPLAY_REC), + DISPLAY_TIMESTN); + displayArray[DISPLAY_FUTURE] = new NsharpAbstractPaneDisplay( + new PixelExtent(NsharpConstants.FUTURE_DISPLAY_REC), + DISPLAY_FUTURE); + // d2dlite start + } else if (paneConfigurationName + .equals(NsharpConstants.PANE_LITE_D2D_CFG_STR)) { + if (rscHandler != null + && rscHandler.getCurrentGraphMode() == NsharpConstants.GRAPH_HODO) { + displayArray[DISPLAY_HODO] = new NsharpHodoPaneDisplay( + new PixelExtent(NsharpConstants.HODO_DISPLAY_REC), + DISPLAY_HODO); + } else { + displayArray[DISPLAY_SKEWT] = new NsharpSkewTPaneDisplay( + new PixelExtent(NsharpConstants.SKEWT_DISPLAY_REC), + DISPLAY_SKEWT); + } + displayArray[DISPLAY_TIMESTN] = new NsharpTimeStnPaneDisplay( + new PixelExtent(NsharpConstants.TIMESTN_DISPLAY_REC), + DISPLAY_TIMESTN); + displayArray[DISPLAY_DATA] = new NsharpDataPaneDisplay( + new PixelExtent(NsharpConstants.DATA_DISPLAY_REC), + DISPLAY_DATA); - ResourcePair insetRscPair = displayArray[DISPLAY_INSET].getDescriptor().getResourceList().get(0); - if (insetRscPair.getResource() instanceof NsharpInsetPaneResource){ - NsharpInsetPaneResource insetPaneRsc = (NsharpInsetPaneResource)insetRscPair.getResource() ; - insetPaneRsc.setRscHandler(rscHandler); - } - } - if(paneConfigurationName.equals(NsharpConstants.PANE_SPCWS_CFG_STR)){ - ResourcePair spcGraphRscPair = displayArray[DISPLAY_SPC_GRAPHS].getDescriptor().getResourceList().get(0); - if (spcGraphRscPair.getResource() instanceof NsharpSpcGraphsPaneResource){ - NsharpSpcGraphsPaneResource spcPaneRsc = (NsharpSpcGraphsPaneResource)spcGraphRscPair.getResource() ; - spcPaneRsc.setRscHandler(rscHandler); - } - } - if(paneConfigurationName.equals(NsharpConstants.PANE_SIMPLE_D2D_CFG_STR)){ - ResourcePair futureRscPair = displayArray[DISPLAY_FUTURE].getDescriptor().getResourceList().get(0); - if (futureRscPair.getResource() instanceof NsharpAbstractPaneResource){ - NsharpAbstractPaneResource futurePaneRsc = (NsharpAbstractPaneResource)futureRscPair.getResource() ; - futurePaneRsc.setRscHandler(rscHandler); - } - } - if(paneConfigurationName.equals(NsharpConstants.PANE_SIMPLE_D2D_CFG_STR)|| - paneConfigurationName.equals(NsharpConstants.PANE_DEF_CFG_1_STR)|| - paneConfigurationName.equals(NsharpConstants.PANE_DEF_CFG_2_STR)){ - ResourcePair timeStnRscPair = displayArray[DISPLAY_TIMESTN].getDescriptor().getResourceList().get(0); - if (timeStnRscPair.getResource() instanceof NsharpTimeStnPaneResource){ - NsharpTimeStnPaneResource timeStnPaneRsc = (NsharpTimeStnPaneResource)timeStnRscPair.getResource() ; - timeStnPaneRsc.setRscHandler(rscHandler); - } - } - if(skewtPaneRsc!=null){ - skewtPaneRsc.setCurrentGraphMode(rscHandler.getCurrentGraphMode()); - //skewtPaneRsc.handleResize(); - } - } - - private void updateEditor() { - initDisplayPublicParms(); - createRenderableDisplayArray(); - nsharpComp = new Composite[DISPLAY_TOTAL]; - displayPane = new VizDisplayPane[DISPLAY_TOTAL]; - - EditorInput edInput = new EditorInput(new NCLoopProperties(), - displayArray); + // d2dlite end + } else { // case of default1 and default 2 pane configurations + displayArray[DISPLAY_SKEWT] = new NsharpSkewTPaneDisplay( + new PixelExtent(NsharpConstants.SKEWT_DISPLAY_REC), + DISPLAY_SKEWT); + displayArray[DISPLAY_WITO] = new NsharpWitoPaneDisplay( + new PixelExtent(NsharpConstants.WITO_DISPLAY_REC), + DISPLAY_WITO); + displayArray[DISPLAY_HODO] = new NsharpHodoPaneDisplay( + new PixelExtent(NsharpConstants.HODO_DISPLAY_REC), + DISPLAY_HODO); + displayArray[DISPLAY_DATA] = new NsharpDataPaneDisplay( + new PixelExtent(NsharpConstants.DATA_DISPLAY_REC), + DISPLAY_DATA); + displayArray[DISPLAY_INSET] = new NsharpInsetPaneDisplay( + new PixelExtent(NsharpConstants.INSET_DISPLAY_REC), + DISPLAY_INSET); + displayArray[DISPLAY_TIMESTN] = new NsharpTimeStnPaneDisplay( + new PixelExtent(NsharpConstants.TIMESTN_DISPLAY_REC), + DISPLAY_TIMESTN); + } + return displayArray; + } - this.setInput(edInput); - this.displaysToLoad = displayArray; - for (IRenderableDisplay display : displayArray) { - if (display != null) { - this.initDisplay(display); - } - } - rscHandler.updateDisplay(displayArray,paneConfigurationName); - rscHandler.resetRscSoundingData(); + /* + * Note: initDisplayPublicParms() and createRenderableDisplayArray() should + * be called before calling this function + */ + private void createPaneResource() { + NsharpSkewTPaneResource skewtPaneRsc = null; + if ((!paneConfigurationName + .equals(NsharpConstants.PANE_LITE_D2D_CFG_STR)) + || (paneConfigurationName + .equals(NsharpConstants.PANE_LITE_D2D_CFG_STR) && rscHandler + .getCurrentGraphMode() != NsharpConstants.GRAPH_HODO)) { // d2dlite + ResourcePair skewtRscPair = displayArray[DISPLAY_SKEWT] + .getDescriptor().getResourceList().get(0); - createPaneResource(); - - } - public static NsharpEditor createOrOpenEditor( ) { - NsharpEditor editor = getActiveNsharpEditor(); - if (editor != null) { - //System.out.println("createOrOpenSkewTEditor return existing editor "+ editor.toString()); - return editor; - } else { - try { - /* - * Chin note: all initialization logics now are done in init() method to support standard eclipse - * Editor open procedure. - * At init(), display array and EditorInput will be created based on user configured pane configuration. - * Therefore, we just create a dummy EditorInput here. - * The following IWorkbenchPage.openEditor() will eventually invoke init() method. - */ - IRenderableDisplay[] tempDisp = new IRenderableDisplay[1]; - tempDisp[0] = new NsharpSkewTPaneDisplay(new PixelExtent(NsharpConstants.SKEWT_DISPLAY_REC),0); - EditorInput edInput = new EditorInput(new NCLoopProperties(), - tempDisp); - editor = (NsharpEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() - .openEditor(edInput, EDITOR_ID); - - } catch (PartInitException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - //System.out.println("createOrOpenSkewTEditor return new editor "+ editor.toString()); - return editor; - } - } - public static void bringEditorToTop( ) { - NsharpEditor editor = getActiveNsharpEditor(); + if (skewtRscPair.getResource() instanceof NsharpSkewTPaneResource) { + skewtPaneRsc = (NsharpSkewTPaneResource) skewtRscPair + .getResource(); + skewtPaneRsc.setRscHandler(rscHandler); + } + + } + ResourcePair dataRscPair = displayArray[DISPLAY_DATA].getDescriptor() + .getResourceList().get(0); + if (dataRscPair.getResource() instanceof NsharpDataPaneResource) { + NsharpDataPaneResource dataPaneRsc = (NsharpDataPaneResource) dataRscPair + .getResource(); + dataPaneRsc.setRscHandler(rscHandler); + } + if ((!paneConfigurationName + .equals(NsharpConstants.PANE_LITE_D2D_CFG_STR)) + || (paneConfigurationName + .equals(NsharpConstants.PANE_LITE_D2D_CFG_STR) && rscHandler + .getCurrentGraphMode() == NsharpConstants.GRAPH_HODO)) { // d2dlite + ResourcePair hodoRscPair = displayArray[DISPLAY_HODO] + .getDescriptor().getResourceList().get(0); + if (hodoRscPair.getResource() instanceof NsharpHodoPaneResource) { + NsharpHodoPaneResource hodoPaneRsc = (NsharpHodoPaneResource) hodoRscPair + .getResource(); + hodoPaneRsc.setRscHandler(rscHandler); + } + } // d2dlite + + if (paneConfigurationName.equals(NsharpConstants.PANE_SPCWS_CFG_STR) + || paneConfigurationName + .equals(NsharpConstants.PANE_DEF_CFG_1_STR) + || paneConfigurationName + .equals(NsharpConstants.PANE_DEF_CFG_2_STR)) { + ResourcePair witoRscPair = displayArray[DISPLAY_WITO] + .getDescriptor().getResourceList().get(0); + if (witoRscPair.getResource() instanceof NsharpWitoPaneResource) { + NsharpWitoPaneResource witoPaneRsc = (NsharpWitoPaneResource) witoRscPair + .getResource(); + witoPaneRsc.setRscHandler(rscHandler); + } + + ResourcePair insetRscPair = displayArray[DISPLAY_INSET] + .getDescriptor().getResourceList().get(0); + if (insetRscPair.getResource() instanceof NsharpInsetPaneResource) { + NsharpInsetPaneResource insetPaneRsc = (NsharpInsetPaneResource) insetRscPair + .getResource(); + insetPaneRsc.setRscHandler(rscHandler); + } + } + if (paneConfigurationName.equals(NsharpConstants.PANE_SPCWS_CFG_STR)) { + ResourcePair spcGraphRscPair = displayArray[DISPLAY_SPC_GRAPHS] + .getDescriptor().getResourceList().get(0); + if (spcGraphRscPair.getResource() instanceof NsharpSpcGraphsPaneResource) { + NsharpSpcGraphsPaneResource spcPaneRsc = (NsharpSpcGraphsPaneResource) spcGraphRscPair + .getResource(); + spcPaneRsc.setRscHandler(rscHandler); + } + } + if (paneConfigurationName + .equals(NsharpConstants.PANE_SIMPLE_D2D_CFG_STR)) { + ResourcePair futureRscPair = displayArray[DISPLAY_FUTURE] + .getDescriptor().getResourceList().get(0); + if (futureRscPair.getResource() instanceof NsharpAbstractPaneResource) { + NsharpAbstractPaneResource futurePaneRsc = (NsharpAbstractPaneResource) futureRscPair + .getResource(); + futurePaneRsc.setRscHandler(rscHandler); + } + } + if (paneConfigurationName + .equals(NsharpConstants.PANE_SIMPLE_D2D_CFG_STR) + || paneConfigurationName + .equals(NsharpConstants.PANE_LITE_D2D_CFG_STR) // d2dlite + || paneConfigurationName + .equals(NsharpConstants.PANE_DEF_CFG_1_STR) + || paneConfigurationName + .equals(NsharpConstants.PANE_DEF_CFG_2_STR)) { + ResourcePair timeStnRscPair = displayArray[DISPLAY_TIMESTN] + .getDescriptor().getResourceList().get(0); + if (timeStnRscPair.getResource() instanceof NsharpTimeStnPaneResource) { + NsharpTimeStnPaneResource timeStnPaneRsc = (NsharpTimeStnPaneResource) timeStnRscPair + .getResource(); + timeStnPaneRsc.setRscHandler(rscHandler); + } + } + if (skewtPaneRsc != null) { + skewtPaneRsc.setCurrentGraphMode(rscHandler.getCurrentGraphMode()); + // skewtPaneRsc.handleResize(); + } + } + + private void updateEditor() { + initDisplayPublicParms(); + createRenderableDisplayArray(); + nsharpComp = new Composite[DISPLAY_TOTAL]; + displayPane = new VizDisplayPane[DISPLAY_TOTAL]; + + EditorInput edInput = new EditorInput(new NCLoopProperties(), + displayArray); + + this.setInput(edInput); + this.displaysToLoad = displayArray; + for (IRenderableDisplay display : displayArray) { + if (display != null) { + this.initDisplay(display); + } + } + rscHandler.updateDisplay(displayArray, paneConfigurationName); + rscHandler.resetRscSoundingData(); + + createPaneResource(); + + } + + public static NsharpEditor createOrOpenEditor() { + NsharpEditor editor = getActiveNsharpEditor(); + if (editor != null) { + // System.out.println("createOrOpenSkewTEditor return existing editor "+ + // editor.toString()); + return editor; + } else { + try { + /* + * Chin note: all initialization logics now are done in init() + * method to support standard eclipse Editor open procedure. At + * init(), display array and EditorInput will be created based + * on user configured pane configuration. Therefore, we just + * create a dummy EditorInput here. The following + * IWorkbenchPage.openEditor() will eventually invoke init() + * method. + */ + IRenderableDisplay[] tempDisp = new IRenderableDisplay[1]; + tempDisp[0] = new NsharpSkewTPaneDisplay(new PixelExtent( + NsharpConstants.SKEWT_DISPLAY_REC), 0); + EditorInput edInput = new EditorInput(new NCLoopProperties(), + tempDisp); + editor = (NsharpEditor) PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getActivePage() + .openEditor(edInput, EDITOR_ID); + + } catch (PartInitException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + // System.out.println("createOrOpenSkewTEditor return new editor "+ + // editor.toString()); + return editor; + } + } + + public static void bringEditorToTop() { + NsharpEditor editor = getActiveNsharpEditor(); if (editor != null) { PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getActivePage().bringToTop(editor); - - } - } - public void refreshGUIElements() { + + } + } + + public void refreshGUIElements() { ICommandService service = (ICommandService) getSite().getService( ICommandService.class); String[] guiUpdateElementCommands = { @@ -1397,291 +1692,325 @@ public class NsharpEditor extends AbstractEditor implements IRenderableDisplayC } - public VizDisplayPane getSelectedPane() { - return selectedPane; - } - public void setSelectedPane(VizDisplayPane selectedPane) { - this.selectedPane = selectedPane; - } - - public int getBaseWidth() { - return baseWidth; - } - public int getBaseHeight() { - return baseHeight; - } - - class PaneMouseListener implements Listener { - private int paneIndex; - - public PaneMouseListener(int index) { - super(); - this.paneIndex = index; - } + public VizDisplayPane getSelectedPane() { + return selectedPane; + } - @Override - public void handleEvent(Event e) { - if ( e.button==0 ) { - selectedPane = displayPane[paneIndex]; - } - } - } + public void setSelectedPane(VizDisplayPane selectedPane) { + this.selectedPane = selectedPane; + } - class ResizeListener implements Listener { - private String paneConfigurationName=""; - - - public ResizeListener(String name) { - super(); - this.paneConfigurationName = name; - } + public int getBaseWidth() { + return baseWidth; + } + public int getBaseHeight() { + return baseHeight; + } - @Override + class PaneMouseListener implements Listener { + private int paneIndex; + + public PaneMouseListener(int index) { + super(); + this.paneIndex = index; + } + + @Override + public void handleEvent(Event e) { + if (e.button == 0) { + selectedPane = displayPane[paneIndex]; + } + } + } + + class ResizeListener implements Listener { + private String paneConfigurationName = ""; + + public ResizeListener(String name) { + super(); + this.paneConfigurationName = name; + } + + @Override public void handleEvent(Event event) { - baseHeight = baseComposite.getSize().y; - baseWidth = baseComposite.getSize().x; - //System.out.println("ResizeListener resizing...nsharp base w= " + baseWidth + " h= "+ baseHeight); - if(paneConfigurationName.equals(NsharpConstants.PANE_DEF_CFG_2_STR)){ - skewTHeightHint = (int) (baseHeight * skewTHeightHintRatio); - skewTWidthHint = (int) (baseWidth*leftGroupWidthRatio *skewTWidthHintRatio); - witoHeightHint = (int) (baseHeight * witoHeightHintRatio); - witoWidthHint = (int) (baseWidth*leftGroupWidthRatio *witoWidthHintRatio); - hodoHeightHint = (int) (baseHeight * hodoHeightHintRatio); - hodoWidthHint = (int) (baseWidth*(1-leftGroupWidthRatio) *hodoWidthHintRatio); - insetHeightHint = (int) (baseHeight * insetHeightHintRatio); - insetWidthHint = (int) (baseWidth*(leftGroupWidthRatio) *insetWidthHintRatio); - timeStnHeightHint = (int) (baseHeight * timeStnHeightHintRatio); - timeStnWidthHint = (int) (baseWidth*(1-leftGroupWidthRatio) *timeStnWidthHintRatio); - dataHeightHint = (int) (baseHeight * dataHeightHintRatio); - dataWidthHint = (int) (baseWidth*(1-leftGroupWidthRatio) *dataWidthHintRatio); - } else if(paneConfigurationName.equals(NsharpConstants.PANE_DEF_CFG_1_STR)){ - skewTHeightHint = (int) (baseHeight * skewTHeightHintRatio); - skewTWidthHint = (int) (baseWidth*leftGroupWidthRatio *skewTWidthHintRatio); - witoHeightHint = (int) (baseHeight * witoHeightHintRatio); - witoWidthHint = (int) (baseWidth*leftGroupWidthRatio *witoWidthHintRatio); - hodoHeightHint = (int) (baseHeight * hodoHeightHintRatio); - hodoWidthHint = (int) (baseWidth*(1-leftGroupWidthRatio) *hodoWidthHintRatio); - insetHeightHint = (int) (baseHeight * insetHeightHintRatio); - insetWidthHint = (int) (baseWidth*(leftGroupWidthRatio) *insetWidthHintRatio); - timeStnHeightHint = (int) (baseHeight * timeStnHeightHintRatio); - timeStnWidthHint = (int) (baseWidth*(leftGroupWidthRatio) *timeStnWidthHintRatio); - dataHeightHint = (int) (baseHeight * dataHeightHintRatio); - dataWidthHint = (int) (baseWidth*(1-leftGroupWidthRatio) *dataWidthHintRatio); - } - else if(paneConfigurationName.equals(NsharpConstants.PANE_SPCWS_CFG_STR)){ - skewTHeightHint = (int) (baseHeight * topGroupHeightRatio* skewTHeightHintRatio); - skewTWidthHint = (int) (baseWidth*skewTWidthHintRatio); - witoHeightHint = (int) (baseHeight * topGroupHeightRatio * witoHeightHintRatio); - witoWidthHint = (int) (baseWidth*witoWidthHintRatio); - hodoHeightHint = (int) (baseHeight *topGroupHeightRatio* hodoHeightHintRatio); - hodoWidthHint = (int) (baseWidth*hodoWidthHintRatio); - insetHeightHint = (int) (baseHeight * topGroupHeightRatio* insetHeightHintRatio); - insetWidthHint = (int) (baseWidth*insetWidthHintRatio); - dataHeightHint = (int) (baseHeight * botGroupHeightRatio*dataHeightHintRatio); - dataWidthHint = (int) (baseWidth*dataWidthHintRatio); - spcHeightHint = (int) (baseHeight * botGroupHeightRatio*dataHeightHintRatio); - spcWidthHint = (int) (baseWidth*dataWidthHintRatio); - } - else if(paneConfigurationName.equals(NsharpConstants.PANE_SIMPLE_D2D_CFG_STR)){ - skewTHeightHint = (int) (baseHeight * topGroupHeightRatio* skewTHeightHintRatio); - skewTWidthHint = (int) (baseWidth*skewTWidthHintRatio); - timeStnHeightHint = (int) (baseHeight * topGroupHeightRatio* timeStnHeightHintRatio); - timeStnWidthHint = (int) (baseWidth* timeStnWidthHintRatio); - futureHeightHint = (int) (baseHeight * topGroupHeightRatio* (1-timeStnHeightHintRatio)); - futureWidthHint = timeStnWidthHint; - dataHeightHint = (int) (baseHeight * botGroupHeightRatio*dataHeightHintRatio); - dataWidthHint = (int) (baseWidth* dataWidthHintRatio); - hodoHeightHint = (int) (baseHeight *botGroupHeightRatio* hodoHeightHintRatio); - hodoWidthHint = (int) (baseWidth*hodoWidthHintRatio); - } - - if(paneConfigurationName.equals(NsharpConstants.PANE_DEF_CFG_2_STR) || paneConfigurationName.equals(NsharpConstants.PANE_DEF_CFG_1_STR)){ - leftGpGd = new GridData(SWT.FILL, SWT.FILL, true, - true); - leftGpGd.widthHint = (int) (baseWidth*leftGroupWidthRatio); - leftGp.setLayoutData(leftGpGd); + baseHeight = baseComposite.getSize().y; + baseWidth = baseComposite.getSize().x; + // System.out.println("ResizeListener resizing...nsharp base w= " + + // baseWidth + " h= "+ baseHeight); + if (paneConfigurationName + .equals(NsharpConstants.PANE_DEF_CFG_2_STR)) { + skewTHeightHint = (int) (baseHeight * skewTHeightHintRatio); + skewTWidthHint = (int) (baseWidth * leftGroupWidthRatio * skewTWidthHintRatio); + witoHeightHint = (int) (baseHeight * witoHeightHintRatio); + witoWidthHint = (int) (baseWidth * leftGroupWidthRatio * witoWidthHintRatio); + hodoHeightHint = (int) (baseHeight * hodoHeightHintRatio); + hodoWidthHint = (int) (baseWidth * (1 - leftGroupWidthRatio) * hodoWidthHintRatio); + insetHeightHint = (int) (baseHeight * insetHeightHintRatio); + insetWidthHint = (int) (baseWidth * (leftGroupWidthRatio) * insetWidthHintRatio); + timeStnHeightHint = (int) (baseHeight * timeStnHeightHintRatio); + timeStnWidthHint = (int) (baseWidth * (1 - leftGroupWidthRatio) * timeStnWidthHintRatio); + dataHeightHint = (int) (baseHeight * dataHeightHintRatio); + dataWidthHint = (int) (baseWidth * (1 - leftGroupWidthRatio) * dataWidthHintRatio); + } else if (paneConfigurationName + .equals(NsharpConstants.PANE_DEF_CFG_1_STR)) { + skewTHeightHint = (int) (baseHeight * skewTHeightHintRatio); + skewTWidthHint = (int) (baseWidth * leftGroupWidthRatio * skewTWidthHintRatio); + witoHeightHint = (int) (baseHeight * witoHeightHintRatio); + witoWidthHint = (int) (baseWidth * leftGroupWidthRatio * witoWidthHintRatio); + hodoHeightHint = (int) (baseHeight * hodoHeightHintRatio); + hodoWidthHint = (int) (baseWidth * (1 - leftGroupWidthRatio) * hodoWidthHintRatio); + insetHeightHint = (int) (baseHeight * insetHeightHintRatio); + insetWidthHint = (int) (baseWidth * (leftGroupWidthRatio) * insetWidthHintRatio); + timeStnHeightHint = (int) (baseHeight * timeStnHeightHintRatio); + timeStnWidthHint = (int) (baseWidth * (leftGroupWidthRatio) * timeStnWidthHintRatio); + dataHeightHint = (int) (baseHeight * dataHeightHintRatio); + dataWidthHint = (int) (baseWidth * (1 - leftGroupWidthRatio) * dataWidthHintRatio); + } else if (paneConfigurationName + .equals(NsharpConstants.PANE_SPCWS_CFG_STR)) { + skewTHeightHint = (int) (baseHeight * topGroupHeightRatio * skewTHeightHintRatio); + skewTWidthHint = (int) (baseWidth * skewTWidthHintRatio); + witoHeightHint = (int) (baseHeight * topGroupHeightRatio * witoHeightHintRatio); + witoWidthHint = (int) (baseWidth * witoWidthHintRatio); + hodoHeightHint = (int) (baseHeight * topGroupHeightRatio * hodoHeightHintRatio); + hodoWidthHint = (int) (baseWidth * hodoWidthHintRatio); + insetHeightHint = (int) (baseHeight * topGroupHeightRatio * insetHeightHintRatio); + insetWidthHint = (int) (baseWidth * insetWidthHintRatio); + dataHeightHint = (int) (baseHeight * botGroupHeightRatio * dataHeightHintRatio); + dataWidthHint = (int) (baseWidth * dataWidthHintRatio); + spcHeightHint = (int) (baseHeight * botGroupHeightRatio * dataHeightHintRatio); + spcWidthHint = (int) (baseWidth * dataWidthHintRatio); + } else if (paneConfigurationName + .equals(NsharpConstants.PANE_SIMPLE_D2D_CFG_STR)) { + skewTHeightHint = (int) (baseHeight * topGroupHeightRatio * skewTHeightHintRatio); + skewTWidthHint = (int) (baseWidth * skewTWidthHintRatio); + timeStnHeightHint = (int) (baseHeight * topGroupHeightRatio * timeStnHeightHintRatio); + timeStnWidthHint = (int) (baseWidth * timeStnWidthHintRatio); + futureHeightHint = (int) (baseHeight * topGroupHeightRatio * (1 - timeStnHeightHintRatio)); + futureWidthHint = timeStnWidthHint; + dataHeightHint = (int) (baseHeight * botGroupHeightRatio * dataHeightHintRatio); + dataWidthHint = (int) (baseWidth * dataWidthHintRatio); + hodoHeightHint = (int) (baseHeight * botGroupHeightRatio * hodoHeightHintRatio); + hodoWidthHint = (int) (baseWidth * hodoWidthHintRatio); + } + // d2dlite start + else if (paneConfigurationName + .equals(NsharpConstants.PANE_LITE_D2D_CFG_STR)) { + skewTHeightHint = (int) (baseHeight * topGroupHeightRatio * skewTHeightHintRatio); + skewTWidthHint = (int) (baseWidth * skewTWidthHintRatio); + // skewt and hodo share same pane real estate + hodoHeightHint = (int) (baseHeight * topGroupHeightRatio * skewTHeightHintRatio); + hodoWidthHint = (int) (baseWidth * skewTWidthHintRatio); + timeStnHeightHint = (int) (baseHeight * topGroupHeightRatio * timeStnHeightHintRatio); + timeStnWidthHint = (int) (baseWidth * timeStnWidthHintRatio); + dataHeightHint = (int) (baseHeight * topGroupHeightRatio * (1 - timeStnHeightHintRatio)); + dataWidthHint = timeStnWidthHint; + } // d2dlite end - rightGpGd = new GridData(SWT.FILL, SWT.FILL, true, - true); - rightGpGd.widthHint = (int) (baseWidth*(1-leftGroupWidthRatio)); - rightGp.setLayoutData(rightGpGd); + if (paneConfigurationName + .equals(NsharpConstants.PANE_DEF_CFG_2_STR) + || paneConfigurationName + .equals(NsharpConstants.PANE_DEF_CFG_1_STR)) { + leftGpGd = new GridData(SWT.FILL, SWT.FILL, true, true); + leftGpGd.widthHint = (int) (baseWidth * leftGroupWidthRatio); + leftGp.setLayoutData(leftGpGd); - leftTopGpGd = new GridData(SWT.FILL, SWT.FILL, true, - true); - leftTopGpGd.heightHint = (int) (baseHeight *leftTopGroupHeightRatio); - leftTopGp.setLayoutData(leftTopGpGd); - if(leftBotGp!=null){ - leftBotGpGd = new GridData(SWT.FILL, SWT.FILL, true, - true); - leftBotGpGd.heightHint = (int) (baseHeight *(1-leftTopGroupHeightRatio)); - leftBotGp.setLayoutData(leftBotGpGd); - } - GridData skewtGd = new GridData(SWT.FILL, SWT.FILL, true, - true);//gridDataArray[DISPLAY_SKEWT]; - skewtGd.heightHint = skewTHeightHint; - skewtGd.widthHint = skewTWidthHint; - nsharpComp[DISPLAY_SKEWT].setLayoutData(skewtGd); - GridData witoGd = new GridData(SWT.FILL, SWT.FILL, true, - true);//gridDataArray[DISPLAY_WITO]; - witoGd.heightHint = witoHeightHint; - witoGd.widthHint = witoWidthHint; - nsharpComp[DISPLAY_WITO].setLayoutData(witoGd); + rightGpGd = new GridData(SWT.FILL, SWT.FILL, true, true); + rightGpGd.widthHint = (int) (baseWidth * (1 - leftGroupWidthRatio)); + rightGp.setLayoutData(rightGpGd); - GridData timeStnGd = new GridData(SWT.FILL, SWT.FILL, true, - true);//gridDataArray[DISPLAY_TIMESTN]; - timeStnGd.heightHint = timeStnHeightHint; - timeStnGd.widthHint = timeStnWidthHint; - nsharpComp[DISPLAY_TIMESTN].setLayoutData(timeStnGd); - GridData insetGd = new GridData(SWT.FILL, SWT.FILL, true, - true);//gridDataArray[DISPLAY_INSET]; - insetGd.heightHint = insetHeightHint; - insetGd.widthHint = insetWidthHint; - nsharpComp[DISPLAY_INSET].setLayoutData(insetGd); + leftTopGpGd = new GridData(SWT.FILL, SWT.FILL, true, true); + leftTopGpGd.heightHint = (int) (baseHeight * leftTopGroupHeightRatio); + leftTopGp.setLayoutData(leftTopGpGd); + if (leftBotGp != null) { + leftBotGpGd = new GridData(SWT.FILL, SWT.FILL, true, true); + leftBotGpGd.heightHint = (int) (baseHeight * (1 - leftTopGroupHeightRatio)); + leftBotGp.setLayoutData(leftBotGpGd); + } + GridData skewtGd = new GridData(SWT.FILL, SWT.FILL, true, true);// gridDataArray[DISPLAY_SKEWT]; + skewtGd.heightHint = skewTHeightHint; + skewtGd.widthHint = skewTWidthHint; + nsharpComp[DISPLAY_SKEWT].setLayoutData(skewtGd); + GridData witoGd = new GridData(SWT.FILL, SWT.FILL, true, true);// gridDataArray[DISPLAY_WITO]; + witoGd.heightHint = witoHeightHint; + witoGd.widthHint = witoWidthHint; + nsharpComp[DISPLAY_WITO].setLayoutData(witoGd); - GridData hodoGd = new GridData(SWT.FILL, SWT.FILL, true, - true);//gridDataArray[DISPLAY_HODO]; - hodoGd.heightHint = hodoHeightHint; - hodoGd.widthHint = hodoWidthHint; - nsharpComp[DISPLAY_HODO].setLayoutData(hodoGd); + GridData timeStnGd = new GridData(SWT.FILL, SWT.FILL, true, + true);// gridDataArray[DISPLAY_TIMESTN]; + timeStnGd.heightHint = timeStnHeightHint; + timeStnGd.widthHint = timeStnWidthHint; + nsharpComp[DISPLAY_TIMESTN].setLayoutData(timeStnGd); + GridData insetGd = new GridData(SWT.FILL, SWT.FILL, true, true);// gridDataArray[DISPLAY_INSET]; + insetGd.heightHint = insetHeightHint; + insetGd.widthHint = insetWidthHint; + nsharpComp[DISPLAY_INSET].setLayoutData(insetGd); - GridData dataGd = new GridData(SWT.FILL, SWT.FILL, true, - true);//gridDataArray[DISPLAY_DATA]; - dataGd.heightHint = dataHeightHint; - dataGd.widthHint = dataWidthHint; - nsharpComp[DISPLAY_DATA].setLayoutData(dataGd); + GridData hodoGd = new GridData(SWT.FILL, SWT.FILL, true, true);// gridDataArray[DISPLAY_HODO]; + hodoGd.heightHint = hodoHeightHint; + hodoGd.widthHint = hodoWidthHint; + nsharpComp[DISPLAY_HODO].setLayoutData(hodoGd); - }else if(paneConfigurationName.equals(NsharpConstants.PANE_SPCWS_CFG_STR)){ - topGpGd = new GridData(SWT.FILL, SWT.FILL, true, - true); - topGpGd.heightHint = (int) (baseHeight * topGroupHeightRatio); - topGp.setLayoutData(topGpGd); - - // skewt composite - GridData skewtGd = new GridData(SWT.FILL, SWT.FILL, true, - true); - skewtGd.heightHint = skewTHeightHint; - skewtGd.widthHint = skewTWidthHint; - nsharpComp[DISPLAY_SKEWT].setLayoutData(skewtGd); - - - // wito composite - GridData witoGd = new GridData(SWT.FILL, SWT.FILL, true, - true); - witoGd.heightHint = witoHeightHint; - witoGd.widthHint = witoWidthHint; - nsharpComp[DISPLAY_WITO].setLayoutData(witoGd); - - // right-top group : right part of top group - rightTopGpGd = new GridData(SWT.FILL, SWT.FILL, true, - true); - rightTopGpGd.widthHint = (int) (baseWidth*hodoWidthHintRatio); - rightTopGp.setLayoutData(rightTopGpGd); - - //hodo composite - GridData hodoGd = new GridData(SWT.FILL, SWT.FILL, true, - true); - hodoGd.heightHint = hodoHeightHint; - hodoGd.widthHint = hodoWidthHint; - nsharpComp[DISPLAY_HODO].setLayoutData(hodoGd); - - - //inset composite - GridData insetGd = new GridData(SWT.FILL, SWT.FILL, true, - true); - insetGd.heightHint = insetHeightHint; - insetGd.widthHint = insetWidthHint; - nsharpComp[DISPLAY_INSET].setLayoutData(insetGd); - /* - //time-stn composite - Composite timeStnComp = new Composite(rightTopGp, SWT.NONE); - GridData timeStnGd = new GridData(SWT.END, SWT.FILL, false, - true); - timeStnComp.setLayoutData(timeStnGd); - */ - - botGpGd = new GridData(SWT.FILL, SWT.END, true, - true); - botGpGd.heightHint = (int) (baseHeight * botGroupHeightRatio); - botGp.setLayoutData(botGpGd); - //data composite - GridData dataGd = new GridData(SWT.FILL, SWT.FILL, true, - false); - dataGd.heightHint = dataHeightHint; - dataGd.widthHint = dataWidthHint; - nsharpComp[DISPLAY_DATA].setLayoutData(dataGd); - //spc composite - GridData spcGd = new GridData(SWT.FILL, SWT.FILL, true, - false); - spcGd.heightHint = spcHeightHint; - spcGd.widthHint = spcWidthHint; - nsharpComp[DISPLAY_SPC_GRAPHS].setLayoutData(spcGd); + GridData dataGd = new GridData(SWT.FILL, SWT.FILL, true, true);// gridDataArray[DISPLAY_DATA]; + dataGd.heightHint = dataHeightHint; + dataGd.widthHint = dataWidthHint; + nsharpComp[DISPLAY_DATA].setLayoutData(dataGd); - } else if(paneConfigurationName.equals(NsharpConstants.PANE_SIMPLE_D2D_CFG_STR)){ - topGpGd = new GridData(SWT.FILL, SWT.FILL, true, - true); - topGpGd.heightHint = skewTHeightHint; - topGp.setLayoutData(topGpGd); - - // skewt composite - GridData skewtGd = new GridData(SWT.FILL, SWT.FILL, true, - true); - skewtGd.heightHint = skewTHeightHint; - skewtGd.widthHint = skewTWidthHint; - nsharpComp[DISPLAY_SKEWT].setLayoutData(skewtGd); - - // right-top group : right part of top group - rightTopGpGd = new GridData(SWT.FILL, SWT.FILL, true, - true); - rightTopGpGd.widthHint = timeStnWidthHint; - rightTopGp.setLayoutData(rightTopGpGd); - - GridData timeStnGd = new GridData(SWT.FILL, SWT.FILL, true, - true);//gridDataArray[DISPLAY_TIMESTN]; - timeStnGd.heightHint = timeStnHeightHint; - timeStnGd.widthHint = timeStnWidthHint; - nsharpComp[DISPLAY_TIMESTN].setLayoutData(timeStnGd); - - //future composite - GridData futureGd = new GridData(SWT.FILL, SWT.FILL, true, - true); - futureGd.heightHint = futureHeightHint; - futureGd.widthHint = futureWidthHint; - nsharpComp[DISPLAY_FUTURE].setLayoutData(futureGd); - - botGpGd = new GridData(SWT.FILL, SWT.END, true, - true); - botGpGd.heightHint = (int) (baseHeight * botGroupHeightRatio); - botGp.setLayoutData(botGpGd); - //hodo composite - GridData hodoGd = new GridData(SWT.FILL, SWT.FILL, true, - false); - hodoGd.heightHint = hodoHeightHint; - hodoGd.widthHint = hodoWidthHint; - nsharpComp[DISPLAY_HODO].setLayoutData(hodoGd); - GridData dataGd = new GridData(SWT.FILL, SWT.FILL, true, - false);//gridDataArray[DISPLAY_DATA]; - dataGd.heightHint = dataHeightHint; - dataGd.widthHint = dataWidthHint; - nsharpComp[DISPLAY_DATA].setLayoutData(dataGd); - } - //System.out.println("After resizing...nsharpComp[0] w= " + nsharpComp[0].getBounds().width + " h= "+ nsharpComp[0].getBounds().height); - //System.out.println("After resizing...nsharpComp[1] w= " + nsharpComp[1].getBounds().width + " h= "+ nsharpComp[1].getBounds().height); + } else if (paneConfigurationName + .equals(NsharpConstants.PANE_SPCWS_CFG_STR)) { + topGpGd = new GridData(SWT.FILL, SWT.FILL, true, true); + topGpGd.heightHint = (int) (baseHeight * topGroupHeightRatio); + topGp.setLayoutData(topGpGd); - for(int i=0; i< DISPLAY_TOTAL; i++){ - if(displayArray[i]!=null && displayArray[i].getDescriptor().getResourceList().isEmpty()== false){ - ResourcePair rscPair = displayArray[i].getDescriptor().getResourceList().get(0); - if (rscPair.getResource() instanceof NsharpAbstractPaneResource){ - NsharpAbstractPaneResource paneRsc = (NsharpAbstractPaneResource)rscPair.getResource() ; - paneRsc.setResize(true); - } - } - } + // skewt composite + GridData skewtGd = new GridData(SWT.FILL, SWT.FILL, true, true); + skewtGd.heightHint = skewTHeightHint; + skewtGd.widthHint = skewTWidthHint; + nsharpComp[DISPLAY_SKEWT].setLayoutData(skewtGd); - } - - } - @Override + // wito composite + GridData witoGd = new GridData(SWT.FILL, SWT.FILL, true, true); + witoGd.heightHint = witoHeightHint; + witoGd.widthHint = witoWidthHint; + nsharpComp[DISPLAY_WITO].setLayoutData(witoGd); + + // right-top group : right part of top group + rightTopGpGd = new GridData(SWT.FILL, SWT.FILL, true, true); + rightTopGpGd.widthHint = (int) (baseWidth * hodoWidthHintRatio); + rightTopGp.setLayoutData(rightTopGpGd); + + // hodo composite + GridData hodoGd = new GridData(SWT.FILL, SWT.FILL, true, true); + hodoGd.heightHint = hodoHeightHint; + hodoGd.widthHint = hodoWidthHint; + nsharpComp[DISPLAY_HODO].setLayoutData(hodoGd); + + // inset composite + GridData insetGd = new GridData(SWT.FILL, SWT.FILL, true, true); + insetGd.heightHint = insetHeightHint; + insetGd.widthHint = insetWidthHint; + nsharpComp[DISPLAY_INSET].setLayoutData(insetGd); + /* + * //time-stn composite Composite timeStnComp = new + * Composite(rightTopGp, SWT.NONE); GridData timeStnGd = new + * GridData(SWT.END, SWT.FILL, false, true); + * timeStnComp.setLayoutData(timeStnGd); + */ + + botGpGd = new GridData(SWT.FILL, SWT.END, true, true); + botGpGd.heightHint = (int) (baseHeight * botGroupHeightRatio); + botGp.setLayoutData(botGpGd); + // data composite + GridData dataGd = new GridData(SWT.FILL, SWT.FILL, true, false); + dataGd.heightHint = dataHeightHint; + dataGd.widthHint = dataWidthHint; + nsharpComp[DISPLAY_DATA].setLayoutData(dataGd); + // spc composite + GridData spcGd = new GridData(SWT.FILL, SWT.FILL, true, false); + spcGd.heightHint = spcHeightHint; + spcGd.widthHint = spcWidthHint; + nsharpComp[DISPLAY_SPC_GRAPHS].setLayoutData(spcGd); + + } else if (paneConfigurationName + .equals(NsharpConstants.PANE_SIMPLE_D2D_CFG_STR)) { + topGpGd = new GridData(SWT.FILL, SWT.FILL, true, true); + topGpGd.heightHint = skewTHeightHint; + topGp.setLayoutData(topGpGd); + + // skewt composite + GridData skewtGd = new GridData(SWT.FILL, SWT.FILL, true, true); + skewtGd.heightHint = skewTHeightHint; + skewtGd.widthHint = skewTWidthHint; + nsharpComp[DISPLAY_SKEWT].setLayoutData(skewtGd); + + // right-top group : right part of top group + rightTopGpGd = new GridData(SWT.FILL, SWT.FILL, true, true); + rightTopGpGd.widthHint = timeStnWidthHint; + rightTopGp.setLayoutData(rightTopGpGd); + + GridData timeStnGd = new GridData(SWT.FILL, SWT.FILL, true, + true);// gridDataArray[DISPLAY_TIMESTN]; + timeStnGd.heightHint = timeStnHeightHint; + timeStnGd.widthHint = timeStnWidthHint; + nsharpComp[DISPLAY_TIMESTN].setLayoutData(timeStnGd); + + // future composite + GridData futureGd = new GridData(SWT.FILL, SWT.FILL, true, true); + futureGd.heightHint = futureHeightHint; + futureGd.widthHint = futureWidthHint; + nsharpComp[DISPLAY_FUTURE].setLayoutData(futureGd); + + botGpGd = new GridData(SWT.FILL, SWT.END, true, true); + botGpGd.heightHint = (int) (baseHeight * botGroupHeightRatio); + botGp.setLayoutData(botGpGd); + // hodo composite + GridData hodoGd = new GridData(SWT.FILL, SWT.FILL, true, false); + hodoGd.heightHint = hodoHeightHint; + hodoGd.widthHint = hodoWidthHint; + nsharpComp[DISPLAY_HODO].setLayoutData(hodoGd); + GridData dataGd = new GridData(SWT.FILL, SWT.FILL, true, false);// gridDataArray[DISPLAY_DATA]; + dataGd.heightHint = dataHeightHint; + dataGd.widthHint = dataWidthHint; + nsharpComp[DISPLAY_DATA].setLayoutData(dataGd); + } + // d2dlite start + else if (paneConfigurationName + .equals(NsharpConstants.PANE_LITE_D2D_CFG_STR)) { + topGpGd = new GridData(SWT.FILL, SWT.FILL, true, true); + topGpGd.heightHint = skewTHeightHint; + topGp.setLayoutData(topGpGd); + + if (rscHandler.getCurrentGraphMode() != NsharpConstants.GRAPH_HODO) { + // skewt composite + GridData skewtGd = new GridData(SWT.FILL, SWT.FILL, true, + true); + skewtGd.heightHint = skewTHeightHint; + skewtGd.widthHint = skewTWidthHint; + nsharpComp[DISPLAY_SKEWT].setLayoutData(skewtGd); + } else { + // hodo composite + GridData hodoGd = new GridData(SWT.FILL, SWT.FILL, true, + false); + hodoGd.heightHint = hodoHeightHint; + hodoGd.widthHint = hodoWidthHint; + nsharpComp[DISPLAY_HODO].setLayoutData(hodoGd); + } + + // right-top group : right part of top group + rightTopGpGd = new GridData(SWT.FILL, SWT.FILL, true, true); + rightTopGpGd.widthHint = timeStnWidthHint; + rightTopGp.setLayoutData(rightTopGpGd); + + GridData timeStnGd = new GridData(SWT.FILL, SWT.FILL, true, + true); + timeStnGd.heightHint = timeStnHeightHint; + timeStnGd.widthHint = timeStnWidthHint; + nsharpComp[DISPLAY_TIMESTN].setLayoutData(timeStnGd); + + GridData dataGd = new GridData(SWT.FILL, SWT.FILL, true, false); + dataGd.heightHint = dataHeightHint; + dataGd.widthHint = dataWidthHint; + nsharpComp[DISPLAY_DATA].setLayoutData(dataGd); + } // d2dlite end + for (int i = 0; i < DISPLAY_TOTAL; i++) { + if (displayArray[i] != null + && displayArray[i].getDescriptor().getResourceList() + .isEmpty() == false) { + ResourcePair rscPair = displayArray[i].getDescriptor() + .getResourceList().get(0); + if (rscPair.getResource() instanceof NsharpAbstractPaneResource) { + NsharpAbstractPaneResource paneRsc = (NsharpAbstractPaneResource) rscPair + .getResource(); + paneRsc.setResize(true); + } + } + } + + } + + } + + @Override public boolean isDirty() { if (!isCloseable()) { return true; @@ -1689,83 +2018,116 @@ public class NsharpEditor extends AbstractEditor implements IRenderableDisplayC return false; } } - @Override + + @Override protected void setInput(IEditorInput input) { super.setInput(input); - this.editorInput = (EditorInput)input; + this.editorInput = (EditorInput) input; } - @Override + + @Override public void renderableDisplayChanged(IDisplayPane pane, IRenderableDisplay newRenderableDisplay, DisplayChangeType type) { - - if(type == DisplayChangeType.ADD){ - //System.out.println("Editor="+this.toString()+" renderableDisplayChanged ADD called, pane = " + pane.toString()+" newRenderableDisplay="+newRenderableDisplay.toString()); - boolean swapping = false; - for(int i = 0 ; i < displayPane.length ; i+= 1){ - if(displayPane[i] == pane){ - //displayArray[i] = newRenderableDisplay; - //System.out.println( "swapping pane, current handler "+rscHandler.toString()+"#############################"); - /* - * Chin Note: For the scenarios of 2 instance of Nsharps. One in Main and one in side pane. - * In order to handle pane swapping in D2D. When this renderableDisplayChanged event happened with - * change type of ADD. - * It indicates that current nsharp in main pane is about to be swapped with Nsharp in side pane. - * Current D2D architecture will not dispose this NsharpEditor (in main pane) but will reuse it for the - * existing Nsharp coming from side pane. - * In other words, we only swap "NsharpResourceHandler" and keep editor. - * Therefore, rscHandler (at this moment) is about to be moved out. Before it is moved out, - * we raise "justMoveToSidePane" flag to be used by skewTPaneRsc at side pane. + + if (type == DisplayChangeType.ADD) { + // System.out.println("Editor="+this.toString()+" renderableDisplayChanged ADD called, pane = " + // + + // pane.toString()+" newRenderableDisplay="+newRenderableDisplay.toString()); + boolean swapping = false; + for (int i = 0; i < displayPane.length; i += 1) { + if (displayPane[i] == pane) { + // displayArray[i] = newRenderableDisplay; + // System.out.println( + // "swapping pane, current handler "+rscHandler.toString()+"#############################"); + /* + * Chin Note: For the scenarios of 2 instance of Nsharps. + * One in Main and one in side pane. In order to handle pane + * swapping in D2D. When this renderableDisplayChanged event + * happened with change type of ADD. It indicates that + * current nsharp in main pane is about to be swapped with + * Nsharp in side pane. Current D2D architecture will not + * dispose this NsharpEditor (in main pane) but will reuse + * it for the existing Nsharp coming from side pane. In + * other words, we only swap "NsharpResourceHandler" and + * keep editor. Therefore, rscHandler (at this moment) is + * about to be moved out. Before it is moved out, we raise + * "justMoveToSidePane" flag to be used by skewTPaneRsc at + * side pane. */ - if(rscHandler.getSkewtPaneRsc()!=null) - rscHandler.getSkewtPaneRsc().setJustMoveToSidePane(true); - if(rscHandler.getWitoPaneRsc() !=null) - rscHandler.getWitoPaneRsc().setInSidePane(true); - swapping= true; + if (rscHandler.getSkewtPaneRsc() != null) + rscHandler.getSkewtPaneRsc() + .setJustMoveToSidePane(true); + if (rscHandler.getWitoPaneRsc() != null) + rscHandler.getWitoPaneRsc().setInSidePane(true); + // FixMark:sidePaneLooping d2dlite + if (rscHandler.getDataPaneRsc() != null) + rscHandler.getDataPaneRsc().setSidePaneMode(true); + swapping = true; } - + } /* - * Chin Note: We only have to handle the following procedures once, either during swapping or NshaepEditor is created. - * Since, in any case, we will have NsharpSkewTPane, therefore we are checking NsharpSkewTPaneDescriptor - * to avoid multiple access of the following code. + * Chin Note: We only have to handle the following procedures once, + * either during swapping or NshaepEditor is created. Since, in any + * case, we will have NsharpSkewTPane, therefore we are checking + * NsharpSkewTPaneDescriptor to avoid multiple access of the + * following code. */ - if(newRenderableDisplay.getDescriptor() instanceof NsharpSkewTPaneDescriptor){ - NsharpAbstractPaneDescriptor desc = (NsharpAbstractPaneDescriptor) newRenderableDisplay.getDescriptor(); + if (newRenderableDisplay.getDescriptor() instanceof NsharpSkewTPaneDescriptor) { + NsharpAbstractPaneDescriptor desc = (NsharpAbstractPaneDescriptor) newRenderableDisplay + .getDescriptor(); NsharpResourceHandler handler = desc.getRscHandler(); if (handler != null) { - //System.out.println("renderableDisplayChanged current handler=" + rscHandler.toString() + " set new Handler=" + handler.toString() + " editor "+ this.toString()); - rscHandler = handler; - if(swapping){ - /* - * Chin Note: If swapping happened, rscHandler is the newly swapping nsharp's. - * We will have to restart editor to construct all graphs and displays for this nsharp instance. - * We also have to re-store nsharp to its previous status (when it was in main pane). - */ - restartEditor( paneConfigurationName); - /*rscHandler.resetRsc(); - NsharpPaletteWindow paletteWin = NsharpPaletteWindow.getInstance(); - if(paletteWin!=null){ - paletteWin.restorePaletteWindow(paneConfigurationName, rscHandler.getCurrentGraphMode(), - rscHandler.isInterpolateIsOn(), rscHandler.isOverlayIsOn(), - rscHandler.isCompareStnIsOn(),rscHandler.isCompareTmIsOn(),rscHandler.isEditGraphOn()); - }*/ - if(rscHandler.getSkewtPaneRsc()!=null) - rscHandler.getSkewtPaneRsc().setJustBackToMainPane(true); - if(rscHandler.getWitoPaneRsc() !=null) - rscHandler.getWitoPaneRsc().setInSidePane(false); - - } - else{ - // Chin Note: This is when NsharpEditor is created case. - // Note that, in D2D when only one Nsharp instance is in side pane, then when it - // is swapped back to main pane, NsharpEditor also is created. - //System.out.println("Editor="+this.toString()+" renderableDisplayChanged ADD but not swapping"+" newRenderableDisplay="+newRenderableDisplay.toString()); + // System.out.println("renderableDisplayChanged current handler=" + // + rscHandler.toString() + " set new Handler=" + + // handler.toString() + " editor "+ this.toString()); + rscHandler = handler; + if (swapping) { + /* + * Chin Note: If swapping happened, rscHandler is the + * newly swapping nsharp's. We will have to restart + * editor to construct all graphs and displays for this + * nsharp instance. We also have to re-store nsharp to + * its previous status (when it was in main pane). + */ + restartEditor(paneConfigurationName); + /* + * rscHandler.resetRsc(); NsharpPaletteWindow paletteWin + * = NsharpPaletteWindow.getInstance(); + * if(paletteWin!=null){ + * paletteWin.restorePaletteWindow( + * paneConfigurationName, + * rscHandler.getCurrentGraphMode(), + * rscHandler.isInterpolateIsOn(), + * rscHandler.isOverlayIsOn(), + * rscHandler.isCompareStnIsOn + * (),rscHandler.isCompareTmIsOn + * (),rscHandler.isEditGraphOn()); } + */ + if (rscHandler.getSkewtPaneRsc() != null) + rscHandler.getSkewtPaneRsc().setJustBackToMainPane( + true); + if (rscHandler.getWitoPaneRsc() != null) + rscHandler.getWitoPaneRsc().setInSidePane(false); + // FixMark:sidePaneLooping + if (rscHandler.getDataPaneRsc() != null) + rscHandler.getDataPaneRsc().setSidePaneMode(false); + + } else { + // Chin Note: This is when NsharpEditor is created case. + // Note that, in D2D when only one Nsharp instance is in + // side pane, then when it + // is swapped back to main pane, NsharpEditor also is + // created. + // System.out.println("Editor="+this.toString()+" renderableDisplayChanged ADD but not swapping"+" newRenderableDisplay="+newRenderableDisplay.toString()); } return; } - } + } } - // else - // System.out.println("Editor="+this.toString()+" renderableDisplayChanged REMOVE called, pane = " + pane.toString()+" newRenderableDisplay="+newRenderableDisplay.toString()); + // else + // System.out.println("Editor="+this.toString()+" renderableDisplayChanged REMOVE called, pane = " + // + + // pane.toString()+" newRenderableDisplay="+newRenderableDisplay.toString()); } } \ No newline at end of file diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/map/NsharpGpdSoundingQuery.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/map/NsharpGpdSoundingQuery.java new file mode 100644 index 0000000000..27eed35adb --- /dev/null +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/map/NsharpGpdSoundingQuery.java @@ -0,0 +1,158 @@ +package gov.noaa.nws.ncep.ui.nsharp.display.map; + +import gov.noaa.nws.ncep.common.dataplugin.gpd.GenericPointDataConstants; +import gov.noaa.nws.ncep.common.dataplugin.gpd.product.GenericPointDataLevel; +import gov.noaa.nws.ncep.common.dataplugin.gpd.product.GenericPointDataParameter; +import gov.noaa.nws.ncep.common.dataplugin.gpd.product.GenericPointDataStationProduct; +import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingLayer; +import gov.noaa.nws.ncep.ui.nsharp.NsharpStationInfo; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +// import gov.noaa.nws.ncep.viz.rsc.gpd.query.GpdQuery; +/* + * Chin Note; User only be able to pick one station from Nsharp map at a time, however, the picked station may have several time lines + * associated with it. stnPtDataLineLst contains a list of same stations but with different time lines (if provided) + */ +public class NsharpGpdSoundingQuery { + public static void getGpdPfcSndData( + List stnPtDataLineLst, + Map> soundingLysLstMap, + String prodName) { + for (NsharpStationInfo StnPt : stnPtDataLineLst) { + // one StnPt represent one reference time line + // with one reference time, there may be many forecast time / range + // start time + List rangeTimeList = new ArrayList(); + for (NsharpStationInfo.timeLineSpecific tmlinSpc : StnPt + .getTimeLineSpList()) { + rangeTimeList.add(tmlinSpc.getTiemLine()); + } + List stnPList = null; + // TBDGPD List stnPList = + // GpdQuery.getGpdStationModelSoundingProductList(prodName,GenericPointDataQueryKey.BY_SLAT_SLON, + // null,(float)stnPtDataLineLst.get(0).getLatitude(),(float)stnPtDataLineLst.get(0).getLongitude(), + // rangeTimeList,false,0,StnPt.getReftime()); + if (stnPList != null && stnPList.size() > 0) { + for (GenericPointDataStationProduct stnProd : stnPList) { + List levelList = stnProd + .getLevelLst(); + List sndLayerList = new ArrayList(); + for (GenericPointDataLevel gpdl : levelList) { + List gpdParmList = gpdl + .getGpdParameters(); + NcSoundingLayer sndLyer = new NcSoundingLayer(); + for (GenericPointDataParameter gpdParm : gpdParmList) { + if (gpdParm.getName().equals( + GenericPointDataConstants.GEMPAK_PRESSURE)) { + sndLyer.setPressure(gpdParm.getValue()); + } else if (gpdParm.getName().equals( + GenericPointDataConstants.GEMPAK_HEIGHT)) { + sndLyer.setGeoHeight(gpdParm.getValue()); + } else if (gpdParm.getName().equals( + GenericPointDataConstants.GEMPAK_TEMP)) { + sndLyer.setTemperature(gpdParm.getValue()); + } else if (gpdParm.getName().equals( + GenericPointDataConstants.GEMPAK_DEWPT)) { + sndLyer.setDewpoint(gpdParm.getValue()); + } else if (gpdParm.getName().equals( + GenericPointDataConstants.GEMPAK_WIND_DIR)) { + sndLyer.setWindDirection(gpdParm.getValue()); + } else if (gpdParm + .getName() + .equals(GenericPointDataConstants.GEMPAK_WIND_SPEED)) { + sndLyer.setWindSpeed(gpdParm.getValue()); + } + } + sndLayerList.add(sndLyer); + } + String dispInfo = ""; + for (NsharpStationInfo.timeLineSpecific tmlinSpc : StnPt + .getTimeLineSpList()) { + if (tmlinSpc.getTiemLine().getTime() == (stnProd + .getForecastTime() * 1000 + stnProd + .getRefTime().getTime())) { + dispInfo = tmlinSpc.getDisplayInfo(); + soundingLysLstMap.put(dispInfo, sndLayerList); + break; + } + } + } + } + + } + } + + public static void getGpdObsSndData( + List stnPtDataLineLst, + Map> soundingLysLstMap, + String prodName) { + List refTimeList = new ArrayList(); + for (NsharpStationInfo StnPt : stnPtDataLineLst) { + // one StnPt represent one data time line + Date refTime = new Date(); + refTime.setTime(StnPt.getReftime().getTime()); + refTimeList.add(refTime); + } + // System.out.println("stn lat =" + + // stnPtDataLineLst.get(0).getLatitude() + // + " lon=" + stnPtDataLineLst.get(0).getLongitude()); + List stnPList = null; + // TBDGPD List stnPList = + // GpdQuery.getGpdStationProductList(prodName,GenericPointDataQueryKey.BY_SLAT_SLON, + // null,(float)stnPtDataLineLst.get(0).getLatitude(),(float)stnPtDataLineLst.get(0).getLongitude(), + // refTimeList,false,0); + if (stnPList != null && stnPList.size() > 0) { + for (GenericPointDataStationProduct stnProd : stnPList) { + List levelList = stnProd.getLevelLst(); + List sndLayerList = new ArrayList(); + for (GenericPointDataLevel gpdl : levelList) { + List gpdParmList = gpdl + .getGpdParameters(); + NcSoundingLayer sndLyer = new NcSoundingLayer(); + for (GenericPointDataParameter gpdParm : gpdParmList) { + if (gpdParm.getName().equals( + GenericPointDataConstants.GEMPAK_PRESSURE)) { + sndLyer.setPressure(gpdParm.getValue()); + } else if (gpdParm.getName().equals( + GenericPointDataConstants.GEMPAK_HEIGHT)) { // NcSoundingProfile + // sndPf= + // PfcSoundingQuery.getPfcSndData(StnPt.getDatauri(),(float)StnPt.getLatitude(), + // (float)StnPt.getLongitude(), + // StnPt.getReftime(), + // StnPt.getRangestarttime(), + // PfcSoundingQuery.PfcSndType.NAMSND); + + sndLyer.setGeoHeight(gpdParm.getValue()); + } else if (gpdParm.getName().equals( + GenericPointDataConstants.GEMPAK_TEMP)) { + sndLyer.setTemperature(gpdParm.getValue()); + } else if (gpdParm.getName().equals( + GenericPointDataConstants.GEMPAK_DEWPT)) { + sndLyer.setDewpoint(gpdParm.getValue()); + } else if (gpdParm.getName().equals( + GenericPointDataConstants.GEMPAK_WIND_DIR)) { + sndLyer.setWindDirection(gpdParm.getValue()); + } else if (gpdParm.getName().equals( + GenericPointDataConstants.GEMPAK_WIND_SPEED)) { + sndLyer.setWindSpeed(gpdParm.getValue()); + } + } + sndLayerList.add(sndLyer); + } + String dispInfo = ""; + for (NsharpStationInfo StnPt : stnPtDataLineLst) { + if (StnPt.getReftime().getTime() == stnProd.getRefTime() + .getTime()) { + dispInfo = StnPt.getStnDisplayInfo(); + soundingLysLstMap.put(dispInfo, sndLayerList); + break; + } + } + } + } + } +} diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/map/NsharpMapMouseHandler.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/map/NsharpMapMouseHandler.java index 0a721cc461..3a2555f89b 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/map/NsharpMapMouseHandler.java +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/map/NsharpMapMouseHandler.java @@ -25,8 +25,8 @@ import gov.noaa.nws.ncep.ui.nsharp.NsharpStationInfo; import gov.noaa.nws.ncep.ui.nsharp.SurfaceStationPointData; import gov.noaa.nws.ncep.ui.nsharp.display.NsharpEditor; import gov.noaa.nws.ncep.ui.nsharp.display.rsc.NsharpResourceHandler; -import gov.noaa.nws.ncep.ui.nsharp.view.ModelSoundingDialogContents; import gov.noaa.nws.ncep.ui.nsharp.view.NsharpLoadDialog; +import gov.noaa.nws.ncep.ui.nsharp.view.NsharpModelSoundingDialogContents; import gov.noaa.nws.ncep.ui.pgen.tools.InputHandlerDefaultImpl; import gov.noaa.nws.ncep.viz.ui.display.NatlCntrsEditor; @@ -51,44 +51,44 @@ import com.vividsolutions.jts.geom.Coordinate; //@SuppressWarnings("unchecked") public class NsharpMapMouseHandler extends InputHandlerDefaultImpl { - - public NsharpMapMouseHandler() { - instance = this; - } + + public NsharpMapMouseHandler() { + instance = this; + } // private NsharpSkewTDisplay renderableDisplay=null; - - private static final double NctextuiPointMinDistance = 45000; + + private static final double NctextuiPointMinDistance = 45000; // private int prevMouseX, prevMouseY; - private static NsharpMapMouseHandler instance; - - private double lat, lon; - - public double getLat() { - return lat; - } + private static NsharpMapMouseHandler instance; + + private double lat, lon; + + public double getLat() { + return lat; + } + + public double getLon() { + return lon; + } - public double getLon() { - return lon; - } - public static NsharpMapMouseHandler getAccess() { - return instance; - } - + return instance; + } + /* * (non-Javadoc) * * @see com.raytheon.viz.ui.input.IInputHandler#handleMouseDown(int, int, * int) */ - @Override - public boolean handleMouseDown(int x, int y, int button) { + @Override + public boolean handleMouseDown(int x, int y, int button) { // System.out.println("nsharp map mouse down"); // prevMouseX = x; // prevMouseY = y; - return false; + return false; } /* @@ -100,21 +100,21 @@ public class NsharpMapMouseHandler extends InputHandlerDefaultImpl { */ @Override public boolean handleMouseDownMove(int x, int y, int button) { - return false; - + return false; + } @Override - public boolean handleMouseMove(int x, int y) { - // TODO Auto-generated method stub - return false; - } + public boolean handleMouseMove(int x, int y) { + // TODO Auto-generated method stub + return false; + } - /* + /* * (non-Javadoc) * * @see com.raytheon.viz.ui.input.IInputHandler#handleMouseUp(int, int, int) - * handle right button, so user be able to pick stn and print text report + * handle right button, so user be able to pick stn and print text report */ @Override public boolean handleMouseUp(int x, int y, int button) { @@ -123,26 +123,26 @@ public class NsharpMapMouseHandler extends InputHandlerDefaultImpl { // if ( !NsharpMapResource.getOrCreateNsharpMapResource().isEditable()) // return false; // System.out.println("NsharpMapMouseHandler handleMouseUp called"); - // button 1 is left mouse button + // button 1 is left mouse button if (button == 1) { - NatlCntrsEditor mapEditor = NsharpMapResource.getMapEditor(); + NatlCntrsEditor mapEditor = NsharpMapResource.getMapEditor(); if (mapEditor != null) { // for(int i=0; i< // mapEditor.getDescriptor().getResourceList().size(); i++) // System.out.println( // "C resourcename="+mapEditor.getDescriptor().getResourceList().get(i).getResource().getName()); - // Check if mouse is in geographic extent - Coordinate loc = mapEditor.translateClick(x, y); + // Check if mouse is in geographic extent + Coordinate loc = mapEditor.translateClick(x, y); if (loc == null) - return false; - NsharpLoadDialog loadDia = NsharpLoadDialog.getAccess(); + return false; + NsharpLoadDialog loadDia = NsharpLoadDialog.getAccess(); if (loadDia != null) { if (loadDia.getActiveLoadSoundingType() == NsharpLoadDialog.MODEL_SND && loadDia.getMdlDialog() != null && loadDia.getMdlDialog().getLocationText() != null) { - if (loadDia.getMdlDialog().getCurrentLocType() == ModelSoundingDialogContents.LocationType.STATION) { + if (loadDia.getMdlDialog().getCurrentLocType() == NsharpModelSoundingDialogContents.LocationType.STATION) { // System.out.println("mouse up 1 loc.x "+ loc.x+ // " loc.y="+ loc.y); String stnName = SurfaceStationPointData @@ -151,7 +151,7 @@ public class NsharpMapMouseHandler extends InputHandlerDefaultImpl { // " loc.y="+ loc.y); // System.out.println("stn name = "+ stnName); if (stnName == null) - stnName = ""; + stnName = ""; loadDia.getMdlDialog().getLocationText() .setText(stnName); } else { @@ -170,10 +170,10 @@ public class NsharpMapMouseHandler extends InputHandlerDefaultImpl { List points = NsharpMapResource .getOrCreateNsharpMapResource().getPoints();// loadDia.getNsharpMapResource().getPoints(); if (points.isEmpty() == false) { - // create an editor NsharpEditor + // create an editor NsharpEditor // NsharpEditor skewtEdt = // NsharpEditor.createOrOpenEditor(); - + // get the stn close to loc "enough" and retrieve // report for it // Note::One stn may have more than one dataLine, if @@ -184,27 +184,50 @@ public class NsharpMapMouseHandler extends InputHandlerDefaultImpl { && stnPtDataLineLst.size() > 0) { // System.out.println("MapMouseHandler creating NsharpSkewTDisplay"); // hash map, use stn display info as key - Map> soundingLysLstMap = new HashMap>(); - + Map> soundingLysLstMap = new HashMap>(); + long t01 = System.currentTimeMillis(); // String soundingType; if (activeLoadType == NsharpLoadDialog.OBSER_SND) { - NsharpMapResource.startWaitCursor(); + NsharpMapResource.startWaitCursor(); NsharpObservedSoundingQuery .getObservedSndData( stnPtDataLineLst, loadDia .getObsDialog() .isRawData(), soundingLysLstMap); - NsharpMapResource.stopWaitCursor(); + NsharpMapResource.stopWaitCursor(); } else if (activeLoadType == NsharpLoadDialog.PFC_SND) { - NsharpMapResource.startWaitCursor(); + NsharpMapResource.startWaitCursor(); + NsharpPfcSoundingQuery .getPfcSndDataBySndTmRange( stnPtDataLineLst, soundingLysLstMap); - NsharpMapResource.stopWaitCursor(); - } else - return false; + NsharpMapResource.stopWaitCursor(); + } + /* + * TBDGPD else if(activeLoadType == + * NsharpLoadDialog.GPD_OBS_SND){ + * NsharpMapResource.startWaitCursor(); + * NsharpGpdSoundingQuery + * .getGpdObsSndData(stnPtDataLineLst, + * soundingLysLstMap, + * loadDia.getActiveGpdProdName()); + * NsharpMapResource.stopWaitCursor(); } else + * if(activeLoadType == + * NsharpLoadDialog.GPD_PFC_SND){ + * NsharpMapResource.startWaitCursor(); + * NsharpGpdSoundingQuery + * .getGpdPfcSndData(stnPtDataLineLst, + * soundingLysLstMap, + * loadDia.getActiveGpdProdName()); + * NsharpMapResource.stopWaitCursor(); } + */ + else + return false; + long t02 = System.currentTimeMillis(); + // System.out.println("Nsharp spent " + + // (t02-t01)+ " ms to query data"); // System.out.println("MAP size/" // +soundingLysLstMap.size()); if (soundingLysLstMap.size() <= 0) { @@ -214,40 +237,40 @@ public class NsharpMapMouseHandler extends InputHandlerDefaultImpl { .getShell(); MessageBox mb = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK); - mb.setMessage("Invalid sounding data returned from DB for this station!!"); - mb.open(); - loadDia.closeDiaOnly(); - return false; - } - loadDia.closeDiaOnly(); - + mb.setMessage("Invalid sounding data returned from DB for this station!!"); + mb.open(); + loadDia.closeDiaOnly(); + return false; + } + loadDia.closeDiaOnly(); + // NsharpResourceHandler skewRsc = // skewtEdt.getRscHandler(); // skewRsc.addRsc(soundingLysLstMap, // stnPtDataLineLst.get(0)); loadDataToNsharpResources(soundingLysLstMap, stnPtDataLineLst.get(0)); - mapEditor = NsharpMapResource.getMapEditor(); - if (mapEditor != null) { - mapEditor.refresh(); - } - bringSkewTEdToTop(); + mapEditor = NsharpMapResource.getMapEditor(); + if (mapEditor != null) { + mapEditor.refresh(); + } + bringSkewTEdToTop(); } else { // System.out.println("Mouse point too far from stn"); - } + } } else { // debug // System.out.println("points is null"); - } - } - } - } - + } + } + } + } + } else if (button == 3) { // NsharpEditor.bringSkewTEditorToTop(); - bringSkewTEdToTop(); - } - - return false; + bringSkewTEdToTop(); + } + + return false; } /* @@ -260,18 +283,18 @@ public class NsharpMapMouseHandler extends InputHandlerDefaultImpl { private void bringSkewTEdToTop() { Job uijob = new UIJob("clear source selection") { //$NON-NLS-1$ public IStatus runInUIThread(IProgressMonitor monitor) { - NsharpEditor.bringEditorToTop(); - return Status.OK_STATUS; - } + NsharpEditor.bringEditorToTop(); + return Status.OK_STATUS; + } - }; - uijob.setSystem(true); - uijob.schedule(); + }; + uijob.setSystem(true); + uijob.schedule(); } - /* - * Same reason to use UIJob as bringSkewTEdToTop() - */ + /* + * Same reason to use UIJob as bringSkewTEdToTop() + */ private void loadDataToNsharpResources( final Map> soundMap, final NsharpStationInfo stnInfo) { @@ -279,16 +302,16 @@ public class NsharpMapMouseHandler extends InputHandlerDefaultImpl { public IStatus runInUIThread(IProgressMonitor monitor) { NsharpResourceHandler rscHdr = NsharpEditor .createOrOpenEditor().getRscHandler(); - rscHdr.addRsc(soundMap, stnInfo); - return Status.OK_STATUS; - } + rscHdr.addRsc(soundMap, stnInfo); + return Status.OK_STATUS; + } - }; - uijob.setSystem(true); - uijob.schedule(); + }; + uijob.setSystem(true); + uijob.schedule(); } - /** + /** * Gets the nearest point of an selected element to the input point * * @param el @@ -300,40 +323,40 @@ public class NsharpMapMouseHandler extends InputHandlerDefaultImpl { private List getPtWithinMinDist( List points, Coordinate pt) { - NsharpStationInfo thePoint = null; - double minDistance = NctextuiPointMinDistance; - GeodeticCalculator gc; - List thePoints = new ArrayList(); - // TODO : can't assume this is a map Editor/MapDescriptor - NatlCntrsEditor mapEditor = NsharpMapResource.getMapEditor(); + NsharpStationInfo thePoint = null; + double minDistance = NctextuiPointMinDistance; + GeodeticCalculator gc; + List thePoints = new ArrayList(); + // TODO : can't assume this is a map Editor/MapDescriptor + NatlCntrsEditor mapEditor = NsharpMapResource.getMapEditor(); if (mapEditor != null) { IMapDescriptor desc = (IMapDescriptor) mapEditor .getActiveDisplayPane().getRenderableDisplay() .getDescriptor(); - gc = new GeodeticCalculator(desc.getCRS()); - gc.setStartingGeographicPoint(pt.x, pt.y); + gc = new GeodeticCalculator(desc.getCRS()); + gc.setStartingGeographicPoint(pt.x, pt.y); // int textDispIndex = 1;//debug for (NsharpStationInfo point : points) { gc.setDestinationGeographicPoint(point.getLongitude(), point.getLatitude()); - double dist; + double dist; try { - dist = gc.getOrthodromicDistance(); + dist = gc.getOrthodromicDistance(); // System.out.println("dist to point " + textDispIndex++ + // " is " + dist); if (dist < minDistance) { - minDistance = dist; - thePoint = point; - } + minDistance = dist; + thePoint = point; + } } catch (Exception e) { // e.printStackTrace(); // System.out.println("getOrthodromicDistance exception happened!"); - } + } - } + } // Chin, there may be more than one point for a selected stn. As // user may selected more than one data time, // For same stn, each data time will have one point to represent it. @@ -342,18 +365,18 @@ public class NsharpMapMouseHandler extends InputHandlerDefaultImpl { for (NsharpStationInfo point : points) { if ((thePoint.getLatitude() == point.getLatitude()) && (thePoint.getLongitude() == point.getLongitude())) { - thePoints.add(point); - } - } - + thePoints.add(point); + } + } + // marked X on selected point NsharpMapResource.getOrCreateNsharpMapResource() .setPickedPoint(thePoint); - - } - } - return thePoints; + } + + } + return thePoints; } diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/map/NsharpMapResource.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/map/NsharpMapResource.java index 2c34c45ff8..398e18168d 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/map/NsharpMapResource.java +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/map/NsharpMapResource.java @@ -73,11 +73,11 @@ public class NsharpMapResource extends private static NatlCntrsEditor mapEditor = null; - private static NsharpMapMouseHandler mouseHandler; + private static NsharpMapMouseHandler mouseHandler; private static Cursor waitCursor = null; - private static Control cursorControl; + private static Control cursorControl; private static boolean mouseHandlerRegistered = false; @@ -90,110 +90,110 @@ public class NsharpMapResource extends .getActivePage() != null) { PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getActivePage().bringToTop(mapEditor); - mapEditor.refresh(); - } + mapEditor.refresh(); + } } catch (Exception e) { - } - - } + } - public static NatlCntrsEditor getMapEditor() { - return mapEditor; - } + } - public static NsharpMapResource getMapRsc() { - return mapRsc; - } + public static NatlCntrsEditor getMapEditor() { + return mapEditor; + } - private NsharpMapResourceData nsharpMapResourceData; + public static NsharpMapResource getMapRsc() { + return mapRsc; + } - /** The set of symbols with similar attributes across many locations */ - private SymbolLocationSet symbolSet = null; + private NsharpMapResourceData nsharpMapResourceData; - private SymbolLocationSet symbolToMark = null; + /** The set of symbols with similar attributes across many locations */ + private SymbolLocationSet symbolSet = null; - private List points = new ArrayList(); + private SymbolLocationSet symbolToMark = null; - private List pickedPoint = new ArrayList(); + private List points = new ArrayList(); - public void setPickedPoint(NsharpStationInfo point) { - this.pickedPoint.add(point); - } - - public List getPoints() { - return points; - } + private List pickedPoint = new ArrayList(); - public void setPoints(List points) { + public void setPickedPoint(NsharpStationInfo point) { + this.pickedPoint.add(point); + } + + public List getPoints() { + return points; + } + + public void setPoints(List points) { if (points == null) { - this.pickedPoint.clear(); + this.pickedPoint.clear(); symbolToMark = null; symbolSet = null; - this.points.clear(); + this.points.clear(); } else { - this.points = points; - } - } + this.points = points; + } + } - public void addPoint(NsharpStationInfo point) { - points.add(point); - } + public void addPoint(NsharpStationInfo point) { + points.add(point); + } + + /** + * Default constructor + */ + protected NsharpMapResource(NsharpMapResourceData resourceData, + LoadProperties loadProperties) { + super(resourceData, loadProperties); - /** - * Default constructor - */ - protected NsharpMapResource(NsharpMapResourceData resourceData, - LoadProperties loadProperties) { - super(resourceData, loadProperties); - // set the editable capability getCapability(EditableCapability.class).setEditable(true); - this.nsharpMapResourceData = resourceData; + this.nsharpMapResourceData = resourceData; // System.out.println("NsharpMapResource constructed"); - - } + + } public static void startWaitCursor() { waitCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_WAIT); - cursorControl = Display.getCurrent().getCursorControl(); + cursorControl = Display.getCurrent().getCursorControl(); if (cursorControl != null && waitCursor != null) - cursorControl.setCursor(waitCursor); - } + cursorControl.setCursor(waitCursor); + } public static void stopWaitCursor() { if (cursorControl != null && waitCursor != null) { - cursorControl.setCursor(null); - } + cursorControl.setCursor(null); + } if (waitCursor != null) { - waitCursor.dispose(); + waitCursor.dispose(); waitCursor = null; - } - } + } + } private static void createMapEditor() { - // create an editor MapEditor - try { - AbstractEditor ed = NcDisplayMngr.getActiveNatlCntrsEditor(); - - // Is this called in D2D. Should we only check for NcMapEditors. + // create an editor MapEditor + try { + AbstractEditor ed = NcDisplayMngr.getActiveNatlCntrsEditor(); + + // Is this called in D2D. Should we only check for NcMapEditors. // If this isn't a NatlCntrsEditor should we look for one or just // create a new one. - // + // if (NcEditorUtil.getNcDisplayType(ed) == NcDisplayType.NMAP_DISPLAY) { mapEditor = (NatlCntrsEditor) ed; } else { mapEditor = (NatlCntrsEditor) NcDisplayMngr .createNatlCntrsEditor(NcDisplayType.NMAP_DISPLAY, "Select NSharp Source"); - } - + } + // for(int i=0; i< // mapEditor.getDescriptor().getResourceList().size(); i++) // System.out.println( // "A resourcename="+mapEditor.getDescriptor().getResourceList().get(i).getResource().getName()); - - ResourceBndlLoader rbdLoader = new ResourceBndlLoader("DefaultMap"); + + ResourceBndlLoader rbdLoader = new ResourceBndlLoader("DefaultMap"); rbdLoader.addDefaultRBD(NcDisplayType.NMAP_DISPLAY, mapEditor); VizApp.runSync(rbdLoader); // System.out.println("NsharpMapResource create editor "+ @@ -207,9 +207,9 @@ public class NsharpMapResource extends System.out .println("NsharpMapResource Could not load initial editor: " + ve.getMessage()); - ve.printStackTrace(); - } - } + ve.printStackTrace(); + } + } // private static void createMapEditorTest(){ // // create an editor MapEditor @@ -245,26 +245,26 @@ public class NsharpMapResource extends // } public static void registerMouseHandler() { if (mouseHandlerRegistered) - return; - - mouseHandler = getMouseHandler(); + return; + + mouseHandler = getMouseHandler(); if (mapEditor != null && mouseHandler != null) { mapEditor.registerMouseHandler((IInputHandler) mouseHandler); - mouseHandlerRegistered = true; - } - } + mouseHandlerRegistered = true; + } + } public static void unregisterMouseHandler() { if (!mouseHandlerRegistered) - return; - mouseHandler = getMouseHandler(); + return; + mouseHandler = getMouseHandler(); if (mapEditor != null && mouseHandler != null) { mapEditor.unregisterMouseHandler((IInputHandler) mouseHandler); mouseHandlerRegistered = false; - } - } + } + } - /** + /** * Create a new MapResource and add it to the current editor. * * @return the MapResource @@ -273,54 +273,54 @@ public class NsharpMapResource extends if (mapRsc == null) { if (mapEditor == null) { createMapEditor();// createMapEditor(); - - } + + } if (mapEditor != null) { IMapDescriptor desc = (IMapDescriptor) mapEditor .getActiveDisplayPane().getRenderableDisplay() .getDescriptor(); - try { + try { if (mapRscData == null) mapRscData = new NsharpMapResourceData(); mapRsc = mapRscData.construct(new LoadProperties(), desc); desc.getResourceList().add(mapRsc); mapRsc.init(mapEditor.getActiveDisplayPane().getTarget()); - + // register mouse handler - mouseHandler = getMouseHandler(); + mouseHandler = getMouseHandler(); mapEditor .registerMouseHandler((IInputHandler) mouseHandler); - - } catch (Exception e) { - e.printStackTrace(); - } - } - } - + + } catch (Exception e) { + e.printStackTrace(); + } + } + } + return mapRsc; } public static void deleteNsharpMapResource() { // System.out.println("NsharpMapResource:deleteNsharpMapResource "); if (mapRsc != null) { - mapRsc.dispose(); - mapRsc = null; - } + mapRsc.dispose(); + mapRsc = null; + } } - /** - * Called when resource is disposed + /** + * Called when resource is disposed * - * @see com.raytheon.viz.core.rsc.IVizResource#dispose() - */ - @Override - public void disposeInternal() { + * @see com.raytheon.viz.core.rsc.IVizResource#dispose() + */ + @Override + public void disposeInternal() { // System.out.println("NsharpMapResource:disposeInternal "+ // this.toString()); - + if (mapEditor != null) { mapEditor.unregisterMouseHandler(mouseHandler); - mouseHandler = null; + mouseHandler = null; // close editor /* * if((PlatformUI.getWorkbench()!= @@ -331,65 +331,65 @@ public class NsharpMapResource extends * PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage * ().closeEditor(mapEditor, false); */ - mapEditor = null; - + mapEditor = null; + } - pickedPoint = null; - points = null; - symbolSet = null; - symbolToMark = null; - mapRsc = null; + pickedPoint = null; + points = null; + symbolSet = null; + symbolToMark = null; + mapRsc = null; mapRscData = null; if (waitCursor != null) - waitCursor.dispose(); + waitCursor.dispose(); waitCursor = null; mouseHandlerRegistered = false; - } + } /* * (non-Javadoc) * * @see * com.raytheon.viz.core.rsc.IVizResource#getCoordinateReferenceSystem() - */ - public CoordinateReferenceSystem getCoordinateReferenceSystem() { + */ + public CoordinateReferenceSystem getCoordinateReferenceSystem() { - if (descriptor == null) - return null; + if (descriptor == null) + return null; - return descriptor.getCRS(); + return descriptor.getCRS(); - } + } /* * (non-Javadoc) * - * @see com.raytheon.viz.core.rsc.IVizResource#getName() - */ - @Override - public String getName() { + * @see com.raytheon.viz.core.rsc.IVizResource#getName() + */ + @Override + public String getName() { - return "NSHARP Resource"; + return "NSHARP Resource"; - } + } /* * (non-Javadoc) * * @see com.raytheon.viz.core.rsc.IVizResource#init(com.raytheon.viz.core. * IGraphicsTarget) - */ - @Override - public void initInternal(IGraphicsTarget target) throws VizException { + */ + @Override + public void initInternal(IGraphicsTarget target) throws VizException { // System.out.println("NsharpMapResource:initInternal called"); // mapfont = target.initializeFont("Monospace", // (float) (12 * // nsharpMapResourceData.getMarkerTextSize().getSoftwareSize()), null); - + // make the nsharp map resource editable EditableManager.makeEditable(this, getCapability(EditableCapability.class).isEditable()); - } + } /* * (non-Javadoc) @@ -397,65 +397,65 @@ public class NsharpMapResource extends * @see * com.raytheon.viz.core.rsc.IVizResource#isApplicable(com.raytheon.viz. * core.PixelExtent) - */ - public boolean isApplicable(PixelExtent extent) { + */ + public boolean isApplicable(PixelExtent extent) { - return true; + return true; - } + } private void generateSymbolForDrawing() { - String type; - float lineWidth = nsharpMapResourceData.getMarkerWidth(); + String type; + float lineWidth = nsharpMapResourceData.getMarkerWidth(); Boolean clear = false; - String category = new String("Marker"); - double sizeScale = nsharpMapResourceData.getMarkerSize(); + String category = new String("Marker"); + double sizeScale = nsharpMapResourceData.getMarkerSize(); - if (points.isEmpty() == true) { - symbolSet = null; + if (points.isEmpty() == true) { + symbolSet = null; } else { // SymbolLocationSet constructor requires a positive-length array of // Coordinate - Coordinate[] locations = new Coordinate[points.size()]; + Coordinate[] locations = new Coordinate[points.size()]; Color[] colors = new Color[] { new Color( NsharpConstants.color_green.red, - NsharpConstants.color_green.green, + NsharpConstants.color_green.green, NsharpConstants.color_green.blue) }; // System.out.println( "generateSymbolSet: size ="+ points.size()); - int i = 0; - for (NsharpStationInfo p : points) { - double lon, lat; - lon = p.getLongitude(); - lat = p.getLatitude(); + int i = 0; + for (NsharpStationInfo p : points) { + double lon, lat; + lon = p.getLongitude(); + lat = p.getLatitude(); locations[i++] = new Coordinate(lon, lat); - } - type = nsharpMapResourceData.getMarkerType().toString(); + } + type = nsharpMapResourceData.getMarkerType().toString(); // System.out.println( "generateSymbolSet done size ="+ i); symbolSet = new SymbolLocationSet(null, colors, lineWidth, sizeScale, clear, locations, category, type); - } + } // generate symbol for picked stn to mark X if (pickedPoint != null && pickedPoint.size() > 0) { - Coordinate[] locations = new Coordinate[pickedPoint.size()]; - int i = 0; - for (NsharpStationInfo p : pickedPoint) { - double lon, lat; - lon = p.getLongitude(); - lat = p.getLatitude(); + Coordinate[] locations = new Coordinate[pickedPoint.size()]; + int i = 0; + for (NsharpStationInfo p : pickedPoint) { + double lon, lat; + lon = p.getLongitude(); + lat = p.getLatitude(); locations[i++] = new Coordinate(lon, lat); - } - type = nsharpMapResourceData.getStnMarkerType().toString(); + } + type = nsharpMapResourceData.getStnMarkerType().toString(); Color[] colors = new Color[] { new Color( NsharpConstants.color_red.red, - NsharpConstants.color_red.green, + NsharpConstants.color_red.green, NsharpConstants.color_red.blue) }; symbolToMark = new SymbolLocationSet(null, colors, lineWidth, sizeScale * 2, clear, locations, category, type); } else symbolToMark = null; - } + } /* * (non-Javadoc) @@ -463,46 +463,46 @@ public class NsharpMapResource extends * @see * com.raytheon.viz.core.drawables.IRenderable#paint(com.raytheon.viz.core * .IGraphicsTarget, com.raytheon.viz.core.drawables.PaintProperties) - */ - @Override - public void paintInternal(IGraphicsTarget target, PaintProperties paintProps) - throws VizException { + */ + @Override + public void paintInternal(IGraphicsTarget target, PaintProperties paintProps) + throws VizException { // System.out.println("paintInternal called!"); // IFont font = target.initializeFont("Monospace", // (float) (12 * // nsharpMapResourceData.getMarkerTextSize().getSoftwareSize()), null); - - generateSymbolForDrawing(); + + generateSymbolForDrawing(); DisplayElementFactory df = new DisplayElementFactory(target, this.descriptor); if (symbolSet != null) { ArrayList elements = df.createDisplayElements( symbolSet, paintProps); for (IDisplayable each : elements) { - try { - each.draw(target, paintProps); - each.dispose(); + try { + each.draw(target, paintProps); + each.dispose(); } catch (Exception e) { - e.printStackTrace(); + e.printStackTrace(); // System.out.println("paintInternal caught draw exception!"); - } - } - } + } + } + } if (symbolToMark != null) { ArrayList elements = df.createDisplayElements( symbolToMark, paintProps); for (IDisplayable each : elements) { - try { - each.draw(target, paintProps); - each.dispose(); + try { + each.draw(target, paintProps); + each.dispose(); } catch (Exception e) { - e.printStackTrace(); + e.printStackTrace(); // System.out.println("paintInternal caught draw exception!"); - } - } - } + } + } + } // font.dispose(); - } + } /* * (non-Javadoc) @@ -510,12 +510,12 @@ public class NsharpMapResource extends * @see * com.raytheon.viz.core.rsc.capabilities.IProjectableResource#isProjectable * (org.opengis.referencing.crs.CoordinateReferenceSystem) - */ - public boolean isProjectable(CoordinateReferenceSystem mapData) { + */ + public boolean isProjectable(CoordinateReferenceSystem mapData) { - return true; + return true; - } + } /* * (non-Javadoc) @@ -523,94 +523,94 @@ public class NsharpMapResource extends * @see * com.raytheon.viz.core.rsc.capabilities.IProjectableResource#project(org * .opengis.referencing.crs.CoordinateReferenceSystem) - */ - @Override - public void project(CoordinateReferenceSystem mapData) throws VizException { + */ + @Override + public void project(CoordinateReferenceSystem mapData) throws VizException { // System.out.println("NctextuiResource: project "); - } - + } + /** * Returns the current mouse handler. * * @return - */ - private static NsharpMapMouseHandler getMouseHandler() { - + */ + private static NsharpMapMouseHandler getMouseHandler() { + if (mouseHandler == null) { - - mouseHandler = new NsharpMapMouseHandler(); - + + mouseHandler = new NsharpMapMouseHandler(); + } return mouseHandler; - + } - + @Override - public boolean okToUnload() { - /* - * DisAllow unloading of Resource - */ - - return false; - - } + public boolean okToUnload() { + /* + * DisAllow unloading of Resource + */ - @Override - public void notifyRemove(ResourcePair rp) throws VizException { - // TODO Auto-generated method stub - - } + return false; - @Override - public void propertiesChanged(ResourceProperties updatedProps) { + } + + @Override + public void notifyRemove(ResourcePair rp) throws VizException { + // TODO Auto-generated method stub + + } + + @Override + public void propertiesChanged(ResourceProperties updatedProps) { if (updatedProps.isVisible()) { reopenTextView(); } else { hideTextView(); - } + } } - + private void hideTextView() { IWorkbenchPage wpage = PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getActivePage(); - + IViewPart vpart = wpage.findView("gov.noaa.nws.ncep.ui.nsharp"); if (wpage.isPartVisible(vpart)) { - NsharpPaletteWindow paletteWin = NsharpPaletteWindow.getInstance(); + NsharpPaletteWindow paletteWin = NsharpPaletteWindow.getInstance(); if (paletteWin != null) { - paletteWin.setEditorVisible(false); - wpage.hideView(vpart); - } + paletteWin.setEditorVisible(false); + wpage.hideView(vpart); + } } - } - + } + private void reopenTextView() { IWorkbenchPage wpage = PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getActivePage(); - + IViewPart vpart = wpage.findView("gov.noaa.nws.ncep.ui.nsharp"); if (!wpage.isPartVisible(vpart)) { - NsharpPaletteWindow paletteWin = NsharpPaletteWindow.getInstance(); + NsharpPaletteWindow paletteWin = NsharpPaletteWindow.getInstance(); if (paletteWin != null) { - paletteWin.setEditorVisible(true); - try { + paletteWin.setEditorVisible(true); + try { vpart = wpage.showView("gov.noaa.nws.ncep.ui.nsharp"); - } catch (Exception e) { - e.printStackTrace(); - } - } + } catch (Exception e) { + e.printStackTrace(); + } + } } - } + } - /** - * Check if the resource is currently editable - * - * @return editable - */ - public boolean isEditable() { - return getCapability(EditableCapability.class).isEditable(); - } + /** + * Check if the resource is currently editable + * + * @return editable + */ + public boolean isEditable() { + return getCapability(EditableCapability.class).isEditable(); + } public void setEditable(boolean enable) { getCapability(EditableCapability.class).setEditable(enable); diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/map/NsharpMapResourceData.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/map/NsharpMapResourceData.java index b809b59028..735fcaac4e 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/map/NsharpMapResourceData.java +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/map/NsharpMapResourceData.java @@ -30,28 +30,28 @@ import com.raytheon.uf.viz.core.rsc.LoadProperties; public class NsharpMapResourceData extends AbstractResourceData { - private MarkerState markerState = MarkerState.MARKER_ONLY; + private MarkerState markerState = MarkerState.MARKER_ONLY; - private MarkerType markerType = MarkerType.DIAMOND; + private MarkerType markerType = MarkerType.DIAMOND; - private Float markerSize = 1f; + private Float markerSize = 1f; - private Integer markerWidth = 2; + private Integer markerWidth = 2; - private MarkerTextSize markerTextSize = MarkerTextSize.MEDIUM; + private MarkerTextSize markerTextSize = MarkerTextSize.MEDIUM; - private String mapName = "NSHARP"; + private String mapName = "NSHARP"; - private MarkerType stnMarkerType = MarkerType.LARGE_X; - - public MarkerType getStnMarkerType() { - return stnMarkerType; - } + private MarkerType stnMarkerType = MarkerType.LARGE_X; + + public MarkerType getStnMarkerType() { + return stnMarkerType; + } + + public NsharpMapResourceData() { + super(); + } - public NsharpMapResourceData() { - super(); - } - /* * (non-Javadoc) * @@ -59,13 +59,13 @@ public class NsharpMapResourceData extends AbstractResourceData { * com.raytheon.uf.viz.core.rsc.AbstractResourceData#construct(com.raytheon * .uf.viz.core.comm.LoadProperties, * com.raytheon.uf.viz.core.drawables.IDescriptor) - */ - @Override - public NsharpMapResource construct(LoadProperties loadProperties, - IDescriptor descriptor) throws VizException { - // TODO Auto-generated method stub - return new NsharpMapResource(this, loadProperties); - } + */ + @Override + public NsharpMapResource construct(LoadProperties loadProperties, + IDescriptor descriptor) throws VizException { + // TODO Auto-generated method stub + return new NsharpMapResource(this, loadProperties); + } /* * (non-Javadoc) @@ -73,15 +73,15 @@ public class NsharpMapResourceData extends AbstractResourceData { * @see * com.raytheon.uf.viz.core.rsc.AbstractResourceData#update(java.lang.Object * ) - */ - @Override - public void update(Object updateData) { - // TODO Auto-generated method stub + */ + @Override + public void update(Object updateData) { + // TODO Auto-generated method stub - } + } - @Override - public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { if (obj == null || !(obj instanceof NsharpMapResourceData)) return false; NsharpMapResourceData rdata = (NsharpMapResourceData) obj; @@ -93,54 +93,54 @@ public class NsharpMapResourceData extends AbstractResourceData { && this.stnMarkerType.equals(rdata.getStnMarkerType())) return true; - return false; - } - - public MarkerState getMarkerState() { - return markerState; - } + return false; + } - public void setMarkerState(MarkerState markerState) { - this.markerState = markerState; - } + public MarkerState getMarkerState() { + return markerState; + } - public MarkerType getMarkerType() { - return markerType; - } + public void setMarkerState(MarkerState markerState) { + this.markerState = markerState; + } - public void setMarkerType(MarkerType markerType) { - this.markerType = markerType; - } + public MarkerType getMarkerType() { + return markerType; + } - public Float getMarkerSize() { - return markerSize; - } + public void setMarkerType(MarkerType markerType) { + this.markerType = markerType; + } - public void setMarkerSize(Float markerSize) { - this.markerSize = markerSize; - } + public Float getMarkerSize() { + return markerSize; + } - public Integer getMarkerWidth() { - return markerWidth; - } + public void setMarkerSize(Float markerSize) { + this.markerSize = markerSize; + } - public void setMarkerWidth(Integer markerWidth) { - this.markerWidth = markerWidth; - } + public Integer getMarkerWidth() { + return markerWidth; + } - public MarkerTextSize getMarkerTextSize() { - return markerTextSize; - } + public void setMarkerWidth(Integer markerWidth) { + this.markerWidth = markerWidth; + } - public void setMarkerTextSize(MarkerTextSize markerTextSize) { - this.markerTextSize = markerTextSize; - } + public MarkerTextSize getMarkerTextSize() { + return markerTextSize; + } - public String getMapName() { - return mapName; - } + public void setMarkerTextSize(MarkerTextSize markerTextSize) { + this.markerTextSize = markerTextSize; + } - public void setMapName(String mapName) { - this.mapName = mapName; - } + public String getMapName() { + return mapName; + } + + public void setMapName(String mapName) { + this.mapName = mapName; + } } diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/map/NsharpObservedSoundingQuery.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/map/NsharpObservedSoundingQuery.java index 11c5d22f96..53493d91f4 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/map/NsharpObservedSoundingQuery.java +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/map/NsharpObservedSoundingQuery.java @@ -1,4 +1,5 @@ package gov.noaa.nws.ncep.ui.nsharp.display.map; + /** * * gov.noaa.nws.ncep.ui.nsharp.display.map.NsharpObservedSoundingQuery @@ -30,92 +31,113 @@ import gov.noaa.nws.ncep.viz.common.soundingQuery.NcSoundingQuery; import java.util.ArrayList; import java.util.List; import java.util.Map; -//Chin-T import com.raytheon.uf.common.sounding.SoundingLayer; import com.vividsolutions.jts.geom.Coordinate; +//Chin-T import com.raytheon.uf.common.sounding.SoundingLayer; public class NsharpObservedSoundingQuery { - - //Chin-T public static void getObservedSndData(List stnPtDataLineLst, Map> soundingLysLstMap) { - //Chin: note that Nsharp currently GUI only allow user pick one stn at one time, but could be many refTimes. - public static void getObservedSndData(List stnPtDataLineLst, boolean rawData, Map> soundingLysLstMap) { - //String pickedStnInfo = ""; - List coords= new ArrayList(); - List refTimeLst = new ArrayList(); - //create refTime array and lat/lon array - for(NsharpStationInfo StnPt : stnPtDataLineLst){ - //one StnPt represent one data time line - //List Ids = StnPt.getDbId(); - System.out.println("stn lat ="+StnPt.getLatitude()+ " lon="+StnPt.getLongitude()); - boolean exist = false; - for(Coordinate c: coords){ - if(c.x == StnPt.getLongitude() && c.y == StnPt.getLatitude()){ - exist= true; - break; - } - } - if(exist==false) { - Coordinate coord = new Coordinate(StnPt.getLongitude(),StnPt.getLatitude()); - coords.add(coord); - } - exist = false; - for(long t: refTimeLst){ - if(t == StnPt.getReftime().getTime()){ - exist= true; - break; - } - } - if(exist==false) { - refTimeLst.add(StnPt.getReftime().getTime()); - } - - - } - double[][] latLon = new double[coords.size()][2]; - for (int i=0; i< coords.size(); i++){ - latLon[i][0]= coords.get(i).y; //lat - latLon[i][1]= coords.get(i).x; //lon - } - NcSoundingCube cube = NcSoundingQuery.uaGenericSoundingQuery(refTimeLst.toArray(new Long[0]), latLon, stnPtDataLineLst.get(0).getSndType(), - NcSoundingLayer.DataType.ALLDATA, !rawData, "-1"); - //NcSoundingCube cube = NcSoundingQuery.soundingQueryByLatLon(stnPtDataLineLst.get(0).getReftime().getTime(), coords, stnPtDataLineLst.get(0).getSndType(), - // NcSoundingLayer.DataType.ALLDATA, !rawData, "-1"); - if(cube != null && cube.getSoundingProfileList().size()>0 && cube.getRtnStatus()==NcSoundingCube.QueryStatus.OK){ - for(NcSoundingProfile sndPf : cube.getSoundingProfileList()){ - List rtnSndLst = sndPf.getSoundingLyLst(); - //if(rtnSndLst != null && rtnSndLst.size() > 0){ - //NcSoundingProfile sndPf = cube.getSoundingProfileList().get(0); - //System.out.println("size of profile = "+ cube.getSoundingProfileList().size()); - //debug - //for(NcSoundingProfile pf: cube.getSoundingProfileList()){ - // System.out.println("sounding profile: lat="+pf.getStationLatitude()+" lon="+pf.getStationLongitude()+ " stnId="+ pf.getStationId() ); - //} - //List rtnSndLst = sndPf.getSoundingLyLst(); - // Chin-T List sndLyList = NsharpSoundingQueryCommon.convertToSoundingLayerList(rtnSndLst); - if(rtnSndLst != null && rtnSndLst.size() > 0){ - //update sounding data so they can be used by Skewt Resource and PalletWindow - if(rawData) - rtnSndLst = NsharpDataHandling.sortObsSoundingDataForShow(rtnSndLst, sndPf.getStationElevation()); - else - rtnSndLst = NsharpDataHandling.organizeSoundingDataForShow(rtnSndLst, sndPf.getStationElevation()); - //minimum rtnSndList size will be 2 (50 & 75 mb layers), but that is not enough - // We need at least 2 regular layers for plotting - if(rtnSndLst != null && rtnSndLst.size() > 4){ - String dispInfo=""; - for(NsharpStationInfo StnPt : stnPtDataLineLst){ - if(StnPt.getReftime().getTime() == sndPf.getFcsTime()){ - dispInfo = StnPt.getStnDisplayInfo(); - break; - } - } - soundingLysLstMap.put(dispInfo, rtnSndLst); - } - } - } - //} - } - - } - + // Chin-T public static void getObservedSndData(List + // stnPtDataLineLst, Map> soundingLysLstMap) { + // Chin: note that Nsharp currently GUI only allow user pick one stn at one + // time, but could be many refTimes. + public static void getObservedSndData( + List stnPtDataLineLst, boolean rawData, + Map> soundingLysLstMap) { + // String pickedStnInfo = ""; + List coords = new ArrayList(); + List refTimeLst = new ArrayList(); + // create refTime array and lat/lon array + for (NsharpStationInfo StnPt : stnPtDataLineLst) { + // one StnPt represent one data time line + // List Ids = StnPt.getDbId(); + // System.out.println("stn lat ="+StnPt.getLatitude()+ + // " lon="+StnPt.getLongitude()); + boolean exist = false; + for (Coordinate c : coords) { + if (c.x == StnPt.getLongitude() && c.y == StnPt.getLatitude()) { + exist = true; + break; + } + } + if (exist == false) { + Coordinate coord = new Coordinate(StnPt.getLongitude(), + StnPt.getLatitude()); + coords.add(coord); + } + exist = false; + for (long t : refTimeLst) { + if (t == StnPt.getReftime().getTime()) { + exist = true; + break; + } + } + if (exist == false) { + refTimeLst.add(StnPt.getReftime().getTime()); + } + + } + double[][] latLon = new double[coords.size()][2]; + for (int i = 0; i < coords.size(); i++) { + latLon[i][0] = coords.get(i).y; // lat + latLon[i][1] = coords.get(i).x; // lon + } + NcSoundingCube cube = NcSoundingQuery + .uaGenericSoundingQuery(refTimeLst.toArray(new Long[0]), + latLon, stnPtDataLineLst.get(0).getSndType(), + NcSoundingLayer.DataType.ALLDATA, !rawData, "-1"); + // NcSoundingCube cube = + // NcSoundingQuery.soundingQueryByLatLon(stnPtDataLineLst.get(0).getReftime().getTime(), + // coords, stnPtDataLineLst.get(0).getSndType(), + // NcSoundingLayer.DataType.ALLDATA, !rawData, "-1"); + if (cube != null && cube.getSoundingProfileList().size() > 0 + && cube.getRtnStatus() == NcSoundingCube.QueryStatus.OK) { + for (NcSoundingProfile sndPf : cube.getSoundingProfileList()) { + List rtnSndLst = sndPf.getSoundingLyLst(); + // if(rtnSndLst != null && rtnSndLst.size() > 0){ + + // NcSoundingProfile sndPf = + // cube.getSoundingProfileList().get(0); + // System.out.println("size of profile = "+ + // cube.getSoundingProfileList().size()); + // debug + // for(NcSoundingProfile pf: cube.getSoundingProfileList()){ + // System.out.println("sounding profile: lat="+pf.getStationLatitude()+" lon="+pf.getStationLongitude()+ + // " stnId="+ pf.getStationId() ); + // } + // List rtnSndLst = sndPf.getSoundingLyLst(); + // Chin-T List sndLyList = + // NsharpSoundingQueryCommon.convertToSoundingLayerList(rtnSndLst); + if (rtnSndLst != null && rtnSndLst.size() > 0) { + // update sounding data so they can be used by Skewt + // Resource and PalletWindow + if (rawData) + rtnSndLst = NsharpDataHandling + .sortObsSoundingDataForShow(rtnSndLst, + sndPf.getStationElevation()); + else + rtnSndLst = NsharpDataHandling + .organizeSoundingDataForShow(rtnSndLst, + sndPf.getStationElevation()); + // minimum rtnSndList size will be 2 (50 & 75 mb layers), + // but that is not enough + // We need at least 2 regular layers for plotting + if (rtnSndLst != null && rtnSndLst.size() > 4) { + String dispInfo = ""; + for (NsharpStationInfo StnPt : stnPtDataLineLst) { + if (StnPt.getReftime().getTime() == sndPf + .getFcsTime()) { + dispInfo = StnPt.getStnDisplayInfo(); + break; + } + } + soundingLysLstMap.put(dispInfo, rtnSndLst); + } + } + } + // } + } + + } + } diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpAbstractPaneResource.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpAbstractPaneResource.java index f1fb1f4e9d..f4930ca4f2 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpAbstractPaneResource.java +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpAbstractPaneResource.java @@ -1,4 +1,5 @@ package gov.noaa.nws.ncep.ui.nsharp.display.rsc; + /** * * @@ -53,273 +54,404 @@ import com.raytheon.viz.core.ColorUtil; import com.raytheon.viz.core.graphing.WGraphics; import com.vividsolutions.jts.geom.Coordinate; -public class NsharpAbstractPaneResource extends AbstractVizResource{ - NsharpNative nsharpNative=null; - protected IGraphicsTarget target=null; - protected Rectangle rectangle; - protected WGraphics world; - protected PixelExtent pe; - protected static final UnitConverter celciusToFahrenheit = SI.CELSIUS.getConverterTo(NonSI.FAHRENHEIT); - protected static final UnitConverter celciusToKelvin = SI.CELSIUS.getConverterTo(SI.KELVIN); - protected List soundingLys = null; - protected List previousSoundingLys = null; - protected NsharpResourceHandler rscHandler=null; - protected NsharpGraphProperty graphConfigProperty=null; - protected HashMap linePropertyMap=null; - protected int currentSoundingLayerIndex =0; - protected IFont font9=null; - protected IFont font10=null; - protected IFont font11=null; - protected IFont font12=null; - protected float currentFont10Size=10; +public class NsharpAbstractPaneResource extends + AbstractVizResource { + NsharpNative nsharpNative = null; + + protected IGraphicsTarget target = null; + + protected Rectangle rectangle; + + protected WGraphics world; + + protected PixelExtent pe; + + protected static final UnitConverter celciusToFahrenheit = SI.CELSIUS + .getConverterTo(NonSI.FAHRENHEIT); + + protected static final UnitConverter celciusToKelvin = SI.CELSIUS + .getConverterTo(SI.KELVIN); + + protected List soundingLys = null; + + protected List previousSoundingLys = null; + + protected NsharpResourceHandler rscHandler = null; + + protected NsharpGraphProperty graphConfigProperty = null; + + protected HashMap linePropertyMap = null; + + protected int currentSoundingLayerIndex = 0; + + protected IFont font9 = null; + + protected IFont font10 = null; + + protected IFont font11 = null; + + protected IFont font12 = null; + + protected IFont font20 = null; // d2dlite + + protected float currentFont10Size = 10; + protected int commonLinewidth; + protected LineStyle commonLineStyle; + protected Coordinate interactiveTempPointCoordinate; - protected Float currentZoomLevel=1f; - protected float currentCanvasBoundWidth;//= NsharpConstants.DEFAULT_CANVAS_WIDTH; - protected float currentCanvasBoundHeight; //= NsharpConstants.DEFAULT_CANVAS_HEIGHT; - protected float myDefaultCanvasHeight;// = NsharpConstants.DEFAULT_CANVAS_HEIGHT*4/5; - protected float myDefaultCanvasWidth;//= NsharpConstants.DEFAULT_CANVAS_WIDTH/2; - //protected Float zoomLevel; - protected boolean resize=false; - protected String paneConfigurationName; + + protected Float currentZoomLevel = 1f; + + protected float currentCanvasBoundWidth;// = + // NsharpConstants.DEFAULT_CANVAS_WIDTH; + + protected float currentCanvasBoundHeight; // = + // NsharpConstants.DEFAULT_CANVAS_HEIGHT; + + protected float myDefaultCanvasHeight;// = + // NsharpConstants.DEFAULT_CANVAS_HEIGHT*4/5; + + protected float myDefaultCanvasWidth;// = + // NsharpConstants.DEFAULT_CANVAS_WIDTH/2; + + // protected Float zoomLevel; + protected boolean resize = false; + + protected String paneConfigurationName; + public static final float INVALID_DATA = NsharpNativeConstants.NSHARP_NATIVE_INVALID_DATA; - protected Coordinate cursorCor; - protected int charHeight = NsharpConstants.CHAR_HEIGHT_; - protected double charWidth; + + protected Coordinate cursorCor; + + protected double charHeight = NsharpConstants.CHAR_HEIGHT_; // d2dlite + + protected double charWidth; + + // d2dlite + protected double lineHeight = charHeight * 1.2; + protected PaintProperties paintProps; - - public NsharpAbstractPaneResource(AbstractResourceData resourceData, - LoadProperties loadProperties, NsharpAbstractPaneDescriptor desc) { - super(resourceData, loadProperties); - descriptor = desc; - this.dataTimes = new ArrayList(); - - } - @Override - protected void disposeInternal() { - if(font9!=null){ - font9.dispose(); - font9=null; - } - if(font10!=null){ - font10.dispose(); - font10=null; - } - if(font11!=null){ - font11.dispose(); - font11=null; - } - if(font12!=null){ - font12.dispose(); - font12=null; - } - this.target.dispose(); - target = null; - } + protected boolean sidePaneMode = false; // FixMark:sidePaneLooping d2dlite + public NsharpAbstractPaneResource(AbstractResourceData resourceData, + LoadProperties loadProperties, NsharpAbstractPaneDescriptor desc) { + super(resourceData, loadProperties); + descriptor = desc; + this.dataTimes = new ArrayList(); - @Override - protected void paintInternal(IGraphicsTarget target, - PaintProperties paintProps) throws VizException { - this.paintProps = paintProps; - this.target = target; - if(rscHandler== null || rscHandler.getSoundingLys()==null) - return; - float zoomLevel = paintProps.getZoomLevel(); - /*if( currentCanvasBoundWidth!= paintProps.getCanvasBounds().width || currentCanvasBoundHeight!=paintProps.getCanvasBounds().height){ + } - currentCanvasBoundWidth= paintProps.getCanvasBounds().width; - currentCanvasBoundHeight=paintProps.getCanvasBounds().height; - adjustFontSize(currentCanvasBoundWidth,currentCanvasBoundHeight); - } - */ - //System.out.println("currentZoomLevel="+currentZoomLevel+" paintProps's zoomLevel="+zoomLevel); - if(zoomLevel > 1.0f) - zoomLevel = 1.0f; - if((zoomLevel != currentZoomLevel) ){ - currentZoomLevel = zoomLevel; - handleZooming(); - - } - if(this.resize==true ){ - handleResize(); - } - } + @Override + protected void disposeInternal() { + if (font9 != null) { + font9.dispose(); + font9 = null; + } + if (font10 != null) { + font10.dispose(); + font10 = null; + } + if (font11 != null) { + font11.dispose(); + font11 = null; + } + if (font12 != null) { + font12.dispose(); + font12 = null; + } + if (font20 != null) { // d2dlite + font20.dispose(); + font20 = null; + } + this.target.dispose(); + target = null; + } - @Override - protected void initInternal(IGraphicsTarget target) throws VizException { - this.target = target; - this.font9 = target.initializeFont("Monospace", 9, null); - this.font10 = target.initializeFont("Monospace", 10, null); - this.font11 = target.initializeFont("Monospace", 11, null); - IFont.Style[] style = {IFont.Style.BOLD}; - this.font12 = target.initializeFont("Monospace", 12, style); - this.font9.setSmoothing(false); - this.font9.setScaleFont(false); - this.font10.setSmoothing(false); - this.font10.setScaleFont(false); - this.font11.setSmoothing(false); - this.font11.setScaleFont(false); - this.font12.setSmoothing(false); - this.font12.setScaleFont(false); - commonLinewidth = getCapability(OutlineCapability.class).getOutlineWidth(); - commonLineStyle = getCapability(OutlineCapability.class) - .getLineStyle(); - this.resize=true ; - //nsharpNative = new NsharpNative(); - //System.out.println("NsharpDefaultPaneResource ::: initInternal with native "+ nsharpNative.toString()); - } - - @SuppressWarnings("deprecation") - public void resetData(List soundingLys, List prevsoundingLys){ - this.soundingLys = soundingLys; - this.previousSoundingLys = prevsoundingLys; - descriptor.setFrame(0); - } + @Override + protected void paintInternal(IGraphicsTarget target, + PaintProperties paintProps) throws VizException { + this.paintProps = paintProps; + this.target = target; + if (rscHandler == null || rscHandler.getSoundingLys() == null) + return; + float zoomLevel = paintProps.getZoomLevel(); + /* + * if( currentCanvasBoundWidth!= paintProps.getCanvasBounds().width || + * currentCanvasBoundHeight!=paintProps.getCanvasBounds().height){ + * + * currentCanvasBoundWidth= paintProps.getCanvasBounds().width; + * currentCanvasBoundHeight=paintProps.getCanvasBounds().height; + * adjustFontSize(currentCanvasBoundWidth,currentCanvasBoundHeight); } + */ + // System.out.println("currentZoomLevel="+currentZoomLevel+" paintProps's zoomLevel="+zoomLevel); + if (zoomLevel > 1.0f) + zoomLevel = 1.0f; + if ((zoomLevel != currentZoomLevel)) { + currentZoomLevel = zoomLevel; + handleZooming(); - public WGraphics getWorld() { - return world; - } - - - protected void adjustFontSize(float canvasW, float canvasH ) { - float font9Size,font10Size,font11Size,font12Size; - - float fontAdjusted=0; - float fontBaseH=90f; //Chin: why 70 & 100? After many "try and error" experiments... - float fontBaseW=120f; - if(canvasH < myDefaultCanvasHeight && canvasW< myDefaultCanvasWidth){ - //both width and height are smaller than default - float wAdjust = (float)(myDefaultCanvasWidth-canvasW)/fontBaseW; - float hAdjust = (float)(myDefaultCanvasHeight-canvasH)/fontBaseH; - fontAdjusted = Math.max(wAdjust,hAdjust); - } - else if(canvasW< myDefaultCanvasWidth){ - // only width smaller than default - fontAdjusted = (float)(myDefaultCanvasWidth-canvasW)/fontBaseW; - } - else if(canvasH < myDefaultCanvasHeight ){ - // only height smaller than default - fontAdjusted = (float)(myDefaultCanvasHeight-canvasH)/fontBaseH; - } - //Chin: Can not bigger than 9, otherwise, fint9 size willbe negative. - //Why 8.8 ? After many "try and error" experiments... - if(fontAdjusted > 8.8) - fontAdjusted=8.8f; - - font9Size = 9-fontAdjusted; - font10Size = 10-fontAdjusted; - font11Size =11-fontAdjusted; - font12Size = 12-fontAdjusted; + } + if (this.resize == true) { + handleResize(); + } + } - if(font9!=null){ - font9.dispose(); - } - font9 = target.initializeFont("Monospace", font9Size, null); - - if(font10!=null){ - font10.dispose(); - } - font10 = target.initializeFont("Monospace", font10Size, null); - if(font11!=null){ - font11.dispose(); - } - font11 = target.initializeFont("Monospace", font11Size, null); - if(font12!=null){ - font12.dispose(); - } - IFont.Style[] style = {IFont.Style.BOLD}; - font12 = target.initializeFont("Monospace", font12Size, style); - currentFont10Size = font10Size; - //System.out.println(descriptor.getPaneNumber()+": adjusted font10 size ="+currentFont10Size); - } - protected void magnifyFont(double zoomLevel) { - float magFactor = 1.0f / (float)zoomLevel; - font9.setMagnification(magFactor); - font10.setMagnification(magFactor); - font11.setMagnification(magFactor); - font12.setMagnification(magFactor); - } - @Override + @Override + protected void initInternal(IGraphicsTarget target) throws VizException { + this.target = target; + this.font9 = target.initializeFont("Monospace", 9, null); + this.font10 = target.initializeFont("Monospace", 10, null); + this.font11 = target.initializeFont("Monospace", 11, null); + IFont.Style[] style = { IFont.Style.BOLD }; + this.font12 = target.initializeFont("Monospace", 12, style); + this.font20 = target.initializeFont("Monospace", 20, null); // d2dlite + this.font9.setSmoothing(false); + this.font9.setScaleFont(false); + this.font10.setSmoothing(false); + this.font10.setScaleFont(false); + this.font11.setSmoothing(false); + this.font11.setScaleFont(false); + this.font12.setSmoothing(false); + this.font12.setScaleFont(false); + this.font20.setSmoothing(false); // d2dlite + this.font20.setScaleFont(false); + commonLinewidth = getCapability(OutlineCapability.class) + .getOutlineWidth(); + commonLineStyle = getCapability(OutlineCapability.class).getLineStyle(); + this.resize = true; + // nsharpNative = new NsharpNative(); + // System.out.println("NsharpDefaultPaneResource ::: initInternal with native "+ + // nsharpNative.toString()); + } + + @SuppressWarnings("deprecation") + public void resetData(List soundingLys, + List prevsoundingLys) { + this.soundingLys = soundingLys; + this.previousSoundingLys = prevsoundingLys; + descriptor.setFrame(0); + } + + public WGraphics getWorld() { + return world; + } + + protected void adjustFontSize(float canvasW, float canvasH) { + float font9Size, font10Size, font11Size, font12Size, font20Size; // d2dlite + + float fontAdjusted = 0; + float fontBaseH = 90f; // Chin: why 70 & 100? After many "try and error" + // experiments... + float fontBaseW = 120f; + if (canvasH < myDefaultCanvasHeight && canvasW < myDefaultCanvasWidth) { + // both width and height are smaller than default + float wAdjust = (float) (myDefaultCanvasWidth - canvasW) + / fontBaseW; + float hAdjust = (float) (myDefaultCanvasHeight - canvasH) + / fontBaseH; + fontAdjusted = Math.max(wAdjust, hAdjust); + } else if (canvasW < myDefaultCanvasWidth) { + // only width smaller than default + fontAdjusted = (float) (myDefaultCanvasWidth - canvasW) / fontBaseW; + } else if (canvasH < myDefaultCanvasHeight) { + // only height smaller than default + fontAdjusted = (float) (myDefaultCanvasHeight - canvasH) + / fontBaseH; + } + // Chin: Can not bigger than 9, otherwise, fint9 size willbe negative. + // Why 8.8 ? After many "try and error" experiments... + if (fontAdjusted > 8.8) + fontAdjusted = 8.8f; + + font9Size = 9 - fontAdjusted; + font10Size = 10 - fontAdjusted; + font11Size = 11 - fontAdjusted; + font12Size = 12 - fontAdjusted; + font20Size = 20 - fontAdjusted; // d2dlite + + if (font9 != null) { + font9.dispose(); + } + font9 = target.initializeFont("Monospace", font9Size, null); + + if (font10 != null) { + font10.dispose(); + } + font10 = target.initializeFont("Monospace", font10Size, null); + if (font11 != null) { + font11.dispose(); + } + font11 = target.initializeFont("Monospace", font11Size, null); + if (font12 != null) { + font12.dispose(); + } + IFont.Style[] style = { IFont.Style.BOLD }; + font12 = target.initializeFont("Monospace", font12Size, style); + // d2dlite + if (font20 != null) { + font20.dispose(); + } + font20 = target.initializeFont("Monospace", font20Size, style); + currentFont10Size = font10Size; + // System.out.println(descriptor.getPaneNumber()+": adjusted font10 size ="+currentFont10Size); + } + + protected void magnifyFont(double zoomLevel) { + float magFactor = 1.0f / (float) zoomLevel; + font9.setMagnification(magFactor); + font10.setMagnification(magFactor); + font11.setMagnification(magFactor); + font12.setMagnification(magFactor); + font20.setMagnification(magFactor); // d2dlite + } + + @Override public void setDescriptor(NsharpAbstractPaneDescriptor descriptor) { super.setDescriptor(descriptor); RGB rgb = ColorUtil.getNewColor(descriptor); getCapability(ColorableCapability.class).setColor(rgb); - //System.out.println("screwT Rsc setDescriptor called"); + // System.out.println("screwT Rsc setDescriptor called"); } - public void setSoundingLys(List soundingLys) { - this.soundingLys = soundingLys; - } + public void setSoundingLys(List soundingLys) { + this.soundingLys = soundingLys; + } - public HashMap getLinePropertyMap() { - return linePropertyMap; - } + public HashMap getLinePropertyMap() { + return linePropertyMap; + } - public void setLinePropertyMap( - HashMap linePropertyMap) { - this.linePropertyMap = linePropertyMap; - - } + public void setLinePropertyMap( + HashMap linePropertyMap) { + this.linePropertyMap = linePropertyMap; - public NsharpGraphProperty getGraphConfigProperty() { - return graphConfigProperty; - } + } - public void setGraphConfigProperty(NsharpGraphProperty graphConfigProperty) { - this.graphConfigProperty = graphConfigProperty; - paneConfigurationName = this.graphConfigProperty.getPaneConfigurationName(); - - } + public NsharpGraphProperty getGraphConfigProperty() { + return graphConfigProperty; + } - public NsharpResourceHandler getRscHandler() { - return rscHandler; - } + public void setGraphConfigProperty(NsharpGraphProperty graphConfigProperty) { + this.graphConfigProperty = graphConfigProperty; + paneConfigurationName = this.graphConfigProperty + .getPaneConfigurationName(); - public int getCurrentSoundingLayerIndex() { - return currentSoundingLayerIndex; - } + } - public void setRscHandler(NsharpResourceHandler rscHandler) { - this.rscHandler = rscHandler; - if(descriptor != null) - descriptor.setRscHandler(rscHandler); - } + public NsharpResourceHandler getRscHandler() { + return rscHandler; + } + + public int getCurrentSoundingLayerIndex() { + return currentSoundingLayerIndex; + } + + public void setRscHandler(NsharpResourceHandler rscHandler) { + this.rscHandler = rscHandler; + if (descriptor != null) + descriptor.setRscHandler(rscHandler); + } + + public void setNsharpNative(NsharpNative nsharpNative) { + this.nsharpNative = nsharpNative; + } + + public void handleResize() { + this.resize = false; + // double vertRatio = paintProps.getView().getExtent().getHeight() / + // paintProps.getCanvasBounds().height; + // double hRatio = paintProps.getView().getExtent().getWidth() / + // paintProps.getCanvasBounds().width; + // System.out.println(descriptor.getPaneNumber()+"viewWidth="+paintProps.getView().getExtent().getWidth()+" viewHeight="+paintProps.getView().getExtent().getHeight() + // ); + // System.out.println(descriptor.getPaneNumber()+"canvWidth="+paintProps.getCanvasBounds().width+" canvHeight="+paintProps.getCanvasBounds().height + // ); + // System.out.println(descriptor.getPaneNumber()+": vertRatio="+vertRatio + // + " hRatio="+hRatio); + if (paintProps != null + && (currentCanvasBoundWidth != paintProps.getCanvasBounds().width || currentCanvasBoundHeight != paintProps + .getCanvasBounds().height)) { + currentCanvasBoundWidth = paintProps.getCanvasBounds().width; + currentCanvasBoundHeight = paintProps.getCanvasBounds().height; + adjustFontSize(currentCanvasBoundWidth, currentCanvasBoundHeight); + } + + } + + public void setResize(boolean resize) { + this.resize = resize; + } + + public void handleZooming() { + + } + + // FixMark:sidePaneLooping + public boolean isSidePaneMode() { + return sidePaneMode; + } + + // FixMark:sidePaneLooping + public void setSidePaneMode(boolean sidePaneMode) { + this.sidePaneMode = sidePaneMode; + } + + protected void defineCharHeight(IFont font) { + if (paintProps == null) + return; + DrawableString str = new DrawableString("CHINCHEN", + NsharpConstants.color_black); + str.font = font; + double vertRatio = paintProps.getView().getExtent().getHeight() + / paintProps.getCanvasBounds().height; + double horizRatio = paintProps.getView().getExtent().getWidth() + / paintProps.getCanvasBounds().width; + charHeight = target.getStringsBounds(str).getHeight() * vertRatio; // d2dlite + lineHeight = charHeight * 1.2; // d2dlite + charWidth = target.getStringsBounds(str).getWidth() * horizRatio / 8; + + } + + // d2dlite start + protected String timeDescriptionToDisplayStr(String timeDescription) { + /* + * As of 2014 April 9, current time description string is defined as + * "YYMMDD/HH(DOW)" or "YYMMDD/HH(DOW)Vxxx". Convert them to + * "DD.HH(DOW)" or "DD.HHVxxx(DOW)" for GUI display. + */ + String rtnStr = timeDescription.substring(4); // get rid of YYMM + if (rtnStr.contains("V")) { + String[] s1Str = rtnStr.split("V"); // split DD/HH(DOW)Vxxx to + // "DD/HH(DOW)" and "xxx" + String[] s2Str = s1Str[0].split("\\("); // split "DD/HH(DOW)" to + // "DD/HH" and "DOW)" + rtnStr = s2Str[0] + "V" + s1Str[1] + "(" + s2Str[1]; // put together + // to + // "DD/HHVxxx(DOW)" + } + rtnStr = rtnStr.replace("/", "."); // replace "/" with "." + return rtnStr; + } + + protected String pickedStnInfoStrToDisplayStr(String pickedStnInfoStr) { + /* + * As of 2014 April 9, current pickedStnInfoStr string is defined as + * "stnId YYMMDD/HH(DOW)Vxxx sndType". This function is to convert it to + * "stnId DD.HHVxxx(DOW) sndType" for GUI display. for example, + * "ATLH 101209/03(Thu)V003 GFS230" converts to + * "ATLH 09.03V003(Thu) GFS230" + */ + String[] s1Str = pickedStnInfoStr.split(" "); + if (s1Str.length == 3) { + String rtnStr = timeDescriptionToDisplayStr(s1Str[1]); + rtnStr = s1Str[0] + " " + rtnStr + " " + s1Str[2]; + return rtnStr; + } else + return pickedStnInfoStr; // not a good input, just return it + } + // d2dlite end - public void setNsharpNative(NsharpNative nsharpNative) { - this.nsharpNative = nsharpNative; - } - public void handleResize(){ - this.resize=false; - //double vertRatio = paintProps.getView().getExtent().getHeight() / paintProps.getCanvasBounds().height; - //double hRatio = paintProps.getView().getExtent().getWidth() / paintProps.getCanvasBounds().width; - //System.out.println(descriptor.getPaneNumber()+"viewWidth="+paintProps.getView().getExtent().getWidth()+" viewHeight="+paintProps.getView().getExtent().getHeight() ); - //System.out.println(descriptor.getPaneNumber()+"canvWidth="+paintProps.getCanvasBounds().width+" canvHeight="+paintProps.getCanvasBounds().height ); - //System.out.println(descriptor.getPaneNumber()+": vertRatio="+vertRatio + " hRatio="+hRatio); - if(paintProps!=null && (currentCanvasBoundWidth!= paintProps.getCanvasBounds().width || currentCanvasBoundHeight!=paintProps.getCanvasBounds().height)){ - currentCanvasBoundWidth= paintProps.getCanvasBounds().width; - currentCanvasBoundHeight=paintProps.getCanvasBounds().height; - adjustFontSize(currentCanvasBoundWidth,currentCanvasBoundHeight); - } - - } - public void setResize(boolean resize) { - this.resize = resize; - } - public void handleZooming(){ - - } - protected void defineCharHeight(IFont font){ - if(paintProps == null) - return; - DrawableString str =new DrawableString("CHINCHEN",NsharpConstants.color_black); - str.font = font; - double vertRatio = paintProps.getView().getExtent().getHeight() / paintProps.getCanvasBounds().height; - double horizRatio = paintProps.getView().getExtent().getWidth() / paintProps.getCanvasBounds().width; - charHeight = (int) (target.getStringsBounds(str).getHeight() * vertRatio); - charWidth = target.getStringsBounds(str).getWidth() * horizRatio /8; - //System.out.println(descriptor.getPaneNumber()+": font10 char height ="+charHeight+ " vertRatio="+vertRatio); - } } diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpDataPaneResource.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpDataPaneResource.java index cc97b6713f..ffbd9e4af9 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpDataPaneResource.java +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpDataPaneResource.java @@ -1,4 +1,5 @@ package gov.noaa.nws.ncep.ui.nsharp.display.rsc; + /** * * @@ -10,6 +11,7 @@ package gov.noaa.nws.ncep.ui.nsharp.display.rsc; * Date Ticket# Engineer Description * ------- ------- -------- ----------- * 04/23/2012 229 Chin Chen Initial coding + * 04/23/2014 Chin Chen Add d2d lite page * * * @@ -48,3338 +50,4351 @@ import com.raytheon.viz.core.graphing.WindBarbFactory; import com.sun.jna.ptr.FloatByReference; import com.vividsolutions.jts.geom.Coordinate; -public class NsharpDataPaneResource extends NsharpAbstractPaneResource{ - private int currentTextChapter= 1; - private int[] pageDisplayOrderNumberArray; //index is the real page defined in NsharpConstants to be shown, value is the order number of this page. index 0 point to a dummy. - private static final String NO_DATA = "NO VALID DATA AVAILABLE"; - //private double charHeight = NsharpConstants.CHAR_HEIGHT_; - private double curY; - private double parcelLineYStart, parcelLineYEnd; - private double firstToken, secondToken, thirdToken, forthToken, fifthToken, sixthToken; - private FloatByReference fValue= new FloatByReference(0); - private FloatByReference fValue1= new FloatByReference(0); - private FloatByReference fValue2= new FloatByReference(0); - private FloatByReference fValue3= new FloatByReference(0); - private FloatByReference fValue4= new FloatByReference(0); - private FloatByReference fValue5= new FloatByReference(0); - private FloatByReference fValue6= new FloatByReference(0); - private FloatByReference fValue7= new FloatByReference(0); - private FloatByReference fValue8= new FloatByReference(0); - private PixelExtent extent; - // physical number of panel in editor display - // total software defined panels to be displayed - private Rectangle[] panelRectArray= new Rectangle[NsharpConstants.dsiplayPanelSize] ; - private int numberPagePerDisplay = 1; - private NsharpGenericPaneBackground dataPanel1Background; - private NsharpGenericPaneBackground dataPanel2Background; - private int dataPaneWidth= NsharpConstants.DATA_PANE_REC_WIDTH; - private int dataPaneHeight= NsharpConstants.DATA_PANE_REC_HEIGHT; - //private int dataWidth = NsharpConstants.DATAPANEL1_WIDTH; - //private int dataHeight = NsharpConstants.DATAPANEL1_HEIGHT; - private int dp1XOrig = NsharpConstants.DATAPANEL1_X_ORIG; - private int dp1YOrig = NsharpConstants.DATAPANEL1_Y_ORIG; - private int dp2XOrig = NsharpConstants.DATAPANEL2_X_ORIG; - private int dp2YOrig = NsharpConstants.DATAPANEL2_Y_ORIG; - private float xRatio=1; - private float yRatio=1; - private IFont myfont=font10; - private boolean initDone=false; - private short currentParcel= NsharpNativeConstants.PARCELTYPE_MOST_UNSTABLE;; - //private int parcelLinesInPhysicalPanelNumber; - private boolean sumP1Visible = false; - public NsharpDataPaneResource(AbstractResourceData resourceData, - LoadProperties loadProperties, NsharpAbstractPaneDescriptor desc) { - super(resourceData, loadProperties, desc); - dataPanel1Background = new NsharpGenericPaneBackground(new Rectangle(NsharpConstants.DATAPANEL1_X_ORIG,NsharpConstants.DATAPANEL1_Y_ORIG, - NsharpConstants.DATAPANEL1_WIDTH,NsharpConstants.DATAPANEL1_HEIGHT)); - dataPanel2Background = new NsharpGenericPaneBackground(new Rectangle(NsharpConstants.DATAPANEL2_X_ORIG,NsharpConstants.DATAPANEL2_Y_ORIG, - NsharpConstants.DATAPANEL2_WIDTH,NsharpConstants.DATAPANEL2_HEIGHT)); - } +public class NsharpDataPaneResource extends NsharpAbstractPaneResource { + private int currentTextChapter = 1; + private int[] pageDisplayOrderNumberArray; // index is the real page defined + // in NsharpConstants to be + // shown, value is the order + // number of this page. index 0 + // point to a dummy. - @Override - protected void paintInternal(IGraphicsTarget target, - PaintProperties paintProps) throws VizException { - super.paintInternal(target, paintProps); - dataPanel1Background.paint(target, paintProps); - if(!paneConfigurationName.equals(NsharpConstants.PANE_SIMPLE_D2D_CFG_STR)){ - dataPanel2Background.paint(target, paintProps); - } - if(rscHandler== null) - return; - - if((soundingLys != null) && (soundingLys.size()>= 4)) - { - this.myfont.setSmoothing(false); - this.myfont.setScaleFont(false); - // write to panels - //Chin: Note: - // Current display algorithm is: One chapter = 2 pages. show 2 pages at one time. - // i.e. show current page and its next page with 2 physical panels. - // currently, we have total of 10 "pages" to display on 2 "physical - // display panels per design. - sumP1Visible = false; - currentTextChapter = rscHandler.getCurrentTextChapter(); - if(numberPagePerDisplay==1) - drawPanel(target,currentTextChapter,1); - else if (numberPagePerDisplay==2){ - for (int i = currentTextChapter*numberPagePerDisplay -1, physicalPanelNum = 1; i <= currentTextChapter*numberPagePerDisplay; i++, physicalPanelNum++){ - int pageNum = i%10; - if (pageNum==0) - pageNum=10; + private static final String NO_DATA = "NO VALID DATA AVAILABLE"; - drawPanel(target,pageNum,physicalPanelNum); - //System.out.println("current chapter="+currentTextChapter+" page num="+pageNum+ " disPanel="+physicalPanelNum); - } - } - } - } - @Override - protected void initInternal(IGraphicsTarget target) throws VizException { - super.initInternal(target); - //currentCanvasBoundWidth = NsharpConstants.DATA_PANE_REC_WIDTH; - //currentCanvasBoundHeight = NsharpConstants.DATA_PANE_REC_HEIGHT; - if(paneConfigurationName.equals(NsharpConstants.PANE_DEF_CFG_2_STR)|| - paneConfigurationName.equals(NsharpConstants.PANE_SPCWS_CFG_STR )|| - paneConfigurationName.equals(NsharpConstants.PANE_SIMPLE_D2D_CFG_STR)){ - myDefaultCanvasWidth = (int) (NsharpConstants.DISPLAY_WIDTH * (1-NsharpConstants.PANE_DEF_CFG_2_LEFT_GP_WIDTH_RATIO)* NsharpConstants.PANE_DEF_CFG_2_DATA_WIDTH_RATIO); - myDefaultCanvasHeight = (int) (NsharpConstants.DISPLAY_HEIGHT*NsharpConstants.PANE_DEF_CFG_2_DATA_HEIGHT_RATIO); - } else if(paneConfigurationName.equals(NsharpConstants.PANE_DEF_CFG_1_STR)){ - myDefaultCanvasWidth = (int) (NsharpConstants.DISPLAY_WIDTH * (1-NsharpConstants.PANE_DEF_CFG_1_LEFT_GP_WIDTH_RATIO)* NsharpConstants.PANE_DEF_CFG_1_DATA_WIDTH_RATIO); - myDefaultCanvasHeight = (int) (NsharpConstants.DISPLAY_HEIGHT*NsharpConstants.PANE_DEF_CFG_1_DATA_HEIGHT_RATIO); - } - //System.out.println("data pane default canv W="+myDefaultCanvasWidth+" h="+myDefaultCanvasHeight); - panelRectArray[0] = dataPanel1Background.getRectangle(); - panelRectArray[1] = dataPanel2Background.getRectangle(); - dataPanel1Background.initInternal(target); - dataPanel2Background.initInternal(target); - if(numberPagePerDisplay == 1) - myfont = font12; - else - myfont = font10; - handleResize(); - initDone = true; - } - - public void setCurrentParcel(short currentParcel) { - this.currentParcel = currentParcel; - } + // private double charHeight = NsharpConstants.CHAR_HEIGHT_; + private double curY; - public short getCurrentParcel() { - return currentParcel; - } - public void resetCurrentParcel() { - currentParcel= NsharpNativeConstants.PARCELTYPE_MOST_UNSTABLE; - } + private double parcelLineYStart, parcelLineYEnd; - @Override - public void resetData(List soundingLys, - List prevsoundingLys) { - - super.resetData(soundingLys, prevsoundingLys); - currentParcel= NsharpNativeConstants.PARCELTYPE_MOST_UNSTABLE; - } + private double firstToken, secondToken, thirdToken, forthToken, fifthToken, + sixthToken; + private FloatByReference fValue = new FloatByReference(0); - private void drawPanel(IGraphicsTarget target, int pageOrderNumber, int dsiplayPanelNumber - ) throws VizException { - if(pageOrderNumber > NsharpConstants.PAGE_MAX_NUMBER || dsiplayPanelNumber > numberPagePerDisplay)// NsharpConstants.dsiplayPanelSize) - return; - int physicalPanelNumber = dsiplayPanelNumber -1; - int displayPageNumber=0; - // find a page with its order number equal to pageOrderNumber - for(int i=1; i <= NsharpConstants.PAGE_MAX_NUMBER; i++){ - if(pageDisplayOrderNumberArray[i]==pageOrderNumber) - displayPageNumber =i; // array index is the page number and value is the order number - } - switch(displayPageNumber){ - case NsharpConstants.PAGE_SUMMARY1: - drawPanel1(target, panelRectArray[physicalPanelNumber]); - break; - case NsharpConstants.PAGE_SUMMARY2: - drawPanel2(target, panelRectArray[physicalPanelNumber]); - break; - case NsharpConstants.PAGE_PARCEL_DATA: - drawPanel3(target, panelRectArray[physicalPanelNumber]); - break; - case NsharpConstants.PAGE_THERMODYNAMIC_DATA: - drawPanel4(target, panelRectArray[physicalPanelNumber]); - break; - case NsharpConstants.PAGE_OPC_DATA: - drawPanel5(target, panelRectArray[physicalPanelNumber]); - break; - case NsharpConstants.PAGE_MIXING_HEIGHT: - drawPanel6(target, panelRectArray[physicalPanelNumber]); - break; - case NsharpConstants.PAGE_STORM_RELATIVE: - drawPanel7(target, panelRectArray[physicalPanelNumber]); - break; - case NsharpConstants.PAGE_MEAN_WIND: - drawPanel8(target, panelRectArray[physicalPanelNumber]); - break; - case NsharpConstants.PAGE_CONVECTIVE_INITIATION: - drawPanel9(target, panelRectArray[physicalPanelNumber]); - break; - case NsharpConstants.PAGE_SEVERE_POTENTIAL: - drawPanel10(target, panelRectArray[physicalPanelNumber]); - break; - default: - break; - } - } - public void setUserPickedParcelLine(Coordinate c) { - //make sure is in virtualPanel 1 as Parcel Line is defined in it. - if(rscHandler != null){ - if(!sumP1Visible) - return; - } - else - return; - //System.out.println("setUserPickedParcelLine c.y="+ c.y+ " parcelLineYStart="+ parcelLineYStart+" parcelLineYEnd="+parcelLineYEnd); - //make sure within parcel line area - if(c.y >= parcelLineYStart && c.y <=parcelLineYEnd){ - int index =((int)(c.y - parcelLineYStart))/ (int)charHeight; - if( index < NsharpNativeConstants.PARCEL_MAX){ - currentParcel = (short) (index + 1); - //System.out.println("setUserPickedParcelLine at "+ currentParcel); - //notify skewtRsc - rscHandler.updateParcelFromPanel(currentParcel); - } - } - } - @SuppressWarnings("deprecation") - private void drawPanel1(IGraphicsTarget target, Rectangle rect - ) throws VizException { - sumP1Visible =true; - extent = new PixelExtent(rect); - target.setupClippingPlane(extent); - - /* - * Chin's NOTE:::: - * This pages based on newer version nsharp from SPC. We dont have source code as of 7/8/2010. - * Therefore, coding is purly based on a captured screen shot given by SPC's John Hart. - * This function is coded based on native nsharp codes which can be found - * in other pages's show functions. - * - * - */ - //if we can not Interpolates a temp with 700 mb pressure, then we dont have enough raw data - if ((nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib.itemp(700.0F)) == 0)) - { - target.drawString(myfont, " " +NO_DATA, rect.x, rect.y, 0.0, - TextStyle.NORMAL, NsharpConstants.color_cyan, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - return; - } - - //call get_topBotPres to set p_top and p_bot - FloatByReference topPF= new FloatByReference(0); - FloatByReference botPF= new FloatByReference(0); - nsharpNative.nsharpLib.get_effectLayertopBotPres(topPF, botPF); - - String textStr, CAPE3Str="", NCAPEStr=""; - curY=rect.y; - - // - // Start with Parcel Data - // - Rectangle2D strBD = target.getStringBounds(myfont, NsharpNativeConstants.PAGE1TEXT1_FCST_STR+"XX"); - double hRatio = paintProps.getView().getExtent().getWidth() / paintProps.getCanvasBounds().width; - double startX = rect.x + 0.5*charWidth; - double widthGap = (rect.width-strBD.getWidth()*hRatio*xRatio)/6;//was -100*xRatio)/6; - firstToken=rect.x+strBD.getWidth()*hRatio*xRatio;//was +100.0*xRatio; - secondToken=firstToken+widthGap; - thirdToken=secondToken+widthGap; - forthToken=thirdToken+widthGap; - fifthToken = forthToken+widthGap; - sixthToken = fifthToken+widthGap; - target.drawString(myfont, "Sum1", startX, rect.y , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - target.drawString(myfont, "CAPE", firstToken, rect.y , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - target.drawString(myfont, "CINH", secondToken, rect.y , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - target.drawString(myfont, "LCL", thirdToken, rect.y , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - target.drawString(myfont, "LI", forthToken, rect.y , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - target.drawString(myfont, "LFC", fifthToken, rect.y , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - target.drawString(myfont, "EL", sixthToken, rect.y , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY+charHeight; - target.drawLine(rect.x, curY, 0.0, rect.x+rect.width, curY, 0.0, NsharpConstants.color_white, 1); - parcelLineYStart = curY; - float layerPressure = 0; - - //get user selected parcel type - _lplvalues lpvls; - _parcel pcl; - //curY = curY+ (double)charHeight * 0.5; - for (short parcelNumber=1; parcelNumber <= NsharpNativeConstants.PARCEL_MAX ; parcelNumber++){ - if(parcelNumber == currentParcel ){ - PixelExtent pixExt = new PixelExtent(rect.x, rect.x+ rect.width,curY, curY+charHeight); - //target.setupClippingPlane(pixExt); - target.drawRect(pixExt, NsharpConstants.color_gold, 1.0f, 1.0f); - } - //call native define_parcel() with parcel type and user defined pressure (if user defined it) - textStr = NsharpNativeConstants.parcelToTypeStrMap.get(parcelNumber); - target.drawString(myfont, textStr, startX, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - float layerPressure1 = NsharpNativeConstants.parcelToLayerMap.get(parcelNumber); - if(parcelNumber == NsharpNativeConstants.PARCELTYPE_USER_DEFINED){ - //get user selected parcel type, if available - layerPressure1 = NsharpParcelDialog.getUserDefdParcelMb(); - } - //System.out.println("drawPanel1-1 called define_parcel pType="+parcelNumber+" pre="+ layerPressure1); + private FloatByReference fValue1 = new FloatByReference(0); - nsharpNative.nsharpLib.define_parcel(parcelNumber,layerPressure1); + private FloatByReference fValue2 = new FloatByReference(0); - lpvls = new _lplvalues(); - nsharpNative.nsharpLib.get_lpvaluesData(lpvls); + private FloatByReference fValue3 = new FloatByReference(0); - float sfctemp, sfcdwpt, sfcpres; - sfctemp = lpvls.temp; - sfcdwpt = lpvls.dwpt; - sfcpres = lpvls.pres; - // get parcel data by calling native nsharp parcel() API. value is returned in pcl - pcl = new _parcel(); - nsharpNative.nsharpLib.parcel( -1.0F, -1.0F, sfcpres, sfctemp, sfcdwpt, pcl); - //draw parcel name - //draw CAPE - if(pcl.bplus != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA) - target.drawString(myfont, String.format( "%.0f", pcl.bplus), firstToken, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - else - target.drawString(myfont, "M", firstToken, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - //draw CINH - if(pcl.bminus != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA) - target.drawString(myfont, String.format("%.0f", pcl.bminus), secondToken, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - else - target.drawString(myfont, "M", secondToken, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - //draw LCL - float lcl = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(pcl.lclpres )); - if(lcl != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA) - target.drawString(myfont, String.format("%.0fm", lcl), thirdToken, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); + private FloatByReference fValue4 = new FloatByReference(0); - else - target.drawString(myfont, "M", thirdToken, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - //draw LI - if(pcl.li5 != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA) - target.drawString(myfont, String.format("%5.0f", pcl.li5), forthToken, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - else - target.drawString(myfont, "M", forthToken, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - //draw LFC - float lfc = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(pcl.lfcpres )); - if(lfc != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA) - target.drawString(myfont, String.format("%.0fm", lfc), fifthToken, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - else - target.drawString(myfont, "M", fifthToken, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - // draw EL - float el = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(pcl.elpres )); - if(el != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA) - target.drawString(myfont, String.format("%.0f'", NsharpConstants.metersToFeet.convert(el)), sixthToken, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - else - target.drawString(myfont, "M", sixthToken, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); + private FloatByReference fValue5 = new FloatByReference(0); - curY = curY+charHeight; - //get 3CAPE value for later to use - if(parcelNumber == NsharpNativeConstants.PARCELTYPE_MEAN_MIXING){ - if(nsharpNative.nsharpLib.qc(pcl.cape3km)==1) { - CAPE3Str = String.format("%.0fJ/kg", pcl.cape3km); - } - else { - CAPE3Str = " M"; - } - }//get NCAPE value for later to use - else if(parcelNumber == NsharpNativeConstants.PARCELTYPE_MOST_UNSTABLE){ - float j1 = pcl.bplus; - float j2 = nsharpNative.nsharpLib.ihght(pcl.elpres) - nsharpNative.nsharpLib.ihght(pcl.lfcpres); - if(nsharpNative.nsharpLib.qc(j1/j2)==1) { - NCAPEStr = String.format("%.2f",j1/j2); - } - else { - NCAPEStr = "NCAPE= M"; - } - } - } - target.drawLine(rect.x, curY, 0.0, rect.x+rect.width, curY, 0.0, NsharpConstants.color_white, 1); - parcelLineYEnd= curY; - if(currentParcel == NsharpNativeConstants.PARCELTYPE_USER_DEFINED){ - layerPressure = NsharpParcelDialog.getUserDefdParcelMb(); - } - else - layerPressure = NsharpNativeConstants.parcelToLayerMap.get(currentParcel); - //System.out.println("drawPanel1-2 called define_parcel pType="+currentParcel+" pre="+ layerPressure); + private FloatByReference fValue6 = new FloatByReference(0); - //reset and define current parcel - nsharpNative.nsharpLib.define_parcel(currentParcel,layerPressure); - lpvls = new _lplvalues(); - nsharpNative.nsharpLib.get_lpvaluesData(lpvls); + private FloatByReference fValue7 = new FloatByReference(0); - float sfctemp, sfcdwpt, sfcpres; - sfctemp = lpvls.temp; - sfcdwpt = lpvls.dwpt; - sfcpres = lpvls.pres; - // get parcel data by calling native nsharp parcel() API. value is returned in pcl - pcl = new _parcel(); - nsharpNative.nsharpLib.parcel( -1.0F, -1.0F, sfcpres, sfctemp, sfcdwpt, pcl); - // - // THERMO DYNAMIC DATA - // - firstToken = rect.x + rect.width/48*12*xRatio; - secondToken = rect.x + rect.width/48*27*xRatio; - thirdToken = rect.x + rect.width/48*38*xRatio; - //curY = curY+ (double)charHeight * 0.5; - DrawableString str = new DrawableString("ABCDE=", NsharpConstants.color_white); - str.font = myfont; - double equalSignPos=(startX+target.getStringsBounds(str).getWidth())*hRatio*xRatio; - fValue.setValue(0); - nsharpNative.nsharpLib.precip_water(fValue, -1.0F, -1.0F); - if(nsharpNative.nsharpLib.qc(fValue.getValue())==1) { - textStr = String.format("%.2f in", fValue.getValue()); - } - else { - textStr = " M"; - } - str.setCoordinates(startX, curY); - str.horizontalAlignment = HorizontalAlignment.LEFT; - str.verticallAlignment = VerticalAlignment.TOP; - str.font = myfont; - str.setText("PW=", NsharpConstants.color_white); - DrawableString str1 =new DrawableString(textStr,NsharpConstants.color_white); - str1.setCoordinates(equalSignPos, curY); - str1.horizontalAlignment = HorizontalAlignment.LEFT; - str1.verticallAlignment = VerticalAlignment.TOP; - str1.font = myfont; - target.drawStrings(str, str1); - - //3CAPE...value was retrieved earlier - str.setText("3CAPE=", NsharpConstants.color_white); - str.setCoordinates(firstToken, curY); - str1.setText(CAPE3Str,NsharpConstants.color_white); - str1.setCoordinates(firstToken+equalSignPos, curY); - target.drawStrings(str, str1); - - fValue.setValue(0); - float wbzft = nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(nsharpNative.nsharpLib.wb_lvl( 0, fValue )))); - if(nsharpNative.nsharpLib.qc(wbzft)==1) { - textStr = String.format("%.0f'",wbzft); - } - else { - textStr = " M"; - } - str.setText("WBZ=", NsharpConstants.color_white); - str.setCoordinates(secondToken, curY); - str1.setText(textStr,NsharpConstants.color_white); - str1.setCoordinates(secondToken+equalSignPos, curY); - target.drawStrings(str, str1); - - - //WNDG - float wndg = nsharpNative.nsharpLib.damaging_wind(); - if(nsharpNative.nsharpLib.qc(wndg)==1) { - textStr = String.format("%.2f",wndg); - } - else { - textStr = " M"; - } - str.setText("WNDG=", NsharpConstants.color_white); - str.setCoordinates(thirdToken, curY); - str1.setText(textStr,NsharpConstants.color_white); - str1.setCoordinates(thirdToken+equalSignPos, curY); - target.drawStrings(str, str1); - - curY = curY+charHeight; //move to new line + private FloatByReference fValue8 = new FloatByReference(0); - fValue.setValue(0); - nsharpNative.nsharpLib.k_index(fValue); - if(nsharpNative.nsharpLib.qc(fValue.getValue())==1) { - textStr = String.format("%.0f",fValue.getValue()); - } - else { - textStr = " M"; - } - str.setText("K=", NsharpConstants.color_white); - str.setCoordinates(startX, curY); - str1.setText(textStr,NsharpConstants.color_white); - str1.setCoordinates(equalSignPos, curY); - target.drawStrings(str, str1); - //DCAPE - //fValue1 will be used for DownT to use - float dcape= nsharpNative.nsharpLib.dcape(fValue, fValue1); - float downT = fValue1.getValue(); - if(nsharpNative.nsharpLib.qc(dcape)==1) { - textStr = String.format("%.0fJ/kg",dcape); - } - else { - textStr = " M"; - } - str.setText("DCAPE=", NsharpConstants.color_white); - str.setCoordinates(firstToken, curY); - str1.setText(textStr,NsharpConstants.color_white); - str1.setCoordinates(firstToken+equalSignPos, curY); - target.drawStrings(str, str1); + private PixelExtent extent; - //FZL - fValue.setValue(0); - float fgzft = nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(nsharpNative.nsharpLib.temp_lvl( 0, fValue )))); - if(nsharpNative.nsharpLib.qc(fgzft)==1) { - textStr = String.format("%.0f'",fgzft); - } - else { - textStr = " M"; - } - str.setText("FZL=", NsharpConstants.color_white); - str.setCoordinates(secondToken, curY); - str1.setText(textStr,NsharpConstants.color_white); - str1.setCoordinates(secondToken+equalSignPos, curY); - target.drawStrings(str, str1); - //ESP - float esp= nsharpNative.nsharpLib.esp(); - if(nsharpNative.nsharpLib.qc(esp)==1) { - textStr = String.format("%.2f",esp); - } - else { - textStr = " M"; - } - str.setText("ESP=", NsharpConstants.color_white); - str.setCoordinates(thirdToken, curY); - str1.setText(textStr,NsharpConstants.color_white); - str1.setCoordinates(thirdToken+equalSignPos, curY); - target.drawStrings(str, str1); - - curY = curY+charHeight; //move to new line - - fValue.setValue(0); - //MidRH - nsharpNative.nsharpLib.get_surface(fValue1, fValue2, fValue3); //fValue 2 and fValue3 are not of concern here - nsharpNative.nsharpLib.mean_relhum( fValue, fValue1.getValue() - 150, fValue1.getValue() - 350 ); - if(nsharpNative.nsharpLib.qc(fValue.getValue())==1) { - textStr = String.format("%.0f%c",fValue.getValue(),NsharpConstants.PERCENT_SYMBOL); - } - else { - textStr = " M"; - } - str.setText("MidRH=", NsharpConstants.color_white); - str.setCoordinates(startX, curY); - str1.setText(textStr,NsharpConstants.color_white); - str1.setCoordinates(equalSignPos, curY); - target.drawStrings(str, str1); - //DownT - downT = nsharpNative.nsharpLib.ctof(downT) ; //convert to F - if(nsharpNative.nsharpLib.qc( downT)==1) { - textStr = String.format("%.0fF",downT); - } - else { - textStr = " M"; - } - str.setText("DownT=", NsharpConstants.color_white); - str.setCoordinates(firstToken, curY); - str1.setText(textStr,NsharpConstants.color_white); - str1.setCoordinates(firstToken+equalSignPos, curY); - target.drawStrings(str, str1); - //ConvT - fValue.setValue(0); - float conTempF = nsharpNative.nsharpLib.ctof(nsharpNative.nsharpLib.cnvtv_temp( fValue, -1)); - - if(nsharpNative.nsharpLib.qc( conTempF )==1) { - textStr = String.format("%.0fF",conTempF); - } - else { - textStr = " M"; - } - str.setText("ConvT=", NsharpConstants.color_white); - str.setCoordinates(secondToken, curY); - str1.setText(textStr,NsharpConstants.color_white); - str1.setCoordinates(secondToken+equalSignPos, curY); - target.drawStrings(str, str1); + // physical number of panel in editor display + // total software defined panels to be displayed + private Rectangle[] panelRectArray = new Rectangle[NsharpConstants.dsiplayPanelSize]; - //MMP: Coniglio MCS Maintenance Parameter - float mmp = nsharpNative.nsharpLib.coniglio1(); - if(nsharpNative.nsharpLib.qc( mmp )==1) { - textStr = String.format("%.2f",mmp); - } - else { - textStr = " M"; - } - str.setText("MMP=", NsharpConstants.color_white); - str.setCoordinates(thirdToken, curY); - str1.setText(textStr,NsharpConstants.color_white); - str1.setCoordinates(thirdToken+equalSignPos, curY); - target.drawStrings(str, str1); - - curY = curY+charHeight; //move to new line + private int numberPagePerDisplay = 1; - fValue.setValue(0); - fValue1.setValue(0); - // get surface pressure (fValue1) before getting mean LRH value - nsharpNative.nsharpLib.get_surface(fValue1, fValue2, fValue3); //fValue 2 and fValue3 are not of concern here - nsharpNative.nsharpLib.mean_relhum( fValue, -1.0F, fValue1.getValue() - 150 ); - if(nsharpNative.nsharpLib.qc(fValue.getValue())==1) { - //textStr = NsharpNativeConstants.THERMO_MEANLRH_LINE; - textStr = String.format("%.0f%c",fValue.getValue(),NsharpConstants.PERCENT_SYMBOL); - } - else { - textStr = " M"; - } - str.setText("LowRH=", NsharpConstants.color_white); - str.setCoordinates(startX, curY); - str1.setText(textStr,NsharpConstants.color_white); - str1.setCoordinates(equalSignPos, curY); - target.drawStrings(str, str1); - - fValue.setValue(0); - nsharpNative.nsharpLib.mean_mixratio(fValue, -1.0F, -1.0F); - if(nsharpNative.nsharpLib.qc(fValue.getValue())==1) { - textStr = String.format("%.1fg/kg",fValue.getValue()); - } - else { - textStr = " M"; - } - str.setText("MeanW=", NsharpConstants.color_white); - str.setCoordinates(firstToken, curY); - str1.setText(textStr,NsharpConstants.color_white); - str1.setCoordinates(firstToken+equalSignPos, curY); - target.drawStrings(str, str1); + private NsharpGenericPaneBackground dataPanel1Background; - fValue.setValue(0); - float maxT= nsharpNative.nsharpLib.ctof(nsharpNative.nsharpLib.max_temp( fValue, -1)); - if(nsharpNative.nsharpLib.qc(maxT)==1) { - textStr = String.format("%.0fF",maxT); - } - else { - textStr = " M"; - } - str.setText("MaxT=", NsharpConstants.color_white); - str.setCoordinates(secondToken, curY); - str1.setText(textStr,NsharpConstants.color_white); - str1.setCoordinates(secondToken+equalSignPos, curY); - target.drawStrings(str, str1); + private NsharpGenericPaneBackground dataPanel2Background; - //NCAPE - str.setText("NCAPE=", NsharpConstants.color_white); - str.setCoordinates(thirdToken, curY); - str1.setText(NCAPEStr,NsharpConstants.color_white); - str1.setCoordinates(thirdToken+equalSignPos, curY); - target.drawStrings(str, str1); + private int dataPaneWidth = NsharpConstants.DATA_PANE_REC_WIDTH; - curY = curY+charHeight; //move to new line - target.drawLine(rect.x, curY, 0.0, rect.x+rect.width, curY, 0.0, NsharpConstants.color_white, 1); - - //draw a vertical line from 2/3 of x axis - str.setText("sfc-3km AglLapseRate=xxC/x.xC/kmX",NsharpConstants.color_black); - str.font = myfont; - double lineXPos = target.getStringsBounds(str).getWidth()*hRatio*xRatio; - if(lineXPos < rect.width *2/3) - lineXPos = rect.width *2/3; - firstToken=rect.x+lineXPos; - target.drawLine(firstToken, curY, 0.0, firstToken, rect.y+rect.height, 0.0, NsharpConstants.color_white, 1); - //curY = curY+ (double)charHeight * 0.5; - firstToken = firstToken + 0.5*charWidth; - - // more thermodynamic data - // the following follow show_parcel_new() at xwvid.c of bigNsharp implementation - // sfc-3km Lapse rate - // - float htsfc =0; - float tDelta = nsharpNative.nsharpLib.aglT(0, 3000); - fValue.setValue(0); - // get surface pressure (fValue) - nsharpNative.nsharpLib.get_surface(fValue, fValue1, fValue2); - if(nsharpNative.nsharpLib.qc(fValue.getValue())==1) { - htsfc = nsharpNative.nsharpLib.ihght(fValue.getValue()); - // get sfc to (sfc+ 3 km) pressure (fValue) - float threekmPre = nsharpNative.nsharpLib.ipres(htsfc+3000); - fValue1.setValue(0); - nsharpNative.nsharpLib.lapse_rate( fValue1, fValue.getValue(), threekmPre ); - if(nsharpNative.nsharpLib.qc(fValue1.getValue())==1) { - //textStr = String.format("sfc-3km AglLapseRate=%.0fC/%.1fC/km", tDelta, fValue1.getValue()); - textStr = String.format("%.0fC/%.1fC/km", tDelta, fValue1.getValue()); - } - else { - textStr = " M";// "sfc-3km AglLapseRate= M"; - } - } - else { - textStr = " M";//"sfc-3km AglLapseRate= M"; - } - str.setText("sfc-3km Agl LapseRate= ", NsharpConstants.color_white); - str.setCoordinates(startX, curY); - equalSignPos=rect.x+target.getStringsBounds(str).getWidth()*hRatio*xRatio; - str1.setText(textStr,NsharpConstants.color_white); - str1.setCoordinates(equalSignPos, curY); - target.drawStrings(str, str1); - - /*target.drawString(myfont, textStr, startX, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null);*/ - - - //"Supercell" - float smdir = rscHandler.getSmWindDir();//bkRsc.getSmDir(); #10438 - float smspd = rscHandler.getSmWindSpd();//bkRsc.getSmSpd(); - float superCell = nsharpNative.nsharpLib.scp(smdir, smspd); - if(nsharpNative.nsharpLib.qc(superCell)==1) { - textStr = String.format("%.1f",superCell); - } - else { - textStr = " M"; - } - str.setText("Supercell= ", NsharpConstants.color_yellow); - double equalSignPos1=firstToken+target.getStringsBounds(str).getWidth()*hRatio*xRatio; - str.setCoordinates(firstToken, curY); - str1.setText(textStr,NsharpConstants.color_yellow); - str1.setCoordinates(equalSignPos1, curY); - target.drawStrings(str, str1); - /*target.drawString(myfont, textStr, firstToken, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_yellow, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null);*/ - - curY = curY+charHeight; //move to new line - - // 3km-6km Lapse rate - fValue.setValue(0); - fValue1.setValue(0); - tDelta = nsharpNative.nsharpLib.aglT(3000, 6000); - // get 3 and 6km pressure (fValue) - float threekmPre = nsharpNative.nsharpLib.ipres(htsfc+3000); - float sixkmPre = nsharpNative.nsharpLib.ipres(htsfc+6000); - fValue1.setValue(0); - nsharpNative.nsharpLib.lapse_rate( fValue1, threekmPre,sixkmPre ); - if(nsharpNative.nsharpLib.qc(fValue1.getValue())==1) { - textStr = String.format("%.0fC/%.1fC/km", tDelta, fValue1.getValue()); + private int dataPaneHeight = NsharpConstants.DATA_PANE_REC_HEIGHT; - } - else { - textStr = " M"; - } - str.setText("3-6km Agl LapseRate=", NsharpConstants.color_white); - str.setCoordinates(startX, curY); - str1.setText(textStr,NsharpConstants.color_white); - str1.setCoordinates(equalSignPos, curY); - target.drawStrings(str, str1); - /*target.drawString(myfont, textStr, startX, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null);*/ - // "STP (CIN)" - float cin = nsharpNative.nsharpLib.sigtorn_cin(smdir, smspd); - if(nsharpNative.nsharpLib.qc(cin)==1) { - textStr = String.format("%.1f",cin); - } - else { - textStr = " M"; - } - str.setText("STP(CIN)=", NsharpConstants.color_white); - str.setCoordinates(firstToken, curY); - str1.setText(textStr,NsharpConstants.color_white); - str1.setCoordinates(equalSignPos1, curY); - target.drawStrings(str, str1); - /*target.drawString(myfont, textStr, firstToken, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null);*/ + // private int dataWidth = NsharpConstants.DATAPANEL1_WIDTH; + // private int dataHeight = NsharpConstants.DATAPANEL1_HEIGHT; + private int dp1XOrig = NsharpConstants.DATAPANEL1_X_ORIG; - curY = curY+charHeight; //move to new line + private int dp1YOrig = NsharpConstants.DATAPANEL1_Y_ORIG; + private int dp2XOrig = NsharpConstants.DATAPANEL2_X_ORIG; - fValue.setValue(0); - fValue1.setValue(0); - //nsharpNative.nsharpLib.vert_tot(fValue); - float delta= nsharpNative.nsharpLib.itemp(850) - nsharpNative.nsharpLib.itemp(500); - nsharpNative.nsharpLib.lapse_rate( fValue1, 850.0F, 500.0F ); - if(nsharpNative.nsharpLib.qc(delta)==1 && nsharpNative.nsharpLib.qc(fValue1.getValue())==1) { - textStr = String.format("%.0fC/%.1fC/km",delta, fValue1.getValue()); - } - else { - textStr = " M"; - } - str.setText("850-500mb LapseRate=", NsharpConstants.color_white); - str.setCoordinates(startX, curY); - str1.setText(textStr,NsharpConstants.color_white); - str1.setCoordinates(equalSignPos, curY); - target.drawStrings(str, str1); - /*target.drawString(myfont, textStr, startX, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null);*/ - // "STP(fixed)" - float fixedStp = nsharpNative.nsharpLib.sigtorn_fixed(smdir, smspd); - if(nsharpNative.nsharpLib.qc(fixedStp)==1) { - textStr = String.format("%.1f",fixedStp); - } - else { - textStr = " M"; - } - str.setText("STP(fixed)=", NsharpConstants.color_white); - str.setCoordinates(firstToken, curY); - str1.setText(textStr,NsharpConstants.color_white); - str1.setCoordinates(equalSignPos1, curY); - target.drawStrings(str, str1); - /*target.drawString(myfont, textStr, firstToken, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null);*/ + private int dp2YOrig = NsharpConstants.DATAPANEL2_Y_ORIG; - curY = curY+charHeight; //move to new line + private float xRatio = 1; - fValue.setValue(0); - fValue1.setValue(0); - //nsharpNative.nsharpLib.delta_t(fValue); - nsharpNative.nsharpLib.lapse_rate( fValue1, 700.0F, 500.0F ); - delta= nsharpNative.nsharpLib.itemp(700) - nsharpNative.nsharpLib.itemp(500); - if(nsharpNative.nsharpLib.qc(/*fValue.getValue())*/delta)==1 && nsharpNative.nsharpLib.qc(fValue1.getValue())==1) { - textStr = String.format("%.0fC/%.1fC/km",delta/*fValue.getValue()*/, fValue1.getValue()); - } - else { - textStr = " M"; - } - str.setText("700-500mb LapseRate=", NsharpConstants.color_white); - str.setCoordinates(startX, curY); - str1.setText(textStr,NsharpConstants.color_white); - str1.setCoordinates(equalSignPos, curY); - target.drawStrings(str, str1); - /*target.drawString(myfont, textStr, startX, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null);*/ - // "SHIP" - float ship = nsharpNative.nsharpLib.cave_ship(); - if(nsharpNative.nsharpLib.qc(ship)==1) { - textStr = String.format("%.1f",ship); - } - else - textStr = " M"; - str.setText("SHIP=", NsharpConstants.color_red); - str.setCoordinates(firstToken, curY); - str1.setText(textStr,NsharpConstants.color_red); - str1.setCoordinates(equalSignPos1, curY); - target.drawStrings(str, str1); - /*target.drawString(myfont, textStr, firstToken, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_red, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null);*/ - //System.out.println("shop="+ship); - //myfont.dispose(); + private float yRatio = 1; + + private IFont defaultFont = font10; + + private boolean initDone = false; + + private boolean resizedone = false; // d2dlite + + private short currentParcel = NsharpNativeConstants.PARCELTYPE_MOST_UNSTABLE;; + + // private int parcelLinesInPhysicalPanelNumber; + private boolean sumP1Visible = false; + + public NsharpDataPaneResource(AbstractResourceData resourceData, + LoadProperties loadProperties, NsharpAbstractPaneDescriptor desc) { + super(resourceData, loadProperties, desc); + dataPanel1Background = new NsharpGenericPaneBackground(new Rectangle( + NsharpConstants.DATAPANEL1_X_ORIG, + NsharpConstants.DATAPANEL1_Y_ORIG, + NsharpConstants.DATAPANEL1_WIDTH, + NsharpConstants.DATAPANEL1_HEIGHT)); + dataPanel2Background = new NsharpGenericPaneBackground(new Rectangle( + NsharpConstants.DATAPANEL2_X_ORIG, + NsharpConstants.DATAPANEL2_Y_ORIG, + NsharpConstants.DATAPANEL2_WIDTH, + NsharpConstants.DATAPANEL2_HEIGHT)); } - @SuppressWarnings("deprecation") - private void drawPanel2(IGraphicsTarget target, Rectangle rect) throws VizException - { - /* - * Chin's NOTE:::: - * This pages based on BigNsharp - * show_shear_new() at xwvid3.c - * - */ - - extent = new PixelExtent(rect); + + @Override + protected void paintInternal(IGraphicsTarget target, + PaintProperties paintProps) throws VizException { + super.paintInternal(target, paintProps); + dataPanel1Background.paint(target, paintProps); + if (numberPagePerDisplay == 2) { + dataPanel2Background.paint(target, paintProps); + } + if (rscHandler == null) + return; + + if (!resizedone) { + resizedone = true; + handleResize(); + } + + if ((soundingLys != null) && (soundingLys.size() >= 4)) { + this.defaultFont.setSmoothing(false); + this.defaultFont.setScaleFont(false); + // write to panels + // Chin: Note: + // Current display algorithm is: One chapter = 2 pages. show 2 pages + // at one time. + // i.e. show current page and its next page with 2 physical panels. + // currently, we have total of 11 "pages" to display on 2 "physical + // display panels per design. + sumP1Visible = false; + currentTextChapter = rscHandler.getCurrentTextChapter(); + if (numberPagePerDisplay == 1) + drawPanel(target, currentTextChapter, 1); + else if (numberPagePerDisplay == 2) { + for (int i = currentTextChapter * numberPagePerDisplay - 1, physicalPanelNum = 1; i <= currentTextChapter + * numberPagePerDisplay; i++, physicalPanelNum++) { + int pageNum = i % NsharpConstants.PAGE_MAX_NUMBER; // d2dlite + if (pageNum == 0) + pageNum = NsharpConstants.PAGE_MAX_NUMBER; // d2dlite + + drawPanel(target, pageNum, physicalPanelNum); + // System.out.println("current chapter="+currentTextChapter+" page num="+pageNum+ + // " disPanel="+physicalPanelNum); + } + } + } + } + + @Override + protected void initInternal(IGraphicsTarget target) throws VizException { + super.initInternal(target); + if (paneConfigurationName.equals(NsharpConstants.PANE_DEF_CFG_2_STR) + || paneConfigurationName + .equals(NsharpConstants.PANE_SPCWS_CFG_STR) + || paneConfigurationName + .equals(NsharpConstants.PANE_SIMPLE_D2D_CFG_STR)) { + myDefaultCanvasWidth = (int) (NsharpConstants.DISPLAY_WIDTH + * (1 - NsharpConstants.PANE_DEF_CFG_2_LEFT_GP_WIDTH_RATIO) * NsharpConstants.PANE_DEF_CFG_2_DATA_WIDTH_RATIO); + myDefaultCanvasHeight = (int) (NsharpConstants.DISPLAY_HEIGHT * NsharpConstants.PANE_DEF_CFG_2_DATA_HEIGHT_RATIO); + } else if (paneConfigurationName + .equals(NsharpConstants.PANE_DEF_CFG_1_STR)) { + myDefaultCanvasWidth = (int) (NsharpConstants.DISPLAY_WIDTH + * (1 - NsharpConstants.PANE_DEF_CFG_1_LEFT_GP_WIDTH_RATIO) * NsharpConstants.PANE_DEF_CFG_1_DATA_WIDTH_RATIO); + myDefaultCanvasHeight = (int) (NsharpConstants.DISPLAY_HEIGHT * NsharpConstants.PANE_DEF_CFG_1_DATA_HEIGHT_RATIO); + } + // System.out.println("data pane default canv W="+myDefaultCanvasWidth+" h="+myDefaultCanvasHeight); + panelRectArray[0] = dataPanel1Background.getRectangle(); + panelRectArray[1] = dataPanel2Background.getRectangle(); + dataPanel1Background.initInternal(target); + dataPanel2Background.initInternal(target); + if (numberPagePerDisplay == 1) + defaultFont = font12; + else + defaultFont = font10; + handleResize(); + initDone = true; + // System.out.println(": font char height =" + charHeight); + } + + public void setCurrentParcel(short currentParcel) { + this.currentParcel = currentParcel; + } + + public short getCurrentParcel() { + return currentParcel; + } + + public void resetCurrentParcel() { + currentParcel = NsharpNativeConstants.PARCELTYPE_MOST_UNSTABLE; + } + + @Override + public void resetData(List soundingLys, + List prevsoundingLys) { + + super.resetData(soundingLys, prevsoundingLys); + currentParcel = NsharpNativeConstants.PARCELTYPE_MOST_UNSTABLE; + } + + private void drawPanel(IGraphicsTarget target, int pageOrderNumber, + int dsiplayPanelNumber) throws VizException { + if (pageOrderNumber > NsharpConstants.PAGE_MAX_NUMBER + || dsiplayPanelNumber > numberPagePerDisplay)// NsharpConstants.dsiplayPanelSize) + return; + int physicalPanelNumber = dsiplayPanelNumber - 1; + int displayPageNumber = 0; + // find a page with its order number equal to pageOrderNumber + for (int i = 1; i <= NsharpConstants.PAGE_MAX_NUMBER; i++) { + if (pageDisplayOrderNumberArray[i] == pageOrderNumber) + displayPageNumber = i; // array index is the page number and + // value is the order number + } + switch (displayPageNumber) { + case NsharpConstants.PAGE_SUMMARY1: + drawPanel1(target, panelRectArray[physicalPanelNumber]); + break; + case NsharpConstants.PAGE_SUMMARY2: + drawPanel2(target, panelRectArray[physicalPanelNumber]); + break; + case NsharpConstants.PAGE_PARCEL_DATA: + drawPanel3(target, panelRectArray[physicalPanelNumber]); + break; + case NsharpConstants.PAGE_THERMODYNAMIC_DATA: + drawPanel4(target, panelRectArray[physicalPanelNumber]); + break; + case NsharpConstants.PAGE_OPC_DATA: + drawPanel5(target, panelRectArray[physicalPanelNumber]); + break; + case NsharpConstants.PAGE_MIXING_HEIGHT: + drawPanel6(target, panelRectArray[physicalPanelNumber]); + break; + case NsharpConstants.PAGE_STORM_RELATIVE: + drawPanel7(target, panelRectArray[physicalPanelNumber]); + break; + case NsharpConstants.PAGE_MEAN_WIND: + drawPanel8(target, panelRectArray[physicalPanelNumber]); + break; + case NsharpConstants.PAGE_CONVECTIVE_INITIATION: + drawPanel9(target, panelRectArray[physicalPanelNumber]); + break; + case NsharpConstants.PAGE_SEVERE_POTENTIAL: + drawPanel10(target, panelRectArray[physicalPanelNumber]); + break; + case NsharpConstants.PAGE_D2DLITE: // d2dlite + drawPanel11(target, panelRectArray[physicalPanelNumber]); + break; + case NsharpConstants.PAGE_FUTURE: // d2dlite + drawPanel12(target, panelRectArray[physicalPanelNumber]); + break; + default: + break; + } + } + + public void setUserPickedParcelLine(Coordinate c) { + // make sure is in virtualPanel 1 as Parcel Line is defined in it. + if (rscHandler != null) { + if (!sumP1Visible) + return; + } else + return; + // System.out.println("setUserPickedParcelLine c.y="+ c.y+ + // " parcelLineYStart="+ + // parcelLineYStart+" parcelLineYEnd="+parcelLineYEnd); + // make sure within parcel line area + if (c.y >= parcelLineYStart && c.y <= parcelLineYEnd) { + int index = ((int) (c.y - parcelLineYStart)) / (int) charHeight; + if (index < NsharpNativeConstants.PARCEL_MAX) { + currentParcel = (short) (index + 1); + // System.out.println("setUserPickedParcelLine at "+ + // currentParcel); + // notify skewtRsc + rscHandler.updateParcelFromPanel(currentParcel); + } + } + } + + @SuppressWarnings("deprecation") + private void drawPanel1(IGraphicsTarget target, Rectangle rect) + throws VizException { + IFont myfont; + if (paneConfigurationName.equals(NsharpConstants.PANE_LITE_D2D_CFG_STR)) { + myfont = font9; + } else { + myfont = defaultFont; + } + defineCharHeight(myfont); + myfont.setSmoothing(false); + myfont.setScaleFont(false); + sumP1Visible = true; + extent = new PixelExtent(rect); target.setupClippingPlane(extent); - //myfont = target.initializeFont(fontName, 10, null); - curY= rect.y; - String textStr; - - //if we can not Interpolates a temp with 700 mb pressure, then we dont have enough raw data - if (nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib.itemp(700.0F)) == 0) - { - target.drawString(myfont, " " +NO_DATA, rect.x, rect.y, 0.0, - TextStyle.NORMAL, NsharpConstants.color_cyan, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - return; - } - // - // Start with Header SRH(m%c/s%c) Shear(kt) MnWind SRW - // - double startX = rect.x + 0.5*charWidth; - double widthGap = (rect.width)/5; - firstToken=rect.x+widthGap; - secondToken=firstToken+widthGap; - thirdToken=secondToken+widthGap; - forthToken=thirdToken+widthGap; - target.drawString(myfont, "Sum2", startX, rect.y , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); + /* + * Chin's NOTE:::: This pages based on newer version nsharp from SPC. We + * dont have source code as of 7/8/2010. Therefore, coding is purly + * based on a captured screen shot given by SPC's John Hart. This + * function is coded based on native nsharp codes which can be found in + * other pages's show functions. + */ + // if we can not Interpolates a temp with 700 mb pressure, then we dont + // have enough raw data + if ((nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib.itemp(700.0F)) == 0)) { + target.drawString(myfont, " " + NO_DATA, rect.x, + rect.y, 0.0, TextStyle.NORMAL, NsharpConstants.color_cyan, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + return; + } - textStr = String.format("SRH(m%c/s%c)",NsharpConstants.SQUARE_SYMBOL, NsharpConstants.SQUARE_SYMBOL); - target.drawString(myfont, textStr, firstToken, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - target.drawString(myfont, "Shear(kt)", secondToken, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - target.drawString(myfont, "MnWind", thirdToken, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, + // call get_topBotPres to set p_top and p_bot + FloatByReference topPF = new FloatByReference(0); + FloatByReference botPF = new FloatByReference(0); + nsharpNative.nsharpLib.get_effectLayertopBotPres(topPF, botPF); + + String textStr, CAPE3Str = "", NCAPEStr = ""; + curY = rect.y; + + // + // Start with Parcel Data + // + Rectangle2D strBD = target.getStringBounds(myfont, + NsharpNativeConstants.PAGE1TEXT1_FCST_STR + "XX"); + double hRatio = paintProps.getView().getExtent().getWidth() + / paintProps.getCanvasBounds().width; + double startX = rect.x + 0.5 * charWidth; + double widthGap = (rect.width - strBD.getWidth() * hRatio * xRatio) / 6;// was + // -100*xRatio)/6; + firstToken = rect.x + strBD.getWidth() * hRatio * xRatio;// was + // +100.0*xRatio; + secondToken = firstToken + widthGap; + thirdToken = secondToken + widthGap; + forthToken = thirdToken + widthGap; + fifthToken = forthToken + widthGap; + sixthToken = fifthToken + widthGap; + target.drawString(myfont, "Sum1", startX, rect.y, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + target.drawString(myfont, "CAPE", firstToken, rect.y, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + target.drawString(myfont, "CINH", secondToken, rect.y, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + target.drawString(myfont, "LCL", thirdToken, rect.y, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + target.drawString(myfont, "LI", forthToken, rect.y, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + target.drawString(myfont, "LFC", fifthToken, rect.y, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + target.drawString(myfont, "EL", sixthToken, rect.y, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + curY = curY + charHeight; + target.drawLine(rect.x, curY, 0.0, rect.x + rect.width, curY, 0.0, + NsharpConstants.color_white, 1); + parcelLineYStart = curY; + float layerPressure = 0; + + // get user selected parcel type + _lplvalues lpvls; + _parcel pcl; + // curY = curY+ (double)charHeight * 0.5; + for (short parcelNumber = 1; parcelNumber <= NsharpNativeConstants.PARCEL_MAX; parcelNumber++) { + if (parcelNumber == currentParcel) { + PixelExtent pixExt = new PixelExtent(rect.x, rect.x + + rect.width, curY, curY + charHeight); + // target.setupClippingPlane(pixExt); + target.drawRect(pixExt, NsharpConstants.color_gold, 1.0f, 1.0f); + } + // call native define_parcel() with parcel type and user defined + // pressure (if user defined it) + textStr = NsharpNativeConstants.parcelToTypeStrMap + .get(parcelNumber); + target.drawString(myfont, textStr, startX, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + float layerPressure1 = NsharpNativeConstants.parcelToLayerMap + .get(parcelNumber); + if (parcelNumber == NsharpNativeConstants.PARCELTYPE_USER_DEFINED) { + // get user selected parcel type, if available + layerPressure1 = NsharpParcelDialog.getUserDefdParcelMb(); + } + // System.out.println("drawPanel1-1 called define_parcel pType="+parcelNumber+" pre="+ + // layerPressure1); + + nsharpNative.nsharpLib.define_parcel(parcelNumber, layerPressure1); + + lpvls = new _lplvalues(); + nsharpNative.nsharpLib.get_lpvaluesData(lpvls); + + float sfctemp, sfcdwpt, sfcpres; + sfctemp = lpvls.temp; + sfcdwpt = lpvls.dwpt; + sfcpres = lpvls.pres; + // get parcel data by calling native nsharp parcel() API. value is + // returned in pcl + pcl = new _parcel(); + nsharpNative.nsharpLib.parcel(-1.0F, -1.0F, sfcpres, sfctemp, + sfcdwpt, pcl); + // draw parcel name + // draw CAPE + if (pcl.bplus != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA) + target.drawString(myfont, String.format("%.0f", pcl.bplus), + firstToken, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + else + target.drawString(myfont, "M", firstToken, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + // draw CINH + if (pcl.bminus != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA) + target.drawString(myfont, String.format("%.0f", pcl.bminus), + secondToken, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + else + target.drawString(myfont, "M", secondToken, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + // draw LCL + float lcl = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(pcl.lclpres)); + if (lcl != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA) + target.drawString(myfont, String.format("%.0fm", lcl), + thirdToken, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); - target.drawString(myfont, "SRW", forthToken, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY+charHeight; //move to new line - target.drawLine(rect.x, curY, 0.0, rect.x+rect.width, curY, 0.0, NsharpConstants.color_white, 1); - //curY = curY+ (double)charHeight * 0.5; - FloatByReference smdir=new FloatByReference(0), smspd = new FloatByReference(0); - nsharpNative.nsharpLib.get_storm(smspd, smdir); - FloatByReference topPF= new FloatByReference(0); - FloatByReference botPF= new FloatByReference(0); - nsharpNative.nsharpLib.get_effectLayertopBotPres(topPF, botPF); - //System.out.println("top="+topPF.getValue()+" bot="+botPF.getValue()); - for (int i =0; i< NsharpNativeConstants.STORM_MOTION_TYPE_STR1.length; i++){ - float h1, h2; - if(NsharpNativeConstants.STORM_MOTION_TYPE_STR1[i].equals("Eff Inflow Layer")){ - if(botPF.getValue()>0){ - h1 = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(botPF.getValue())); - h2 = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(topPF.getValue())); - } - else{ - h1=-999; - h2=-999; - } - } - else { - h1 = NsharpNativeConstants.STORM_MOTION_HEIGHT1[i][0]; - h2 = NsharpNativeConstants.STORM_MOTION_HEIGHT1[i][1]; - } - //h1 = NsharpNativeConstants.STORM_MOTION_HEIGHT1[i][0]; - //h2 = NsharpNativeConstants.STORM_MOTION_HEIGHT1[i][1]; - if(h1!=-999&& h2!=-999){ - //SRH - //calculate helicity + else + target.drawString(myfont, "M", thirdToken, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + // draw LI + if (pcl.li5 != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA) + target.drawString(myfont, String.format("%5.0f", pcl.li5), + forthToken, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + else + target.drawString(myfont, "M", forthToken, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + // draw LFC + float lfc = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(pcl.lfcpres)); + if (lfc != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA) + target.drawString(myfont, String.format("%.0fm", lfc), + fifthToken, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + else + target.drawString(myfont, "M", fifthToken, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + // draw EL + float el = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(pcl.elpres)); + if (el != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA) + target.drawString( + myfont, + String.format("%.0f'", + NsharpConstants.metersToFeet.convert(el)), + sixthToken, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + else + target.drawString(myfont, "M", sixthToken, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); - float totHeli = nsharpNative.nsharpLib.helicity( h1, - h2, smdir.getValue(), smspd.getValue(), fValue, fValue1); - target.drawString(myfont, NsharpNativeConstants.STORM_MOTION_TYPE_STR1[i], startX, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - - //gc.drawText(NsharpNativeConstants.STORM_MOTION_TYPE_STR[i],0, textLineNumber*textHeight + graphLineNumber); - if(nsharpNative.nsharpLib.qc(fValue.getValue())==1&&nsharpNative.nsharpLib.qc(fValue1.getValue())==1) { - //textStr = NsharpNativeConstants.STORM_MOTION_TYPE_STR[i]+" %.0f"; - textStr = String.format("%.0f", totHeli); - } - else { - textStr = "M"; - } - target.drawString(myfont, textStr, firstToken, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - - //Calculate wind shear - //Note: -1 as first parameter indicating bottom layer is surface layer, see wind.c for wind_shear() source code - nsharpNative.nsharpLib.wind_shear( nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(h1)), nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(h2)), - fValue, fValue1,fValue2, fValue3); - if(nsharpNative.nsharpLib.qc(fValue3.getValue())==1) { - textStr = String.format("%.0f",fValue3.getValue()); - - } - else { - textStr = "M"; - } - target.drawString(myfont, textStr, secondToken, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - - //Calculate mean wind - nsharpNative.nsharpLib.mean_wind( nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(h1)), nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(h2)), fValue, fValue1,fValue2, fValue3); - if(nsharpNative.nsharpLib.qc(fValue2.getValue())==1&&nsharpNative.nsharpLib.qc(fValue3.getValue())==1) { - textStr = String.format("%.0f/%.0f",fValue2.getValue(), fValue3.getValue()); - } - else { - textStr = "M"; - } - target.drawString(myfont, textStr, thirdToken, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - - //calculate pressure-weighted SR mean wind - nsharpNative.nsharpLib.sr_wind( nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(h1)), - nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(h2)), smdir.getValue(), smspd.getValue(), - fValue, fValue1,fValue2, fValue3); - if(nsharpNative.nsharpLib.qc(fValue2.getValue())==1) { - textStr = String.format("%.0f/%.0f",fValue2.getValue(), fValue3.getValue()); - } - else { - textStr = "M"; - } - target.drawString(myfont, textStr, forthToken, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - - if(NsharpNativeConstants.STORM_MOTION_TYPE_STR1[i].equals("Eff Inflow Layer")){ - //draw bax around it - Rectangle rectangle = new Rectangle(rect.x,(int)curY,rect.width,(int)charHeight); - //System.out.println("rect.x="+ rectangle.x+ " y="+ rectangle.y+" w="+rectangle.width+ " h="+rectangle.height); - PixelExtent pixExt = new PixelExtent(rectangle); - target.drawRect(pixExt,NsharpConstants.color_gold, 1.0f, 1.0f); - } - } - curY = curY+charHeight; //move to new line - - } - float pres=0; - short oldlplchoice=3; - float sfctemp, sfcdwpt, sfcpres; - _lplvalues lpvls; - _parcel pcl; - lpvls = new _lplvalues(); - //nsharpNative.nsharpLib.get_lpvaluesData(lpvls); - //sfctemp = lpvls.temp; - //sfcdwpt = lpvls.dwpt; - //sfcpres = lpvls.pres; - // get parcel data by calling native nsharp parcel() API. value is returned in pcl - pcl = new _parcel(); - for (int i =0; i< NsharpNativeConstants.STORM_MOTION_TYPE_STR2.length; i++){ - float h1, h2; - - h1=-999; - h2=-999; - nsharpNative.nsharpLib.get_lpvaluesData(lpvls); - if(NsharpNativeConstants.STORM_MOTION_TYPE_STR2[i].equals("LCL-EL(Cloud Layer)")){ - sfctemp = lpvls.temp; - sfcdwpt = lpvls.dwpt; - sfcpres = lpvls.pres; - nsharpNative.nsharpLib.parcel( -1.0F, -1.0F, sfcpres, sfctemp, sfcdwpt, pcl); - if (pcl.bplus > 0) - { - h1 = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(pcl.lclpres)); - h2 = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(pcl.elpres)); - } - } - else if (NsharpNativeConstants.STORM_MOTION_TYPE_STR2[i].equals("Lower Half Storm Depth")){ - oldlplchoice = lpvls.flag; - nsharpNative.nsharpLib.define_parcel(NsharpNativeConstants.PARCELTYPE_MOST_UNSTABLE, NsharpNativeConstants.MU_LAYER); - nsharpNative.nsharpLib.get_lpvaluesData(lpvls);//regain lpvls value after defined parcel - sfctemp = lpvls.temp; - sfcdwpt = lpvls.dwpt; - sfcpres = lpvls.pres; - nsharpNative.nsharpLib.parcel( -1.0F, -1.0F, sfcpres, sfctemp, sfcdwpt, pcl); - float el = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(pcl.elpres)); - if (pcl.bplus >= 100.0) - { - - float base = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(botPF.getValue())); - float depth = (el - base); - h1 = base; - h2 = base + (depth * 0.5f); - - nsharpNative.nsharpLib.get_lpvaluesData(lpvls); - } - - //System.out.println("drawPanel2-2 called define_parcel pType="+oldlplchoice+" pre="+ pres); - try{ - if(oldlplchoice == NsharpNativeConstants.PARCELTYPE_USER_DEFINED){ - pres = NsharpParcelDialog.getUserDefdParcelMb(); - } - else - pres = NsharpNativeConstants.parcelToLayerMap.get(oldlplchoice); - - //reset and define oldchoice parcel - nsharpNative.nsharpLib.define_parcel(oldlplchoice,pres); - } - catch (NullPointerException e) { - // when in changing pane configuration situation, an odd scenario may happened that - // "oldlplchoice" may be a null, and parcelToLayerMap.get(oldlplchoice); throws a - // NullPointerException. In that case, we do not re-define_parcel and continue on - e.printStackTrace(); - } - - } - else { - h1 = NsharpNativeConstants.STORM_MOTION_HEIGHT2[i][0]; - h2 = NsharpNativeConstants.STORM_MOTION_HEIGHT2[i][1]; - } - if(h1!=-999&& h2!=-999){ - //SRH - //calculate helicity - float totHeli = nsharpNative.nsharpLib.helicity( h1, - h2, smdir.getValue(), smspd.getValue(), fValue, fValue1); - target.drawString(myfont, NsharpNativeConstants.STORM_MOTION_TYPE_STR2[i], startX, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - - //gc.drawText(NsharpNativeConstants.STORM_MOTION_TYPE_STR[i],0, textLineNumber*textHeight + graphLineNumber); - if(nsharpNative.nsharpLib.qc(fValue.getValue())==1&&nsharpNative.nsharpLib.qc(fValue1.getValue())==1) { - //textStr = NsharpNativeConstants.STORM_MOTION_TYPE_STR[i]+" %.0f"; - textStr = String.format("%.0f", totHeli); - } - else { - textStr = "M"; - } - // SR Helicity is not shown for these 4 storm motions, see oroginal BigNsharp show_shear_new() - //target.drawString(myfont, textStr, firstToken, curY , 0.0, - // TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - // VerticalAlignment.TOP, null); - - //Calculate wind shear - //Note: -1 as first parameter indicating bottom layer is surface layer, see wind.c for wind_shear() source code - nsharpNative.nsharpLib.wind_shear( nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(h1)), nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(h2)), - fValue, fValue1,fValue2, fValue3); - if(nsharpNative.nsharpLib.qc(fValue3.getValue())==1) { - textStr = String.format("%.0f",fValue3.getValue()); - - } - else { - textStr = "M"; - } - target.drawString(myfont, textStr, secondToken, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - - //Calculate mean wind - nsharpNative.nsharpLib.mean_wind( nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(h1)), nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(h2)), fValue, fValue1,fValue2, fValue3); - if(nsharpNative.nsharpLib.qc(fValue2.getValue())==1&&nsharpNative.nsharpLib.qc(fValue3.getValue())==1) { - textStr = String.format("%.0f/%.0f",fValue2.getValue(), fValue3.getValue()); - } - else { - textStr = "M"; - } - target.drawString(myfont, textStr, thirdToken, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - - //calculate pressure-weighted SR mean wind - nsharpNative.nsharpLib.sr_wind( nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(h1)), - nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(h2)), smdir.getValue(), smspd.getValue(), - fValue, fValue1,fValue2, fValue3); - if(nsharpNative.nsharpLib.qc(fValue2.getValue())==1) { - textStr = String.format("%.0f/%.0f",fValue2.getValue(), fValue3.getValue()); - } - else { - textStr = "M"; - } - target.drawString(myfont, textStr, forthToken, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - if (NsharpNativeConstants.STORM_MOTION_TYPE_STR2[i].equals("Lower Half Storm Depth")){ - //draw bax around it - Rectangle rectangle = new Rectangle(rect.x,(int)curY,rect.width,(int)charHeight); - //System.out.println("rect.x="+ rectangle.x+ " y="+ rectangle.y+" w="+rectangle.width+ " h="+rectangle.height); - PixelExtent pixExt = new PixelExtent(rectangle); - target.drawRect(pixExt,NsharpConstants.color_gold, 1.0f, 1.0f); - } - } - curY = curY+charHeight; //move to new line - - - } - //align all following parameters output with "Corfidi Downshear" - double hRatio = paintProps.getView().getExtent().getWidth() / paintProps.getCanvasBounds().width; - DrawableString str = new DrawableString("Corfidi Downshear = ", NsharpConstants.color_white); - double equalSignPos= secondToken;//rect.x+target.getStringsBounds(str).getWidth()*hRatio*xRatio; - - //BRN Shear - // get parcel data by calling native nsharp parcel() API. value is returned in pcl - // current parcel is reset earlief already we dont have to call define_parcel() again. - nsharpNative.nsharpLib.get_lpvaluesData(lpvls); - sfctemp = lpvls.temp; - sfcdwpt = lpvls.dwpt; - sfcpres = lpvls.pres; - nsharpNative.nsharpLib.parcel( -1.0F, -1.0F, sfcpres, sfctemp, sfcdwpt, pcl); - - nsharpNative.nsharpLib.cave_bulk_rich2( fValue ); - if(nsharpNative.nsharpLib.qc(fValue.getValue())==1) - textStr = String.format("%.0f m%c/s%c",fValue.getValue(),NsharpConstants.SQUARE_SYMBOL, NsharpConstants.SQUARE_SYMBOL); - else - textStr = " M"; - str.setCoordinates(startX, curY); - str.horizontalAlignment = HorizontalAlignment.LEFT; - str.verticallAlignment = VerticalAlignment.TOP; - str.font = myfont; - str.setText("BRN Shear = ", NsharpConstants.color_white); - DrawableString str1 =new DrawableString(textStr,NsharpConstants.color_white); - str1.setCoordinates(equalSignPos, curY); - str1.horizontalAlignment = HorizontalAlignment.LEFT; - str1.verticallAlignment = VerticalAlignment.TOP; - str1.font = myfont; - target.drawStrings(str, str1); - - curY = curY+charHeight; //move to new line - //4-6km srw - nsharpNative.nsharpLib.sr_wind( nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(4000)), - nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(6000)), smdir.getValue(), smspd.getValue(), - fValue, fValue1,fValue2, fValue3); - if(nsharpNative.nsharpLib.qc(fValue2.getValue())==1) { - textStr = String.format("%.0f/%.0f kt",fValue2.getValue(), fValue3.getValue()); - } - else { - textStr = " M"; - } - str.setText("4-6km SR Wind =", NsharpConstants.color_white); - str.setCoordinates(startX, curY); - str1.setText(textStr,NsharpConstants.color_white); - str1.setCoordinates(equalSignPos, curY); - target.drawStrings(str, str1); - - curY = curY+charHeight; //move to new line - - //Corfidi Downshear, we use fValue3, fValue4 only by calling corfidi_MCS_motion - nsharpNative.nsharpLib.corfidi_MCS_motion(fValue1, fValue2, fValue3, fValue4, fValue5, fValue6, fValue7, fValue8); - textStr = String.format("%.0f/%.0f kt",fValue3.getValue(), fValue4.getValue()); - str.setText("Corfidi Downshear =", NsharpConstants.color_white); - str.setCoordinates(startX, curY); - str1.setText(textStr,NsharpConstants.color_white); - str1.setCoordinates(equalSignPos, curY); - target.drawStrings(str, str1); - curY = curY+charHeight; //move to new line - - //Corfidi Upshear, we use fValue7, fValue8 only by calling corfidi_MCS_motion - textStr = String.format("%.0f/%.0f kt",fValue7.getValue(), fValue8.getValue()); - str.setText("Corfidi Upshear =", NsharpConstants.color_white); - str.setCoordinates(startX, curY); - str1.setText(textStr,NsharpConstants.color_white); - str1.setCoordinates(equalSignPos, curY); - target.drawStrings(str, str1); - curY = curY+charHeight; //move to new line - - //Bunkers Right - nsharpNative.nsharpLib.bunkers_storm_motion(fValue1, fValue2, fValue3, fValue4); - textStr = String.format("%.0f/%.0f kt",fValue3.getValue(), fValue4.getValue()); - str.setText("Bunkers Right =", NsharpConstants.color_red); - str.setCoordinates(startX, curY); - str1.setText(textStr,NsharpConstants.color_red); - str1.setCoordinates(equalSignPos, curY); - target.drawStrings(str, str1); - - - curY = curY+charHeight; //move to new line - //Bunkers Left - nsharpNative.nsharpLib.bunkers_left_motion(fValue1, fValue2, fValue3, fValue4); - textStr = String.format("%.0f/%.0f kt",fValue3.getValue(), fValue4.getValue()); - str.setText("Bunkers Left =", NsharpConstants.color_cyan); - str.setCoordinates(startX, curY); - str1.setText(textStr,NsharpConstants.color_cyan); - str1.setCoordinates(equalSignPos, curY); - target.drawStrings(str, str1); - curY = curY+charHeight; //move to new line - - // STPC(test) - test STP using cape6km - //Chin Note: BigNsharp sigtorn_test always return -9999..a bug - float stpTest = nsharpNative.nsharpLib.sigtorn_test(smdir.getValue(), smspd.getValue()); - //System.out.println("smdir="+smdir.getValue()+"smspd="+ smspd.getValue()+"stpTest="+stpTest+ - // "p_bot="+botPF.getValue()+"p_top="+topPF.getValue()); - if(nsharpNative.nsharpLib.qc(stpTest)==1) - textStr = String.format("%.1f", stpTest); - else - textStr = " M"; - str.setText("STPC(test) =", NsharpConstants.color_white); - str.setCoordinates(startX, curY); - str1.setText(textStr,NsharpConstants.color_white); - str1.setCoordinates(equalSignPos, curY); - target.drawStrings(str, str1); - - //wind barb labels - str1.setText("12345SPACE",NsharpConstants.color_red); // rest str1 to get a right x position - //firstToken = equalSignPos+ (target.getStringsBounds(str1).getMaxX())*hRatio*xRatio; - textStr = "1km"; - str.setText(textStr, NsharpConstants.color_red); - str.setCoordinates(thirdToken, curY); - textStr = " & "; - str1.setText(textStr,NsharpConstants.color_white); - str1.setCoordinates(thirdToken + target.getStringsBounds(str).getWidth()*hRatio*xRatio, curY); - textStr = "6km"; - DrawableString str2 =new DrawableString(textStr,NsharpConstants.color_cyan); - str2.horizontalAlignment = HorizontalAlignment.LEFT; - str2.verticallAlignment = VerticalAlignment.TOP; - str2.font = myfont; - str2.setCoordinates(thirdToken+ (target.getStringsBounds(str).getWidth()+target.getStringsBounds(str1).getWidth())*hRatio*xRatio, curY); - textStr = " AGL Wind Barb"; - DrawableString str3 =new DrawableString(textStr,NsharpConstants.color_white); - str3.horizontalAlignment = HorizontalAlignment.LEFT; - str3.verticallAlignment = VerticalAlignment.TOP; - str3.font = myfont; - str3.setCoordinates(thirdToken + (target.getStringsBounds(str).getWidth()+target.getStringsBounds(str1).getWidth()+target.getStringsBounds(str2).getWidth())*hRatio*xRatio, curY); - target.drawStrings(str, str1, str2, str3); - - //1 km wind barb - double wbToken= (thirdToken+forthToken)/2 ; - str1.setText("1234/56 ktSPACESPACESPACE",NsharpConstants.color_red); // rest str1 to get a right x position - //firstToken = equalSignPos+ (target.getStringsBounds(str1).getMaxX())*hRatio*xRatio; - double yOri = curY- 3* charHeight; - double barbScaleF= charHeight;//12; - List barb = WindBarbFactory.getWindGraphics( - (double)nsharpNative.nsharpLib.iwspd(nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(1000))), - (double)nsharpNative.nsharpLib.iwdir(nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(1000)))); - if (barb != null) { - WindBarbFactory.scaleBarb(barb, barbScaleF); - - double cur0X=wbToken, cur0Y=yOri, cur1X=wbToken, cur1Y=yOri,newY=0; - WindBarbFactory.translateBarb(barb,cur0X ,yOri ); - - for (LineStroke stroke : barb) { - Coordinate point = stroke.getPoint(); - // Chin NOte; when using WindBarbFactory.getWindGraphics() to create barb, the Y axis is growing - // upwards. However, on this canvas, Y axis is growing downwards. Therefore, the following Y coordinate - // adjustment is necessary. - // - newY = yOri - (point.y - yOri ); - // Note: stroke.render(gc, relativeX, relativeY) is not working here. Therefore, need to - // draw wind barb ourself. - if(stroke.getType() == "M"){ - cur0X = point.x; - cur0Y = newY; - } - else if(stroke.getType() == "D"){ - cur1X = point.x; - cur1Y = newY; - target.drawLine(cur0X,cur0Y, 0.0, cur1X, cur1Y,0.0, NsharpConstants.color_red, 1); - // bsteffen added these two lines to fix 50 kts wind barbs - cur0X = cur1X; - cur0Y = cur1Y; - } + curY = curY + charHeight; + // get 3CAPE value for later to use + if (parcelNumber == NsharpNativeConstants.PARCELTYPE_MEAN_MIXING) { + if (nsharpNative.nsharpLib.qc(pcl.cape3km) == 1) { + CAPE3Str = String.format("%.0fJ/kg", pcl.cape3km); + } else { + CAPE3Str = " M"; + } + }// get NCAPE value for later to use + else if (parcelNumber == NsharpNativeConstants.PARCELTYPE_MOST_UNSTABLE) { + float j1 = pcl.bplus; + float j2 = nsharpNative.nsharpLib.ihght(pcl.elpres) + - nsharpNative.nsharpLib.ihght(pcl.lfcpres); + if (nsharpNative.nsharpLib.qc(j1 / j2) == 1) { + NCAPEStr = String.format("%.2f", j1 / j2); + } else { + NCAPEStr = "NCAPE= M"; + } } } - //6 km wind barb - barb.clear(); - barb = WindBarbFactory.getWindGraphics( - (double)nsharpNative.nsharpLib.iwspd(nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(6000))), - (double)nsharpNative.nsharpLib.iwdir(nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(6000)))); - if (barb != null) { - WindBarbFactory.scaleBarb(barb, barbScaleF); - - double cur0X=wbToken, cur0Y=yOri, cur1X=wbToken, cur1Y=yOri,newY=0; - WindBarbFactory.translateBarb(barb,cur0X ,yOri ); - - for (LineStroke stroke : barb) { - Coordinate point = stroke.getPoint(); - // Chin NOte; when using WindBarbFactory.getWindGraphics() to create barb, the Y axis is growing - // upwards. However, on this canvas, Y axis is growing downwards. Therefore, the following Y coordinate - // adjustment is necessary. - newY = yOri - (point.y - yOri ); - // - // Note: stroke.render(gc, relativeX, relativeY) is not working here. Therefore, need to - // draw wind barb ourself. - if(stroke.getType() == "M"){ - cur0X = point.x; - cur0Y = newY; - } - else if(stroke.getType() == "D"){ - cur1X = point.x; - cur1Y = newY; - target.drawLine(cur0X,cur0Y, 0.0, cur1X, cur1Y,0.0, NsharpConstants.color_cyan, 1); - // bsteffen added these two lines to fix 50 kts wind barbs - cur0X = cur1X; - cur0Y = cur1Y; - } - } + target.drawLine(rect.x, curY, 0.0, rect.x + rect.width, curY, 0.0, + NsharpConstants.color_white, 1); + parcelLineYEnd = curY; + if (currentParcel == NsharpNativeConstants.PARCELTYPE_USER_DEFINED) { + layerPressure = NsharpParcelDialog.getUserDefdParcelMb(); + } else + layerPressure = NsharpNativeConstants.parcelToLayerMap + .get(currentParcel); + // System.out.println("drawPanel1-2 called define_parcel pType="+currentParcel+" pre="+ + // layerPressure); + + // reset and define current parcel + nsharpNative.nsharpLib.define_parcel(currentParcel, layerPressure); + lpvls = new _lplvalues(); + nsharpNative.nsharpLib.get_lpvaluesData(lpvls); + + float sfctemp, sfcdwpt, sfcpres; + sfctemp = lpvls.temp; + sfcdwpt = lpvls.dwpt; + sfcpres = lpvls.pres; + // get parcel data by calling native nsharp parcel() API. value is + // returned in pcl + pcl = new _parcel(); + nsharpNative.nsharpLib.parcel(-1.0F, -1.0F, sfcpres, sfctemp, sfcdwpt, + pcl); + // + // THERMO DYNAMIC DATA + // + firstToken = rect.x + rect.width / 48 * 12 * xRatio; + secondToken = rect.x + rect.width / 48 * 27 * xRatio; + thirdToken = rect.x + rect.width / 48 * 38 * xRatio; + // curY = curY+ (double)charHeight * 0.5; + DrawableString str = new DrawableString("ABCDE=", + NsharpConstants.color_white); + str.font = myfont; + double equalSignPos = (startX + target.getStringsBounds(str).getWidth()) + * hRatio * xRatio; + fValue.setValue(0); + nsharpNative.nsharpLib.precip_water(fValue, -1.0F, -1.0F); + if (nsharpNative.nsharpLib.qc(fValue.getValue()) == 1) { + textStr = String.format("%.2f in", fValue.getValue()); + } else { + textStr = " M"; } - //myfont.dispose(); - } - @SuppressWarnings("deprecation") - private void drawPanel3(IGraphicsTarget target,Rectangle rect) - throws VizException { - extent = new PixelExtent(rect); + str.setCoordinates(startX, curY); + str.horizontalAlignment = HorizontalAlignment.LEFT; + str.verticallAlignment = VerticalAlignment.TOP; + str.font = myfont; + str.setText("PW=", NsharpConstants.color_white); + DrawableString str1 = new DrawableString(textStr, + NsharpConstants.color_white); + str1.setCoordinates(equalSignPos, curY); + str1.horizontalAlignment = HorizontalAlignment.LEFT; + str1.verticallAlignment = VerticalAlignment.TOP; + str1.font = myfont; + target.drawStrings(str, str1); + + // 3CAPE...value was retrieved earlier + str.setText("3CAPE=", NsharpConstants.color_white); + str.setCoordinates(firstToken, curY); + str1.setText(CAPE3Str, NsharpConstants.color_white); + str1.setCoordinates(firstToken + equalSignPos, curY); + target.drawStrings(str, str1); + + fValue.setValue(0); + float wbzft = nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib + .agl(nsharpNative.nsharpLib.ihght(nsharpNative.nsharpLib + .wb_lvl(0, fValue)))); + if (nsharpNative.nsharpLib.qc(wbzft) == 1) { + textStr = String.format("%.0f'", wbzft); + } else { + textStr = " M"; + } + str.setText("WBZ=", NsharpConstants.color_white); + str.setCoordinates(secondToken, curY); + str1.setText(textStr, NsharpConstants.color_white); + str1.setCoordinates(secondToken + equalSignPos, curY); + target.drawStrings(str, str1); + + // WNDG + float wndg = nsharpNative.nsharpLib.damaging_wind(); + if (nsharpNative.nsharpLib.qc(wndg) == 1) { + textStr = String.format("%.2f", wndg); + } else { + textStr = " M"; + } + str.setText("WNDG=", NsharpConstants.color_white); + str.setCoordinates(thirdToken, curY); + str1.setText(textStr, NsharpConstants.color_white); + str1.setCoordinates(thirdToken + equalSignPos, curY); + target.drawStrings(str, str1); + + curY = curY + charHeight; // move to new line + + fValue.setValue(0); + nsharpNative.nsharpLib.k_index(fValue); + if (nsharpNative.nsharpLib.qc(fValue.getValue()) == 1) { + textStr = String.format("%.0f", fValue.getValue()); + } else { + textStr = " M"; + } + str.setText("K=", NsharpConstants.color_white); + str.setCoordinates(startX, curY); + str1.setText(textStr, NsharpConstants.color_white); + str1.setCoordinates(equalSignPos, curY); + target.drawStrings(str, str1); + // DCAPE + // fValue1 will be used for DownT to use + float dcape = nsharpNative.nsharpLib.dcape(fValue, fValue1); + float downT = fValue1.getValue(); + if (nsharpNative.nsharpLib.qc(dcape) == 1) { + textStr = String.format("%.0fJ/kg", dcape); + } else { + textStr = " M"; + } + str.setText("DCAPE=", NsharpConstants.color_white); + str.setCoordinates(firstToken, curY); + str1.setText(textStr, NsharpConstants.color_white); + str1.setCoordinates(firstToken + equalSignPos, curY); + target.drawStrings(str, str1); + + // FZL + fValue.setValue(0); + float fgzft = nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib + .agl(nsharpNative.nsharpLib.ihght(nsharpNative.nsharpLib + .temp_lvl(0, fValue)))); + if (nsharpNative.nsharpLib.qc(fgzft) == 1) { + textStr = String.format("%.0f'", fgzft); + } else { + textStr = " M"; + } + str.setText("FZL=", NsharpConstants.color_white); + str.setCoordinates(secondToken, curY); + str1.setText(textStr, NsharpConstants.color_white); + str1.setCoordinates(secondToken + equalSignPos, curY); + target.drawStrings(str, str1); + // ESP + float esp = nsharpNative.nsharpLib.esp(); + if (nsharpNative.nsharpLib.qc(esp) == 1) { + textStr = String.format("%.2f", esp); + } else { + textStr = " M"; + } + str.setText("ESP=", NsharpConstants.color_white); + str.setCoordinates(thirdToken, curY); + str1.setText(textStr, NsharpConstants.color_white); + str1.setCoordinates(thirdToken + equalSignPos, curY); + target.drawStrings(str, str1); + + curY = curY + charHeight; // move to new line + + fValue.setValue(0); + // MidRH + nsharpNative.nsharpLib.get_surface(fValue1, fValue2, fValue3); // fValue + // 2 and + // fValue3 + // are + // not of + // concern + // here + nsharpNative.nsharpLib.mean_relhum(fValue, fValue1.getValue() - 150, + fValue1.getValue() - 350); + if (nsharpNative.nsharpLib.qc(fValue.getValue()) == 1) { + textStr = String.format("%.0f%c", fValue.getValue(), + NsharpConstants.PERCENT_SYMBOL); + } else { + textStr = " M"; + } + str.setText("MidRH=", NsharpConstants.color_white); + str.setCoordinates(startX, curY); + str1.setText(textStr, NsharpConstants.color_white); + str1.setCoordinates(equalSignPos, curY); + target.drawStrings(str, str1); + // DownT + downT = nsharpNative.nsharpLib.ctof(downT); // convert to F + if (nsharpNative.nsharpLib.qc(downT) == 1) { + textStr = String.format("%.0fF", downT); + } else { + textStr = " M"; + } + str.setText("DownT=", NsharpConstants.color_white); + str.setCoordinates(firstToken, curY); + str1.setText(textStr, NsharpConstants.color_white); + str1.setCoordinates(firstToken + equalSignPos, curY); + target.drawStrings(str, str1); + // ConvT + fValue.setValue(0); + float conTempF = nsharpNative.nsharpLib.ctof(nsharpNative.nsharpLib + .cnvtv_temp(fValue, -1)); + + if (nsharpNative.nsharpLib.qc(conTempF) == 1) { + textStr = String.format("%.0fF", conTempF); + } else { + textStr = " M"; + } + str.setText("ConvT=", NsharpConstants.color_white); + str.setCoordinates(secondToken, curY); + str1.setText(textStr, NsharpConstants.color_white); + str1.setCoordinates(secondToken + equalSignPos, curY); + target.drawStrings(str, str1); + + // MMP: Coniglio MCS Maintenance Parameter + float mmp = nsharpNative.nsharpLib.coniglio1(); + if (nsharpNative.nsharpLib.qc(mmp) == 1) { + textStr = String.format("%.2f", mmp); + } else { + textStr = " M"; + } + str.setText("MMP=", NsharpConstants.color_white); + str.setCoordinates(thirdToken, curY); + str1.setText(textStr, NsharpConstants.color_white); + str1.setCoordinates(thirdToken + equalSignPos, curY); + target.drawStrings(str, str1); + + curY = curY + charHeight; // move to new line + + fValue.setValue(0); + fValue1.setValue(0); + // get surface pressure (fValue1) before getting mean LRH value + nsharpNative.nsharpLib.get_surface(fValue1, fValue2, fValue3); // fValue + // 2 and + // fValue3 + // are + // not of + // concern + // here + nsharpNative.nsharpLib.mean_relhum(fValue, -1.0F, + fValue1.getValue() - 150); + if (nsharpNative.nsharpLib.qc(fValue.getValue()) == 1) { + // textStr = NsharpNativeConstants.THERMO_MEANLRH_LINE; + textStr = String.format("%.0f%c", fValue.getValue(), + NsharpConstants.PERCENT_SYMBOL); + } else { + textStr = " M"; + } + str.setText("LowRH=", NsharpConstants.color_white); + str.setCoordinates(startX, curY); + str1.setText(textStr, NsharpConstants.color_white); + str1.setCoordinates(equalSignPos, curY); + target.drawStrings(str, str1); + + fValue.setValue(0); + nsharpNative.nsharpLib.mean_mixratio(fValue, -1.0F, -1.0F); + if (nsharpNative.nsharpLib.qc(fValue.getValue()) == 1) { + textStr = String.format("%.1fg/kg", fValue.getValue()); + } else { + textStr = " M"; + } + str.setText("MeanW=", NsharpConstants.color_white); + str.setCoordinates(firstToken, curY); + str1.setText(textStr, NsharpConstants.color_white); + str1.setCoordinates(firstToken + equalSignPos, curY); + target.drawStrings(str, str1); + + fValue.setValue(0); + float maxT = nsharpNative.nsharpLib.ctof(nsharpNative.nsharpLib + .max_temp(fValue, -1)); + if (nsharpNative.nsharpLib.qc(maxT) == 1) { + textStr = String.format("%.0fF", maxT); + } else { + textStr = " M"; + } + str.setText("MaxT=", NsharpConstants.color_white); + str.setCoordinates(secondToken, curY); + str1.setText(textStr, NsharpConstants.color_white); + str1.setCoordinates(secondToken + equalSignPos, curY); + target.drawStrings(str, str1); + + // NCAPE + str.setText("NCAPE=", NsharpConstants.color_white); + str.setCoordinates(thirdToken, curY); + str1.setText(NCAPEStr, NsharpConstants.color_white); + str1.setCoordinates(thirdToken + equalSignPos, curY); + target.drawStrings(str, str1); + + curY = curY + charHeight; // move to new line + target.drawLine(rect.x, curY, 0.0, rect.x + rect.width, curY, 0.0, + NsharpConstants.color_white, 1); + + // draw a vertical line from 2/3 of x axis + str.setText("sfc-3km AglLapseRate=xxC/x.xC/kmX", + NsharpConstants.color_black); + str.font = myfont; + double lineXPos = target.getStringsBounds(str).getWidth() * hRatio + * xRatio; + if (lineXPos < rect.width * 2 / 3) + lineXPos = rect.width * 2 / 3; + firstToken = rect.x + lineXPos; + target.drawLine(firstToken, curY, 0.0, firstToken, + rect.y + rect.height, 0.0, NsharpConstants.color_white, 1); + // curY = curY+ (double)charHeight * 0.5; + firstToken = firstToken + 0.5 * charWidth; + + // more thermodynamic data + // the following follow show_parcel_new() at xwvid.c of bigNsharp + // implementation + // sfc-3km Lapse rate + // + float htsfc = 0; + float tDelta = nsharpNative.nsharpLib.aglT(0, 3000); + fValue.setValue(0); + // get surface pressure (fValue) + nsharpNative.nsharpLib.get_surface(fValue, fValue1, fValue2); + if (nsharpNative.nsharpLib.qc(fValue.getValue()) == 1) { + htsfc = nsharpNative.nsharpLib.ihght(fValue.getValue()); + // get sfc to (sfc+ 3 km) pressure (fValue) + float threekmPre = nsharpNative.nsharpLib.ipres(htsfc + 3000); + fValue1.setValue(0); + nsharpNative.nsharpLib.lapse_rate(fValue1, fValue.getValue(), + threekmPre); + if (nsharpNative.nsharpLib.qc(fValue1.getValue()) == 1) { + // textStr = + // String.format("sfc-3km AglLapseRate=%.0fC/%.1fC/km", tDelta, + // fValue1.getValue()); + textStr = String.format("%.0fC/%.1fC/km", tDelta, + fValue1.getValue()); + } else { + textStr = " M";// "sfc-3km AglLapseRate= M"; + } + } else { + textStr = " M";// "sfc-3km AglLapseRate= M"; + } + str.setText("sfc-3km Agl LapseRate= ", NsharpConstants.color_white); + str.setCoordinates(startX, curY); + equalSignPos = rect.x + target.getStringsBounds(str).getWidth() + * hRatio * xRatio; + str1.setText(textStr, NsharpConstants.color_white); + str1.setCoordinates(equalSignPos, curY); + target.drawStrings(str, str1); + + /* + * target.drawString(myfont, textStr, startX, curY , 0.0, + * TextStyle.NORMAL, NsharpConstants.color_white, + * HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + */ + + // "Supercell" + float smdir = rscHandler.getSmWindDir();// bkRsc.getSmDir(); #10438 + float smspd = rscHandler.getSmWindSpd();// bkRsc.getSmSpd(); + float superCell = nsharpNative.nsharpLib.scp(smdir, smspd); + if (nsharpNative.nsharpLib.qc(superCell) == 1) { + textStr = String.format("%.1f", superCell); + } else { + textStr = " M"; + } + str.setText("Supercell= ", NsharpConstants.color_yellow); + double equalSignPos1 = firstToken + + target.getStringsBounds(str).getWidth() * hRatio * xRatio; + str.setCoordinates(firstToken, curY); + str1.setText(textStr, NsharpConstants.color_yellow); + str1.setCoordinates(equalSignPos1, curY); + target.drawStrings(str, str1); + /* + * target.drawString(myfont, textStr, firstToken, curY , 0.0, + * TextStyle.NORMAL, NsharpConstants.color_yellow, + * HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + */ + + curY = curY + charHeight; // move to new line + + // 3km-6km Lapse rate + fValue.setValue(0); + fValue1.setValue(0); + tDelta = nsharpNative.nsharpLib.aglT(3000, 6000); + // get 3 and 6km pressure (fValue) + float threekmPre = nsharpNative.nsharpLib.ipres(htsfc + 3000); + float sixkmPre = nsharpNative.nsharpLib.ipres(htsfc + 6000); + fValue1.setValue(0); + nsharpNative.nsharpLib.lapse_rate(fValue1, threekmPre, sixkmPre); + if (nsharpNative.nsharpLib.qc(fValue1.getValue()) == 1) { + textStr = String.format("%.0fC/%.1fC/km", tDelta, + fValue1.getValue()); + + } else { + textStr = " M"; + } + str.setText("3-6km Agl LapseRate=", NsharpConstants.color_white); + str.setCoordinates(startX, curY); + str1.setText(textStr, NsharpConstants.color_white); + str1.setCoordinates(equalSignPos, curY); + target.drawStrings(str, str1); + /* + * target.drawString(myfont, textStr, startX, curY , 0.0, + * TextStyle.NORMAL, NsharpConstants.color_white, + * HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + */ + // "STP (CIN)" + float cin = nsharpNative.nsharpLib.sigtorn_cin(smdir, smspd); + if (nsharpNative.nsharpLib.qc(cin) == 1) { + textStr = String.format("%.1f", cin); + } else { + textStr = " M"; + } + str.setText("STP(CIN)=", NsharpConstants.color_white); + str.setCoordinates(firstToken, curY); + str1.setText(textStr, NsharpConstants.color_white); + str1.setCoordinates(equalSignPos1, curY); + target.drawStrings(str, str1); + /* + * target.drawString(myfont, textStr, firstToken, curY , 0.0, + * TextStyle.NORMAL, NsharpConstants.color_white, + * HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + */ + + curY = curY + charHeight; // move to new line + + fValue.setValue(0); + fValue1.setValue(0); + // nsharpNative.nsharpLib.vert_tot(fValue); + float delta = nsharpNative.nsharpLib.itemp(850) + - nsharpNative.nsharpLib.itemp(500); + nsharpNative.nsharpLib.lapse_rate(fValue1, 850.0F, 500.0F); + if (nsharpNative.nsharpLib.qc(delta) == 1 + && nsharpNative.nsharpLib.qc(fValue1.getValue()) == 1) { + textStr = String + .format("%.0fC/%.1fC/km", delta, fValue1.getValue()); + } else { + textStr = " M"; + } + str.setText("850-500mb LapseRate=", NsharpConstants.color_white); + str.setCoordinates(startX, curY); + str1.setText(textStr, NsharpConstants.color_white); + str1.setCoordinates(equalSignPos, curY); + target.drawStrings(str, str1); + /* + * target.drawString(myfont, textStr, startX, curY , 0.0, + * TextStyle.NORMAL, NsharpConstants.color_white, + * HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + */ + // "STP(fixed)" + float fixedStp = nsharpNative.nsharpLib.sigtorn_fixed(smdir, smspd); + if (nsharpNative.nsharpLib.qc(fixedStp) == 1) { + textStr = String.format("%.1f", fixedStp); + } else { + textStr = " M"; + } + str.setText("STP(fixed)=", NsharpConstants.color_white); + str.setCoordinates(firstToken, curY); + str1.setText(textStr, NsharpConstants.color_white); + str1.setCoordinates(equalSignPos1, curY); + target.drawStrings(str, str1); + /* + * target.drawString(myfont, textStr, firstToken, curY , 0.0, + * TextStyle.NORMAL, NsharpConstants.color_white, + * HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + */ + + curY = curY + charHeight; // move to new line + + fValue.setValue(0); + fValue1.setValue(0); + // nsharpNative.nsharpLib.delta_t(fValue); + nsharpNative.nsharpLib.lapse_rate(fValue1, 700.0F, 500.0F); + delta = nsharpNative.nsharpLib.itemp(700) + - nsharpNative.nsharpLib.itemp(500); + if (nsharpNative.nsharpLib.qc(/* fValue.getValue()) */delta) == 1 + && nsharpNative.nsharpLib.qc(fValue1.getValue()) == 1) { + textStr = String.format("%.0fC/%.1fC/km", + delta/* fValue.getValue() */, fValue1.getValue()); + } else { + textStr = " M"; + } + str.setText("700-500mb LapseRate=", NsharpConstants.color_white); + str.setCoordinates(startX, curY); + str1.setText(textStr, NsharpConstants.color_white); + str1.setCoordinates(equalSignPos, curY); + target.drawStrings(str, str1); + /* + * target.drawString(myfont, textStr, startX, curY , 0.0, + * TextStyle.NORMAL, NsharpConstants.color_white, + * HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + */ + // "SHIP" + float ship = nsharpNative.nsharpLib.cave_ship(); + if (nsharpNative.nsharpLib.qc(ship) == 1) { + textStr = String.format("%.1f", ship); + } else + textStr = " M"; + str.setText("SHIP=", NsharpConstants.color_red); + str.setCoordinates(firstToken, curY); + str1.setText(textStr, NsharpConstants.color_red); + str1.setCoordinates(equalSignPos1, curY); + target.drawStrings(str, str1); + /* + * target.drawString(myfont, textStr, firstToken, curY , 0.0, + * TextStyle.NORMAL, NsharpConstants.color_red, + * HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + */ + // System.out.println("shop="+ship); + // myfont.dispose(); + } + + @SuppressWarnings("deprecation") + private void drawPanel2(IGraphicsTarget target, Rectangle rect) + throws VizException { + IFont myfont; + if (paneConfigurationName.equals(NsharpConstants.PANE_LITE_D2D_CFG_STR)) { + myfont = font10; + } else { + myfont = defaultFont; + } + /* + * Chin's NOTE:::: This pages based on BigNsharp show_shear_new() at + * xwvid3.c + */ + + defineCharHeight(myfont); + myfont.setSmoothing(false); + myfont.setScaleFont(false); + extent = new PixelExtent(rect); target.setupClippingPlane(extent); - //myfont = target.initializeFont(fontName, fontSize, null); + // myfont = target.initializeFont(fontName, 10, null); + curY = rect.y; + String textStr; + + // if we can not Interpolates a temp with 700 mb pressure, then we dont + // have enough raw data + if (nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib.itemp(700.0F)) == 0) { + target.drawString(myfont, " " + NO_DATA, rect.x, + rect.y, 0.0, TextStyle.NORMAL, NsharpConstants.color_cyan, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + return; + } + + // + // Start with Header SRH(m%c/s%c) Shear(kt) MnWind SRW + // + double startX = rect.x + 0.5 * charWidth; + double widthGap = (rect.width) / 5; + firstToken = rect.x + widthGap; + secondToken = firstToken + widthGap; + thirdToken = secondToken + widthGap; + forthToken = thirdToken + widthGap; + target.drawString(myfont, "Sum2", startX, rect.y, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + + textStr = String.format("SRH(m%c/s%c)", NsharpConstants.SQUARE_SYMBOL, + NsharpConstants.SQUARE_SYMBOL); + target.drawString(myfont, textStr, firstToken, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + target.drawString(myfont, "Shear(kt)", secondToken, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + target.drawString(myfont, "MnWind", thirdToken, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + target.drawString(myfont, "SRW", forthToken, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + curY = curY + charHeight; // move to new line + target.drawLine(rect.x, curY, 0.0, rect.x + rect.width, curY, 0.0, + NsharpConstants.color_white, 1); + // curY = curY+ (double)charHeight * 0.5; + FloatByReference smdir = new FloatByReference(0), smspd = new FloatByReference( + 0); + nsharpNative.nsharpLib.get_storm(smspd, smdir); + FloatByReference topPF = new FloatByReference(0); + FloatByReference botPF = new FloatByReference(0); + nsharpNative.nsharpLib.get_effectLayertopBotPres(topPF, botPF); + // System.out.println("top="+topPF.getValue()+" bot="+botPF.getValue()); + for (int i = 0; i < NsharpNativeConstants.STORM_MOTION_TYPE_STR1.length; i++) { + float h1, h2; + if (NsharpNativeConstants.STORM_MOTION_TYPE_STR1[i] + .equals("Eff Inflow Layer")) { + + if (botPF.getValue() > 0) { + h1 = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(botPF.getValue())); + h2 = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(topPF.getValue())); + } else { + h1 = -999; + h2 = -999; + } + } else { + h1 = NsharpNativeConstants.STORM_MOTION_HEIGHT1[i][0]; + h2 = NsharpNativeConstants.STORM_MOTION_HEIGHT1[i][1]; + } + // h1 = NsharpNativeConstants.STORM_MOTION_HEIGHT1[i][0]; + // h2 = NsharpNativeConstants.STORM_MOTION_HEIGHT1[i][1]; + if (h1 != -999 && h2 != -999) { + // SRH + // calculate helicity + + float totHeli = nsharpNative.nsharpLib.helicity(h1, h2, + smdir.getValue(), smspd.getValue(), fValue, fValue1); + target.drawString(myfont, + NsharpNativeConstants.STORM_MOTION_TYPE_STR1[i], + startX, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + + // gc.drawText(NsharpNativeConstants.STORM_MOTION_TYPE_STR[i],0, + // textLineNumber*textHeight + graphLineNumber); + if (nsharpNative.nsharpLib.qc(fValue.getValue()) == 1 + && nsharpNative.nsharpLib.qc(fValue1.getValue()) == 1) { + // textStr = + // NsharpNativeConstants.STORM_MOTION_TYPE_STR[i]+" %.0f"; + textStr = String.format("%.0f", totHeli); + } else { + textStr = "M"; + } + target.drawString(myfont, textStr, firstToken, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + + // Calculate wind shear + // Note: -1 as first parameter indicating bottom layer is + // surface layer, see wind.c for wind_shear() source code + nsharpNative.nsharpLib.wind_shear(nsharpNative.nsharpLib + .ipres(nsharpNative.nsharpLib.msl(h1)), + nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib + .msl(h2)), fValue, fValue1, fValue2, fValue3); + if (nsharpNative.nsharpLib.qc(fValue3.getValue()) == 1) { + textStr = String.format("%.0f", fValue3.getValue()); + + } else { + textStr = "M"; + } + target.drawString(myfont, textStr, secondToken, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + + // Calculate mean wind + nsharpNative.nsharpLib.mean_wind(nsharpNative.nsharpLib + .ipres(nsharpNative.nsharpLib.msl(h1)), + nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib + .msl(h2)), fValue, fValue1, fValue2, fValue3); + if (nsharpNative.nsharpLib.qc(fValue2.getValue()) == 1 + && nsharpNative.nsharpLib.qc(fValue3.getValue()) == 1) { + textStr = String.format("%.0f/%.0f", fValue2.getValue(), + fValue3.getValue()); + } else { + textStr = "M"; + } + target.drawString(myfont, textStr, thirdToken, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + + // calculate pressure-weighted SR mean wind + nsharpNative.nsharpLib.sr_wind(nsharpNative.nsharpLib + .ipres(nsharpNative.nsharpLib.msl(h1)), + nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib + .msl(h2)), smdir.getValue(), smspd.getValue(), + fValue, fValue1, fValue2, fValue3); + if (nsharpNative.nsharpLib.qc(fValue2.getValue()) == 1) { + textStr = String.format("%.0f/%.0f", fValue2.getValue(), + fValue3.getValue()); + } else { + textStr = "M"; + } + target.drawString(myfont, textStr, forthToken, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + + if (NsharpNativeConstants.STORM_MOTION_TYPE_STR1[i] + .equals("Eff Inflow Layer")) { + // draw bax around it + Rectangle rectangle = new Rectangle(rect.x, (int) curY, + rect.width, (int) charHeight); + // System.out.println("rect.x="+ rectangle.x+ " y="+ + // rectangle.y+" w="+rectangle.width+ + // " h="+rectangle.height); + PixelExtent pixExt = new PixelExtent(rectangle); + target.drawRect(pixExt, NsharpConstants.color_gold, 1.0f, + 1.0f); + } + } + curY = curY + charHeight; // move to new line + + } + float pres = 0; + short oldlplchoice = 3; + float sfctemp, sfcdwpt, sfcpres; + _lplvalues lpvls; + _parcel pcl; + lpvls = new _lplvalues(); + // nsharpNative.nsharpLib.get_lpvaluesData(lpvls); + // sfctemp = lpvls.temp; + // sfcdwpt = lpvls.dwpt; + // sfcpres = lpvls.pres; + // get parcel data by calling native nsharp parcel() API. value is + // returned in pcl + pcl = new _parcel(); + for (int i = 0; i < NsharpNativeConstants.STORM_MOTION_TYPE_STR2.length; i++) { + float h1, h2; + + h1 = -999; + h2 = -999; + nsharpNative.nsharpLib.get_lpvaluesData(lpvls); + if (NsharpNativeConstants.STORM_MOTION_TYPE_STR2[i] + .equals("LCL-EL(Cloud Layer)")) { + sfctemp = lpvls.temp; + sfcdwpt = lpvls.dwpt; + sfcpres = lpvls.pres; + nsharpNative.nsharpLib.parcel(-1.0F, -1.0F, sfcpres, sfctemp, + sfcdwpt, pcl); + if (pcl.bplus > 0) { + h1 = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(pcl.lclpres)); + h2 = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(pcl.elpres)); + } + } else if (NsharpNativeConstants.STORM_MOTION_TYPE_STR2[i] + .equals("Lower Half Storm Depth")) { + oldlplchoice = lpvls.flag; + nsharpNative.nsharpLib.define_parcel( + NsharpNativeConstants.PARCELTYPE_MOST_UNSTABLE, + NsharpNativeConstants.MU_LAYER); + nsharpNative.nsharpLib.get_lpvaluesData(lpvls);// regain lpvls + // value after + // defined parcel + sfctemp = lpvls.temp; + sfcdwpt = lpvls.dwpt; + sfcpres = lpvls.pres; + nsharpNative.nsharpLib.parcel(-1.0F, -1.0F, sfcpres, sfctemp, + sfcdwpt, pcl); + float el = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(pcl.elpres)); + if (pcl.bplus >= 100.0) { + + float base = nsharpNative.nsharpLib + .agl(nsharpNative.nsharpLib.ihght(botPF.getValue())); + float depth = (el - base); + h1 = base; + h2 = base + (depth * 0.5f); + + nsharpNative.nsharpLib.get_lpvaluesData(lpvls); + } + + // System.out.println("drawPanel2-2 called define_parcel pType="+oldlplchoice+" pre="+ + // pres); + try { + if (oldlplchoice == NsharpNativeConstants.PARCELTYPE_USER_DEFINED) { + pres = NsharpParcelDialog.getUserDefdParcelMb(); + } else + pres = NsharpNativeConstants.parcelToLayerMap + .get(oldlplchoice); + + // reset and define oldchoice parcel + nsharpNative.nsharpLib.define_parcel(oldlplchoice, pres); + } catch (NullPointerException e) { + // when in changing pane configuration situation, an odd + // scenario may happened that + // "oldlplchoice" may be a null, and + // parcelToLayerMap.get(oldlplchoice); throws a + // NullPointerException. In that case, we do not + // re-define_parcel and continue on + e.printStackTrace(); + } + + } else { + h1 = NsharpNativeConstants.STORM_MOTION_HEIGHT2[i][0]; + h2 = NsharpNativeConstants.STORM_MOTION_HEIGHT2[i][1]; + } + if (h1 != -999 && h2 != -999) { + // SRH + // calculate helicity + float totHeli = nsharpNative.nsharpLib.helicity(h1, h2, + smdir.getValue(), smspd.getValue(), fValue, fValue1); + target.drawString(myfont, + NsharpNativeConstants.STORM_MOTION_TYPE_STR2[i], + startX, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + + // gc.drawText(NsharpNativeConstants.STORM_MOTION_TYPE_STR[i],0, + // textLineNumber*textHeight + graphLineNumber); + if (nsharpNative.nsharpLib.qc(fValue.getValue()) == 1 + && nsharpNative.nsharpLib.qc(fValue1.getValue()) == 1) { + // textStr = + // NsharpNativeConstants.STORM_MOTION_TYPE_STR[i]+" %.0f"; + textStr = String.format("%.0f", totHeli); + } else { + textStr = "M"; + } + // SR Helicity is not shown for these 4 storm motions, see + // oroginal BigNsharp show_shear_new() + // target.drawString(myfont, textStr, firstToken, curY , 0.0, + // TextStyle.NORMAL, NsharpConstants.color_white, + // HorizontalAlignment.LEFT, + // VerticalAlignment.TOP, null); + + // Calculate wind shear + // Note: -1 as first parameter indicating bottom layer is + // surface layer, see wind.c for wind_shear() source code + nsharpNative.nsharpLib.wind_shear(nsharpNative.nsharpLib + .ipres(nsharpNative.nsharpLib.msl(h1)), + nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib + .msl(h2)), fValue, fValue1, fValue2, fValue3); + if (nsharpNative.nsharpLib.qc(fValue3.getValue()) == 1) { + textStr = String.format("%.0f", fValue3.getValue()); + + } else { + textStr = "M"; + } + target.drawString(myfont, textStr, secondToken, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + + // Calculate mean wind + nsharpNative.nsharpLib.mean_wind(nsharpNative.nsharpLib + .ipres(nsharpNative.nsharpLib.msl(h1)), + nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib + .msl(h2)), fValue, fValue1, fValue2, fValue3); + if (nsharpNative.nsharpLib.qc(fValue2.getValue()) == 1 + && nsharpNative.nsharpLib.qc(fValue3.getValue()) == 1) { + textStr = String.format("%.0f/%.0f", fValue2.getValue(), + fValue3.getValue()); + } else { + textStr = "M"; + } + target.drawString(myfont, textStr, thirdToken, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + + // calculate pressure-weighted SR mean wind + nsharpNative.nsharpLib.sr_wind(nsharpNative.nsharpLib + .ipres(nsharpNative.nsharpLib.msl(h1)), + nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib + .msl(h2)), smdir.getValue(), smspd.getValue(), + fValue, fValue1, fValue2, fValue3); + if (nsharpNative.nsharpLib.qc(fValue2.getValue()) == 1) { + textStr = String.format("%.0f/%.0f", fValue2.getValue(), + fValue3.getValue()); + } else { + textStr = "M"; + } + target.drawString(myfont, textStr, forthToken, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + if (NsharpNativeConstants.STORM_MOTION_TYPE_STR2[i] + .equals("Lower Half Storm Depth")) { + // draw bax around it + Rectangle rectangle = new Rectangle(rect.x, (int) curY, + rect.width, (int) charHeight); + // System.out.println("rect.x="+ rectangle.x+ " y="+ + // rectangle.y+" w="+rectangle.width+ + // " h="+rectangle.height); + PixelExtent pixExt = new PixelExtent(rectangle); + target.drawRect(pixExt, NsharpConstants.color_gold, 1.0f, + 1.0f); + } + } + curY = curY + charHeight; // move to new line + + } + // align all following parameters output with "Corfidi Downshear" + double hRatio = paintProps.getView().getExtent().getWidth() + / paintProps.getCanvasBounds().width; + DrawableString str = new DrawableString("Corfidi Downshear = ", + NsharpConstants.color_white); + double equalSignPos = secondToken;// rect.x+target.getStringsBounds(str).getWidth()*hRatio*xRatio; + + // BRN Shear + // get parcel data by calling native nsharp parcel() API. value is + // returned in pcl + // current parcel is reset earlief already we dont have to call + // define_parcel() again. + nsharpNative.nsharpLib.get_lpvaluesData(lpvls); + sfctemp = lpvls.temp; + sfcdwpt = lpvls.dwpt; + sfcpres = lpvls.pres; + nsharpNative.nsharpLib.parcel(-1.0F, -1.0F, sfcpres, sfctemp, sfcdwpt, + pcl); + + nsharpNative.nsharpLib.cave_bulk_rich2(fValue); + if (nsharpNative.nsharpLib.qc(fValue.getValue()) == 1) + textStr = String.format("%.0f m%c/s%c", fValue.getValue(), + NsharpConstants.SQUARE_SYMBOL, + NsharpConstants.SQUARE_SYMBOL); + else + textStr = " M"; + str.setCoordinates(startX, curY); + str.horizontalAlignment = HorizontalAlignment.LEFT; + str.verticallAlignment = VerticalAlignment.TOP; + str.font = myfont; + str.setText("BRN Shear = ", NsharpConstants.color_white); + DrawableString str1 = new DrawableString(textStr, + NsharpConstants.color_white); + str1.setCoordinates(equalSignPos, curY); + str1.horizontalAlignment = HorizontalAlignment.LEFT; + str1.verticallAlignment = VerticalAlignment.TOP; + str1.font = myfont; + target.drawStrings(str, str1); + + curY = curY + charHeight; // move to new line + // 4-6km srw + nsharpNative.nsharpLib.sr_wind( + nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(4000)), + nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(6000)), + smdir.getValue(), smspd.getValue(), fValue, fValue1, fValue2, + fValue3); + if (nsharpNative.nsharpLib.qc(fValue2.getValue()) == 1) { + textStr = String.format("%.0f/%.0f kt", fValue2.getValue(), + fValue3.getValue()); + } else { + textStr = " M"; + } + str.setText("4-6km SR Wind =", NsharpConstants.color_white); + str.setCoordinates(startX, curY); + str1.setText(textStr, NsharpConstants.color_white); + str1.setCoordinates(equalSignPos, curY); + target.drawStrings(str, str1); + + curY = curY + charHeight; // move to new line + + // Corfidi Downshear, we use fValue3, fValue4 only by calling + // corfidi_MCS_motion + nsharpNative.nsharpLib.corfidi_MCS_motion(fValue1, fValue2, fValue3, + fValue4, fValue5, fValue6, fValue7, fValue8); + textStr = String.format("%.0f/%.0f kt", fValue3.getValue(), + fValue4.getValue()); + str.setText("Corfidi Downshear =", NsharpConstants.color_white); + str.setCoordinates(startX, curY); + str1.setText(textStr, NsharpConstants.color_white); + str1.setCoordinates(equalSignPos, curY); + target.drawStrings(str, str1); + curY = curY + charHeight; // move to new line + + // Corfidi Upshear, we use fValue7, fValue8 only by calling + // corfidi_MCS_motion + textStr = String.format("%.0f/%.0f kt", fValue7.getValue(), + fValue8.getValue()); + str.setText("Corfidi Upshear =", NsharpConstants.color_white); + str.setCoordinates(startX, curY); + str1.setText(textStr, NsharpConstants.color_white); + str1.setCoordinates(equalSignPos, curY); + target.drawStrings(str, str1); + curY = curY + charHeight; // move to new line + + // Bunkers Right + nsharpNative.nsharpLib.bunkers_storm_motion(fValue1, fValue2, fValue3, + fValue4); + textStr = String.format("%.0f/%.0f kt", fValue3.getValue(), + fValue4.getValue()); + str.setText("Bunkers Right =", NsharpConstants.color_red); + str.setCoordinates(startX, curY); + str1.setText(textStr, NsharpConstants.color_red); + str1.setCoordinates(equalSignPos, curY); + target.drawStrings(str, str1); + + curY = curY + charHeight; // move to new line + // Bunkers Left + nsharpNative.nsharpLib.bunkers_left_motion(fValue1, fValue2, fValue3, + fValue4); + textStr = String.format("%.0f/%.0f kt", fValue3.getValue(), + fValue4.getValue()); + str.setText("Bunkers Left =", NsharpConstants.color_cyan); + str.setCoordinates(startX, curY); + str1.setText(textStr, NsharpConstants.color_cyan); + str1.setCoordinates(equalSignPos, curY); + target.drawStrings(str, str1); + curY = curY + charHeight; // move to new line + + // STPC(test) - test STP using cape6km + // Chin Note: BigNsharp sigtorn_test always return -9999..a bug + float stpTest = nsharpNative.nsharpLib.sigtorn_test(smdir.getValue(), + smspd.getValue()); + // System.out.println("smdir="+smdir.getValue()+"smspd="+ + // smspd.getValue()+"stpTest="+stpTest+ + // "p_bot="+botPF.getValue()+"p_top="+topPF.getValue()); + if (nsharpNative.nsharpLib.qc(stpTest) == 1) + textStr = String.format("%.1f", stpTest); + else + textStr = " M"; + str.setText("STPC(test) =", NsharpConstants.color_white); + str.setCoordinates(startX, curY); + str1.setText(textStr, NsharpConstants.color_white); + str1.setCoordinates(equalSignPos, curY); + target.drawStrings(str, str1); + + // wind barb labels + str1.setText("12345SPACE", NsharpConstants.color_red); // rest str1 to + // get a right x + // position + // firstToken = equalSignPos+ + // (target.getStringsBounds(str1).getMaxX())*hRatio*xRatio; + textStr = "1km"; + str.setText(textStr, NsharpConstants.color_red); + str.setCoordinates(thirdToken, curY); + textStr = " & "; + str1.setText(textStr, NsharpConstants.color_white); + str1.setCoordinates(thirdToken + + target.getStringsBounds(str).getWidth() * hRatio * xRatio, + curY); + textStr = "6km"; + DrawableString str2 = new DrawableString(textStr, + NsharpConstants.color_cyan); + str2.horizontalAlignment = HorizontalAlignment.LEFT; + str2.verticallAlignment = VerticalAlignment.TOP; + str2.font = myfont; + str2.setCoordinates(thirdToken + + (target.getStringsBounds(str).getWidth() + target + .getStringsBounds(str1).getWidth()) * hRatio * xRatio, + curY); + textStr = " AGL Wind Barb"; + DrawableString str3 = new DrawableString(textStr, + NsharpConstants.color_white); + str3.horizontalAlignment = HorizontalAlignment.LEFT; + str3.verticallAlignment = VerticalAlignment.TOP; + str3.font = myfont; + str3.setCoordinates(thirdToken + + (target.getStringsBounds(str).getWidth() + + target.getStringsBounds(str1).getWidth() + target + .getStringsBounds(str2).getWidth()) * hRatio * xRatio, + curY); + target.drawStrings(str, str1, str2, str3); + + // 1 km wind barb + double wbToken = (thirdToken + forthToken) / 2; + str1.setText("1234/56 ktSPACESPACESPACE", NsharpConstants.color_red); // rest + // str1 + // to + // get + // a + // right + // x + // position + // firstToken = equalSignPos+ + // (target.getStringsBounds(str1).getMaxX())*hRatio*xRatio; + double yOri = curY - 3 * charHeight; + double barbScaleF = charHeight;// 12; + List barb = WindBarbFactory.getWindGraphics( + (double) nsharpNative.nsharpLib.iwspd(nsharpNative.nsharpLib + .ipres(nsharpNative.nsharpLib.msl(1000))), + (double) nsharpNative.nsharpLib.iwdir(nsharpNative.nsharpLib + .ipres(nsharpNative.nsharpLib.msl(1000)))); + if (barb != null) { + WindBarbFactory.scaleBarb(barb, barbScaleF); + + double cur0X = wbToken, cur0Y = yOri, cur1X = wbToken, cur1Y = yOri, newY = 0; + WindBarbFactory.translateBarb(barb, cur0X, yOri); + + for (LineStroke stroke : barb) { + Coordinate point = stroke.getPoint(); + // Chin NOte; when using WindBarbFactory.getWindGraphics() to + // create barb, the Y axis is growing + // upwards. However, on this canvas, Y axis is growing + // downwards. Therefore, the following Y coordinate + // adjustment is necessary. + // + newY = yOri - (point.y - yOri); + // Note: stroke.render(gc, relativeX, relativeY) is not working + // here. Therefore, need to + // draw wind barb ourself. + if (stroke.getType() == "M") { + cur0X = point.x; + cur0Y = newY; + } else if (stroke.getType() == "D") { + cur1X = point.x; + cur1Y = newY; + target.drawLine(cur0X, cur0Y, 0.0, cur1X, cur1Y, 0.0, + NsharpConstants.color_red, 1); + // bsteffen added these two lines to fix 50 kts wind barbs + cur0X = cur1X; + cur0Y = cur1Y; + } + } + } + // 6 km wind barb + barb.clear(); + barb = WindBarbFactory.getWindGraphics((double) nsharpNative.nsharpLib + .iwspd(nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib + .msl(6000))), (double) nsharpNative.nsharpLib + .iwdir(nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib + .msl(6000)))); + if (barb != null) { + WindBarbFactory.scaleBarb(barb, barbScaleF); + + double cur0X = wbToken, cur0Y = yOri, cur1X = wbToken, cur1Y = yOri, newY = 0; + WindBarbFactory.translateBarb(barb, cur0X, yOri); + + for (LineStroke stroke : barb) { + Coordinate point = stroke.getPoint(); + // Chin NOte; when using WindBarbFactory.getWindGraphics() to + // create barb, the Y axis is growing + // upwards. However, on this canvas, Y axis is growing + // downwards. Therefore, the following Y coordinate + // adjustment is necessary. + newY = yOri - (point.y - yOri); + // + // Note: stroke.render(gc, relativeX, relativeY) is not working + // here. Therefore, need to + // draw wind barb ourself. + if (stroke.getType() == "M") { + cur0X = point.x; + cur0Y = newY; + } else if (stroke.getType() == "D") { + cur1X = point.x; + cur1Y = newY; + target.drawLine(cur0X, cur0Y, 0.0, cur1X, cur1Y, 0.0, + NsharpConstants.color_cyan, 1); + // bsteffen added these two lines to fix 50 kts wind barbs + cur0X = cur1X; + cur0Y = cur1Y; + } + } + } + // myfont.dispose(); + } + + @SuppressWarnings("deprecation") + private void drawPanel3(IGraphicsTarget target, Rectangle rect) + throws VizException { + IFont myfont; + myfont = defaultFont; + defineCharHeight(myfont); + myfont.setSmoothing(false); + myfont.setScaleFont(false); + extent = new PixelExtent(rect); + target.setupClippingPlane(extent); + // myfont = target.initializeFont(fontName, fontSize, null); String splitedStr[]; String textStr; curY = rect.y; - //Chin's NOTE::::this function is coded based on native nsharp show_parcel() in xwvid3.c + // Chin's NOTE::::this function is coded based on native nsharp + // show_parcel() in xwvid3.c // moved from NsharpPaletteWindow.showParcelData() - - //if we can not Interpolates a temp with 700 mb pressure, then we dont have enough raw data - if (nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib.itemp(700.0F)) == 0) - return; - String title = NsharpNativeConstants.PARCEL_DATA_STR; - - target.drawString(myfont, title, rect.x + rect.width /3, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_cyan, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - - - String hdrStr; - //short currentParcel; - float layerPressure = 0;; - //get user selected parcel type - hdrStr = NsharpNativeConstants.parcelToHdrStrMap.get(currentParcel); - layerPressure = NsharpNativeConstants.parcelToLayerMap.get(currentParcel); - if(currentParcel == NsharpNativeConstants.PARCELTYPE_USER_DEFINED ){ - layerPressure = NsharpParcelDialog.getUserDefdParcelMb(); - hdrStr = String.format(hdrStr, layerPressure); - } - curY = curY + charHeight; - target.drawString(myfont, hdrStr, rect.x + rect.width /4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_yellow, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - + // if we can not Interpolates a temp with 700 mb pressure, then we dont + // have enough raw data + if (nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib.itemp(700.0F)) == 0) + return; + String title = NsharpNativeConstants.PARCEL_DATA_STR; - //call native define_parcel() with parcel type and user defined pressure (if user defined it) - nsharpNative.nsharpLib.define_parcel(currentParcel,layerPressure); + target.drawString(myfont, title, rect.x + rect.width / 3, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_cyan, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); - _lplvalues lpvls = new _lplvalues(); - nsharpNative.nsharpLib.get_lpvaluesData(lpvls); + String hdrStr; + // short currentParcel; + float layerPressure = 0; + ; + // get user selected parcel type + hdrStr = NsharpNativeConstants.parcelToHdrStrMap.get(currentParcel); + layerPressure = NsharpNativeConstants.parcelToLayerMap + .get(currentParcel); + if (currentParcel == NsharpNativeConstants.PARCELTYPE_USER_DEFINED) { + layerPressure = NsharpParcelDialog.getUserDefdParcelMb(); + hdrStr = String.format(hdrStr, layerPressure); + } + curY = curY + charHeight; + target.drawString(myfont, hdrStr, rect.x + rect.width / 4, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_yellow, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + curY = curY + charHeight; - float sfctemp, sfcdwpt, sfcpres; - sfctemp = lpvls.temp; - sfcdwpt = lpvls.dwpt; - sfcpres = lpvls.pres; - - // get parcel data by calling native nsharp parcel() API. value is returned in pcl - _parcel pcl = new _parcel(); - nsharpNative.nsharpLib.parcel( -1.0F, -1.0F, sfcpres, sfctemp, sfcdwpt, pcl); - textStr = NsharpNativeConstants.PARCEL_LPL_LINE_; - textStr = String.format(textStr, (int)pcl.lplpres,(int)pcl.lpltemp,(int)pcl.lpldwpt, - (int)nsharpNative.nsharpLib.ctof(pcl.lpltemp),(int)nsharpNative.nsharpLib.ctof(pcl.lpldwpt)); - // Chin: note: target.drawString does NOT handle formatted string. For example, "ABC\tabc" will be printed - // as "ABCabc" So, we have to add '_' to separate each value when formatting String. - // Then, use String.split() to have each value in a sub-string. - - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - - curY = curY + 2*charHeight; + // call native define_parcel() with parcel type and user defined + // pressure (if user defined it) + nsharpNative.nsharpLib.define_parcel(currentParcel, layerPressure); - if(nsharpNative.nsharpLib.qc(pcl.bplus)==1){ - textStr = NsharpNativeConstants.PARCEL_CAPE_LINE; - textStr = String.format(textStr,pcl.bplus); - } - else { - textStr = NsharpNativeConstants.PARCEL_CAPE_MISSING; - } - target.drawString(myfont, textStr, rect.x, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, + _lplvalues lpvls = new _lplvalues(); + nsharpNative.nsharpLib.get_lpvaluesData(lpvls); + + float sfctemp, sfcdwpt, sfcpres; + sfctemp = lpvls.temp; + sfcdwpt = lpvls.dwpt; + sfcpres = lpvls.pres; + + // get parcel data by calling native nsharp parcel() API. value is + // returned in pcl + _parcel pcl = new _parcel(); + nsharpNative.nsharpLib.parcel(-1.0F, -1.0F, sfcpres, sfctemp, sfcdwpt, + pcl); + textStr = NsharpNativeConstants.PARCEL_LPL_LINE_; + textStr = String.format(textStr, (int) pcl.lplpres, (int) pcl.lpltemp, + (int) pcl.lpldwpt, + (int) nsharpNative.nsharpLib.ctof(pcl.lpltemp), + (int) nsharpNative.nsharpLib.ctof(pcl.lpldwpt)); + // Chin: note: target.drawString does NOT handle formatted string. For + // example, "ABC\tabc" will be printed + // as "ABCabc" So, we have to add '_' to separate each value when + // formatting String. + // Then, use String.split() to have each value in a sub-string. + + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + + curY = curY + 2 * charHeight; + + if (nsharpNative.nsharpLib.qc(pcl.bplus) == 1) { + textStr = NsharpNativeConstants.PARCEL_CAPE_LINE; + textStr = String.format(textStr, pcl.bplus); + } else { + textStr = NsharpNativeConstants.PARCEL_CAPE_MISSING; + } + target.drawString(myfont, textStr, rect.x, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); - if(nsharpNative.nsharpLib.qc(pcl.li5)==1){ - textStr = NsharpNativeConstants.PARCEL_LI_LINE; - textStr = String.format(textStr,pcl.li5); - } - else { - textStr = NsharpNativeConstants.PARCEL_LI_MISSING; - } - target.drawString(myfont, textStr, rect.x+rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, + if (nsharpNative.nsharpLib.qc(pcl.li5) == 1) { + textStr = NsharpNativeConstants.PARCEL_LI_LINE; + textStr = String.format(textStr, pcl.li5); + } else { + textStr = NsharpNativeConstants.PARCEL_LI_MISSING; + } + target.drawString(myfont, textStr, rect.x + rect.width / 2, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + curY = curY + charHeight; + if (nsharpNative.nsharpLib.qc(pcl.bfzl) == 1) { + textStr = NsharpNativeConstants.PARCEL_BFZL_LINE; + textStr = String.format(textStr, pcl.bfzl); + } else { + textStr = NsharpNativeConstants.PARCEL_BFZL_MISSING; + } + target.drawString(myfont, textStr, rect.x, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); - curY = curY + charHeight; - if(nsharpNative.nsharpLib.qc(pcl.bfzl)==1){ - textStr = NsharpNativeConstants.PARCEL_BFZL_LINE; - textStr = String.format(textStr,pcl.bfzl); - } - else{ - textStr = NsharpNativeConstants.PARCEL_BFZL_MISSING; - } - target.drawString(myfont, textStr, rect.x, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - if(nsharpNative.nsharpLib.qc(pcl.limax)==1){ - textStr = NsharpNativeConstants.PARCEL_LIMIN_LINE; - textStr = String.format(textStr,pcl.limax,pcl.limaxpres); - } - else{ - textStr = NsharpNativeConstants.PARCEL_LIMIN_MISSING; - } - target.drawString(myfont, textStr, rect.x+rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - if(nsharpNative.nsharpLib.qc(pcl.bminus)==1){ - textStr = NsharpNativeConstants.PARCEL_CINH_LINE; - textStr = String.format(textStr,pcl.bminus); - } - else { - textStr = NsharpNativeConstants.PARCEL_CINH_MISSING; - } - target.drawString(myfont, textStr, rect.x, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, + if (nsharpNative.nsharpLib.qc(pcl.limax) == 1) { + textStr = NsharpNativeConstants.PARCEL_LIMIN_LINE; + textStr = String.format(textStr, pcl.limax, pcl.limaxpres); + } else { + textStr = NsharpNativeConstants.PARCEL_LIMIN_MISSING; + } + target.drawString(myfont, textStr, rect.x + rect.width / 2, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + curY = curY + charHeight; + if (nsharpNative.nsharpLib.qc(pcl.bminus) == 1) { + textStr = NsharpNativeConstants.PARCEL_CINH_LINE; + textStr = String.format(textStr, pcl.bminus); + } else { + textStr = NsharpNativeConstants.PARCEL_CINH_MISSING; + } + target.drawString(myfont, textStr, rect.x, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); - if(nsharpNative.nsharpLib.qc(pcl.cap)==1){ - textStr = NsharpNativeConstants.PARCEL_CAP_LINE; - textStr = String.format(textStr, pcl.cap, pcl.cappres); - } - else { - textStr = NsharpNativeConstants.PARCEL_CAP_MISSING; - } - target.drawString(myfont, textStr, rect.x+rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + 2* charHeight; - + if (nsharpNative.nsharpLib.qc(pcl.cap) == 1) { + textStr = NsharpNativeConstants.PARCEL_CAP_LINE; + textStr = String.format(textStr, pcl.cap, pcl.cappres); + } else { + textStr = NsharpNativeConstants.PARCEL_CAP_MISSING; + } + target.drawString(myfont, textStr, rect.x + rect.width / 2, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + curY = curY + 2 * charHeight; - textStr = NsharpNativeConstants.PARCEL_LEVEL_LINE_; - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - target.drawLine(rect.x, curY, 0.0, rect.x+rect.width, curY, 0.0, NsharpConstants.color_white, 1); - - if(nsharpNative.nsharpLib.qc(pcl.lclpres)==1&& - nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(pcl.lclpres ))))==1 ) - { - textStr = NsharpNativeConstants.PARCEL_LCL_LINE_; - textStr = String.format(textStr,pcl.lclpres, nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(pcl.lclpres )))); - } - else { - textStr = NsharpNativeConstants.PARCEL_LCL_MISSING_; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; + textStr = NsharpNativeConstants.PARCEL_LEVEL_LINE_; + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + target.drawLine(rect.x, curY, 0.0, rect.x + rect.width, curY, 0.0, + NsharpConstants.color_white, 1); - if(nsharpNative.nsharpLib.qc(pcl.lfcpres)==1 && - nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(pcl.lfcpres ))))==1 && - nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib.itemp(pcl.lfcpres ))==1) - { - textStr = NsharpNativeConstants.PARCEL_LFC_LINE_; - textStr = String.format(textStr,pcl.lfcpres, nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(pcl.lfcpres ))), - nsharpNative.nsharpLib.itemp(pcl.lfcpres )); - } - else { - textStr = NsharpNativeConstants.PARCEL_LFC_MISSING_; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; + if (nsharpNative.nsharpLib.qc(pcl.lclpres) == 1 + && nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib + .mtof(nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(pcl.lclpres)))) == 1) { + textStr = NsharpNativeConstants.PARCEL_LCL_LINE_; + textStr = String.format(textStr, pcl.lclpres, + nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib + .agl(nsharpNative.nsharpLib.ihght(pcl.lclpres)))); + } else { + textStr = NsharpNativeConstants.PARCEL_LCL_MISSING_; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; - if(nsharpNative.nsharpLib.qc(pcl.elpres) ==1&& - nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(pcl.elpres )))) ==1&& - nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib.itemp(pcl.elpres ))==1) - { - textStr = NsharpNativeConstants.PARCEL_EL_LINE_; - textStr = String.format(textStr,pcl.elpres, nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(pcl.elpres ))), - nsharpNative.nsharpLib.itemp(pcl.elpres )); - } - else { - textStr = NsharpNativeConstants.PARCEL_EL_MISSING_; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; + if (nsharpNative.nsharpLib.qc(pcl.lfcpres) == 1 + && nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib + .mtof(nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(pcl.lfcpres)))) == 1 + && nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib + .itemp(pcl.lfcpres)) == 1) { + textStr = NsharpNativeConstants.PARCEL_LFC_LINE_; + textStr = String.format(textStr, pcl.lfcpres, + nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib + .agl(nsharpNative.nsharpLib.ihght(pcl.lfcpres))), + nsharpNative.nsharpLib.itemp(pcl.lfcpres)); + } else { + textStr = NsharpNativeConstants.PARCEL_LFC_MISSING_; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; - if(nsharpNative.nsharpLib.qc(pcl.mplpres)==1 && - nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(pcl.mplpres ))))==1 ) - { - textStr = NsharpNativeConstants.PARCEL_MPL_LINE_; - textStr = String.format(textStr,pcl.mplpres, nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(pcl.mplpres )))); - } - else { - textStr = NsharpNativeConstants.PARCEL_MPL_MISSING_; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - //myfont.dispose(); + if (nsharpNative.nsharpLib.qc(pcl.elpres) == 1 + && nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib + .mtof(nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(pcl.elpres)))) == 1 + && nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib + .itemp(pcl.elpres)) == 1) { + textStr = NsharpNativeConstants.PARCEL_EL_LINE_; + textStr = String.format(textStr, pcl.elpres, nsharpNative.nsharpLib + .mtof(nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(pcl.elpres))), nsharpNative.nsharpLib + .itemp(pcl.elpres)); + } else { + textStr = NsharpNativeConstants.PARCEL_EL_MISSING_; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + if (nsharpNative.nsharpLib.qc(pcl.mplpres) == 1 + && nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib + .mtof(nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(pcl.mplpres)))) == 1) { + textStr = NsharpNativeConstants.PARCEL_MPL_LINE_; + textStr = String.format(textStr, pcl.mplpres, + nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib + .agl(nsharpNative.nsharpLib.ihght(pcl.mplpres)))); + } else { + textStr = NsharpNativeConstants.PARCEL_MPL_MISSING_; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + // myfont.dispose(); } - @SuppressWarnings("deprecation") - private void drawPanel4(IGraphicsTarget target,Rectangle rect) - throws VizException { - extent = new PixelExtent(rect); - target.setupClippingPlane(extent); - //myfont = target.initializeFont(fontName, fontSize, null); - String textStr; - curY = rect.y; - /* - * Chin's NOTE::::this function is coded based on legacy native nsharp software show_thermoparms(), - * show_moisture(),show_instability() in xwvid3.c - * - * Moved from NsharpPaletteWindow.showThermoparms() - */ - - target.drawString(myfont, NsharpNativeConstants.THERMO_DATA_STR, rect.x + rect.width /3, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_cyan, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - target.drawString(myfont, NsharpNativeConstants.THERMO_MOISTURE_STR, rect.x + rect.width /4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_yellow, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - - - fValue.setValue(0); - nsharpNative.nsharpLib.precip_water(fValue, -1.0F, -1.0F); - if(nsharpNative.nsharpLib.qc(fValue.getValue())==1) { - textStr = NsharpNativeConstants.THERMO_PWATER_LINE; - textStr = String.format(textStr,fValue.getValue()); - } - else { - textStr = NsharpNativeConstants.THERMO_PWATER_MISSING; - } - target.drawString(myfont, textStr, rect.x, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - - fValue.setValue(0); - nsharpNative.nsharpLib.mean_relhum(fValue, -1.0F, -1.0F); - if(nsharpNative.nsharpLib.qc(fValue.getValue())==1) { - textStr = NsharpNativeConstants.THERMO_MEANRH_LINE; - textStr = String.format(textStr,fValue.getValue(),NsharpConstants.PERCENT_SYMBOL); - } - else { - textStr = NsharpNativeConstants.THERMO_MEANRH_MISSING; - } - target.drawString(myfont, textStr, rect.x + rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - - - fValue.setValue(0); - nsharpNative.nsharpLib.mean_mixratio(fValue, -1.0F, -1.0F); - if(nsharpNative.nsharpLib.qc(fValue.getValue())==1) { - textStr = NsharpNativeConstants.THERMO_MEANW_LINE; - textStr = String.format(textStr,fValue.getValue()); - } - else { - textStr = NsharpNativeConstants.THERMO_MEANW_MISSING; - } - target.drawString(myfont, textStr, rect.x, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - fValue.setValue(0); - fValue1.setValue(0); - // get surface pressure (fValue1) before getting mean LRH value - nsharpNative.nsharpLib.get_surface(fValue1, fValue2, fValue3); //fValue 2 and fValue3 are not of concern here - nsharpNative.nsharpLib.mean_relhum( fValue, -1.0F, fValue1.getValue() - 150 ); - if(nsharpNative.nsharpLib.qc(fValue.getValue())==1) { - textStr = NsharpNativeConstants.THERMO_MEANLRH_LINE; - textStr = String.format(textStr,fValue.getValue(),NsharpConstants.PERCENT_SYMBOL); - } - else { - textStr = NsharpNativeConstants.THERMO_MEANLRH_MISSING; - } - target.drawString(myfont, textStr, rect.x + rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - - - fValue.setValue(0); - nsharpNative.nsharpLib.top_moistlyr(fValue); - if(nsharpNative.nsharpLib.qc(fValue.getValue())==1) { - textStr = NsharpNativeConstants.THERMO_TOP_LINE; - textStr = String.format(textStr,fValue.getValue(),nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(fValue.getValue())))); - } - else { - textStr = NsharpNativeConstants.THERMO_TOP_MISSING; - } - target.drawString(myfont, textStr, rect.x, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - - - //instability data--------------// - //yellow and bold for parcel header - target.drawString(myfont, NsharpNativeConstants.THERMO_INSTABILITY_STR, rect.x + rect.width /4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_yellow, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - - curY = curY + charHeight; - - - fValue.setValue(0); - fValue1.setValue(0); - - nsharpNative.nsharpLib.delta_t(fValue); - nsharpNative.nsharpLib.lapse_rate( fValue1, 700.0F, 500.0F ); - - if(nsharpNative.nsharpLib.qc(fValue.getValue())==1 && nsharpNative.nsharpLib.qc(fValue1.getValue())==1) { - textStr = NsharpNativeConstants.THERMO_700500mb_LINE; - textStr = String.format(textStr,fValue.getValue(), fValue1.getValue()); - } - else { - textStr = NsharpNativeConstants.THERMO_700500mb_MISSING; - } - target.drawString(myfont, textStr, rect.x, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - - - fValue.setValue(0); - fValue1.setValue(0); - - nsharpNative.nsharpLib.vert_tot(fValue); - nsharpNative.nsharpLib.lapse_rate( fValue1, 850.0F, 500.0F ); - - if(nsharpNative.nsharpLib.qc(fValue.getValue())==1 && nsharpNative.nsharpLib.qc(fValue1.getValue())==1) { - textStr = NsharpNativeConstants.THERMO_850500mb_LINE; - textStr = String.format(textStr,fValue.getValue(), fValue1.getValue()); - } - else { - textStr = NsharpNativeConstants.THERMO_850500mb_MISSING; - } - target.drawString(myfont, textStr, rect.x, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - - - //misc parameters data--------------// - target.drawString(myfont, NsharpNativeConstants.THERMO_MISC_PARMS_STR, rect.x + rect.width /4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_yellow, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - - fValue.setValue(0); - fValue1.setValue(0); - fValue2.setValue(0); - nsharpNative.nsharpLib.t_totals(fValue, fValue1, fValue2); - if(nsharpNative.nsharpLib.qc(fValue.getValue())==1) { - textStr = NsharpNativeConstants.THERMO_TOTAL_LINE; - textStr = String.format(textStr,fValue.getValue()); - } - else { - textStr = NsharpNativeConstants.THERMO_TOTAL_MISSING; - } - target.drawString(myfont, textStr, rect.x, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - - fValue.setValue(0); - nsharpNative.nsharpLib.k_index(fValue); - if(nsharpNative.nsharpLib.qc(fValue.getValue())==1) { - textStr = NsharpNativeConstants.THERMO_KINDEX_LINE; - textStr = String.format(textStr,fValue.getValue()); - } - else { - textStr = NsharpNativeConstants.THERMO_KINDEX_MISSING; - } - target.drawString(myfont, textStr, rect.x + rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - - - fValue.setValue(0); - nsharpNative.nsharpLib.sweat_index(fValue); - if(nsharpNative.nsharpLib.qc(fValue.getValue())==1) { - textStr = NsharpNativeConstants.THERMO_SWEAT_LINE; - textStr = String.format(textStr,fValue.getValue()); - } - else { - textStr = NsharpNativeConstants.THERMO_SWEAT_MISSING; - } - - target.drawString(myfont, textStr, rect.x, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - - fValue.setValue(0); - float maxTempF = nsharpNative.nsharpLib.ctof(nsharpNative.nsharpLib.max_temp( fValue, -1)); - if(nsharpNative.nsharpLib.qc(maxTempF)==1) { - textStr = NsharpNativeConstants.THERMO_MAXT_LINE; - textStr = String.format(textStr,maxTempF); - } - else { - textStr = NsharpNativeConstants.THERMO_MAXT_MISSING; - } - target.drawString(myfont, textStr, rect.x + rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - - - fValue.setValue(0); - float theDiff = nsharpNative.nsharpLib.ThetaE_diff( fValue); - if(nsharpNative.nsharpLib.qc(theDiff)==1) { - textStr = NsharpNativeConstants.THERMO_THETAE_LINE; - textStr = String.format(textStr,theDiff); - } - else { - textStr = NsharpNativeConstants.THERMO_THETAE_MISSING; - } - target.drawString(myfont, textStr, rect.x, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - fValue.setValue(0); - float conTempF = nsharpNative.nsharpLib.ctof(nsharpNative.nsharpLib.cnvtv_temp( fValue, -1)); - if(nsharpNative.nsharpLib.qc(conTempF)==1) { - textStr = NsharpNativeConstants.THERMO_CONVT_LINE; - textStr = String.format(textStr,conTempF); - } - else { - textStr = NsharpNativeConstants.THERMO_CONVT_MISSING; - } - target.drawString(myfont, textStr, rect.x + rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - - fValue.setValue(0); - float wbzft = nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(nsharpNative.nsharpLib.wb_lvl( 0, fValue )))); - if(nsharpNative.nsharpLib.qc(wbzft)==1) { - textStr = NsharpNativeConstants.THERMO_WBZ_LINE; - textStr = String.format(textStr,wbzft); - } - else { - textStr = NsharpNativeConstants.THERMO_WBZ_MISSING; - } - target.drawString(myfont, textStr, rect.x, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - fValue.setValue(0); - float fgzft = nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(nsharpNative.nsharpLib.temp_lvl( 0, fValue )))); - if(nsharpNative.nsharpLib.qc(fgzft)==1) { - textStr = NsharpNativeConstants.THERMO_FGZ_LINE; - textStr = String.format(textStr,fgzft); - } - else { - textStr = NsharpNativeConstants.THERMO_FGZ_MISSING; - } - target.drawString(myfont, textStr, rect.x + rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - //myfont.dispose(); - } - @SuppressWarnings("deprecation") - private void drawPanel5(IGraphicsTarget target,Rectangle rect) - throws VizException { - extent = new PixelExtent(rect); + @SuppressWarnings("deprecation") + private void drawPanel4(IGraphicsTarget target, Rectangle rect) + throws VizException { + IFont myfont; + myfont = defaultFont; + defineCharHeight(myfont); + myfont.setSmoothing(false); + myfont.setScaleFont(false); + extent = new PixelExtent(rect); target.setupClippingPlane(extent); - //myfont = target.initializeFont(fontName, fontSize, null); - String splitedStr[]; + // myfont = target.initializeFont(fontName, fontSize, null); String textStr; curY = rect.y; - - /* - * Chin's NOTE::::this function is coded based on legacy nsharp software - * show_gradient() - * in xwvid3.c - */ - FloatByReference Surfpressure= new FloatByReference(0); - FloatByReference surfTemp= new FloatByReference(0); - FloatByReference surfDewpt= new FloatByReference(0); - target.drawString(myfont, NsharpNativeConstants.OPC_LOW_LEVEL_STR, rect.x + rect.width /3, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_cyan, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - target.drawString(myfont, NsharpNativeConstants.OPC_SURFACE975_STR, rect.x + rect.width /4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_yellow, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - - - textStr = NsharpNativeConstants.OPC_LEVEL_LINE_; - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - target.drawLine(rect.x, curY, 0.0, rect.x+rect.width, curY, 0.0, NsharpConstants.color_white, 1); - - float ht = nsharpNative.nsharpLib.ihght(975); - if(ht == NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA) - textStr = NsharpNativeConstants.OPC_975_LINE_MISSING_; - else{ - textStr = NsharpNativeConstants.OPC_975_LINE_; - textStr = String.format(textStr, nsharpNative.nsharpLib.ihght(975), nsharpNative.nsharpLib.itemp(975)); - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - - ht=0; - // get surface pressure (fValue1), Surface_temp (fValue2) - nsharpNative.nsharpLib.get_surface(Surfpressure, surfTemp, surfDewpt); - if(nsharpNative.nsharpLib.qc(Surfpressure.getValue())==1) - ht = nsharpNative.nsharpLib.ihght( Surfpressure.getValue() ); - if(nsharpNative.nsharpLib.qc(Surfpressure.getValue())==1 && nsharpNative.nsharpLib.qc(surfTemp.getValue())==1) { - textStr = NsharpNativeConstants.OPC_SURFACE_LINE_; - textStr = String.format(textStr,Surfpressure.getValue(), ht,surfTemp.getValue()); - } - else { - textStr = NsharpNativeConstants.OPC_SURFACE_MISSING_; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; + /* + * Chin's NOTE::::this function is coded based on legacy native nsharp + * software show_thermoparms(), show_moisture(),show_instability() in + * xwvid3.c + * + * Moved from NsharpPaletteWindow.showThermoparms() + */ - /* ----- Sfc-975 Grad ----- */ - /* make sure both 975mb layer and surface layer temperatures are available */ - if(nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib.itemp(975))==1 && nsharpNative.nsharpLib.qc(surfTemp.getValue())==1){ - textStr = NsharpNativeConstants.OPC_975_SURFACE_LINE; - textStr = String.format(textStr,nsharpNative.nsharpLib.itemp(975)-surfTemp.getValue()); - } - else { - textStr = NsharpNativeConstants.OPC_975_SURFACE_MISSING; - } - target.drawString(myfont, textStr, rect.x, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, + target.drawString(myfont, NsharpNativeConstants.THERMO_DATA_STR, rect.x + + rect.width / 3, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_cyan, HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); - curY = curY + charHeight; - /* - * Chin's NOTE::::this function is coded based on legacy nsharp software - * show_inversion() - * in xwvid3.c - * - * inv_mb - Pressure of inversion level (mb) - * inv_dC - Change in temperature (C) - * - */ - FloatByReference inv_mb= new FloatByReference(0); - FloatByReference inv_dC= new FloatByReference(0); - ; - //yellow and bold for parcel header - target.drawString(myfont, NsharpNativeConstants.OPC_LOWEST_INV_STR, rect.x + rect.width /4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_yellow, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + 2* charHeight; - nsharpNative.nsharpLib.low_inv(inv_mb, inv_dC); - if(nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib.ihght(inv_mb.getValue()))==1) { - textStr = NsharpNativeConstants.OPC_BASEHEIGHT_LINE; - textStr = String.format(textStr,nsharpNative.nsharpLib.ihght(inv_mb.getValue())); - } - else { - textStr = NsharpNativeConstants.OPC_BASEHEIGHT_MISSING; - } - target.drawString(myfont, textStr, rect.x, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, + curY = curY + charHeight; + target.drawString(myfont, NsharpNativeConstants.THERMO_MOISTURE_STR, + rect.x + rect.width / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_yellow, HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); - curY = curY + charHeight; + curY = curY + charHeight; - if(nsharpNative.nsharpLib.qc(inv_mb.getValue())==1) { - textStr = NsharpNativeConstants.OPC_BASEPRESSURE_LINE; - textStr = String.format(textStr,inv_mb.getValue()); - } - else { - textStr = NsharpNativeConstants.OPC_BASEPRESSURE_MISSING; - } - target.drawString(myfont, textStr, rect.x, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - - if(nsharpNative.nsharpLib.qc(inv_dC.getValue())==1) { - textStr = NsharpNativeConstants.OPC_CHANGE_IN_TEMP_LINE; - textStr = String.format(textStr,inv_dC.getValue()); - } - else { - textStr = NsharpNativeConstants.OPC_CHANGE_IN_TEMP_MISSING; - } - target.drawString(myfont, textStr, rect.x, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - - //myfont.dispose(); - } - @SuppressWarnings("deprecation") - private void drawPanel6(IGraphicsTarget target,Rectangle rect) - throws VizException { - extent = new PixelExtent(rect); - target.setupClippingPlane(extent); - //myfont = target.initializeFont(fontName, fontSize, null); - String splitedStr[]; - String textStr; - curY = rect.y; - - /* - * Chin's NOTE::::this function is coded based on legacy nsharp software - * show_mixheight() - * in xwvid3.c - * Calculates the mixing height using legacy mix_height() - * - * void mix_height ( float *mh_mb, float *mh_drct, float *mh_sped, - * float *mh_dC, float *mh_lr, float *mh_drct_max, - * float *mh_sped_max, short flag ) - * - * Where: - * flag = 0 Surface-based lapse rate - * flag = 1 Layer-based lapse rate - * - * mh_mb - Pressure at mixing height (mb) - * mh_drct - Wind direction at mixing height (deg) - * mh_sped - Wind speed at mixing height (kt) - * mh_dC - Layer change in temperature (C) - * mh_lr - Layer lapse rate (C/km) - * mh_drct_max - Layer maximum wind direction (deg) - * mh_sped_max - Layer maximum wind speed (kt) - */ - FloatByReference mh_mb= new FloatByReference(0); - FloatByReference mh_drct= new FloatByReference(0); - FloatByReference mh_sped= new FloatByReference(0); - FloatByReference mh_dC= new FloatByReference(0); - FloatByReference mh_lr= new FloatByReference(0); - FloatByReference mh_drct_max= new FloatByReference(0); - FloatByReference mh_sped_max= new FloatByReference(0); - short flag; - - //yellow and bold for parcel header - target.drawString(myfont, NsharpNativeConstants.OPC_MIXING_HGT_STR, rect.x + rect.width /10, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_yellow, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - textStr = NsharpNativeConstants.OPC_DRY_AD_LINE; - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - textStr = NsharpNativeConstants.OPC_THRESH_LAPSE_LINE; - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - - // Cyan color for Layer Based string - target.drawString(myfont, NsharpNativeConstants.OPC_LAYER_BASED_STR, rect.x + rect.width /3, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_cyan, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - // calculate Layer-based lapse rate data - flag = 1; - nsharpNative.nsharpLib.mix_height(mh_mb,mh_drct,mh_sped,mh_dC,mh_lr,mh_drct_max,mh_sped_max,flag); - - if(nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib.ihght(mh_mb.getValue()))==1) { - textStr = NsharpNativeConstants.OPC_MIXINGHEIGHT_LINE; - textStr = String.format(textStr,nsharpNative.nsharpLib.ihght(mh_mb.getValue())); - } - else { - textStr = NsharpNativeConstants.OPC_MIXINGHEIGHT_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - - if(nsharpNative.nsharpLib.qc(mh_mb.getValue())==1) { - textStr = NsharpNativeConstants.OPC_MIXINGPRESSURE_LINE; - textStr = String.format(textStr,mh_mb.getValue()); - } - else { - textStr = NsharpNativeConstants.OPC_MIXINGPRESSURE_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - - if(nsharpNative.nsharpLib.qc(mh_drct.getValue())==1 && nsharpNative.nsharpLib.qc(mh_sped.getValue())==1) { - textStr = NsharpNativeConstants.OPC_TOPMIXLAYER_LINE; - //System.out.println("speed = " + mh_sped.getValue()); - textStr = String.format(textStr,(int)mh_drct.getValue(),NsharpConstants.DEGREE_SYMBOL,(int)(mh_sped.getValue())); - } - else { - textStr = NsharpNativeConstants.OPC_TOPMIXLAYER_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - - if(nsharpNative.nsharpLib.qc(mh_drct_max.getValue()) ==1 && nsharpNative.nsharpLib.qc(mh_sped_max.getValue())==1) { - textStr = NsharpNativeConstants.OPC_MIXLAYERMAX_LINE; - textStr = String.format(textStr,(int)mh_drct_max.getValue(),NsharpConstants.DEGREE_SYMBOL,(int)mh_sped_max.getValue()); - } - else { - textStr = NsharpNativeConstants.OPC_MIXLAYERMAX_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - - if(nsharpNative.nsharpLib.qc(mh_dC.getValue()) ==1 && nsharpNative.nsharpLib.qc(mh_lr.getValue())==1) { - textStr = NsharpNativeConstants.OPC_LAYER_LAPSE_LINE; - textStr = String.format(textStr,mh_dC.getValue(),mh_lr.getValue()); - } - else { - textStr = NsharpNativeConstants.OPC_LAYER_LAPSE_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - - - // Purple color for Layer Based string - target.drawString(myfont, NsharpNativeConstants.OPC_SURFACE_BASED_STR, rect.x + rect.width /3, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_violet, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - // calculate Surface-based lapse rate data - flag = 0; - mh_mb.setValue(0); - mh_drct.setValue(0); - mh_sped.setValue(0); - mh_dC.setValue(0); - mh_lr.setValue(0); - mh_drct_max.setValue(0); - mh_sped_max.setValue(0);; - nsharpNative.nsharpLib.mix_height(mh_mb,mh_drct,mh_sped,mh_dC,mh_lr,mh_drct_max,mh_sped_max,flag); - - //white color for text - if(nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib.ihght(mh_mb.getValue()))==1) { - textStr = NsharpNativeConstants.OPC_MIXINGHEIGHT_LINE; - textStr = String.format(textStr,nsharpNative.nsharpLib.ihght(mh_mb.getValue())); - } - else { - textStr = NsharpNativeConstants.OPC_MIXINGHEIGHT_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - - if(nsharpNative.nsharpLib.qc(mh_mb.getValue())==1) { - textStr = NsharpNativeConstants.OPC_MIXINGPRESSURE_LINE; - textStr = String.format(textStr,mh_mb.getValue()); - } - else { - textStr = NsharpNativeConstants.OPC_MIXINGPRESSURE_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - - if(nsharpNative.nsharpLib.qc(mh_drct.getValue()) == 1 && nsharpNative.nsharpLib.qc(mh_sped.getValue())==1) { - textStr = NsharpNativeConstants.OPC_TOPMIXLAYER_LINE; - textStr = String.format(textStr,(int)mh_drct.getValue(),NsharpConstants.DEGREE_SYMBOL,(int)mh_sped.getValue()); - } - else { - textStr = NsharpNativeConstants.OPC_TOPMIXLAYER_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - - if(nsharpNative.nsharpLib.qc(mh_drct_max.getValue()) ==1 && nsharpNative.nsharpLib.qc(mh_sped_max.getValue())==1) { - textStr = NsharpNativeConstants.OPC_MIXLAYERMAX_LINE; - textStr = String.format(textStr,(int)mh_drct_max.getValue(),NsharpConstants.DEGREE_SYMBOL,(int)mh_sped_max.getValue()); - } - else { - textStr = NsharpNativeConstants.OPC_MIXLAYERMAX_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - - if(nsharpNative.nsharpLib.qc(mh_dC.getValue())==1 && nsharpNative.nsharpLib.qc(mh_lr.getValue())==1) { - textStr = NsharpNativeConstants.OPC_LAYER_LAPSE_LINE; - textStr = String.format(textStr,mh_dC.getValue(),mh_lr.getValue()); - } - else { - textStr = NsharpNativeConstants.OPC_LAYER_LAPSE_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - //myfont.dispose(); - } - @SuppressWarnings("deprecation") - private void drawPanel7(IGraphicsTarget target,Rectangle rect) - throws VizException { - extent = new PixelExtent(rect); - target.setupClippingPlane(extent); - //myfont = target.initializeFont(fontName, fontSize, null); - String splitedStr[]; - String textStr; - curY = rect.y; - /* - * Chin's NOTE::::this function is coded based on legacy nsharp software - * show_srdata() in xwvid3.c. - * Hard coded numerical numbers are directly copied from it. - * - * float helicity ( float lower, float upper, float sdir, float sspd, - * float *phel, float *nhel ) - * Calculates the storm-relative helicity (m2/s2) of a - * layer from LOWER(m, agl) to UPPER(m, agl). Uses the - * storm motion vector (sdir, sspd). - * - * lower - Bottom level of layer (m, AGL)[-1=LPL] - * upper - Top level of layer (m, AGL) [-1=LFC] - * sdir - Storm motion direction (degrees) - * sspd - Storm motion speed (kt) - * phel - Positive helicity in layer (m2/s2) - * nhel - Negative helicity in layer (m2/s2) - * RETURN VALUE - Total helicity (m2/s2) - * - * void sr_wind ( float pbot, float ptop, float sdir, float sspd, - * float *mnu, float *mnv, float *wdir, float *wspd ) - * Calculates a pressure-weighted SR mean wind thru the - * layer (pbot-ptop). Default layer is LFC-EL. - * pbot - Bottom level of layer (mb) - * ptop - Top level of layer (mb) - * sdir - Storm motion dirction (deg) - * sspd - Storm motion speed (kt) - * mnu - U-Component of mean wind (kt) - * mnv - V-Component of mean wind (kt) / - */ - - //FloatByReference sspd= new FloatByReference(0); - //FloatByReference sdir= new FloatByReference(0); - FloatByReference phel= new FloatByReference(0); - FloatByReference nhel= new FloatByReference(0); - FloatByReference mnu= new FloatByReference(0); - FloatByReference mnv= new FloatByReference(0); - FloatByReference smdir= new FloatByReference(0); - FloatByReference smspd= new FloatByReference(0); - FloatByReference wdir= new FloatByReference(0); - FloatByReference wspd= new FloatByReference(0); - float totHeli; - - target.drawString(myfont, NsharpNativeConstants.STORM_RELATIVE_STR, rect.x + rect.width /3, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_cyan, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - - nsharpNative.nsharpLib.get_storm(smspd, smdir); - - if(nsharpNative.nsharpLib.qc(smspd.getValue()) == 1 && nsharpNative.nsharpLib.qc(smdir.getValue())==1) { - textStr = NsharpNativeConstants.STORM_MOTION_LINE; - textStr = String.format(textStr,smdir.getValue(),NsharpConstants.DEGREE_SYMBOL, - smspd.getValue(), nsharpNative.nsharpLib.kt_to_mps(smspd.getValue())); - } - else { - textStr = NsharpNativeConstants.STORM_MOTION_MISSING; - } - target.drawString(myfont, textStr, rect.x + rect.width /4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - - //yellow and bold for parcel header - target.drawString(myfont, NsharpNativeConstants.STORM_HELICITY_STR, rect.x + rect.width /4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_yellow, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - textStr = NsharpNativeConstants.STORM_LAYER_POS_STR; - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - target.drawLine(rect.x, curY, 0.0, rect.x+rect.width, curY, 0.0, NsharpConstants.color_white, 1); - - //calculate helicity for sfc-2 km - totHeli = nsharpNative.nsharpLib.helicity( (float)0, (float)2000, smdir.getValue(), smspd.getValue(), phel, nhel); - if(nsharpNative.nsharpLib.qc(phel.getValue()) ==1 && nsharpNative.nsharpLib.qc(nhel.getValue())==1) { - textStr = NsharpNativeConstants.STORM_SFC2KM_LINE; - textStr = String.format(textStr,phel.getValue(), nhel.getValue(), totHeli, - NsharpConstants.SQUARE_SYMBOL, NsharpConstants.SQUARE_SYMBOL); - - } - else { - textStr = NsharpNativeConstants.STORM_SFC2KM_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - //calculate helicity for sfc-3 km - totHeli = nsharpNative.nsharpLib.helicity( (float)0, (float)3000, smdir.getValue(), smspd.getValue(), phel, nhel); - if(nsharpNative.nsharpLib.qc(phel.getValue()) == 1 && nsharpNative.nsharpLib.qc(nhel.getValue())==1) { - textStr = NsharpNativeConstants.STORM_SFC3KM_LINE; - textStr = String.format(textStr,phel.getValue(), nhel.getValue(), totHeli, - NsharpConstants.SQUARE_SYMBOL, NsharpConstants.SQUARE_SYMBOL); - } - else { - textStr = NsharpNativeConstants.STORM_SFC3KM_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - //calculate helicity for LPL - LFC - totHeli = nsharpNative.nsharpLib.helicity( (float)-1, (float)-1, smdir.getValue(), smspd.getValue(), phel, nhel); - if(nsharpNative.nsharpLib.qc(phel.getValue())==1 && nsharpNative.nsharpLib.qc(nhel.getValue())==1) { - textStr = NsharpNativeConstants.STORM_LPL_LFC_LINE; - textStr = String.format(textStr,phel.getValue(), nhel.getValue(), totHeli, - NsharpConstants.SQUARE_SYMBOL, NsharpConstants.SQUARE_SYMBOL); - } - else { - textStr = NsharpNativeConstants.STORM_LPL_LFC_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - //yellow and bold for header - target.drawString(myfont, NsharpNativeConstants.STORM_WIND_STR, rect.x + rect.width /4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_yellow, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + 2* charHeight; - textStr = NsharpNativeConstants.STORM_LAYER_VECTOR_STR; - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - target.drawLine(rect.x, curY, 0.0, rect.x+rect.width, curY, 0.0, NsharpConstants.color_white, 1); - - //calculate pressure-weighted SR mean wind at sfc-2 km - nsharpNative.nsharpLib.sr_wind( nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(0)), - nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(2000)), smdir.getValue(), smspd.getValue(), - mnu, mnv, wdir, wspd); - if(nsharpNative.nsharpLib.qc(wdir.getValue())==1) { - textStr = NsharpNativeConstants.STORM_SFC2KM_VECT_LINE; - textStr = String.format(textStr,wdir.getValue(), wspd.getValue(), nsharpNative.nsharpLib.kt_to_mps(wspd.getValue())); - } - else { - textStr = NsharpNativeConstants.STORM_SFC2KM_VECT_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - - //calculate pressure-weighted SR mean wind at 4-6 km - //System.out.println("msl(4000))="+ nsharpNative.nsharpLib.msl(4000) + "i_pres(msl(4000))" + nsharpNative.nsharpLib.i_pres(nsharpNative.nsharpLib.msl(4000))); - //System.out.println("msl(6000))="+ nsharpNative.nsharpLib.msl(6000) + "i_pres(msl(6000))" + nsharpNative.nsharpLib.i_pres(nsharpNative.nsharpLib.msl(6000))); - //System.out.println("dir "+ smdir.getValue()+ " spd " + smspd.getValue()); - nsharpNative.nsharpLib.sr_wind( nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(4000)), - nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(6000)), smdir.getValue(), smspd.getValue(), - mnu, mnv, wdir, wspd); - if(nsharpNative.nsharpLib.qc(wdir.getValue()) == 1) { - textStr = NsharpNativeConstants.STORM_4_6KM_VECT_LINE; - //System.out.println("wdir "+ wdir.getValue() + " widSp " + wspd.getValue()); - textStr = String.format(textStr,wdir.getValue(), wspd.getValue(), nsharpNative.nsharpLib.kt_to_mps(wspd.getValue())); - } - else { - textStr = NsharpNativeConstants.STORM_4_6KM_VECT_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - - //calculate pressure-weighted SR mean wind at 9-11 km - nsharpNative.nsharpLib.sr_wind( nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(9000)), - nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(11000)), smdir.getValue(), smspd.getValue(), - mnu, mnv, wdir, wspd); - if(nsharpNative.nsharpLib.qc(wdir.getValue())==1) { - textStr = NsharpNativeConstants.STORM_9_11KM_VECT_LINE; - textStr = String.format(textStr,wdir.getValue(), wspd.getValue(), nsharpNative.nsharpLib.kt_to_mps(wspd.getValue())); - } - else { - textStr = NsharpNativeConstants.STORM_9_11KM_VECT_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - - //myfont.dispose(); - } - @SuppressWarnings("deprecation") - private void drawPanel8(IGraphicsTarget target,Rectangle rect) - throws VizException { - extent = new PixelExtent(rect); - target.setupClippingPlane(extent); - //myfont = target.initializeFont(fontName, fontSize, null); - String splitedStr[]; - String textStr; - curY = rect.y; - /* - * Chin's NOTE::::this function is coded based on legacy nsharp software - * show_meanwind() - * in xwvid3.c - * - * void mean_wind ( float pbot, float ptop, float *mnu, float *mnv, - * float *wdir, float *wspd ) - * Calculates a pressure-weighted mean wind thru the - * layer (pbot-ptop). Default layer is LFC-EL. - * - * pbot - Bottom level of layer (mb) - * ptop - Top level of layer (mb) - * mnu - U-Component of mean wind (kt) - * mnv - V-Component of mean wind (kt) - */ - FloatByReference mnu= new FloatByReference(0); - FloatByReference mnv= new FloatByReference(0); - FloatByReference wdir= new FloatByReference(0); - FloatByReference wspd= new FloatByReference(0); - target.drawString(myfont, NsharpNativeConstants.MEAN_WIND_STR, rect.x + rect.width*0.4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_cyan, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - - //fix TT 549890 - //Calculate mean wind at 0-6 km, following the same algorithm used in drawPanel2() at BigNsharp page 2. - //Like this : mean_wind(nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(h1)), nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(h2))) - nsharpNative.nsharpLib.mean_wind( nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(0)), nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(6000)), mnu, mnv, wdir, wspd); - //this line was nsharpNative.nsharpLib.mean_wind( -1, nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.agl(6000)), mnu, mnv, wdir, wspd); - //System.out.println("wsp ="+ wspd.getValue()+ " wdir "+ wdir.getValue() + " agl(6000)="+nsharpNative.nsharpLib.agl(6000)+ " preAt6000="+nsharpNative.nsharpLib.i_pres(nsharpNative.nsharpLib.agl(6000))); - if(nsharpNative.nsharpLib.qc(wdir.getValue()) == 1 && nsharpNative.nsharpLib.qc(wspd.getValue())== 1) { - textStr = NsharpNativeConstants.MEANWIND_SFC6KM_LINE; - textStr = String.format(textStr,(wdir.getValue()), wspd.getValue(), - nsharpNative.nsharpLib.kt_to_mps(wspd.getValue())); - } - else { - textStr = NsharpNativeConstants.MEANWIND_SFC6KM_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - - - - //fix TT 549890 - //Calculate mean wind at LFC-EL, following the same algorithm used in drawPanel2() for LCL_EL for BigNsharp pag - // Replacing LCL with LFC - _lplvalues lpvls; - _parcel pcl; - lpvls = new _lplvalues(); - pcl = new _parcel(); - float h1, h2; - h1=-1; - h2=-1; - nsharpNative.nsharpLib.get_lpvaluesData(lpvls); - - float sfctemp = lpvls.temp; - float sfcdwpt = lpvls.dwpt; - float sfcpres = lpvls.pres; - nsharpNative.nsharpLib.parcel( -1.0F, -1.0F, sfcpres, sfctemp, sfcdwpt, pcl); - if (pcl.bplus > 0) - { - h1 = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(pcl.lfcpres)); - h2 = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(pcl.elpres)); - } - - //Calculate mean wind at LFC-EL - nsharpNative.nsharpLib.mean_wind( nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(h1)), nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(h2)), mnu, mnv, wdir, wspd); - if(nsharpNative.nsharpLib.qc(wdir.getValue())==1 && nsharpNative.nsharpLib.qc(wspd.getValue())==1) { - textStr = NsharpNativeConstants.MEANWIND_LFC_EL_LINE; - textStr = String.format(textStr,wdir.getValue(), wspd.getValue(), - nsharpNative.nsharpLib.kt_to_mps(wspd.getValue())); - } - else { - textStr = NsharpNativeConstants.MEANWIND_LFC_EL_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - //Calculate mean wind at 850-200 mb - nsharpNative.nsharpLib.mean_wind( 850,200, mnu, mnv, wdir, wspd); - if(nsharpNative.nsharpLib.qc(wdir.getValue()) ==1 && nsharpNative.nsharpLib.qc(wspd.getValue())==1) { - textStr = NsharpNativeConstants.MEANWIND_850_200MB_LINE; - textStr = String.format(textStr,wdir.getValue(), wspd.getValue(), - nsharpNative.nsharpLib.kt_to_mps(wspd.getValue())); - } - else { - textStr = NsharpNativeConstants.MEANWIND_850_200MB_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - /* - * Chin's NOTE::::this function is coded based on legacy nsharp software - * show_shear() - * in xwvid3.c - * - * void wind_shear ( float pbot, float ptop, float *shu, float *shv, - * float *sdir, float *smag ) - * - * Calculates the shear between the wind at (pbot) and - * (ptop). Default lower wind is a 1km mean wind, while - * the default upper layer is 3km. - * - * pbot - Bottom level of layer (mb) - * ptop - Top level of layer (mb) - * shu - U-Component of shear (m/s) - * shv - V-Component of shear (m/s) - * sdir - Direction of shear vector (degrees) - * smag - Magnitude of shear vector (m/s) - */ - FloatByReference shu= new FloatByReference(0); - FloatByReference shv= new FloatByReference(0); - FloatByReference sdir= new FloatByReference(0); - FloatByReference smag= new FloatByReference(0); - target.drawString(myfont, NsharpNativeConstants.ENVIRONMENTAL_SHEAR_STR, rect.x + rect.width/3, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_cyan, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - - - textStr = NsharpNativeConstants.SHEAR_LAYER_DELTA_STR; - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/3, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - target.drawLine(rect.x, curY, 0.0, rect.x+rect.width, curY, 0.0, NsharpConstants.color_white, 1); - - //Calculate wind shear at Low - 3 km - nsharpNative.nsharpLib.wind_shear( nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(0)), nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(3000)), - shu,shv,sdir,smag); - if(nsharpNative.nsharpLib.qc(smag.getValue())==1) { - textStr = NsharpNativeConstants.SHEAR_LOW_3KM_LINE; - textStr = String.format(textStr,smag.getValue(), - nsharpNative.nsharpLib.kt_to_mps(smag.getValue()), - nsharpNative.nsharpLib.kt_to_mps(smag.getValue())/.3F); - //System.out.println("from cave "+smag.getValue() + " kt, " + nsharpNative.nsharpLib.kt_to_mps(smag.getValue())+ " m/s, Tot="+ nsharpNative.nsharpLib.kt_to_mps(smag.getValue())/.3F); - } - else { - textStr = NsharpNativeConstants.SHEAR_LOW_3KM_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/3, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - - //Calculate wind shear at Sfc - 2 km - nsharpNative.nsharpLib.wind_shear( nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(0)), nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(2000)), - shu,shv,sdir,smag); - if(nsharpNative.nsharpLib.qc(smag.getValue())==1) { - textStr = NsharpNativeConstants.SHEAR_SFC_2KM_LINE; - textStr = String.format(textStr,smag.getValue(), - nsharpNative.nsharpLib.kt_to_mps(smag.getValue()), - nsharpNative.nsharpLib.kt_to_mps(smag.getValue())/.2F); - } - else { - textStr = NsharpNativeConstants.SHEAR_SFC_2KM_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/3, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - - //Calculate wind shear at Sfc - 6 km - nsharpNative.nsharpLib.wind_shear( nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(0)), nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(6000)), - shu,shv,sdir,smag); - if(nsharpNative.nsharpLib.qc(smag.getValue())==1) { - textStr = NsharpNativeConstants.SHEAR_SFC_6KM_LINE; - textStr = String.format(textStr,smag.getValue(), - nsharpNative.nsharpLib.kt_to_mps(smag.getValue()), - nsharpNative.nsharpLib.kt_to_mps(smag.getValue())/.6F); - } - else { - textStr = NsharpNativeConstants.SHEAR_SFC_6KM_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/3, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - - //Calculate wind shear at Sfc - 12 km - nsharpNative.nsharpLib.wind_shear( nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(0)), nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(12000)), - shu,shv,sdir,smag); - if(nsharpNative.nsharpLib.qc(smag.getValue())==1) { - textStr = NsharpNativeConstants.SHEAR_SFC_12KM_LINE; - textStr = String.format(textStr,smag.getValue(), - nsharpNative.nsharpLib.kt_to_mps(smag.getValue()), - nsharpNative.nsharpLib.kt_to_mps(smag.getValue())/1.2F); - } - else { - textStr = NsharpNativeConstants.SHEAR_SFC_12KM_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/3, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - //myfont.dispose(); - } - @SuppressWarnings("deprecation") - private void drawPanel9(IGraphicsTarget target,Rectangle rect) - throws VizException { - extent = new PixelExtent(rect); - target.setupClippingPlane(extent); - //myfont = target.initializeFont(fontName, fontSize, null); - String splitedStr[]; - String textStr; - curY = rect.y; - /* - * Chin's NOTE::::this function is coded based on legacy nsharp software - * show_initiation(): Displays thunderstorm initiation parameters, - * show_heavypcpn(), show_preciptype() and show_stormtype() - * in xwvid3.c - * - */ - FloatByReference fvalue2= new FloatByReference(0); - FloatByReference fvalue3= new FloatByReference(0); - FloatByReference wdir= new FloatByReference(0); - FloatByReference wspd= new FloatByReference(0); - FloatByReference fvalue= new FloatByReference(0); - FloatByReference fvalue1= new FloatByReference(0); - // get parcel data by calling native nsharp parcel() API. value is returned in pcl - // current parcel is already decided when page 1 is displyed. Note that page 1 is always - // displayed before this page (page 4). Therefore, we dont have to call define_parcel() again. - // set default - //short currentParcel; - float layerPressure; - if(currentParcel == NsharpNativeConstants.PARCELTYPE_USER_DEFINED ){ - layerPressure = NsharpParcelDialog.getUserDefdParcelMb(); - } - else - layerPressure = NsharpNativeConstants.parcelToLayerMap.get(currentParcel); - nsharpNative.nsharpLib.define_parcel(currentParcel,layerPressure); - - - _parcel pcl = new _parcel();; - _lplvalues lpvls = new _lplvalues(); - nsharpNative.nsharpLib.get_lpvaluesData(lpvls); - float sfctemp, sfcdwpt, sfcpres; - sfctemp = lpvls.temp; - sfcdwpt = lpvls.dwpt; - sfcpres = lpvls.pres; - nsharpNative.nsharpLib.parcel( -1.0F, -1.0F, sfcpres, sfctemp, sfcdwpt, pcl); - //_parcel.ByValue pcl_byvalue = new _parcel.ByValue(); - //nsharpNative.nsharpLib.parcel( -1.0F, -1.0F, sfcpres, sfctemp, sfcdwpt, pcl_byvalue); - - - //CONVECTIVE_INITIATION - target.drawString(myfont, NsharpNativeConstants.CONVECTIVE_INITIATION_STR, rect.x + rect.width/3, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_cyan, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - //CINH - if(nsharpNative.nsharpLib.qc(pcl.bminus)==1) { - textStr = NsharpNativeConstants.CONVECTIVE_CINH_LINE; - textStr = String.format(textStr,pcl.bminus); - } - else { - textStr = NsharpNativeConstants.CONVECTIVE_CINH_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - - //cap - if(nsharpNative.nsharpLib.qc(pcl.cap)==1 && nsharpNative.nsharpLib.qc(pcl.cappres)==1) { - textStr = NsharpNativeConstants.CONVECTIVE_CAP_LINE; - textStr = String.format(textStr,pcl.cap, pcl.cappres); - } - else { - textStr = NsharpNativeConstants.CONVECTIVE_CAP_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + rect.width/2+ i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - - //K-index - nsharpNative.nsharpLib.k_index(fvalue); - if(nsharpNative.nsharpLib.qc(fvalue.getValue())==1) { - textStr = NsharpNativeConstants.CONVECTIVE_KINDEX_LINE; - textStr = String.format(textStr,fvalue.getValue()); - } - else { - textStr = NsharpNativeConstants.CONVECTIVE_KINDEX_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - - //Mean RH - nsharpNative.nsharpLib.mean_relhum(fvalue, -1, -1); - if(nsharpNative.nsharpLib.qc(fvalue.getValue())==1) { - textStr = NsharpNativeConstants.CONVECTIVE_MEANRH_LINE; - textStr = String.format(textStr,fvalue.getValue(), NsharpConstants.PERCENT_SYMBOL); - } - else { - textStr = NsharpNativeConstants.CONVECTIVE_MEANRH_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + rect.width/2+ i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + 2*charHeight; - - //Top of M layer - nsharpNative.nsharpLib.top_moistlyr(fvalue); - //System.out.println("top_moistlyr=" + fvalue.getValue() ); - - if(nsharpNative.nsharpLib.qc(fvalue.getValue())==1) { - float ht = - nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(fvalue.getValue()))); - if(nsharpNative.nsharpLib.qc(ht)==1){ - textStr = NsharpNativeConstants.CONVECTIVE_TOP_LINE; - textStr = String.format(textStr,fvalue.getValue(),ht); - } - else { - textStr = NsharpNativeConstants.CONVECTIVE_TOP_MISSING; - } - } - else { - textStr = NsharpNativeConstants.CONVECTIVE_TOP_MISSING; - } - target.drawString(myfont, textStr, rect.x, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - //LFC height - if(nsharpNative.nsharpLib.qc(pcl.lfcpres)==1) { - float ht = - nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(pcl.lfcpres))); - if(nsharpNative.nsharpLib.qc(ht)==1){ - textStr = NsharpNativeConstants.CONVECTIVE_LFC_LINE; - textStr = String.format(textStr,pcl.lfcpres,ht); - } - else { - textStr = NsharpNativeConstants.CONVECTIVE_LFC_MISSING; - } - } - else { - textStr = NsharpNativeConstants.CONVECTIVE_LFC_MISSING; - } - target.drawString(myfont, textStr, rect.x, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - - //STORM TYPE - target.drawString(myfont, NsharpNativeConstants.STORM_TYPE_STR, rect.x + rect.width/3, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_cyan, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - - //CAPE - if(nsharpNative.nsharpLib.qc(pcl.bplus)==1) { - textStr = NsharpNativeConstants.STORM_TYPE_CAPE_LINE; - textStr = String.format(textStr,pcl.bplus); - } - else { - textStr = NsharpNativeConstants.STORM_TYPE_CAPE_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - - //EFF. SREH - float hel=0; - nsharpNative.nsharpLib.get_storm(wspd,wdir); - if(nsharpNative.nsharpLib.qc(wdir.getValue()) ==1 && nsharpNative.nsharpLib.qc(wspd.getValue())==1) { - hel = - nsharpNative.nsharpLib.helicity( -1.0F, -1.0F, wdir.getValue(), wspd.getValue(), fvalue, fvalue1); - if(nsharpNative.nsharpLib.qc(hel)==1){ - textStr = NsharpNativeConstants.STORM_TYPE_EFF_LINE; - textStr = String.format(textStr,hel,NsharpConstants.SQUARE_SYMBOL,NsharpConstants.SQUARE_SYMBOL); - } - else { - textStr = NsharpNativeConstants.STORM_TYPE_EFF_MISSING; - } - } - else { - textStr = NsharpNativeConstants.STORM_TYPE_EFF_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + rect.width/2+ i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - - //EHI - if(nsharpNative.nsharpLib.qc(pcl.bplus)==1) { - float ehi = - nsharpNative.nsharpLib.ehi( pcl.bplus, hel); - if(nsharpNative.nsharpLib.qc(ehi)==1){ - textStr = NsharpNativeConstants.STORM_TYPE_EHI_LINE; - textStr = String.format(textStr,ehi); - } - else { - textStr = NsharpNativeConstants.STORM_TYPE_EHI_MISSING; - } - } - else { - textStr = NsharpNativeConstants.STORM_TYPE_EHI_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - - //3km Shear - nsharpNative.nsharpLib.wind_shear( -1, -1, fvalue, fvalue1,fvalue2,fvalue3); - if(nsharpNative.nsharpLib.qc(fvalue3.getValue())==1) { - textStr = NsharpNativeConstants.STORM_TYPE_3KM_LINE; - textStr = String.format(textStr,nsharpNative.nsharpLib.kt_to_mps(fvalue3.getValue())); - } - else { - textStr = NsharpNativeConstants.STORM_TYPE_3KM_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + rect.width/2+ i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - - //BRN - if(nsharpNative.nsharpLib.qc(pcl.brn)==1) { - textStr = NsharpNativeConstants.STORM_TYPE_BRN_LINE; - textStr = String.format(textStr,pcl.brn); - } - else { - textStr = NsharpNativeConstants.STORM_TYPE_BRN_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - - //BRN Shear - //nsharpNative.nsharpLib.cave_bulk_rich(pcl.lplpres, pcl.bplus, fvalue ); - //System.out.println("bulk_rich fvalue = "+ fvalue.getValue()); - nsharpNative.nsharpLib.cave_bulk_rich2(fvalue ); - if(nsharpNative.nsharpLib.qc(fvalue.getValue())==1) { - textStr = NsharpNativeConstants.STORM_TYPE_BRNSHEAR_LINE; - textStr = String.format(textStr,fvalue.getValue(),NsharpConstants.SQUARE_SYMBOL, NsharpConstants.SQUARE_SYMBOL); - } - else - textStr = NsharpNativeConstants.STORM_TYPE_BRNSHEAR_MISSING; - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + rect.width/2+ i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - - //PRECIPITATION_TYPE - target.drawString(myfont, NsharpNativeConstants.PRECIPITATION_TYPE_STR, rect.x + rect.width/3, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_cyan, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - - //Melting Level - float web = nsharpNative.nsharpLib.wb_lvl( 0, fvalue ); - if(nsharpNative.nsharpLib.qc(web)==1) { - - float aglft = nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(web))); - if(nsharpNative.nsharpLib.qc(aglft)==1){ - textStr = NsharpNativeConstants.PRECIPITATION_MELTING_LINE; - textStr = String.format(textStr,aglft, web); - } - else - textStr = NsharpNativeConstants.PRECIPITATION_MELTING_MISSING; - } - else { - textStr = NsharpNativeConstants.PRECIPITATION_MELTING_MISSING; - } - target.drawString(myfont, textStr, rect.x, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - //HEAVY_RAINFAL - target.drawString(myfont, NsharpNativeConstants.HEAVY_RAINFALL_STR, rect.x + rect.width/3, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_cyan, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - - //Rogash_QPF, Chin: note: BigNsharp has different implementation of Rogash_QPF() - // We are using bigNsharp now. - nsharpNative.nsharpLib.Rogash_QPF(fvalue); - if(nsharpNative.nsharpLib.qc(fvalue.getValue())==1) { - textStr = NsharpNativeConstants.HEAVY_ROGASH_LINE; - textStr = String.format(textStr,fvalue.getValue()); - } - else { - textStr = NsharpNativeConstants.HEAVY_ROGASH_MISSING; - } - target.drawString(myfont, textStr, rect.x, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - // myfont.dispose(); - } - @SuppressWarnings("deprecation") - private void drawPanel10(IGraphicsTarget target,Rectangle rect) - throws VizException { - extent = new PixelExtent(rect); - target.setupClippingPlane(extent); - //myfont = target.initializeFont(fontName, fontSize, null); - String splitedStr[]; - String textStr; - curY = rect.y; - /* - * Chin's NOTE::::this function is coded based on legacy nsharp software - * show_hailpot(), show_torpot() - * in xwvid3.c - * - */ - FloatByReference fvalue2= new FloatByReference(0); - FloatByReference fvalue3= new FloatByReference(0); - FloatByReference wdir= new FloatByReference(0); - FloatByReference wspd= new FloatByReference(0); - FloatByReference fvalue= new FloatByReference(0); - FloatByReference fvalue1= new FloatByReference(0); - - target.drawString(myfont, NsharpNativeConstants.SEVERE_POTENTIAL_STR, rect.x + rect.width/3, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_cyan, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - - target.drawString(myfont, NsharpNativeConstants.SEVERE_HAIL_POTENTIAL_STR, rect.x + rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_yellow, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - - _parcel pcl = new _parcel();; - _lplvalues lpvls = new _lplvalues(); - nsharpNative.nsharpLib.get_lpvaluesData(lpvls); - float sfctemp, sfcdwpt, sfcpres; - sfctemp = lpvls.temp; - sfcdwpt = lpvls.dwpt; - sfcpres = lpvls.pres; - nsharpNative.nsharpLib.parcel( -1.0F, -1.0F, sfcpres, sfctemp, sfcdwpt, pcl); - //CAPE - if(nsharpNative.nsharpLib.qc(pcl.bplus)==1) { - textStr = NsharpNativeConstants.SEVERE_CAPE_LINE; - textStr = String.format(textStr,pcl.bplus); - } - else { - textStr = NsharpNativeConstants.SEVERE_CAPE_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - - // WBZ level - float wbzft = nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(nsharpNative.nsharpLib.wb_lvl( 0, fvalue )))); - if(nsharpNative.nsharpLib.qc(wbzft)==1) { - textStr = NsharpNativeConstants.SEVERE_WBZ_LINE; - textStr = String.format(textStr,wbzft); - } - else { - textStr = NsharpNativeConstants.SEVERE_WBZ_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + rect.width/2+ i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - - //Mid Level RH - nsharpNative.nsharpLib.mean_relhum( fvalue, 700, 500); - if(nsharpNative.nsharpLib.qc(fvalue.getValue())==1) { - textStr = NsharpNativeConstants.SEVERE_MIDRH_LINE; - textStr = String.format(textStr,fvalue.getValue(),NsharpConstants.PERCENT_SYMBOL); - } - else { - textStr = NsharpNativeConstants.SEVERE_MIDSRW_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - - //FZG level - float fgzft = nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(nsharpNative.nsharpLib.temp_lvl( 0, fvalue )))); - if(nsharpNative.nsharpLib.qc(fgzft)==1) { - textStr = NsharpNativeConstants.SEVERE_FGZ_LINE; - textStr = String.format(textStr,fgzft); - } - else { - textStr = NsharpNativeConstants.SEVERE_FGZ_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + rect.width/2+ i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - - //EL Storm - nsharpNative.nsharpLib.get_storm(wspd,wdir); - nsharpNative.nsharpLib.sr_wind( pcl.elpres+25, pcl.elpres-25,wdir.getValue(), wspd.getValue(), fvalue,fvalue1,fvalue2,fvalue3); - if(nsharpNative.nsharpLib.qc(fvalue3.getValue())==1) { - textStr = NsharpNativeConstants.SEVERE_ELSTORM_LINE; - textStr = String.format(textStr,fvalue3.getValue()); - } - else { - textStr = NsharpNativeConstants.SEVERE_ELSTORM_MISSING; - } - target.drawString(myfont, textStr, rect.x, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - // CHI1 - //_parcel.ByValue pcl_byvalue = new _parcel.ByValue(); - // pr = nsharpNative.nsharpLib.parcel( -1.0F, -1.0F, sfcpres, sfctemp, sfcdwpt, pcl_byvalue); - //Assigne values that needed for bulk_rich() - //pcl_byvalue.lplpres = sfcpres; - //pcl_byvalue.bplus = pcl.bplus; - nsharpNative.nsharpLib.cave_bulk_rich2( fvalue ); - float rtn = (pcl.bplus * fvalue.getValue()) / nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(nsharpNative.nsharpLib.wb_lvl( 0, fvalue1 ))); - if(nsharpNative.nsharpLib.qc(rtn)==1) { - textStr = NsharpNativeConstants.SEVERE_CHI1_LINE; - textStr = String.format(textStr,rtn); - } - else { - textStr = NsharpNativeConstants.SEVERE_CHI1_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - //CHI2 - nsharpNative.nsharpLib.Mean_WBtemp( fvalue2, -1, -1); - if(nsharpNative.nsharpLib.qc(rtn/fvalue2.getValue())==1) { - textStr = NsharpNativeConstants.SEVERE_CHI2_LINE; - textStr = String.format(textStr,rtn/fvalue2.getValue()); - } - else { - textStr = NsharpNativeConstants.SEVERE_CHI2_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + rect.width/2+ i*rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - - //Avg BL - nsharpNative.nsharpLib.Mean_WBtemp( fvalue, -1, -1); - if(nsharpNative.nsharpLib.qc(fvalue.getValue())==1) { - textStr = NsharpNativeConstants.SEVERE_AVGBL_LINE; - textStr = String.format(textStr,fvalue.getValue(),NsharpConstants.DEGREE_SYMBOL); - } - else { - textStr = NsharpNativeConstants.SEVERE_AVGBL_MISSING; - } - target.drawString(myfont, textStr, rect.x, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - - //TORNADO_POTENTIAL - target.drawString(myfont, NsharpNativeConstants.SEVERE_TORNADO_POTENTIAL_STR, rect.x + rect.width/4, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_yellow, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - curY = curY + charHeight; - - //Low SRW Sfc - float blyr = nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(0)); - float tlyr = pcl.lfcpres; - if(tlyr > 0){ - nsharpNative.nsharpLib.sr_wind( blyr, tlyr, wdir.getValue(), wspd.getValue(), fvalue,fvalue1,fvalue2,fvalue3); - if(nsharpNative.nsharpLib.qc(fvalue3.getValue())==1) { - textStr = NsharpNativeConstants.SEVERE_LOWSRWSFC_LINE; - textStr = String.format(textStr,fvalue3.getValue()); - } - else { - textStr = NsharpNativeConstants.SEVERE_LOWSRWSFC_MISSING; - } - } - else { - textStr = NsharpNativeConstants.SEVERE_LOWSRWSFC_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - - blyr = pcl.lfcpres; - tlyr = nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.ihght(pcl.lfcpres) + 4000); - if((tlyr > 0)&&(blyr > 0)) { - nsharpNative.nsharpLib.sr_wind( blyr, tlyr, wdir.getValue(), wspd.getValue(), fvalue,fvalue1,fvalue2,fvalue3); - if(nsharpNative.nsharpLib.qc(fvalue3.getValue())==1) { - textStr = NsharpNativeConstants.SEVERE_MIDSRW_LINE; - textStr = String.format(textStr,fvalue3.getValue()); - } - else { - textStr = NsharpNativeConstants.SEVERE_MIDSRW_MISSING; - } - + fValue.setValue(0); + nsharpNative.nsharpLib.precip_water(fValue, -1.0F, -1.0F); + if (nsharpNative.nsharpLib.qc(fValue.getValue()) == 1) { + textStr = NsharpNativeConstants.THERMO_PWATER_LINE; + textStr = String.format(textStr, fValue.getValue()); + } else { + textStr = NsharpNativeConstants.THERMO_PWATER_MISSING; } - else { - textStr = NsharpNativeConstants.SEVERE_MIDSRW_MISSING; - } - splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, + target.drawString(myfont, textStr, rect.x, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); - } - curY = curY + charHeight; - - blyr = nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.ihght(pcl.elpres) - 4000); + + fValue.setValue(0); + nsharpNative.nsharpLib.mean_relhum(fValue, -1.0F, -1.0F); + if (nsharpNative.nsharpLib.qc(fValue.getValue()) == 1) { + textStr = NsharpNativeConstants.THERMO_MEANRH_LINE; + textStr = String.format(textStr, fValue.getValue(), + NsharpConstants.PERCENT_SYMBOL); + } else { + textStr = NsharpNativeConstants.THERMO_MEANRH_MISSING; + } + target.drawString(myfont, textStr, rect.x + rect.width / 2, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + curY = curY + charHeight; + + fValue.setValue(0); + nsharpNative.nsharpLib.mean_mixratio(fValue, -1.0F, -1.0F); + if (nsharpNative.nsharpLib.qc(fValue.getValue()) == 1) { + textStr = NsharpNativeConstants.THERMO_MEANW_LINE; + textStr = String.format(textStr, fValue.getValue()); + } else { + textStr = NsharpNativeConstants.THERMO_MEANW_MISSING; + } + target.drawString(myfont, textStr, rect.x, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + fValue.setValue(0); + fValue1.setValue(0); + // get surface pressure (fValue1) before getting mean LRH value + nsharpNative.nsharpLib.get_surface(fValue1, fValue2, fValue3); // fValue + // 2 and + // fValue3 + // are + // not of + // concern + // here + nsharpNative.nsharpLib.mean_relhum(fValue, -1.0F, + fValue1.getValue() - 150); + if (nsharpNative.nsharpLib.qc(fValue.getValue()) == 1) { + textStr = NsharpNativeConstants.THERMO_MEANLRH_LINE; + textStr = String.format(textStr, fValue.getValue(), + NsharpConstants.PERCENT_SYMBOL); + } else { + textStr = NsharpNativeConstants.THERMO_MEANLRH_MISSING; + } + target.drawString(myfont, textStr, rect.x + rect.width / 2, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + curY = curY + charHeight; + + fValue.setValue(0); + nsharpNative.nsharpLib.top_moistlyr(fValue); + if (nsharpNative.nsharpLib.qc(fValue.getValue()) == 1) { + textStr = NsharpNativeConstants.THERMO_TOP_LINE; + textStr = String + .format(textStr, fValue.getValue(), nsharpNative.nsharpLib + .mtof(nsharpNative.nsharpLib + .agl(nsharpNative.nsharpLib.ihght(fValue + .getValue())))); + } else { + textStr = NsharpNativeConstants.THERMO_TOP_MISSING; + } + target.drawString(myfont, textStr, rect.x, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + + // instability data--------------// + // yellow and bold for parcel header + target.drawString(myfont, NsharpNativeConstants.THERMO_INSTABILITY_STR, + rect.x + rect.width / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_yellow, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + + curY = curY + charHeight; + + fValue.setValue(0); + fValue1.setValue(0); + + nsharpNative.nsharpLib.delta_t(fValue); + nsharpNative.nsharpLib.lapse_rate(fValue1, 700.0F, 500.0F); + + if (nsharpNative.nsharpLib.qc(fValue.getValue()) == 1 + && nsharpNative.nsharpLib.qc(fValue1.getValue()) == 1) { + textStr = NsharpNativeConstants.THERMO_700500mb_LINE; + textStr = String.format(textStr, fValue.getValue(), + fValue1.getValue()); + } else { + textStr = NsharpNativeConstants.THERMO_700500mb_MISSING; + } + target.drawString(myfont, textStr, rect.x, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + + fValue.setValue(0); + fValue1.setValue(0); + + nsharpNative.nsharpLib.vert_tot(fValue); + nsharpNative.nsharpLib.lapse_rate(fValue1, 850.0F, 500.0F); + + if (nsharpNative.nsharpLib.qc(fValue.getValue()) == 1 + && nsharpNative.nsharpLib.qc(fValue1.getValue()) == 1) { + textStr = NsharpNativeConstants.THERMO_850500mb_LINE; + textStr = String.format(textStr, fValue.getValue(), + fValue1.getValue()); + } else { + textStr = NsharpNativeConstants.THERMO_850500mb_MISSING; + } + target.drawString(myfont, textStr, rect.x, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + + // misc parameters data--------------// + target.drawString(myfont, NsharpNativeConstants.THERMO_MISC_PARMS_STR, + rect.x + rect.width / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_yellow, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + + fValue.setValue(0); + fValue1.setValue(0); + fValue2.setValue(0); + nsharpNative.nsharpLib.t_totals(fValue, fValue1, fValue2); + if (nsharpNative.nsharpLib.qc(fValue.getValue()) == 1) { + textStr = NsharpNativeConstants.THERMO_TOTAL_LINE; + textStr = String.format(textStr, fValue.getValue()); + } else { + textStr = NsharpNativeConstants.THERMO_TOTAL_MISSING; + } + target.drawString(myfont, textStr, rect.x, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + + fValue.setValue(0); + nsharpNative.nsharpLib.k_index(fValue); + if (nsharpNative.nsharpLib.qc(fValue.getValue()) == 1) { + textStr = NsharpNativeConstants.THERMO_KINDEX_LINE; + textStr = String.format(textStr, fValue.getValue()); + } else { + textStr = NsharpNativeConstants.THERMO_KINDEX_MISSING; + } + target.drawString(myfont, textStr, rect.x + rect.width / 2, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + curY = curY + charHeight; + + fValue.setValue(0); + nsharpNative.nsharpLib.sweat_index(fValue); + if (nsharpNative.nsharpLib.qc(fValue.getValue()) == 1) { + textStr = NsharpNativeConstants.THERMO_SWEAT_LINE; + textStr = String.format(textStr, fValue.getValue()); + } else { + textStr = NsharpNativeConstants.THERMO_SWEAT_MISSING; + } + + target.drawString(myfont, textStr, rect.x, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + + fValue.setValue(0); + float maxTempF = nsharpNative.nsharpLib.ctof(nsharpNative.nsharpLib + .max_temp(fValue, -1)); + if (nsharpNative.nsharpLib.qc(maxTempF) == 1) { + textStr = NsharpNativeConstants.THERMO_MAXT_LINE; + textStr = String.format(textStr, maxTempF); + } else { + textStr = NsharpNativeConstants.THERMO_MAXT_MISSING; + } + target.drawString(myfont, textStr, rect.x + rect.width / 2, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + curY = curY + charHeight; + + fValue.setValue(0); + float theDiff = nsharpNative.nsharpLib.ThetaE_diff(fValue); + if (nsharpNative.nsharpLib.qc(theDiff) == 1) { + textStr = NsharpNativeConstants.THERMO_THETAE_LINE; + textStr = String.format(textStr, theDiff); + } else { + textStr = NsharpNativeConstants.THERMO_THETAE_MISSING; + } + target.drawString(myfont, textStr, rect.x, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + fValue.setValue(0); + float conTempF = nsharpNative.nsharpLib.ctof(nsharpNative.nsharpLib + .cnvtv_temp(fValue, -1)); + if (nsharpNative.nsharpLib.qc(conTempF) == 1) { + textStr = NsharpNativeConstants.THERMO_CONVT_LINE; + textStr = String.format(textStr, conTempF); + } else { + textStr = NsharpNativeConstants.THERMO_CONVT_MISSING; + } + target.drawString(myfont, textStr, rect.x + rect.width / 2, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + curY = curY + charHeight; + + fValue.setValue(0); + float wbzft = nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib + .agl(nsharpNative.nsharpLib.ihght(nsharpNative.nsharpLib + .wb_lvl(0, fValue)))); + if (nsharpNative.nsharpLib.qc(wbzft) == 1) { + textStr = NsharpNativeConstants.THERMO_WBZ_LINE; + textStr = String.format(textStr, wbzft); + } else { + textStr = NsharpNativeConstants.THERMO_WBZ_MISSING; + } + target.drawString(myfont, textStr, rect.x, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + fValue.setValue(0); + float fgzft = nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib + .agl(nsharpNative.nsharpLib.ihght(nsharpNative.nsharpLib + .temp_lvl(0, fValue)))); + if (nsharpNative.nsharpLib.qc(fgzft) == 1) { + textStr = NsharpNativeConstants.THERMO_FGZ_LINE; + textStr = String.format(textStr, fgzft); + } else { + textStr = NsharpNativeConstants.THERMO_FGZ_MISSING; + } + target.drawString(myfont, textStr, rect.x + rect.width / 2, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + // myfont.dispose(); + } + + @SuppressWarnings("deprecation") + private void drawPanel5(IGraphicsTarget target, Rectangle rect) + throws VizException { + IFont myfont; + myfont = defaultFont; + defineCharHeight(myfont); + myfont.setSmoothing(false); + myfont.setScaleFont(false); + extent = new PixelExtent(rect); + target.setupClippingPlane(extent); + // myfont = target.initializeFont(fontName, fontSize, null); + String splitedStr[]; + String textStr; + curY = rect.y; + + /* + * Chin's NOTE::::this function is coded based on legacy nsharp software + * show_gradient() in xwvid3.c + */ + FloatByReference Surfpressure = new FloatByReference(0); + FloatByReference surfTemp = new FloatByReference(0); + FloatByReference surfDewpt = new FloatByReference(0); + target.drawString(myfont, NsharpNativeConstants.OPC_LOW_LEVEL_STR, + rect.x + rect.width / 3, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_cyan, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + target.drawString(myfont, NsharpNativeConstants.OPC_SURFACE975_STR, + rect.x + rect.width / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_yellow, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + + textStr = NsharpNativeConstants.OPC_LEVEL_LINE_; + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + target.drawLine(rect.x, curY, 0.0, rect.x + rect.width, curY, 0.0, + NsharpConstants.color_white, 1); + + float ht = nsharpNative.nsharpLib.ihght(975); + if (ht == NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA) + textStr = NsharpNativeConstants.OPC_975_LINE_MISSING_; + else { + textStr = NsharpNativeConstants.OPC_975_LINE_; + textStr = String.format(textStr, nsharpNative.nsharpLib.ihght(975), + nsharpNative.nsharpLib.itemp(975)); + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + ht = 0; + // get surface pressure (fValue1), Surface_temp (fValue2) + nsharpNative.nsharpLib.get_surface(Surfpressure, surfTemp, surfDewpt); + if (nsharpNative.nsharpLib.qc(Surfpressure.getValue()) == 1) + ht = nsharpNative.nsharpLib.ihght(Surfpressure.getValue()); + if (nsharpNative.nsharpLib.qc(Surfpressure.getValue()) == 1 + && nsharpNative.nsharpLib.qc(surfTemp.getValue()) == 1) { + textStr = NsharpNativeConstants.OPC_SURFACE_LINE_; + textStr = String.format(textStr, Surfpressure.getValue(), ht, + surfTemp.getValue()); + } else { + textStr = NsharpNativeConstants.OPC_SURFACE_MISSING_; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + /* ----- Sfc-975 Grad ----- */ + /* + * make sure both 975mb layer and surface layer temperatures are + * available + */ + if (nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib.itemp(975)) == 1 + && nsharpNative.nsharpLib.qc(surfTemp.getValue()) == 1) { + textStr = NsharpNativeConstants.OPC_975_SURFACE_LINE; + textStr = String.format(textStr, nsharpNative.nsharpLib.itemp(975) + - surfTemp.getValue()); + } else { + textStr = NsharpNativeConstants.OPC_975_SURFACE_MISSING; + } + target.drawString(myfont, textStr, rect.x, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + /* + * Chin's NOTE::::this function is coded based on legacy nsharp software + * show_inversion() in xwvid3.c + * + * inv_mb - Pressure of inversion level (mb) inv_dC - Change in + * temperature (C) + */ + FloatByReference inv_mb = new FloatByReference(0); + FloatByReference inv_dC = new FloatByReference(0); + ; + // yellow and bold for parcel header + target.drawString(myfont, NsharpNativeConstants.OPC_LOWEST_INV_STR, + rect.x + rect.width / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_yellow, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + 2 * charHeight; + nsharpNative.nsharpLib.low_inv(inv_mb, inv_dC); + if (nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib.ihght(inv_mb + .getValue())) == 1) { + textStr = NsharpNativeConstants.OPC_BASEHEIGHT_LINE; + textStr = String.format(textStr, + nsharpNative.nsharpLib.ihght(inv_mb.getValue())); + } else { + textStr = NsharpNativeConstants.OPC_BASEHEIGHT_MISSING; + } + target.drawString(myfont, textStr, rect.x, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + + if (nsharpNative.nsharpLib.qc(inv_mb.getValue()) == 1) { + textStr = NsharpNativeConstants.OPC_BASEPRESSURE_LINE; + textStr = String.format(textStr, inv_mb.getValue()); + } else { + textStr = NsharpNativeConstants.OPC_BASEPRESSURE_MISSING; + } + target.drawString(myfont, textStr, rect.x, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + + if (nsharpNative.nsharpLib.qc(inv_dC.getValue()) == 1) { + textStr = NsharpNativeConstants.OPC_CHANGE_IN_TEMP_LINE; + textStr = String.format(textStr, inv_dC.getValue()); + } else { + textStr = NsharpNativeConstants.OPC_CHANGE_IN_TEMP_MISSING; + } + target.drawString(myfont, textStr, rect.x, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + + // myfont.dispose(); + } + + @SuppressWarnings("deprecation") + private void drawPanel6(IGraphicsTarget target, Rectangle rect) + throws VizException { + IFont myfont; + myfont = defaultFont; + defineCharHeight(myfont); + myfont.setSmoothing(false); + myfont.setScaleFont(false); + extent = new PixelExtent(rect); + target.setupClippingPlane(extent); + // myfont = target.initializeFont(fontName, fontSize, null); + String splitedStr[]; + String textStr; + curY = rect.y; + + /* + * Chin's NOTE::::this function is coded based on legacy nsharp software + * show_mixheight() in xwvid3.c Calculates the mixing height using + * legacy mix_height() + * + * void mix_height ( float *mh_mb, float *mh_drct, float *mh_sped, float + * *mh_dC, float *mh_lr, float *mh_drct_max, float *mh_sped_max, short + * flag ) + * + * Where: flag = 0 Surface-based lapse rate flag = 1 Layer-based lapse + * rate + * + * mh_mb - Pressure at mixing height (mb) mh_drct - Wind direction at + * mixing height (deg) mh_sped - Wind speed at mixing height (kt) mh_dC + * - Layer change in temperature (C) mh_lr - Layer lapse rate (C/km) + * mh_drct_max - Layer maximum wind direction (deg) mh_sped_max - Layer + * maximum wind speed (kt) + */ + FloatByReference mh_mb = new FloatByReference(0); + FloatByReference mh_drct = new FloatByReference(0); + FloatByReference mh_sped = new FloatByReference(0); + FloatByReference mh_dC = new FloatByReference(0); + FloatByReference mh_lr = new FloatByReference(0); + FloatByReference mh_drct_max = new FloatByReference(0); + FloatByReference mh_sped_max = new FloatByReference(0); + short flag; + + // yellow and bold for parcel header + target.drawString(myfont, NsharpNativeConstants.OPC_MIXING_HGT_STR, + rect.x + rect.width / 10, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_yellow, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + textStr = NsharpNativeConstants.OPC_DRY_AD_LINE; + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 2, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + textStr = NsharpNativeConstants.OPC_THRESH_LAPSE_LINE; + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 2, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + // Cyan color for Layer Based string + target.drawString(myfont, NsharpNativeConstants.OPC_LAYER_BASED_STR, + rect.x + rect.width / 3, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_cyan, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + // calculate Layer-based lapse rate data + flag = 1; + nsharpNative.nsharpLib.mix_height(mh_mb, mh_drct, mh_sped, mh_dC, + mh_lr, mh_drct_max, mh_sped_max, flag); + + if (nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib.ihght(mh_mb + .getValue())) == 1) { + textStr = NsharpNativeConstants.OPC_MIXINGHEIGHT_LINE; + textStr = String.format(textStr, + nsharpNative.nsharpLib.ihght(mh_mb.getValue())); + } else { + textStr = NsharpNativeConstants.OPC_MIXINGHEIGHT_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 2, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + if (nsharpNative.nsharpLib.qc(mh_mb.getValue()) == 1) { + textStr = NsharpNativeConstants.OPC_MIXINGPRESSURE_LINE; + textStr = String.format(textStr, mh_mb.getValue()); + } else { + textStr = NsharpNativeConstants.OPC_MIXINGPRESSURE_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 2, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + if (nsharpNative.nsharpLib.qc(mh_drct.getValue()) == 1 + && nsharpNative.nsharpLib.qc(mh_sped.getValue()) == 1) { + textStr = NsharpNativeConstants.OPC_TOPMIXLAYER_LINE; + // System.out.println("speed = " + mh_sped.getValue()); + textStr = String.format(textStr, (int) mh_drct.getValue(), + NsharpConstants.DEGREE_SYMBOL, (int) (mh_sped.getValue())); + } else { + textStr = NsharpNativeConstants.OPC_TOPMIXLAYER_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 2, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + if (nsharpNative.nsharpLib.qc(mh_drct_max.getValue()) == 1 + && nsharpNative.nsharpLib.qc(mh_sped_max.getValue()) == 1) { + textStr = NsharpNativeConstants.OPC_MIXLAYERMAX_LINE; + textStr = String + .format(textStr, (int) mh_drct_max.getValue(), + NsharpConstants.DEGREE_SYMBOL, + (int) mh_sped_max.getValue()); + } else { + textStr = NsharpNativeConstants.OPC_MIXLAYERMAX_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 2, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + if (nsharpNative.nsharpLib.qc(mh_dC.getValue()) == 1 + && nsharpNative.nsharpLib.qc(mh_lr.getValue()) == 1) { + textStr = NsharpNativeConstants.OPC_LAYER_LAPSE_LINE; + textStr = String + .format(textStr, mh_dC.getValue(), mh_lr.getValue()); + } else { + textStr = NsharpNativeConstants.OPC_LAYER_LAPSE_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 2, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + // Purple color for Layer Based string + target.drawString(myfont, NsharpNativeConstants.OPC_SURFACE_BASED_STR, + rect.x + rect.width / 3, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_violet, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + // calculate Surface-based lapse rate data + flag = 0; + mh_mb.setValue(0); + mh_drct.setValue(0); + mh_sped.setValue(0); + mh_dC.setValue(0); + mh_lr.setValue(0); + mh_drct_max.setValue(0); + mh_sped_max.setValue(0); + ; + nsharpNative.nsharpLib.mix_height(mh_mb, mh_drct, mh_sped, mh_dC, + mh_lr, mh_drct_max, mh_sped_max, flag); + + // white color for text + if (nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib.ihght(mh_mb + .getValue())) == 1) { + textStr = NsharpNativeConstants.OPC_MIXINGHEIGHT_LINE; + textStr = String.format(textStr, + nsharpNative.nsharpLib.ihght(mh_mb.getValue())); + } else { + textStr = NsharpNativeConstants.OPC_MIXINGHEIGHT_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 2, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + if (nsharpNative.nsharpLib.qc(mh_mb.getValue()) == 1) { + textStr = NsharpNativeConstants.OPC_MIXINGPRESSURE_LINE; + textStr = String.format(textStr, mh_mb.getValue()); + } else { + textStr = NsharpNativeConstants.OPC_MIXINGPRESSURE_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 2, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + if (nsharpNative.nsharpLib.qc(mh_drct.getValue()) == 1 + && nsharpNative.nsharpLib.qc(mh_sped.getValue()) == 1) { + textStr = NsharpNativeConstants.OPC_TOPMIXLAYER_LINE; + textStr = String.format(textStr, (int) mh_drct.getValue(), + NsharpConstants.DEGREE_SYMBOL, (int) mh_sped.getValue()); + } else { + textStr = NsharpNativeConstants.OPC_TOPMIXLAYER_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 2, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + if (nsharpNative.nsharpLib.qc(mh_drct_max.getValue()) == 1 + && nsharpNative.nsharpLib.qc(mh_sped_max.getValue()) == 1) { + textStr = NsharpNativeConstants.OPC_MIXLAYERMAX_LINE; + textStr = String + .format(textStr, (int) mh_drct_max.getValue(), + NsharpConstants.DEGREE_SYMBOL, + (int) mh_sped_max.getValue()); + } else { + textStr = NsharpNativeConstants.OPC_MIXLAYERMAX_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 2, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + if (nsharpNative.nsharpLib.qc(mh_dC.getValue()) == 1 + && nsharpNative.nsharpLib.qc(mh_lr.getValue()) == 1) { + textStr = NsharpNativeConstants.OPC_LAYER_LAPSE_LINE; + textStr = String + .format(textStr, mh_dC.getValue(), mh_lr.getValue()); + } else { + textStr = NsharpNativeConstants.OPC_LAYER_LAPSE_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 2, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + // myfont.dispose(); + } + + @SuppressWarnings("deprecation") + private void drawPanel7(IGraphicsTarget target, Rectangle rect) + throws VizException { + IFont myfont; + myfont = defaultFont; + defineCharHeight(myfont); + myfont.setSmoothing(false); + myfont.setScaleFont(false); + extent = new PixelExtent(rect); + target.setupClippingPlane(extent); + // myfont = target.initializeFont(fontName, fontSize, null); + String splitedStr[]; + String textStr; + curY = rect.y; + /* + * Chin's NOTE::::this function is coded based on legacy nsharp software + * show_srdata() in xwvid3.c. Hard coded numerical numbers are directly + * copied from it. + * + * float helicity ( float lower, float upper, float sdir, float sspd, + * float *phel, float *nhel ) Calculates the storm-relative helicity + * (m2/s2) of a layer from LOWER(m, agl) to UPPER(m, agl). Uses the + * storm motion vector (sdir, sspd). + * + * lower - Bottom level of layer (m, AGL)[-1=LPL] upper - Top level of + * layer (m, AGL) [-1=LFC] sdir - Storm motion direction (degrees) sspd + * - Storm motion speed (kt) phel - Positive helicity in layer (m2/s2) + * nhel - Negative helicity in layer (m2/s2) RETURN VALUE - Total + * helicity (m2/s2) + * + * void sr_wind ( float pbot, float ptop, float sdir, float sspd, float + * *mnu, float *mnv, float *wdir, float *wspd ) Calculates a + * pressure-weighted SR mean wind thru the layer (pbot-ptop). Default + * layer is LFC-EL. pbot - Bottom level of layer (mb) ptop - Top level + * of layer (mb) sdir - Storm motion dirction (deg) sspd - Storm motion + * speed (kt) mnu - U-Component of mean wind (kt) mnv - V-Component of + * mean wind (kt) / + */ + + // FloatByReference sspd= new FloatByReference(0); + // FloatByReference sdir= new FloatByReference(0); + FloatByReference phel = new FloatByReference(0); + FloatByReference nhel = new FloatByReference(0); + FloatByReference mnu = new FloatByReference(0); + FloatByReference mnv = new FloatByReference(0); + FloatByReference smdir = new FloatByReference(0); + FloatByReference smspd = new FloatByReference(0); + FloatByReference wdir = new FloatByReference(0); + FloatByReference wspd = new FloatByReference(0); + float totHeli; + + target.drawString(myfont, NsharpNativeConstants.STORM_RELATIVE_STR, + rect.x + rect.width / 3, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_cyan, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + + nsharpNative.nsharpLib.get_storm(smspd, smdir); + + if (nsharpNative.nsharpLib.qc(smspd.getValue()) == 1 + && nsharpNative.nsharpLib.qc(smdir.getValue()) == 1) { + textStr = NsharpNativeConstants.STORM_MOTION_LINE; + textStr = String.format(textStr, smdir.getValue(), + NsharpConstants.DEGREE_SYMBOL, smspd.getValue(), + nsharpNative.nsharpLib.kt_to_mps(smspd.getValue())); + } else { + textStr = NsharpNativeConstants.STORM_MOTION_MISSING; + } + target.drawString(myfont, textStr, rect.x + rect.width / 4, curY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + curY = curY + charHeight; + + // yellow and bold for parcel header + target.drawString(myfont, NsharpNativeConstants.STORM_HELICITY_STR, + rect.x + rect.width / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_yellow, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + textStr = NsharpNativeConstants.STORM_LAYER_POS_STR; + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + target.drawLine(rect.x, curY, 0.0, rect.x + rect.width, curY, 0.0, + NsharpConstants.color_white, 1); + + // calculate helicity for sfc-2 km + totHeli = nsharpNative.nsharpLib.helicity((float) 0, (float) 2000, + smdir.getValue(), smspd.getValue(), phel, nhel); + if (nsharpNative.nsharpLib.qc(phel.getValue()) == 1 + && nsharpNative.nsharpLib.qc(nhel.getValue()) == 1) { + textStr = NsharpNativeConstants.STORM_SFC2KM_LINE; + textStr = String.format(textStr, phel.getValue(), nhel.getValue(), + totHeli, NsharpConstants.SQUARE_SYMBOL, + NsharpConstants.SQUARE_SYMBOL); + + } else { + textStr = NsharpNativeConstants.STORM_SFC2KM_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + // calculate helicity for sfc-3 km + totHeli = nsharpNative.nsharpLib.helicity((float) 0, (float) 3000, + smdir.getValue(), smspd.getValue(), phel, nhel); + if (nsharpNative.nsharpLib.qc(phel.getValue()) == 1 + && nsharpNative.nsharpLib.qc(nhel.getValue()) == 1) { + textStr = NsharpNativeConstants.STORM_SFC3KM_LINE; + textStr = String.format(textStr, phel.getValue(), nhel.getValue(), + totHeli, NsharpConstants.SQUARE_SYMBOL, + NsharpConstants.SQUARE_SYMBOL); + } else { + textStr = NsharpNativeConstants.STORM_SFC3KM_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + // calculate helicity for LPL - LFC + totHeli = nsharpNative.nsharpLib.helicity((float) -1, (float) -1, + smdir.getValue(), smspd.getValue(), phel, nhel); + if (nsharpNative.nsharpLib.qc(phel.getValue()) == 1 + && nsharpNative.nsharpLib.qc(nhel.getValue()) == 1) { + textStr = NsharpNativeConstants.STORM_LPL_LFC_LINE; + textStr = String.format(textStr, phel.getValue(), nhel.getValue(), + totHeli, NsharpConstants.SQUARE_SYMBOL, + NsharpConstants.SQUARE_SYMBOL); + } else { + textStr = NsharpNativeConstants.STORM_LPL_LFC_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + // yellow and bold for header + target.drawString(myfont, NsharpNativeConstants.STORM_WIND_STR, rect.x + + rect.width / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_yellow, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + 2 * charHeight; + textStr = NsharpNativeConstants.STORM_LAYER_VECTOR_STR; + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 2, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + target.drawLine(rect.x, curY, 0.0, rect.x + rect.width, curY, 0.0, + NsharpConstants.color_white, 1); + + // calculate pressure-weighted SR mean wind at sfc-2 km + nsharpNative.nsharpLib.sr_wind( + nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(0)), + nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(2000)), + smdir.getValue(), smspd.getValue(), mnu, mnv, wdir, wspd); + if (nsharpNative.nsharpLib.qc(wdir.getValue()) == 1) { + textStr = NsharpNativeConstants.STORM_SFC2KM_VECT_LINE; + textStr = String.format(textStr, wdir.getValue(), wspd.getValue(), + nsharpNative.nsharpLib.kt_to_mps(wspd.getValue())); + } else { + textStr = NsharpNativeConstants.STORM_SFC2KM_VECT_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 2, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + // calculate pressure-weighted SR mean wind at 4-6 km + // System.out.println("msl(4000))="+ nsharpNative.nsharpLib.msl(4000) + + // "i_pres(msl(4000))" + + // nsharpNative.nsharpLib.i_pres(nsharpNative.nsharpLib.msl(4000))); + // System.out.println("msl(6000))="+ nsharpNative.nsharpLib.msl(6000) + + // "i_pres(msl(6000))" + + // nsharpNative.nsharpLib.i_pres(nsharpNative.nsharpLib.msl(6000))); + // System.out.println("dir "+ smdir.getValue()+ " spd " + + // smspd.getValue()); + nsharpNative.nsharpLib.sr_wind( + nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(4000)), + nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(6000)), + smdir.getValue(), smspd.getValue(), mnu, mnv, wdir, wspd); + if (nsharpNative.nsharpLib.qc(wdir.getValue()) == 1) { + textStr = NsharpNativeConstants.STORM_4_6KM_VECT_LINE; + // System.out.println("wdir "+ wdir.getValue() + " widSp " + + // wspd.getValue()); + textStr = String.format(textStr, wdir.getValue(), wspd.getValue(), + nsharpNative.nsharpLib.kt_to_mps(wspd.getValue())); + } else { + textStr = NsharpNativeConstants.STORM_4_6KM_VECT_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 2, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + // calculate pressure-weighted SR mean wind at 9-11 km + nsharpNative.nsharpLib + .sr_wind(nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib + .msl(9000)), nsharpNative.nsharpLib + .ipres(nsharpNative.nsharpLib.msl(11000)), smdir + .getValue(), smspd.getValue(), mnu, mnv, wdir, wspd); + if (nsharpNative.nsharpLib.qc(wdir.getValue()) == 1) { + textStr = NsharpNativeConstants.STORM_9_11KM_VECT_LINE; + textStr = String.format(textStr, wdir.getValue(), wspd.getValue(), + nsharpNative.nsharpLib.kt_to_mps(wspd.getValue())); + } else { + textStr = NsharpNativeConstants.STORM_9_11KM_VECT_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 2, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + + // myfont.dispose(); + } + + @SuppressWarnings("deprecation") + private void drawPanel8(IGraphicsTarget target, Rectangle rect) + throws VizException { + IFont myfont; + myfont = defaultFont; + defineCharHeight(myfont); + myfont.setSmoothing(false); + myfont.setScaleFont(false); + extent = new PixelExtent(rect); + target.setupClippingPlane(extent); + // myfont = target.initializeFont(fontName, fontSize, null); + String splitedStr[]; + String textStr; + curY = rect.y; + /* + * Chin's NOTE::::this function is coded based on legacy nsharp software + * show_meanwind() in xwvid3.c + * + * void mean_wind ( float pbot, float ptop, float *mnu, float *mnv, + * float *wdir, float *wspd ) Calculates a pressure-weighted mean wind + * thru the layer (pbot-ptop). Default layer is LFC-EL. + * + * pbot - Bottom level of layer (mb) ptop - Top level of layer (mb) mnu + * - U-Component of mean wind (kt) mnv - V-Component of mean wind (kt) + */ + FloatByReference mnu = new FloatByReference(0); + FloatByReference mnv = new FloatByReference(0); + FloatByReference wdir = new FloatByReference(0); + FloatByReference wspd = new FloatByReference(0); + target.drawString(myfont, NsharpNativeConstants.MEAN_WIND_STR, rect.x + + rect.width * 0.4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_cyan, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + + // fix TT 549890 + // Calculate mean wind at 0-6 km, following the same algorithm used in + // drawPanel2() at BigNsharp page 2. + // Like this : + // mean_wind(nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(h1)), + // nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(h2))) + nsharpNative.nsharpLib.mean_wind( + nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(0)), + nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(6000)), + mnu, mnv, wdir, wspd); + // this line was nsharpNative.nsharpLib.mean_wind( -1, + // nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.agl(6000)), mnu, + // mnv, wdir, wspd); + // System.out.println("wsp ="+ wspd.getValue()+ " wdir "+ + // wdir.getValue() + " agl(6000)="+nsharpNative.nsharpLib.agl(6000)+ + // " preAt6000="+nsharpNative.nsharpLib.i_pres(nsharpNative.nsharpLib.agl(6000))); + if (nsharpNative.nsharpLib.qc(wdir.getValue()) == 1 + && nsharpNative.nsharpLib.qc(wspd.getValue()) == 1) { + textStr = NsharpNativeConstants.MEANWIND_SFC6KM_LINE; + textStr = String.format(textStr, (wdir.getValue()), + wspd.getValue(), + nsharpNative.nsharpLib.kt_to_mps(wspd.getValue())); + } else { + textStr = NsharpNativeConstants.MEANWIND_SFC6KM_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 2, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + // fix TT 549890 + // Calculate mean wind at LFC-EL, following the same algorithm used in + // drawPanel2() for LCL_EL for BigNsharp pag + // Replacing LCL with LFC + _lplvalues lpvls; + _parcel pcl; + lpvls = new _lplvalues(); + pcl = new _parcel(); + float h1, h2; + h1 = -1; + h2 = -1; + nsharpNative.nsharpLib.get_lpvaluesData(lpvls); + + float sfctemp = lpvls.temp; + float sfcdwpt = lpvls.dwpt; + float sfcpres = lpvls.pres; + nsharpNative.nsharpLib.parcel(-1.0F, -1.0F, sfcpres, sfctemp, sfcdwpt, + pcl); + if (pcl.bplus > 0) { + h1 = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(pcl.lfcpres)); + h2 = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(pcl.elpres)); + } + + // Calculate mean wind at LFC-EL + nsharpNative.nsharpLib.mean_wind( + nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(h1)), + nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(h2)), + mnu, mnv, wdir, wspd); + if (nsharpNative.nsharpLib.qc(wdir.getValue()) == 1 + && nsharpNative.nsharpLib.qc(wspd.getValue()) == 1) { + textStr = NsharpNativeConstants.MEANWIND_LFC_EL_LINE; + textStr = String.format(textStr, wdir.getValue(), wspd.getValue(), + nsharpNative.nsharpLib.kt_to_mps(wspd.getValue())); + } else { + textStr = NsharpNativeConstants.MEANWIND_LFC_EL_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 2, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + // Calculate mean wind at 850-200 mb + nsharpNative.nsharpLib.mean_wind(850, 200, mnu, mnv, wdir, wspd); + if (nsharpNative.nsharpLib.qc(wdir.getValue()) == 1 + && nsharpNative.nsharpLib.qc(wspd.getValue()) == 1) { + textStr = NsharpNativeConstants.MEANWIND_850_200MB_LINE; + textStr = String.format(textStr, wdir.getValue(), wspd.getValue(), + nsharpNative.nsharpLib.kt_to_mps(wspd.getValue())); + } else { + textStr = NsharpNativeConstants.MEANWIND_850_200MB_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 2, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + /* + * Chin's NOTE::::this function is coded based on legacy nsharp software + * show_shear() in xwvid3.c + * + * void wind_shear ( float pbot, float ptop, float *shu, float *shv, + * float *sdir, float *smag ) + * + * Calculates the shear between the wind at (pbot) and (ptop). Default + * lower wind is a 1km mean wind, while the default upper layer is 3km. + * + * pbot - Bottom level of layer (mb) ptop - Top level of layer (mb) shu + * - U-Component of shear (m/s) shv - V-Component of shear (m/s) sdir - + * Direction of shear vector (degrees) smag - Magnitude of shear vector + * (m/s) + */ + FloatByReference shu = new FloatByReference(0); + FloatByReference shv = new FloatByReference(0); + FloatByReference sdir = new FloatByReference(0); + FloatByReference smag = new FloatByReference(0); + target.drawString(myfont, + NsharpNativeConstants.ENVIRONMENTAL_SHEAR_STR, rect.x + + rect.width / 3, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_cyan, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + + textStr = NsharpNativeConstants.SHEAR_LAYER_DELTA_STR; + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 3, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + target.drawLine(rect.x, curY, 0.0, rect.x + rect.width, curY, 0.0, + NsharpConstants.color_white, 1); + + // Calculate wind shear at Low - 3 km + nsharpNative.nsharpLib.wind_shear( + nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(0)), + nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(3000)), + shu, shv, sdir, smag); + if (nsharpNative.nsharpLib.qc(smag.getValue()) == 1) { + textStr = NsharpNativeConstants.SHEAR_LOW_3KM_LINE; + textStr = String.format(textStr, smag.getValue(), + nsharpNative.nsharpLib.kt_to_mps(smag.getValue()), + nsharpNative.nsharpLib.kt_to_mps(smag.getValue()) / .3F); + // System.out.println("from cave "+smag.getValue() + " kt, " + + // nsharpNative.nsharpLib.kt_to_mps(smag.getValue())+ " m/s, Tot="+ + // nsharpNative.nsharpLib.kt_to_mps(smag.getValue())/.3F); + } else { + textStr = NsharpNativeConstants.SHEAR_LOW_3KM_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 3, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + // Calculate wind shear at Sfc - 2 km + nsharpNative.nsharpLib.wind_shear( + nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(0)), + nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(2000)), + shu, shv, sdir, smag); + if (nsharpNative.nsharpLib.qc(smag.getValue()) == 1) { + textStr = NsharpNativeConstants.SHEAR_SFC_2KM_LINE; + textStr = String.format(textStr, smag.getValue(), + nsharpNative.nsharpLib.kt_to_mps(smag.getValue()), + nsharpNative.nsharpLib.kt_to_mps(smag.getValue()) / .2F); + } else { + textStr = NsharpNativeConstants.SHEAR_SFC_2KM_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 3, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + // Calculate wind shear at Sfc - 6 km + nsharpNative.nsharpLib.wind_shear( + nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(0)), + nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib.msl(6000)), + shu, shv, sdir, smag); + if (nsharpNative.nsharpLib.qc(smag.getValue()) == 1) { + textStr = NsharpNativeConstants.SHEAR_SFC_6KM_LINE; + textStr = String.format(textStr, smag.getValue(), + nsharpNative.nsharpLib.kt_to_mps(smag.getValue()), + nsharpNative.nsharpLib.kt_to_mps(smag.getValue()) / .6F); + } else { + textStr = NsharpNativeConstants.SHEAR_SFC_6KM_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 3, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + // Calculate wind shear at Sfc - 12 km + nsharpNative.nsharpLib + .wind_shear(nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib + .msl(0)), nsharpNative.nsharpLib + .ipres(nsharpNative.nsharpLib.msl(12000)), shu, shv, + sdir, smag); + if (nsharpNative.nsharpLib.qc(smag.getValue()) == 1) { + textStr = NsharpNativeConstants.SHEAR_SFC_12KM_LINE; + textStr = String.format(textStr, smag.getValue(), + nsharpNative.nsharpLib.kt_to_mps(smag.getValue()), + nsharpNative.nsharpLib.kt_to_mps(smag.getValue()) / 1.2F); + } else { + textStr = NsharpNativeConstants.SHEAR_SFC_12KM_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 3, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + // myfont.dispose(); + } + + @SuppressWarnings("deprecation") + private void drawPanel9(IGraphicsTarget target, Rectangle rect) + throws VizException { + IFont myfont; + if (paneConfigurationName.equals(NsharpConstants.PANE_LITE_D2D_CFG_STR)) { + myfont = font11; + } else { + myfont = defaultFont; + } + defineCharHeight(myfont); + myfont.setSmoothing(false); + myfont.setScaleFont(false); + extent = new PixelExtent(rect); + target.setupClippingPlane(extent); + // myfont = target.initializeFont(fontName, fontSize, null); + String splitedStr[]; + String textStr; + curY = rect.y; + /* + * Chin's NOTE::::this function is coded based on legacy nsharp software + * show_initiation(): Displays thunderstorm initiation parameters, + * show_heavypcpn(), show_preciptype() and show_stormtype() in xwvid3.c + */ + FloatByReference fvalue2 = new FloatByReference(0); + FloatByReference fvalue3 = new FloatByReference(0); + FloatByReference wdir = new FloatByReference(0); + FloatByReference wspd = new FloatByReference(0); + FloatByReference fvalue = new FloatByReference(0); + FloatByReference fvalue1 = new FloatByReference(0); + // get parcel data by calling native nsharp parcel() API. value is + // returned in pcl + // current parcel is already decided when page 1 is displyed. Note that + // page 1 is always + // displayed before this page (page 4). Therefore, we dont have to call + // define_parcel() again. + // set default + // short currentParcel; + float layerPressure; + if (currentParcel == NsharpNativeConstants.PARCELTYPE_USER_DEFINED) { + layerPressure = NsharpParcelDialog.getUserDefdParcelMb(); + } else + layerPressure = NsharpNativeConstants.parcelToLayerMap + .get(currentParcel); + nsharpNative.nsharpLib.define_parcel(currentParcel, layerPressure); + + _parcel pcl = new _parcel(); + ; + _lplvalues lpvls = new _lplvalues(); + nsharpNative.nsharpLib.get_lpvaluesData(lpvls); + float sfctemp, sfcdwpt, sfcpres; + sfctemp = lpvls.temp; + sfcdwpt = lpvls.dwpt; + sfcpres = lpvls.pres; + nsharpNative.nsharpLib.parcel(-1.0F, -1.0F, sfcpres, sfctemp, sfcdwpt, + pcl); + // _parcel.ByValue pcl_byvalue = new _parcel.ByValue(); + // nsharpNative.nsharpLib.parcel( -1.0F, -1.0F, sfcpres, sfctemp, + // sfcdwpt, pcl_byvalue); + + // CONVECTIVE_INITIATION + target.drawString(myfont, + NsharpNativeConstants.CONVECTIVE_INITIATION_STR, rect.x + + rect.width / 3, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_cyan, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + // CINH + if (nsharpNative.nsharpLib.qc(pcl.bminus) == 1) { + textStr = NsharpNativeConstants.CONVECTIVE_CINH_LINE; + textStr = String.format(textStr, pcl.bminus); + } else { + textStr = NsharpNativeConstants.CONVECTIVE_CINH_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + + // cap + if (nsharpNative.nsharpLib.qc(pcl.cap) == 1 + && nsharpNative.nsharpLib.qc(pcl.cappres) == 1) { + textStr = NsharpNativeConstants.CONVECTIVE_CAP_LINE; + textStr = String.format(textStr, pcl.cap, pcl.cappres); + } else { + textStr = NsharpNativeConstants.CONVECTIVE_CAP_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + rect.width / 2 + + i * rect.width / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + // K-index + nsharpNative.nsharpLib.k_index(fvalue); + if (nsharpNative.nsharpLib.qc(fvalue.getValue()) == 1) { + textStr = NsharpNativeConstants.CONVECTIVE_KINDEX_LINE; + textStr = String.format(textStr, fvalue.getValue()); + } else { + textStr = NsharpNativeConstants.CONVECTIVE_KINDEX_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + + // Mean RH + nsharpNative.nsharpLib.mean_relhum(fvalue, -1, -1); + if (nsharpNative.nsharpLib.qc(fvalue.getValue()) == 1) { + textStr = NsharpNativeConstants.CONVECTIVE_MEANRH_LINE; + textStr = String.format(textStr, fvalue.getValue(), + NsharpConstants.PERCENT_SYMBOL); + } else { + textStr = NsharpNativeConstants.CONVECTIVE_MEANRH_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + rect.width / 2 + + i * rect.width / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + 2 * charHeight; + + // Top of M layer + nsharpNative.nsharpLib.top_moistlyr(fvalue); + // System.out.println("top_moistlyr=" + fvalue.getValue() ); + + if (nsharpNative.nsharpLib.qc(fvalue.getValue()) == 1) { + float ht = nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib + .agl(nsharpNative.nsharpLib.ihght(fvalue.getValue()))); + if (nsharpNative.nsharpLib.qc(ht) == 1) { + textStr = NsharpNativeConstants.CONVECTIVE_TOP_LINE; + textStr = String.format(textStr, fvalue.getValue(), ht); + } else { + textStr = NsharpNativeConstants.CONVECTIVE_TOP_MISSING; + } + } else { + textStr = NsharpNativeConstants.CONVECTIVE_TOP_MISSING; + } + target.drawString(myfont, textStr, rect.x, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + // LFC height + if (nsharpNative.nsharpLib.qc(pcl.lfcpres) == 1) { + float ht = nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib + .agl(nsharpNative.nsharpLib.ihght(pcl.lfcpres))); + if (nsharpNative.nsharpLib.qc(ht) == 1) { + textStr = NsharpNativeConstants.CONVECTIVE_LFC_LINE; + textStr = String.format(textStr, pcl.lfcpres, ht); + } else { + textStr = NsharpNativeConstants.CONVECTIVE_LFC_MISSING; + } + } else { + textStr = NsharpNativeConstants.CONVECTIVE_LFC_MISSING; + } + target.drawString(myfont, textStr, rect.x, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + + // STORM TYPE + target.drawString(myfont, NsharpNativeConstants.STORM_TYPE_STR, rect.x + + rect.width / 3, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_cyan, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + + // CAPE + if (nsharpNative.nsharpLib.qc(pcl.bplus) == 1) { + textStr = NsharpNativeConstants.STORM_TYPE_CAPE_LINE; + textStr = String.format(textStr, pcl.bplus); + } else { + textStr = NsharpNativeConstants.STORM_TYPE_CAPE_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + + // EFF. SREH + float hel = 0; + nsharpNative.nsharpLib.get_storm(wspd, wdir); + if (nsharpNative.nsharpLib.qc(wdir.getValue()) == 1 + && nsharpNative.nsharpLib.qc(wspd.getValue()) == 1) { + hel = nsharpNative.nsharpLib.helicity(-1.0F, -1.0F, + wdir.getValue(), wspd.getValue(), fvalue, fvalue1); + if (nsharpNative.nsharpLib.qc(hel) == 1) { + textStr = NsharpNativeConstants.STORM_TYPE_EFF_LINE; + textStr = String.format(textStr, hel, + NsharpConstants.SQUARE_SYMBOL, + NsharpConstants.SQUARE_SYMBOL); + } else { + textStr = NsharpNativeConstants.STORM_TYPE_EFF_MISSING; + } + } else { + textStr = NsharpNativeConstants.STORM_TYPE_EFF_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + rect.width / 2 + + i * rect.width / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + // EHI + if (nsharpNative.nsharpLib.qc(pcl.bplus) == 1) { + float ehi = nsharpNative.nsharpLib.ehi(pcl.bplus, hel); + if (nsharpNative.nsharpLib.qc(ehi) == 1) { + textStr = NsharpNativeConstants.STORM_TYPE_EHI_LINE; + textStr = String.format(textStr, ehi); + } else { + textStr = NsharpNativeConstants.STORM_TYPE_EHI_MISSING; + } + } else { + textStr = NsharpNativeConstants.STORM_TYPE_EHI_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + + // 3km Shear + nsharpNative.nsharpLib.wind_shear(-1, -1, fvalue, fvalue1, fvalue2, + fvalue3); + if (nsharpNative.nsharpLib.qc(fvalue3.getValue()) == 1) { + textStr = NsharpNativeConstants.STORM_TYPE_3KM_LINE; + textStr = String.format(textStr, + nsharpNative.nsharpLib.kt_to_mps(fvalue3.getValue())); + } else { + textStr = NsharpNativeConstants.STORM_TYPE_3KM_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + rect.width / 2 + + i * rect.width / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + // BRN + if (nsharpNative.nsharpLib.qc(pcl.brn) == 1) { + textStr = NsharpNativeConstants.STORM_TYPE_BRN_LINE; + textStr = String.format(textStr, pcl.brn); + } else { + textStr = NsharpNativeConstants.STORM_TYPE_BRN_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + + // BRN Shear + // nsharpNative.nsharpLib.cave_bulk_rich(pcl.lplpres, pcl.bplus, fvalue + // ); + // System.out.println("bulk_rich fvalue = "+ fvalue.getValue()); + nsharpNative.nsharpLib.cave_bulk_rich2(fvalue); + if (nsharpNative.nsharpLib.qc(fvalue.getValue()) == 1) { + textStr = NsharpNativeConstants.STORM_TYPE_BRNSHEAR_LINE; + textStr = String.format(textStr, fvalue.getValue(), + NsharpConstants.SQUARE_SYMBOL, + NsharpConstants.SQUARE_SYMBOL); + } else + textStr = NsharpNativeConstants.STORM_TYPE_BRNSHEAR_MISSING; + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + rect.width / 2 + + i * rect.width / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + // PRECIPITATION_TYPE + target.drawString(myfont, NsharpNativeConstants.PRECIPITATION_TYPE_STR, + rect.x + rect.width / 3, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_cyan, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + + // Melting Level + float web = nsharpNative.nsharpLib.wb_lvl(0, fvalue); + if (nsharpNative.nsharpLib.qc(web) == 1) { + + float aglft = nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib + .agl(nsharpNative.nsharpLib.ihght(web))); + if (nsharpNative.nsharpLib.qc(aglft) == 1) { + textStr = NsharpNativeConstants.PRECIPITATION_MELTING_LINE; + textStr = String.format(textStr, aglft, web); + } else + textStr = NsharpNativeConstants.PRECIPITATION_MELTING_MISSING; + } else { + textStr = NsharpNativeConstants.PRECIPITATION_MELTING_MISSING; + } + target.drawString(myfont, textStr, rect.x, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + // HEAVY_RAINFAL + target.drawString(myfont, NsharpNativeConstants.HEAVY_RAINFALL_STR, + rect.x + rect.width / 3, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_cyan, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + + // Rogash_QPF, Chin: note: BigNsharp has different implementation of + // Rogash_QPF() + // We are using bigNsharp now. + nsharpNative.nsharpLib.Rogash_QPF(fvalue); + if (nsharpNative.nsharpLib.qc(fvalue.getValue()) == 1) { + textStr = NsharpNativeConstants.HEAVY_ROGASH_LINE; + textStr = String.format(textStr, fvalue.getValue()); + } else { + textStr = NsharpNativeConstants.HEAVY_ROGASH_MISSING; + } + target.drawString(myfont, textStr, rect.x, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + // myfont.dispose(); + } + + @SuppressWarnings("deprecation") + private void drawPanel10(IGraphicsTarget target, Rectangle rect) + throws VizException { + IFont myfont; + if (paneConfigurationName.equals(NsharpConstants.PANE_LITE_D2D_CFG_STR)) { + myfont = font11; + } else { + myfont = defaultFont; + } + defineCharHeight(myfont); + myfont.setSmoothing(false); + myfont.setScaleFont(false); + extent = new PixelExtent(rect); + target.setupClippingPlane(extent); + // myfont = target.initializeFont(fontName, fontSize, null); + String splitedStr[]; + String textStr; + curY = rect.y; + /* + * Chin's NOTE::::this function is coded based on legacy nsharp software + * show_hailpot(), show_torpot() in xwvid3.c + */ + FloatByReference fvalue2 = new FloatByReference(0); + FloatByReference fvalue3 = new FloatByReference(0); + FloatByReference wdir = new FloatByReference(0); + FloatByReference wspd = new FloatByReference(0); + FloatByReference fvalue = new FloatByReference(0); + FloatByReference fvalue1 = new FloatByReference(0); + + target.drawString(myfont, NsharpNativeConstants.SEVERE_POTENTIAL_STR, + rect.x + rect.width / 3, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_cyan, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + + target.drawString(myfont, + NsharpNativeConstants.SEVERE_HAIL_POTENTIAL_STR, rect.x + + rect.width / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_yellow, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + + _parcel pcl = new _parcel(); + ; + _lplvalues lpvls = new _lplvalues(); + nsharpNative.nsharpLib.get_lpvaluesData(lpvls); + float sfctemp, sfcdwpt, sfcpres; + sfctemp = lpvls.temp; + sfcdwpt = lpvls.dwpt; + sfcpres = lpvls.pres; + nsharpNative.nsharpLib.parcel(-1.0F, -1.0F, sfcpres, sfctemp, sfcdwpt, + pcl); + // CAPE + if (nsharpNative.nsharpLib.qc(pcl.bplus) == 1) { + textStr = NsharpNativeConstants.SEVERE_CAPE_LINE; + textStr = String.format(textStr, pcl.bplus); + } else { + textStr = NsharpNativeConstants.SEVERE_CAPE_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + + // WBZ level + float wbzft = nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib + .agl(nsharpNative.nsharpLib.ihght(nsharpNative.nsharpLib + .wb_lvl(0, fvalue)))); + if (nsharpNative.nsharpLib.qc(wbzft) == 1) { + textStr = NsharpNativeConstants.SEVERE_WBZ_LINE; + textStr = String.format(textStr, wbzft); + } else { + textStr = NsharpNativeConstants.SEVERE_WBZ_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + rect.width / 2 + + i * rect.width / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + // Mid Level RH + nsharpNative.nsharpLib.mean_relhum(fvalue, 700, 500); + if (nsharpNative.nsharpLib.qc(fvalue.getValue()) == 1) { + textStr = NsharpNativeConstants.SEVERE_MIDRH_LINE; + textStr = String.format(textStr, fvalue.getValue(), + NsharpConstants.PERCENT_SYMBOL); + } else { + textStr = NsharpNativeConstants.SEVERE_MIDSRW_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + + // FZG level + float fgzft = nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib + .agl(nsharpNative.nsharpLib.ihght(nsharpNative.nsharpLib + .temp_lvl(0, fvalue)))); + if (nsharpNative.nsharpLib.qc(fgzft) == 1) { + textStr = NsharpNativeConstants.SEVERE_FGZ_LINE; + textStr = String.format(textStr, fgzft); + } else { + textStr = NsharpNativeConstants.SEVERE_FGZ_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + rect.width / 2 + + i * rect.width / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + // EL Storm + nsharpNative.nsharpLib.get_storm(wspd, wdir); + nsharpNative.nsharpLib.sr_wind(pcl.elpres + 25, pcl.elpres - 25, + wdir.getValue(), wspd.getValue(), fvalue, fvalue1, fvalue2, + fvalue3); + if (nsharpNative.nsharpLib.qc(fvalue3.getValue()) == 1) { + textStr = NsharpNativeConstants.SEVERE_ELSTORM_LINE; + textStr = String.format(textStr, fvalue3.getValue()); + } else { + textStr = NsharpNativeConstants.SEVERE_ELSTORM_MISSING; + } + target.drawString(myfont, textStr, rect.x, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + // CHI1 + // _parcel.ByValue pcl_byvalue = new _parcel.ByValue(); + // pr = nsharpNative.nsharpLib.parcel( -1.0F, -1.0F, sfcpres, sfctemp, + // sfcdwpt, pcl_byvalue); + // Assigne values that needed for bulk_rich() + // pcl_byvalue.lplpres = sfcpres; + // pcl_byvalue.bplus = pcl.bplus; + nsharpNative.nsharpLib.cave_bulk_rich2(fvalue); + float rtn = (pcl.bplus * fvalue.getValue()) + / nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(nsharpNative.nsharpLib.wb_lvl(0, fvalue1))); + if (nsharpNative.nsharpLib.qc(rtn) == 1) { + textStr = NsharpNativeConstants.SEVERE_CHI1_LINE; + textStr = String.format(textStr, rtn); + } else { + textStr = NsharpNativeConstants.SEVERE_CHI1_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + // CHI2 + nsharpNative.nsharpLib.Mean_WBtemp(fvalue2, -1, -1); + if (nsharpNative.nsharpLib.qc(rtn / fvalue2.getValue()) == 1) { + textStr = NsharpNativeConstants.SEVERE_CHI2_LINE; + textStr = String.format(textStr, rtn / fvalue2.getValue()); + } else { + textStr = NsharpNativeConstants.SEVERE_CHI2_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + rect.width / 2 + + i * rect.width / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + // Avg BL + nsharpNative.nsharpLib.Mean_WBtemp(fvalue, -1, -1); + if (nsharpNative.nsharpLib.qc(fvalue.getValue()) == 1) { + textStr = NsharpNativeConstants.SEVERE_AVGBL_LINE; + textStr = String.format(textStr, fvalue.getValue(), + NsharpConstants.DEGREE_SYMBOL); + } else { + textStr = NsharpNativeConstants.SEVERE_AVGBL_MISSING; + } + target.drawString(myfont, textStr, rect.x, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + + // TORNADO_POTENTIAL + target.drawString(myfont, + NsharpNativeConstants.SEVERE_TORNADO_POTENTIAL_STR, rect.x + + rect.width / 4, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_yellow, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + curY = curY + charHeight; + + // Low SRW Sfc + float blyr = nsharpNative.nsharpLib + .ipres(nsharpNative.nsharpLib.msl(0)); + float tlyr = pcl.lfcpres; + if (tlyr > 0) { + nsharpNative.nsharpLib.sr_wind(blyr, tlyr, wdir.getValue(), + wspd.getValue(), fvalue, fvalue1, fvalue2, fvalue3); + if (nsharpNative.nsharpLib.qc(fvalue3.getValue()) == 1) { + textStr = NsharpNativeConstants.SEVERE_LOWSRWSFC_LINE; + textStr = String.format(textStr, fvalue3.getValue()); + } else { + textStr = NsharpNativeConstants.SEVERE_LOWSRWSFC_MISSING; + } + } else { + textStr = NsharpNativeConstants.SEVERE_LOWSRWSFC_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 2, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + blyr = pcl.lfcpres; + tlyr = nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib + .ihght(pcl.lfcpres) + 4000); + if ((tlyr > 0) && (blyr > 0)) { + nsharpNative.nsharpLib.sr_wind(blyr, tlyr, wdir.getValue(), + wspd.getValue(), fvalue, fvalue1, fvalue2, fvalue3); + if (nsharpNative.nsharpLib.qc(fvalue3.getValue()) == 1) { + textStr = NsharpNativeConstants.SEVERE_MIDSRW_LINE; + textStr = String.format(textStr, fvalue3.getValue()); + } else { + textStr = NsharpNativeConstants.SEVERE_MIDSRW_MISSING; + } + + } else { + textStr = NsharpNativeConstants.SEVERE_MIDSRW_MISSING; + } + splitedStr = textStr.split("_", -1); + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 2, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + curY = curY + charHeight; + + blyr = nsharpNative.nsharpLib.ipres(nsharpNative.nsharpLib + .ihght(pcl.elpres) - 4000); tlyr = pcl.elpres; - if((tlyr > 0)&&(blyr > 0)) { - nsharpNative.nsharpLib.sr_wind( blyr, tlyr, wdir.getValue(), wspd.getValue(), fvalue,fvalue1,fvalue2,fvalue3); - if(nsharpNative.nsharpLib.qc(fvalue3.getValue())==1) { - textStr = NsharpNativeConstants.SEVERE_LOWSRWEL_LINE; - textStr = String.format(textStr,fvalue3.getValue()); - } - else { - textStr = NsharpNativeConstants.SEVERE_LOWSRWEL_MISSING; - } - + if ((tlyr > 0) && (blyr > 0)) { + nsharpNative.nsharpLib.sr_wind(blyr, tlyr, wdir.getValue(), + wspd.getValue(), fvalue, fvalue1, fvalue2, fvalue3); + if (nsharpNative.nsharpLib.qc(fvalue3.getValue()) == 1) { + textStr = NsharpNativeConstants.SEVERE_LOWSRWEL_LINE; + textStr = String.format(textStr, fvalue3.getValue()); + } else { + textStr = NsharpNativeConstants.SEVERE_LOWSRWEL_MISSING; + } + + } else { + textStr = NsharpNativeConstants.SEVERE_LOWSRWEL_MISSING; } - else { - textStr = NsharpNativeConstants.SEVERE_LOWSRWEL_MISSING; - } splitedStr = textStr.split("_", -1); - for (int i =0; i < splitedStr.length; i++){ - target.drawString(myfont, splitedStr[i], rect.x + i*rect.width/2, curY , 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - } - - //myfont.dispose(); - } + for (int i = 0; i < splitedStr.length; i++) { + target.drawString(myfont, splitedStr[i], rect.x + i * rect.width + / 2, curY, 0.0, TextStyle.NORMAL, + NsharpConstants.color_white, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + } + // myfont.dispose(); + } - public boolean isSumP1Visible() { - return sumP1Visible; - } + // Surface based CAPE -p1 + // Forecast parcel CAPE - p1 + // Most unstable CAPE -p1 + // LCL (shown as both mb andft) - p1(m) p3(mb) + // LFC (shown as both mb and ft) - p1(m)p3(mb) + // CIN - p1 CINH + // Convective Temp (maybe) - p1/p4 + // Precipitable Water - p1/p4 + // Freezing Level - p1 FZL (FGZ level) + // Wet Bulb Zero - p1 WBZ + // 0-1 km Helicity - p2 SFC-1km SRH + // 0-3 km Helicity - p2 SFC-3km SRH + // BRN Shear - p2 BRN Shear, This is true for Surface-based, + // Forecast, and Mixed-length Parcels. For Most-unstable and User-defined + // parcels, The bottom level could be at 500m below the parcel level, not at + // the surface. The depth in computing bulk shear is always 6km. + // Bunkers RM Storm - p2 Bunkers Right Motion + // Bulk Richardson Number -p9 BRN + // start d2dlite + @SuppressWarnings("deprecation") + private void drawPanel11(IGraphicsTarget target, Rectangle rect) + throws VizException { + IFont myfont; + if (paneConfigurationName + .equals(NsharpConstants.PANE_SIMPLE_D2D_CFG_STR) + || paneConfigurationName + .equals(NsharpConstants.PANE_SPCWS_CFG_STR)) { + myfont = font11; + } else { + myfont = defaultFont; + } + defineCharHeight(myfont); + myfont.setSmoothing(false); + myfont.setScaleFont(false); + extent = new PixelExtent(rect); + target.setupClippingPlane(extent); + // if we can not Interpolates a temp with 700 mb pressure, then we dont + // have enough raw data + if ((nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib.itemp(700.0F)) == 0)) { + target.drawString(myfont, " " + NO_DATA, rect.x, + rect.y, 0.0, TextStyle.NORMAL, NsharpConstants.color_cyan, + HorizontalAlignment.LEFT, VerticalAlignment.TOP, null); + return; + } - public NsharpGenericPaneBackground getDataPanel1Background() { - return dataPanel1Background; - } + // call get_topBotPres to set p_top and p_bot + FloatByReference topPF = new FloatByReference(0); + FloatByReference botPF = new FloatByReference(0); + nsharpNative.nsharpLib.get_effectLayertopBotPres(topPF, botPF); + String textStr; + curY = rect.y; - public NsharpGenericPaneBackground getDataPanel2Background() { - return dataPanel2Background; - } - - public void setPageDisplayOrderNumberArray(int[] pageDisplayOrderNumberArray, int numberPagePerDisplay) { - this.pageDisplayOrderNumberArray = pageDisplayOrderNumberArray; - if(paneConfigurationName.equals(NsharpConstants.PANE_DEF_CFG_1_STR)) - //This configuration always show 2 pages layout vertically - this.numberPagePerDisplay = 2; - else - this.numberPagePerDisplay = numberPagePerDisplay; - if(initDone){ - if(this.numberPagePerDisplay == 1) - myfont = font12; - else - myfont = font10; - handleResize(); - } - - } - @Override - protected void adjustFontSize(float canvasW, float canvasH ) { - /* - if(canvasH < myDefaultCanvasHeight/3 || canvasW< myDefaultCanvasWidth/3){ - if(myfont!=null){ - myfont.dispose(); - } - myfont = target.initializeFont("Monospace", 8, null); - } else if(canvasH < myDefaultCanvasHeight/2 || canvasW< myDefaultCanvasWidth/2){ - if(myfont!=null){ - myfont.dispose(); - } - myfont = target.initializeFont("Monospace", 8, null); - }*/ - } - @Override - public void handleResize(){ - super.handleResize(); - //Chin Note; ext size is its view size Not canvas size - IExtent ext = getDescriptor().getRenderableDisplay().getExtent(); - ext.reset(); - this.rectangle = new Rectangle((int)ext.getMinX(), (int) ext.getMinY(), - (int) ext.getWidth(), (int) ext.getHeight()); - pe = new PixelExtent(this.rectangle); - getDescriptor().setNewPe(pe); - defineCharHeight(myfont); - float prevHeight = dataPaneHeight; - float prevWidth = dataPaneWidth; - dp1XOrig = (int) (ext.getMinX()); - dp1YOrig = (int) (ext.getMinY()); - if(paneConfigurationName.equals(NsharpConstants.PANE_DEF_CFG_2_STR) || - paneConfigurationName.equals(NsharpConstants.PANE_SPCWS_CFG_STR) || - paneConfigurationName.equals(NsharpConstants.PANE_SIMPLE_D2D_CFG_STR)){ - if(numberPagePerDisplay == 2){ - //these 2 configurations lay 2 data panels side by side - dataPaneWidth= (int) (ext.getWidth()/2); - dataPaneHeight= (int) ext.getHeight(); - dp2XOrig = dp1XOrig+ dataPaneWidth; - dp2YOrig = dp1YOrig; - } - else { - dataPaneWidth= (int) ext.getWidth(); - dataPaneHeight= (int) ext.getHeight(); - dp2XOrig = dp1XOrig; - dp2YOrig = dp1YOrig; - } - } else if(paneConfigurationName.equals(NsharpConstants.PANE_DEF_CFG_1_STR)){ - //this configuration lays 2 data panels top/down - // always display 2 pages - dataPaneWidth= (int) ext.getWidth(); - dataPaneHeight= (int) ext.getHeight()/2; - dp2XOrig = dp1XOrig; - dp2YOrig = dp1YOrig+dataPaneHeight; - } - - xRatio = xRatio* dataPaneWidth/prevWidth; - xRatio=1; //turn off - yRatio = yRatio* dataPaneHeight/prevHeight; - yRatio=1;//turn off - charHeight = (int) (charHeight * yRatio); - - Rectangle rectangle = new Rectangle(dp1XOrig, dp1YOrig,dataPaneWidth,dataPaneHeight); - dataPanel1Background.handleResize(rectangle); - rectangle = new Rectangle(dp2XOrig, dp2YOrig,dataPaneWidth,dataPaneHeight); - dataPanel2Background.handleResize(rectangle); - panelRectArray[0] = dataPanel1Background.getRectangle(); - panelRectArray[1] = dataPanel2Background.getRectangle(); - //System.out.println("Data: handle resize w="+dataPaneWidth+ " h="+ dataPaneHeight); + // + // Start with Parcel Data + // + float layerPressure = 0; - } - @Override - public void handleZooming(){ - magnifyFont(currentZoomLevel); - } + // get user selected parcel type + _lplvalues lpvls; + _parcel pcl; + DrawableString str1 = new DrawableString( + NsharpNativeConstants.PAGE1TEXT1_FCST_STR + "XX", + NsharpConstants.color_white); + str1.font = myfont; + double hRatio = paintProps.getView().getExtent().getWidth() + / paintProps.getCanvasBounds().width; + double startX = rect.x + 0.5 * charWidth; + double widthGap = rect.width / 4; + str1.setText("12345ft", NsharpConstants.color_red); + double aglWidth = target.getStringsBounds(str1).getWidth() * hRatio + * xRatio; + str1.setText("D2D Lite Page", NsharpConstants.color_red); + str1.setCoordinates(startX, curY); + str1.horizontalAlignment = HorizontalAlignment.LEFT; + str1.verticallAlignment = VerticalAlignment.TOP; + DrawableString str2 = new DrawableString("", + NsharpConstants.color_white); + // str2.setCoordinates(startX, curY); + str2.horizontalAlignment = HorizontalAlignment.LEFT; + str2.verticallAlignment = VerticalAlignment.TOP; + str2.font = myfont; + DrawableString str3 = new DrawableString("", + NsharpConstants.color_white); + // str3.setCoordinates(firstToken, curY); + str3.horizontalAlignment = HorizontalAlignment.RIGHT; + str3.verticallAlignment = VerticalAlignment.TOP; + str3.font = myfont; + DrawableString str4 = new DrawableString("", + NsharpConstants.color_white); + // str4.setCoordinates(secondToken, curY); + str4.horizontalAlignment = HorizontalAlignment.LEFT; + str4.verticallAlignment = VerticalAlignment.TOP; + str4.font = myfont; + DrawableString str5 = new DrawableString("", + NsharpConstants.color_white); + // str5.setCoordinates(thirdToken, curY); + str5.horizontalAlignment = HorizontalAlignment.RIGHT; + str5.verticallAlignment = VerticalAlignment.TOP; + str5.font = myfont; + DrawableString str6 = new DrawableString("", + NsharpConstants.color_white); + // str6.setCoordinates(startX, curY); + str6.horizontalAlignment = HorizontalAlignment.LEFT; + str6.verticallAlignment = VerticalAlignment.TOP; + str6.font = myfont; + DrawableString str7 = new DrawableString("", + NsharpConstants.color_white); + // str7.setCoordinates(firstToken, curY); + str7.horizontalAlignment = HorizontalAlignment.RIGHT; + str7.verticallAlignment = VerticalAlignment.TOP; + str7.font = myfont; + DrawableString str8 = new DrawableString("", + NsharpConstants.color_white); + // str8.setCoordinates(secondToken, curY); + str8.horizontalAlignment = HorizontalAlignment.LEFT; + str8.verticallAlignment = VerticalAlignment.TOP; + str8.font = myfont; + DrawableString str9 = new DrawableString("", + NsharpConstants.color_white); + // str9.setCoordinates(thirdToken, curY); + str9.horizontalAlignment = HorizontalAlignment.RIGHT; + str9.verticallAlignment = VerticalAlignment.TOP; + str9.font = myfont; + DrawableString str10 = new DrawableString("", + NsharpConstants.color_white); + // str10.setCoordinates(startX, curY); + str10.horizontalAlignment = HorizontalAlignment.LEFT; + str10.verticallAlignment = VerticalAlignment.TOP; + str10.font = myfont; + DrawableString str11 = new DrawableString("", + NsharpConstants.color_white); + // str11.setCoordinates(firstToken, curY); + str11.horizontalAlignment = HorizontalAlignment.RIGHT; + str11.verticallAlignment = VerticalAlignment.TOP; + str11.font = myfont; + DrawableString str12 = new DrawableString("", + NsharpConstants.color_white); + // str12.setCoordinates(secondToken, curY); + str12.horizontalAlignment = HorizontalAlignment.LEFT; + str12.verticallAlignment = VerticalAlignment.TOP; + str12.font = myfont; + DrawableString str13 = new DrawableString("", + NsharpConstants.color_white); + // str13.setCoordinates(thirdToken, curY); + str13.horizontalAlignment = HorizontalAlignment.RIGHT; + str13.verticallAlignment = VerticalAlignment.TOP; + str13.font = myfont; + + target.drawStrings(str1); + curY = curY + charHeight; + target.drawLine(rect.x, curY, 0.0, rect.x + rect.width, curY, 0.0, + NsharpConstants.color_white, 1); + + if (paneConfigurationName.equals(NsharpConstants.PANE_LITE_D2D_CFG_STR)) { + firstToken = rect.x + widthGap + aglWidth; + secondToken = rect.x + 2 * widthGap - charWidth; + thirdToken = rect.x + 3 * widthGap + aglWidth; + + // thirdToken = thirdToken - aglWidth / 2; + // forthToken = forthToken - aglWidth / 2; + // fifthToken = fifthToken - aglWidth / 2; + // sixthToken = sixthToken - aglWidth / 2; + for (short parcelNumber = 1; parcelNumber <= NsharpNativeConstants.PARCEL_D2DLITE_MAX; parcelNumber++) { + // call native define_parcel() with parcel type and user defined + // pressure (if user defined it) + textStr = NsharpNativeConstants.parcelToTypeStrMap + .get(parcelNumber); + str1.setText(textStr, NsharpConstants.color_gold); + + str1.setCoordinates(startX, curY); + float layerPressure1 = NsharpNativeConstants.parcelToLayerMap + .get(parcelNumber); + nsharpNative.nsharpLib.define_parcel(parcelNumber, + layerPressure1); + + lpvls = new _lplvalues(); + nsharpNative.nsharpLib.get_lpvaluesData(lpvls); + + float sfctemp, sfcdwpt, sfcpres; + sfctemp = lpvls.temp; + sfcdwpt = lpvls.dwpt; + sfcpres = lpvls.pres; + // get parcel data by calling native nsharp parcel() API. value + // is + // returned in pcl + pcl = new _parcel(); + nsharpNative.nsharpLib.parcel(-1.0F, -1.0F, sfcpres, sfctemp, + sfcdwpt, pcl); + curY = curY + charHeight; + // draw CAPE + str2.setText("CAPE=", NsharpConstants.color_white); + str2.setCoordinates(startX, curY); + if (pcl.bplus != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA) + str3.setText(String.format("%.0f", pcl.bplus), + NsharpConstants.color_white); + else + str3.setText("M", NsharpConstants.color_white); + str3.setCoordinates(firstToken, curY); + + // draw CINH + str4.setText("CINH=", NsharpConstants.color_white); + str4.setCoordinates(secondToken, curY); + + if (pcl.bminus != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA) + str5.setText(String.format("%.0f", pcl.bminus), + NsharpConstants.color_white); + else + str5.setText("M", NsharpConstants.color_white); + str5.setCoordinates(thirdToken, curY); + curY = curY + charHeight; + // draw LCL + str6.setText("LCL(Pres)=", NsharpConstants.color_white); + str6.setCoordinates(startX, curY); + str8.setText("LCL(AGL)=", NsharpConstants.color_white); + str8.setCoordinates(secondToken, curY); + if (nsharpNative.nsharpLib.qc(pcl.lclpres) == 1 + && nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib + .mtof(nsharpNative.nsharpLib + .agl(nsharpNative.nsharpLib + .ihght(pcl.lclpres)))) == 1) { + float lcl = nsharpNative.nsharpLib + .mtof(nsharpNative.nsharpLib + .agl(nsharpNative.nsharpLib + .ihght(pcl.lclpres))); + + str7.setText(String.format("%5.0fmb", pcl.lclpres), + NsharpConstants.color_white); + str9.setText(String.format("%7.0fft", lcl), + NsharpConstants.color_white); + } else { + str7.setText("M", NsharpConstants.color_white); + str9.setText("M", NsharpConstants.color_white); + } + str7.setCoordinates(firstToken, curY); + str9.setCoordinates(thirdToken, curY); + curY = curY + charHeight; + // draw LFC + str10.setText("LFC(Pres)=", NsharpConstants.color_white); + str10.setCoordinates(startX, curY); + str12.setText("LFC(AGL)=", NsharpConstants.color_white); + str12.setCoordinates(secondToken, curY); + if (nsharpNative.nsharpLib.qc(pcl.lfcpres) == 1 + && nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib + .mtof(nsharpNative.nsharpLib + .agl(nsharpNative.nsharpLib + .ihght(pcl.lfcpres)))) == 1 + && nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib + .itemp(pcl.lfcpres)) == 1) { + float lfc = nsharpNative.nsharpLib + .mtof(nsharpNative.nsharpLib + .agl(nsharpNative.nsharpLib + .ihght(pcl.lfcpres))); + str11.setText(String.format("%5.0fmb", pcl.lfcpres), + NsharpConstants.color_white); + str13.setText(String.format("%7.0fft", lfc), + NsharpConstants.color_white); + } else { + str11.setText("M", NsharpConstants.color_white); + str13.setText("M", NsharpConstants.color_white); + } + str11.setCoordinates(firstToken, curY); + str13.setCoordinates(thirdToken, curY); + target.drawStrings(str1, str2, str3, str4, str5, str6, str7, + str8, str9, str10, str11, str12, str13); + curY = curY + charHeight; + } + } else if (paneConfigurationName + .equals(NsharpConstants.PANE_SIMPLE_D2D_CFG_STR) + || paneConfigurationName + .equals(NsharpConstants.PANE_SPCWS_CFG_STR)) { + widthGap = rect.width / 3; + firstToken = rect.x + widthGap * 0.8; + secondToken = rect.x + widthGap; + thirdToken = secondToken + widthGap * 0.8; + forthToken = rect.x + 2 * widthGap; + fifthToken = forthToken + widthGap * 0.8; + for (short parcelNumber = 1; parcelNumber <= NsharpNativeConstants.PARCEL_D2DLITE_MAX; parcelNumber++) { + // call native define_parcel() with parcel type and user defined + // pressure (if user defined it) + textStr = NsharpNativeConstants.parcelToTypeStrMap + .get(parcelNumber); + str1.setText(textStr, NsharpConstants.color_gold); + + str1.setCoordinates(startX, curY); + float layerPressure1 = NsharpNativeConstants.parcelToLayerMap + .get(parcelNumber); + nsharpNative.nsharpLib.define_parcel(parcelNumber, + layerPressure1); + + lpvls = new _lplvalues(); + nsharpNative.nsharpLib.get_lpvaluesData(lpvls); + + float sfctemp, sfcdwpt, sfcpres; + sfctemp = lpvls.temp; + sfcdwpt = lpvls.dwpt; + sfcpres = lpvls.pres; + // get parcel data by calling native nsharp parcel() API. value + // is + // returned in pcl + pcl = new _parcel(); + nsharpNative.nsharpLib.parcel(-1.0F, -1.0F, sfcpres, sfctemp, + sfcdwpt, pcl); + curY = curY + charHeight; + // draw CAPE + str2.setText("CAPE=", NsharpConstants.color_white); + str2.setCoordinates(startX, curY); + if (pcl.bplus != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA) + str3.setText(String.format("%.0f", pcl.bplus), + NsharpConstants.color_white); + else + str3.setText("M", NsharpConstants.color_white); + str3.setCoordinates(firstToken, curY); + + // draw LCL + str4.setText("LCL(mb)=", NsharpConstants.color_white); + str4.setCoordinates(secondToken, curY); + str6.setText("LCL(ft)=", NsharpConstants.color_white); + str6.setCoordinates(forthToken, curY); + if (nsharpNative.nsharpLib.qc(pcl.lclpres) == 1 + && nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib + .mtof(nsharpNative.nsharpLib + .agl(nsharpNative.nsharpLib + .ihght(pcl.lclpres)))) == 1) { + float lcl = nsharpNative.nsharpLib + .mtof(nsharpNative.nsharpLib + .agl(nsharpNative.nsharpLib + .ihght(pcl.lclpres))); + + str5.setText(String.format("%5.0f", pcl.lclpres), + NsharpConstants.color_white); + str7.setText(String.format("%7.0f", lcl), + NsharpConstants.color_white); + } else { + str5.setText("M", NsharpConstants.color_white); + str7.setText("M", NsharpConstants.color_white); + } + str5.setCoordinates(thirdToken, curY); + str7.setCoordinates(fifthToken, curY); + curY = curY + charHeight; + // draw CINH + str8.setText("CINH=", NsharpConstants.color_white); + str8.setCoordinates(startX, curY); + + if (pcl.bminus != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA) + str9.setText(String.format("%.0f", pcl.bminus), + NsharpConstants.color_white); + else + str9.setText("M", NsharpConstants.color_white); + str9.setCoordinates(firstToken, curY); + + // draw LFC + str10.setText("LFC(mb)=", NsharpConstants.color_white); + str10.setCoordinates(secondToken, curY); + str12.setText("LFC(ft)=", NsharpConstants.color_white); + str12.setCoordinates(forthToken, curY); + if (nsharpNative.nsharpLib.qc(pcl.lfcpres) == 1 + && nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib + .mtof(nsharpNative.nsharpLib + .agl(nsharpNative.nsharpLib + .ihght(pcl.lfcpres)))) == 1 + && nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib + .itemp(pcl.lfcpres)) == 1) { + float lfc = nsharpNative.nsharpLib + .mtof(nsharpNative.nsharpLib + .agl(nsharpNative.nsharpLib + .ihght(pcl.lfcpres))); + str11.setText(String.format("%5.0f", pcl.lfcpres), + NsharpConstants.color_white); + str13.setText(String.format("%7.0f", lfc), + NsharpConstants.color_white); + } else { + str11.setText("M", NsharpConstants.color_white); + str13.setText("M", NsharpConstants.color_white); + } + str11.setCoordinates(thirdToken, curY); + str13.setCoordinates(fifthToken, curY); + target.drawStrings(str1, str2, str3, str4, str5, str6, str7, + str8, str9, str10, str11, str12, str13); + curY = curY + charHeight; + } + } + // widthGap = rect.width / 4; + // firstToken = rect.x + widthGap + aglWidth; + // secondToken = rect.x + 2 * widthGap; + // thirdToken = rect.x + 3 * widthGap + aglWidth; + + if (currentParcel == NsharpNativeConstants.PARCELTYPE_USER_DEFINED) { + layerPressure = NsharpParcelDialog.getUserDefdParcelMb(); + } else + layerPressure = NsharpNativeConstants.parcelToLayerMap + .get(currentParcel); + + // reset and define current parcel + nsharpNative.nsharpLib.define_parcel(currentParcel, layerPressure); + lpvls = new _lplvalues(); + nsharpNative.nsharpLib.get_lpvaluesData(lpvls); + + float sfctemp, sfcdwpt, sfcpres; + sfctemp = lpvls.temp; + sfcdwpt = lpvls.dwpt; + sfcpres = lpvls.pres; + // get parcel data by calling native nsharp parcel() API. value is + // returned in pcl + pcl = new _parcel(); + nsharpNative.nsharpLib.parcel(-1.0F, -1.0F, sfcpres, sfctemp, sfcdwpt, + pcl); + + str2.horizontalAlignment = HorizontalAlignment.RIGHT; + str3.horizontalAlignment = HorizontalAlignment.LEFT; + str4.horizontalAlignment = HorizontalAlignment.RIGHT; + str5.horizontalAlignment = HorizontalAlignment.LEFT; + str6.horizontalAlignment = HorizontalAlignment.RIGHT; + str7.horizontalAlignment = HorizontalAlignment.LEFT; + str8.horizontalAlignment = HorizontalAlignment.RIGHT; + str9.horizontalAlignment = HorizontalAlignment.LEFT; + str10.horizontalAlignment = HorizontalAlignment.RIGHT; + str11.horizontalAlignment = HorizontalAlignment.LEFT; + str12.horizontalAlignment = HorizontalAlignment.RIGHT; + target.drawLine(rect.x, curY, 0.0, rect.x + rect.width, curY, 0.0, + NsharpConstants.color_white, 1); + str1.setText("PW =", NsharpConstants.color_white); + str1.setCoordinates(startX, curY); + fValue.setValue(0); + nsharpNative.nsharpLib.precip_water(fValue, -1.0F, -1.0F); + if (nsharpNative.nsharpLib.qc(fValue.getValue()) == 1) { + textStr = String.format("%.2fin", fValue.getValue()); + } else { + textStr = "M"; + } + str2.setText(textStr, NsharpConstants.color_white); + str2.setCoordinates(firstToken, curY); + str3.setText("ConvT =", NsharpConstants.color_white); + str3.setCoordinates(secondToken, curY); + fValue.setValue(0); + float conTempF = nsharpNative.nsharpLib.ctof(nsharpNative.nsharpLib + .cnvtv_temp(fValue, -1)); + + if (nsharpNative.nsharpLib.qc(conTempF) == 1) { + textStr = String.format("%.0fF", conTempF); + } else { + textStr = "M"; + } + str4.setText(textStr, NsharpConstants.color_white); + str4.setCoordinates(thirdToken, curY); + curY = curY + charHeight; + str5.setText("WBZ =", NsharpConstants.color_white); + str5.setCoordinates(startX, curY); + fValue.setValue(0); + float wbzft = nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib + .agl(nsharpNative.nsharpLib.ihght(nsharpNative.nsharpLib + .wb_lvl(0, fValue)))); + if (nsharpNative.nsharpLib.qc(wbzft) == 1) { + textStr = String.format("%.0fft", wbzft); + } else { + textStr = "M"; + } + str6.setText(textStr, NsharpConstants.color_white); + str6.setCoordinates(firstToken, curY); + str7.setText("FGZ =", NsharpConstants.color_white); + str7.setCoordinates(secondToken, curY); + fValue.setValue(0); + float fgzft = nsharpNative.nsharpLib.mtof(nsharpNative.nsharpLib + .agl(nsharpNative.nsharpLib.ihght(nsharpNative.nsharpLib + .temp_lvl(0, fValue)))); + if (nsharpNative.nsharpLib.qc(fgzft) == 1) { + textStr = String.format("%.0fft", fgzft); + } else { + textStr = "M"; + } + str8.setText(textStr, NsharpConstants.color_white); + str8.setCoordinates(thirdToken, curY); + + target.drawStrings(str1, str2, str3, str4, str5, str6, str7, str8); + curY = curY + charHeight; + str1.setText("BRN =", NsharpConstants.color_white); + str1.setCoordinates(startX, curY); + if (nsharpNative.nsharpLib.qc(pcl.brn) == 1) { + textStr = NsharpNativeConstants.STORM_TYPE_BRN_LINE; + textStr = String.format("%6.0f", pcl.brn); + } else { + textStr = "M"; + } + str2.setText(textStr, NsharpConstants.color_white); + str2.setCoordinates(firstToken, curY); + str3.setText("BRN Shr=", NsharpConstants.color_white); + str3.setCoordinates(secondToken, curY); + nsharpNative.nsharpLib.get_lpvaluesData(lpvls); + sfctemp = lpvls.temp; + sfcdwpt = lpvls.dwpt; + sfcpres = lpvls.pres; + nsharpNative.nsharpLib.parcel(-1.0F, -1.0F, sfcpres, sfctemp, sfcdwpt, + pcl); + nsharpNative.nsharpLib.cave_bulk_rich2(fValue); + if (nsharpNative.nsharpLib.qc(fValue.getValue()) == 1) + textStr = String.format("%.0f m%c/s%c", fValue.getValue(), + NsharpConstants.SQUARE_SYMBOL, + NsharpConstants.SQUARE_SYMBOL); + else + textStr = "M"; + str4.setText(textStr, NsharpConstants.color_white); + str4.setCoordinates(thirdToken, curY); + curY = curY + charHeight; + target.drawLine(rect.x, curY, 0.0, rect.x + rect.width, curY, 0.0, + NsharpConstants.color_white, 1); + str5.setText("Bunkers Right=", NsharpConstants.color_white); + str5.setCoordinates(startX, curY); + nsharpNative.nsharpLib.bunkers_storm_motion(fValue1, fValue2, fValue3, + fValue4); + textStr = String.format("%.0f/%.0f kt", fValue3.getValue(), + fValue4.getValue()); + + str6.setText(textStr, NsharpConstants.color_white); + str6.setCoordinates(thirdToken, curY); + curY = curY + charHeight; + + target.drawStrings(str1, str2, str3, str4, str5, str6); + + str1.setText("0-1km Helicity=", NsharpConstants.color_white); + str1.setCoordinates(startX, curY); + FloatByReference smdir = new FloatByReference(0), smspd = new FloatByReference( + 0); + nsharpNative.nsharpLib.get_storm(smspd, smdir); + float totHeli = nsharpNative.nsharpLib.helicity(0, 1000, + smdir.getValue(), smspd.getValue(), fValue, fValue1); + if (nsharpNative.nsharpLib.qc(fValue.getValue()) == 1 + && nsharpNative.nsharpLib.qc(fValue1.getValue()) == 1) { + textStr = String.format("%.0f m%c/s%c", totHeli, + NsharpConstants.SQUARE_SYMBOL, + NsharpConstants.SQUARE_SYMBOL); + } else { + textStr = "M"; + } + str2.setText(textStr, NsharpConstants.color_white); + str2.setCoordinates(thirdToken, curY); + curY = curY + charHeight; + str3.setText("0-3km Helicity=", NsharpConstants.color_white); + str3.setCoordinates(startX, curY); + totHeli = nsharpNative.nsharpLib.helicity(0, 3000, smdir.getValue(), + smspd.getValue(), fValue, fValue1); + if (nsharpNative.nsharpLib.qc(fValue.getValue()) == 1 + && nsharpNative.nsharpLib.qc(fValue1.getValue()) == 1) { + textStr = String.format("%.0f m%c/s%c", totHeli, + NsharpConstants.SQUARE_SYMBOL, + NsharpConstants.SQUARE_SYMBOL); + } else { + textStr = "M"; + } + str4.setText(textStr, NsharpConstants.color_white); + str4.setCoordinates(thirdToken, curY); + target.drawStrings(str1, str2, str3, str4); + } + + @SuppressWarnings("deprecation") + // future (dummy) page + private void drawPanel12(IGraphicsTarget target, Rectangle rect) + throws VizException { + IFont myfont; + myfont = defaultFont; + defineCharHeight(myfont); + myfont.setSmoothing(false); + myfont.setScaleFont(false); + extent = new PixelExtent(rect); + target.setupClippingPlane(extent); + // if we can not Interpolates a temp with 700 mb pressure, then we dont + // have enough raw data + target.drawString(myfont, " FUTURE PAGE", rect.x + + rect.width / 2, rect.y + rect.height / 2, 0.0, + TextStyle.NORMAL, NsharpConstants.color_cyan, + HorizontalAlignment.RIGHT, VerticalAlignment.TOP, null); + return; + } + + // end d2dlite + + public boolean isSumP1Visible() { + return sumP1Visible; + } + + public NsharpGenericPaneBackground getDataPanel1Background() { + return dataPanel1Background; + } + + public NsharpGenericPaneBackground getDataPanel2Background() { + return dataPanel2Background; + } + + public void setPageDisplayOrderNumberArray( + int[] pageDisplayOrderNumberArray, int numberPagePerDisplay) { + this.pageDisplayOrderNumberArray = pageDisplayOrderNumberArray; + if (paneConfigurationName.equals(NsharpConstants.PANE_DEF_CFG_1_STR)) + // This configuration always show 2 pages layout vertically + this.numberPagePerDisplay = 2; + else if (paneConfigurationName + .equals(NsharpConstants.PANE_LITE_D2D_CFG_STR)) // d2dlite + this.numberPagePerDisplay = 1; + else + this.numberPagePerDisplay = numberPagePerDisplay; + if (initDone) { + if (this.numberPagePerDisplay == 1) + defaultFont = font12; + else + defaultFont = font10; + handleResize(); + } + + } + + @Override + protected void adjustFontSize(float canvasW, float canvasH) { + /* + * if(canvasH < myDefaultCanvasHeight/3 || canvasW< + * myDefaultCanvasWidth/3){ if(myfont!=null){ myfont.dispose(); } myfont + * = target.initializeFont("Monospace", 8, null); } else if(canvasH < + * myDefaultCanvasHeight/2 || canvasW< myDefaultCanvasWidth/2){ + * if(myfont!=null){ myfont.dispose(); } myfont = + * target.initializeFont("Monospace", 8, null); } + */ + } + + @Override + public void handleResize() { + super.handleResize(); + // Chin Note; ext size is its view size Not canvas size + IExtent ext = getDescriptor().getRenderableDisplay().getExtent(); + ext.reset(); + this.rectangle = new Rectangle((int) ext.getMinX(), + (int) ext.getMinY(), (int) ext.getWidth(), + (int) ext.getHeight()); + pe = new PixelExtent(this.rectangle); + getDescriptor().setNewPe(pe); + defineCharHeight(defaultFont); + float prevHeight = dataPaneHeight; + float prevWidth = dataPaneWidth; + dp1XOrig = (int) (ext.getMinX()); + dp1YOrig = (int) (ext.getMinY()); + if (paneConfigurationName.equals(NsharpConstants.PANE_DEF_CFG_2_STR) + || paneConfigurationName + .equals(NsharpConstants.PANE_SPCWS_CFG_STR) + || paneConfigurationName + .equals(NsharpConstants.PANE_SIMPLE_D2D_CFG_STR) + || paneConfigurationName + .equals(NsharpConstants.PANE_LITE_D2D_CFG_STR)) { + if (numberPagePerDisplay == 2) { + // these 2 configurations lay 2 data panels side by side + dataPaneWidth = (int) (ext.getWidth() / 2); + dataPaneHeight = (int) ext.getHeight(); + dp2XOrig = dp1XOrig + dataPaneWidth; + dp2YOrig = dp1YOrig; + } else { + dataPaneWidth = (int) ext.getWidth(); + dataPaneHeight = (int) ext.getHeight(); + dp2XOrig = dp1XOrig; + dp2YOrig = dp1YOrig; + } + } else if (paneConfigurationName + .equals(NsharpConstants.PANE_DEF_CFG_1_STR)) { + // this configuration lays 2 data panels top/down + // always display 2 pages + dataPaneWidth = (int) ext.getWidth(); + dataPaneHeight = (int) ext.getHeight() / 2; + dp2XOrig = dp1XOrig; + dp2YOrig = dp1YOrig + dataPaneHeight; + } + + xRatio = xRatio * dataPaneWidth / prevWidth; + xRatio = 1; // turn off + yRatio = yRatio * dataPaneHeight / prevHeight; + yRatio = 1;// turn off + charHeight = (int) (charHeight * yRatio); + + Rectangle rectangle = new Rectangle(dp1XOrig, dp1YOrig, dataPaneWidth, + dataPaneHeight); + dataPanel1Background.handleResize(rectangle); + rectangle = new Rectangle(dp2XOrig, dp2YOrig, dataPaneWidth, + dataPaneHeight); + dataPanel2Background.handleResize(rectangle); + panelRectArray[0] = dataPanel1Background.getRectangle(); + panelRectArray[1] = dataPanel2Background.getRectangle(); + // System.out.println("Data: handle resize w="+dataPaneWidth+ " h="+ + // dataPaneHeight); + + } + + @Override + public void handleZooming() { + magnifyFont(currentZoomLevel); + } } diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpHodoPaneResource.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpHodoPaneResource.java index cf0ff9ed27..3a32bf087d 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpHodoPaneResource.java +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpHodoPaneResource.java @@ -213,6 +213,20 @@ public class NsharpHodoPaneResource extends NsharpAbstractPaneResource{ } } else if(compareSndIsOn && currentStnListIndex >=0 && currentTimeListIndex >=0){ + //start FixMark:nearByStnCompSnd + List sndCompElementList = rscHandler.getCompSndSelectedElemList(); + for(NsharpResourceHandler.CompSndSelectedElem compElem: sndCompElementList){ + NsharpSoundingElementStateProperty elemProp = stnTimeSndTable.get(compElem.getStnIndex()).get(compElem.getTimeIndex()).get(compElem.getSndIndex()); + if(sndElemList.get(compElem.getSndIndex()).getActionState()== NsharpConstants.ActState.ACTIVE && + elemProp!=null){ + List soundingLayeys = elemProp.getSndLyLst(); + int colorIndex = elemProp.getCompColorIndex(); + RGB color = linePropertyMap.get(NsharpConstants.lineNameArray[colorIndex]).getLineColor(); + createRscHodoWindShape(world, soundingLayeys, color); + } + } + + /* origonal code for(NsharpOperationElement elm: sndElemList) { if(elm.getActionState() == NsharpConstants.ActState.ACTIVE && stnTimeSndTable.get(currentStnListIndex).get(currentTimeListIndex).get(sndElemList.indexOf(elm))!=null){ @@ -221,7 +235,8 @@ public class NsharpHodoPaneResource extends NsharpAbstractPaneResource{ RGB color = linePropertyMap.get(NsharpConstants.lineNameArray[colorIndex]).getLineColor(); createRscHodoWindShape(world, soundingLayeys, color); } - } + }*/ + //end FixMark:nearByStnCompSnd } else if(overlayIsOn == true ){ previousSoundingLys = rscHandler.getPreviousSoundingLys(); diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpResourceHandler.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpResourceHandler.java index 6632978f23..e459a29819 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpResourceHandler.java +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpResourceHandler.java @@ -61,6 +61,8 @@ import java.util.StringTokenizer; import org.eclipse.core.runtime.ListenerList; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.RGB; +import org.geotools.referencing.GeodeticCalculator; +import org.geotools.referencing.datum.DefaultEllipsoid; import com.raytheon.uf.common.sounding.WxMath; import com.raytheon.uf.common.time.DataTime; @@ -75,3591 +77,4327 @@ import com.raytheon.viz.core.graphing.WGraphics; import com.raytheon.viz.core.graphing.WindBarbFactory; import com.sun.jna.ptr.FloatByReference; import com.vividsolutions.jts.geom.Coordinate; + @SuppressWarnings("deprecation") public class NsharpResourceHandler { - private IRenderableDisplay[] displayArray=null; - private NsharpPartListener.PartEvent editorPartStatus =NsharpPartListener.PartEvent.partClosed; - private NsharpSkewTPaneResource skewtPaneRsc; - private NsharpWitoPaneResource witoPaneRsc; - private NsharpHodoPaneResource hodoPaneRsc; - private NsharpTimeStnPaneResource timeStnPaneRsc; - private NsharpInsetPaneResource insetPaneRsc; - private NsharpDataPaneResource dataPaneRsc; - private NsharpSpcGraphsPaneResource spcGraphsPaneRsc; - private NsharpAbstractPaneResource futurePaneRsc; - private String[] defaultDays; - NsharpNative nsharpNative=null; - private int displayDataPageMax; - private static final int INSETPAGEMAX =2; - private int currentTextChapter= 1; - private int currentInsetPage= 1; - private int cnYOrig = NsharpConstants.COLOR_NOTATION_Y_ORIG; - private int dtNextPageEnd = NsharpConstants.DATA_TIMELINE_NEXT_PAGE_END_; - private int charHeight = NsharpConstants.CHAR_HEIGHT_; - private int dtXOrig = NsharpConstants.DATA_TIMELINE_X_ORIG; - private int dtYOrig = NsharpConstants.DATA_TIMELINE_Y_ORIG; - private int dtWidth = NsharpConstants.DATA_TIMELINE_WIDTH; - private String paneConfigurationName; - private int numTimeLinePerPage=1; - /* Hodograph Modes - definition is based on definitions in globals_xw.h of BigNsharp */ - private static final int HODO_NORMAL = 0; - //private static int HODO_EFFECTIVE= 1; not used in BigNsharp source code - private static final int HODO_STORMRELATIVE= 2; - @SuppressWarnings("unused") - private static final int HODO_BNDRY= 3; - private static final int HODO_MEANWIND= 4; - @SuppressWarnings("unused") - private int currentHodoWindMode = HODO_MEANWIND; - private NsharpConfigManager configMgr; - private NsharpConfigStore configStore; - private NsharpGraphProperty graphConfigProperty; - private HashMap linePropertyMap; - private NsharpDataPageProperty dataPageProperty; - private int[] pageDisplayOrderNumberArray = new int[NsharpConstants.PAGE_MAX_NUMBER+1]; //index is the real page defined in NsharpConstants to be shown, value is the order number of this page. index 0 point to a dummy. - private boolean overlayIsOn = false; - private boolean interpolateIsOn = false; - private boolean compareSndIsOn = false; - private boolean compareStnIsOn = false; - private boolean compareTmIsOn = false; - private boolean editGraphOn=false; - private boolean getTimeMatcher=false; - public int TEMP_TYPE = 1; - public int DEWPOINT_TYPE = 2; - private int currentTempCurveType; - private int currentSoundingLayerIndex =0; - private int hodoEditingSoundingLayerIndex =0; - private boolean plotInteractiveTemp= false; - private Coordinate interactiveTempPointCoordinate; - public static final float INVALID_DATA = NsharpNativeConstants.NSHARP_NATIVE_INVALID_DATA; - protected static final double BARB_LENGTH = 3.5; - private String soundingType= null; - - protected DataTime displayedSounding; - - private int currentGraphMode= NsharpConstants.GRAPH_SKEWT; - - protected ListenerList listenerList = new ListenerList(); - - //current active sounding layer list - private List soundingLys = null; - private List previousSoundingLys = null; - private String pickedStnInfoStr; // current picked stn info with time line, e.g. "ATLH 101209/03(Thu)V003" - private NsharpStationInfo pickedStnInfo = null; - private IFrameCoordinator.FrameChangeOperation currentOpDirection = IFrameCoordinator.FrameChangeOperation.NEXT; // next =forward - private HashMap stormSlinkyColorMap = new HashMap(); - - private List>>stnTimeSndTable = new ArrayList< List>>(); - // stnTimeSndTable: - // Store all sounding profiles property for GUI display control - // 1st index refer to stnId, 2nd index refer to time line and 3rd point to sndType. - // It is same as [][][] 3d array. - // We dynamically expand this 3D array based on newly added stnid/timeline/sndType When a new sounding data is loaded, - // All unloaded element is null. Only when user load new sounding with this stnId/this time line/this sndType, then - // the element allocated. - // - // stn3-> T1--->T2--->T3->... - // ^ - // / - // stn2-> T1--->T2--->T3->... - // ^ - // / - //stn1-> T1--->T2--->T3->... - // | | | - // V V V - // snd1 snd1 snd1 - // | | | - // V V V - // snd2 snd2 snd2 - // | | | - // V V V - // stnTimeSndTable first dimension (station id) should be in sync with stnElementList, - // 2nd dimension (time line) should be in sync with timeElementList, and - // 3rd dimension (sounding type) should be in sync with sndTypeElementList - // NULL element in stnTimeSndTable indicates that sounding data is not loaded yet. - - private List stnElementList = new ArrayList(); - private List timeElementList = new ArrayList(); - private List sndElementList = new ArrayList(); - private NsharpSoundingElementStateProperty curSndProfileProp = null; - private NsharpSoundingElementStateProperty preSndProfileProp = null; - private int curTimeLinePage=1; - private int totalTimeLinePage=1; - private int curStnIdPage=1; - private int totalStnIdPage=1; - private int curSndPage=1; - private int totalSndPage=1; - private int previousTimeLineStateListIndex; - - private int currentStnElementListIndex=-1; //index to first dim of stnTimeSndTable and index to stnElementList - private int currentTimeElementListIndex=-1;//index to 2nd dim of stnTimeSndTable and index to timeElementList - private int currentSndElementListIndex=-1;//index to 3rd dim of stnTimeSndTable and index to sndElementList - - //use element state, NsharpConstants.LoadState or NsharpConstants.ActState, as key to set color for drawing - private HashMap elementColorMap = new HashMap(); - private short currentParcel = NsharpNativeConstants.PARCELTYPE_MOST_UNSTABLE; - private float currentParcelLayerPressure = NsharpNativeConstants.MU_LAYER; - private float smWindDir, smWindSpd; - - public List>> getStnTimeSndTable() { - return stnTimeSndTable; - } - public List getAllLoadedSndDesciptionList(){ - List strLst = new ArrayList(); - for(List> tlListList: stnTimeSndTable){ - // add a new element for the new sndType to each existing sndlist of each existing time of each existing stnId - for(List sndtyList: tlListList){ - for (NsharpSoundingElementStateProperty elem: sndtyList){ - if(elem!=null) - strLst.add(elem.getElementDescription()); - } - } - } - return strLst; - } - - public List getStnElementList() { - return stnElementList; - } - - - public List getTimeElementList() { - return timeElementList; - } - - - public List getSndElementList() { - return sndElementList; - } - - - public int getCurrentStnElementListIndex() { - return currentStnElementListIndex; - } - - - public int getCurrentTimeElementListIndex() { - return currentTimeElementListIndex; - } - - public int getTimeElementListSize(){ - return timeElementList.size(); - } - - public int getCurrentSndElementListIndex() { - return currentSndElementListIndex; - } - - - //shape and color storage - public class ShapeAndLineProperty { - IWireframeShape shape; - NsharpLineProperty lp; - public ShapeAndLineProperty() { - super(); - lp = new NsharpLineProperty(); - } - - } - public HashMap getLinePropertyMap() { - return linePropertyMap; - } - - - - public boolean isCompareStnIsOn() { - return compareStnIsOn; - } - public boolean isCompareTmIsOn() { - return compareTmIsOn; - } - - public boolean isCompareSndIsOn() { - return compareSndIsOn; - } - - - public boolean isOverlayIsOn() { - return overlayIsOn; - } - - - public NsharpNative getNsharpNative() { - return nsharpNative; - } - - - - public void setNextTextChapter(){ - if(currentTextChapter == displayDataPageMax){ - currentTextChapter = 1; - } - else - currentTextChapter++; - } - public void setNextInsetPage(){ - if(currentInsetPage == INSETPAGEMAX){ - currentInsetPage = 1; - } - else - currentInsetPage++; - } - - - public void setOverlayIsOn(boolean overlay) { - previousSoundingLys=null; - previousTimeLineStateListIndex=-1; - preSndProfileProp = null; - this.overlayIsOn = overlay; - - if(hodoPaneRsc!=null) - hodoPaneRsc.createRscHodoWindShapeAll(); - if(skewtPaneRsc!=null) - skewtPaneRsc.handleResize(); - } - - public boolean isInterpolateIsOn() { - return interpolateIsOn; - } - - /* - * When compareStnIsOn is changed, - */ - public void setCompareStnIsOn(boolean compareIsOn) { - this.compareStnIsOn = compareIsOn; - - //This is the case when sounding data is not available at currentTimeElementListIndex/currentSndElementListIndex/currentStnElementListIndex and user set - // compare stn on. - if(compareStnIsOn){ - if(soundingLys==null && currentTimeElementListIndex>=0 && currentSndElementListIndex>=0){ - //find a new available stn for current time and sndType - boolean found = false; - for(int i =0; i< stnElementList.size(); i++){ - if(stnElementList.get(i).getActionState() == NsharpConstants.ActState.ACTIVE - && stnTimeSndTable.get(i).get(currentTimeElementListIndex).get(currentSndElementListIndex)!=null){ - found = true; - currentStnElementListIndex = i; - } - - if(found) - break; - } - if(!found) - return; - } - - int colorIndex = NsharpConstants.LINE_COMP1; - for(NsharpOperationElement elm: stnElementList) { - int stnIndex = stnElementList.indexOf(elm); - NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable.get(stnIndex).get(currentTimeElementListIndex).get(currentSndElementListIndex); - if(stnTmElm!=null){ - stnTmElm.setCompColorIndex(colorIndex); - //if(colorIndex > NsharpConstants.LINE_COMP10) - // colorIndex = NsharpConstants.LINE_COMP1; - } - colorIndex++; - if(colorIndex > NsharpConstants.LINE_COMP10) - colorIndex = NsharpConstants.LINE_COMP1; - } - } - setCurSndProfileProp(); - setCurrentSoundingLayerInfo(); - resetData(); - } - - public void setCompareSndIsOn(boolean compareSndIsOn) { - this.compareSndIsOn = compareSndIsOn; - //This is the case when sounding data is not available at currentTimeElementListIndex/currentSndElementListIndex/currentStnElementListIndex and user set - // compSnd on - if(compareSndIsOn){ - if(soundingLys==null && currentStnElementListIndex >=0 && currentTimeElementListIndex >=0){ - //find a new available snd type for current time and stn - boolean found = false; - for(int i =0; i< sndElementList.size(); i++){ - if(sndElementList.get(i).getActionState() == NsharpConstants.ActState.ACTIVE - && stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).get(i)!=null){ - found = true; - currentSndElementListIndex = i; - } - if(found) - break; - } - if(!found) - return; - } - int colorIndex = NsharpConstants.LINE_COMP1; - for(NsharpOperationElement elm: sndElementList) { - int sndIndex = sndElementList.indexOf(elm); - NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).get(sndIndex); - if(stnTmElm!=null){ - stnTmElm.setCompColorIndex(colorIndex); - //if(colorIndex > NsharpConstants.LINE_COMP10) - // colorIndex = NsharpConstants.LINE_COMP1; - } - colorIndex++; - if(colorIndex > NsharpConstants.LINE_COMP10) - colorIndex = NsharpConstants.LINE_COMP1; - } - } - setCurSndProfileProp(); - setCurrentSoundingLayerInfo(); - resetData(); - - } - - - public void setCompareTmIsOn(boolean compareIsOn) { - this.compareTmIsOn = compareIsOn; - //This is the case when sounding data is not available at currentTimeElementListIndex/currentSndElementListIndex/currentStnElementListIndex and user set - // compTm on - if(compareIsOn){ - if(soundingLys==null && currentStnElementListIndex >=0 && currentSndElementListIndex >=0){ - //find a new available time line for current snd type and stn - boolean found = false; - for(int i =0; i< timeElementList.size(); i++){ - if(timeElementList.get(i).getActionState() == NsharpConstants.ActState.ACTIVE - && stnTimeSndTable.get(currentStnElementListIndex).get(i).get(currentSndElementListIndex)!=null){ - found = true; - currentTimeElementListIndex = i; - } - if(found) - break; - } - if(!found) - return; - } - int colorIndex = NsharpConstants.LINE_COMP1; - for(NsharpOperationElement elm: timeElementList) { - int tmIndex = timeElementList.indexOf(elm); - NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable.get(currentStnElementListIndex).get(tmIndex).get(currentSndElementListIndex); - if(stnTmElm!=null){ - stnTmElm.setCompColorIndex(colorIndex); - //if(colorIndex > NsharpConstants.LINE_COMP10) - // colorIndex = NsharpConstants.LINE_COMP1; - } - colorIndex++; - if(colorIndex > NsharpConstants.LINE_COMP10) - colorIndex = NsharpConstants.LINE_COMP1; - } - } - setCurSndProfileProp(); - setCurrentSoundingLayerInfo(); - resetData(); - } - - public void setEditGraphOn(boolean editGraphOn) { - this.editGraphOn = editGraphOn; - } - - public boolean isEditGraphOn() { - return editGraphOn; - } - - - public int getCurrentGraphMode() { - return currentGraphMode; - } - - public void setCurrentGraphMode(int currentGraphMode) { - this.currentGraphMode = currentGraphMode; - if(skewtPaneRsc!=null) - skewtPaneRsc.setCurrentGraphMode(currentGraphMode); - refreshPane(); - } - - - public short getCurrentParcel() { - return currentParcel; - } - - //native nsharp c/fortran lib - //NsharpNative is native nsharp lib awips/lib/libnsharp.so wrapper class - - public float getSmWindDir() { - return smWindDir; - } - public float getSmWindSpd() { - return smWindSpd; - } - - public void setCurrentHodoWindMode(int cursorPositionIndex) { - switch(cursorPositionIndex){ - case 0: - this.currentHodoWindMode = HODO_NORMAL; - break; - case 1: - this.currentHodoWindMode = HODO_STORMRELATIVE; - break; - case 2: - default: - this.currentHodoWindMode = HODO_MEANWIND; - break; - } - } - - public NsharpStationInfo getPickedStnInfo() { - return pickedStnInfo; - } - public String getSoundingType() { - return soundingType; - } - - - public void setSoundingType(String soundingType) { - this.soundingType = soundingType; - } - - public void setCurrentParcel(short currentParcel) { - this.currentParcel = currentParcel; - currentParcelLayerPressure=NsharpNativeConstants.parcelToLayerMap.get(currentParcel); - //inform data/skewT panel as well - if(dataPaneRsc!=null){ - dataPaneRsc.setCurrentParcel(currentParcel); - } - if(skewtPaneRsc!=null){ - if(currentParcel == NsharpNativeConstants.PARCELTYPE_USER_DEFINED) - currentParcelLayerPressure = NsharpParcelDialog.getUserDefdParcelMb(); - skewtPaneRsc.createRscParcelTraceShapes(currentParcel,currentParcelLayerPressure); - skewtPaneRsc.createRscParcelRtTraceShapesList(currentParcel,currentParcelLayerPressure); - skewtPaneRsc.createLCLEtcLinesShape(); - } - } - - public void updateParcelFromPanel(short currentParcel){ - this.currentParcel = currentParcel; - currentParcelLayerPressure=NsharpNativeConstants.parcelToLayerMap.get(currentParcel); - if(skewtPaneRsc!=null){ - skewtPaneRsc.createRscParcelTraceShapes(currentParcel,currentParcelLayerPressure); - skewtPaneRsc.createRscParcelRtTraceShapesList(currentParcel,currentParcelLayerPressure); - skewtPaneRsc.createLCLEtcLinesShape(); - } - } - - public void setHodoStmCenter(Coordinate hodoHouseC) { - if(hodoPaneRsc==null) - return; - //hodoPaneRsc.setHodoHouseC(hodoHouseC); - Coordinate c = hodoPaneRsc.getHodoBackground().getWorld().unMap(hodoHouseC.x, hodoHouseC.y); - c = WxMath.speedDir((float) c.x, (float) c.y); - smWindDir = (float) c.y; - smWindSpd = (float)c.x; - nsharpNative.nsharpLib.set_storm(smWindSpd, smWindDir); - if(insetPaneRsc!=null){ - WGraphics WGc = insetPaneRsc.getPsblWatchTypeBackground().getWorld(); - insetPaneRsc.createBkgPsblWatchShape(WGc); - - //Sr wind vs Height graph shape need to recreate - WGc= insetPaneRsc.getSrWindsBackground().getWorld(); - insetPaneRsc.createRscSrWindShape(WGc); - } - if(skewtPaneRsc!=null){ - skewtPaneRsc.createEffectiveLayerLinesShape(); - skewtPaneRsc.updatePsblWatchColor(); - } - } - - //This function is called only when interpolation "on/off" is changed by user - public void resetInfoOnInterpolate(boolean interpolateIsOn) throws CloneNotSupportedException{ - //We dont want to assume previous interpolation on/off state. So, reset soundingLys any how. - this.interpolateIsOn = interpolateIsOn; - NsharpSoundingElementStateProperty elem = getCurSoundingElementStateProperty(); - if(elem!=null){ - if(interpolateIsOn==false){ - soundingLys = elem.getSndLyLst(); - - } - else{ - /* - //TTR829 - //interpolation is on - //we dont want to change original raw data, so use a deep copy - List intpSndLst = new ArrayList(); - for(NcSoundingLayer layer: elem.getSndLyLst() ) { - intpSndLst.add((NcSoundingLayer) layer.clone()); - } - - // interpolation - intpSndLst = performInterpolation(intpSndLst); - - soundingLys = intpSndLst;*/ - //end TTR829 - soundingLys = performInterpolation(soundingLys); - } - - - nsharpNative.populateSndgData(soundingLys); - if(skewtPaneRsc!=null) - skewtPaneRsc.resetData(soundingLys,previousSoundingLys); - if(hodoPaneRsc!=null) - hodoPaneRsc.resetData(soundingLys,previousSoundingLys); - if(witoPaneRsc!=null) - witoPaneRsc.resetData(soundingLys, previousSoundingLys); - if(dataPaneRsc!=null) - dataPaneRsc.resetData(soundingLys, previousSoundingLys); - if(insetPaneRsc!=null) - insetPaneRsc.resetData(soundingLys, previousSoundingLys); - - //re-create shape - if(skewtPaneRsc!=null) - skewtPaneRsc.handleResize(); - if(hodoPaneRsc!=null) - hodoPaneRsc.createRscHodoWindShapeAll(); - if(insetPaneRsc!=null) - insetPaneRsc.createInsetWireFrameShapes(); - if(witoPaneRsc!=null) - witoPaneRsc.createRscWireFrameShapes(); - - } - - } - - - public void handleNsharpEditorPartEvent(NsharpPartListener.PartEvent pStatus){ - switch(pStatus){ - case partActivated: - if(editorPartStatus != NsharpPartListener.PartEvent.partDeactivated){ - //repopulateSndgData(); - //resetRsc(); - resetData(); - } - - break; - default: - break; - } - editorPartStatus = pStatus; - } - public void resetRsc() { - restoreAllSoundingData(); - NsharpSoundingElementStateProperty elem = getCurSoundingElementStateProperty(); - if(elem!=null){ - this.soundingLys = elem.getSndLyLst(); - //Set default parcel trace data - currentParcel = NsharpNativeConstants.PARCELTYPE_MOST_UNSTABLE; - currentParcelLayerPressure = NsharpNativeConstants.MU_LAYER; - setSoundingInfo(this.soundingLys); - currentTextChapter = 1; - overlayIsOn = false; - interpolateIsOn = false; - compareStnIsOn = false; - compareSndIsOn = false; - compareTmIsOn = false; - editGraphOn = false; - if(skewtPaneRsc!=null) - skewtPaneRsc.setCurrentSkewTEditMode(NsharpConstants.SKEWT_EDIT_MODE_EDITPOINT); - resetData(); - } - - } - public synchronized void resetData(){ - //System.out.println("resetData called, rscHdr="+this.toString() + " pickedStnInfoStr="+pickedStnInfoStr+ " nsharpNative="+nsharpNative.toString()); - - //update active sounding layer and picked stn info - //re-populate snd data to nsharp native code lib for later calculating - nsharpNative.populateSndgData(soundingLys); - if(skewtPaneRsc!=null) - skewtPaneRsc.resetData(soundingLys,previousSoundingLys); - if(hodoPaneRsc!=null) - hodoPaneRsc.resetData(soundingLys,previousSoundingLys); - if(insetPaneRsc!=null) - insetPaneRsc.resetData(soundingLys, previousSoundingLys); - if(dataPaneRsc!=null) - dataPaneRsc.resetData(soundingLys, previousSoundingLys); - if(witoPaneRsc!=null) - witoPaneRsc.resetData(soundingLys, previousSoundingLys); - - NsharpShowTextDialog textarea = NsharpShowTextDialog.getAccess(); - if(textarea != null){ - textarea.refreshTextData(); - } - //if soundingLys is null, then we stop here, after reset data. - if(soundingLys == null) - return; - if(soundingLys.size() >0){ - //set initial hodohouseC - - // ----- set hodo circle at Bunkers Right, Chin according to TTR6065 or RaytheonTicket#10438 - FloatByReference dummy1= new FloatByReference(-999); - FloatByReference dummy2= new FloatByReference(-999); - FloatByReference bwdir= new FloatByReference(-999); - FloatByReference bwspd= new FloatByReference(-999); - nsharpNative.nsharpLib.bunkers_storm_motion(dummy1, dummy2, bwdir, bwspd); - //System.out.println("resetData windspd="+ bwspd.getValue()+ " dir="+bwdir.getValue()); - smWindSpd = bwspd.getValue(); - smWindDir = bwdir.getValue(); - nsharpNative.nsharpLib.set_storm(smWindSpd, smWindDir); - - //reset parcel - currentParcel = NsharpNativeConstants.PARCELTYPE_MOST_UNSTABLE; - currentParcelLayerPressure = NsharpNativeConstants.MU_LAYER; - //reset parcel dialog as well - if(NsharpParcelDialog.getAccess()!=null){ - NsharpParcelDialog.getAccess().resetUserDefParcel(); - } - /* Chin::: - * This api is called in many scenarios. - * User may want to keep his previous picked parcel type. - * Therefore, thdataPaneRsc.resetCurrentParcel should be called from - * other area that really meant to reset parcel type. - */ - } - //Chin: TBD remove handle resize here to fix sizing issue when swapped nsharp from side pane back to main pane - // but, may cause other problem? - //if(skewtPaneRsc!=null) - //skewtPaneRsc.handleResize(); - if(skewtPaneRsc!=null) - skewtPaneRsc.createRscWireFrameShapes(); - if(hodoPaneRsc!=null) - hodoPaneRsc.createRscHodoWindShapeAll(); - if(insetPaneRsc!=null) - insetPaneRsc.createInsetWireFrameShapes(); - if(witoPaneRsc!=null) - witoPaneRsc.createAllWireFrameShapes(); - } - private class NsharpOperationElementComparator implements Comparator{ - @Override - public int compare(NsharpOperationElement o1, NsharpOperationElement o2) { - - String s1tok1="";//, s1tok2=""; - String s2tok1="";//, s2tok2=""; - StringTokenizer st1 = new StringTokenizer(o1.getElementDescription()); - int tkCount1 = st1.countTokens(); - //System.out.println("ElementComparatorTimeLine o1="+o1.elementDescription+"c1 = "+tkCount1); - if(tkCount1 >= 1) - { - s1tok1 = st1.nextToken(); - } - else{ - return 0; - - } - //System.out.println("t1="+s1tok1+" t2="+s2tok1); - StringTokenizer st2 = new StringTokenizer(o2.getElementDescription()); - int tkCount2 = st2.countTokens(); - //System.out.println("ElementComparatorTimeLine o2="+o2.elementDescription+"c2 = "+tkCount2); - if(tkCount2 >= 1) - { - s2tok1 = st2.nextToken(); - } - else{ - return 0; - - } - //System.out.println("t1="+s2tok1+" t2="+s2tok2); - if(s1tok1.compareTo(s2tok1) == 0){ - return 0; - }else if (s1tok1.compareTo(s2tok1) < 0){ - return 1; - } else if (s1tok1.compareTo(s2tok1) > 0) { - return -1; - } - return 0; - } - } - - private int getIndexFromElementList(String targetDescription, List elemLst){ - for(NsharpOperationElement sndProp: elemLst){ - if(sndProp.getElementDescription().equals(targetDescription) ) - return elemLst.indexOf(sndProp); - - } - return -1; - } - - private void restoreAllSoundingData(){ - for(List> tlListList: stnTimeSndTable){ - // add a new element for the new sndType to each existing sndlist of each existing time of each existing stnId - for(List sndtyList: tlListList){ - for (NsharpSoundingElementStateProperty elem: sndtyList){ - if(elem!=null) - elem.restoreSndLyLstFromBackup(); - } - } - } - } - private int addElemToElemList(String elemDesc,List elemList){ - NsharpOperationElement elem = new NsharpOperationElement(elemDesc,NsharpConstants.ActState.ACTIVE); - elemList.add(elem); - Collections.sort(elemList, new NsharpOperationElementComparator()); - return elemList.indexOf(elem); - } - private void addNewSndToStnTimeSndTable(int sndIndex){ - for(List> tlListList: stnTimeSndTable){ - // add a new element for the new sndType to each existing sndlist of each existing time of each existing stnId - for(List sndtyList: tlListList){ - sndtyList.add(sndIndex,null); - } - } - } - private void addNewStnToStnTimeSndTable(int stnIndex){ - // Add new stnid to outer list of stnTimeSndTable - List> listListForNewStn = new ArrayList>(); - // based on new stn id, add list for each existing time line - for(int i=0; i sndListForTm = new ArrayList(); - for(int j=0; j< sndElementList.size(); j++ ){ - sndListForTm.add(null); - } - listListForNewStn.add(sndListForTm); - } - stnTimeSndTable.add(stnIndex, listListForNewStn); - } - private void addNewTimeToStnTimeSndTable(int timeIndex){ - for(List> tlListList: stnTimeSndTable){ - // based on sndTypeElementList - //create sndlist for the new time line for each existing stnid - List newSndList = new ArrayList(); - for(int i=0; i< sndElementList.size();i++ ){ - newSndList.add(null); - } - //add sndlist for the new time line to stn list - tlListList.add(timeIndex,newSndList); - } - } - private void addElementToTableAndLists(String stnId_timeLine_sndType,String stnId, String tmLine, String sndType, NsharpStationInfo stnInfo, List sndLyLst){ - //System.out.println("stn to be added "+ stnId + " timeline "+tmLine); - NsharpSoundingElementStateProperty newSndPropElem=null; - int tmIndex = getIndexFromElementList(tmLine, timeElementList); - int stnIndex = getIndexFromElementList(stnId, stnElementList); - int sndTpyeIndex = getIndexFromElementList(sndType, sndElementList); - currentTimeElementListIndex = tmIndex; - currentStnElementListIndex = stnIndex; - currentSndElementListIndex = sndTpyeIndex; - //based on these 3 indexes, we have 8 cases to handle. - if(tmIndex>=0 && stnIndex>=0 && sndTpyeIndex>=0){ - //CASE1: All 3 index are good (>=0) - if(stnTimeSndTable.get(stnIndex).get(tmIndex).get(sndTpyeIndex) != null) - // this sounding element is already loaded - return; - else { - //replace previously added "null" object with real NsharpSoundingElementStateProperty object - newSndPropElem = - new NsharpSoundingElementStateProperty(stnId_timeLine_sndType,stnId, tmLine, stnInfo, sndLyLst); - stnTimeSndTable.get(stnIndex).get(tmIndex).set(sndTpyeIndex, newSndPropElem); - } - } - else if (tmIndex >=0 ){ - if(stnIndex >=0 ){ - //CASE2 : tmIndex/stnIndex are good (>=0), sndTpyeIndex is bad (<0), a new snd type - //add new sndType to sndTypeElementList - currentSndElementListIndex = addElemToElemList(sndType,sndElementList ); - //Add new snd type to each snd type list of stnTimeSndTable - addNewSndToStnTimeSndTable(currentSndElementListIndex); - //replace previously added "null" object with real NsharpSoundingElementStateProperty object - newSndPropElem = - new NsharpSoundingElementStateProperty(stnId_timeLine_sndType, stnId, tmLine, stnInfo, sndLyLst); - stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).set(currentSndElementListIndex, newSndPropElem); - } - else{ - if(sndTpyeIndex >=0){ - //CASE3 : tmIndex/sndTpyeIndex are good, stnIndex is bad (<0), a new stnId - //add new stn to stnElementList - currentStnElementListIndex = addElemToElemList(stnId,stnElementList ); - // Add new stnid to outer list of stnTimeSndTable - addNewStnToStnTimeSndTable(currentStnElementListIndex); - //replace previously added "null" object with real NsharpSoundingElementStateProperty object - newSndPropElem = - new NsharpSoundingElementStateProperty(stnId_timeLine_sndType, stnId, tmLine, stnInfo, sndLyLst); - stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).set(currentSndElementListIndex, newSndPropElem); - - } - else{ - //CASE4 : tmIndex is good, stnIndex/sndTpyeIndex are bad (<0), new stnId and new snd type - //add new stn to stnElementList - currentStnElementListIndex = addElemToElemList(stnId,stnElementList ); - //add new sndType to sndTypeElementList - currentSndElementListIndex = addElemToElemList(sndType,sndElementList ); - //Add new snd type to each snd type list of stnTimeSndTable - addNewSndToStnTimeSndTable(currentSndElementListIndex); - // Add new stnid to outer list of stnTimeSndTable - addNewStnToStnTimeSndTable(currentStnElementListIndex); - //replace previously added "null" object with real NsharpSoundingElementStateProperty object - newSndPropElem = - new NsharpSoundingElementStateProperty(stnId_timeLine_sndType, stnId, tmLine, stnInfo, sndLyLst); - stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).set(currentSndElementListIndex, newSndPropElem); - - } - } - } - else{ - if(stnIndex >=0 ){ - if(sndTpyeIndex >=0){ - //CASE5 : stnIndex/sndTpyeIndex are good, tmIndex is bad (<0) - //add new time line to timeElementList - currentTimeElementListIndex = addElemToElemList(tmLine,timeElementList ); - //add new time line to StnTimeSndTable - addNewTimeToStnTimeSndTable(currentTimeElementListIndex); - //replace previously added "null" object with real NsharpSoundingElementStateProperty object - newSndPropElem = - new NsharpSoundingElementStateProperty(stnId_timeLine_sndType, stnId, tmLine, stnInfo, sndLyLst); - stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).set(currentSndElementListIndex, newSndPropElem); - - } - else{ - //CASE6 : stnIndex is good, tmIndex/sndTpyeIndex are bad (<0) - //add new time line to timeElementList - currentTimeElementListIndex = addElemToElemList(tmLine,timeElementList ); - //add new sndType to sndTypeElementList - currentSndElementListIndex = addElemToElemList(sndType,sndElementList ); - //Add new snd type to each snd type list of stnTimeSndTable - addNewSndToStnTimeSndTable(currentSndElementListIndex); - //add new time line to StnTimeSndTable - addNewTimeToStnTimeSndTable(currentTimeElementListIndex); - //replace previously added "null" object with real NsharpSoundingElementStateProperty object - newSndPropElem = - new NsharpSoundingElementStateProperty(stnId_timeLine_sndType, stnId, tmLine, stnInfo, sndLyLst); - stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).set(currentSndElementListIndex, newSndPropElem); - - } - - } - else{ - if(sndTpyeIndex >=0){ - //CASE7 : sndTpyeIndex is good, tmIndex/stnIndex are bad (<0) - //add new time line to timeElementList - currentTimeElementListIndex = addElemToElemList(tmLine,timeElementList ); - //add new stn to stnElementList - currentStnElementListIndex = addElemToElemList(stnId,stnElementList ); - //add new time line to StnTimeSndTable - addNewTimeToStnTimeSndTable(currentTimeElementListIndex); - // Add new stnid to outer list of stnTimeSndTable - addNewStnToStnTimeSndTable(currentStnElementListIndex); - //replace previously added "null" object with real NsharpSoundingElementStateProperty object - newSndPropElem = - new NsharpSoundingElementStateProperty(stnId_timeLine_sndType, stnId, tmLine, stnInfo, sndLyLst); - stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).set(currentSndElementListIndex, newSndPropElem); - - } - else{ - //CASE8 : All are bad (<0) - // an element with new time line, new stnId and new sndType - //add new time line to timeElementList - currentTimeElementListIndex = addElemToElemList(tmLine,timeElementList ); - //add new stn to stnElementList - currentStnElementListIndex = addElemToElemList(stnId,stnElementList ); - //add new sndType to sndTypeElementList - currentSndElementListIndex = addElemToElemList(sndType,sndElementList ); - - //Construct stnTimeSndTable - if(stnTimeSndTable.size()>0){ - List> listListForNewStn = new ArrayList>(); - // based on new stn id, add list for each existing time line - for(NsharpOperationElement tmElem: timeElementList){ - // based on each time line, add element for each existing sndType - List sndlistForTm = new ArrayList(); - for(NsharpOperationElement sndElem: sndElementList ){ - if(tmLine.equals(tmElem.getElementDescription()) && sndType.equals(sndElem.getElementDescription()) ){ - //only one case falls in this route as only one new loaded sounding data - newSndPropElem = - new NsharpSoundingElementStateProperty(stnId_timeLine_sndType, stnId, tmLine, stnInfo, sndLyLst); - - sndlistForTm.add(newSndPropElem); - } - else{ - //create for not avail sounding profiles - sndlistForTm.add(null); - } - } - listListForNewStn.add(sndlistForTm); - } - - //Now update stnTimeSndTable by adding "dummy" NsharpSoundingElementStateProperty to all exiting stn listList and time list - //Note that we have NOT added "listListForNewStn" to stnTimeSndTable yet. - //we have to update current table now - for(List> tlListList: stnTimeSndTable){ - // add a new element for the new sndType to each existing sndlist of each existing time of each existing stnId - for(List sndtyList: tlListList){ - sndtyList.add(currentSndElementListIndex,null); - } - // based on sndTypeElementList - //add a new sndlist for the new time line for each existing stnid - List newSndList = new ArrayList(); - for(int i=0;i< sndElementList.size();i++ ){ - { - newSndList.add(null); - } - } - tlListList.add(currentTimeElementListIndex,newSndList); - } - //finally, add this new stn list to table - stnTimeSndTable.add(currentStnElementListIndex, listListForNewStn); - } - else{ - //this is the case, we are adding first element to stnTimeSndTable - // need a new stn time line list to stnTimeSndTable - List newList = new ArrayList(); - List> newListList = new ArrayList>(); - - newSndPropElem = - new NsharpSoundingElementStateProperty(stnId_timeLine_sndType, stnId, tmLine,stnInfo, sndLyLst); - newList.add(newSndPropElem); - newListList.add(newList); - stnTimeSndTable.add(newListList); - curSndProfileProp=newSndPropElem; - return; - } - - } - } - } - setCurSndProfileProp(); - - } - private void setCurSndProfileProp() { - if(currentTimeElementListIndex <0 || currentTimeElementListIndex >= timeElementList.size()|| - currentStnElementListIndex < 0 || currentStnElementListIndex >= stnElementList.size() - || currentSndElementListIndex<0 || currentSndElementListIndex>= sndElementList.size()){ - curSndProfileProp = null; - preSndProfileProp = null; - } - else { - preSndProfileProp = curSndProfileProp; - curSndProfileProp = stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).get(currentSndElementListIndex); - } - } - private void cleanUpStnTimeSndTable(int stni, int tmi, int sndi){ - boolean found = false; - //find if this station is no longer in use - List> tlListList = stnTimeSndTable.get(stni); - for(List sndtyList: tlListList){ - for (NsharpSoundingElementStateProperty elem: sndtyList){ - if(elem!=null) { - found = true; - break; - } - } - if(found) - break; - } - if(!found){ - //This stn is no longer in use...delete it from stnTimeSndTable and stnElementList - stnElementList.remove(stni); - tlListList= stnTimeSndTable.remove(stni); - tlListList.clear(); - } - //find if this time line is no longer in use - found = false; - for (List> tmListListForStn: stnTimeSndTable){ - List sndtyListForTm = tmListListForStn.get(tmi); - for (NsharpSoundingElementStateProperty elem: sndtyListForTm){ - if(elem!=null) { - found = true; - break; - } - } - if(found) - break; - } - if(!found){ - //This time line is no longer in use...delete it from stnTimeSndTable and timeElementList - timeElementList.remove(tmi); - for (List> tmListListForStn: stnTimeSndTable){ - List sndtyListForTm = tmListListForStn.remove(tmi); - sndtyListForTm.clear(); - } - } - //find if this sounding type is no longer in use - found = false; - for (List> tmListListForStn: stnTimeSndTable){ - for(List sndtyListForTm : tmListListForStn){ - NsharpSoundingElementStateProperty elem= sndtyListForTm.get(sndi); - if(elem!=null) { - found = true; - break; - } - } - if(found) - break; - } - if(!found){ - //This sounding type is no longer in use...delete it from stnTimeSndTable and sndElementList - sndElementList.remove(sndi); - for (List> tmListListForStn: stnTimeSndTable){ - for(List sndtyListForTm : tmListListForStn){ - sndtyListForTm.remove(sndi); - } - } - } - - } - public boolean deleteRsc(List deletingDataTimeList){ - boolean curSndDeleted = false; - for(String dataTmLine: deletingDataTimeList){ - if(curSndProfileProp!=null && curSndProfileProp.getElementDescription().equals(dataTmLine)){ - curSndDeleted = true; - } - //find deleting element from stnTimeSndTable and null it - boolean setdone = false; - for(List> tlListList: stnTimeSndTable){ - for(List sndtyList: tlListList){ - for (NsharpSoundingElementStateProperty elem: sndtyList){ - if(elem!=null && dataTmLine.equals(elem.getElementDescription())){ - int sndi = sndtyList.indexOf(elem); - int tmi = tlListList.indexOf(sndtyList); - int stni = stnTimeSndTable.indexOf(tlListList); - sndtyList.set(sndtyList.indexOf(elem),null); - setdone = true; - // clean up stnTimeSndTable if a stn/timeline/snd is no longer in use - cleanUpStnTimeSndTable(stni,tmi,sndi); - break; - } - } - if(setdone) - break; - } - if(setdone) - break; - } - } - - if(curSndDeleted || soundingLys == null){ - //this is the case that we are deleting current snd, so, a new current snd should be selected - curSndProfileProp = null; - //find CurrentElementIndexes After Delete current snding - boolean found = false; - int stni=0; - for(List> tlListList: stnTimeSndTable){ - int timei=0; - for(List sndtyList: tlListList){ - int sndi=0; - for (NsharpSoundingElementStateProperty elem: sndtyList){ - if(elem!=null && stnElementList.get(stni).getActionState()== NsharpConstants.ActState.ACTIVE && - timeElementList.get(timei).getActionState()== NsharpConstants.ActState.ACTIVE && - sndElementList.get(sndi).getActionState()== NsharpConstants.ActState.ACTIVE){ - currentStnElementListIndex = stni; - currentSndElementListIndex = sndi; - currentTimeElementListIndex = timei; - found = true; - break; - } - sndi++; - } - if(found) - break; - timei++; - } - if(found) - break; - stni++; - } - if(!found){ - currentStnElementListIndex = -1; - currentSndElementListIndex = -1; - currentTimeElementListIndex = -1; - } - setCurSndProfileProp(); - } - else{ - // currentStnElementListIndex, currentSndElementListIndex and currentTimeElementListIndex may not point to right element - //after some elements are deleted. - currentStnElementListIndex = -1; - currentTimeElementListIndex = -1; - currentSndElementListIndex = -1; - if(curSndProfileProp!= null){ - boolean found = false; - for (List> tmListListForStn: stnTimeSndTable){ - for(List sndtyListForTm : tmListListForStn){ - for (NsharpSoundingElementStateProperty elem: sndtyListForTm){ - if(elem!=null && curSndProfileProp.getElementDescription().equals(elem.getElementDescription())){ - currentSndElementListIndex = sndtyListForTm.indexOf(elem); - currentTimeElementListIndex = tmListListForStn.indexOf(sndtyListForTm); - currentStnElementListIndex = stnTimeSndTable.indexOf(tmListListForStn); - found= true; - break; - } - } - if(found) - break; - } - if(found) - break; - } - } - } - setCurrentSoundingLayerInfo(); - resetData(); - System.out.println("num="+getFrameCount()); - return curSndDeleted; - // anything more to do? - } - public void deleteRscAll(){ - NsharpMapResource nsharpMapResource = NsharpMapResource.getOrCreateNsharpMapResource(); - nsharpMapResource.setPoints(null); - if(soundingLys!=null){ - soundingLys.clear(); - soundingLys=null; - } - if(previousSoundingLys!=null){ - previousSoundingLys.clear(); - previousSoundingLys = null; - } - if(stnTimeSndTable != null){ - for(List> stnListList: stnTimeSndTable){ - for(List timeList: stnListList){ - timeList.clear(); - } - stnListList.clear(); - } - stnTimeSndTable.clear(); - } - if(timeElementList != null) - timeElementList.clear(); - if(stnElementList != null) - stnElementList.clear(); - if(sndElementList != null) - sndElementList.clear(); - curSndProfileProp = null; - preSndProfileProp = null; - currentTextChapter = 1; - currentInsetPage = 1; - currentParcel = NsharpNativeConstants.PARCELTYPE_MOST_UNSTABLE; - currentParcelLayerPressure = NsharpNativeConstants.MU_LAYER; - currentTimeElementListIndex = -1; - currentStnElementListIndex = -1; - currentSndElementListIndex = -1; - resetData(); - } - - - private NsharpSoundingElementStateProperty getCurSoundingElementStateProperty(){ - if(currentTimeElementListIndex >=0 && currentStnElementListIndex>=0 && currentSndElementListIndex>=0 && - stnTimeSndTable.get( currentStnElementListIndex).get( currentTimeElementListIndex).get(currentSndElementListIndex)!=null){ - return stnTimeSndTable.get( currentStnElementListIndex).get( currentTimeElementListIndex).get(currentSndElementListIndex); - } - return null; - } - private void setCurrentSoundingLayerInfo() { - NsharpSoundingElementStateProperty elem = getCurSoundingElementStateProperty(); - if(elem!=null){ - pickedStnInfoStr = elem.getElementDescription(); - pickedStnInfo = elem.getStnInfo(); - - if(overlayIsOn){ - previousSoundingLys = soundingLys; - } - else { - previousSoundingLys = null; - } - - if(interpolateIsOn == true){ - /* TTR829 - * deep copy is not necessary as performInterpolation() will re-allocate new layer for each - * layer - //we dont want to change original raw data, so use a new copy - NcSoundingLayer newLayer; - List mySndLst = new ArrayList(); - for(NcSoundingLayer layer:elem.getSndLyLst()){ - newLayer = new NcSoundingLayer(); - try { - newLayer = (NcSoundingLayer) layer.clone(); - - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } //here a shallowCopy is enough - mySndLst.add(newLayer); - } - // interpolation - mySndLst = performInterpolation(mySndLst); - - soundingLys = mySndLst; */ - - soundingLys = performInterpolation(elem.getSndLyLst()); - } - else { - soundingLys = elem.getSndLyLst(); - } - } - else{ - previousSoundingLys = null; - soundingLys = null; - } - - } - public void addRsc(Map> soundMap, NsharpStationInfo stnInfo, boolean fromNCP){ - if(fromNCP){ - //this is from NCP do nothing now - this.addRsc(true, soundMap, stnInfo); - //NCP case: - //Key String format will be like this for NCUAIR - // KGRI 100616/03(Wed)-NCUAIR - // and for PFC/Grid sounding will be like this - //KGRI 100616/03(Wed)V001-GFSSND - } - else{ - //D2D case:::: - //this is from D2D, edit display and time line string to add short day-of-week and - //also add sounding type to string to solve an issue that data with same stn, same time line but different - //sounding type will not be loaded. - //D2D's key string is like this: "KGRI 2010-06-16 03:00:00" - // will change it to "KGRI 100616/03(Wed)-GFSSND" - Set dataTimelineSet = soundMap.keySet(); - SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - //DateFormatSymbols dfs= new DateFormatSymbols(); - //String[] defaultDays = dfs.getShortWeekdays(); - Calendar cal =Calendar.getInstance(); - Date date; - Map> newmap = new HashMap> (); - String sndType = stnInfo.getSndType(); - for(String timeline: dataTimelineSet){ - System.out.println("D2D sending timeline Str:"+ timeline); - String dateStr = timeline.substring(timeline.indexOf(' ')+1); - String stnId= timeline.substring(0, timeline.indexOf(' ')); - try { - date = df.parse(dateStr); - cal.setTime(date); - String dayOfWeek = defaultDays[cal.get(Calendar.DAY_OF_WEEK)]; - //dateStr = timeline.substring(0, timeline.indexOf(':'))+dayOfWeek+stnInfo.getSndType(); - //System.out.println("New Str:"+ dateStr); - String finalTimeStr = String.format("%4$s %1$ty%1$tm%1$td/%1$tH(%2$s) %3$s", cal, dayOfWeek,sndType,stnId); - System.out.println("D2D (modified) timeline Str:"+ finalTimeStr); - //put newTimeStr to new map with original value - newmap.put(finalTimeStr, soundMap.get(timeline)); - } catch (ParseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - continue; - } - } - //this is from D2D, and it does not want to display new data right away. - this.addRsc(false, newmap, stnInfo); - } - } - /* - public void loadSoundingData( boolean displayNewData, List soundDataLst, String stnId, String sndType, - Timestamp rangeStartTime,double latitude,double longitude){ - //* testing code - //stnInfo.setStnId("KFSD"); - { - Set keyset= new HashSet(soundMap.keySet()); - for(String key: keyset) { - List sndLy = soundMap.remove(key); - String newkey= key.replace("NAMS", "yahoo"); - //String newkey= key.replace("GFSS", "NAMS"); - //newkey = newkey.replace("KSLN", "KFSD"); - soundMap.put(newkey, sndLy); - } - stnInfo.setSndType(stnInfo.getSndType().replace("NAMS", "yahoo")); - //stnInfo.setSndType(stnInfo.getSndType().replace("GFSS", "NAMS")); - }// - - //need to format reftime to GMT time string. Timestamp.toString produce a local time Not GMT time - Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); - cal.setTimeInMillis(rangeStartTime.getTime()); - String dayOfWeek = defaultDays[cal.get(Calendar.DAY_OF_WEEK)]; - String timeLine = String.format("%1$ty%1$tm%1$td/%1$tH(%2$s)", cal, dayOfWeek); - if(stnId.indexOf(" ")>=0){ - //take care stnId with SPACE case. - stnId = stnId.replace(" ", "_"); - } - if(timeElementList.isEmpty() || stnElementList.isEmpty() || - currentSndElementListIndex < 0 ||sndElementList.isEmpty() || - currentTimeElementListIndex < 0 || currentStnElementListIndex < 0){ - //if no data was loaded since, then display this data any way - displayNewData = true; - } - //save current timeline and stn state properties if we are NOT loading new data - NsharpOperationElement currentTL=null; - NsharpOperationElement currentStn=null; - NsharpOperationElement currentSnd=null; - NsharpSoundingElementStateProperty currentPreSndProfileProp=null; - if(!displayNewData){ - currentTL = timeElementList.get(currentTimeElementListIndex); - currentStn = stnElementList.get(currentStnElementListIndex); - currentSnd = sndElementList.get(currentSndElementListIndex); - currentPreSndProfileProp = preSndProfileProp; - } - //add new data to table - //add time line to stnTimeTable and set its index - addElementToTableAndLists((stnId+" "+timeLine+" "+sndType),stnId,timeLine,sndType,stnInfo, soundDataLst); - - if(displayNewData){ - //Set default parcel trace data - currentParcel = NsharpNativeConstants.PARCELTYPE_MOST_UNSTABLE; - currentParcelLayerPressure = NsharpNativeConstants.MU_LAYER; - setCurrentSoundingLayerInfo(); - resetData(); - } - else { - //Not display new data. Reset current "parameter"s after adding data to map/lists - currentStnElementListIndex= stnElementList.indexOf(currentStn); - currentTimeElementListIndex = timeElementList.indexOf(currentTL); - currentSndElementListIndex = sndElementList.indexOf(currentSnd); - preSndProfileProp = currentPreSndProfileProp; - curSndProfileProp = stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).get(currentSndElementListIndex); - } - - //set total time line group and stn id list page number - calculateTimeStnBoxData(); - - //set data time to descriptor - //this is necessary for looping - // starting 13.2.1, this line is changed by Raytheon - if (( skewtPaneRsc.getDescriptor().getFramesInfo().getFrameCount() == 0)&& !getTimeMatcher) { - //was this line before 13.2.1 if (( skewtPaneRsc.getDescriptor().getTimeMatcher() == null || skewtPaneRsc.getDescriptor().getTimeMatcher().getTimeMatchBasis() == null)&& !getTimeMatcher) { - //DataTime[] dataTimes = new DataTime[dataTimelineList.size()]; - //Chin Note: we just have to do this once and set dataTimes size bigger than 1. - //Nsharp handles changing frame itself. It just need system to send change frame notice. - //That is happened at NsharpSkewTDescriptor.checkDrawTime(). - DataTime[] dataTimes = new DataTime[2]; - Date now = new Date(); - for(int k =0; k < 2 ; k++){ - dataTimes[k]= new DataTime(now, k); - } - //no need to get a descriptor from a renderableDispaly since we have a descriptor - skewtPaneRsc.getDescriptor().setDataTimes(dataTimes); - getTimeMatcher=true; + private IRenderableDisplay[] displayArray = null; + + private NsharpPartListener.PartEvent editorPartStatus = NsharpPartListener.PartEvent.partClosed; + + private NsharpSkewTPaneResource skewtPaneRsc; + + private NsharpWitoPaneResource witoPaneRsc; + + private NsharpHodoPaneResource hodoPaneRsc; + + private NsharpTimeStnPaneResource timeStnPaneRsc; + + private NsharpInsetPaneResource insetPaneRsc; + + private NsharpDataPaneResource dataPaneRsc; + + private NsharpSpcGraphsPaneResource spcGraphsPaneRsc; + + private NsharpAbstractPaneResource futurePaneRsc; + + private String[] defaultDays; + + NsharpNative nsharpNative = null; + + private int displayDataPageMax; + + private static final int INSETPAGEMAX = 2; + + private int currentTextChapter = 1; + + private int currentInsetPage = 1; + + private int cnYOrig = NsharpConstants.COLOR_NOTATION_Y_ORIG; + + private int dtNextPageEnd = NsharpConstants.DATA_TIMELINE_NEXT_PAGE_END_; + + private double charHeight = NsharpConstants.CHAR_HEIGHT_; + + // d2dlite + private double lineHeight = charHeight; + + private int dtXOrig = NsharpConstants.DATA_TIMELINE_X_ORIG; + + private int dtYOrig = NsharpConstants.DATA_TIMELINE_Y_ORIG; + + private int dtWidth = NsharpConstants.DATA_TIMELINE_WIDTH; + + private String paneConfigurationName; + + private int numTimeLinePerPage = 1; + + /* + * Hodograph Modes - definition is based on definitions in globals_xw.h of + * BigNsharp + */ + private static final int HODO_NORMAL = 0; + + // private static int HODO_EFFECTIVE= 1; not used in BigNsharp source code + private static final int HODO_STORMRELATIVE = 2; + + @SuppressWarnings("unused") + private static final int HODO_BNDRY = 3; + + private static final int HODO_MEANWIND = 4; + + @SuppressWarnings("unused") + private int currentHodoWindMode = HODO_MEANWIND; + + private NsharpConfigManager configMgr; + + private NsharpConfigStore configStore; + + private NsharpGraphProperty graphConfigProperty; + + private HashMap linePropertyMap; + + private NsharpDataPageProperty dataPageProperty; + + private int[] pageDisplayOrderNumberArray = new int[NsharpConstants.PAGE_MAX_NUMBER + 1]; + + // index is the real page defined in NsharpConstants to be shown, value is + // the order number of this page. + // index 0 point to a dummy. + + private boolean overlayIsOn = false; + + private boolean interpolateIsOn = false; + + private boolean compareSndIsOn = false; + + private boolean compareStnIsOn = false; + + private boolean compareTmIsOn = false; + + private boolean editGraphOn = false; + + private boolean getTimeMatcher = false; + + public int TEMP_TYPE = 1; + + public int DEWPOINT_TYPE = 2; + + private int currentTempCurveType; + + private int currentSoundingLayerIndex = 0; + + private int hodoEditingSoundingLayerIndex = 0; + + private boolean plotInteractiveTemp = false; + + private Coordinate interactiveTempPointCoordinate; + + public static final float INVALID_DATA = NsharpNativeConstants.NSHARP_NATIVE_INVALID_DATA; + + protected static final double BARB_LENGTH = 3.5; + + private String soundingType = null; + + protected DataTime displayedSounding; + + private int currentGraphMode = NsharpConstants.GRAPH_SKEWT; + + protected ListenerList listenerList = new ListenerList(); + + // current active sounding layer list + private List soundingLys = null; + + private List previousSoundingLys = null; + + private String pickedStnInfoStr; // current picked stn info with time line + // and sounding source, + // e.g. "ATLH 101209/03(Thu)V003 GFS230" + + private NsharpStationInfo pickedStnInfo = null; + + private IFrameCoordinator.FrameChangeOperation currentOpDirection = IFrameCoordinator.FrameChangeOperation.NEXT; // next + // =forward + + private HashMap stormSlinkyColorMap = new HashMap(); + + private List>> stnTimeSndTable = new ArrayList>>(); + + // stnTimeSndTable: + // Store all sounding profiles property for GUI display control + // 1st index refer to stnId, 2nd index refer to time line and 3rd point to + // sndType. + // It is same as [][][] 3d array. + // We dynamically expand this 3D array based on newly added + // stnid/timeline/sndType When a new sounding data is loaded, + // All unloaded element is null. Only when user load new sounding with this + // stnId/this time line/this sndType, then + // the element allocated. + // + // stn3-> T1--->T2--->T3->... + // ^ + // / + // stn2-> T1--->T2--->T3->... + // ^ + // / + // stn1-> T1--->T2--->T3->... + // | | | + // V V V + // snd1 snd1 snd1 + // | | | + // V V V + // snd2 snd2 snd2 + // | | | + // V V V + // stnTimeSndTable first dimension (station id) should be in sync with + // stnElementList, + // 2nd dimension (time line) should be in sync with timeElementList, and + // 3rd dimension (sounding type) should be in sync with sndTypeElementList + // NULL element in stnTimeSndTable indicates that sounding data is not + // loaded yet. + + private List stnElementList = new ArrayList(); + + private List timeElementList = new ArrayList(); + + private List sndElementList = new ArrayList(); + + private NsharpSoundingElementStateProperty curSndProfileProp = null; + + private NsharpSoundingElementStateProperty preSndProfileProp = null; + + private int curTimeLinePage = 1; + + private int totalTimeLinePage = 1; + + private int curStnIdPage = 1; + + private int totalStnIdPage = 1; + + private int curSndPage = 1; + + private int totalSndPage = 1; + + private int previousTimeLineStateListIndex; + + private int currentStnElementListIndex = -1; // index to first dim of + // stnTimeSndTable and index to + // stnElementList + + private int currentTimeElementListIndex = -1;// index to 2nd dim of + // stnTimeSndTable and index to + // timeElementList + + private int currentSndElementListIndex = -1;// index to 3rd dim of + // stnTimeSndTable and index to + // sndElementList + + // use element state, NsharpConstants.LoadState or NsharpConstants.ActState, + // as key to set color for drawing + private HashMap elementColorMap = new HashMap(); + + private short currentParcel = NsharpNativeConstants.PARCELTYPE_MOST_UNSTABLE; + + private float currentParcelLayerPressure = NsharpNativeConstants.MU_LAYER; + + private float smWindDir, smWindSpd; + + // start FixMark:nearByStnCompSnd + public class CompSndSelectedElem { + private int stnIndex; + + private int timeIndex; + + private int sndIndex; + + public CompSndSelectedElem(int stnIndex, int timeIndex, int sndIndex) { + super(); + this.stnIndex = stnIndex; + this.timeIndex = timeIndex; + this.sndIndex = sndIndex; } - NsharpShowTextDialog textarea = NsharpShowTextDialog.getAccess(); - if(textarea != null){ - textarea.refreshTextData(); - } - NsharpPaletteWindow win = NsharpPaletteWindow.getInstance() ; - if(win!=null) - currentGraphMode=win.getCurrentGraphMode(); - - refreshPane(); - - } - */ - - private void addRsc( boolean displayNewData,Map> soundMap, NsharpStationInfo stnInfo){ - /* testing code - stnInfo.setStnId("KUKI"); - { - Set keyset= new HashSet(soundMap.keySet()); - for(String key: keyset) { - List sndLy = soundMap.remove(key); - //String newkey= key.replace("NCUAIR", "gpduair"); - String newkey= key.replace("NAMS","GFSS"); - newkey = newkey.replace("AJO", "KUKI"); - soundMap.put(newkey, sndLy); - } - //stnInfo.setSndType(stnInfo.getSndType().replace("NCUAIR", "gpduair")); - stnInfo.setSndType(stnInfo.getSndType().replace( "NAMS","GFSS")); - }//*/ - - - if(stnInfo.getStnId() != null && stnInfo.getStnId().indexOf(" ")>=0){ - //take care stnId with SPACE case. - String stnId= stnInfo.getStnId(); - String newStnId = stnId.replace(" ", "_"); - stnInfo.setStnId(newStnId); - String dspInfo= stnInfo.getStnDisplayInfo(); - stnInfo.setStnDisplayInfo(dspInfo.replace(stnId, newStnId)); - Set keyset= new HashSet(soundMap.keySet()); - for(String key: keyset) { - List sndLy = soundMap.remove(key); - String newkey= key.replace(stnId, newStnId); - soundMap.put(newkey, sndLy); - } - - } - - if(soundMap.size() <=0 || (skewtPaneRsc==null)){ - return; - } - if(timeElementList.isEmpty() || stnElementList.isEmpty() || - currentSndElementListIndex < 0 ||sndElementList.isEmpty() || - currentTimeElementListIndex < 0 || currentStnElementListIndex < 0){ - //if no data was loaded since, then display this data any way - displayNewData = true; - } - //save current timeline and stn state properties if we are NOT loading new data - NsharpOperationElement currentTL=null; - NsharpOperationElement currentStn=null; - NsharpOperationElement currentSnd=null; - NsharpSoundingElementStateProperty currentPreSndProfileProp=null; - if(!displayNewData){ - currentTL = timeElementList.get(currentTimeElementListIndex); - currentStn = stnElementList.get(currentStnElementListIndex); - currentSnd = sndElementList.get(currentSndElementListIndex); - currentPreSndProfileProp = preSndProfileProp; - } - //add new data to table - Set dataTimelineSet = soundMap.keySet(); - String[] tempTimeLineArr = dataTimelineSet.toArray(new String[dataTimelineSet.size()]); - Arrays.sort(tempTimeLineArr); - for (int i=0; i< tempTimeLineArr.length; i++){ - // based on this KEY string format "KGRI 100616/03(Wed) GFSSND" - String stnId_timeLine_sndType = tempTimeLineArr[i].toString(); - String stnId = stnId_timeLine_sndType.substring(0,stnId_timeLine_sndType.indexOf(" ")); - String timeLine_sndType= stnId_timeLine_sndType.substring(stnId_timeLine_sndType.indexOf(" ")+1); - String timeLine= timeLine_sndType.substring(0,timeLine_sndType.indexOf(" ")); - String sndType= timeLine_sndType.substring(timeLine_sndType.indexOf(" ")+1); - //No more needed? timeLine = timeLine.replace(" ", "-"); //fixed DR15325 - sorting time line issue in D2D - //add time line to stnTimeTable and set its index - addElementToTableAndLists(stnId_timeLine_sndType,stnId,timeLine,sndType,stnInfo, soundMap.get(stnId_timeLine_sndType)); - } - if(displayNewData){ - //Set default parcel trace data - currentParcel = NsharpNativeConstants.PARCELTYPE_MOST_UNSTABLE; - currentParcelLayerPressure = NsharpNativeConstants.MU_LAYER; - setCurrentSoundingLayerInfo(); - resetData(); - } - else { - //Not display new data. Reset current "parameter"s after adding data to map/lists - currentStnElementListIndex= stnElementList.indexOf(currentStn); - currentTimeElementListIndex = timeElementList.indexOf(currentTL); - currentSndElementListIndex = sndElementList.indexOf(currentSnd); - preSndProfileProp = currentPreSndProfileProp; - curSndProfileProp = stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).get(currentSndElementListIndex); - } - - //set total time line group and stn id list page number - calculateTimeStnBoxData(); - - //set data time to descriptor - //this is necessary for looping - // starting 13.2.1, this line is changed by Raytheon - if (( skewtPaneRsc.getDescriptor().getFramesInfo().getFrameCount() == 0)&& !getTimeMatcher) { - //was this line before 13.2.1 if (( skewtPaneRsc.getDescriptor().getTimeMatcher() == null || skewtPaneRsc.getDescriptor().getTimeMatcher().getTimeMatchBasis() == null)&& !getTimeMatcher) { - //DataTime[] dataTimes = new DataTime[dataTimelineList.size()]; - //Chin Note: we just have to do this once and set dataTimes size bigger than 1. - //Nsharp handles changing frame itself. It just need system to send change frame notice. - //That is happened at NsharpSkewTDescriptor.checkDrawTime(). - DataTime[] dataTimes = new DataTime[2/*stnTimeTable.size()*/]; - Date now = new Date(); - for(int k =0; k < 2/*stnTimeTable.size()*/ ; k++){ - dataTimes[k]= new DataTime(now, k); - } - //no need to get a descriptor from a renderableDispaly since we have a descriptor - skewtPaneRsc.getDescriptor().setDataTimes(dataTimes); - getTimeMatcher=true; - } - - NsharpShowTextDialog textarea = NsharpShowTextDialog.getAccess(); - if(textarea != null){ - textarea.refreshTextData(); - } - NsharpPaletteWindow win = NsharpPaletteWindow.getInstance() ; - if(win!=null) - currentGraphMode=win.getCurrentGraphMode(); - - refreshPane(); - - } - - public void addRsc(Map> soundMap, NsharpStationInfo stnInfo){ - //by default, display new data - //NCP always call from this route. - this.addRsc(true, soundMap, stnInfo); - return; - } - public String getPickedStnInfoStr() { - return pickedStnInfoStr; - } - //start FixMark:clickOnTimeStnPane - private void handleUserPickNewStationId(int index){ - currentStnElementListIndex = index; - if(compareTmIsOn){ - boolean found = false; - if( currentTimeElementListIndex>=0 && currentSndElementListIndex>=0 && - stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).get(currentSndElementListIndex)!=null){ - // use currentTimeLineStateListIndex - found = true; - } - else { - //find an active and available timeline for this stn and set is as current - for (int i=0; i < timeElementList.size(); i++){ - if(timeElementList.get(i).getActionState()== NsharpConstants.ActState.ACTIVE && - stnTimeSndTable.get(currentStnElementListIndex).get(i).get(currentSndElementListIndex)!=null){ - currentTimeElementListIndex = i; - found = true; - break; - } - } - } - if(!found){ - currentTimeElementListIndex = -1; - } - else{ - int colorIndex = NsharpConstants.LINE_COMP1; - for(NsharpOperationElement elm: timeElementList) { - if(elm.getActionState() == NsharpConstants.ActState.INACTIVE) - continue; - int tmIndex = timeElementList.indexOf(elm); - NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable.get(currentStnElementListIndex).get(tmIndex).get(currentSndElementListIndex); - if(stnTmElm!=null){ - stnTmElm.setCompColorIndex(colorIndex); - } - colorIndex++; - if(colorIndex > NsharpConstants.LINE_COMP10) - colorIndex = NsharpConstants.LINE_COMP1; - - } - } - } - else if(compareSndIsOn){ - boolean found = false; - if( currentTimeElementListIndex>=0 && currentSndElementListIndex>=0 && - stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).get(currentSndElementListIndex)!=null){ - found = true; - } - else { - //find an active and available snd for this stn and set is as current - for (int i=0; i < sndElementList.size(); i++){ - if(sndElementList.get(i).getActionState()== NsharpConstants.ActState.ACTIVE && - stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).get(i)!=null){ - currentSndElementListIndex = i; - found = true; - break; - } - } - } - if(!found){ - currentSndElementListIndex = -1; - } - else{ - int colorIndex = NsharpConstants.LINE_COMP1; - for(NsharpOperationElement elm: sndElementList) { - if(elm.getActionState() == NsharpConstants.ActState.INACTIVE) - continue; - int sndIndex = sndElementList.indexOf(elm); - NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).get(sndIndex); - if(stnTmElm!=null){ - stnTmElm.setCompColorIndex(colorIndex); - } - colorIndex++; - if(colorIndex > NsharpConstants.LINE_COMP10) - colorIndex = NsharpConstants.LINE_COMP1; - } - } - } - setCurSndProfileProp(); - setCurrentSoundingLayerInfo(); - resetData(); - refreshPane(); - } // end FixMark:clickOnTimeStnPane - public void handleUserClickOnStationId(Coordinate c,boolean shiftDown) { - //first to find if it is for change to next page, or change sorting - //System.out.println("numTimeLinePerPage="+numTimeLinePerPage+"gap="+(cnYOrig-dtNextPageEnd)); - int index =((int)(c.y - dtYOrig))/ charHeight; - - if(index == 0 ){ - //change to next/previous page - if( totalStnIdPage == 1 ) - return; - if((c.x - (dtXOrig+dtWidth)) < (dtWidth/2)){ - curStnIdPage++; - if(curStnIdPage>totalStnIdPage) - curStnIdPage=1; - } else { - curStnIdPage--; - if(curStnIdPage <=0) - curStnIdPage = totalStnIdPage; - } - return; - } - // recalculate index for time line - index =((int)(c.y - dtNextPageEnd))/ charHeight + - (curStnIdPage-1)* numTimeLinePerPage ; - - if( index < this.stnElementList.size() ){ - // FixMark:clickOnTimeStnPane start - NsharpConstants.ActState actState = stnElementList.get(index).getActionState(); - if(!shiftDown ){ - if( actState == NsharpConstants.ActState.ACTIVE) - handleUserPickNewStationId(index); - } - else { // End FixMark:clickOnTimeStnPane - - switch(actState){ - - case INACTIVE: - stnElementList.get(index).setActionState( NsharpConstants.ActState.ACTIVE); - break; - case ACTIVE: - //do not allow deactivate current stn - if(index == currentStnElementListIndex) - return; - stnElementList.get(index).setActionState( NsharpConstants.ActState.INACTIVE); - break; - default: - return; - } - if(skewtPaneRsc!=null) - skewtPaneRsc.createRscWireFrameShapes(); - if(hodoPaneRsc!=null) - hodoPaneRsc.createRscHodoWindShapeAll(); - } - } - } - // start FixMark:clickOnTimeStnPane - private void handleUserPickNewTimeLine(int index){ - previousTimeLineStateListIndex = currentTimeElementListIndex; - currentTimeElementListIndex = index; - if(compareStnIsOn){ - boolean found = false; - if(currentStnElementListIndex >=0 && currentSndElementListIndex >=0 && - stnTimeSndTable.get(currentStnElementListIndex).get(index).get(currentSndElementListIndex)!=null){ - found = true; - } - else{ - //find an active and available stn for this timeline and set is as current - for (int i=0; i < stnElementList.size(); i++){ - if(stnElementList.get(i).getActionState()==NsharpConstants.ActState.ACTIVE && - stnTimeSndTable.get(i).get(index).get(currentSndElementListIndex) !=null){ - currentStnElementListIndex = i; - found = true; - break; - } - } - } - if(!found){ - currentStnElementListIndex = -1; - } - else{ - int colorIndex = NsharpConstants.LINE_COMP1; - for(NsharpOperationElement elm: stnElementList) { - int stnIndex = stnElementList.indexOf(elm); - NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable.get(stnIndex).get(index).get(currentSndElementListIndex); - if(stnTmElm != null){ - stnTmElm.setCompColorIndex(colorIndex); - } - colorIndex++; - if(colorIndex > NsharpConstants.LINE_COMP10) - colorIndex = NsharpConstants.LINE_COMP1; - } - } - } - else if(compareSndIsOn){ - boolean found = false; - if(currentStnElementListIndex >=0 && currentSndElementListIndex >=0 && - stnTimeSndTable.get(currentStnElementListIndex).get(index).get(currentSndElementListIndex)!=null){ - found = true; - } - else { - //find an active and available snd for this stn and set is as current - for (int i=0; i < sndElementList.size(); i++){ - if(sndElementList.get(i).getActionState()== NsharpConstants.ActState.ACTIVE && - stnTimeSndTable.get(currentStnElementListIndex).get(index).get(i)!=null){ - currentSndElementListIndex = i; - found = true; - break; - } - } - } - if(!found){ - currentSndElementListIndex = -1; - } - else{ - int colorIndex = NsharpConstants.LINE_COMP1; - for(NsharpOperationElement elm: sndElementList) { - if(elm.getActionState() == NsharpConstants.ActState.INACTIVE) - continue; - int sndIndex = sndElementList.indexOf(elm); - NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable.get(currentStnElementListIndex).get(index).get(sndIndex); - if(stnTmElm!=null){ - stnTmElm.setCompColorIndex(colorIndex); - } - colorIndex++; - if(colorIndex > NsharpConstants.LINE_COMP10) - colorIndex = NsharpConstants.LINE_COMP1; - } - } - } - setCurSndProfileProp(); - setCurrentSoundingLayerInfo(); - resetData(); - refreshPane(); - } // end FixMark:clickOnTimeStnPane - public void handleUserClickOnTimeLine(Coordinate c, boolean shiftDown) { - - //first to find if it is for change to next/prev page - //System.out.println("numTimeLinePerPage="+numTimeLinePerPage+"gap="+(cnYOrig-dtNextPageEnd)); - int index =((int)(c.y - dtYOrig))/ charHeight; - if(index == 0 ){ - //change to next/previous page - if( totalTimeLinePage == 1) - return; - if((c.x - dtXOrig) < (dtWidth /2)){ - curTimeLinePage++; - if(curTimeLinePage>totalTimeLinePage) - curTimeLinePage=1; - } else { - curTimeLinePage--; - if(curTimeLinePage <=0) - curTimeLinePage = totalTimeLinePage; - } - return; - } - // recalculate index for time line - index =((int)(c.y - dtNextPageEnd))/ charHeight + - (curTimeLinePage-1)* numTimeLinePerPage ; - - if( index < timeElementList.size() && index >=0 ){ - // FixMark:clickOnTimeStnPane start - NsharpConstants.ActState actState = timeElementList.get(index).getActionState(); - if(!shiftDown ){ - if( actState == NsharpConstants.ActState.ACTIVE) - handleUserPickNewTimeLine(index); - } - else { - switch(actState){// End FixMark:clickOnTimeStnPane - case INACTIVE: - timeElementList.get(index).setActionState( NsharpConstants.ActState.ACTIVE); - break; - case ACTIVE: - if(index == currentTimeElementListIndex) - //dont allow to deactive current time line - return; - timeElementList.get(index).setActionState( NsharpConstants.ActState.INACTIVE); - break; - - default: - return; - - } - if(skewtPaneRsc!=null) - skewtPaneRsc.createRscWireFrameShapes(); - if(hodoPaneRsc!=null) - hodoPaneRsc.createRscHodoWindShapeAll(); - } - } - } - // start FixMark:clickOnTimeStnPane - private void handleUserPickNewSndLine(int index){ - currentSndElementListIndex = index; - if(compareTmIsOn){ - boolean found = false; - if(currentTimeElementListIndex>=0 && currentStnElementListIndex>=0 && - stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).get(currentSndElementListIndex)!=null){ - // use currentTimeLineStateListIndex - found = true; - } - else { - //find an active and available timeline for this stn and set is as current - for (int i=0; i < timeElementList.size(); i++){ - if(timeElementList.get(i).getActionState()== NsharpConstants.ActState.ACTIVE && - stnTimeSndTable.get(currentStnElementListIndex).get(i).get(currentSndElementListIndex)!=null){ - currentTimeElementListIndex = i; - found = true; - break; - } - } - } - if(!found){ - currentTimeElementListIndex = -1; - } - else{ - int colorIndex = NsharpConstants.LINE_COMP1; - for(NsharpOperationElement elm: timeElementList) { - if(elm.getActionState() == NsharpConstants.ActState.INACTIVE) - continue; - int tmIndex = timeElementList.indexOf(elm); - NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable.get(currentStnElementListIndex).get(tmIndex).get(currentSndElementListIndex); - if(stnTmElm!=null){ - stnTmElm.setCompColorIndex(colorIndex); - } - colorIndex++; - if(colorIndex > NsharpConstants.LINE_COMP10) - colorIndex = NsharpConstants.LINE_COMP1; - } - } - } - else if(compareStnIsOn){ - boolean found = false; - //find an active and available stn for this timeline and set is as current - if(currentTimeElementListIndex>=0 && currentStnElementListIndex>=0 && - stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).get(currentSndElementListIndex)!=null){ - found = true; - } - else { - for (int i=0; i < stnElementList.size(); i++){ - if(stnElementList.get(i).getActionState()==NsharpConstants.ActState.ACTIVE && - stnTimeSndTable.get(i).get(currentTimeElementListIndex).get(currentSndElementListIndex) !=null){ - currentStnElementListIndex = i; - found = true; - break; - } - } - } - if(!found){ - currentStnElementListIndex = -1; - } - else{ - int colorIndex = NsharpConstants.LINE_COMP1; - for(NsharpOperationElement elm: stnElementList) { - int stnIndex = stnElementList.indexOf(elm); - NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable.get(stnIndex).get(currentTimeElementListIndex).get(currentSndElementListIndex); - if(stnTmElm!=null){ - stnTmElm.setCompColorIndex(colorIndex); - } - colorIndex++; - if(colorIndex > NsharpConstants.LINE_COMP10) - colorIndex = NsharpConstants.LINE_COMP1; - - } - } - } - setCurSndProfileProp(); - setCurrentSoundingLayerInfo(); - resetData(); - refreshPane(); - } - //end FixMark:clickOnTimeStnPane - public void handleUserClickOnSndLine(Coordinate c, boolean shiftDown) { - - //first to find if it is for change to next/prev page - //System.out.println("numTimeLinePerPage="+numTimeLinePerPage+"gap="+(cnYOrig-dtNextPageEnd)); - int index =((int)(c.y - dtYOrig))/ charHeight; - if(index == 0 ){ - //change to next/previous page - if( totalSndPage == 1) - return; - if((c.x - dtXOrig) < (dtWidth/2)){ - curSndPage++; - if(curSndPage>totalSndPage) - curSndPage=1; - } else { - curSndPage--; - if(curSndPage <=0) - curSndPage = totalSndPage; - } - return; - } - // recalculate index for time line - index =((int)(c.y - dtNextPageEnd))/ charHeight + - (curSndPage-1)* numTimeLinePerPage ; - - if( index < sndElementList.size() && index >=0 ){ - // FixMark:clickOnTimeStnPane start - NsharpConstants.ActState actState = sndElementList.get(index).getActionState(); - if(!shiftDown ){ - if( actState == NsharpConstants.ActState.ACTIVE) - handleUserPickNewSndLine(index); - } - else { - switch(actState){// End FixMark:clickOnTimeStnPane - case INACTIVE: - sndElementList.get(index).setActionState( NsharpConstants.ActState.ACTIVE); - break; - case ACTIVE: - if(index == currentSndElementListIndex) - //dont allow to deactive current time line - return; - sndElementList.get(index).setActionState( NsharpConstants.ActState.INACTIVE); - break; - - default: - return; - - } - if(skewtPaneRsc!=null) - skewtPaneRsc.createRscWireFrameShapes(); - if(hodoPaneRsc!=null) - hodoPaneRsc.createRscHodoWindShapeAll(); - - } - } - } - - private void moveTimeLineIndexBackward(){ - previousTimeLineStateListIndex = currentTimeElementListIndex; - int counter=0; - while(true){ - currentTimeElementListIndex++; - currentTimeElementListIndex = currentTimeElementListIndex % this.timeElementList.size(); - counter++; - if(counter > timeElementList.size()) - break; - if( timeElementList.get(currentTimeElementListIndex).getActionState() == NsharpConstants.ActState.ACTIVE - && stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).get(currentSndElementListIndex)!=null){ - break;//out of while loop - } - - } - } - private void moveTimeLineIndexForward (){ - previousTimeLineStateListIndex = currentTimeElementListIndex; - int counter=0; - while(true){ - currentTimeElementListIndex= currentTimeElementListIndex + this.timeElementList.size();// so, we wont get a negative number - currentTimeElementListIndex--; - currentTimeElementListIndex = currentTimeElementListIndex % this.timeElementList.size(); - counter++; - if(counter > timeElementList.size()) - break; - if( timeElementList.get(currentTimeElementListIndex).getActionState() == NsharpConstants.ActState.ACTIVE - && stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).get(currentSndElementListIndex)!=null){ - break;//out of while loop - } - } - //System.out.println("timeline="+timeLineStateList.get(pickedTimeGroupIndex).getElementDescription()); - } - private void moveTimeLineIndexCycle (){ - previousTimeLineStateListIndex = currentTimeElementListIndex; - //Note: direction should only be NEXT or PREVIOUS - int counter=0; - while(true){ - counter++; - if(counter > timeElementList.size()){ - currentTimeElementListIndex = previousTimeLineStateListIndex; - break; - } - if(currentOpDirection == IFrameCoordinator.FrameChangeOperation.NEXT ){ - currentTimeElementListIndex--; - if(currentTimeElementListIndex <= 0){ - //the end of forward direction, change direction to backward - currentOpDirection = IFrameCoordinator.FrameChangeOperation.PREVIOUS; - currentTimeElementListIndex=0; - } - - } - else{ // direction is FrameChangeOperation.PREVIOUS - currentTimeElementListIndex++; - if(currentTimeElementListIndex >= timeElementList.size()-1){ - //the end of backward direction, change direction to forward - currentOpDirection = IFrameCoordinator.FrameChangeOperation.NEXT; - currentTimeElementListIndex = timeElementList.size()-1; - } - } - if( timeElementList.get(currentTimeElementListIndex).getActionState() == NsharpConstants.ActState.ACTIVE - && stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).get(currentSndElementListIndex)!=null){ - break;//out of while loop - } - } - - } - /* - * Note: looping only apply to curAggregateTimeLineList NOT stationIdList - */ - public void setLoopingDataTimeLine(LoopProperties loopProperties) { - //System.out.println("setLoopingDataTimeLine loopmode ="+loopProperties.getMode().toString()); - if( this.timeElementList.size()>0) { - switch(loopProperties.getMode()){ - case Forward: - moveTimeLineIndexForward(); - break; - case Backward: - moveTimeLineIndexBackward(); - break; - case Cycle: - moveTimeLineIndexCycle(); - - break; - } - - curTimeLinePage = currentTimeElementListIndex/numTimeLinePerPage + 1; - setCurSndProfileProp(); - setCurrentSoundingLayerInfo(); - resetData(); - refreshPane(); - } - - } - public enum LoopMode { - Forward, Backward, Cycle - }; - - - private int getElemlistActiveNumber(List elemlist){ - int n=0; - for (NsharpOperationElement elem: elemlist){ - if(elem.getActionState() == NsharpConstants.ActState.ACTIVE){ - n++; - } - } - return n; - } - - public void setSteppingTimeLine(IFrameCoordinator.FrameChangeOperation operation, IFrameCoordinator.FrameChangeMode mode) { - if( this.timeElementList.size() > 0 && getElemlistActiveNumber(timeElementList)>1/* && getAvailTimeLineNumber(currentStnStateListIndex)>1*/) { - int targetIndex = currentTimeElementListIndex; - //previousTimeLineStateListIndex = currentTimeLineStateListIndex; - //preset index for LAST and FIRST operation - switch(operation){ - case LAST: //the future-est time, at top of time line shown. set to -1, so in while loop, it starts from 0 - targetIndex=-1;// - break; - case FIRST: //the oldest time, set to dataTimelineList.length, so in while loop, it starts from dataTimelineList.length-1 - targetIndex = timeElementList.size(); - break; - default: - break; - - } - - int counter=0; - while(true){ - switch(operation){ - case LAST: //the future-est time, at top of time line shown - targetIndex++; - break; - case FIRST: //the oldest time - targetIndex--; - break; - case PREVIOUS: - targetIndex++; - targetIndex = targetIndex % this.timeElementList.size(); - break; - case NEXT: - // so, we wont get a negative number - targetIndex= targetIndex + this.timeElementList.size(); - targetIndex--; - targetIndex = targetIndex % this.timeElementList.size(); - break; - default: - break; - } - counter++; - if(counter >= timeElementList.size()) - return; // looped through whole list already, and index back to original - - if(timeElementList.get(targetIndex).getActionState() == NsharpConstants.ActState.ACTIVE){ - if(compareTmIsOn && currentStnElementListIndex >=0 && currentSndElementListIndex >=0 && - stnTimeSndTable.get(currentStnElementListIndex).get(targetIndex).get(currentSndElementListIndex)== null){ - continue; - } - else if(compareStnIsOn){ - boolean found = false; - if(currentStnElementListIndex >=0 && currentSndElementListIndex >=0 && - stnTimeSndTable.get(currentStnElementListIndex).get(targetIndex).get(currentSndElementListIndex)!=null){ - found = true; - } - else{ - //find an active and available stn for this timeline and set is as current - for (int i=0; i < stnElementList.size(); i++){ - if(stnElementList.get(i).getActionState()==NsharpConstants.ActState.ACTIVE && - stnTimeSndTable.get(i).get(targetIndex).get(currentSndElementListIndex) !=null){ - currentStnElementListIndex = i; - found = true; - break; - } - } - } - if(!found){ - currentStnElementListIndex = -1; - } - else{ - int colorIndex = NsharpConstants.LINE_COMP1; - for(NsharpOperationElement elm: stnElementList) { - int stnIndex = stnElementList.indexOf(elm); - NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable.get(stnIndex).get(targetIndex).get(currentSndElementListIndex); - if(stnTmElm != null){ - stnTmElm.setCompColorIndex(colorIndex); - //if(colorIndex > NsharpConstants.LINE_COMP10) - // colorIndex = NsharpConstants.LINE_COMP1; - } - colorIndex++; - if(colorIndex > NsharpConstants.LINE_COMP10) - colorIndex = NsharpConstants.LINE_COMP1; - } - } - //no matter we find current stn or not - //we should get out of here - break; - } - else if(compareSndIsOn){ - boolean found = false; - if(currentStnElementListIndex >=0 && currentSndElementListIndex >=0 && - stnTimeSndTable.get(currentStnElementListIndex).get(targetIndex).get(currentSndElementListIndex)!=null){ - found = true; - } - else { - //find an active and available snd for this stn and set is as current - for (int i=0; i < sndElementList.size(); i++){ - if(sndElementList.get(i).getActionState()== NsharpConstants.ActState.ACTIVE && - stnTimeSndTable.get(currentStnElementListIndex).get(targetIndex).get(i)!=null){ - currentSndElementListIndex = i; - found = true; - break; - } - } - } - if(!found){ - currentSndElementListIndex = -1; - } - else{ - int colorIndex = NsharpConstants.LINE_COMP1; - for(NsharpOperationElement elm: sndElementList) { - if(elm.getActionState() == NsharpConstants.ActState.INACTIVE) - continue; - int sndIndex = sndElementList.indexOf(elm); - NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable.get(currentStnElementListIndex).get(targetIndex).get(sndIndex); - if(stnTmElm!=null){ - stnTmElm.setCompColorIndex(colorIndex); - } - colorIndex++; - if(colorIndex > NsharpConstants.LINE_COMP10) - colorIndex = NsharpConstants.LINE_COMP1; - } - } - //no matter we find current snd type for this stn or not - //we should get out of here - break; - } - else{ - break; - } - } - } - previousTimeLineStateListIndex = currentTimeElementListIndex; - currentTimeElementListIndex = targetIndex; - curTimeLinePage = currentTimeElementListIndex/numTimeLinePerPage + 1; - setCurSndProfileProp(); - setCurrentSoundingLayerInfo(); - resetData(); - refreshPane(); - } - } - - /* - * Stn index stepping is only controlled by up/down arrow keys, down key = PREVIOUS operation, up key = NEXT operation - */ - public void setSteppingStnIdList(IFrameCoordinator.FrameChangeOperation operation) { - if( this.stnElementList.size() > 0 && getElemlistActiveNumber(stnElementList)>1){ - - int counter=0; - while(true){ - switch(operation){ - case NEXT: - currentStnElementListIndex= currentStnElementListIndex + this.stnElementList.size(); - currentStnElementListIndex--; - currentStnElementListIndex = currentStnElementListIndex % this.stnElementList.size(); - break; - case PREVIOUS: - // so, we wont get a negative number - currentStnElementListIndex++; - currentStnElementListIndex = currentStnElementListIndex % this.stnElementList.size(); - break; - default: - break; - - } - counter++; - //System.out.println("counter = "+ counter); - if(counter >= stnElementList.size()) - return; // looped through whole list already, and index back to original - if(stnElementList.get(currentStnElementListIndex).getActionState() == NsharpConstants.ActState.ACTIVE){ - if (compareStnIsOn && currentTimeElementListIndex>=0 && currentSndElementListIndex>=0 - && stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).get(currentSndElementListIndex)== null){//.getElementState() == NsharpConstants.LoadState.NOTAVAIL){ - continue; - } - else if(compareTmIsOn){ - boolean found = false; - if( currentTimeElementListIndex>=0 && currentSndElementListIndex>=0 && - stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).get(currentSndElementListIndex)!=null){ - // use currentTimeLineStateListIndex - found = true; - } - else { - //find an active and available timeline for this stn and set is as current - for (int i=0; i < timeElementList.size(); i++){ - if(timeElementList.get(i).getActionState()== NsharpConstants.ActState.ACTIVE && - stnTimeSndTable.get(currentStnElementListIndex).get(i).get(currentSndElementListIndex)!=null){ - currentTimeElementListIndex = i; - found = true; - break; - } - } - } - if(!found){ - currentTimeElementListIndex = -1; - } - else{ - int colorIndex = NsharpConstants.LINE_COMP1; - for(NsharpOperationElement elm: timeElementList) { - if(elm.getActionState() == NsharpConstants.ActState.INACTIVE) - continue; - int tmIndex = timeElementList.indexOf(elm); - NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable.get(currentStnElementListIndex).get(tmIndex).get(currentSndElementListIndex); - if(stnTmElm!=null){ - stnTmElm.setCompColorIndex(colorIndex); - } - colorIndex++; - if(colorIndex > NsharpConstants.LINE_COMP10) - colorIndex = NsharpConstants.LINE_COMP1; - - } - } - //no matter we find current time line for this stn or not - //we should get out of here - break; - } - else if(compareSndIsOn){ - boolean found = false; - if( currentTimeElementListIndex>=0 && currentSndElementListIndex>=0 && - stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).get(currentSndElementListIndex)!=null){ - found = true; - } - else { - //find an active and available snd for this stn and set is as current - for (int i=0; i < sndElementList.size(); i++){ - if(sndElementList.get(i).getActionState()== NsharpConstants.ActState.ACTIVE && - stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).get(i)!=null){ - currentSndElementListIndex = i; - found = true; - break; - } - } - } - if(!found){ - currentSndElementListIndex = -1; - } - else{ - int colorIndex = NsharpConstants.LINE_COMP1; - for(NsharpOperationElement elm: sndElementList) { - if(elm.getActionState() == NsharpConstants.ActState.INACTIVE) - continue; - int sndIndex = sndElementList.indexOf(elm); - NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).get(sndIndex); - if(stnTmElm!=null){ - stnTmElm.setCompColorIndex(colorIndex); - } - colorIndex++; - if(colorIndex > NsharpConstants.LINE_COMP10) - colorIndex = NsharpConstants.LINE_COMP1; - } - } - //no matter we find current snd type for this stn or not - //we should get out of here - break; - } - else - break; - } - } - curStnIdPage = currentStnElementListIndex/numTimeLinePerPage + 1; - - setCurSndProfileProp(); - setCurrentSoundingLayerInfo(); - resetData(); - - refreshPane(); - } - - } - /* - * Snd Type index stepping is only controlled by shift + up/down arrow keys, shift+down key = PREVIOUS operation, shift+up key = NEXT operation - */ - public void setSteppingSndTypeList(IFrameCoordinator.FrameChangeOperation operation) { - if( this.sndElementList.size() > 0 && getElemlistActiveNumber(sndElementList)>1){ - - int counter=0; - while(true){ - switch(operation){ - case NEXT: - currentSndElementListIndex= currentSndElementListIndex + this.sndElementList.size(); - currentSndElementListIndex--; - currentSndElementListIndex = currentSndElementListIndex % this.sndElementList.size(); - break; - case PREVIOUS: - // so, we wont get a negative number - currentSndElementListIndex++; - currentSndElementListIndex = currentSndElementListIndex % this.sndElementList.size(); - break; - default: - break; - - } - counter++; - //System.out.println("counter = "+ counter); - if(counter >= sndElementList.size()) - return; // looped through whole list already, and index back to original - if(sndElementList.get(currentSndElementListIndex).getActionState() == NsharpConstants.ActState.ACTIVE){ - if (compareSndIsOn && currentTimeElementListIndex>=0 && currentStnElementListIndex>=0 - && stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).get(currentSndElementListIndex)== null){ - continue; - } - else if(compareTmIsOn){ - boolean found = false; - if(currentTimeElementListIndex>=0 && currentStnElementListIndex>=0 && - stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).get(currentSndElementListIndex)!=null){ - // use currentTimeLineStateListIndex - found = true; - } - else { - //find an active and available timeline for this stn and set is as current - for (int i=0; i < timeElementList.size(); i++){ - if(timeElementList.get(i).getActionState()== NsharpConstants.ActState.ACTIVE && - stnTimeSndTable.get(currentStnElementListIndex).get(i).get(currentSndElementListIndex)!=null){ - currentTimeElementListIndex = i; - found = true; - break; - } - } - } - if(!found){ - currentTimeElementListIndex = -1; - } - else{ - int colorIndex = NsharpConstants.LINE_COMP1; - for(NsharpOperationElement elm: timeElementList) { - if(elm.getActionState() == NsharpConstants.ActState.INACTIVE) - continue; - int tmIndex = timeElementList.indexOf(elm); - NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable.get(currentStnElementListIndex).get(tmIndex).get(currentSndElementListIndex); - if(stnTmElm!=null){ - stnTmElm.setCompColorIndex(colorIndex); - } - colorIndex++; - if(colorIndex > NsharpConstants.LINE_COMP10) - colorIndex = NsharpConstants.LINE_COMP1; - } - } - //no matter we find current time line for this stn or not - //we should get out of here - break; - } - else if(compareStnIsOn){ - boolean found = false; - //find an active and available stn for this timeline and set is as current - if(currentTimeElementListIndex>=0 && currentStnElementListIndex>=0 && - stnTimeSndTable.get(currentStnElementListIndex).get(currentTimeElementListIndex).get(currentSndElementListIndex)!=null){ - found = true; - } - else { - for (int i=0; i < stnElementList.size(); i++){ - if(stnElementList.get(i).getActionState()==NsharpConstants.ActState.ACTIVE && - stnTimeSndTable.get(i).get(currentTimeElementListIndex).get(currentSndElementListIndex) !=null){ - currentStnElementListIndex = i; - found = true; - break; - } - } - } - if(!found){ - currentStnElementListIndex = -1; - } - else{ - int colorIndex = NsharpConstants.LINE_COMP1; - for(NsharpOperationElement elm: stnElementList) { - int stnIndex = stnElementList.indexOf(elm); - NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable.get(stnIndex).get(currentTimeElementListIndex).get(currentSndElementListIndex); - if(stnTmElm!=null){ - stnTmElm.setCompColorIndex(colorIndex); - } - colorIndex++; - if(colorIndex > NsharpConstants.LINE_COMP10) - colorIndex = NsharpConstants.LINE_COMP1; - - } - } - //no matter we find current stn or not - //we should get out of here - break; - } - else - break; - } - } - curStnIdPage = currentSndElementListIndex/numTimeLinePerPage + 1; - - setCurSndProfileProp(); - setCurrentSoundingLayerInfo(); - resetData(); - - refreshPane(); - } - - } - //used for sorting - public class tempPoint implements Comparable{ - double diff; - double temp; - double pressure; - int type; //1= temp, 2 = dewpoint - tempPoint(double diff,double temp,double pressure, int type){ - this.diff = diff; - this.temp = temp; - this.pressure = pressure; - this.type = type; - } - - @Override - public int compareTo(tempPoint o) { - if(this.diff >= o.diff) - return 1; - else - return 0; - } - } - /* - * Return the closest point to the input point on Hodo graph - * - */ - public Coordinate getClosestHodoPoint(Coordinate inputC){ - //System.out.println("picked pt CX "+ inputC.x + " CY "+ inputC.y); - Coordinate closeptC = new Coordinate(0,0); - if(hodoPaneRsc==null) - return closeptC; - - double curSmallestDist=10000; // picked a impossible big number to start with - double distance; - boolean ptFound = false; - NcSoundingLayer layer; - // - // Note: soundingLys list sorted with highest pressure as first element - // - for (int i=0; i< this.soundingLys.size(); i++) { - layer = this.soundingLys.get(i); - double curS, curD; - curS = layer.getWindSpeed(); - curD = layer.getWindDirection(); - closeptC = WxMath.uvComp((float)curS, (float)curD); - closeptC = hodoPaneRsc.getHodoBackground().getWorld().map(closeptC); - //System.out.println("closeptCx " + closeptC.x+ " closeptCy "+ closeptC.y); - distance = inputC.distance(closeptC); - //System.out.println("closeptCx " + closeptC.x+ " closeptCy "+ closeptC.y+" distance "+ distance + " curSmallestDist " +curSmallestDist); - if(distance < curSmallestDist){ - curSmallestDist = distance; - hodoEditingSoundingLayerIndex = i; - ptFound = true; - } - } - if(ptFound == false){ - closeptC.x=closeptC.y=0; - } else{ - layer = this.soundingLys.get(hodoEditingSoundingLayerIndex); - closeptC = WxMath.uvComp((float)layer.getWindSpeed(), (float)layer.getWindDirection()); - closeptC = hodoPaneRsc.getHodoBackground().getWorld().map(closeptC); - } - - //System.out.println("picked closeptCx " + closeptC.x+ " closeptCy "+ closeptC.y); - return closeptC; - } - - public List getSoundingLys() { - return soundingLys; - } - - public List getPreviousSoundingLys() { - return previousSoundingLys; - } - - - /* - * This interpolation is to smooth data out with a pressure gap of 25 mb per layer and also keep - * original lowest and highest layers. - */ - private List performInterpolation(List rawSndLysLst){ - NcSoundingLayer newLayer= new NcSoundingLayer(); - //System.out.println(" performInterpolation"); - nsharpNative.populateSndgData(rawSndLysLst); - - List mySndLst = new ArrayList(); - // add top layer - try { - //here a shallowCopy is enough - newLayer = (NcSoundingLayer) rawSndLysLst.get(0).clone(); - mySndLst.add(newLayer); - } catch (CloneNotSupportedException e) { - e.printStackTrace(); - } - // The first layer has highest pressure - // get a pressure value below first layer and can be divided by 25 exactly - int p =(int) (rawSndLysLst.get(0).getPressure()/25) * 25; - float interpolatedValue; - if ( p == (int)rawSndLysLst.get(0).getPressure()) - { // if p is same as first layer, then this layer is added already, start from 2nd layer - p = p-25; - } - for (; p >= 50 ; p = p-25){ - newLayer= new NcSoundingLayer(); - newLayer.setPressure(p); - interpolatedValue = nsharpNative.nsharpLib.itemp(p); - if(interpolatedValue ==NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA) - //this is not good layer data, usually happened when lowest layer pressure is - // more than 50, then when interpolate layer for pressure 50, will return unvalid value - continue; - newLayer.setTemperature(interpolatedValue); - interpolatedValue = nsharpNative.nsharpLib.idwpt(p); - newLayer.setDewpoint(interpolatedValue); - interpolatedValue = nsharpNative.nsharpLib.iwdir(p); - newLayer.setWindDirection(interpolatedValue); - interpolatedValue = nsharpNative.nsharpLib.iwspd(p); - newLayer.setWindSpeed(interpolatedValue); - interpolatedValue = nsharpNative.nsharpLib.ihght(p); - newLayer.setGeoHeight(interpolatedValue); - interpolatedValue = nsharpNative.nsharpLib.iomeg(p); - newLayer.setOmega(interpolatedValue); - - mySndLst.add(newLayer); - } - return mySndLst; - } - - - private void setSoundingInfo(List sndLys) { - if(overlayIsOn){ - previousSoundingLys = soundingLys; - } - else { - previousSoundingLys = null; - } - - if(interpolateIsOn == true){ - /* TTR829 - * deep copy is not necessary as performInterpolation() will re-allocate new layer for each - * layer - //interpolation is on - //we dont want to change original raw data, so use a deep copy - List intpSndLst = new ArrayList(); - for(NcSoundingLayer layer: sndLys ) { - try { - intpSndLst.add((NcSoundingLayer) layer.clone()); - } catch (CloneNotSupportedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - // interpolation - intpSndLst = performInterpolation(intpSndLst); - - soundingLys = intpSndLst;*/ - - soundingLys = performInterpolation(sndLys); - } - else { - soundingLys = sndLys; - - } - } - public void updateDisplay(IRenderableDisplay[] displayArray, String paneConfigurationName) { - skewtPaneRsc = null; - witoPaneRsc = null; - hodoPaneRsc = null; - timeStnPaneRsc = null; - insetPaneRsc = null; - dataPaneRsc = null; - spcGraphsPaneRsc = null; - futurePaneRsc = null; - for(IRenderableDisplay disp: displayArray) { - ResourcePair rscP = disp.getDescriptor().getResourceList().get(0); - NsharpAbstractPaneResource absPaneRsc = (NsharpAbstractPaneResource)rscP.getResource(); - if (absPaneRsc instanceof NsharpSkewTPaneResource){ - skewtPaneRsc = (NsharpSkewTPaneResource)absPaneRsc ; - skewtPaneRsc.setLinePropertyMap(linePropertyMap); - skewtPaneRsc.setGraphConfigProperty(graphConfigProperty); - skewtPaneRsc.setNsharpNative(nsharpNative); - } - else if (absPaneRsc instanceof NsharpDataPaneResource){ - dataPaneRsc = (NsharpDataPaneResource)absPaneRsc; - dataPaneRsc.setLinePropertyMap(linePropertyMap); - dataPaneRsc.setGraphConfigProperty(graphConfigProperty); - dataPaneRsc.setNsharpNative(nsharpNative); - dataPaneRsc.setPageDisplayOrderNumberArray(pageDisplayOrderNumberArray, dataPageProperty.getNumberPagePerDisplay()); - } - else if (absPaneRsc instanceof NsharpHodoPaneResource){ - hodoPaneRsc = (NsharpHodoPaneResource)absPaneRsc; - hodoPaneRsc.setLinePropertyMap(linePropertyMap); - hodoPaneRsc.setGraphConfigProperty(graphConfigProperty); - hodoPaneRsc.setNsharpNative(nsharpNative); - } - else if (absPaneRsc instanceof NsharpWitoPaneResource && - (paneConfigurationName.equals(NsharpConstants.PANE_SPCWS_CFG_STR)|| - paneConfigurationName.equals(NsharpConstants.PANE_DEF_CFG_1_STR)|| - paneConfigurationName.equals(NsharpConstants.PANE_DEF_CFG_2_STR))){ - - witoPaneRsc = (NsharpWitoPaneResource)absPaneRsc; - witoPaneRsc.setLinePropertyMap(linePropertyMap); - witoPaneRsc.setGraphConfigProperty(graphConfigProperty); - witoPaneRsc.setNsharpNative(nsharpNative); - - } - else if (absPaneRsc instanceof NsharpInsetPaneResource && - (paneConfigurationName.equals(NsharpConstants.PANE_SPCWS_CFG_STR)|| - paneConfigurationName.equals(NsharpConstants.PANE_DEF_CFG_1_STR)|| - paneConfigurationName.equals(NsharpConstants.PANE_DEF_CFG_2_STR))){ - - insetPaneRsc = (NsharpInsetPaneResource)absPaneRsc; - insetPaneRsc.setLinePropertyMap(linePropertyMap); - insetPaneRsc.setGraphConfigProperty(graphConfigProperty); - insetPaneRsc.setNsharpNative(nsharpNative); - - } - else if (absPaneRsc instanceof NsharpSpcGraphsPaneResource && paneConfigurationName.equals(NsharpConstants.PANE_SPCWS_CFG_STR)){ - spcGraphsPaneRsc = (NsharpSpcGraphsPaneResource)absPaneRsc; - spcGraphsPaneRsc.setLinePropertyMap(linePropertyMap); - spcGraphsPaneRsc.setGraphConfigProperty(graphConfigProperty); - spcGraphsPaneRsc.setNsharpNative(nsharpNative); - } - else if(absPaneRsc instanceof NsharpAbstractPaneResource && paneConfigurationName.equals(NsharpConstants.PANE_SIMPLE_D2D_CFG_STR)){ - futurePaneRsc = (NsharpAbstractPaneResource)absPaneRsc; - futurePaneRsc.setLinePropertyMap(linePropertyMap); - futurePaneRsc.setGraphConfigProperty(graphConfigProperty); - futurePaneRsc.setNsharpNative(nsharpNative); - - } - else if (absPaneRsc instanceof NsharpTimeStnPaneResource && - (paneConfigurationName.equals(NsharpConstants.PANE_SIMPLE_D2D_CFG_STR)|| - paneConfigurationName.equals(NsharpConstants.PANE_DEF_CFG_1_STR)|| - paneConfigurationName.equals(NsharpConstants.PANE_DEF_CFG_2_STR))){ - timeStnPaneRsc = (NsharpTimeStnPaneResource)absPaneRsc ; - timeStnPaneRsc.setLinePropertyMap(linePropertyMap); - timeStnPaneRsc.setGraphConfigProperty(graphConfigProperty); - timeStnPaneRsc.setNsharpNative(nsharpNative); - } - } - this.displayArray = displayArray; - } - public void resetRscSoundingData(){ - if(skewtPaneRsc!=null) - skewtPaneRsc.resetData(soundingLys,previousSoundingLys); - if(hodoPaneRsc!=null) - hodoPaneRsc.resetData(soundingLys,previousSoundingLys); - if(witoPaneRsc!=null) - witoPaneRsc.resetData(soundingLys, previousSoundingLys); - if(dataPaneRsc!=null) - dataPaneRsc.resetData(soundingLys, previousSoundingLys); - if(insetPaneRsc!=null) - insetPaneRsc.resetData(soundingLys, previousSoundingLys); - if(spcGraphsPaneRsc!=null) - spcGraphsPaneRsc.resetData(soundingLys, previousSoundingLys); - } - - - public NsharpResourceHandler(IRenderableDisplay[] displayArray, NsharpEditor editor) { - //System.out.println("NsharpResourceHandler constructed"); - //myNsharpEditor = editor; - elementColorMap.put(NsharpConstants.ActState.CURRENT.name(),NsharpConstants.color_green); - elementColorMap.put(NsharpConstants.ActState.ACTIVE.name(),NsharpConstants.color_yellow); - elementColorMap.put(NsharpConstants.ActState.INACTIVE.name(),NsharpConstants.color_white); - //elementColorMap.put(NsharpConstants.LoadState.NOTAVAIL.name(),NsharpConstants.color_red); - //elementColorMap.put(NsharpConstants.ActState.OVERLAY,NsharpConstants.color_red); - //elementColorMap.put(NsharpConstants.LoadState.AVAIL.name(),NsharpConstants.color_yellow); - nsharpNative = new NsharpNative(); - //System.out.println("NsharpResourceHandler constructed"+this.toString() + " nsharpNative="+nsharpNative.toString()); - //based on BigNsharp storm slinky color used and gempak color definition - stormSlinkyColorMap.put(new Integer(3),NsharpConstants.color_green); //green - stormSlinkyColorMap.put(new Integer(7),NsharpConstants.color_magenta); - stormSlinkyColorMap.put(new Integer(6),NsharpConstants.color_cyan); - stormSlinkyColorMap.put(new Integer(13),NsharpConstants.color_violet_md); - stormSlinkyColorMap.put(new Integer(20),NsharpConstants.color_yellow_DK); - stormSlinkyColorMap.put(new Integer(27),NsharpConstants.color_cyan_md); - NsharpPaletteWindow win = NsharpPaletteWindow.getInstance() ; - if(win!=null) - currentGraphMode=win.getCurrentGraphMode(); - - - // new for configMgr - configMgr = NsharpConfigManager.getInstance(); - configStore = configMgr.retrieveNsharpConfigStoreFromFs(); - graphConfigProperty = configStore.getGraphProperty(); - paneConfigurationName = graphConfigProperty.getPaneConfigurationName(); - - int tempOffset = graphConfigProperty.getTempOffset(); - NsharpWxMath.setTempOffset(tempOffset); - linePropertyMap = configStore.getLinePropertyMap(); - dataPageProperty = configStore.getDataPageProperty(); - updatePageOrderArray(); - updateDisplay(displayArray,paneConfigurationName); - displayDataPageMax = NsharpConstants.PAGE_MAX_NUMBER / dataPageProperty.getNumberPagePerDisplay(); - - DateFormatSymbols dfs= new DateFormatSymbols(); - defaultDays = dfs.getShortWeekdays(); - } - public void disposeInternal() { - //System.out.println("NsharpResourceHandler disposeInternal called"); - //soundingMap= null; - listenerList=null; - soundingLys = null; - previousSoundingLys = null; - stormSlinkyColorMap = null; - elementColorMap= null; - - if(NsharpParcelDialog.getAccess()!= null){ - NsharpParcelDialog.getAccess().reset(); - } - - nsharpNative = null; - } - - - - - public void printHeightMark(WGraphics world, GC gc) throws VizException{ - //print feet scales... - double vyMax = world.getViewYmax(); - double vyMin = world.getViewYmin(); - double vxMax = world.getViewXmax(); - for (int j = 0; j < NsharpConstants.HEIGHT_LEVEL_FEET.length; j++) { - float meters = (float)NsharpConstants.feetToMeters.convert(NsharpConstants.HEIGHT_LEVEL_FEET[j]); - - double pressure = nsharpNative.nsharpLib.ipres(meters); - double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, -50).y); - - gc.drawString( Integer.toString(NsharpConstants.HEIGHT_LEVEL_FEET[j]/1000), (int)vxMax + 40, - (int)y,false); - - - gc.drawLine( (int)vxMax + 50,(int) y, (int) vxMax + 45,(int) y); - } - //print meter scales... - for (int j = 0; j < NsharpConstants.HEIGHT_LEVEL_METERS.length; j++) { - int meters = NsharpConstants.HEIGHT_LEVEL_METERS[j]; - - double pressure = nsharpNative.nsharpLib.ipres(meters); - double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, -50).y); - - gc.drawString( Integer.toString(meters/1000), (int)vxMax + 52, - (int)y,false); - - - gc.drawLine( (int)vxMax + 50,(int) y, (int) vxMax + 55,(int) y); - } - // print surface level mark - double y = world.mapY(NsharpWxMath.getSkewTXY(soundingLys.get(0).getPressure(), -50).y); - gc.drawString("SFC("+Integer.toString((int)(soundingLys.get(0).getGeoHeight()))+"m)", (int)vxMax+ 50, - (int)y, false); - gc.drawLine((int) vxMax+ 50, (int)y, (int) vxMax + 55,(int) y); - // top level mark at 100 mbar - y = world.mapY(NsharpWxMath.getSkewTXY(100, -50).y); - float hgt = nsharpNative.nsharpLib.ihght(100); - gc.drawString(Float.toString(hgt/1000F), (int)vxMax+ 50,(int)y, false); - gc.drawString("Kft Km", (int) vxMax+35, (int)y -8); - gc.drawString("MSL", (int) vxMax+45, (int)y -15); - gc.drawLine((int) vxMax+40, (int)y, (int) vxMax + 60,(int) y); - - gc.drawLine((int) vxMax+50, (int)vyMin, (int) vxMax + 50,(int)vyMax); - - } - - /** - * Prints the pressure lines number at left side out of skewT bkgd for printing job - * - * @throws VizException - */ - public void printNsharpPressureLinesNumber(WGraphics world, GC gc) throws VizException { - String s = null; - double vxMax = world.getViewXmax(); - double vxMin = world.getViewXmin(); - for (int i = 0; i < NsharpConstants.PRESSURE_MAIN_LEVELS.length; i++) { - //we only care about pressure for this case, temp is no important when calling getSkewTXY - Coordinate coor = NsharpWxMath.getSkewTXY(NsharpConstants.PRESSURE_MAIN_LEVELS[i],0); - - gc.drawLine((int)vxMin, (int)world.mapY(coor.y), - (int)vxMax, - (int)world.mapY(coor.y)); - - } - for (int i = 0; i < NsharpConstants.PRESSURE_MARK_LEVELS.length; i++) { - //we only care about pressure for this case, temp is no important when calling getSkewTXY - Coordinate coor = NsharpWxMath.getSkewTXY(NsharpConstants.PRESSURE_MARK_LEVELS[i],0); - - gc.drawLine((int)vxMin, (int)world.mapY(coor.y), - (int)vxMin+10, - (int)world.mapY(coor.y)); - - } - for (int i = 0; i < NsharpConstants.PRESSURE_NUMBERING_LEVELS.length; i++) { - s = NsharpConstants.pressFormat.format(NsharpConstants.PRESSURE_NUMBERING_LEVELS[i]); - //we only care about pressure for this case, temp is no important when calling getSkewTXY - Coordinate coor = NsharpWxMath.getSkewTXY(NsharpConstants.PRESSURE_NUMBERING_LEVELS[i],0); - - gc.drawString( s, (int)vxMin-20, - (int)world.mapY(coor.y), false); - } - } - - /** - * Print the temp number at bottom out of skewT bkgd for printing job - * - * @throws VizException - */ - public void printNsharpTempNumber(WGraphics world, GC gc) throws VizException { - for (int i = 40; i > -50; i -= 10) { - Coordinate coorStart = NsharpWxMath.getSkewTXY(1050, i); - double startX = world.mapX(coorStart.x); - double startY = world.mapY(coorStart.y); - - gc.drawString( Integer.toString(i), (int)startX,(int)startY+5,false); - } - for (int i = -60; i > -120; i -= 10) { - Coordinate coorEnd = NsharpWxMath.getSkewTXY(100, i); - - //System.out.println("X = "+ startX + " Y = "+ startY); - double endX = world.mapX(coorEnd.x); - double endY = world.mapY(coorEnd.y); - - - gc.drawString( Integer.toString(i),(int) endX,(int)endY-10,false); - } - } - /** - * - * Print Wind barb for printing job - * This function followed algorithm in plot_barbs (void) at xwvid1.c - * to choose wind bulb for drawing around every 400m - * - */ - public void printNsharpWind(WGraphics world, GC gc)throws VizException { - ArrayList> windList = new ArrayList>(); - - double windX = world.getViewXmax() + 6*BARB_LENGTH; - //System.out.println("windX="+windX); - float lastHeight = -999; - double windY; - for (NcSoundingLayer layer : soundingLys) { - float pressure = layer.getPressure(); - float spd = layer.getWindSpeed(); - float dir = layer.getWindDirection(); - - - if ( pressure < 100) { - continue; - } - - if ((layer.getGeoHeight() - lastHeight) < 400){ - - continue; - } - - // Get the vertical ordinate. - windY = world.mapY(NsharpWxMath.getSkewTXY(pressure, 0).y); - - List barb = WindBarbFactory.getWindGraphics( - /*metersPerSecondToKnots.convert*/(double) (spd), (double) dir); - if (barb != null) { - WindBarbFactory.scaleBarb(barb, -7); - WindBarbFactory.translateBarb(barb, windX, windY); - windList.add(barb); - } - - lastHeight = layer.getGeoHeight(); - } - Coordinate pt1=new Coordinate(0,0), pt2; - for (List barb : windList) { - for (LineStroke stroke : barb) { - //stroke render: rewrite stroke.render() for our printing purpose - if(stroke.getType()=="M") { - pt1 = stroke.getPoint(); - //change X coordinate by mirroring x coordinate at windX axis. AS we scaleBarb with -5 time. - // It is easier to mirror at x-axis for this case. - pt1.x = windX - (pt1.x-windX); - //System.out.print("Myp1x="+(int)pt1.x+" p1y="+(int)pt1.y); - - } - else if(stroke.getType()=="D"){ - pt2 = stroke.getPoint(); - pt2.x = windX - (pt2.x-windX); - //System.out.println( " p2x="+(int)pt2.x+" p2y="+ (int)pt2.y); - gc.drawLine((int)pt1.x, (int)pt1.y, (int)pt2.x, (int)pt2.y); - } - } - } - gc.drawLine((int)windX,(int)world.mapY(NsharpWxMath.getSkewTXY(100, 0).y), - (int)windX,(int)world.mapY(NsharpWxMath.getSkewTXY(1000, 0).y)); - } - - /** - * - * Print the wetbulb trace curve - * - * @throws VizException - */ - public void printNsharpWetbulbTraceCurve( - WGraphics world, GC gc) throws VizException { - if((soundingLys == null) || (soundingLys.size()==0)) - return; - float t1; - - Coordinate c2 = null; - Coordinate c1; - // print trace - for (NcSoundingLayer layer : this.soundingLys) { - if (layer.getDewpoint() > -200){ - t1 = nsharpNative.nsharpLib.wetbulb(layer.getPressure(), layer.getTemperature(), - layer.getDewpoint()); - - c1 = NsharpWxMath.getSkewTXY(layer.getPressure(), t1); - c1.x = world.mapX(c1.x); - c1.y = world.mapY(c1.y); - if(c2!= null){ - gc.drawLine((int)c1.x, (int)c1.y, (int)c2.x, (int)c2.y); - } - c2 = c1; - } - } - - } - - public void printNsharpParcelTraceCurve(WGraphics world, GC gc) throws VizException{ - if(soundingLys.size() > 0){ - //for (ParcelData parData: parcelList){ - //plotNsharpParcelTraceCurve(null, 0, world, NsharpConstants.color_white,parData.parcelType, parData.userPressure, gc, true); - //nsharpNative.nsharpLib.define_parcel(parData.parcelType, parData.parcelLayerPressure); - nsharpNative.nsharpLib.define_parcel(currentParcel,currentParcelLayerPressure); - _lplvalues lpvls = new _lplvalues(); - nsharpNative.nsharpLib.get_lpvaluesData(lpvls); - - float sfctemp, sfcdwpt, sfcpres; - sfctemp = lpvls.temp; - sfcdwpt = lpvls.dwpt; - sfcpres = lpvls.pres; - - float vtemp = nsharpNative.nsharpLib.virtemp (sfcpres, sfctemp, sfcdwpt); - Coordinate c1 = NsharpWxMath.getSkewTXY(sfcpres, vtemp); - c1.x = world.mapX(c1.x); - c1.y = world.mapY(c1.y); - FloatByReference p2 = new FloatByReference(0), t2 = new FloatByReference(0);; - nsharpNative.nsharpLib.drylift (sfcpres, sfctemp, sfcdwpt, p2, t2); - vtemp = nsharpNative.nsharpLib.virtemp (p2.getValue(), t2.getValue(), t2.getValue()); - Coordinate c2 = NsharpWxMath.getSkewTXY(p2.getValue(), vtemp); - c2.x = world.mapX(c2.x); - c2.y = world.mapY(c2.y); - - gc.drawLine((int)c1.x, (int)c1.y, (int)c2.x, (int)c2.y); - c1 = c2; - - - float t3; - for (float i = p2.getValue() - 50; i >= 100; i = i - 50) - { - t3 = nsharpNative.nsharpLib.wetlift (p2.getValue(), t2.getValue(), i); - vtemp = nsharpNative.nsharpLib.virtemp (i, t3, t3); - c2 = NsharpWxMath.getSkewTXY(i, vtemp); - c2.x = world.mapX(c2.x); - c2.y = world.mapY(c2.y); - - gc.drawLine((int)c1.x, (int)c1.y, (int)c2.x, (int)c2.y); - c1 = c2; - } - - t3 = nsharpNative.nsharpLib.wetlift (p2.getValue(), t2.getValue(), 100); - vtemp = nsharpNative.nsharpLib.virtemp (100, t3, t3); - c2 = NsharpWxMath.getSkewTXY(100, vtemp); - c2.x = world.mapX(c2.x); - c2.y = world.mapY(c2.y); - - gc.drawLine((int)c1.x, (int)c1.y, (int)c2.x, (int)c2.y); - //} - } - } - /** - * - * Print the temperature curve when during overlap or compare mode - * - * @throws VizException - */ - - public void printNsharpPressureTempCurve(WGraphics world, int type, GC gc,List soundingLys) throws VizException { - if((soundingLys == null) || (soundingLys.size()==0)) - return; - - double maxPressure = NsharpWxMath.reverseSkewTXY(new Coordinate(0, world - .getWorldYmax())).y; - double minPressure = NsharpWxMath.reverseSkewTXY(new Coordinate(0, world - .getWorldYmin())).y; - Coordinate c0 = null; - for (NcSoundingLayer layer : soundingLys) { - double t; - if(type == TEMP_TYPE) - t = layer.getTemperature(); - else if (type == DEWPOINT_TYPE) - t = layer.getDewpoint(); - else - break; - double pressure = layer.getPressure(); - if (t != INVALID_DATA && pressure >= minPressure - && pressure <= maxPressure) { - - Coordinate c1 = NsharpWxMath.getSkewTXY(pressure, t); - - c1.x = world.mapX(c1.x); - c1.y = world.mapY(c1.y); - //System.out.println("C.x "+ c1.x + " C.y "+ c1.y); - if (c0 != null) { - gc.drawLine((int)c0.x, (int)c0.y, (int)c1.x, (int)c1.y); - } - c0 = c1; - } - } - - } - - - /** - * - * Print the HODO - * - * - * @throws VizException - */ - - public void printNsharpHodoWind(WGraphics world, GC gc, List soundingLays) throws VizException { - Coordinate c0 = null; - Coordinate c1; - for (NcSoundingLayer layer : soundingLays){ - if(layer.getPressure() < 100 || layer.getWindSpeed() <0) - continue; - float wspd = layer.getWindSpeed(); - float wdir = layer.getWindDirection(); - c1 = WxMath.uvComp(wspd, wdir); - if (c0 != null) { - gc.setLineWidth(1); - gc.drawLine((int)world.mapX(c0.x),(int) world.mapY(c0.y),(int) world - .mapX(c1.x),(int) world.mapY(c1.y)); - } - c0 = c1; - } - - - } - - - public boolean isPlotInteractiveTemp() { - return plotInteractiveTemp; - } - - - public void setPlotInteractiveTemp(boolean plotInteractiveTemp) { - this.plotInteractiveTemp = plotInteractiveTemp; - if(skewtPaneRsc!=null) - skewtPaneRsc.setPlotInteractiveTemp(plotInteractiveTemp); - } - public void setInteractiveTempPointCoordinate( - Coordinate interactiveTempPointCoordinate) { - //System.out.println("setInteractiveTempPointCoordinate called"); - this.interactiveTempPointCoordinate = interactiveTempPointCoordinate; - plotInteractiveTemp = true; - if(skewtPaneRsc!=null){ - skewtPaneRsc.setPlotInteractiveTemp(plotInteractiveTemp); - skewtPaneRsc.setInteractiveTempPointCoordinate(interactiveTempPointCoordinate); - } - } - public void setInteractiveHodoPointCoordinate(Coordinate c){ - if(hodoPaneRsc == null) - return; - try { - NcSoundingLayer hodoLayer = soundingLys.get(hodoEditingSoundingLayerIndex); - if(hodoLayer != null){ - //TTR575 - nsharpNative.populateSndgData(soundingLys); - //end TTR575 - Coordinate c1 = hodoPaneRsc.getHodoBackground().getWorld().unMap(c.x, c.y); - //System.out.println("picked pt after unmap CX "+ c1.x + " CY "+ c1.y); - c1 = WxMath.speedDir((float) c1.x, (float) c1.y); - hodoLayer.setWindSpeed((float)c1.x); - hodoLayer.setWindDirection((float)c1.y); - hodoPaneRsc.createRscHodoWindShapeAll(); - if(witoPaneRsc!=null) - witoPaneRsc.createAllWireFrameShapes(); - if(insetPaneRsc!=null) - insetPaneRsc.createInsetWireFrameShapes(); - if(skewtPaneRsc!=null) - //CHIN:::fix edit zoom issue skewtPaneRsc.handleResize(); - skewtPaneRsc.createRscWireFrameShapes(); - } - } - catch(Exception e) { - - } - } - public void applyMovingTempLine(){ - if(skewtPaneRsc==null) - return; - Coordinate inC = NsharpWxMath.reverseSkewTXY(skewtPaneRsc.getWorld().unMap(interactiveTempPointCoordinate)); - float inTemp = (float) inC.x; - currentSoundingLayerIndex = skewtPaneRsc.getCurrentSoundingLayerIndex(); - currentTempCurveType = skewtPaneRsc.getCurrentTempCurveType(); - float currentLayerTemp, currentLayerDewP; - float smallestGap = skewtPaneRsc.getTempDewPtSmallestGap(); - float tempShiftedDist; - currentLayerTemp = soundingLys.get(currentSoundingLayerIndex).getTemperature(); - currentLayerDewP = soundingLys.get(currentSoundingLayerIndex).getDewpoint(); - if(currentTempCurveType == TEMP_TYPE){ - if(inTemp < currentLayerTemp){ - // shift to left, tempShiftedDist should be a negative number - if((currentLayerTemp - inTemp)> smallestGap){ - tempShiftedDist = -smallestGap; - } - else { - tempShiftedDist = inTemp - currentLayerTemp; - } - } - else { - // shift to right, tempShiftedDist should be a positive number - tempShiftedDist = inTemp - currentLayerTemp; - } - } - else { - if(inTemp < currentLayerDewP){ - // shift to left, tempShiftedDist should be a negative number - tempShiftedDist = inTemp - currentLayerDewP; - } - else { - // shift to right, tempShiftedDist should be a positive number - if((inTemp - currentLayerDewP)> smallestGap){ - tempShiftedDist = smallestGap; - } - else { - tempShiftedDist = inTemp - currentLayerDewP; - } - } - } - for (NcSoundingLayer layer : soundingLys) { - float t; - if(currentTempCurveType == TEMP_TYPE){ - t = layer.getTemperature(); - if (t != NsharpNativeConstants.NSHARP_NATIVE_INVALID_DATA ) { - layer.setTemperature(t+tempShiftedDist); - } - } - else{ - t = layer.getDewpoint(); - if (t != NsharpNativeConstants.NSHARP_NATIVE_INVALID_DATA ) { - layer.setDewpoint(t+tempShiftedDist); - } - } - } - //re-populate snd data to nsharp native code lib for later calculating - nsharpNative.populateSndgData(soundingLys); - //get storm motion wind data after populate sounding from NsharpLib - skewtPaneRsc.setSoundingLys(soundingLys); - //CHIN:::fix edit zoom issue skewtPaneRsc.handleResize(); - skewtPaneRsc.createRscWireFrameShapes(); - if(hodoPaneRsc!=null){ - hodoPaneRsc.setSoundingLys(soundingLys); - hodoPaneRsc.createRscHodoWindShapeAll(); - } - } - public void applyInteractiveTempPoint(){ - if(skewtPaneRsc==null) - return; - Coordinate inC = NsharpWxMath.reverseSkewTXY(skewtPaneRsc.getWorld().unMap(interactiveTempPointCoordinate)); - double inTemp = inC.x; - currentSoundingLayerIndex = skewtPaneRsc.getCurrentSoundingLayerIndex(); - NcSoundingLayer layer = this.soundingLys.get(currentSoundingLayerIndex); - currentTempCurveType = skewtPaneRsc.getCurrentTempCurveType(); - //System.out.println("applyInteractiveTempPoint called pressure " + inC.y + " temp "+ inTemp + - // " currentTempCurveType " + currentTempCurveType ); - - if(currentTempCurveType == TEMP_TYPE){ - if(inTemp < layer.getDewpoint()) - // temp can not be lower than dew point - layer.setTemperature(layer.getDewpoint()); - else - layer.setTemperature((float)inTemp); - } - else{ - if(inTemp > layer.getTemperature()) - // dew point can not be higher than temp - layer.setDewpoint(layer.getTemperature()); - else - layer.setDewpoint((float)inTemp); - } - - - //re-populate snd data to nsharp native code lib for later calculating - nsharpNative.populateSndgData(soundingLys); - //get storm motion wind data after populate sounding from NsharpLib - skewtPaneRsc.setSoundingLys(soundingLys); - //CHIN:::fix edit zoom issue skewtPaneRsc.handleResize(); - skewtPaneRsc.createRscWireFrameShapes(); - - if(hodoPaneRsc!=null){ - hodoPaneRsc.setSoundingLys(soundingLys); - hodoPaneRsc.createRscHodoWindShapeAll(); - } - } - - public void applySfcEditing(float tp, float dp, float ws, float wd, float pressure){ - currentSoundingLayerIndex =nsharpNative.nsharpLib.sfc(); - NcSoundingLayer layer = this.soundingLys.get(currentSoundingLayerIndex); - layer.setTemperature(tp); - layer.setDewpoint(dp); - layer.setWindDirection(wd); - layer.setWindSpeed(ws); - layer.setPressure(pressure); - //re-populate snd data to nsharp native code lib for later calculating - nsharpNative.populateSndgData(soundingLys); - if(skewtPaneRsc!=null) - skewtPaneRsc.setSoundingLys(soundingLys); - if(hodoPaneRsc!=null) - hodoPaneRsc.setSoundingLys(soundingLys); - if(insetPaneRsc!=null) - insetPaneRsc.setSoundingLys(soundingLys); - if(witoPaneRsc!=null) - witoPaneRsc.setSoundingLys(soundingLys); - if(dataPaneRsc!=null) - dataPaneRsc.setSoundingLys(soundingLys); - } - public void updateLayer(int layerIndex, float tp, float dp, float ws, float wd, float pressure){ - if(layerIndex <0 || layerIndex >= soundingLys.size()) - return; - currentSoundingLayerIndex =layerIndex; - NcSoundingLayer layer = soundingLys.get(currentSoundingLayerIndex); - layer.setGeoHeight(nsharpNative.nsharpLib.ihght(pressure)); - layer.setTemperature(tp); - layer.setDewpoint(dp); - layer.setWindDirection(wd); - layer.setWindSpeed(ws); - layer.setPressure(pressure); - //re-populate snd data to nsharp native code lib for later calculating - Collections.sort(soundingLys,NsharpDataHandling.reversePressureHeightWindComparator()); - nsharpNative.populateSndgData(soundingLys); - //get storm motion wind data after populate sounding from NsharpLib - //refresh test area if it is shown now - NsharpShowTextDialog textarea = NsharpShowTextDialog.getAccess(); - if(textarea != null){ - textarea.refreshTextData(); - } - if(skewtPaneRsc!=null){ - skewtPaneRsc.setSoundingLys(soundingLys); - //CHIN:::fix edit zoom issue skewtPaneRsc.handleResize(); - skewtPaneRsc.createRscWireFrameShapes(); - } - if(hodoPaneRsc!=null){ - hodoPaneRsc.setSoundingLys(soundingLys); - hodoPaneRsc.createRscHodoWindShapeAll(); - } - if(insetPaneRsc!=null){ - insetPaneRsc.setSoundingLys(soundingLys); - insetPaneRsc.createInsetWireFrameShapes(); - } - if(witoPaneRsc!=null) { - witoPaneRsc.setSoundingLys(soundingLys); - witoPaneRsc.createAllWireFrameShapes(); - } - if(dataPaneRsc!=null) - dataPaneRsc.setSoundingLys(soundingLys); - } - public void addNewLayer(float tp, float dp, float ws, float wd, float pressure){ - //NsharpBackgroundResource bkRsc = descriptor.getSkewTBkGResource(); - //currentSoundingLayer =layerIndex; - NcSoundingLayer layer = new NcSoundingLayer(); - layer.setGeoHeight(nsharpNative.nsharpLib.ihght(pressure)); - layer.setTemperature(tp); - layer.setDewpoint(dp); - layer.setWindDirection(wd); - layer.setWindSpeed(ws); - layer.setPressure(pressure); - soundingLys.add(layer); - //re-populate snd data to nsharp native code lib for later calculating - Collections.sort(soundingLys,NsharpDataHandling.reversePressureHeightWindComparator()); - nsharpNative.populateSndgData(soundingLys); - //get storm motion wind data after populate sounding from NsharpLib - //refresh text area if it is shown now - NsharpShowTextDialog textarea = NsharpShowTextDialog.getAccess(); - if(textarea != null){ - textarea.refreshTextData(); - } - if(skewtPaneRsc!=null){ - skewtPaneRsc.setSoundingLys(soundingLys); - //CHIN:::fix edit zoom issue skewtPaneRsc.handleResize(); - skewtPaneRsc.createRscWireFrameShapes(); - } - if(hodoPaneRsc!=null){ - hodoPaneRsc.setSoundingLys(soundingLys); - hodoPaneRsc.createRscHodoWindShapeAll(); - } - if(insetPaneRsc!=null){ - insetPaneRsc.setSoundingLys(soundingLys); - insetPaneRsc.createInsetWireFrameShapes(); - } - if(witoPaneRsc!=null) { - witoPaneRsc.setSoundingLys(soundingLys); - witoPaneRsc.createAllWireFrameShapes(); - } - if(dataPaneRsc!=null) - dataPaneRsc.setSoundingLys(soundingLys); - } - - - - - public void setGraphConfigProperty(NsharpGraphProperty graphConfigProperty) { - this.graphConfigProperty = graphConfigProperty; - int tempOffset = graphConfigProperty.getTempOffset(); - NsharpWxMath.setTempOffset(tempOffset); - if(skewtPaneRsc!=null){ - skewtPaneRsc.setGraphConfigProperty(graphConfigProperty); - skewtPaneRsc.handleResize(); - skewtPaneRsc.getSkewTBackground().setGraphConfigProperty(graphConfigProperty); - } - if(hodoPaneRsc!=null) { - hodoPaneRsc.setGraphConfigProperty(graphConfigProperty); - hodoPaneRsc.createRscHodoWindShapeAll(); - } - if(witoPaneRsc!=null) { - witoPaneRsc.setGraphConfigProperty(graphConfigProperty); - witoPaneRsc.createAllWireFrameShapes(); - } - if(insetPaneRsc!=null){ - insetPaneRsc.setGraphConfigProperty(graphConfigProperty); - insetPaneRsc.createInsetWireFrameShapes(); - } - } - - - public NsharpGraphProperty getGraphConfigProperty() { - return graphConfigProperty; - } - - - public void setLinePropertyMap( - HashMap linePropertyMap) { - this.linePropertyMap = linePropertyMap; - if(skewtPaneRsc!=null){ - skewtPaneRsc.setLinePropertyMap(linePropertyMap); - skewtPaneRsc.handleResize(); - } - if(hodoPaneRsc!=null){ - hodoPaneRsc.setLinePropertyMap(linePropertyMap); - hodoPaneRsc.createRscHodoWindShapeAll(); - } - if(timeStnPaneRsc!=null) - timeStnPaneRsc.setLinePropertyMap(linePropertyMap); - } - private void updatePageOrderArray(){ - pageDisplayOrderNumberArray[NsharpConstants.PAGE_SUMMARY1 ] = dataPageProperty.getSummary1Page(); - pageDisplayOrderNumberArray[NsharpConstants.PAGE_SUMMARY2 ] = dataPageProperty.getSummary2Page(); - pageDisplayOrderNumberArray[NsharpConstants.PAGE_PARCEL_DATA ] = dataPageProperty.getParcelDataPage(); - pageDisplayOrderNumberArray[NsharpConstants.PAGE_THERMODYNAMIC_DATA ] = dataPageProperty.getThermodynamicDataPage(); - pageDisplayOrderNumberArray[NsharpConstants.PAGE_OPC_DATA ] = dataPageProperty.getOpcDataPage(); - pageDisplayOrderNumberArray[NsharpConstants.PAGE_MIXING_HEIGHT] = dataPageProperty.getMixingHeightPage(); - pageDisplayOrderNumberArray[NsharpConstants.PAGE_STORM_RELATIVE ] = dataPageProperty.getStormRelativePage(); - pageDisplayOrderNumberArray[NsharpConstants.PAGE_MEAN_WIND ] = dataPageProperty.getMeanWindPage(); - pageDisplayOrderNumberArray[NsharpConstants.PAGE_CONVECTIVE_INITIATION ] = dataPageProperty.getConvectiveInitiationPage(); - pageDisplayOrderNumberArray[NsharpConstants.PAGE_SEVERE_POTENTIAL ] = dataPageProperty.getSeverePotentialPage(); - } - public void setDataPageProperty(NsharpDataPageProperty dataPageProperty) { - this.dataPageProperty = dataPageProperty; - updatePageOrderArray(); - if(dataPaneRsc!=null) - dataPaneRsc.setPageDisplayOrderNumberArray(pageDisplayOrderNumberArray, dataPageProperty.getNumberPagePerDisplay()); - } - - - public void handleTimeLineActConfig(List tlList, NsharpConstants.ActState actSt){ - for(String tlStr: tlList){ - for(NsharpOperationElement tl: timeElementList){ - if(tlStr.equals(tl.getElementDescription())){ - tl.setActionState( actSt); - break; - } - } - } - } - public void handleStationActConfig(List stnList, NsharpConstants.ActState actSt){ - for(String tlStr: stnList){ - for(NsharpOperationElement stn: stnElementList){ - if(tlStr.equals(stn.getElementDescription())){ - stn.setActionState( actSt); - break; - } - } - } - } - - public void handleSndTypeActConfig(List sndTypeList, NsharpConstants.ActState actSt){ - for(String tlStr: sndTypeList){ - for(NsharpOperationElement sndType: sndElementList){ - if(tlStr.equals(sndType.getElementDescription())){ - sndType.setActionState( actSt); - break; - } - } - } - } - - public int getCurrentTextChapter() { - return currentTextChapter; - } - - - public float getCurrentParcelLayerPressure() { - return currentParcelLayerPressure; - } - - - public NsharpSkewTPaneResource getSkewtPaneRsc() { - return skewtPaneRsc; - } - - - public NsharpHodoPaneResource getHodoPaneRsc() { - return hodoPaneRsc; - } - - - public NsharpSoundingElementStateProperty getPreSndProfileProp() { - return preSndProfileProp; - } - - - - - public int getCurTimeLinePage() { - return curTimeLinePage; - } - - - public int getCurrentInsetPage() { - return currentInsetPage; - } - - - public int getCurrentSoundingLayerIndex() { - return currentSoundingLayerIndex; - } - - - public IFrameCoordinator.FrameChangeOperation getCurrentOpDirection() { - return currentOpDirection; - } - - - public NsharpSoundingElementStateProperty getCurSndProfileProp() { - return curSndProfileProp; - } - - - public int getCurStnIdPage() { - return curStnIdPage; - } - - - public int getCurSndPage() { - return curSndPage; - } - - - public HashMap getElementColorMap() { - return elementColorMap; - } - - - public int getTotalTimeLinePage() { - return totalTimeLinePage; - } - - - public int getTotalStnIdPage() { - return totalStnIdPage; - } - - - public int getTotalSndPage() { - return totalSndPage; - } - - - public void repopulateSndgData(){ - nsharpNative.populateSndgData(soundingLys); - } - - - public NsharpWitoPaneResource getWitoPaneRsc() { - return witoPaneRsc; - } - - - public NsharpInsetPaneResource getInsetPaneRsc() { - return insetPaneRsc; - } - - - - public NsharpSpcGraphsPaneResource getSpcGraphsPaneRsc() { - return spcGraphsPaneRsc; - } - - - public NsharpDataPaneResource getDataPaneRsc() { - return dataPaneRsc; - } - public void setTimeStnBoxData(int cnYOrig,int dtNextPage_end, int dtYOrig , int dtXOrig, int dtWidth, int charHeight){ - this.charHeight = charHeight; - this.dtYOrig = dtYOrig; - this.dtXOrig = dtXOrig; - this.dtWidth = dtWidth; - this.cnYOrig = cnYOrig; - this.dtNextPageEnd = dtNextPage_end; - calculateTimeStnBoxData(); - } - - public void refreshPane(){ - for(int i =0; i< displayArray.length ; i++){ - displayArray[i].refresh(); - } - } - - - public String getPaneConfigurationName() { - return paneConfigurationName; - } - - private void calculateTimeStnBoxData(){ - //set total time line group and stn id list page number - numTimeLinePerPage = (cnYOrig-dtNextPageEnd)/charHeight; - if(numTimeLinePerPage<=0) - numTimeLinePerPage=1; - //System.out.println("numTimeLinePerPage="+numTimeLinePerPage); - totalTimeLinePage = timeElementList.size()/numTimeLinePerPage ; - if(timeElementList.size()%numTimeLinePerPage != 0) - totalTimeLinePage= totalTimeLinePage+1; - curTimeLinePage = currentTimeElementListIndex/numTimeLinePerPage+1; - totalStnIdPage = stnElementList.size()/numTimeLinePerPage; - if(stnElementList.size()%numTimeLinePerPage != 0) - totalStnIdPage++; - curStnIdPage= currentStnElementListIndex/numTimeLinePerPage + 1; - totalSndPage = sndElementList.size()/numTimeLinePerPage; - if(sndElementList.size()%numTimeLinePerPage != 0) - totalSndPage++; - curSndPage= currentSndElementListIndex/numTimeLinePerPage + 1; - } - - /* - * Return size of stnTimeSndTable - * Note that not all elements in this table has sounding data loaded. - * Therefore, returned size may be much bigger than the number of actual loaded sounding data frame. - */ - public int getFrameCount(){ - return timeElementList.size() * sndElementList.size()* stnElementList.size(); - } - /* - * return "accumulated" index to stnTimeSndTable of current displayed sounding data - */ - public int getCurrentIndex() { - int index = 0; - if(currentSndElementListIndex >= 0 && currentStnElementListIndex >=0 && currentTimeElementListIndex >=0){ - index = currentSndElementListIndex - + currentTimeElementListIndex * sndElementList.size() - + currentStnElementListIndex * timeElementList.size() * sndElementList.size(); - } - return index; - } - /* - * set current displayed sounding data using the input "accumulated" index (to stnTimeSndTable) - * return false: If input index is not valid or sounding data is not loaded for input index - * return true: if set successfully - */ - public boolean setCurrentIndex( int index) { - if(index < 0 || index >= (timeElementList.size() * sndElementList.size() * stnElementList.size())){ - //System.out.println("invalid index="+index); - return false; - } - int tempStni, tempSndi, tempTmi; - tempStni = index / (timeElementList.size() * sndElementList.size()); - tempTmi = (index % (timeElementList.size() * sndElementList.size()))/ sndElementList.size(); - tempSndi = (index % (timeElementList.size() * sndElementList.size()))% sndElementList.size(); - if(timeElementList.get(tempTmi).getActionState() == NsharpConstants.ActState.INACTIVE || - stnElementList.get(tempStni).getActionState() == NsharpConstants.ActState.INACTIVE || - sndElementList.get(tempSndi).getActionState() == NsharpConstants.ActState.INACTIVE || - stnTimeSndTable.get(tempStni).get(tempTmi).get(tempSndi)== null - ) - { - //System.out.println("invalid element="+index); - return false; - } - previousTimeLineStateListIndex = currentTimeElementListIndex; - currentStnElementListIndex = tempStni; - currentTimeElementListIndex =tempTmi; - currentSndElementListIndex = tempSndi; - setCurSndProfileProp(); - curTimeLinePage = currentTimeElementListIndex/numTimeLinePerPage + 1; - curSndPage= currentSndElementListIndex/numTimeLinePerPage + 1; - curStnIdPage= currentStnElementListIndex/numTimeLinePerPage + 1; - setCurrentSoundingLayerInfo(); - resetData(); - refreshPane(); - return true; - } + public int getSndIndex() { + return sndIndex; + } + + public void setSndIndex(int sndIndex) { + this.sndIndex = sndIndex; + } + + public int getStnIndex() { + return stnIndex; + } + + public void setStnIndex(int stnIndex) { + this.stnIndex = stnIndex; + } + + public int getTimeIndex() { + return timeIndex; + } + + public void setTimeIndex(int timeIndex) { + this.timeIndex = timeIndex; + } + + } + + private List compSndSelectedElemList = new ArrayList(); + + private int sndCompRadius = 0; + + public List getCompSndSelectedElemList() { + return compSndSelectedElemList; + } + + // end FixMark:nearByStnCompSnd + public List>> getStnTimeSndTable() { + return stnTimeSndTable; + } + + public List getAllLoadedSndDesciptionList() { + List strLst = new ArrayList(); + for (List> tlListList : stnTimeSndTable) { + // add a new element for the new sndType to each existing sndlist of + // each existing time of each existing stnId + for (List sndtyList : tlListList) { + for (NsharpSoundingElementStateProperty elem : sndtyList) { + if (elem != null) + strLst.add(elem.getElementDescription()); + } + } + } + return strLst; + } + + public List getStnElementList() { + return stnElementList; + } + + public List getTimeElementList() { + return timeElementList; + } + + public List getSndElementList() { + return sndElementList; + } + + public int getCurrentStnElementListIndex() { + return currentStnElementListIndex; + } + + public int getCurrentTimeElementListIndex() { + return currentTimeElementListIndex; + } + + public int getTimeElementListSize() { + return timeElementList.size(); + } + + public int getCurrentSndElementListIndex() { + return currentSndElementListIndex; + } + + // shape and color storage + public class ShapeAndLineProperty { + IWireframeShape shape; + + NsharpLineProperty lp; + + public ShapeAndLineProperty() { + super(); + lp = new NsharpLineProperty(); + } + + } + + public HashMap getLinePropertyMap() { + return linePropertyMap; + } + + public boolean isCompareStnIsOn() { + return compareStnIsOn; + } + + public boolean isCompareTmIsOn() { + return compareTmIsOn; + } + + public boolean isCompareSndIsOn() { + return compareSndIsOn; + } + + public boolean isOverlayIsOn() { + return overlayIsOn; + } + + public NsharpNative getNsharpNative() { + return nsharpNative; + } + + public void setNextTextChapter() { + if (currentTextChapter == displayDataPageMax) { + currentTextChapter = 1; + } else { + currentTextChapter++; + // d2dlite if one page per chap case, skip future page + if ((dataPageProperty.getNumberPagePerDisplay() == 1 || paneConfigurationName + .equals(NsharpConstants.PANE_LITE_D2D_CFG_STR)) + && currentTextChapter == displayDataPageMax) + currentTextChapter = 1; + } + } + + // start d2dlite + public void setPrevTextChapter() { + currentTextChapter--; + if (currentTextChapter == 0) { + currentTextChapter = displayDataPageMax; + // d2dlite if one page per chap case, skip future page + if (dataPageProperty.getNumberPagePerDisplay() == 1 + || paneConfigurationName + .equals(NsharpConstants.PANE_LITE_D2D_CFG_STR)) + currentTextChapter = displayDataPageMax - 1; + } + } + + public void setPrevInsetPage() { + currentInsetPage--; + if (currentInsetPage == 0) { + currentInsetPage = INSETPAGEMAX; + } + } + + // end d2dlite + public void setNextInsetPage() { + if (currentInsetPage == INSETPAGEMAX) { + currentInsetPage = 1; + } else + currentInsetPage++; + } + + public void setOverlayIsOn(boolean overlay) { + previousSoundingLys = null; + previousTimeLineStateListIndex = -1; + preSndProfileProp = null; + this.overlayIsOn = overlay; + + if (hodoPaneRsc != null) + hodoPaneRsc.createRscHodoWindShapeAll(); + if (skewtPaneRsc != null) + skewtPaneRsc.handleResize(); + } + + public boolean isInterpolateIsOn() { + return interpolateIsOn; + } + + /* + * When compareStnIsOn is changed, + */ + public void setCompareStnIsOn(boolean compareIsOn) { + this.compareStnIsOn = compareIsOn; + + // This is the case when sounding data is not available at + // currentTimeElementListIndex/currentSndElementListIndex/currentStnElementListIndex + // and user set + // compare stn on. + if (compareStnIsOn) { + if (soundingLys == null && currentTimeElementListIndex >= 0 + && currentSndElementListIndex >= 0) { + // find a new available stn for current time and sndType + boolean found = false; + for (int i = 0; i < stnElementList.size(); i++) { + if (stnElementList.get(i).getActionState() == NsharpConstants.ActState.ACTIVE + && stnTimeSndTable.get(i) + .get(currentTimeElementListIndex) + .get(currentSndElementListIndex) != null) { + found = true; + currentStnElementListIndex = i; + } + + if (found) + break; + } + if (!found) + return; + } + + int colorIndex = NsharpConstants.LINE_COMP1; + for (NsharpOperationElement elm : stnElementList) { + int stnIndex = stnElementList.indexOf(elm); + NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable + .get(stnIndex).get(currentTimeElementListIndex) + .get(currentSndElementListIndex); + if (stnTmElm != null) { + stnTmElm.setCompColorIndex(colorIndex); + // if(colorIndex > NsharpConstants.LINE_COMP10) + // colorIndex = NsharpConstants.LINE_COMP1; + } + colorIndex++; + if (colorIndex > NsharpConstants.LINE_COMP10) + colorIndex = NsharpConstants.LINE_COMP1; + } + } + setCurSndProfileProp(); + setCurrentSoundingLayerInfo(); + resetData(); + } + + // start FixMark:nearByStnCompSnd + public void setCompareSndIsOn(boolean compareSndIsOn) { + this.compareSndIsOn = compareSndIsOn; + // This is the case when sounding data is not available at + // currentTimeElementListIndex/currentSndElementListIndex/currentStnElementListIndex + // and user set + // compSnd on + if (compareSndIsOn) { + if (soundingLys == null && currentStnElementListIndex >= 0 + && currentTimeElementListIndex >= 0) { + // find a new available snd type for current time and stn + boolean found = false; + for (int i = 0; i < sndElementList.size(); i++) { + if (sndElementList.get(i).getActionState() == NsharpConstants.ActState.ACTIVE + && stnTimeSndTable.get(currentStnElementListIndex) + .get(currentTimeElementListIndex).get(i) != null) { + found = true; + currentSndElementListIndex = i; + } + if (found) + break; + } + if (!found) + return; + } + int colorIndex = NsharpConstants.LINE_COMP1; + + /* + * The following code is to create a list of stns within the range + * of user defined radius (minimum distance) to "current" station + * and also has data loaded with same time line as "current" time + * line. Note that we have two time line formats, yymmdd/hh(day)Vxxx + * and yymmdd/hh(day). A same time line is compared by yymmdd/hh + * only. All qualified stations, including current station, found + * will be listed and used for SND comparison. + */ + compSndSelectedElemList.clear(); + // CompSndSelectedElem curStnTimeIndexCouple = new + // CompSndSelectedElem(currentStnElementListIndex,currentTimeElementListIndex,currentSndElementListIndex); + // compSndSelectedElemList.add(curStnTimeIndexCouple); //current + // station/time line/sounding element is always added to the list + GeodeticCalculator gc = new GeodeticCalculator( + DefaultEllipsoid.WGS84); + NsharpStationInfo currentStnInfo = stnTimeSndTable + .get(currentStnElementListIndex) + .get(currentTimeElementListIndex) + .get(currentSndElementListIndex).getStnInfo(); + gc.setStartingGeographicPoint(currentStnInfo.getLongitude(), + currentStnInfo.getLatitude()); + int timeLineLengthToComp = "yymmdd/hh".length(); + String currentTimeLineToComp = timeElementList + .get(currentTimeElementListIndex).getElementDescription() + .substring(0, timeLineLengthToComp); + // loop through stns list to find "ACTIVE" stns which are within snd + // comparison radius + for (int i = 0; i < stnElementList.size(); i++) { + if (stnElementList.get(i).getActionState() == NsharpConstants.ActState.ACTIVE) { + // check if target station is within minimum distance + // (radius) from current station + // we have to get this station's lat/lon for distance + // computation + // by getting first available + // NsharpSoundingElementStateProperty of this station at + // current time line + // if distance to current station is smaller than minimum + // distance then add it to list + for (int k = 0; k < timeElementList.size(); k++) { + boolean goodTimeLine = false; + if (k != currentTimeElementListIndex) { + String timeToCopm1 = timeElementList.get(k) + .getElementDescription() + .substring(0, timeLineLengthToComp); + if (currentTimeLineToComp.equals(timeToCopm1) == true) { + goodTimeLine = true; + } + } else + goodTimeLine = true; // currentTimeElementListIndex + // is sure to be a good time + // line to use + if (goodTimeLine == true) { + for (int j = 0; j < sndElementList.size(); j++) { + NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable + .get(i).get(k).get(j); + if (stnTmElm != null) { + if ((currentStnElementListIndex == i) + || (currentStnElementListIndex != i && currentSndElementListIndex != j)) { + NsharpStationInfo stnInfo = stnTmElm + .getStnInfo(); + gc.setDestinationGeographicPoint( + stnInfo.getLongitude(), + stnInfo.getLatitude()); + double distance = gc + .getOrthodromicDistance(); + // GeodeticCalculator return value in + // meter + // convert it to mile + if (distance / 1609.344 <= sndCompRadius) { + CompSndSelectedElem selectedElem = new CompSndSelectedElem( + i, k, j); + compSndSelectedElemList + .add(selectedElem); + // stnTmElm.setCompColorIndex(colorIndex); + // colorIndex++; + // if(colorIndex > + // NsharpConstants.LINE_COMP10) + // colorIndex = + // NsharpConstants.LINE_COMP1; + } + } + } + } + } + } + } + } + // now set colors here to keep color assignment (numbers) always + // consistently counting from first snd source down + for (int j = 0; j < sndElementList.size(); j++) { + for (CompSndSelectedElem elem : compSndSelectedElemList) { + if (elem.getSndIndex() == j) { + NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable + .get(elem.getStnIndex()) + .get(elem.getTimeIndex()).get(j); + stnTmElm.setCompColorIndex(colorIndex); + colorIndex++; + if (colorIndex > NsharpConstants.LINE_COMP10) + colorIndex = NsharpConstants.LINE_COMP1; + } + } + } + } else { + compSndSelectedElemList.clear(); + } + setCurSndProfileProp(); + setCurrentSoundingLayerInfo(); + resetData(); + } + + /*** + * original code public void setCompareSndIsOn(boolean compareSndIsOn) { + * this.compareSndIsOn = compareSndIsOn; //This is the case when sounding + * data is not available at + * currentTimeElementListIndex/currentSndElementListIndex + * /currentStnElementListIndex and user set // compSnd on + * if(compareSndIsOn){ if(soundingLys==null && currentStnElementListIndex + * >=0 && currentTimeElementListIndex >=0){ //find a new available snd type + * for current time and stn boolean found = false; for(int i =0; i< + * sndElementList.size(); i++){ if(sndElementList.get(i).getActionState() == + * NsharpConstants.ActState.ACTIVE && + * stnTimeSndTable.get(currentStnElementListIndex + * ).get(currentTimeElementListIndex).get(i)!=null){ found = true; + * currentSndElementListIndex = i; } if(found) break; } if(!found) return; } + * int colorIndex = NsharpConstants.LINE_COMP1; for(NsharpOperationElement + * elm: sndElementList) { int sndIndex = sndElementList.indexOf(elm); + * NsharpSoundingElementStateProperty stnTmElm = + * stnTimeSndTable.get(currentStnElementListIndex + * ).get(currentTimeElementListIndex).get(sndIndex); if(stnTmElm!=null){ + * stnTmElm.setCompColorIndex(colorIndex); //if(colorIndex > + * NsharpConstants.LINE_COMP10) // colorIndex = NsharpConstants.LINE_COMP1; + * } colorIndex++; if(colorIndex > NsharpConstants.LINE_COMP10) colorIndex = + * NsharpConstants.LINE_COMP1; } } setCurSndProfileProp(); + * setCurrentSoundingLayerInfo(); resetData(); + * + * } + ***/ + // end FixMark:nearByStnCompSnd + + public void setCompareTmIsOn(boolean compareIsOn) { + this.compareTmIsOn = compareIsOn; + // This is the case when sounding data is not available at + // currentTimeElementListIndex/currentSndElementListIndex/currentStnElementListIndex + // and user set + // compTm on + if (compareIsOn) { + if (soundingLys == null && currentStnElementListIndex >= 0 + && currentSndElementListIndex >= 0) { + // find a new available time line for current snd type and stn + boolean found = false; + for (int i = 0; i < timeElementList.size(); i++) { + if (timeElementList.get(i).getActionState() == NsharpConstants.ActState.ACTIVE + && stnTimeSndTable.get(currentStnElementListIndex) + .get(i).get(currentSndElementListIndex) != null) { + found = true; + currentTimeElementListIndex = i; + } + if (found) + break; + } + if (!found) + return; + } + int colorIndex = NsharpConstants.LINE_COMP1; + for (NsharpOperationElement elm : timeElementList) { + int tmIndex = timeElementList.indexOf(elm); + NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable + .get(currentStnElementListIndex).get(tmIndex) + .get(currentSndElementListIndex); + if (stnTmElm != null) { + stnTmElm.setCompColorIndex(colorIndex); + // if(colorIndex > NsharpConstants.LINE_COMP10) + // colorIndex = NsharpConstants.LINE_COMP1; + } + colorIndex++; + if (colorIndex > NsharpConstants.LINE_COMP10) + colorIndex = NsharpConstants.LINE_COMP1; + } + } + setCurSndProfileProp(); + setCurrentSoundingLayerInfo(); + resetData(); + } + + public void setEditGraphOn(boolean editGraphOn) { + this.editGraphOn = editGraphOn; + } + + public boolean isEditGraphOn() { + return editGraphOn; + } + + public int getCurrentGraphMode() { + return currentGraphMode; + } + + public void setCurrentGraphMode(int currentGraphMode) { + this.currentGraphMode = currentGraphMode; + if (!paneConfigurationName + .equals(NsharpConstants.PANE_LITE_D2D_CFG_STR)) { + if (skewtPaneRsc != null) + skewtPaneRsc.setCurrentGraphMode(currentGraphMode); + refreshPane(); + } else { + NsharpEditor editor = NsharpEditor.getActiveNsharpEditor(); + if (editor == null) { + return; + } + editor.restartEditor(paneConfigurationName); + } + } + + public short getCurrentParcel() { + return currentParcel; + } + + // native nsharp c/fortran lib + // NsharpNative is native nsharp lib awips/lib/libnsharp.so wrapper class + + public float getSmWindDir() { + return smWindDir; + } + + public float getSmWindSpd() { + return smWindSpd; + } + + public void setCurrentHodoWindMode(int cursorPositionIndex) { + switch (cursorPositionIndex) { + case 0: + this.currentHodoWindMode = HODO_NORMAL; + break; + case 1: + this.currentHodoWindMode = HODO_STORMRELATIVE; + break; + case 2: + default: + this.currentHodoWindMode = HODO_MEANWIND; + break; + } + } + + public NsharpStationInfo getPickedStnInfo() { + return pickedStnInfo; + } + + public String getSoundingType() { + return soundingType; + } + + public void setSoundingType(String soundingType) { + this.soundingType = soundingType; + } + + public void setCurrentParcel(short currentParcel) { + this.currentParcel = currentParcel; + currentParcelLayerPressure = NsharpNativeConstants.parcelToLayerMap + .get(currentParcel); + // inform data/skewT panel as well + if (dataPaneRsc != null) { + dataPaneRsc.setCurrentParcel(currentParcel); + } + if (skewtPaneRsc != null) { + if (currentParcel == NsharpNativeConstants.PARCELTYPE_USER_DEFINED) + currentParcelLayerPressure = NsharpParcelDialog + .getUserDefdParcelMb(); + skewtPaneRsc.createRscParcelTraceShapes(currentParcel, + currentParcelLayerPressure); + skewtPaneRsc.createRscParcelRtTraceShapesList(currentParcel, + currentParcelLayerPressure); + skewtPaneRsc.createLCLEtcLinesShape(); + } + } + + public void updateParcelFromPanel(short currentParcel) { + this.currentParcel = currentParcel; + currentParcelLayerPressure = NsharpNativeConstants.parcelToLayerMap + .get(currentParcel); + if (skewtPaneRsc != null) { + skewtPaneRsc.createRscParcelTraceShapes(currentParcel, + currentParcelLayerPressure); + skewtPaneRsc.createRscParcelRtTraceShapesList(currentParcel, + currentParcelLayerPressure); + skewtPaneRsc.createLCLEtcLinesShape(); + } + } + + public void setHodoStmCenter(Coordinate hodoHouseC) { + if (hodoPaneRsc == null) + return; + // hodoPaneRsc.setHodoHouseC(hodoHouseC); + Coordinate c = hodoPaneRsc.getHodoBackground().getWorld() + .unMap(hodoHouseC.x, hodoHouseC.y); + c = WxMath.speedDir((float) c.x, (float) c.y); + smWindDir = (float) c.y; + smWindSpd = (float) c.x; + nsharpNative.nsharpLib.set_storm(smWindSpd, smWindDir); + if (insetPaneRsc != null) { + WGraphics WGc = insetPaneRsc.getPsblWatchTypeBackground() + .getWorld(); + insetPaneRsc.createBkgPsblWatchShape(WGc); + + // Sr wind vs Height graph shape need to recreate + WGc = insetPaneRsc.getSrWindsBackground().getWorld(); + insetPaneRsc.createRscSrWindShape(WGc); + } + if (skewtPaneRsc != null) { + skewtPaneRsc.createEffectiveLayerLinesShape(); + skewtPaneRsc.updatePsblWatchColor(); + } + } + + // This function is called only when interpolation "on/off" is changed by + // user + public void resetInfoOnInterpolate(boolean interpolateIsOn) + throws CloneNotSupportedException { + // We dont want to assume previous interpolation on/off state. So, reset + // soundingLys any how. + this.interpolateIsOn = interpolateIsOn; + NsharpSoundingElementStateProperty elem = getCurSoundingElementStateProperty(); + if (elem != null) { + if (interpolateIsOn == false) { + soundingLys = elem.getSndLyLst(); + + } else { + /* + * //TTR829 //interpolation is on //we dont want to change + * original raw data, so use a deep copy List + * intpSndLst = new ArrayList(); + * for(NcSoundingLayer layer: elem.getSndLyLst() ) { + * intpSndLst.add((NcSoundingLayer) layer.clone()); } + * + * // interpolation intpSndLst = + * performInterpolation(intpSndLst); + * + * soundingLys = intpSndLst; + */ + // end TTR829 + soundingLys = performInterpolation(soundingLys); + } + + nsharpNative.populateSndgData(soundingLys); + if (skewtPaneRsc != null) + skewtPaneRsc.resetData(soundingLys, previousSoundingLys); + if (hodoPaneRsc != null) + hodoPaneRsc.resetData(soundingLys, previousSoundingLys); + if (witoPaneRsc != null) + witoPaneRsc.resetData(soundingLys, previousSoundingLys); + if (dataPaneRsc != null) + dataPaneRsc.resetData(soundingLys, previousSoundingLys); + if (insetPaneRsc != null) + insetPaneRsc.resetData(soundingLys, previousSoundingLys); + + // re-create shape + if (skewtPaneRsc != null) + skewtPaneRsc.handleResize(); + if (hodoPaneRsc != null) + hodoPaneRsc.createRscHodoWindShapeAll(); + if (insetPaneRsc != null) + insetPaneRsc.createInsetWireFrameShapes(); + if (witoPaneRsc != null) + witoPaneRsc.createRscWireFrameShapes(); + + } + + } + + public void handleNsharpEditorPartEvent(NsharpPartListener.PartEvent pStatus) { + switch (pStatus) { + case partActivated: + if (editorPartStatus != NsharpPartListener.PartEvent.partDeactivated) { + // repopulateSndgData(); + // resetRsc(); + resetData(); + } + + break; + default: + break; + } + editorPartStatus = pStatus; + } + + public void resetRsc() { + restoreAllSoundingData(); + NsharpSoundingElementStateProperty elem = getCurSoundingElementStateProperty(); + if (elem != null) { + this.soundingLys = elem.getSndLyLst(); + // Set default parcel trace data + currentParcel = NsharpNativeConstants.PARCELTYPE_MOST_UNSTABLE; + currentParcelLayerPressure = NsharpNativeConstants.MU_LAYER; + setSoundingInfo(this.soundingLys); + currentTextChapter = 1; + overlayIsOn = false; + interpolateIsOn = false; + compareStnIsOn = false; + compareSndIsOn = false; + compareTmIsOn = false; + editGraphOn = false; + if (skewtPaneRsc != null) + skewtPaneRsc + .setCurrentSkewTEditMode(NsharpConstants.SKEWT_EDIT_MODE_EDITPOINT); + resetData(); + } + + } + + public synchronized void resetData() { + // System.out.println("resetData called, rscHdr="+this.toString() + + // " pickedStnInfoStr="+pickedStnInfoStr+ + // " nsharpNative="+nsharpNative.toString()); + + // update active sounding layer and picked stn info + // re-populate snd data to nsharp native code lib for later calculating + nsharpNative.populateSndgData(soundingLys); + if (skewtPaneRsc != null) + skewtPaneRsc.resetData(soundingLys, previousSoundingLys); + if (hodoPaneRsc != null) + hodoPaneRsc.resetData(soundingLys, previousSoundingLys); + if (insetPaneRsc != null) + insetPaneRsc.resetData(soundingLys, previousSoundingLys); + if (dataPaneRsc != null) + dataPaneRsc.resetData(soundingLys, previousSoundingLys); + if (witoPaneRsc != null) + witoPaneRsc.resetData(soundingLys, previousSoundingLys); + + NsharpShowTextDialog textarea = NsharpShowTextDialog.getAccess(); + if (textarea != null) { + textarea.refreshTextData(); + } + // if soundingLys is null, then we stop here, after reset data. + if (soundingLys == null) + return; + if (soundingLys.size() > 0) { + // set initial hodohouseC + + // ----- set hodo circle at Bunkers Right, Chin according to TTR6065 + // or RaytheonTicket#10438 + FloatByReference dummy1 = new FloatByReference(-999); + FloatByReference dummy2 = new FloatByReference(-999); + FloatByReference bwdir = new FloatByReference(-999); + FloatByReference bwspd = new FloatByReference(-999); + nsharpNative.nsharpLib.bunkers_storm_motion(dummy1, dummy2, bwdir, + bwspd); + // System.out.println("resetData windspd="+ bwspd.getValue()+ + // " dir="+bwdir.getValue()); + smWindSpd = bwspd.getValue(); + smWindDir = bwdir.getValue(); + nsharpNative.nsharpLib.set_storm(smWindSpd, smWindDir); + + // reset parcel + currentParcel = NsharpNativeConstants.PARCELTYPE_MOST_UNSTABLE; + currentParcelLayerPressure = NsharpNativeConstants.MU_LAYER; + // reset parcel dialog as well + if (NsharpParcelDialog.getAccess() != null) { + NsharpParcelDialog.getAccess().resetUserDefParcel(); + } + /* + * Chin::: This api is called in many scenarios. User may want to + * keep his previous picked parcel type. Therefore, + * thdataPaneRsc.resetCurrentParcel should be called from other area + * that really meant to reset parcel type. + */ + } + // Chin: TBD remove handle resize here to fix sizing issue when swapped + // nsharp from side pane back to main pane + // but, may cause other problem? + // if(skewtPaneRsc!=null) + // skewtPaneRsc.handleResize(); + if (skewtPaneRsc != null) + skewtPaneRsc.createRscWireFrameShapes(); + if (hodoPaneRsc != null) + hodoPaneRsc.createRscHodoWindShapeAll(); + if (insetPaneRsc != null) + insetPaneRsc.createInsetWireFrameShapes(); + if (witoPaneRsc != null) + witoPaneRsc.createAllWireFrameShapes(); + } + + private class NsharpOperationElementComparator implements + Comparator { + @Override + public int compare(NsharpOperationElement o1, NsharpOperationElement o2) { + + String s1tok1 = "";// , s1tok2=""; + String s2tok1 = "";// , s2tok2=""; + StringTokenizer st1 = new StringTokenizer( + o1.getElementDescription()); + int tkCount1 = st1.countTokens(); + // System.out.println("ElementComparatorTimeLine o1="+o1.elementDescription+"c1 = "+tkCount1); + if (tkCount1 >= 1) { + s1tok1 = st1.nextToken(); + } else { + return 0; + + } + // System.out.println("t1="+s1tok1+" t2="+s2tok1); + StringTokenizer st2 = new StringTokenizer( + o2.getElementDescription()); + int tkCount2 = st2.countTokens(); + // System.out.println("ElementComparatorTimeLine o2="+o2.elementDescription+"c2 = "+tkCount2); + if (tkCount2 >= 1) { + s2tok1 = st2.nextToken(); + } else { + return 0; + + } + // System.out.println("t1="+s2tok1+" t2="+s2tok2); + if (s1tok1.compareTo(s2tok1) == 0) { + return 0; + } else if (s1tok1.compareTo(s2tok1) < 0) { + return 1; + } else if (s1tok1.compareTo(s2tok1) > 0) { + return -1; + } + return 0; + } + } + + private int getIndexFromElementList(String targetDescription, + List elemLst) { + for (NsharpOperationElement sndProp : elemLst) { + if (sndProp.getElementDescription().equals(targetDescription)) + return elemLst.indexOf(sndProp); + + } + return -1; + } + + private void restoreAllSoundingData() { + for (List> tlListList : stnTimeSndTable) { + // add a new element for the new sndType to each existing sndlist of + // each existing time of each existing stnId + for (List sndtyList : tlListList) { + for (NsharpSoundingElementStateProperty elem : sndtyList) { + if (elem != null) + elem.restoreSndLyLstFromBackup(); + } + } + } + } + + private int addElemToElemList(String elemDesc, + List elemList) { + NsharpOperationElement elem = new NsharpOperationElement(elemDesc, + NsharpConstants.ActState.ACTIVE); + elemList.add(elem); + Collections.sort(elemList, new NsharpOperationElementComparator()); + return elemList.indexOf(elem); + } + + private void addNewSndToStnTimeSndTable(int sndIndex) { + for (List> tlListList : stnTimeSndTable) { + // add a new element for the new sndType to each existing sndlist of + // each existing time of each existing stnId + for (List sndtyList : tlListList) { + sndtyList.add(sndIndex, null); + } + } + } + + private void addNewStnToStnTimeSndTable(int stnIndex) { + // Add new stnid to outer list of stnTimeSndTable + List> listListForNewStn = new ArrayList>(); + // based on new stn id, add list for each existing time line + for (int i = 0; i < timeElementList.size(); i++) { + // based on each time line, add element for each existing sndType + List sndListForTm = new ArrayList(); + for (int j = 0; j < sndElementList.size(); j++) { + sndListForTm.add(null); + } + listListForNewStn.add(sndListForTm); + } + stnTimeSndTable.add(stnIndex, listListForNewStn); + } + + private void addNewTimeToStnTimeSndTable(int timeIndex) { + for (List> tlListList : stnTimeSndTable) { + // based on sndTypeElementList + // create sndlist for the new time line for each existing stnid + List newSndList = new ArrayList(); + for (int i = 0; i < sndElementList.size(); i++) { + newSndList.add(null); + } + // add sndlist for the new time line to stn list + tlListList.add(timeIndex, newSndList); + } + } + + private void addElementToTableAndLists(String stnId_timeLine_sndType, + String stnId, String tmLine, String sndType, + NsharpStationInfo stnInfo, List sndLyLst) { + // System.out.println("stn to be added "+ stnId + " timeline "+tmLine); + NsharpSoundingElementStateProperty newSndPropElem = null; + int tmIndex = getIndexFromElementList(tmLine, timeElementList); + int stnIndex = getIndexFromElementList(stnId, stnElementList); + int sndTpyeIndex = getIndexFromElementList(sndType, sndElementList); + currentTimeElementListIndex = tmIndex; + currentStnElementListIndex = stnIndex; + currentSndElementListIndex = sndTpyeIndex; + // based on these 3 indexes, we have 8 cases to handle. + if (tmIndex >= 0 && stnIndex >= 0 && sndTpyeIndex >= 0) { + // CASE1: All 3 index are good (>=0) + if (stnTimeSndTable.get(stnIndex).get(tmIndex).get(sndTpyeIndex) != null) + // this sounding element is already loaded + return; + else { + // replace previously added "null" object with real + // NsharpSoundingElementStateProperty object + newSndPropElem = new NsharpSoundingElementStateProperty( + stnId_timeLine_sndType, stnId, tmLine, stnInfo, + sndLyLst); + stnTimeSndTable.get(stnIndex).get(tmIndex) + .set(sndTpyeIndex, newSndPropElem); + } + } else if (tmIndex >= 0) { + if (stnIndex >= 0) { + // CASE2 : tmIndex/stnIndex are good (>=0), sndTpyeIndex is bad + // (<0), a new snd type + // add new sndType to sndTypeElementList + currentSndElementListIndex = addElemToElemList(sndType, + sndElementList); + // Add new snd type to each snd type list of stnTimeSndTable + addNewSndToStnTimeSndTable(currentSndElementListIndex); + // replace previously added "null" object with real + // NsharpSoundingElementStateProperty object + newSndPropElem = new NsharpSoundingElementStateProperty( + stnId_timeLine_sndType, stnId, tmLine, stnInfo, + sndLyLst); + stnTimeSndTable.get(currentStnElementListIndex) + .get(currentTimeElementListIndex) + .set(currentSndElementListIndex, newSndPropElem); + } else { + if (sndTpyeIndex >= 0) { + // CASE3 : tmIndex/sndTpyeIndex are good, stnIndex is bad + // (<0), a new stnId + // add new stn to stnElementList + currentStnElementListIndex = addElemToElemList(stnId, + stnElementList); + // Add new stnid to outer list of stnTimeSndTable + addNewStnToStnTimeSndTable(currentStnElementListIndex); + // replace previously added "null" object with real + // NsharpSoundingElementStateProperty object + newSndPropElem = new NsharpSoundingElementStateProperty( + stnId_timeLine_sndType, stnId, tmLine, stnInfo, + sndLyLst); + stnTimeSndTable.get(currentStnElementListIndex) + .get(currentTimeElementListIndex) + .set(currentSndElementListIndex, newSndPropElem); + + } else { + // CASE4 : tmIndex is good, stnIndex/sndTpyeIndex are bad + // (<0), new stnId and new snd type + // add new stn to stnElementList + currentStnElementListIndex = addElemToElemList(stnId, + stnElementList); + // add new sndType to sndTypeElementList + currentSndElementListIndex = addElemToElemList(sndType, + sndElementList); + // Add new snd type to each snd type list of stnTimeSndTable + addNewSndToStnTimeSndTable(currentSndElementListIndex); + // Add new stnid to outer list of stnTimeSndTable + addNewStnToStnTimeSndTable(currentStnElementListIndex); + // replace previously added "null" object with real + // NsharpSoundingElementStateProperty object + newSndPropElem = new NsharpSoundingElementStateProperty( + stnId_timeLine_sndType, stnId, tmLine, stnInfo, + sndLyLst); + stnTimeSndTable.get(currentStnElementListIndex) + .get(currentTimeElementListIndex) + .set(currentSndElementListIndex, newSndPropElem); + + } + } + } else { + if (stnIndex >= 0) { + if (sndTpyeIndex >= 0) { + // CASE5 : stnIndex/sndTpyeIndex are good, tmIndex is bad + // (<0) + // add new time line to timeElementList + currentTimeElementListIndex = addElemToElemList(tmLine, + timeElementList); + // add new time line to StnTimeSndTable + addNewTimeToStnTimeSndTable(currentTimeElementListIndex); + // replace previously added "null" object with real + // NsharpSoundingElementStateProperty object + newSndPropElem = new NsharpSoundingElementStateProperty( + stnId_timeLine_sndType, stnId, tmLine, stnInfo, + sndLyLst); + stnTimeSndTable.get(currentStnElementListIndex) + .get(currentTimeElementListIndex) + .set(currentSndElementListIndex, newSndPropElem); + + } else { + // CASE6 : stnIndex is good, tmIndex/sndTpyeIndex are bad + // (<0) + // add new time line to timeElementList + currentTimeElementListIndex = addElemToElemList(tmLine, + timeElementList); + // add new sndType to sndTypeElementList + currentSndElementListIndex = addElemToElemList(sndType, + sndElementList); + // Add new snd type to each snd type list of stnTimeSndTable + addNewSndToStnTimeSndTable(currentSndElementListIndex); + // add new time line to StnTimeSndTable + addNewTimeToStnTimeSndTable(currentTimeElementListIndex); + // replace previously added "null" object with real + // NsharpSoundingElementStateProperty object + newSndPropElem = new NsharpSoundingElementStateProperty( + stnId_timeLine_sndType, stnId, tmLine, stnInfo, + sndLyLst); + stnTimeSndTable.get(currentStnElementListIndex) + .get(currentTimeElementListIndex) + .set(currentSndElementListIndex, newSndPropElem); + + } + + } else { + if (sndTpyeIndex >= 0) { + // CASE7 : sndTpyeIndex is good, tmIndex/stnIndex are bad + // (<0) + // add new time line to timeElementList + currentTimeElementListIndex = addElemToElemList(tmLine, + timeElementList); + // add new stn to stnElementList + currentStnElementListIndex = addElemToElemList(stnId, + stnElementList); + // add new time line to StnTimeSndTable + addNewTimeToStnTimeSndTable(currentTimeElementListIndex); + // Add new stnid to outer list of stnTimeSndTable + addNewStnToStnTimeSndTable(currentStnElementListIndex); + // replace previously added "null" object with real + // NsharpSoundingElementStateProperty object + newSndPropElem = new NsharpSoundingElementStateProperty( + stnId_timeLine_sndType, stnId, tmLine, stnInfo, + sndLyLst); + stnTimeSndTable.get(currentStnElementListIndex) + .get(currentTimeElementListIndex) + .set(currentSndElementListIndex, newSndPropElem); + + } else { + // CASE8 : All are bad (<0) + // an element with new time line, new stnId and new sndType + // add new time line to timeElementList + currentTimeElementListIndex = addElemToElemList(tmLine, + timeElementList); + // add new stn to stnElementList + currentStnElementListIndex = addElemToElemList(stnId, + stnElementList); + // add new sndType to sndTypeElementList + currentSndElementListIndex = addElemToElemList(sndType, + sndElementList); + + // Construct stnTimeSndTable + if (stnTimeSndTable.size() > 0) { + List> listListForNewStn = new ArrayList>(); + // based on new stn id, add list for each existing time + // line + for (NsharpOperationElement tmElem : timeElementList) { + // based on each time line, add element for each + // existing sndType + List sndlistForTm = new ArrayList(); + for (NsharpOperationElement sndElem : sndElementList) { + if (tmLine.equals(tmElem + .getElementDescription()) + && sndType.equals(sndElem + .getElementDescription())) { + // only one case falls in this route as only + // one new loaded sounding data + newSndPropElem = new NsharpSoundingElementStateProperty( + stnId_timeLine_sndType, stnId, + tmLine, stnInfo, sndLyLst); + + sndlistForTm.add(newSndPropElem); + } else { + // create for not avail sounding profiles + sndlistForTm.add(null); + } + } + listListForNewStn.add(sndlistForTm); + } + + // Now update stnTimeSndTable by adding "dummy" + // NsharpSoundingElementStateProperty to all exiting stn + // listList and time list + // Note that we have NOT added "listListForNewStn" to + // stnTimeSndTable yet. + // we have to update current table now + for (List> tlListList : stnTimeSndTable) { + // add a new element for the new sndType to each + // existing sndlist of each existing time of each + // existing stnId + for (List sndtyList : tlListList) { + sndtyList.add(currentSndElementListIndex, null); + } + // based on sndTypeElementList + // add a new sndlist for the new time line for each + // existing stnid + List newSndList = new ArrayList(); + for (int i = 0; i < sndElementList.size(); i++) { + { + newSndList.add(null); + } + } + tlListList.add(currentTimeElementListIndex, + newSndList); + } + // finally, add this new stn list to table + stnTimeSndTable.add(currentStnElementListIndex, + listListForNewStn); + } else { + // this is the case, we are adding first element to + // stnTimeSndTable + // need a new stn time line list to stnTimeSndTable + List newList = new ArrayList(); + List> newListList = new ArrayList>(); + + newSndPropElem = new NsharpSoundingElementStateProperty( + stnId_timeLine_sndType, stnId, tmLine, stnInfo, + sndLyLst); + newList.add(newSndPropElem); + newListList.add(newList); + stnTimeSndTable.add(newListList); + curSndProfileProp = newSndPropElem; + return; + } + + } + } + } + setCurSndProfileProp(); + + } + + private void setCurSndProfileProp() { + if (currentTimeElementListIndex < 0 + || currentTimeElementListIndex >= timeElementList.size() + || currentStnElementListIndex < 0 + || currentStnElementListIndex >= stnElementList.size() + || currentSndElementListIndex < 0 + || currentSndElementListIndex >= sndElementList.size()) { + curSndProfileProp = null; + preSndProfileProp = null; + } else { + preSndProfileProp = curSndProfileProp; + curSndProfileProp = stnTimeSndTable.get(currentStnElementListIndex) + .get(currentTimeElementListIndex) + .get(currentSndElementListIndex); + } + } + + private void cleanUpStnTimeSndTable(int stni, int tmi, int sndi) { + boolean found = false; + // find if this station is no longer in use + List> tlListList = stnTimeSndTable + .get(stni); + for (List sndtyList : tlListList) { + for (NsharpSoundingElementStateProperty elem : sndtyList) { + if (elem != null) { + found = true; + break; + } + } + if (found) + break; + } + if (!found) { + // This stn is no longer in use...delete it from stnTimeSndTable and + // stnElementList + stnElementList.remove(stni); + tlListList = stnTimeSndTable.remove(stni); + tlListList.clear(); + } + // find if this time line is no longer in use + found = false; + for (List> tmListListForStn : stnTimeSndTable) { + List sndtyListForTm = tmListListForStn + .get(tmi); + for (NsharpSoundingElementStateProperty elem : sndtyListForTm) { + if (elem != null) { + found = true; + break; + } + } + if (found) + break; + } + if (!found) { + // This time line is no longer in use...delete it from + // stnTimeSndTable and timeElementList + timeElementList.remove(tmi); + for (List> tmListListForStn : stnTimeSndTable) { + List sndtyListForTm = tmListListForStn + .remove(tmi); + sndtyListForTm.clear(); + } + } + // find if this sounding type is no longer in use + found = false; + for (List> tmListListForStn : stnTimeSndTable) { + for (List sndtyListForTm : tmListListForStn) { + NsharpSoundingElementStateProperty elem = sndtyListForTm + .get(sndi); + if (elem != null) { + found = true; + break; + } + } + if (found) + break; + } + if (!found) { + // This sounding type is no longer in use...delete it from + // stnTimeSndTable and sndElementList + sndElementList.remove(sndi); + for (List> tmListListForStn : stnTimeSndTable) { + for (List sndtyListForTm : tmListListForStn) { + sndtyListForTm.remove(sndi); + } + } + } + + } + + public boolean deleteRsc(List deletingDataTimeList) { + boolean curSndDeleted = false; + for (String dataTmLine : deletingDataTimeList) { + if (curSndProfileProp != null + && curSndProfileProp.getElementDescription().equals( + dataTmLine)) { + curSndDeleted = true; + } + // find deleting element from stnTimeSndTable and null it + boolean setdone = false; + for (List> tlListList : stnTimeSndTable) { + for (List sndtyList : tlListList) { + for (NsharpSoundingElementStateProperty elem : sndtyList) { + if (elem != null + && dataTmLine.equals(elem + .getElementDescription())) { + int sndi = sndtyList.indexOf(elem); + int tmi = tlListList.indexOf(sndtyList); + int stni = stnTimeSndTable.indexOf(tlListList); + sndtyList.set(sndtyList.indexOf(elem), null); + setdone = true; + // clean up stnTimeSndTable if a stn/timeline/snd is + // no longer in use + cleanUpStnTimeSndTable(stni, tmi, sndi); + break; + } + } + if (setdone) + break; + } + if (setdone) + break; + } + } + + if (curSndDeleted || soundingLys == null) { + // this is the case that we are deleting current snd, so, a new + // current snd should be selected + curSndProfileProp = null; + // find CurrentElementIndexes After Delete current snding + boolean found = false; + int stni = 0; + for (List> tlListList : stnTimeSndTable) { + int timei = 0; + for (List sndtyList : tlListList) { + int sndi = 0; + for (NsharpSoundingElementStateProperty elem : sndtyList) { + if (elem != null + && stnElementList.get(stni).getActionState() == NsharpConstants.ActState.ACTIVE + && timeElementList.get(timei).getActionState() == NsharpConstants.ActState.ACTIVE + && sndElementList.get(sndi).getActionState() == NsharpConstants.ActState.ACTIVE) { + currentStnElementListIndex = stni; + currentSndElementListIndex = sndi; + currentTimeElementListIndex = timei; + found = true; + break; + } + sndi++; + } + if (found) + break; + timei++; + } + if (found) + break; + stni++; + } + if (!found) { + currentStnElementListIndex = -1; + currentSndElementListIndex = -1; + currentTimeElementListIndex = -1; + } + setCurSndProfileProp(); + } else { + // currentStnElementListIndex, currentSndElementListIndex and + // currentTimeElementListIndex may not point to right element + // after some elements are deleted. + currentStnElementListIndex = -1; + currentTimeElementListIndex = -1; + currentSndElementListIndex = -1; + if (curSndProfileProp != null) { + boolean found = false; + for (List> tmListListForStn : stnTimeSndTable) { + for (List sndtyListForTm : tmListListForStn) { + for (NsharpSoundingElementStateProperty elem : sndtyListForTm) { + if (elem != null + && curSndProfileProp + .getElementDescription() + .equals(elem + .getElementDescription())) { + currentSndElementListIndex = sndtyListForTm + .indexOf(elem); + currentTimeElementListIndex = tmListListForStn + .indexOf(sndtyListForTm); + currentStnElementListIndex = stnTimeSndTable + .indexOf(tmListListForStn); + found = true; + break; + } + } + if (found) + break; + } + if (found) + break; + } + } + } + setCurrentSoundingLayerInfo(); + resetData(); + // System.out.println("num="+getFrameCount()); + return curSndDeleted; + // anything more to do? + } + + public void deleteRscAll() { + NsharpMapResource nsharpMapResource = NsharpMapResource + .getOrCreateNsharpMapResource(); + nsharpMapResource.setPoints(null); + if (soundingLys != null) { + soundingLys.clear(); + soundingLys = null; + } + if (previousSoundingLys != null) { + previousSoundingLys.clear(); + previousSoundingLys = null; + } + if (stnTimeSndTable != null) { + for (List> stnListList : stnTimeSndTable) { + for (List timeList : stnListList) { + timeList.clear(); + } + stnListList.clear(); + } + stnTimeSndTable.clear(); + } + if (timeElementList != null) + timeElementList.clear(); + if (stnElementList != null) + stnElementList.clear(); + if (sndElementList != null) + sndElementList.clear(); + // start FixMark:nearByStnCompSnd + if (compSndSelectedElemList != null) { + compSndSelectedElemList.clear(); + } + // end FixMark:nearByStnCompSnd + curSndProfileProp = null; + preSndProfileProp = null; + currentTextChapter = 1; + currentInsetPage = 1; + currentParcel = NsharpNativeConstants.PARCELTYPE_MOST_UNSTABLE; + currentParcelLayerPressure = NsharpNativeConstants.MU_LAYER; + currentTimeElementListIndex = -1; + currentStnElementListIndex = -1; + currentSndElementListIndex = -1; + resetData(); + } + + private NsharpSoundingElementStateProperty getCurSoundingElementStateProperty() { + if (currentTimeElementListIndex >= 0 + && currentStnElementListIndex >= 0 + && currentSndElementListIndex >= 0 + && stnTimeSndTable.get(currentStnElementListIndex) + .get(currentTimeElementListIndex) + .get(currentSndElementListIndex) != null) { + return stnTimeSndTable.get(currentStnElementListIndex) + .get(currentTimeElementListIndex) + .get(currentSndElementListIndex); + } + return null; + } + + private void setCurrentSoundingLayerInfo() { + NsharpSoundingElementStateProperty elem = getCurSoundingElementStateProperty(); + if (elem != null) { + pickedStnInfoStr = elem.getElementDescription(); + pickedStnInfo = elem.getStnInfo(); + + if (overlayIsOn) { + previousSoundingLys = soundingLys; + } else { + previousSoundingLys = null; + } + + if (interpolateIsOn == true) { + /* + * TTR829 deep copy is not necessary as performInterpolation() + * will re-allocate new layer for each layer //we dont want to + * change original raw data, so use a new copy NcSoundingLayer + * newLayer; List mySndLst = new + * ArrayList(); for(NcSoundingLayer + * layer:elem.getSndLyLst()){ newLayer = new NcSoundingLayer(); + * try { newLayer = (NcSoundingLayer) layer.clone(); + * + * } catch (CloneNotSupportedException e) { e.printStackTrace(); + * } //here a shallowCopy is enough mySndLst.add(newLayer); } // + * interpolation mySndLst = performInterpolation(mySndLst); + * + * soundingLys = mySndLst; + */ + + soundingLys = performInterpolation(elem.getSndLyLst()); + } else { + soundingLys = elem.getSndLyLst(); + } + } else { + previousSoundingLys = null; + soundingLys = null; + } + + } + + public void addRsc(Map> soundMap, + NsharpStationInfo stnInfo, boolean fromNCP) { + if (fromNCP) { + // this is from NCP do nothing now + this.addRsc(true, soundMap, stnInfo); + // NCP case: + // Key String format will be like this for NCUAIR + // KGRI 100616/03(Wed)-NCUAIR + // and for PFC/Grid sounding will be like this + // KGRI 100616/03(Wed)V001-GFSSND + } else { + // D2D case:::: + // this is from D2D, edit display and time line string to add short + // day-of-week and + // also add sounding type to string to solve an issue that data with + // same stn, same time line but different + // sounding type will not be loaded. + // D2D's key string is like this: "KGRI 2010-06-16 03:00:00" + // will change it to "KGRI 100616/03(Wed)-GFSSND" + Set dataTimelineSet = soundMap.keySet(); + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + // DateFormatSymbols dfs= new DateFormatSymbols(); + // String[] defaultDays = dfs.getShortWeekdays(); + Calendar cal = Calendar.getInstance(); + Date date; + Map> newmap = new HashMap>(); + String sndType = stnInfo.getSndType(); + for (String timeline : dataTimelineSet) { + System.out.println("D2D sending timeline Str:" + timeline); + String dateStr = timeline.substring(timeline.indexOf(' ') + 1); + String stnId = timeline.substring(0, timeline.indexOf(' ')); + try { + date = df.parse(dateStr); + cal.setTime(date); + String dayOfWeek = defaultDays[cal + .get(Calendar.DAY_OF_WEEK)]; + // dateStr = timeline.substring(0, + // timeline.indexOf(':'))+dayOfWeek+stnInfo.getSndType(); + // System.out.println("New Str:"+ dateStr); + String finalTimeStr = String.format( + "%4$s %1$ty%1$tm%1$td/%1$tH(%2$s) %3$s", cal, + dayOfWeek, sndType, stnId); + System.out.println("D2D (modified) timeline Str:" + + finalTimeStr); + // put newTimeStr to new map with original value + newmap.put(finalTimeStr, soundMap.get(timeline)); + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + continue; + } + } + // this is from D2D, and it does not want to display new data right + // away. + this.addRsc(false, newmap, stnInfo); + } + } + + /* + * public void loadSoundingData( boolean displayNewData, + * List soundDataLst, String stnId, String sndType, + * Timestamp rangeStartTime,double latitude,double longitude){ //* testing + * code //stnInfo.setStnId("KFSD"); { Set keyset= new + * HashSet(soundMap.keySet()); for(String key: keyset) { + * List sndLy = soundMap.remove(key); String newkey= + * key.replace("NAMS", "yahoo"); //String newkey= key.replace("GFSS", + * "NAMS"); //newkey = newkey.replace("KSLN", "KFSD"); soundMap.put(newkey, + * sndLy); } stnInfo.setSndType(stnInfo.getSndType().replace("NAMS", + * "yahoo")); //stnInfo.setSndType(stnInfo.getSndType().replace("GFSS", + * "NAMS")); }// + * + * //need to format reftime to GMT time string. Timestamp.toString produce a + * local time Not GMT time Calendar cal = + * Calendar.getInstance(TimeZone.getTimeZone("GMT")); + * cal.setTimeInMillis(rangeStartTime.getTime()); String dayOfWeek = + * defaultDays[cal.get(Calendar.DAY_OF_WEEK)]; String timeLine = + * String.format("%1$ty%1$tm%1$td/%1$tH(%2$s)", cal, dayOfWeek); + * if(stnId.indexOf(" ")>=0){ //take care stnId with SPACE case. stnId = + * stnId.replace(" ", "_"); } if(timeElementList.isEmpty() || + * stnElementList.isEmpty() || currentSndElementListIndex < 0 + * ||sndElementList.isEmpty() || currentTimeElementListIndex < 0 || + * currentStnElementListIndex < 0){ //if no data was loaded since, then + * display this data any way displayNewData = true; } //save current + * timeline and stn state properties if we are NOT loading new data + * NsharpOperationElement currentTL=null; NsharpOperationElement + * currentStn=null; NsharpOperationElement currentSnd=null; + * NsharpSoundingElementStateProperty currentPreSndProfileProp=null; + * if(!displayNewData){ currentTL = + * timeElementList.get(currentTimeElementListIndex); currentStn = + * stnElementList.get(currentStnElementListIndex); currentSnd = + * sndElementList.get(currentSndElementListIndex); currentPreSndProfileProp + * = preSndProfileProp; } //add new data to table //add time line to + * stnTimeTable and set its index + * addElementToTableAndLists((stnId+" "+timeLine + * +" "+sndType),stnId,timeLine,sndType,stnInfo, soundDataLst); + * + * if(displayNewData){ //Set default parcel trace data currentParcel = + * NsharpNativeConstants.PARCELTYPE_MOST_UNSTABLE; + * currentParcelLayerPressure = NsharpNativeConstants.MU_LAYER; + * setCurrentSoundingLayerInfo(); resetData(); } else { //Not display new + * data. Reset current "parameter"s after adding data to map/lists + * currentStnElementListIndex= stnElementList.indexOf(currentStn); + * currentTimeElementListIndex = timeElementList.indexOf(currentTL); + * currentSndElementListIndex = sndElementList.indexOf(currentSnd); + * preSndProfileProp = currentPreSndProfileProp; curSndProfileProp = + * stnTimeSndTable + * .get(currentStnElementListIndex).get(currentTimeElementListIndex + * ).get(currentSndElementListIndex); } + * + * //set total time line group and stn id list page number + * calculateTimeStnBoxData(); + * + * //set data time to descriptor //this is necessary for looping // starting + * 13.2.1, this line is changed by Raytheon if (( + * skewtPaneRsc.getDescriptor().getFramesInfo().getFrameCount() == 0)&& + * !getTimeMatcher) { //was this line before 13.2.1 if (( + * skewtPaneRsc.getDescriptor().getTimeMatcher() == null || + * skewtPaneRsc.getDescriptor().getTimeMatcher().getTimeMatchBasis() == + * null)&& !getTimeMatcher) { //DataTime[] dataTimes = new + * DataTime[dataTimelineList.size()]; //Chin Note: we just have to do this + * once and set dataTimes size bigger than 1. //Nsharp handles changing + * frame itself. It just need system to send change frame notice. //That is + * happened at NsharpSkewTDescriptor.checkDrawTime(). DataTime[] dataTimes = + * new DataTime[2]; Date now = new Date(); for(int k =0; k < 2 ; k++){ + * dataTimes[k]= new DataTime(now, k); } //no need to get a descriptor from + * a renderableDispaly since we have a descriptor + * skewtPaneRsc.getDescriptor().setDataTimes(dataTimes); + * getTimeMatcher=true; } + * + * NsharpShowTextDialog textarea = NsharpShowTextDialog.getAccess(); + * if(textarea != null){ textarea.refreshTextData(); } NsharpPaletteWindow + * win = NsharpPaletteWindow.getInstance() ; if(win!=null) + * currentGraphMode=win.getCurrentGraphMode(); + * + * refreshPane(); + * + * } + */ + + private void addRsc(boolean displayNewData, + Map> soundMap, + NsharpStationInfo stnInfo) { + + // // testing code // stnInfo.setStnId("KUKI"); + // Set keysettest = new HashSet(soundMap.keySet()); + // for (String key : keysettest) { + // List sndLy = soundMap.remove(key); // String + // // newkey= + // // key.replace("NCUAIR", "gpduair"); // String newkey = + // // key.replace("NAMS", "SSS"); + // String newkey = key.replace("140303/12", "120109/12"); + // soundMap.put(newkey, sndLy); + // } // + // // stnInfo.setSndType(stnInfo.getSndType().replace("NCUAIR", // + // // "gpduair")); // stnInfo.setSndType(stnInfo.getSndType().replace( + // // "NAMS","SSS")); + // // + + if (stnInfo.getStnId() != null && stnInfo.getStnId().indexOf(" ") >= 0) { + // take care stnId with SPACE case. + String stnId = stnInfo.getStnId(); + String newStnId = stnId.replace(" ", "_"); + stnInfo.setStnId(newStnId); + String dspInfo = stnInfo.getStnDisplayInfo(); + stnInfo.setStnDisplayInfo(dspInfo.replace(stnId, newStnId)); + Set keyset = new HashSet(soundMap.keySet()); + for (String key : keyset) { + List sndLy = soundMap.remove(key); + String newkey = key.replace(stnId, newStnId); + soundMap.put(newkey, sndLy); + } + + } + + if (soundMap.size() <= 0 + || (skewtPaneRsc == null && hodoPaneRsc == null)) { + return; + } + if (timeElementList.isEmpty() || stnElementList.isEmpty() + || currentSndElementListIndex < 0 || sndElementList.isEmpty() + || currentTimeElementListIndex < 0 + || currentStnElementListIndex < 0) { + // if no data was loaded since, then display this data any way + displayNewData = true; + } + // save current timeline and stn state properties if we are NOT loading + // new data + NsharpOperationElement currentTL = null; + NsharpOperationElement currentStn = null; + NsharpOperationElement currentSnd = null; + NsharpSoundingElementStateProperty currentPreSndProfileProp = null; + if (!displayNewData) { + currentTL = timeElementList.get(currentTimeElementListIndex); + currentStn = stnElementList.get(currentStnElementListIndex); + currentSnd = sndElementList.get(currentSndElementListIndex); + currentPreSndProfileProp = preSndProfileProp; + } + // add new data to table + Set dataTimelineSet = soundMap.keySet(); + String[] tempTimeLineArr = dataTimelineSet + .toArray(new String[dataTimelineSet.size()]); + Arrays.sort(tempTimeLineArr); + for (int i = 0; i < tempTimeLineArr.length; i++) { + // based on this KEY string format "KGRI 100616/03(Wed)Vxxx GFSSND" + String stnId, sndType, timeLine, timeLine_sndType, stnId_timeLine_sndType; + List sndLyLst; + try { + stnId_timeLine_sndType = tempTimeLineArr[i].toString(); + sndLyLst = soundMap.get(stnId_timeLine_sndType); + stnId = stnId_timeLine_sndType.substring(0, + stnId_timeLine_sndType.indexOf(" ")); + timeLine_sndType = stnId_timeLine_sndType + .substring(stnId_timeLine_sndType.indexOf(" ") + 1); + timeLine = timeLine_sndType.substring(0, + timeLine_sndType.indexOf(" ")); + sndType = timeLine_sndType.substring(timeLine_sndType + .indexOf(" ") + 1); + } catch (Exception e) { + e.printStackTrace(); + return; + } + // start FixMark:nearByStnCompSnd d2dlite + if (!(sndType.contentEquals("NCUAIR") || sndType + .contentEquals("BUFRUA"))) { + // Chin's NOTE: + // Can Not use reference time directly from the stnInfo, + // Timestamp refTime = stnInfo.getReftime() + // AS there is a "BUG" in Timestamp or Database. In some cases, + // Timestamp's "nanos" filelds contains non zero value of + // some nanoseconds and cause "hour" value shifted one hour, and + // therefore when calling refTime.getTime() will return + // unexpected reference time, + // So, use the following way to get referrence time. + // Based on timeline format "100616/03(Wed)Vxxx" do + // the following. to append reference time format of "DD.HH" at + // end of sndType. + SimpleDateFormat df = new SimpleDateFormat("yyMMdd/HH"); + String dateStr = timeLine.substring(0, 9); + try { + Date date = df.parse(dateStr); + String vStr = timeLine.substring(15, 18); + int vNum = Integer.parseInt(vStr); + date.setTime(date.getTime() - vNum * 60 * 60 * 1000); + String dateOfMonthStr, hourStr; + if (date.getDate() < 10) + dateOfMonthStr = "0" + date.getDate(); + else + dateOfMonthStr = "" + date.getDate(); + + if (date.getHours() < 10) + hourStr = "0" + date.getHours(); + else + hourStr = "" + date.getHours(); + sndType = dateOfMonthStr + "." + hourStr + "@" + sndType; + } catch (ParseException e) { + // TODO Auto-generated catch block. Please revise as + // appropriate. + e.printStackTrace(); + } + + } + + /* + * As of 2014 April 9, current time description string is defined as + * "YYMMDD/HH(DOW)" or "YYMMDD/HH(DOW)Vxxx". Convert them to + * "DD.HH(DOW)" or "DD.HHVxxx(DOW)" for GUI display. + */ + timeLine = timeLine.substring(4); // get rid of YYMM + if (timeLine.contains("V")) { + String[] s1Str = timeLine.split("V"); // split + // DD/HH(DOW)Vxxx to + // "DD/HH(DOW)" and + // "xxx" + String[] s2Str = s1Str[0].split("\\("); // split + // "DD/HH(DOW)" to + // "DD/HH" and + // "DOW)" + timeLine = s2Str[0] + "V" + s1Str[1] + "(" + s2Str[1]; // put + // together + // to + // "DD/HHVxxx(DOW)" + } + timeLine = timeLine.replace("/", "."); // replace "/" with "." + + // recreate stnId_timeLine_sndType + stnId_timeLine_sndType = stnId + " " + timeLine + " " + sndType; + // end FixMark:nearByStnCompSnd d2dlite + + // No more needed? timeLine = timeLine.replace(" ", "-"); //fixed + // DR15325 - sorting time line issue in D2D + // add time line to stnTimeTable and set its index + addElementToTableAndLists(stnId_timeLine_sndType, stnId, timeLine, + sndType, stnInfo, sndLyLst); + } + if (displayNewData) { + // Set default parcel trace data + currentParcel = NsharpNativeConstants.PARCELTYPE_MOST_UNSTABLE; + currentParcelLayerPressure = NsharpNativeConstants.MU_LAYER; + setCurrentSoundingLayerInfo(); + resetData(); + } else { + // Not display new data. Reset current "parameter"s after adding + // data to map/lists + currentStnElementListIndex = stnElementList.indexOf(currentStn); + currentTimeElementListIndex = timeElementList.indexOf(currentTL); + currentSndElementListIndex = sndElementList.indexOf(currentSnd); + preSndProfileProp = currentPreSndProfileProp; + curSndProfileProp = stnTimeSndTable.get(currentStnElementListIndex) + .get(currentTimeElementListIndex) + .get(currentSndElementListIndex); + } + + // set total time line group and stn id list page number + calculateTimeStnBoxData(); + + // set data time to descriptor + // this is necessary for looping + // starting 13.2.1, this line is changed by Raytheon + if ((skewtPaneRsc != null) + && (skewtPaneRsc.getDescriptor().getFramesInfo() + .getFrameCount() == 0) && !getTimeMatcher) { + // was this line before 13.2.1 if (( + // skewtPaneRsc.getDescriptor().getTimeMatcher() == null || + // skewtPaneRsc.getDescriptor().getTimeMatcher().getTimeMatchBasis() + // == null)&& !getTimeMatcher) { + // DataTime[] dataTimes = new DataTime[dataTimelineList.size()]; + // Chin Note: we just have to do this once and set dataTimes size + // bigger than 1. + // Nsharp handles changing frame itself. It just need system to send + // change frame notice. + // That is happened at NsharpSkewTDescriptor.checkDrawTime(). + DataTime[] dataTimes = new DataTime[2/* stnTimeTable.size() */]; + Date now = new Date(); + for (int k = 0; k < 2/* stnTimeTable.size() */; k++) { + dataTimes[k] = new DataTime(now, k); + } + // no need to get a descriptor from a renderableDispaly since we + // have a descriptor + skewtPaneRsc.getDescriptor().setDataTimes(dataTimes); + getTimeMatcher = true; + } + + NsharpShowTextDialog textarea = NsharpShowTextDialog.getAccess(); + if (textarea != null) { + textarea.refreshTextData(); + } + NsharpPaletteWindow win = NsharpPaletteWindow.getInstance(); + if (win != null) + currentGraphMode = win.getCurrentGraphMode(); + + refreshPane(); + + } + + public void addRsc(Map> soundMap, + NsharpStationInfo stnInfo) { + // by default, display new data + // NCP always call from this route. + this.addRsc(true, soundMap, stnInfo); + return; + } + + public String getPickedStnInfoStr() { + return pickedStnInfoStr; + } + + // start FixMark:clickOnTimeStnPane + private void handleUserPickNewStationId(int index) { + currentStnElementListIndex = index; + if (compareTmIsOn) { + /* + * boolean found = false; if( currentTimeElementListIndex>=0 && + * currentSndElementListIndex>=0 && + * stnTimeSndTable.get(currentStnElementListIndex + * ).get(currentTimeElementListIndex + * ).get(currentSndElementListIndex)!=null){ // use + * currentTimeLineStateListIndex found = true; } else { //find an + * active and available timeline for this stn and set is as current + * for (int i=0; i < timeElementList.size(); i++){ + * if(timeElementList.get(i).getActionState()== + * NsharpConstants.ActState.ACTIVE && + * stnTimeSndTable.get(currentStnElementListIndex + * ).get(i).get(currentSndElementListIndex)!=null){ + * currentTimeElementListIndex = i; found = true; break; } } } + * if(!found){ currentTimeElementListIndex = -1; } else + */{ + int colorIndex = NsharpConstants.LINE_COMP1; + for (NsharpOperationElement elm : timeElementList) { + if (elm.getActionState() == NsharpConstants.ActState.INACTIVE) + continue; + int tmIndex = timeElementList.indexOf(elm); + NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable + .get(currentStnElementListIndex).get(tmIndex) + .get(currentSndElementListIndex); + if (stnTmElm != null) { + stnTmElm.setCompColorIndex(colorIndex); + } + colorIndex++; + if (colorIndex > NsharpConstants.LINE_COMP10) + colorIndex = NsharpConstants.LINE_COMP1; + + } + } + } else if (compareSndIsOn) { + // start FixMark:nearByStnCompSnd + if (currentTimeElementListIndex >= 0 + && currentSndElementListIndex >= 0 + && stnTimeSndTable.get(currentStnElementListIndex) + .get(currentTimeElementListIndex) + .get(currentSndElementListIndex) != null) { + setCompareSndIsOn(true); + } + /* + * boolean found = false; if( currentTimeElementListIndex>=0 && + * currentSndElementListIndex>=0 && + * stnTimeSndTable.get(currentStnElementListIndex + * ).get(currentTimeElementListIndex + * ).get(currentSndElementListIndex)!=null){ found = true; } else { + * //find an active and available snd for this stn and set is as + * current for (int i=0; i < sndElementList.size(); i++){ + * if(sndElementList.get(i).getActionState()== + * NsharpConstants.ActState.ACTIVE && + * stnTimeSndTable.get(currentStnElementListIndex + * ).get(currentTimeElementListIndex).get(i)!=null){ + * currentSndElementListIndex = i; found = true; break; } } } + * if(!found){ currentSndElementListIndex = -1; } else{ int + * colorIndex = NsharpConstants.LINE_COMP1; + * for(NsharpOperationElement elm: sndElementList) { + * if(elm.getActionState() == NsharpConstants.ActState.INACTIVE) + * continue; int sndIndex = sndElementList.indexOf(elm); + * NsharpSoundingElementStateProperty stnTmElm = + * stnTimeSndTable.get( + * currentStnElementListIndex).get(currentTimeElementListIndex + * ).get(sndIndex); if(stnTmElm!=null){ + * stnTmElm.setCompColorIndex(colorIndex); } colorIndex++; + * if(colorIndex > NsharpConstants.LINE_COMP10) colorIndex = + * NsharpConstants.LINE_COMP1; } } + */ + // end FixMark:nearByStnCompSnd + } + setCurSndProfileProp(); + setCurrentSoundingLayerInfo(); + resetData(); + refreshPane(); + } // end FixMark:clickOnTimeStnPane + + public void handleUserClickOnStationId(Coordinate c, boolean shiftDown) { + // first to find if it is for change to next page, or change sorting + // System.out.println("numTimeLinePerPage="+numTimeLinePerPage+"gap="+(cnYOrig-dtNextPageEnd)); + int index = ((int) (c.y - dtYOrig)) / (int) lineHeight; + + if (c.y < dtNextPageEnd) {// d2dlite + // change to next/previous page + if (totalStnIdPage == 1) + return; + if ((c.x - (dtXOrig + dtWidth)) < (dtWidth / 2)) { + curStnIdPage++; + if (curStnIdPage > totalStnIdPage) + curStnIdPage = 1; + } else { + curStnIdPage--; + if (curStnIdPage <= 0) + curStnIdPage = totalStnIdPage; + } + return; + } + double dIndex; + // recalculate index for time line + dIndex = ((c.y - dtNextPageEnd)) / lineHeight + (curStnIdPage - 1) + * numTimeLinePerPage; + + index = (int) dIndex; + if (index < this.stnElementList.size()) { + // FixMark:clickOnTimeStnPane start + NsharpConstants.ActState actState = stnElementList.get(index) + .getActionState(); + if (!shiftDown) { + if (actState == NsharpConstants.ActState.ACTIVE) + handleUserPickNewStationId(index); + } else { // End FixMark:clickOnTimeStnPane + + switch (actState) { + + case INACTIVE: + stnElementList.get(index).setActionState( + NsharpConstants.ActState.ACTIVE); + break; + case ACTIVE: + // do not allow deactivate current stn + if (index == currentStnElementListIndex) + return; + stnElementList.get(index).setActionState( + NsharpConstants.ActState.INACTIVE); + break; + default: + return; + } + if (skewtPaneRsc != null) + skewtPaneRsc.createRscWireFrameShapes(); + if (hodoPaneRsc != null) + hodoPaneRsc.createRscHodoWindShapeAll(); + } + } + } + + // start FixMark:clickOnTimeStnPane + private void handleUserPickNewTimeLine(int index) { + previousTimeLineStateListIndex = currentTimeElementListIndex; + currentTimeElementListIndex = index; + if (compareStnIsOn) { + /* + * boolean found = false; if(currentStnElementListIndex >=0 && + * currentSndElementListIndex >=0 && + * stnTimeSndTable.get(currentStnElementListIndex + * ).get(index).get(currentSndElementListIndex)!=null){ found = + * true; } else{ //find an active and available stn for this + * timeline and set is as current for (int i=0; i < + * stnElementList.size(); i++){ + * if(stnElementList.get(i).getActionState + * ()==NsharpConstants.ActState.ACTIVE && + * stnTimeSndTable.get(i).get(index).get(currentSndElementListIndex) + * !=null){ currentStnElementListIndex = i; found = true; break; } } + * } if(!found){ currentStnElementListIndex = -1; } else + */{ + int colorIndex = NsharpConstants.LINE_COMP1; + for (NsharpOperationElement elm : stnElementList) { + int stnIndex = stnElementList.indexOf(elm); + NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable + .get(stnIndex).get(index) + .get(currentSndElementListIndex); + if (stnTmElm != null) { + stnTmElm.setCompColorIndex(colorIndex); + } + colorIndex++; + if (colorIndex > NsharpConstants.LINE_COMP10) + colorIndex = NsharpConstants.LINE_COMP1; + } + } + } else if (compareSndIsOn) { + // start FixMark:nearByStnCompSnd + if (currentStnElementListIndex >= 0 + && currentSndElementListIndex >= 0 + && stnTimeSndTable.get(currentStnElementListIndex) + .get(currentTimeElementListIndex) + .get(currentSndElementListIndex) != null) { + setCompareSndIsOn(true); + } + /* + * boolean found = false; if(currentStnElementListIndex >=0 && + * currentSndElementListIndex >=0 && + * stnTimeSndTable.get(currentStnElementListIndex + * ).get(index).get(currentSndElementListIndex)!=null){ found = + * true; } else { //find an active and available snd for this stn + * and set is as current for (int i=0; i < sndElementList.size(); + * i++){ if(sndElementList.get(i).getActionState()== + * NsharpConstants.ActState.ACTIVE && + * stnTimeSndTable.get(currentStnElementListIndex + * ).get(index).get(i)!=null){ currentSndElementListIndex = i; found + * = true; break; } } } if(!found){ currentSndElementListIndex = -1; + * } else{ int colorIndex = NsharpConstants.LINE_COMP1; + * for(NsharpOperationElement elm: sndElementList) { + * if(elm.getActionState() == NsharpConstants.ActState.INACTIVE) + * continue; int sndIndex = sndElementList.indexOf(elm); + * NsharpSoundingElementStateProperty stnTmElm = + * stnTimeSndTable.get( + * currentStnElementListIndex).get(index).get(sndIndex); + * if(stnTmElm!=null){ stnTmElm.setCompColorIndex(colorIndex); } + * colorIndex++; if(colorIndex > NsharpConstants.LINE_COMP10) + * colorIndex = NsharpConstants.LINE_COMP1; } } + */ + // end FixMark:nearByStnCompSnd + } + setCurSndProfileProp(); + setCurrentSoundingLayerInfo(); + resetData(); + refreshPane(); + } // end FixMark:clickOnTimeStnPane + + public void handleUserClickOnTimeLine(Coordinate c, boolean shiftDown) { + + // first to find if it is for change to next/prev page + // System.out.println("numTimeLinePerPage="+numTimeLinePerPage+"gap="+(cnYOrig-dtNextPageEnd)); + int index = ((int) (c.y - dtYOrig)) / ((int) lineHeight); + + if (c.y < dtNextPageEnd) {// d2dlite + // change to next/previous page + if (totalTimeLinePage == 1) + return; + if ((c.x - dtXOrig) < (dtWidth / 2)) { + curTimeLinePage++; + if (curTimeLinePage > totalTimeLinePage) + curTimeLinePage = 1; + } else { + curTimeLinePage--; + if (curTimeLinePage <= 0) + curTimeLinePage = totalTimeLinePage; + } + return; + } + double dIndex; + // recalculate index for time line + dIndex = (c.y - dtNextPageEnd) / lineHeight + (curTimeLinePage - 1) + * numTimeLinePerPage; + index = (int) dIndex; + if (index < timeElementList.size() && index >= 0) { + // FixMark:clickOnTimeStnPane start + NsharpConstants.ActState actState = timeElementList.get(index) + .getActionState(); + if (!shiftDown) { + if (actState == NsharpConstants.ActState.ACTIVE) + handleUserPickNewTimeLine(index); + } else { + switch (actState) {// End FixMark:clickOnTimeStnPane + case INACTIVE: + timeElementList.get(index).setActionState( + NsharpConstants.ActState.ACTIVE); + break; + case ACTIVE: + if (index == currentTimeElementListIndex) + // dont allow to deactive current time line + return; + timeElementList.get(index).setActionState( + NsharpConstants.ActState.INACTIVE); + break; + + default: + return; + + } + if (skewtPaneRsc != null) + skewtPaneRsc.createRscWireFrameShapes(); + if (hodoPaneRsc != null) + hodoPaneRsc.createRscHodoWindShapeAll(); + } + } + } + + // start FixMark:clickOnTimeStnPane + private void handleUserPickNewSndLine(int index) { + currentSndElementListIndex = index; + if (compareTmIsOn) { + /* + * boolean found = false; if(currentTimeElementListIndex>=0 && + * currentStnElementListIndex>=0 && + * stnTimeSndTable.get(currentStnElementListIndex + * ).get(currentTimeElementListIndex + * ).get(currentSndElementListIndex)!=null){ // use + * currentTimeLineStateListIndex found = true; } else { //find an + * active and available timeline for this stn and set is as current + * for (int i=0; i < timeElementList.size(); i++){ + * if(timeElementList.get(i).getActionState()== + * NsharpConstants.ActState.ACTIVE && + * stnTimeSndTable.get(currentStnElementListIndex + * ).get(i).get(currentSndElementListIndex)!=null){ + * currentTimeElementListIndex = i; found = true; break; } } } + * if(!found){ currentTimeElementListIndex = -1; } else + */{ + int colorIndex = NsharpConstants.LINE_COMP1; + for (NsharpOperationElement elm : timeElementList) { + if (elm.getActionState() == NsharpConstants.ActState.INACTIVE) + continue; + int tmIndex = timeElementList.indexOf(elm); + NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable + .get(currentStnElementListIndex).get(tmIndex) + .get(currentSndElementListIndex); + if (stnTmElm != null) { + stnTmElm.setCompColorIndex(colorIndex); + } + colorIndex++; + if (colorIndex > NsharpConstants.LINE_COMP10) + colorIndex = NsharpConstants.LINE_COMP1; + } + } + } else if (compareStnIsOn) { + /* + * boolean found = false; //find an active and available stn for + * this timeline and set is as current + * if(currentTimeElementListIndex>=0 && + * currentStnElementListIndex>=0 && + * stnTimeSndTable.get(currentStnElementListIndex + * ).get(currentTimeElementListIndex + * ).get(currentSndElementListIndex)!=null){ found = true; } else { + * for (int i=0; i < stnElementList.size(); i++){ + * if(stnElementList.get + * (i).getActionState()==NsharpConstants.ActState.ACTIVE && + * stnTimeSndTable.get(i).get(currentTimeElementListIndex).get( + * currentSndElementListIndex) !=null){ currentStnElementListIndex = + * i; found = true; break; } } } if(!found){ + * currentStnElementListIndex = -1; } else + */{ + int colorIndex = NsharpConstants.LINE_COMP1; + for (NsharpOperationElement elm : stnElementList) { + int stnIndex = stnElementList.indexOf(elm); + NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable + .get(stnIndex).get(currentTimeElementListIndex) + .get(currentSndElementListIndex); + if (stnTmElm != null) { + stnTmElm.setCompColorIndex(colorIndex); + } + colorIndex++; + if (colorIndex > NsharpConstants.LINE_COMP10) + colorIndex = NsharpConstants.LINE_COMP1; + + } + } + } + // start FixMark:nearByStnCompSnd + else if (compareSndIsOn) { + // see if the new currentSndElementListIndex is used in one of the + // element + for (CompSndSelectedElem elem : compSndSelectedElemList) { + if (elem.getSndIndex() == currentSndElementListIndex) { + currentTimeElementListIndex = elem.getTimeIndex(); + currentStnElementListIndex = elem.getStnIndex(); + // setCompareSndIsOn(true); + break; + } + } + } + // end FixMark:nearByStnCompSnd + setCurSndProfileProp(); + setCurrentSoundingLayerInfo(); + resetData(); + refreshPane(); + } + + // end FixMark:clickOnTimeStnPane + public void handleUserClickOnSndLine(Coordinate c, boolean shiftDown) { + + // first to find if it is for change to next/prev page + // System.out.println("numTimeLinePerPage="+numTimeLinePerPage+"gap="+(cnYOrig-dtNextPageEnd)); + int index = ((int) (c.y - dtYOrig)) / (int) lineHeight; + if (c.y < dtNextPageEnd) { // d2dlite + // change to next/previous page + if (totalSndPage == 1) + return; + if ((c.x - dtXOrig) < (dtWidth / 2)) { + curSndPage++; + if (curSndPage > totalSndPage) + curSndPage = 1; + } else { + curSndPage--; + if (curSndPage <= 0) + curSndPage = totalSndPage; + } + return; + } + double dIndex; + // recalculate index for time line + dIndex = (c.y - dtNextPageEnd) / lineHeight + (curSndPage - 1) + * numTimeLinePerPage; + index = (int) dIndex; + if (index < sndElementList.size() && index >= 0) { + // FixMark:clickOnTimeStnPane start + NsharpConstants.ActState actState = sndElementList.get(index) + .getActionState(); + if (!shiftDown) { + if (actState == NsharpConstants.ActState.ACTIVE) + handleUserPickNewSndLine(index); + } else { + switch (actState) {// End FixMark:clickOnTimeStnPane + case INACTIVE: + sndElementList.get(index).setActionState( + NsharpConstants.ActState.ACTIVE); + break; + case ACTIVE: + if (index == currentSndElementListIndex) + // dont allow to deactive current time line + return; + sndElementList.get(index).setActionState( + NsharpConstants.ActState.INACTIVE); + break; + + default: + return; + + } + if (skewtPaneRsc != null) + skewtPaneRsc.createRscWireFrameShapes(); + if (hodoPaneRsc != null) + hodoPaneRsc.createRscHodoWindShapeAll(); + + } + } + } + + private void moveTimeLineIndexBackward() { + previousTimeLineStateListIndex = currentTimeElementListIndex; + int counter = 0; + while (true) { + currentTimeElementListIndex++; + currentTimeElementListIndex = currentTimeElementListIndex + % this.timeElementList.size(); + counter++; + if (counter > timeElementList.size()) + break; + if (timeElementList.get(currentTimeElementListIndex) + .getActionState() == NsharpConstants.ActState.ACTIVE + && stnTimeSndTable.get(currentStnElementListIndex) + .get(currentTimeElementListIndex) + .get(currentSndElementListIndex) != null) { + break;// out of while loop + } + + } + } + + private void moveTimeLineIndexForward() { + previousTimeLineStateListIndex = currentTimeElementListIndex; + int counter = 0; + while (true) { + currentTimeElementListIndex = currentTimeElementListIndex + + this.timeElementList.size();// so, we wont get a negative + // number + currentTimeElementListIndex--; + currentTimeElementListIndex = currentTimeElementListIndex + % this.timeElementList.size(); + counter++; + if (counter > timeElementList.size()) + break; + if (timeElementList.get(currentTimeElementListIndex) + .getActionState() == NsharpConstants.ActState.ACTIVE + && stnTimeSndTable.get(currentStnElementListIndex) + .get(currentTimeElementListIndex) + .get(currentSndElementListIndex) != null) { + break;// out of while loop + } + } + // System.out.println("timeline="+timeLineStateList.get(pickedTimeGroupIndex).getElementDescription()); + } + + private void moveTimeLineIndexCycle() { + previousTimeLineStateListIndex = currentTimeElementListIndex; + // Note: direction should only be NEXT or PREVIOUS + int counter = 0; + while (true) { + counter++; + if (counter > timeElementList.size()) { + currentTimeElementListIndex = previousTimeLineStateListIndex; + break; + } + if (currentOpDirection == IFrameCoordinator.FrameChangeOperation.NEXT) { + currentTimeElementListIndex--; + if (currentTimeElementListIndex <= 0) { + // the end of forward direction, change direction to + // backward + currentOpDirection = IFrameCoordinator.FrameChangeOperation.PREVIOUS; + currentTimeElementListIndex = 0; + } + + } else { // direction is FrameChangeOperation.PREVIOUS + currentTimeElementListIndex++; + if (currentTimeElementListIndex >= timeElementList.size() - 1) { + // the end of backward direction, change direction to + // forward + currentOpDirection = IFrameCoordinator.FrameChangeOperation.NEXT; + currentTimeElementListIndex = timeElementList.size() - 1; + } + } + if (timeElementList.get(currentTimeElementListIndex) + .getActionState() == NsharpConstants.ActState.ACTIVE + && stnTimeSndTable.get(currentStnElementListIndex) + .get(currentTimeElementListIndex) + .get(currentSndElementListIndex) != null) { + break;// out of while loop + } + } + + } + + /* + * Note: looping only apply to curAggregateTimeLineList NOT stationIdList + */ + public void setLoopingDataTimeLine(LoopProperties loopProperties) { + // System.out.println("setLoopingDataTimeLine loopmode ="+loopProperties.getMode().toString()); + if (this.timeElementList.size() > 0) { + switch (loopProperties.getMode()) { + case Forward: + moveTimeLineIndexForward(); + break; + case Backward: + moveTimeLineIndexBackward(); + break; + case Cycle: + moveTimeLineIndexCycle(); + + break; + } + + curTimeLinePage = currentTimeElementListIndex / numTimeLinePerPage + + 1; + setCurSndProfileProp(); + setCurrentSoundingLayerInfo(); + resetData(); + refreshPane(); + } + + } + + public enum LoopMode { + Forward, Backward, Cycle + }; + + private int getElemlistActiveNumber(List elemlist) { + int n = 0; + for (NsharpOperationElement elem : elemlist) { + if (elem.getActionState() == NsharpConstants.ActState.ACTIVE) { + n++; + } + } + return n; + } + + public void setSteppingTimeLine( + IFrameCoordinator.FrameChangeOperation operation, + IFrameCoordinator.FrameChangeMode mode) { + if (this.timeElementList.size() > 0 + && getElemlistActiveNumber(timeElementList) > 1/* + * && + * getAvailTimeLineNumber + * ( + * currentStnStateListIndex + * )>1 + */) { + int targetIndex = currentTimeElementListIndex; + // previousTimeLineStateListIndex = currentTimeLineStateListIndex; + // preset index for LAST and FIRST operation + switch (operation) { + case LAST: // the future-est time, at top of time line shown. set to + // -1, so in while loop, it starts from 0 + targetIndex = -1;// + break; + case FIRST: // the oldest time, set to dataTimelineList.length, so + // in while loop, it starts from + // dataTimelineList.length-1 + targetIndex = timeElementList.size(); + break; + default: + break; + + } + + int counter = 0; + while (true) { + switch (operation) { + case LAST: // the future-est time, at top of time line shown + targetIndex++; + break; + case FIRST: // the oldest time + targetIndex--; + break; + case PREVIOUS: + targetIndex++; + targetIndex = targetIndex % this.timeElementList.size(); + break; + case NEXT: + // so, we wont get a negative number + targetIndex = targetIndex + this.timeElementList.size(); + targetIndex--; + targetIndex = targetIndex % this.timeElementList.size(); + break; + default: + break; + } + counter++; + if (counter >= timeElementList.size()) + return; // looped through whole list already, and index back + // to original + + if (timeElementList.get(targetIndex).getActionState() == NsharpConstants.ActState.ACTIVE) { + if (compareTmIsOn + && currentStnElementListIndex >= 0 + && currentSndElementListIndex >= 0 + && stnTimeSndTable.get(currentStnElementListIndex) + .get(targetIndex) + .get(currentSndElementListIndex) == null) { + continue; + } else if (compareStnIsOn) { + boolean found = false; + if (currentStnElementListIndex >= 0 + && currentSndElementListIndex >= 0 + && stnTimeSndTable + .get(currentStnElementListIndex) + .get(targetIndex) + .get(currentSndElementListIndex) != null) { + found = true; + } else { + // find an active and available stn for this + // timeline and set is as current + for (int i = 0; i < stnElementList.size(); i++) { + if (stnElementList.get(i).getActionState() == NsharpConstants.ActState.ACTIVE + && stnTimeSndTable + .get(i) + .get(targetIndex) + .get(currentSndElementListIndex) != null) { + currentStnElementListIndex = i; + found = true; + break; + } + } + } + if (!found) { + currentStnElementListIndex = -1; + } else { + int colorIndex = NsharpConstants.LINE_COMP1; + for (NsharpOperationElement elm : stnElementList) { + int stnIndex = stnElementList.indexOf(elm); + NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable + .get(stnIndex).get(targetIndex) + .get(currentSndElementListIndex); + if (stnTmElm != null) { + stnTmElm.setCompColorIndex(colorIndex); + // if(colorIndex > + // NsharpConstants.LINE_COMP10) + // colorIndex = NsharpConstants.LINE_COMP1; + } + colorIndex++; + if (colorIndex > NsharpConstants.LINE_COMP10) + colorIndex = NsharpConstants.LINE_COMP1; + } + } + // no matter we find current stn or not + // we should get out of here + break; + } else if (compareSndIsOn) { + boolean found = false; + if (currentStnElementListIndex >= 0 + && currentSndElementListIndex >= 0 + && stnTimeSndTable + .get(currentStnElementListIndex) + .get(targetIndex) + .get(currentSndElementListIndex) != null) { + found = true; + } else { + // find an active and available snd for this stn and + // set is as current + for (int i = 0; i < sndElementList.size(); i++) { + if (sndElementList.get(i).getActionState() == NsharpConstants.ActState.ACTIVE + && stnTimeSndTable + .get(currentStnElementListIndex) + .get(targetIndex).get(i) != null) { + currentSndElementListIndex = i; + found = true; + break; + } + } + } + if (!found) { + currentSndElementListIndex = -1; + } else { + int colorIndex = NsharpConstants.LINE_COMP1; + for (NsharpOperationElement elm : sndElementList) { + if (elm.getActionState() == NsharpConstants.ActState.INACTIVE) + continue; + int sndIndex = sndElementList.indexOf(elm); + NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable + .get(currentStnElementListIndex) + .get(targetIndex).get(sndIndex); + if (stnTmElm != null) { + stnTmElm.setCompColorIndex(colorIndex); + } + colorIndex++; + if (colorIndex > NsharpConstants.LINE_COMP10) + colorIndex = NsharpConstants.LINE_COMP1; + } + } + // no matter we find current snd type for this stn or + // not + // we should get out of here + break; + } else { + break; + } + } + } + previousTimeLineStateListIndex = currentTimeElementListIndex; + currentTimeElementListIndex = targetIndex; + curTimeLinePage = currentTimeElementListIndex / numTimeLinePerPage + + 1; + setCurSndProfileProp(); + setCurrentSoundingLayerInfo(); + resetData(); + refreshPane(); + } + } + + /* + * Stn index stepping is only controlled by up/down arrow keys, down key = + * PREVIOUS operation, up key = NEXT operation + */ + public void setSteppingStnIdList( + IFrameCoordinator.FrameChangeOperation operation) { + if (this.stnElementList.size() > 0 + && getElemlistActiveNumber(stnElementList) > 1) { + + int counter = 0; + while (true) { + switch (operation) { + case NEXT: + currentStnElementListIndex = currentStnElementListIndex + + this.stnElementList.size(); + currentStnElementListIndex--; + currentStnElementListIndex = currentStnElementListIndex + % this.stnElementList.size(); + break; + case PREVIOUS: + // so, we wont get a negative number + currentStnElementListIndex++; + currentStnElementListIndex = currentStnElementListIndex + % this.stnElementList.size(); + break; + default: + break; + + } + counter++; + // System.out.println("counter = "+ counter); + if (counter >= stnElementList.size()) + return; // looped through whole list already, and index back + // to original + if (stnElementList.get(currentStnElementListIndex) + .getActionState() == NsharpConstants.ActState.ACTIVE) { + if (compareStnIsOn + && currentTimeElementListIndex >= 0 + && currentSndElementListIndex >= 0 + && stnTimeSndTable.get(currentStnElementListIndex) + .get(currentTimeElementListIndex) + .get(currentSndElementListIndex) == null) {// .getElementState() + // == + // NsharpConstants.LoadState.NOTAVAIL){ + continue; + } else if (compareTmIsOn) { + boolean found = false; + if (currentTimeElementListIndex >= 0 + && currentSndElementListIndex >= 0 + && stnTimeSndTable + .get(currentStnElementListIndex) + .get(currentTimeElementListIndex) + .get(currentSndElementListIndex) != null) { + // use currentTimeLineStateListIndex + found = true; + } else { + // find an active and available timeline for this + // stn and set is as current + for (int i = 0; i < timeElementList.size(); i++) { + if (timeElementList.get(i).getActionState() == NsharpConstants.ActState.ACTIVE + && stnTimeSndTable + .get(currentStnElementListIndex) + .get(i) + .get(currentSndElementListIndex) != null) { + currentTimeElementListIndex = i; + found = true; + break; + } + } + } + if (!found) { + currentTimeElementListIndex = -1; + } else { + int colorIndex = NsharpConstants.LINE_COMP1; + for (NsharpOperationElement elm : timeElementList) { + if (elm.getActionState() == NsharpConstants.ActState.INACTIVE) + continue; + int tmIndex = timeElementList.indexOf(elm); + NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable + .get(currentStnElementListIndex) + .get(tmIndex) + .get(currentSndElementListIndex); + if (stnTmElm != null) { + stnTmElm.setCompColorIndex(colorIndex); + } + colorIndex++; + if (colorIndex > NsharpConstants.LINE_COMP10) + colorIndex = NsharpConstants.LINE_COMP1; + + } + } + // no matter we find current time line for this stn or + // not + // we should get out of here + break; + } else if (compareSndIsOn) { + boolean found = false; + if (currentTimeElementListIndex >= 0 + && currentSndElementListIndex >= 0 + && stnTimeSndTable + .get(currentStnElementListIndex) + .get(currentTimeElementListIndex) + .get(currentSndElementListIndex) != null) { + found = true; + } else { + // find an active and available snd for this stn and + // set is as current + for (int i = 0; i < sndElementList.size(); i++) { + if (sndElementList.get(i).getActionState() == NsharpConstants.ActState.ACTIVE + && stnTimeSndTable + .get(currentStnElementListIndex) + .get(currentTimeElementListIndex) + .get(i) != null) { + currentSndElementListIndex = i; + found = true; + break; + } + } + } + if (!found) { + currentSndElementListIndex = -1; + } else { + int colorIndex = NsharpConstants.LINE_COMP1; + for (NsharpOperationElement elm : sndElementList) { + if (elm.getActionState() == NsharpConstants.ActState.INACTIVE) + continue; + int sndIndex = sndElementList.indexOf(elm); + NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable + .get(currentStnElementListIndex) + .get(currentTimeElementListIndex) + .get(sndIndex); + if (stnTmElm != null) { + stnTmElm.setCompColorIndex(colorIndex); + } + colorIndex++; + if (colorIndex > NsharpConstants.LINE_COMP10) + colorIndex = NsharpConstants.LINE_COMP1; + } + } + // no matter we find current snd type for this stn or + // not + // we should get out of here + break; + } else + break; + } + } + curStnIdPage = currentStnElementListIndex / numTimeLinePerPage + 1; + + setCurSndProfileProp(); + setCurrentSoundingLayerInfo(); + resetData(); + + refreshPane(); + } + + } + + /* + * Snd Type index stepping is only controlled by shift + up/down arrow keys, + * shift+down key = PREVIOUS operation, shift+up key = NEXT operation + */ + public void setSteppingSndTypeList( + IFrameCoordinator.FrameChangeOperation operation) { + if (this.sndElementList.size() > 0 + && getElemlistActiveNumber(sndElementList) > 1) { + + int counter = 0; + while (true) { + switch (operation) { + case NEXT: + currentSndElementListIndex = currentSndElementListIndex + + this.sndElementList.size(); + currentSndElementListIndex--; + currentSndElementListIndex = currentSndElementListIndex + % this.sndElementList.size(); + break; + case PREVIOUS: + // so, we wont get a negative number + currentSndElementListIndex++; + currentSndElementListIndex = currentSndElementListIndex + % this.sndElementList.size(); + break; + default: + break; + + } + counter++; + // System.out.println("counter = "+ counter); + if (counter >= sndElementList.size()) + return; // looped through whole list already, and index back + // to original + if (sndElementList.get(currentSndElementListIndex) + .getActionState() == NsharpConstants.ActState.ACTIVE) { + if (compareSndIsOn + && currentTimeElementListIndex >= 0 + && currentStnElementListIndex >= 0 + && stnTimeSndTable.get(currentStnElementListIndex) + .get(currentTimeElementListIndex) + .get(currentSndElementListIndex) == null) { + continue; + } else if (compareTmIsOn) { + boolean found = false; + if (currentTimeElementListIndex >= 0 + && currentStnElementListIndex >= 0 + && stnTimeSndTable + .get(currentStnElementListIndex) + .get(currentTimeElementListIndex) + .get(currentSndElementListIndex) != null) { + // use currentTimeLineStateListIndex + found = true; + } else { + // find an active and available timeline for this + // stn and set is as current + for (int i = 0; i < timeElementList.size(); i++) { + if (timeElementList.get(i).getActionState() == NsharpConstants.ActState.ACTIVE + && stnTimeSndTable + .get(currentStnElementListIndex) + .get(i) + .get(currentSndElementListIndex) != null) { + currentTimeElementListIndex = i; + found = true; + break; + } + } + } + if (!found) { + currentTimeElementListIndex = -1; + } else { + int colorIndex = NsharpConstants.LINE_COMP1; + for (NsharpOperationElement elm : timeElementList) { + if (elm.getActionState() == NsharpConstants.ActState.INACTIVE) + continue; + int tmIndex = timeElementList.indexOf(elm); + NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable + .get(currentStnElementListIndex) + .get(tmIndex) + .get(currentSndElementListIndex); + if (stnTmElm != null) { + stnTmElm.setCompColorIndex(colorIndex); + } + colorIndex++; + if (colorIndex > NsharpConstants.LINE_COMP10) + colorIndex = NsharpConstants.LINE_COMP1; + } + } + // no matter we find current time line for this stn or + // not + // we should get out of here + break; + } else if (compareStnIsOn) { + boolean found = false; + // find an active and available stn for this timeline + // and set is as current + if (currentTimeElementListIndex >= 0 + && currentStnElementListIndex >= 0 + && stnTimeSndTable + .get(currentStnElementListIndex) + .get(currentTimeElementListIndex) + .get(currentSndElementListIndex) != null) { + found = true; + } else { + for (int i = 0; i < stnElementList.size(); i++) { + if (stnElementList.get(i).getActionState() == NsharpConstants.ActState.ACTIVE + && stnTimeSndTable + .get(i) + .get(currentTimeElementListIndex) + .get(currentSndElementListIndex) != null) { + currentStnElementListIndex = i; + found = true; + break; + } + } + } + if (!found) { + currentStnElementListIndex = -1; + } else { + int colorIndex = NsharpConstants.LINE_COMP1; + for (NsharpOperationElement elm : stnElementList) { + int stnIndex = stnElementList.indexOf(elm); + NsharpSoundingElementStateProperty stnTmElm = stnTimeSndTable + .get(stnIndex) + .get(currentTimeElementListIndex) + .get(currentSndElementListIndex); + if (stnTmElm != null) { + stnTmElm.setCompColorIndex(colorIndex); + } + colorIndex++; + if (colorIndex > NsharpConstants.LINE_COMP10) + colorIndex = NsharpConstants.LINE_COMP1; + + } + } + // no matter we find current stn or not + // we should get out of here + break; + } else + break; + } + } + curStnIdPage = currentSndElementListIndex / numTimeLinePerPage + 1; + + setCurSndProfileProp(); + setCurrentSoundingLayerInfo(); + resetData(); + + refreshPane(); + } + + } + + // used for sorting + public class tempPoint implements Comparable { + double diff; + + double temp; + + double pressure; + + int type; // 1= temp, 2 = dewpoint + + tempPoint(double diff, double temp, double pressure, int type) { + this.diff = diff; + this.temp = temp; + this.pressure = pressure; + this.type = type; + } + + @Override + public int compareTo(tempPoint o) { + if (this.diff >= o.diff) + return 1; + else + return 0; + } + } + + /* + * Return the closest point to the input point on Hodo graph + */ + public Coordinate getClosestHodoPoint(Coordinate inputC) { + // System.out.println("picked pt CX "+ inputC.x + " CY "+ inputC.y); + Coordinate closeptC = new Coordinate(0, 0); + if (hodoPaneRsc == null) + return closeptC; + + double curSmallestDist = 10000; // picked a impossible big number to + // start with + double distance; + boolean ptFound = false; + NcSoundingLayer layer; + // + // Note: soundingLys list sorted with highest pressure as first element + // + for (int i = 0; i < this.soundingLys.size(); i++) { + layer = this.soundingLys.get(i); + double curS, curD; + curS = layer.getWindSpeed(); + curD = layer.getWindDirection(); + closeptC = WxMath.uvComp((float) curS, (float) curD); + closeptC = hodoPaneRsc.getHodoBackground().getWorld().map(closeptC); + // System.out.println("closeptCx " + closeptC.x+ " closeptCy "+ + // closeptC.y); + distance = inputC.distance(closeptC); + // System.out.println("closeptCx " + closeptC.x+ " closeptCy "+ + // closeptC.y+" distance "+ distance + " curSmallestDist " + // +curSmallestDist); + if (distance < curSmallestDist) { + curSmallestDist = distance; + hodoEditingSoundingLayerIndex = i; + ptFound = true; + } + } + if (ptFound == false) { + closeptC.x = closeptC.y = 0; + } else { + layer = this.soundingLys.get(hodoEditingSoundingLayerIndex); + closeptC = WxMath.uvComp((float) layer.getWindSpeed(), + (float) layer.getWindDirection()); + closeptC = hodoPaneRsc.getHodoBackground().getWorld().map(closeptC); + } + + // System.out.println("picked closeptCx " + closeptC.x+ " closeptCy "+ + // closeptC.y); + return closeptC; + } + + public List getSoundingLys() { + return soundingLys; + } + + public List getPreviousSoundingLys() { + return previousSoundingLys; + } + + /* + * This interpolation is to smooth data out with a pressure gap of 25 mb per + * layer and also keep original lowest and highest layers. + */ + private List performInterpolation( + List rawSndLysLst) { + NcSoundingLayer newLayer = new NcSoundingLayer(); + // System.out.println(" performInterpolation"); + nsharpNative.populateSndgData(rawSndLysLst); + + List mySndLst = new ArrayList(); + // add top layer + try { + // here a shallowCopy is enough + newLayer = (NcSoundingLayer) rawSndLysLst.get(0).clone(); + mySndLst.add(newLayer); + } catch (CloneNotSupportedException e) { + e.printStackTrace(); + } + // The first layer has highest pressure + // get a pressure value below first layer and can be divided by 25 + // exactly + int p = (int) (rawSndLysLst.get(0).getPressure() / 25) * 25; + float interpolatedValue; + if (p == (int) rawSndLysLst.get(0).getPressure()) { // if p is same as + // first layer, then + // this layer is + // added already, + // start from 2nd + // layer + p = p - 25; + } + for (; p >= 50; p = p - 25) { + newLayer = new NcSoundingLayer(); + newLayer.setPressure(p); + interpolatedValue = nsharpNative.nsharpLib.itemp(p); + if (interpolatedValue == NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA) + // this is not good layer data, usually happened when lowest + // layer pressure is + // more than 50, then when interpolate layer for pressure 50, + // will return unvalid value + continue; + newLayer.setTemperature(interpolatedValue); + interpolatedValue = nsharpNative.nsharpLib.idwpt(p); + newLayer.setDewpoint(interpolatedValue); + interpolatedValue = nsharpNative.nsharpLib.iwdir(p); + newLayer.setWindDirection(interpolatedValue); + interpolatedValue = nsharpNative.nsharpLib.iwspd(p); + newLayer.setWindSpeed(interpolatedValue); + interpolatedValue = nsharpNative.nsharpLib.ihght(p); + newLayer.setGeoHeight(interpolatedValue); + interpolatedValue = nsharpNative.nsharpLib.iomeg(p); + newLayer.setOmega(interpolatedValue); + + mySndLst.add(newLayer); + } + return mySndLst; + } + + private void setSoundingInfo(List sndLys) { + if (overlayIsOn) { + previousSoundingLys = soundingLys; + } else { + previousSoundingLys = null; + } + + if (interpolateIsOn == true) { + /* + * TTR829 deep copy is not necessary as performInterpolation() will + * re-allocate new layer for each layer //interpolation is on //we + * dont want to change original raw data, so use a deep copy + * List intpSndLst = new + * ArrayList(); for(NcSoundingLayer layer: sndLys ) + * { try { intpSndLst.add((NcSoundingLayer) layer.clone()); } catch + * (CloneNotSupportedException e) { // TODO Auto-generated catch + * block e.printStackTrace(); } } + * + * // interpolation intpSndLst = performInterpolation(intpSndLst); + * + * soundingLys = intpSndLst; + */ + + soundingLys = performInterpolation(sndLys); + } else { + soundingLys = sndLys; + + } + } + + public void updateDisplay(IRenderableDisplay[] displayArray, + String paneConfigurationName) { + skewtPaneRsc = null; + witoPaneRsc = null; + hodoPaneRsc = null; + timeStnPaneRsc = null; + insetPaneRsc = null; + dataPaneRsc = null; + spcGraphsPaneRsc = null; + futurePaneRsc = null; + for (IRenderableDisplay disp : displayArray) { + ResourcePair rscP = disp.getDescriptor().getResourceList().get(0); + NsharpAbstractPaneResource absPaneRsc = (NsharpAbstractPaneResource) rscP + .getResource(); + if (absPaneRsc instanceof NsharpSkewTPaneResource) { + skewtPaneRsc = (NsharpSkewTPaneResource) absPaneRsc; + skewtPaneRsc.setLinePropertyMap(linePropertyMap); + skewtPaneRsc.setGraphConfigProperty(graphConfigProperty); + skewtPaneRsc.setNsharpNative(nsharpNative); + } else if (absPaneRsc instanceof NsharpDataPaneResource) { + dataPaneRsc = (NsharpDataPaneResource) absPaneRsc; + dataPaneRsc.setLinePropertyMap(linePropertyMap); + dataPaneRsc.setGraphConfigProperty(graphConfigProperty); + dataPaneRsc.setNsharpNative(nsharpNative); + dataPaneRsc.setPageDisplayOrderNumberArray( + pageDisplayOrderNumberArray, + dataPageProperty.getNumberPagePerDisplay()); + } else if (absPaneRsc instanceof NsharpHodoPaneResource) { + hodoPaneRsc = (NsharpHodoPaneResource) absPaneRsc; + hodoPaneRsc.setLinePropertyMap(linePropertyMap); + hodoPaneRsc.setGraphConfigProperty(graphConfigProperty); + hodoPaneRsc.setNsharpNative(nsharpNative); + } else if (absPaneRsc instanceof NsharpWitoPaneResource + && (paneConfigurationName + .equals(NsharpConstants.PANE_SPCWS_CFG_STR) + || paneConfigurationName + .equals(NsharpConstants.PANE_DEF_CFG_1_STR) || paneConfigurationName + .equals(NsharpConstants.PANE_DEF_CFG_2_STR))) { + + witoPaneRsc = (NsharpWitoPaneResource) absPaneRsc; + witoPaneRsc.setLinePropertyMap(linePropertyMap); + witoPaneRsc.setGraphConfigProperty(graphConfigProperty); + witoPaneRsc.setNsharpNative(nsharpNative); + + } else if (absPaneRsc instanceof NsharpInsetPaneResource + && (paneConfigurationName + .equals(NsharpConstants.PANE_SPCWS_CFG_STR) + || paneConfigurationName + .equals(NsharpConstants.PANE_DEF_CFG_1_STR) || paneConfigurationName + .equals(NsharpConstants.PANE_DEF_CFG_2_STR))) { + + insetPaneRsc = (NsharpInsetPaneResource) absPaneRsc; + insetPaneRsc.setLinePropertyMap(linePropertyMap); + insetPaneRsc.setGraphConfigProperty(graphConfigProperty); + insetPaneRsc.setNsharpNative(nsharpNative); + + } else if (absPaneRsc instanceof NsharpSpcGraphsPaneResource + && paneConfigurationName + .equals(NsharpConstants.PANE_SPCWS_CFG_STR)) { + spcGraphsPaneRsc = (NsharpSpcGraphsPaneResource) absPaneRsc; + spcGraphsPaneRsc.setLinePropertyMap(linePropertyMap); + spcGraphsPaneRsc.setGraphConfigProperty(graphConfigProperty); + spcGraphsPaneRsc.setNsharpNative(nsharpNative); + } else if (absPaneRsc instanceof NsharpAbstractPaneResource + && paneConfigurationName + .equals(NsharpConstants.PANE_SIMPLE_D2D_CFG_STR)) { + futurePaneRsc = (NsharpAbstractPaneResource) absPaneRsc; + futurePaneRsc.setLinePropertyMap(linePropertyMap); + futurePaneRsc.setGraphConfigProperty(graphConfigProperty); + futurePaneRsc.setNsharpNative(nsharpNative); + + } else if (absPaneRsc instanceof NsharpTimeStnPaneResource + && (paneConfigurationName + .equals(NsharpConstants.PANE_SIMPLE_D2D_CFG_STR) + || paneConfigurationName + .equals(NsharpConstants.PANE_LITE_D2D_CFG_STR) // d2dlite + || paneConfigurationName + .equals(NsharpConstants.PANE_DEF_CFG_1_STR) || paneConfigurationName + .equals(NsharpConstants.PANE_DEF_CFG_2_STR))) { + timeStnPaneRsc = (NsharpTimeStnPaneResource) absPaneRsc; + timeStnPaneRsc.setLinePropertyMap(linePropertyMap); + timeStnPaneRsc.setGraphConfigProperty(graphConfigProperty); + timeStnPaneRsc.setNsharpNative(nsharpNative); + } + } + this.displayArray = displayArray; + } + + public void resetRscSoundingData() { + if (skewtPaneRsc != null) + skewtPaneRsc.resetData(soundingLys, previousSoundingLys); + if (hodoPaneRsc != null) + hodoPaneRsc.resetData(soundingLys, previousSoundingLys); + if (witoPaneRsc != null) + witoPaneRsc.resetData(soundingLys, previousSoundingLys); + if (dataPaneRsc != null) + dataPaneRsc.resetData(soundingLys, previousSoundingLys); + if (insetPaneRsc != null) + insetPaneRsc.resetData(soundingLys, previousSoundingLys); + if (spcGraphsPaneRsc != null) + spcGraphsPaneRsc.resetData(soundingLys, previousSoundingLys); + } + + public NsharpResourceHandler(IRenderableDisplay[] displayArray, + NsharpEditor editor) { + // System.out.println("NsharpResourceHandler constructed"); + // myNsharpEditor = editor; + elementColorMap.put(NsharpConstants.ActState.CURRENT.name(), + NsharpConstants.color_green); + elementColorMap.put(NsharpConstants.ActState.ACTIVE.name(), + NsharpConstants.color_yellow); + elementColorMap.put(NsharpConstants.ActState.INACTIVE.name(), + NsharpConstants.color_white); + // elementColorMap.put(NsharpConstants.LoadState.NOTAVAIL.name(),NsharpConstants.color_red); + // elementColorMap.put(NsharpConstants.ActState.OVERLAY,NsharpConstants.color_red); + // elementColorMap.put(NsharpConstants.LoadState.AVAIL.name(),NsharpConstants.color_yellow); + nsharpNative = new NsharpNative(); + // System.out.println("NsharpResourceHandler constructed"+this.toString() + // + " nsharpNative="+nsharpNative.toString()); + // based on BigNsharp storm slinky color used and gempak color + // definition + stormSlinkyColorMap.put(new Integer(3), NsharpConstants.color_green); // green + stormSlinkyColorMap.put(new Integer(7), NsharpConstants.color_magenta); + stormSlinkyColorMap.put(new Integer(6), NsharpConstants.color_cyan); + stormSlinkyColorMap.put(new Integer(13), + NsharpConstants.color_violet_md); + stormSlinkyColorMap.put(new Integer(20), + NsharpConstants.color_yellow_DK); + stormSlinkyColorMap.put(new Integer(27), NsharpConstants.color_cyan_md); + NsharpPaletteWindow win = NsharpPaletteWindow.getInstance(); + if (win != null) + currentGraphMode = win.getCurrentGraphMode(); + + // new for configMgr + configMgr = NsharpConfigManager.getInstance(); + configStore = configMgr.retrieveNsharpConfigStoreFromFs(); + graphConfigProperty = configStore.getGraphProperty(); + paneConfigurationName = graphConfigProperty.getPaneConfigurationName(); + + int tempOffset = graphConfigProperty.getTempOffset(); + NsharpWxMath.setTempOffset(tempOffset); + sndCompRadius = graphConfigProperty.getSndCompRadius();// FixMark:nearByStnCompSnd + linePropertyMap = configStore.getLinePropertyMap(); + dataPageProperty = configStore.getDataPageProperty(); + updatePageOrderArray(); + updateDisplay(displayArray, paneConfigurationName); + displayDataPageMax = NsharpConstants.PAGE_MAX_NUMBER + / dataPageProperty.getNumberPagePerDisplay(); + + DateFormatSymbols dfs = new DateFormatSymbols(); + defaultDays = dfs.getShortWeekdays(); + } + + public void disposeInternal() { + // System.out.println("NsharpResourceHandler disposeInternal called"); + // soundingMap= null; + listenerList = null; + soundingLys = null; + previousSoundingLys = null; + stormSlinkyColorMap = null; + elementColorMap = null; + + if (NsharpParcelDialog.getAccess() != null) { + NsharpParcelDialog.getAccess().reset(); + } + + nsharpNative = null; + } + + public void printHeightMark(WGraphics world, GC gc) throws VizException { + // print feet scales... + double vyMax = world.getViewYmax(); + double vyMin = world.getViewYmin(); + double vxMax = world.getViewXmax(); + for (int j = 0; j < NsharpConstants.HEIGHT_LEVEL_FEET.length; j++) { + float meters = (float) NsharpConstants.feetToMeters + .convert(NsharpConstants.HEIGHT_LEVEL_FEET[j]); + + double pressure = nsharpNative.nsharpLib.ipres(meters); + double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, -50).y); + + gc.drawString(Integer + .toString(NsharpConstants.HEIGHT_LEVEL_FEET[j] / 1000), + (int) vxMax + 40, (int) y, false); + + gc.drawLine((int) vxMax + 50, (int) y, (int) vxMax + 45, (int) y); + } + // print meter scales... + for (int j = 0; j < NsharpConstants.HEIGHT_LEVEL_METERS.length; j++) { + int meters = NsharpConstants.HEIGHT_LEVEL_METERS[j]; + + double pressure = nsharpNative.nsharpLib.ipres(meters); + double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, -50).y); + + gc.drawString(Integer.toString(meters / 1000), (int) vxMax + 52, + (int) y, false); + + gc.drawLine((int) vxMax + 50, (int) y, (int) vxMax + 55, (int) y); + } + // print surface level mark + double y = world.mapY(NsharpWxMath.getSkewTXY(soundingLys.get(0) + .getPressure(), -50).y); + gc.drawString( + "SFC(" + + Integer.toString((int) (soundingLys.get(0) + .getGeoHeight())) + "m)", (int) vxMax + 50, + (int) y, false); + gc.drawLine((int) vxMax + 50, (int) y, (int) vxMax + 55, (int) y); + // top level mark at 100 mbar + y = world.mapY(NsharpWxMath.getSkewTXY(100, -50).y); + float hgt = nsharpNative.nsharpLib.ihght(100); + gc.drawString(Float.toString(hgt / 1000F), (int) vxMax + 50, (int) y, + false); + gc.drawString("Kft Km", (int) vxMax + 35, (int) y - 8); + gc.drawString("MSL", (int) vxMax + 45, (int) y - 15); + gc.drawLine((int) vxMax + 40, (int) y, (int) vxMax + 60, (int) y); + + gc.drawLine((int) vxMax + 50, (int) vyMin, (int) vxMax + 50, + (int) vyMax); + + } + + /** + * Prints the pressure lines number at left side out of skewT bkgd for + * printing job + * + * @throws VizException + */ + public void printNsharpPressureLinesNumber(WGraphics world, GC gc) + throws VizException { + String s = null; + double vxMax = world.getViewXmax(); + double vxMin = world.getViewXmin(); + for (int i = 0; i < NsharpConstants.PRESSURE_MAIN_LEVELS.length; i++) { + // we only care about pressure for this case, temp is no important + // when calling getSkewTXY + Coordinate coor = NsharpWxMath.getSkewTXY( + NsharpConstants.PRESSURE_MAIN_LEVELS[i], 0); + + gc.drawLine((int) vxMin, (int) world.mapY(coor.y), (int) vxMax, + (int) world.mapY(coor.y)); + + } + for (int i = 0; i < NsharpConstants.PRESSURE_MARK_LEVELS.length; i++) { + // we only care about pressure for this case, temp is no important + // when calling getSkewTXY + Coordinate coor = NsharpWxMath.getSkewTXY( + NsharpConstants.PRESSURE_MARK_LEVELS[i], 0); + + gc.drawLine((int) vxMin, (int) world.mapY(coor.y), + (int) vxMin + 10, (int) world.mapY(coor.y)); + + } + for (int i = 0; i < NsharpConstants.PRESSURE_NUMBERING_LEVELS.length; i++) { + s = NsharpConstants.pressFormat + .format(NsharpConstants.PRESSURE_NUMBERING_LEVELS[i]); + // we only care about pressure for this case, temp is no important + // when calling getSkewTXY + Coordinate coor = NsharpWxMath.getSkewTXY( + NsharpConstants.PRESSURE_NUMBERING_LEVELS[i], 0); + + gc.drawString(s, (int) vxMin - 20, (int) world.mapY(coor.y), false); + } + } + + /** + * Print the temp number at bottom out of skewT bkgd for printing job + * + * @throws VizException + */ + public void printNsharpTempNumber(WGraphics world, GC gc) + throws VizException { + for (int i = 40; i > -50; i -= 10) { + Coordinate coorStart = NsharpWxMath.getSkewTXY(1050, i); + double startX = world.mapX(coorStart.x); + double startY = world.mapY(coorStart.y); + + gc.drawString(Integer.toString(i), (int) startX, (int) startY + 5, + false); + } + for (int i = -60; i > -120; i -= 10) { + Coordinate coorEnd = NsharpWxMath.getSkewTXY(100, i); + + // System.out.println("X = "+ startX + " Y = "+ startY); + double endX = world.mapX(coorEnd.x); + double endY = world.mapY(coorEnd.y); + + gc.drawString(Integer.toString(i), (int) endX, (int) endY - 10, + false); + } + } + + /** + * + * Print Wind barb for printing job This function followed algorithm in + * plot_barbs (void) at xwvid1.c to choose wind bulb for drawing around + * every 400m + * + */ + public void printNsharpWind(WGraphics world, GC gc) throws VizException { + ArrayList> windList = new ArrayList>(); + + double windX = world.getViewXmax() + 6 * BARB_LENGTH; + // System.out.println("windX="+windX); + float lastHeight = -999; + double windY; + for (NcSoundingLayer layer : soundingLys) { + float pressure = layer.getPressure(); + float spd = layer.getWindSpeed(); + float dir = layer.getWindDirection(); + + if (pressure < 100) { + continue; + } + + if ((layer.getGeoHeight() - lastHeight) < 400) { + + continue; + } + + // Get the vertical ordinate. + windY = world.mapY(NsharpWxMath.getSkewTXY(pressure, 0).y); + + List barb = WindBarbFactory.getWindGraphics( + /* metersPerSecondToKnots.convert */(double) (spd), (double) dir); + if (barb != null) { + WindBarbFactory.scaleBarb(barb, -7); + WindBarbFactory.translateBarb(barb, windX, windY); + windList.add(barb); + } + + lastHeight = layer.getGeoHeight(); + } + Coordinate pt1 = new Coordinate(0, 0), pt2; + for (List barb : windList) { + for (LineStroke stroke : barb) { + // stroke render: rewrite stroke.render() for our printing + // purpose + if (stroke.getType() == "M") { + pt1 = stroke.getPoint(); + // change X coordinate by mirroring x coordinate at windX + // axis. AS we scaleBarb with -5 time. + // It is easier to mirror at x-axis for this case. + pt1.x = windX - (pt1.x - windX); + // System.out.print("Myp1x="+(int)pt1.x+" p1y="+(int)pt1.y); + + } else if (stroke.getType() == "D") { + pt2 = stroke.getPoint(); + pt2.x = windX - (pt2.x - windX); + // System.out.println( " p2x="+(int)pt2.x+" p2y="+ + // (int)pt2.y); + gc.drawLine((int) pt1.x, (int) pt1.y, (int) pt2.x, + (int) pt2.y); + } + } + } + gc.drawLine((int) windX, + (int) world.mapY(NsharpWxMath.getSkewTXY(100, 0).y), + (int) windX, + (int) world.mapY(NsharpWxMath.getSkewTXY(1000, 0).y)); + } + + /** + * + * Print the wetbulb trace curve + * + * @throws VizException + */ + public void printNsharpWetbulbTraceCurve(WGraphics world, GC gc) + throws VizException { + if ((soundingLys == null) || (soundingLys.size() == 0)) + return; + float t1; + + Coordinate c2 = null; + Coordinate c1; + // print trace + for (NcSoundingLayer layer : this.soundingLys) { + if (layer.getDewpoint() > -200) { + t1 = nsharpNative.nsharpLib.wetbulb(layer.getPressure(), + layer.getTemperature(), layer.getDewpoint()); + + c1 = NsharpWxMath.getSkewTXY(layer.getPressure(), t1); + c1.x = world.mapX(c1.x); + c1.y = world.mapY(c1.y); + if (c2 != null) { + gc.drawLine((int) c1.x, (int) c1.y, (int) c2.x, (int) c2.y); + } + c2 = c1; + } + } + + } + + public void printNsharpParcelTraceCurve(WGraphics world, GC gc) + throws VizException { + if (soundingLys.size() > 0) { + // for (ParcelData parData: parcelList){ + // plotNsharpParcelTraceCurve(null, 0, world, + // NsharpConstants.color_white,parData.parcelType, + // parData.userPressure, gc, true); + // nsharpNative.nsharpLib.define_parcel(parData.parcelType, + // parData.parcelLayerPressure); + nsharpNative.nsharpLib.define_parcel(currentParcel, + currentParcelLayerPressure); + _lplvalues lpvls = new _lplvalues(); + nsharpNative.nsharpLib.get_lpvaluesData(lpvls); + + float sfctemp, sfcdwpt, sfcpres; + sfctemp = lpvls.temp; + sfcdwpt = lpvls.dwpt; + sfcpres = lpvls.pres; + + float vtemp = nsharpNative.nsharpLib.virtemp(sfcpres, sfctemp, + sfcdwpt); + Coordinate c1 = NsharpWxMath.getSkewTXY(sfcpres, vtemp); + c1.x = world.mapX(c1.x); + c1.y = world.mapY(c1.y); + FloatByReference p2 = new FloatByReference(0), t2 = new FloatByReference( + 0); + ; + nsharpNative.nsharpLib.drylift(sfcpres, sfctemp, sfcdwpt, p2, t2); + vtemp = nsharpNative.nsharpLib.virtemp(p2.getValue(), + t2.getValue(), t2.getValue()); + Coordinate c2 = NsharpWxMath.getSkewTXY(p2.getValue(), vtemp); + c2.x = world.mapX(c2.x); + c2.y = world.mapY(c2.y); + + gc.drawLine((int) c1.x, (int) c1.y, (int) c2.x, (int) c2.y); + c1 = c2; + + float t3; + for (float i = p2.getValue() - 50; i >= 100; i = i - 50) { + t3 = nsharpNative.nsharpLib.wetlift(p2.getValue(), + t2.getValue(), i); + vtemp = nsharpNative.nsharpLib.virtemp(i, t3, t3); + c2 = NsharpWxMath.getSkewTXY(i, vtemp); + c2.x = world.mapX(c2.x); + c2.y = world.mapY(c2.y); + + gc.drawLine((int) c1.x, (int) c1.y, (int) c2.x, (int) c2.y); + c1 = c2; + } + + t3 = nsharpNative.nsharpLib.wetlift(p2.getValue(), t2.getValue(), + 100); + vtemp = nsharpNative.nsharpLib.virtemp(100, t3, t3); + c2 = NsharpWxMath.getSkewTXY(100, vtemp); + c2.x = world.mapX(c2.x); + c2.y = world.mapY(c2.y); + + gc.drawLine((int) c1.x, (int) c1.y, (int) c2.x, (int) c2.y); + // } + } + } + + /** + * + * Print the temperature curve when during overlap or compare mode + * + * @throws VizException + */ + + public void printNsharpPressureTempCurve(WGraphics world, int type, GC gc, + List soundingLys) throws VizException { + if ((soundingLys == null) || (soundingLys.size() == 0)) + return; + + double maxPressure = NsharpWxMath.reverseSkewTXY(new Coordinate(0, + world.getWorldYmax())).y; + double minPressure = NsharpWxMath.reverseSkewTXY(new Coordinate(0, + world.getWorldYmin())).y; + Coordinate c0 = null; + for (NcSoundingLayer layer : soundingLys) { + double t; + if (type == TEMP_TYPE) + t = layer.getTemperature(); + else if (type == DEWPOINT_TYPE) + t = layer.getDewpoint(); + else + break; + double pressure = layer.getPressure(); + if (t != INVALID_DATA && pressure >= minPressure + && pressure <= maxPressure) { + + Coordinate c1 = NsharpWxMath.getSkewTXY(pressure, t); + + c1.x = world.mapX(c1.x); + c1.y = world.mapY(c1.y); + // System.out.println("C.x "+ c1.x + " C.y "+ c1.y); + if (c0 != null) { + gc.drawLine((int) c0.x, (int) c0.y, (int) c1.x, (int) c1.y); + } + c0 = c1; + } + } + + } + + /** + * + * Print the HODO + * + * + * @throws VizException + */ + + public void printNsharpHodoWind(WGraphics world, GC gc, + List soundingLays) throws VizException { + Coordinate c0 = null; + Coordinate c1; + for (NcSoundingLayer layer : soundingLays) { + if (layer.getPressure() < 100 || layer.getWindSpeed() < 0) + continue; + float wspd = layer.getWindSpeed(); + float wdir = layer.getWindDirection(); + c1 = WxMath.uvComp(wspd, wdir); + if (c0 != null) { + gc.setLineWidth(1); + gc.drawLine((int) world.mapX(c0.x), (int) world.mapY(c0.y), + (int) world.mapX(c1.x), (int) world.mapY(c1.y)); + } + c0 = c1; + } + + } + + public boolean isPlotInteractiveTemp() { + return plotInteractiveTemp; + } + + public void setPlotInteractiveTemp(boolean plotInteractiveTemp) { + this.plotInteractiveTemp = plotInteractiveTemp; + if (skewtPaneRsc != null) + skewtPaneRsc.setPlotInteractiveTemp(plotInteractiveTemp); + } + + public void setInteractiveTempPointCoordinate( + Coordinate interactiveTempPointCoordinate) { + // System.out.println("setInteractiveTempPointCoordinate called"); + this.interactiveTempPointCoordinate = interactiveTempPointCoordinate; + plotInteractiveTemp = true; + if (skewtPaneRsc != null) { + skewtPaneRsc.setPlotInteractiveTemp(plotInteractiveTemp); + skewtPaneRsc + .setInteractiveTempPointCoordinate(interactiveTempPointCoordinate); + } + } + + public void setInteractiveHodoPointCoordinate(Coordinate c) { + if (hodoPaneRsc == null) + return; + try { + NcSoundingLayer hodoLayer = soundingLys + .get(hodoEditingSoundingLayerIndex); + if (hodoLayer != null) { + // TTR575 + nsharpNative.populateSndgData(soundingLys); + // end TTR575 + Coordinate c1 = hodoPaneRsc.getHodoBackground().getWorld() + .unMap(c.x, c.y); + // System.out.println("picked pt after unmap CX "+ c1.x + + // " CY "+ c1.y); + c1 = WxMath.speedDir((float) c1.x, (float) c1.y); + hodoLayer.setWindSpeed((float) c1.x); + hodoLayer.setWindDirection((float) c1.y); + hodoPaneRsc.createRscHodoWindShapeAll(); + if (witoPaneRsc != null) + witoPaneRsc.createAllWireFrameShapes(); + if (insetPaneRsc != null) + insetPaneRsc.createInsetWireFrameShapes(); + if (skewtPaneRsc != null) + // CHIN:::fix edit zoom issue skewtPaneRsc.handleResize(); + skewtPaneRsc.createRscWireFrameShapes(); + } + } catch (Exception e) { + + } + } + + public void applyMovingTempLine() { + if (skewtPaneRsc == null) + return; + Coordinate inC = NsharpWxMath.reverseSkewTXY(skewtPaneRsc.getWorld() + .unMap(interactiveTempPointCoordinate)); + float inTemp = (float) inC.x; + currentSoundingLayerIndex = skewtPaneRsc.getCurrentSoundingLayerIndex(); + currentTempCurveType = skewtPaneRsc.getCurrentTempCurveType(); + float currentLayerTemp, currentLayerDewP; + float smallestGap = skewtPaneRsc.getTempDewPtSmallestGap(); + float tempShiftedDist; + currentLayerTemp = soundingLys.get(currentSoundingLayerIndex) + .getTemperature(); + currentLayerDewP = soundingLys.get(currentSoundingLayerIndex) + .getDewpoint(); + if (currentTempCurveType == TEMP_TYPE) { + if (inTemp < currentLayerTemp) { + // shift to left, tempShiftedDist should be a negative number + if ((currentLayerTemp - inTemp) > smallestGap) { + tempShiftedDist = -smallestGap; + } else { + tempShiftedDist = inTemp - currentLayerTemp; + } + } else { + // shift to right, tempShiftedDist should be a positive number + tempShiftedDist = inTemp - currentLayerTemp; + } + } else { + if (inTemp < currentLayerDewP) { + // shift to left, tempShiftedDist should be a negative number + tempShiftedDist = inTemp - currentLayerDewP; + } else { + // shift to right, tempShiftedDist should be a positive number + if ((inTemp - currentLayerDewP) > smallestGap) { + tempShiftedDist = smallestGap; + } else { + tempShiftedDist = inTemp - currentLayerDewP; + } + } + } + for (NcSoundingLayer layer : soundingLys) { + float t; + if (currentTempCurveType == TEMP_TYPE) { + t = layer.getTemperature(); + if (t != NsharpNativeConstants.NSHARP_NATIVE_INVALID_DATA) { + layer.setTemperature(t + tempShiftedDist); + } + } else { + t = layer.getDewpoint(); + if (t != NsharpNativeConstants.NSHARP_NATIVE_INVALID_DATA) { + layer.setDewpoint(t + tempShiftedDist); + } + } + } + // re-populate snd data to nsharp native code lib for later calculating + nsharpNative.populateSndgData(soundingLys); + // get storm motion wind data after populate sounding from NsharpLib + skewtPaneRsc.setSoundingLys(soundingLys); + // CHIN:::fix edit zoom issue skewtPaneRsc.handleResize(); + skewtPaneRsc.createRscWireFrameShapes(); + if (hodoPaneRsc != null) { + hodoPaneRsc.setSoundingLys(soundingLys); + hodoPaneRsc.createRscHodoWindShapeAll(); + } + } + + public void applyInteractiveTempPoint() { + if (skewtPaneRsc == null) + return; + Coordinate inC = NsharpWxMath.reverseSkewTXY(skewtPaneRsc.getWorld() + .unMap(interactiveTempPointCoordinate)); + double inTemp = inC.x; + currentSoundingLayerIndex = skewtPaneRsc.getCurrentSoundingLayerIndex(); + NcSoundingLayer layer = this.soundingLys.get(currentSoundingLayerIndex); + currentTempCurveType = skewtPaneRsc.getCurrentTempCurveType(); + // System.out.println("applyInteractiveTempPoint called pressure " + + // inC.y + " temp "+ inTemp + + // " currentTempCurveType " + currentTempCurveType ); + + if (currentTempCurveType == TEMP_TYPE) { + if (inTemp < layer.getDewpoint()) + // temp can not be lower than dew point + layer.setTemperature(layer.getDewpoint()); + else + layer.setTemperature((float) inTemp); + } else { + if (inTemp > layer.getTemperature()) + // dew point can not be higher than temp + layer.setDewpoint(layer.getTemperature()); + else + layer.setDewpoint((float) inTemp); + } + + // re-populate snd data to nsharp native code lib for later calculating + nsharpNative.populateSndgData(soundingLys); + // get storm motion wind data after populate sounding from NsharpLib + skewtPaneRsc.setSoundingLys(soundingLys); + // CHIN:::fix edit zoom issue skewtPaneRsc.handleResize(); + skewtPaneRsc.createRscWireFrameShapes(); + + if (hodoPaneRsc != null) { + hodoPaneRsc.setSoundingLys(soundingLys); + hodoPaneRsc.createRscHodoWindShapeAll(); + } + } + + public void applySfcEditing(float tp, float dp, float ws, float wd, + float pressure) { + currentSoundingLayerIndex = nsharpNative.nsharpLib.sfc(); + NcSoundingLayer layer = this.soundingLys.get(currentSoundingLayerIndex); + layer.setTemperature(tp); + layer.setDewpoint(dp); + layer.setWindDirection(wd); + layer.setWindSpeed(ws); + layer.setPressure(pressure); + // re-populate snd data to nsharp native code lib for later calculating + nsharpNative.populateSndgData(soundingLys); + if (skewtPaneRsc != null) + skewtPaneRsc.setSoundingLys(soundingLys); + if (hodoPaneRsc != null) + hodoPaneRsc.setSoundingLys(soundingLys); + if (insetPaneRsc != null) + insetPaneRsc.setSoundingLys(soundingLys); + if (witoPaneRsc != null) + witoPaneRsc.setSoundingLys(soundingLys); + if (dataPaneRsc != null) + dataPaneRsc.setSoundingLys(soundingLys); + } + + public void updateLayer(int layerIndex, float tp, float dp, float ws, + float wd, float pressure) { + if (layerIndex < 0 || layerIndex >= soundingLys.size()) + return; + currentSoundingLayerIndex = layerIndex; + NcSoundingLayer layer = soundingLys.get(currentSoundingLayerIndex); + layer.setGeoHeight(nsharpNative.nsharpLib.ihght(pressure)); + layer.setTemperature(tp); + layer.setDewpoint(dp); + layer.setWindDirection(wd); + layer.setWindSpeed(ws); + layer.setPressure(pressure); + // re-populate snd data to nsharp native code lib for later calculating + Collections.sort(soundingLys, + NsharpDataHandling.reversePressureHeightWindComparator()); + nsharpNative.populateSndgData(soundingLys); + // get storm motion wind data after populate sounding from NsharpLib + // refresh test area if it is shown now + NsharpShowTextDialog textarea = NsharpShowTextDialog.getAccess(); + if (textarea != null) { + textarea.refreshTextData(); + } + if (skewtPaneRsc != null) { + skewtPaneRsc.setSoundingLys(soundingLys); + // CHIN:::fix edit zoom issue skewtPaneRsc.handleResize(); + skewtPaneRsc.createRscWireFrameShapes(); + } + if (hodoPaneRsc != null) { + hodoPaneRsc.setSoundingLys(soundingLys); + hodoPaneRsc.createRscHodoWindShapeAll(); + } + if (insetPaneRsc != null) { + insetPaneRsc.setSoundingLys(soundingLys); + insetPaneRsc.createInsetWireFrameShapes(); + } + if (witoPaneRsc != null) { + witoPaneRsc.setSoundingLys(soundingLys); + witoPaneRsc.createAllWireFrameShapes(); + } + if (dataPaneRsc != null) + dataPaneRsc.setSoundingLys(soundingLys); + } + + public void addNewLayer(float tp, float dp, float ws, float wd, + float pressure) { + // NsharpBackgroundResource bkRsc = descriptor.getSkewTBkGResource(); + // currentSoundingLayer =layerIndex; + NcSoundingLayer layer = new NcSoundingLayer(); + layer.setGeoHeight(nsharpNative.nsharpLib.ihght(pressure)); + layer.setTemperature(tp); + layer.setDewpoint(dp); + layer.setWindDirection(wd); + layer.setWindSpeed(ws); + layer.setPressure(pressure); + soundingLys.add(layer); + // re-populate snd data to nsharp native code lib for later calculating + Collections.sort(soundingLys, + NsharpDataHandling.reversePressureHeightWindComparator()); + nsharpNative.populateSndgData(soundingLys); + // get storm motion wind data after populate sounding from NsharpLib + // refresh text area if it is shown now + NsharpShowTextDialog textarea = NsharpShowTextDialog.getAccess(); + if (textarea != null) { + textarea.refreshTextData(); + } + if (skewtPaneRsc != null) { + skewtPaneRsc.setSoundingLys(soundingLys); + // CHIN:::fix edit zoom issue skewtPaneRsc.handleResize(); + skewtPaneRsc.createRscWireFrameShapes(); + } + if (hodoPaneRsc != null) { + hodoPaneRsc.setSoundingLys(soundingLys); + hodoPaneRsc.createRscHodoWindShapeAll(); + } + if (insetPaneRsc != null) { + insetPaneRsc.setSoundingLys(soundingLys); + insetPaneRsc.createInsetWireFrameShapes(); + } + if (witoPaneRsc != null) { + witoPaneRsc.setSoundingLys(soundingLys); + witoPaneRsc.createAllWireFrameShapes(); + } + if (dataPaneRsc != null) + dataPaneRsc.setSoundingLys(soundingLys); + } + + public void setGraphConfigProperty(NsharpGraphProperty graphConfigProperty) { + this.graphConfigProperty = graphConfigProperty; + int tempOffset = graphConfigProperty.getTempOffset(); + sndCompRadius = graphConfigProperty.getSndCompRadius();// FixMark:nearByStnCompSnd + NsharpWxMath.setTempOffset(tempOffset); + if (skewtPaneRsc != null) { + skewtPaneRsc.setGraphConfigProperty(graphConfigProperty); + skewtPaneRsc.handleResize(); + skewtPaneRsc.getSkewTBackground().setGraphConfigProperty( + graphConfigProperty); + } + if (hodoPaneRsc != null) { + hodoPaneRsc.setGraphConfigProperty(graphConfigProperty); + hodoPaneRsc.createRscHodoWindShapeAll(); + } + if (witoPaneRsc != null) { + witoPaneRsc.setGraphConfigProperty(graphConfigProperty); + witoPaneRsc.createAllWireFrameShapes(); + } + if (insetPaneRsc != null) { + insetPaneRsc.setGraphConfigProperty(graphConfigProperty); + insetPaneRsc.createInsetWireFrameShapes(); + } + } + + public NsharpGraphProperty getGraphConfigProperty() { + return graphConfigProperty; + } + + public void setLinePropertyMap( + HashMap linePropertyMap) { + this.linePropertyMap = linePropertyMap; + if (skewtPaneRsc != null) { + skewtPaneRsc.setLinePropertyMap(linePropertyMap); + skewtPaneRsc.handleResize(); + } + if (hodoPaneRsc != null) { + hodoPaneRsc.setLinePropertyMap(linePropertyMap); + hodoPaneRsc.createRscHodoWindShapeAll(); + } + if (timeStnPaneRsc != null) + timeStnPaneRsc.setLinePropertyMap(linePropertyMap); + } + + private void updatePageOrderArray() { + pageDisplayOrderNumberArray[NsharpConstants.PAGE_SUMMARY1] = dataPageProperty + .getSummary1Page(); + pageDisplayOrderNumberArray[NsharpConstants.PAGE_SUMMARY2] = dataPageProperty + .getSummary2Page(); + pageDisplayOrderNumberArray[NsharpConstants.PAGE_PARCEL_DATA] = dataPageProperty + .getParcelDataPage(); + pageDisplayOrderNumberArray[NsharpConstants.PAGE_THERMODYNAMIC_DATA] = dataPageProperty + .getThermodynamicDataPage(); + pageDisplayOrderNumberArray[NsharpConstants.PAGE_OPC_DATA] = dataPageProperty + .getOpcDataPage(); + pageDisplayOrderNumberArray[NsharpConstants.PAGE_MIXING_HEIGHT] = dataPageProperty + .getMixingHeightPage(); + pageDisplayOrderNumberArray[NsharpConstants.PAGE_STORM_RELATIVE] = dataPageProperty + .getStormRelativePage(); + pageDisplayOrderNumberArray[NsharpConstants.PAGE_MEAN_WIND] = dataPageProperty + .getMeanWindPage(); + pageDisplayOrderNumberArray[NsharpConstants.PAGE_CONVECTIVE_INITIATION] = dataPageProperty + .getConvectiveInitiationPage(); + pageDisplayOrderNumberArray[NsharpConstants.PAGE_SEVERE_POTENTIAL] = dataPageProperty + .getSeverePotentialPage(); + pageDisplayOrderNumberArray[NsharpConstants.PAGE_D2DLITE] = dataPageProperty + .getD2dLitePage(); // d2dlite + pageDisplayOrderNumberArray[NsharpConstants.PAGE_FUTURE] = dataPageProperty + .getFuturePage(); // d2dlite + } + + public void setDataPageProperty(NsharpDataPageProperty dataPageProperty) { + this.dataPageProperty = dataPageProperty; + updatePageOrderArray(); + if (dataPaneRsc != null) + dataPaneRsc.setPageDisplayOrderNumberArray( + pageDisplayOrderNumberArray, + dataPageProperty.getNumberPagePerDisplay()); + } + + public void handleTimeLineActConfig(List tlList, + NsharpConstants.ActState actSt) { + for (String tlStr : tlList) { + for (NsharpOperationElement tl : timeElementList) { + if (tlStr.equals(tl.getElementDescription())) { + tl.setActionState(actSt); + break; + } + } + } + } + + public void handleStationActConfig(List stnList, + NsharpConstants.ActState actSt) { + for (String tlStr : stnList) { + for (NsharpOperationElement stn : stnElementList) { + if (tlStr.equals(stn.getElementDescription())) { + stn.setActionState(actSt); + break; + } + } + } + } + + public void handleSndTypeActConfig(List sndTypeList, + NsharpConstants.ActState actSt) { + for (String tlStr : sndTypeList) { + for (NsharpOperationElement sndType : sndElementList) { + if (tlStr.equals(sndType.getElementDescription())) { + sndType.setActionState(actSt); + break; + } + } + } + } + + public int getCurrentTextChapter() { + return currentTextChapter; + } + + public float getCurrentParcelLayerPressure() { + return currentParcelLayerPressure; + } + + public NsharpSkewTPaneResource getSkewtPaneRsc() { + return skewtPaneRsc; + } + + public NsharpHodoPaneResource getHodoPaneRsc() { + return hodoPaneRsc; + } + + public NsharpSoundingElementStateProperty getPreSndProfileProp() { + return preSndProfileProp; + } + + public int getCurTimeLinePage() { + return curTimeLinePage; + } + + public int getCurrentInsetPage() { + return currentInsetPage; + } + + public int getCurrentSoundingLayerIndex() { + return currentSoundingLayerIndex; + } + + public IFrameCoordinator.FrameChangeOperation getCurrentOpDirection() { + return currentOpDirection; + } + + public NsharpSoundingElementStateProperty getCurSndProfileProp() { + return curSndProfileProp; + } + + public int getCurStnIdPage() { + return curStnIdPage; + } + + public int getCurSndPage() { + return curSndPage; + } + + public HashMap getElementColorMap() { + return elementColorMap; + } + + public int getTotalTimeLinePage() { + return totalTimeLinePage; + } + + public int getTotalStnIdPage() { + return totalStnIdPage; + } + + public int getTotalSndPage() { + return totalSndPage; + } + + public void repopulateSndgData() { + nsharpNative.populateSndgData(soundingLys); + } + + public NsharpWitoPaneResource getWitoPaneRsc() { + return witoPaneRsc; + } + + public NsharpInsetPaneResource getInsetPaneRsc() { + return insetPaneRsc; + } + + public NsharpSpcGraphsPaneResource getSpcGraphsPaneRsc() { + return spcGraphsPaneRsc; + } + + public NsharpDataPaneResource getDataPaneRsc() { + return dataPaneRsc; + } + + public void setTimeStnBoxData(int cnYOrig, int dtNextPage_end, int dtYOrig, + int dtXOrig, int dtWidth, double charHeight, double lineHeight, + int numTimeLinePerPage) { + this.charHeight = charHeight; + this.lineHeight = lineHeight; + this.dtYOrig = dtYOrig; + this.dtXOrig = dtXOrig; + this.dtWidth = dtWidth; + this.cnYOrig = cnYOrig; + this.dtNextPageEnd = dtNextPage_end; + this.numTimeLinePerPage = numTimeLinePerPage; + calculateTimeStnBoxData(); + } + + public void refreshPane() { + for (int i = 0; i < displayArray.length; i++) { + displayArray[i].refresh(); + } + } + + public String getPaneConfigurationName() { + return paneConfigurationName; + } + + // d2dlite start + public void setPaneConfigurationName(String paneConfigurationName) { + if (this.paneConfigurationName.equals(paneConfigurationName)) + return; + if (this.paneConfigurationName + .equals(NsharpConstants.PANE_LITE_D2D_CFG_STR)) { + if (!paneConfigurationName + .equals(NsharpConstants.PANE_LITE_D2D_CFG_STR)) { + + currentGraphMode = NsharpConstants.GRAPH_SKEWT; + } + } else { + if (paneConfigurationName + .equals(NsharpConstants.PANE_LITE_D2D_CFG_STR)) { + currentGraphMode = NsharpConstants.GRAPH_SKEWT; + } + } + this.paneConfigurationName = paneConfigurationName; + } // d2dlite end + + private void calculateTimeStnBoxData() { + // set total time line group and stn id list page number + + // System.out.println("numTimeLinePerPage="+numTimeLinePerPage); + totalTimeLinePage = timeElementList.size() / numTimeLinePerPage; + if (timeElementList.size() % numTimeLinePerPage != 0) + totalTimeLinePage = totalTimeLinePage + 1; + curTimeLinePage = currentTimeElementListIndex / numTimeLinePerPage + 1; + totalStnIdPage = stnElementList.size() / numTimeLinePerPage; + if (stnElementList.size() % numTimeLinePerPage != 0) + totalStnIdPage++; + curStnIdPage = currentStnElementListIndex / numTimeLinePerPage + 1; + totalSndPage = sndElementList.size() / numTimeLinePerPage; + if (sndElementList.size() % numTimeLinePerPage != 0) + totalSndPage++; + curSndPage = currentSndElementListIndex / numTimeLinePerPage + 1; + } + + /* + * Return size of stnTimeSndTable Note that not all elements in this table + * has sounding data loaded. Therefore, returned size may be much bigger + * than the number of actual loaded sounding data frame. + */ + public int getFrameCount() { + return timeElementList.size() * sndElementList.size() + * stnElementList.size(); + } + + /* + * return "accumulated" index to stnTimeSndTable of current displayed + * sounding data + */ + public int getCurrentIndex() { + int index = 0; + if (currentSndElementListIndex >= 0 && currentStnElementListIndex >= 0 + && currentTimeElementListIndex >= 0) { + index = currentSndElementListIndex + currentTimeElementListIndex + * sndElementList.size() + currentStnElementListIndex + * timeElementList.size() * sndElementList.size(); + } + return index; + } + + /* + * set current displayed sounding data using the input "accumulated" index + * (to stnTimeSndTable) return false: If input index is not valid or + * sounding data is not loaded for input index return true: if set + * successfully + */ + public boolean setCurrentIndex(int index) { + if (index < 0 + || index >= (timeElementList.size() * sndElementList.size() * stnElementList + .size())) { + // System.out.println("invalid index="+index); + return false; + } + int tempStni, tempSndi, tempTmi; + tempStni = index / (timeElementList.size() * sndElementList.size()); + tempTmi = (index % (timeElementList.size() * sndElementList.size())) + / sndElementList.size(); + tempSndi = (index % (timeElementList.size() * sndElementList.size())) + % sndElementList.size(); + if (timeElementList.get(tempTmi).getActionState() == NsharpConstants.ActState.INACTIVE + || stnElementList.get(tempStni).getActionState() == NsharpConstants.ActState.INACTIVE + || sndElementList.get(tempSndi).getActionState() == NsharpConstants.ActState.INACTIVE + || stnTimeSndTable.get(tempStni).get(tempTmi).get(tempSndi) == null) { + // System.out.println("invalid element="+index); + return false; + } + previousTimeLineStateListIndex = currentTimeElementListIndex; + currentStnElementListIndex = tempStni; + currentTimeElementListIndex = tempTmi; + currentSndElementListIndex = tempSndi; + setCurSndProfileProp(); + curTimeLinePage = currentTimeElementListIndex / numTimeLinePerPage + 1; + curSndPage = currentSndElementListIndex / numTimeLinePerPage + 1; + curStnIdPage = currentStnElementListIndex / numTimeLinePerPage + 1; + setCurrentSoundingLayerInfo(); + resetData(); + refreshPane(); + return true; + } } - diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpSkewTPaneResource.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpSkewTPaneResource.java index 5db16267f7..248782caf1 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpSkewTPaneResource.java +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpSkewTPaneResource.java @@ -1,4 +1,5 @@ package gov.noaa.nws.ncep.ui.nsharp.display.rsc; + /** * * @@ -87,678 +88,810 @@ import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.GeometryFactory; import com.vividsolutions.jts.geom.LineString; -public class NsharpSkewTPaneResource extends NsharpAbstractPaneResource{ - private NsharpSkewTPaneBackground skewTBackground; - private NsharpIcingPaneBackground icingBackground; - private NsharpTurbulencePaneBackground turbBackground; - private PaintProperties paintProps; - private RGB wwTypeColor; - private int currentGraphMode= NsharpConstants.GRAPH_SKEWT; - private int currentSkewTEditMode = NsharpConstants.SKEWT_EDIT_MODE_EDITPOINT; - private int skewtWidth = NsharpConstants.SKEWT_WIDTH; - private int skewtHeight = NsharpConstants.SKEWT_HEIGHT; - private int skewtXOrig = NsharpConstants.SKEWT_X_ORIG; - private int skewtYOrig = NsharpConstants.SKEWT_Y_ORIG; - private float omegaXOrig = NsharpConstants.OMEGA_X_ORIG; - private float omegaYOrig = NsharpConstants.OMEGA_Y_ORIG; - private float omegaWidth = NsharpConstants.OMEGA_WIDTH; - private float omegaHeight = NsharpConstants.OMEGA_HEIGHT; - private float omegaYEnd = NsharpConstants.OMEGA_Y_END; - private float xRatio=1; - private float yRatio=1; - private String sTemperatureC= ""; - private String sTemperatureF = ""; - private String sThetaInK = ""; - private String sWThetaInK = ""; - private String sEThetaInK=""; - private String sMixingRatio = ""; - private String sPressure = ""; - private double dPressure; - private ArrayList windBarbShapeList; - private IWireframeShape heightMarkRscShape=null; - private IWireframeShape wetBulbTraceRscShape = null; - private IWireframeShape vtempTraceCurveRscShape = null; - private IWireframeShape omegaBkgShape = null; - private IWireframeShape titleBoxShape = null; - private IWireframeShape omegaRscShape=null; - private IShadedShape cloudFMShape = null; - private IWireframeShape cloudFMLabelShape = null; - private IShadedShape cloudCEShape = null; - private IWireframeShape parcelVtTraceRscShape; //Virtual temperature Parcel trace - //Real temperature parcel trace also considering comparison/overlay, therefore using a list - private List parcelRtShapeList = new ArrayList(); - private IWireframeShape dacpeTraceRscShape; - private ListpressureTempRscShapeList = new ArrayList(); - //ICING wireframe shape - private IWireframeShape icingTempShape = null; - private IWireframeShape icingRHShape = null; - private IWireframeShape icingEPIShape = null; - //Turbulence wireframe shape - private IWireframeShape turbLnShape = null; - private IWireframeShape turbWindShearShape = null; - - private IWireframeShape lclShape = null; - private IWireframeShape elShape = null; - private IWireframeShape lfcShape = null; - private IWireframeShape fzlShape = null; - private IWireframeShape effectiveLayerLineShape=null; - public int TEMP_TYPE = 1; - public int DEWPOINT_TYPE = 2; - private int currentTempCurveType; - private Coordinate interactiveTempPointCoordinate; - private boolean plotInteractiveTemp= false; - private boolean cursorInSkewT = false; - private static int CURSER_FONT_INC_STEP = 3; - private static int CURSER_FONT_10 =10; - private static int CURSER_STRING_OFF =CURSER_FONT_10+ 5*CURSER_FONT_INC_STEP; - private int curseToggledFontLevel= CURSER_FONT_10; //0:default 1:large 2:turn off display - private String myPerspective= NmapCommon.NatlCntrsPerspectiveID; - public static ReentrantLock reentryLock = new ReentrantLock (); - private boolean justMoveToSidePane = false; - private boolean cursorTopWindBarb = false; - private boolean windBarbMagnify = false; - private int currentWindBarbSoundingLayerIndex; - - +public class NsharpSkewTPaneResource extends NsharpAbstractPaneResource { + private NsharpSkewTPaneBackground skewTBackground; + + private NsharpIcingPaneBackground icingBackground; + + private NsharpTurbulencePaneBackground turbBackground; + + private PaintProperties paintProps; + + private RGB wwTypeColor; + + private int currentGraphMode = NsharpConstants.GRAPH_SKEWT; + + private int currentSkewTEditMode = NsharpConstants.SKEWT_EDIT_MODE_EDITPOINT; + + private int skewtWidth = NsharpConstants.SKEWT_WIDTH; + + private int skewtHeight = NsharpConstants.SKEWT_HEIGHT; + + private int skewtXOrig = NsharpConstants.SKEWT_X_ORIG; + + private int skewtYOrig = NsharpConstants.SKEWT_Y_ORIG; + + private float omegaXOrig = NsharpConstants.OMEGA_X_ORIG; + + private float omegaYOrig = NsharpConstants.OMEGA_Y_ORIG; + + private float omegaWidth = NsharpConstants.OMEGA_WIDTH; + + private float omegaHeight = NsharpConstants.OMEGA_HEIGHT; + + private float omegaYEnd = NsharpConstants.OMEGA_Y_END; + + private float xRatio = 1; + + private float yRatio = 1; + + private String sTemperatureC = ""; + + private String sTemperatureF = ""; + + private String sThetaInK = ""; + + private String sWThetaInK = ""; + + private String sEThetaInK = ""; + + private String sMixingRatio = ""; + + private String sPressure = ""; + + private double dPressure; + + private ArrayList windBarbShapeList; + + private IWireframeShape heightMarkRscShape = null; + + private IWireframeShape wetBulbTraceRscShape = null; + + private IWireframeShape vtempTraceCurveRscShape = null; + + private IWireframeShape omegaBkgShape = null; + + private IWireframeShape titleBoxShape = null; + + private IWireframeShape omegaRscShape = null; + + private IShadedShape cloudFMShape = null; + + private IWireframeShape cloudFMLabelShape = null; + + private IShadedShape cloudCEShape = null; + + private IWireframeShape parcelVtTraceRscShape; // Virtual temperature Parcel + // trace + + // Real temperature parcel trace also considering comparison/overlay, + // therefore using a list + private List parcelRtShapeList = new ArrayList(); + + private IWireframeShape dacpeTraceRscShape; + + private List pressureTempRscShapeList = new ArrayList(); + + // ICING wireframe shape + private IWireframeShape icingTempShape = null; + + private IWireframeShape icingRHShape = null; + + private IWireframeShape icingEPIShape = null; + + // Turbulence wireframe shape + private IWireframeShape turbLnShape = null; + + private IWireframeShape turbWindShearShape = null; + + private IWireframeShape lclShape = null; + + private IWireframeShape elShape = null; + + private IWireframeShape lfcShape = null; + + private IWireframeShape fzlShape = null; + + private IWireframeShape effectiveLayerLineShape = null; + + public int TEMP_TYPE = 1; + + public int DEWPOINT_TYPE = 2; + + private int currentTempCurveType; + + private Coordinate interactiveTempPointCoordinate; + + private boolean plotInteractiveTemp = false; + + private boolean cursorInSkewT = false; + + private static int CURSER_FONT_INC_STEP = 3; + + private static int CURSER_FONT_10 = 10; + + private static int CURSER_STRING_OFF = CURSER_FONT_10 + 5 + * CURSER_FONT_INC_STEP; + + private int curseToggledFontLevel = 15;// CURSER_FONT_10; // 0:default + // 1:large + // 2:turn off display + + private String myPerspective = NmapCommon.NatlCntrsPerspectiveID; + + public static ReentrantLock reentryLock = new ReentrantLock(); + + private boolean justMoveToSidePane = false; + + private boolean cursorTopWindBarb = false; + + private boolean windBarbMagnify = false; + + private int currentWindBarbSoundingLayerIndex; + public boolean isWindBarbMagnify() { - return windBarbMagnify; - } + return windBarbMagnify; + } - public void setWindBarbMagnify(boolean windBarbMagnify) { - this.windBarbMagnify = windBarbMagnify; - } + public void setWindBarbMagnify(boolean windBarbMagnify) { + this.windBarbMagnify = windBarbMagnify; + } - public boolean isCursorTopWindBarb() { - return cursorTopWindBarb; - } + public boolean isCursorTopWindBarb() { + return cursorTopWindBarb; + } - public void setCursorTopWindBarb(boolean cursorTopWindBarb) { - this.cursorTopWindBarb = cursorTopWindBarb; - } + public void setCursorTopWindBarb(boolean cursorTopWindBarb) { + this.cursorTopWindBarb = cursorTopWindBarb; + } public boolean isJustMoveToSidePane() { - return justMoveToSidePane; - } + return justMoveToSidePane; + } - public void setJustMoveToSidePane(boolean justMoveToSidePane) { - this.justMoveToSidePane = justMoveToSidePane; - } - private boolean justBackToMainPane = false; - - public boolean isJustBackToMainPane() { - return justBackToMainPane; - } + public void setJustMoveToSidePane(boolean justMoveToSidePane) { + this.justMoveToSidePane = justMoveToSidePane; + } - public void setJustBackToMainPane(boolean justBackToMainPane) { - this.justBackToMainPane = justBackToMainPane; - } - public NsharpSkewTPaneResource(AbstractResourceData resourceData, - LoadProperties loadProperties, NsharpSkewTPaneDescriptor desc) { - super(resourceData, loadProperties, desc); - skewTBackground = new NsharpSkewTPaneBackground((NsharpSkewTPaneDescriptor)descriptor); - icingBackground = new NsharpIcingPaneBackground((NsharpSkewTPaneDescriptor)descriptor); - turbBackground = new NsharpTurbulencePaneBackground((NsharpSkewTPaneDescriptor)descriptor); - //verticalWindBackground = new NsharpSKEWTBackground(descriptor); - this.dataTimes = new ArrayList(); - if( VizPerspectiveListener.getCurrentPerspectiveManager()!= null){ - myPerspective = VizPerspectiveListener.getCurrentPerspectiveManager().getPerspectiveId(); - } + private boolean justBackToMainPane = false; - } + public boolean isJustBackToMainPane() { + return justBackToMainPane; + } - @Override - protected void disposeInternal() { - skewTBackground.disposeInternal(); - icingBackground.disposeInternal(); - turbBackground.disposeInternal(); - skewTBackground = null; - icingBackground = null; - turbBackground = null; - disposeRscWireFrameShapes(); - titleBoxShape.dispose(); - pressureTempRscShapeList=null; - parcelRtShapeList = null; - super.disposeInternal(); - } - private void plotPressureTempEditPoints(IGraphicsTarget target, - WGraphics world, RGB color, int type, List soundingLys) throws VizException { - double maxPressure = NsharpWxMath.reverseSkewTXY(new Coordinate(0, world - .getWorldYmax())).y; - double minPressure = NsharpWxMath.reverseSkewTXY(new Coordinate(0, world - .getWorldYmin())).y; + public void setJustBackToMainPane(boolean justBackToMainPane) { + this.justBackToMainPane = justBackToMainPane; + } + + public NsharpSkewTPaneResource(AbstractResourceData resourceData, + LoadProperties loadProperties, NsharpSkewTPaneDescriptor desc) { + super(resourceData, loadProperties, desc); + skewTBackground = new NsharpSkewTPaneBackground( + (NsharpSkewTPaneDescriptor) descriptor); + icingBackground = new NsharpIcingPaneBackground( + (NsharpSkewTPaneDescriptor) descriptor); + turbBackground = new NsharpTurbulencePaneBackground( + (NsharpSkewTPaneDescriptor) descriptor); + // verticalWindBackground = new NsharpSKEWTBackground(descriptor); + this.dataTimes = new ArrayList(); + if (VizPerspectiveListener.getCurrentPerspectiveManager() != null) { + myPerspective = VizPerspectiveListener + .getCurrentPerspectiveManager().getPerspectiveId(); + } + + } + + @Override + protected void disposeInternal() { + skewTBackground.disposeInternal(); + icingBackground.disposeInternal(); + turbBackground.disposeInternal(); + skewTBackground = null; + icingBackground = null; + turbBackground = null; + disposeRscWireFrameShapes(); + titleBoxShape.dispose(); + pressureTempRscShapeList = null; + parcelRtShapeList = null; + super.disposeInternal(); + } + + private void plotPressureTempEditPoints(IGraphicsTarget target, + WGraphics world, RGB color, int type, + List soundingLys) throws VizException { + double maxPressure = NsharpWxMath.reverseSkewTXY(new Coordinate(0, + world.getWorldYmax())).y; + double minPressure = NsharpWxMath.reverseSkewTXY(new Coordinate(0, + world.getWorldYmin())).y; PointStyle ps = PointStyle.CIRCLE; - for (NcSoundingLayer layer : soundingLys) { - double t; - if(type == TEMP_TYPE) - t = layer.getTemperature(); - else if (type == DEWPOINT_TYPE) - t = layer.getDewpoint(); - else - break; + for (NcSoundingLayer layer : soundingLys) { + double t; + if (type == TEMP_TYPE) + t = layer.getTemperature(); + else if (type == DEWPOINT_TYPE) + t = layer.getDewpoint(); + else + break; double pressure = layer.getPressure(); - if (t != INVALID_DATA && pressure >= minPressure + if (t != INVALID_DATA && pressure >= minPressure && pressure <= maxPressure) { Coordinate c1 = NsharpWxMath.getSkewTXY(pressure, t); - + c1.x = world.mapX(c1.x); c1.y = world.mapY(c1.y); - + target.drawPoint(c1.x, c1.y, 0.0, color, ps); - + } } } + /* - * This function mostly follow display_effective_layer() of xwvid1.c - * - */ - public void createEffectiveLayerLinesShape(){ - if(effectiveLayerLineShape != null){ - effectiveLayerLineShape.dispose(); - effectiveLayerLineShape = null; - } - FloatByReference topPF= new FloatByReference(0); - FloatByReference botPF= new FloatByReference(0); - nsharpNative.nsharpLib.get_effectLayertopBotPres(topPF, botPF); - if(botPF.getValue() < 1 ) return; - effectiveLayerLineShape= target.createWireframeShape(false,descriptor ); - effectiveLayerLineShape.allocate(8); - double dispX0; - double dispX1; - double dispX2; - double dispX3; - IExtent ext = getDescriptor().getRenderableDisplay().getExtent(); - dispX0 = ext.getMinX() + ext.getWidth()/5; - dispX1 = dispX0+ 20 * currentZoomLevel* xRatio; - dispX2 = dispX1+ 20 * currentZoomLevel* xRatio; - dispX3 = dispX2+ 20 * currentZoomLevel* xRatio; - String botStr, topStr; - float aglTop, aglBot; - aglTop = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(topPF.getValue())); - aglBot = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(botPF.getValue())); - // Draw effective sfc level - if (aglBot < 1) - { - botStr = "SFC"; - } - else - { - botStr = String.format( "%.0fm", aglBot); - } - double y = world.mapY(NsharpWxMath.getSkewTXY(botPF.getValue(), 10).y); - double [][] line1 = {{dispX1, y},{dispX3, y}}; - effectiveLayerLineShape.addLineSegment(line1); - double [] lblXy = { dispX3, y}; - effectiveLayerLineShape.addLabel(botStr, lblXy); - - // Draw effective top level - topStr = String.format( "%.0fm", aglTop); - double y1 = world.mapY(NsharpWxMath.getSkewTXY(topPF.getValue(), 10).y); - double [][] line2 = {{dispX1, y1},{dispX3, y1}}; - effectiveLayerLineShape.addLineSegment(line2); - if(aglTop > aglBot){ - double [] lbl1Xy = { dispX3, y1}; - effectiveLayerLineShape.addLabel(topStr, lbl1Xy); - } - - // Draw connecting line - double [][] line3 = {{dispX2, y},{dispX2, y1}}; - effectiveLayerLineShape.addLineSegment(line3); - // Compute and display effective helicity - topPF.setValue(0); // just a placeholder - botPF.setValue(0); - float helicity = nsharpNative.nsharpLib.helicity(aglBot,aglTop, rscHandler.getSmWindDir(),rscHandler.getSmWindSpd(), topPF, botPF); - String helicityStr = String.format("%4.0f m%cs%c", helicity,NsharpConstants.SQUARE_SYMBOL, NsharpConstants.SQUARE_SYMBOL); + * This function mostly follow display_effective_layer() of xwvid1.c + */ + public void createEffectiveLayerLinesShape() { + if (effectiveLayerLineShape != null) { + effectiveLayerLineShape.dispose(); + effectiveLayerLineShape = null; + } + FloatByReference topPF = new FloatByReference(0); + FloatByReference botPF = new FloatByReference(0); + nsharpNative.nsharpLib.get_effectLayertopBotPres(topPF, botPF); + if (botPF.getValue() < 1) + return; + effectiveLayerLineShape = target + .createWireframeShape(false, descriptor); + effectiveLayerLineShape.allocate(8); + double dispX0; + double dispX1; + double dispX2; + double dispX3; + IExtent ext = getDescriptor().getRenderableDisplay().getExtent(); + dispX0 = ext.getMinX() + ext.getWidth() / 5; + dispX1 = dispX0 + 20 * currentZoomLevel * xRatio; + dispX2 = dispX1 + 20 * currentZoomLevel * xRatio; + dispX3 = dispX2 + 20 * currentZoomLevel * xRatio; + String botStr, topStr; + float aglTop, aglBot; + aglTop = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(topPF + .getValue())); + aglBot = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(botPF + .getValue())); + // Draw effective sfc level + if (aglBot < 1) { + botStr = "SFC"; + } else { + botStr = String.format("%.0fm", aglBot); + } + double y = world.mapY(NsharpWxMath.getSkewTXY(botPF.getValue(), 10).y); + double[][] line1 = { { dispX1, y }, { dispX3, y } }; + effectiveLayerLineShape.addLineSegment(line1); + double[] lblXy = { dispX3, y }; + effectiveLayerLineShape.addLabel(botStr, lblXy); + + // Draw effective top level + topStr = String.format("%.0fm", aglTop); + double y1 = world.mapY(NsharpWxMath.getSkewTXY(topPF.getValue(), 10).y); + double[][] line2 = { { dispX1, y1 }, { dispX3, y1 } }; + effectiveLayerLineShape.addLineSegment(line2); + if (aglTop > aglBot) { + double[] lbl1Xy = { dispX3, y1 }; + effectiveLayerLineShape.addLabel(topStr, lbl1Xy); + } + + // Draw connecting line + double[][] line3 = { { dispX2, y }, { dispX2, y1 } }; + effectiveLayerLineShape.addLineSegment(line3); + // Compute and display effective helicity + topPF.setValue(0); // just a placeholder + botPF.setValue(0); + float helicity = nsharpNative.nsharpLib.helicity(aglBot, aglTop, + rscHandler.getSmWindDir(), rscHandler.getSmWindSpd(), topPF, + botPF); + String helicityStr = String.format("%4.0f m%cs%c", helicity, + NsharpConstants.SQUARE_SYMBOL, NsharpConstants.SQUARE_SYMBOL); + + // draw kelicity + double[] lbl2Xy = { dispX0, y1 - 10 * yRatio }; + effectiveLayerLineShape.addLabel(helicityStr, lbl2Xy); + effectiveLayerLineShape.compile(); + } - //draw kelicity - double [] lbl2Xy = { dispX0, y1-10*yRatio}; - effectiveLayerLineShape.addLabel(helicityStr, lbl2Xy); - effectiveLayerLineShape.compile(); - } @SuppressWarnings({ "deprecation", "unused" }) - private void drawEffectiveLayerLines(IGraphicsTarget target) throws VizException{ - - FloatByReference topPF= new FloatByReference(0); - FloatByReference botPF= new FloatByReference(0); - nsharpNative.nsharpLib.get_effectLayertopBotPres(topPF, botPF); - if(botPF.getValue() < 1 ) return; - double dispX0; - double dispX1; - double dispX2; - double dispX3; - IExtent ext = getDescriptor().getRenderableDisplay().getExtent(); - dispX0 = ext.getMinX() + ext.getWidth()/5; - dispX1 = dispX0+ 20 * currentZoomLevel* xRatio; - dispX2 = dispX1+ 20 * currentZoomLevel* xRatio; - dispX3 = dispX2+ 20 * currentZoomLevel* xRatio; - String botStr, topStr; - float aglTop, aglBot; - aglTop = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(topPF.getValue())); - aglBot = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(botPF.getValue())); - // Draw effective sfc level - if (aglBot < 1) - { - botStr = "SFC"; - } - else - { - botStr = String.format( "%.0fm", aglBot); - } - double y = world.mapY(NsharpWxMath.getSkewTXY(botPF.getValue(), 10).y); - target.drawLine( dispX1, y, 0.0, dispX3, y, 0.0, - NsharpConstants.color_cyan_md, 2); - target.drawString(font10,botStr, dispX3, - y, 0.0, TextStyle.NORMAL, - NsharpConstants.color_cyan_md, HorizontalAlignment.LEFT, - VerticalAlignment.MIDDLE, null); - // Draw effective top level - topStr = String.format( "%.0fm", aglTop); - double y1 = world.mapY(NsharpWxMath.getSkewTXY(topPF.getValue(), 10).y); - target.drawLine( dispX1, y1, 0.0, dispX3, y1, 0.0, - NsharpConstants.color_cyan_md, 2); - if(aglTop > aglBot){ - target.drawString(font10,topStr, dispX3, - y1, 0.0, TextStyle.NORMAL, - NsharpConstants.color_cyan_md, HorizontalAlignment.LEFT, - VerticalAlignment.MIDDLE, null); - //System.out.println("aglbot="+aglBot+" agltop="+aglTop); - } - - // Draw connecting line - target.drawLine( dispX2, y, 0.0, dispX2, y1, 0.0, - NsharpConstants.color_cyan_md, 2); - // Compute and display effective helicity - topPF.setValue(0); // just a placeholder - botPF.setValue(0); - float helicity = nsharpNative.nsharpLib.helicity(aglBot,aglTop, rscHandler.getSmWindDir(),rscHandler.getSmWindSpd(), topPF, botPF); - String helicityStr = String.format("%4.0f m%cs%c", helicity,NsharpConstants.SQUARE_SYMBOL, NsharpConstants.SQUARE_SYMBOL); + private void drawEffectiveLayerLines(IGraphicsTarget target) + throws VizException { - //draw kelicity - target.drawString(font10,helicityStr, dispX0, - y1-10*yRatio, 0.0, TextStyle.NORMAL, - NsharpConstants.color_cyan_md, HorizontalAlignment.LEFT, - VerticalAlignment.MIDDLE, null); + FloatByReference topPF = new FloatByReference(0); + FloatByReference botPF = new FloatByReference(0); + nsharpNative.nsharpLib.get_effectLayertopBotPres(topPF, botPF); + if (botPF.getValue() < 1) + return; + double dispX0; + double dispX1; + double dispX2; + double dispX3; + IExtent ext = getDescriptor().getRenderableDisplay().getExtent(); + dispX0 = ext.getMinX() + ext.getWidth() / 5; + dispX1 = dispX0 + 20 * currentZoomLevel * xRatio; + dispX2 = dispX1 + 20 * currentZoomLevel * xRatio; + dispX3 = dispX2 + 20 * currentZoomLevel * xRatio; + String botStr, topStr; + float aglTop, aglBot; + aglTop = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(topPF + .getValue())); + aglBot = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(botPF + .getValue())); + // Draw effective sfc level + if (aglBot < 1) { + botStr = "SFC"; + } else { + botStr = String.format("%.0fm", aglBot); + } + double y = world.mapY(NsharpWxMath.getSkewTXY(botPF.getValue(), 10).y); + target.drawLine(dispX1, y, 0.0, dispX3, y, 0.0, + NsharpConstants.color_cyan_md, 2); + target.drawString(font10, botStr, dispX3, y, 0.0, TextStyle.NORMAL, + NsharpConstants.color_cyan_md, HorizontalAlignment.LEFT, + VerticalAlignment.MIDDLE, null); + // Draw effective top level + topStr = String.format("%.0fm", aglTop); + double y1 = world.mapY(NsharpWxMath.getSkewTXY(topPF.getValue(), 10).y); + target.drawLine(dispX1, y1, 0.0, dispX3, y1, 0.0, + NsharpConstants.color_cyan_md, 2); + if (aglTop > aglBot) { + target.drawString(font10, topStr, dispX3, y1, 0.0, + TextStyle.NORMAL, NsharpConstants.color_cyan_md, + HorizontalAlignment.LEFT, VerticalAlignment.MIDDLE, null); + // System.out.println("aglbot="+aglBot+" agltop="+aglTop); + } + + // Draw connecting line + target.drawLine(dispX2, y, 0.0, dispX2, y1, 0.0, + NsharpConstants.color_cyan_md, 2); + // Compute and display effective helicity + topPF.setValue(0); // just a placeholder + botPF.setValue(0); + float helicity = nsharpNative.nsharpLib.helicity(aglBot, aglTop, + rscHandler.getSmWindDir(), rscHandler.getSmWindSpd(), topPF, + botPF); + String helicityStr = String.format("%4.0f m%cs%c", helicity, + NsharpConstants.SQUARE_SYMBOL, NsharpConstants.SQUARE_SYMBOL); + + // draw kelicity + target.drawString(font10, helicityStr, dispX0, y1 - 10 * yRatio, 0.0, + TextStyle.NORMAL, NsharpConstants.color_cyan_md, + HorizontalAlignment.LEFT, VerticalAlignment.MIDDLE, null); } + @SuppressWarnings("deprecation") - public void createLCLEtcLinesShape(){ - if(target==null) - return; - if(lclShape != null){ - lclShape.dispose(); - lclShape = null; - } - if(elShape != null){ - elShape.dispose(); - elShape = null; - } - if(fzlShape != null){ - fzlShape.dispose(); - fzlShape = null; - } - if(lfcShape != null){ - lfcShape.dispose(); - lfcShape = null; - } - double dispX1; - double dispX2; - IExtent ext = getDescriptor().getRenderableDisplay().getExtent(); - dispX1 = ext.getMaxX() -ext.getWidth()/3; - dispX2 = dispX1+ 40 * currentZoomLevel* xRatio; - nsharpNative.nsharpLib.define_parcel(rscHandler.getCurrentParcel(), rscHandler.getCurrentParcelLayerPressure()); - _lplvalues lpvls = new _lplvalues(); - nsharpNative.nsharpLib.get_lpvaluesData(lpvls); + public void createLCLEtcLinesShape() { + if (target == null) + return; + if (lclShape != null) { + lclShape.dispose(); + lclShape = null; + } + if (elShape != null) { + elShape.dispose(); + elShape = null; + } + if (fzlShape != null) { + fzlShape.dispose(); + fzlShape = null; + } + if (lfcShape != null) { + lfcShape.dispose(); + lfcShape = null; + } + double dispX1; + double dispX2; + IExtent ext = getDescriptor().getRenderableDisplay().getExtent(); + dispX1 = ext.getMaxX() - ext.getWidth() / 3; + dispX2 = dispX1 + 40 * currentZoomLevel * xRatio; + nsharpNative.nsharpLib.define_parcel(rscHandler.getCurrentParcel(), + rscHandler.getCurrentParcelLayerPressure()); + _lplvalues lpvls = new _lplvalues(); + nsharpNative.nsharpLib.get_lpvaluesData(lpvls); + + float sfctemp, sfcdwpt, sfcpres; + sfctemp = lpvls.temp; + sfcdwpt = lpvls.dwpt; + sfcpres = lpvls.pres; + // get parcel data by calling native nsharp parcel() API. value is + // returned in pcl + _parcel pcl = new _parcel(); + nsharpNative.nsharpLib.parcel(-1.0F, -1.0F, sfcpres, sfctemp, sfcdwpt, + pcl); + // draw LCL line + float lcl = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(pcl.lclpres)); + if (lcl != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA) { + lclShape = target.createWireframeShape(false, descriptor); + lclShape.allocate(4); + double pressure = nsharpNative.nsharpLib.ipres(lcl + + (int) (soundingLys.get(0).getGeoHeight())); + // System.out.println("lcl= " + lcl + " lclpres ="+pcl.lclpres + // +" pressure="+ pressure); + double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, 10).y); + double[][] lines = { { dispX1, y }, { dispX2, y } }; + lclShape.addLineSegment(lines); + double[] lblXy = { dispX1, y + 5 * yRatio }; + lclShape.addLabel("LCL", lblXy); + lclShape.compile(); + } + if (pcl.lclpres != pcl.lfcpres) { + float lfc = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(pcl.lfcpres)); + if (lfc != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA) { + lfcShape = target.createWireframeShape(false, descriptor); + lfcShape.allocate(4); + double pressure = nsharpNative.nsharpLib.ipres(lfc + + (int) (soundingLys.get(0).getGeoHeight())); + // System.out.println("lfcpres ="+pcl.lfcpres +" pressure="+ + // pressure); + double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, 10).y); + double[][] lines = { { dispX1, y }, { dispX2, y } }; + lfcShape.addLineSegment(lines); + double[] lblXy = { dispX1, y }; + lfcShape.addLabel("LFC", lblXy); + lfcShape.compile(); + } + } + // draw EL line + if (pcl.lclpres != pcl.elpres && pcl.elpres != pcl.lfcpres) { + float el = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(pcl.elpres)); + if (el != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA) { + elShape = target.createWireframeShape(false, descriptor); + elShape.allocate(4); + double pressure = nsharpNative.nsharpLib.ipres(el + + (int) (soundingLys.get(0).getGeoHeight())); + // System.out.println("elpres ="+pcl.elpres +" pressure="+ + // pressure); + double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, 10).y); + double[][] lines = { { dispX1, y }, { dispX2, y } }; + elShape.addLineSegment(lines); + double[] lblXy = { dispX1, y - 10 * yRatio }; + elShape.addLabel("EL", lblXy); + elShape.compile(); + } + } + // draw FZL line, -20Cline and -30Clinein same shape, fzlShape + FloatByReference fValue = new FloatByReference(0); + float fgzm = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(nsharpNative.nsharpLib.temp_lvl(0, fValue))); + float fgzft = nsharpNative.nsharpLib.mtof(fgzm); + if (nsharpNative.nsharpLib.qc(fgzft) == 1) { + fzlShape = target.createWireframeShape(false, descriptor); + fzlShape.allocate(6); + double pressure = nsharpNative.nsharpLib.ipres(fgzm + + (int) (soundingLys.get(0).getGeoHeight())); + // System.out.println("elpres ="+pcl.elpres +" pressure="+ + // pressure); + double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, 10).y); + String textStr = "FZL= %.0f'"; + textStr = String.format(textStr, fgzft); + double[][] lines = { { dispX1, y }, { dispX2, y } }; + fzlShape.addLineSegment(lines); + double[] lblXy = { dispX1, y - 10 * yRatio }; + fzlShape.addLabel(textStr, lblXy); + + } + // draw -20Cline + float h20m = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(nsharpNative.nsharpLib.temp_lvl(-20, fValue))); + float h20ft = nsharpNative.nsharpLib.mtof(h20m); + if (nsharpNative.nsharpLib.qc(h20ft) == 1) { + if (fzlShape == null) { + fzlShape = target.createWireframeShape(false, descriptor); + fzlShape.allocate(4); + } + double pressure = nsharpNative.nsharpLib.ipres(h20m + + (int) (soundingLys.get(0).getGeoHeight())); + // System.out.println("elpres ="+pcl.elpres +" pressure="+ + // pressure); + double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, -20).y); + // double x = world.mapX(NsharpWxMath.getSkewTXY(pressure, -20).x); + String textStr = "-20C= %.0f'"; + textStr = String.format(textStr, h20ft); + double[][] lines = { { dispX1, y }, { dispX2, y } }; + fzlShape.addLineSegment(lines); + double[] lblXy = { dispX1, y - 10 * yRatio }; + fzlShape.addLabel(textStr, lblXy); + } + // draw -30Cline + float h30m = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(nsharpNative.nsharpLib.temp_lvl(-30, fValue))); + float h30ft = nsharpNative.nsharpLib.mtof(h30m); + if (nsharpNative.nsharpLib.qc(h30ft) == 1) { + if (fzlShape == null) { + fzlShape = target.createWireframeShape(false, descriptor); + fzlShape.allocate(4); + } + double pressure = nsharpNative.nsharpLib.ipres(h30m + + (int) (soundingLys.get(0).getGeoHeight())); + // System.out.println("elpres ="+pcl.elpres +" pressure="+ + // pressure); + double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, 10).y); + String textStr = "-30C= %.0f'"; + textStr = String.format(textStr, h30ft); + double[][] lines = { { dispX1, y }, { dispX2, y } }; + fzlShape.addLineSegment(lines); + double[] lblXy = { dispX1, y - 10 * yRatio }; + fzlShape.addLabel(textStr, lblXy); + } + + if (fzlShape != null) + fzlShape.compile(); - float sfctemp, sfcdwpt, sfcpres; - sfctemp = lpvls.temp; - sfcdwpt = lpvls.dwpt; - sfcpres = lpvls.pres; - // get parcel data by calling native nsharp parcel() API. value is returned in pcl - _parcel pcl = new _parcel(); - nsharpNative.nsharpLib.parcel( -1.0F, -1.0F, sfcpres, sfctemp, sfcdwpt, pcl); - //draw LCL line - float lcl = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(pcl.lclpres )); - if(lcl != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA){ - lclShape= target.createWireframeShape(false,descriptor ); - lclShape.allocate(4); - double pressure = nsharpNative.nsharpLib.ipres(lcl+(int)(soundingLys.get(0).getGeoHeight())); - //System.out.println("lcl= " + lcl + " lclpres ="+pcl.lclpres +" pressure="+ pressure); - double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, 10).y); - double [][] lines = {{dispX1, y},{dispX2, y}}; - lclShape.addLineSegment(lines); - double [] lblXy = { dispX1, y+5*yRatio}; - lclShape.addLabel("LCL", lblXy); - lclShape.compile(); - } - if(pcl.lclpres!=pcl.lfcpres){ - float lfc = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(pcl.lfcpres )); - if(lfc != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA){ - lfcShape= target.createWireframeShape(false,descriptor ); - lfcShape.allocate(4); - double pressure = nsharpNative.nsharpLib.ipres(lfc+(int)(soundingLys.get(0).getGeoHeight())); - //System.out.println("lfcpres ="+pcl.lfcpres +" pressure="+ pressure); - double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, 10).y); - double [][] lines = {{dispX1, y},{dispX2, y}}; - lfcShape.addLineSegment(lines); - double [] lblXy = { dispX1, y}; - lfcShape.addLabel("LFC", lblXy); - lfcShape.compile(); - } - } - // draw EL line - if(pcl.lclpres!=pcl.elpres && pcl.elpres!=pcl.lfcpres){ - float el = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(pcl.elpres )); - if(el != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA){ - elShape= target.createWireframeShape(false,descriptor ); - elShape.allocate(4); - double pressure = nsharpNative.nsharpLib.ipres(el+(int)(soundingLys.get(0).getGeoHeight())); - //System.out.println("elpres ="+pcl.elpres +" pressure="+ pressure); - double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, 10).y); - double [][] lines = {{dispX1, y},{dispX2, y}}; - elShape.addLineSegment(lines); - double [] lblXy = { dispX1, y-10*yRatio}; - elShape.addLabel("EL", lblXy); - elShape.compile(); - } - } - // draw FZL line, -20Cline and -30Clinein same shape, fzlShape - FloatByReference fValue= new FloatByReference(0); - float fgzm = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(nsharpNative.nsharpLib.temp_lvl( 0, fValue ))); - float fgzft = nsharpNative.nsharpLib.mtof(fgzm); - if(nsharpNative.nsharpLib.qc(fgzft)==1) { - fzlShape= target.createWireframeShape(false,descriptor ); - fzlShape.allocate(6); - double pressure = nsharpNative.nsharpLib.ipres(fgzm+(int)(soundingLys.get(0).getGeoHeight())); - //System.out.println("elpres ="+pcl.elpres +" pressure="+ pressure); - double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, 10).y); - String textStr = "FZL= %.0f'"; - textStr = String.format(textStr,fgzft); - double [][] lines = {{dispX1, y},{dispX2, y}}; - fzlShape.addLineSegment(lines); - double [] lblXy = { dispX1, y-10*yRatio}; - fzlShape.addLabel(textStr, lblXy); - - } - // draw -20Cline - float h20m = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(nsharpNative.nsharpLib.temp_lvl( -20, fValue ))); - float h20ft = nsharpNative.nsharpLib.mtof(h20m); - if(nsharpNative.nsharpLib.qc(h20ft)==1) { - if(fzlShape == null){ - fzlShape= target.createWireframeShape(false,descriptor ); - fzlShape.allocate(4); - } - double pressure = nsharpNative.nsharpLib.ipres(h20m+(int)(soundingLys.get(0).getGeoHeight())); - //System.out.println("elpres ="+pcl.elpres +" pressure="+ pressure); - double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, -20).y); - //double x = world.mapX(NsharpWxMath.getSkewTXY(pressure, -20).x); - String textStr = "-20C= %.0f'"; - textStr = String.format(textStr,h20ft); - double [][] lines = {{dispX1, y},{dispX2, y}}; - fzlShape.addLineSegment(lines); - double [] lblXy = { dispX1, y-10*yRatio}; - fzlShape.addLabel(textStr, lblXy); - } - // draw -30Cline - float h30m = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(nsharpNative.nsharpLib.temp_lvl( -30, fValue ))); - float h30ft = nsharpNative.nsharpLib.mtof(h30m); - if(nsharpNative.nsharpLib.qc(h30ft)==1) { - if(fzlShape == null){ - fzlShape= target.createWireframeShape(false,descriptor ); - fzlShape.allocate(4); - } - double pressure = nsharpNative.nsharpLib.ipres(h30m+(int)(soundingLys.get(0).getGeoHeight())); - //System.out.println("elpres ="+pcl.elpres +" pressure="+ pressure); - double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, 10).y); - String textStr = "-30C= %.0f'"; - textStr = String.format(textStr,h30ft); - double [][] lines = {{dispX1, y},{dispX2, y}}; - fzlShape.addLineSegment(lines); - double [] lblXy = { dispX1, y-10*yRatio}; - fzlShape.addLabel(textStr, lblXy); - } - - if(fzlShape != null) - fzlShape.compile(); - } + @SuppressWarnings({ "deprecation", "unused" }) - private void drawLclLine(IGraphicsTarget target) throws VizException{ - //System.out.println("drawLclLine called define_parcel pType="+currentParcel+" pre="+ currentParcelLayerPressure); - double dispX1; - double dispX2; - IExtent ext = getDescriptor().getRenderableDisplay().getExtent(); - dispX1 = ext.getMaxX() -ext.getWidth()/3; - dispX2 = dispX1+ 40 * currentZoomLevel* xRatio; - nsharpNative.nsharpLib.define_parcel(rscHandler.getCurrentParcel(), rscHandler.getCurrentParcelLayerPressure()); - _lplvalues lpvls = new _lplvalues(); - nsharpNative.nsharpLib.get_lpvaluesData(lpvls); + private void drawLclLine(IGraphicsTarget target) throws VizException { + // System.out.println("drawLclLine called define_parcel pType="+currentParcel+" pre="+ + // currentParcelLayerPressure); + double dispX1; + double dispX2; + IExtent ext = getDescriptor().getRenderableDisplay().getExtent(); + dispX1 = ext.getMaxX() - ext.getWidth() / 3; + dispX2 = dispX1 + 40 * currentZoomLevel * xRatio; + nsharpNative.nsharpLib.define_parcel(rscHandler.getCurrentParcel(), + rscHandler.getCurrentParcelLayerPressure()); + _lplvalues lpvls = new _lplvalues(); + nsharpNative.nsharpLib.get_lpvaluesData(lpvls); - float sfctemp, sfcdwpt, sfcpres; - sfctemp = lpvls.temp; - sfcdwpt = lpvls.dwpt; - sfcpres = lpvls.pres; - // get parcel data by calling native nsharp parcel() API. value is returned in pcl - _parcel pcl = new _parcel(); - nsharpNative.nsharpLib.parcel( -1.0F, -1.0F, sfcpres, sfctemp, sfcdwpt, pcl); - //draw LCL line - float lcl = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(pcl.lclpres )); - if(lcl != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA){ - double pressure = nsharpNative.nsharpLib.ipres(lcl+(int)(soundingLys.get(0).getGeoHeight())); - //System.out.println("lcl= " + lcl + " lclpres ="+pcl.lclpres +" pressure="+ pressure); - double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, 10).y); - target.drawLine( dispX1/*world.mapX(NsharpConstants.right)-220 */, y, 0.0,dispX2/* world.mapX(NsharpConstants.right) -180*/, y, 0.0, - NsharpConstants.color_green, 2); - target.drawString(font10, "LCL",dispX1 /*world.mapX(NsharpConstants.right)-220*/, - y+5*yRatio, 0.0, TextStyle.NORMAL, - NsharpConstants.color_green, HorizontalAlignment.LEFT, - VerticalAlignment.MIDDLE, null); - } - //draw LFC line - if(pcl.lclpres!=pcl.lfcpres){ - float lfc = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(pcl.lfcpres )); - if(lfc != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA){ - double pressure = nsharpNative.nsharpLib.ipres(lfc+(int)(soundingLys.get(0).getGeoHeight())); - //System.out.println("lfcpres ="+pcl.lfcpres +" pressure="+ pressure); - double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, 10).y); - target.drawLine( dispX1, y, 0.0, dispX2, y, 0.0, - NsharpConstants.color_yellow, 2); - target.drawString(font10, "LFC", dispX1, - y, 0.0, TextStyle.NORMAL, - NsharpConstants.color_yellow, HorizontalAlignment.RIGHT, - VerticalAlignment.MIDDLE, null); - } - } - // draw EL line - if(pcl.lclpres!=pcl.elpres && pcl.elpres!=pcl.lfcpres){ - float el = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(pcl.elpres )); - if(el != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA){ - double pressure = nsharpNative.nsharpLib.ipres(el+(int)(soundingLys.get(0).getGeoHeight())); - //System.out.println("elpres ="+pcl.elpres +" pressure="+ pressure); - double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, 10).y); - target.drawLine( dispX1, y, 0.0, dispX2, y, 0.0, - NsharpConstants.color_red, 2); - target.drawString(font10, "EL", dispX1, - y-10*yRatio, 0.0, TextStyle.NORMAL, - NsharpConstants.color_red, HorizontalAlignment.LEFT, - VerticalAlignment.MIDDLE, null); - } - } - // draw FGZ line - FloatByReference fValue= new FloatByReference(0); - float fgzm = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(nsharpNative.nsharpLib.temp_lvl( 0, fValue ))); - float fgzft = nsharpNative.nsharpLib.mtof(fgzm); - if(nsharpNative.nsharpLib.qc(fgzft)==1) { - double pressure = nsharpNative.nsharpLib.ipres(fgzm+(int)(soundingLys.get(0).getGeoHeight())); - //System.out.println("elpres ="+pcl.elpres +" pressure="+ pressure); - double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, 10).y); - target.drawLine( dispX1, y, 0.0, dispX2, y, 0.0, - NsharpConstants.color_cyan, 2); - String textStr = "FZL= %.0f'"; - textStr = String.format(textStr,fgzft); - target.drawString(font10, textStr, dispX1, - y-10*yRatio, 0.0, TextStyle.NORMAL, - NsharpConstants.color_cyan, HorizontalAlignment.LEFT, - VerticalAlignment.MIDDLE, null); - } - // draw -20Cline - float h20m = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(nsharpNative.nsharpLib.temp_lvl( -20, fValue ))); - float h20ft = nsharpNative.nsharpLib.mtof(h20m); - if(nsharpNative.nsharpLib.qc(h20ft)==1) { - double pressure = nsharpNative.nsharpLib.ipres(h20m+(int)(soundingLys.get(0).getGeoHeight())); - //System.out.println("elpres ="+pcl.elpres +" pressure="+ pressure); - double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, -20).y); - //double x = world.mapX(NsharpWxMath.getSkewTXY(pressure, -20).x); - target.drawLine( dispX1, y, 0.0, dispX2, y, 0.0, - NsharpConstants.color_cyan, 2); - String textStr = "-20C= %.0f'"; - textStr = String.format(textStr,h20ft); - target.drawString(font10, textStr, dispX1, - y-10*yRatio, 0.0, TextStyle.NORMAL, - NsharpConstants.color_cyan, HorizontalAlignment.LEFT, - VerticalAlignment.MIDDLE, null); - } - // draw -30Cline - float h30m = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght(nsharpNative.nsharpLib.temp_lvl( -30, fValue ))); - float h30ft = nsharpNative.nsharpLib.mtof(h30m); - if(nsharpNative.nsharpLib.qc(h30ft)==1) { - double pressure = nsharpNative.nsharpLib.ipres(h30m+(int)(soundingLys.get(0).getGeoHeight())); - //System.out.println("elpres ="+pcl.elpres +" pressure="+ pressure); - double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, 10).y); - target.drawLine( dispX1, y, 0.0, dispX2, y, 0.0, - NsharpConstants.color_cyan, 2); - String textStr = "-30C= %.0f'"; - textStr = String.format(textStr,h30ft); - target.drawString(font10, textStr, dispX1, - y-10*yRatio, 0.0, TextStyle.NORMAL, - NsharpConstants.color_cyan, HorizontalAlignment.LEFT, - VerticalAlignment.MIDDLE, null); - } + float sfctemp, sfcdwpt, sfcpres; + sfctemp = lpvls.temp; + sfcdwpt = lpvls.dwpt; + sfcpres = lpvls.pres; + // get parcel data by calling native nsharp parcel() API. value is + // returned in pcl + _parcel pcl = new _parcel(); + nsharpNative.nsharpLib.parcel(-1.0F, -1.0F, sfcpres, sfctemp, sfcdwpt, + pcl); + // draw LCL line + float lcl = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(pcl.lclpres)); + if (lcl != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA) { + double pressure = nsharpNative.nsharpLib.ipres(lcl + + (int) (soundingLys.get(0).getGeoHeight())); + // System.out.println("lcl= " + lcl + " lclpres ="+pcl.lclpres + // +" pressure="+ pressure); + double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, 10).y); + target.drawLine(dispX1/* world.mapX(NsharpConstants.right)-220 */, + y, 0.0, dispX2/* world.mapX(NsharpConstants.right) -180 */, + y, 0.0, NsharpConstants.color_green, 2); + target.drawString(font10, "LCL", dispX1 /* + * world.mapX(NsharpConstants + * .right)-220 + */, y + 5 * yRatio, 0.0, + TextStyle.NORMAL, NsharpConstants.color_green, + HorizontalAlignment.LEFT, VerticalAlignment.MIDDLE, null); + } + // draw LFC line + if (pcl.lclpres != pcl.lfcpres) { + float lfc = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(pcl.lfcpres)); + if (lfc != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA) { + double pressure = nsharpNative.nsharpLib.ipres(lfc + + (int) (soundingLys.get(0).getGeoHeight())); + // System.out.println("lfcpres ="+pcl.lfcpres +" pressure="+ + // pressure); + double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, 10).y); + target.drawLine(dispX1, y, 0.0, dispX2, y, 0.0, + NsharpConstants.color_yellow, 2); + target.drawString(font10, "LFC", dispX1, y, 0.0, + TextStyle.NORMAL, NsharpConstants.color_yellow, + HorizontalAlignment.RIGHT, VerticalAlignment.MIDDLE, + null); + } + } + // draw EL line + if (pcl.lclpres != pcl.elpres && pcl.elpres != pcl.lfcpres) { + float el = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(pcl.elpres)); + if (el != NsharpNativeConstants.NSHARP_LEGACY_LIB_INVALID_DATA) { + double pressure = nsharpNative.nsharpLib.ipres(el + + (int) (soundingLys.get(0).getGeoHeight())); + // System.out.println("elpres ="+pcl.elpres +" pressure="+ + // pressure); + double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, 10).y); + target.drawLine(dispX1, y, 0.0, dispX2, y, 0.0, + NsharpConstants.color_red, 2); + target.drawString(font10, "EL", dispX1, y - 10 * yRatio, 0.0, + TextStyle.NORMAL, NsharpConstants.color_red, + HorizontalAlignment.LEFT, VerticalAlignment.MIDDLE, + null); + } + } + // draw FGZ line + FloatByReference fValue = new FloatByReference(0); + float fgzm = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(nsharpNative.nsharpLib.temp_lvl(0, fValue))); + float fgzft = nsharpNative.nsharpLib.mtof(fgzm); + if (nsharpNative.nsharpLib.qc(fgzft) == 1) { + double pressure = nsharpNative.nsharpLib.ipres(fgzm + + (int) (soundingLys.get(0).getGeoHeight())); + // System.out.println("elpres ="+pcl.elpres +" pressure="+ + // pressure); + double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, 10).y); + target.drawLine(dispX1, y, 0.0, dispX2, y, 0.0, + NsharpConstants.color_cyan, 2); + String textStr = "FZL= %.0f'"; + textStr = String.format(textStr, fgzft); + target.drawString(font10, textStr, dispX1, y - 10 * yRatio, 0.0, + TextStyle.NORMAL, NsharpConstants.color_cyan, + HorizontalAlignment.LEFT, VerticalAlignment.MIDDLE, null); + } + // draw -20Cline + float h20m = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(nsharpNative.nsharpLib.temp_lvl(-20, fValue))); + float h20ft = nsharpNative.nsharpLib.mtof(h20m); + if (nsharpNative.nsharpLib.qc(h20ft) == 1) { + double pressure = nsharpNative.nsharpLib.ipres(h20m + + (int) (soundingLys.get(0).getGeoHeight())); + // System.out.println("elpres ="+pcl.elpres +" pressure="+ + // pressure); + double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, -20).y); + // double x = world.mapX(NsharpWxMath.getSkewTXY(pressure, -20).x); + target.drawLine(dispX1, y, 0.0, dispX2, y, 0.0, + NsharpConstants.color_cyan, 2); + String textStr = "-20C= %.0f'"; + textStr = String.format(textStr, h20ft); + target.drawString(font10, textStr, dispX1, y - 10 * yRatio, 0.0, + TextStyle.NORMAL, NsharpConstants.color_cyan, + HorizontalAlignment.LEFT, VerticalAlignment.MIDDLE, null); + } + // draw -30Cline + float h30m = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght(nsharpNative.nsharpLib.temp_lvl(-30, fValue))); + float h30ft = nsharpNative.nsharpLib.mtof(h30m); + if (nsharpNative.nsharpLib.qc(h30ft) == 1) { + double pressure = nsharpNative.nsharpLib.ipres(h30m + + (int) (soundingLys.get(0).getGeoHeight())); + // System.out.println("elpres ="+pcl.elpres +" pressure="+ + // pressure); + double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, 10).y); + target.drawLine(dispX1, y, 0.0, dispX2, y, 0.0, + NsharpConstants.color_cyan, 2); + String textStr = "-30C= %.0f'"; + textStr = String.format(textStr, h30ft); + target.drawString(font10, textStr, dispX1, y - 10 * yRatio, 0.0, + TextStyle.NORMAL, NsharpConstants.color_cyan, + HorizontalAlignment.LEFT, VerticalAlignment.MIDDLE, null); + } } - public float getTempDewPtSmallestGap(){ - float gap= soundingLys.get(0).getTemperature() - soundingLys.get(0).getDewpoint(); - for( NcSoundingLayer layer:soundingLys){ - if(gap > layer.getTemperature() - layer.getDewpoint()) - gap = layer.getTemperature() - layer.getDewpoint(); - } - return gap; + + public float getTempDewPtSmallestGap() { + float gap = soundingLys.get(0).getTemperature() + - soundingLys.get(0).getDewpoint(); + for (NcSoundingLayer layer : soundingLys) { + if (gap > layer.getTemperature() - layer.getDewpoint()) + gap = layer.getTemperature() - layer.getDewpoint(); + } + return gap; } + @SuppressWarnings("deprecation") - private void plotNsharpMovingTempLine(IGraphicsTarget target, - WGraphics world, RGB color) throws VizException{ - float currentLayerTemp, currentLayerDewP; - Coordinate inC = NsharpWxMath.reverseSkewTXY(this.getWorld().unMap(interactiveTempPointCoordinate)); - float inTemp = (float) inC.x; - float smallestGap = getTempDewPtSmallestGap(); - float tempShiftedDist; - currentLayerTemp = soundingLys.get(currentSoundingLayerIndex).getTemperature(); - currentLayerDewP = soundingLys.get(currentSoundingLayerIndex).getDewpoint(); - if(currentTempCurveType == TEMP_TYPE){ - if(inTemp < currentLayerTemp){ - // shift to left, tempShiftedDist should be a negative number - if((currentLayerTemp - inTemp)> smallestGap){ - tempShiftedDist = -smallestGap; - } - else { - tempShiftedDist = inTemp - currentLayerTemp; - } - } - else { - // shift to right, tempShiftedDist should be a positive number - tempShiftedDist = inTemp - currentLayerTemp; - } - } - else { - if(inTemp < currentLayerDewP){ - // shift to left, tempShiftedDist should be a negative number - tempShiftedDist = inTemp - currentLayerDewP; - } - else { - // shift to right, tempShiftedDist should be a positive number - if((inTemp - currentLayerDewP)> smallestGap){ - tempShiftedDist = smallestGap; - } - else { - tempShiftedDist = inTemp - currentLayerDewP; - } - } - } - Coordinate c0 = null; - //draw the line - for (NcSoundingLayer layer : soundingLys) { - double t; - if(currentTempCurveType == TEMP_TYPE) - t = layer.getTemperature(); - else - t = layer.getDewpoint(); - double pressure = layer.getPressure(); - if (t != NsharpNativeConstants.NSHARP_NATIVE_INVALID_DATA ) { - - Coordinate c1 = NsharpWxMath.getSkewTXY(pressure, t+tempShiftedDist); - - c1.x = world.mapX(c1.x); - c1.y = world.mapY(c1.y); - if (c0 != null) { - target.drawLine(c1.x, c1.y, 0.0, c0.x, c0.y, 0.0, color, - commonLinewidth, LineStyle.SOLID); - } - c0 = c1; - } - - } - - } - @SuppressWarnings("deprecation") - private void plotNsharpInteractiveEditingTemp(IGraphicsTarget target, double zoomLevel, + private void plotNsharpMovingTempLine(IGraphicsTarget target, WGraphics world, RGB color) throws VizException { - if(soundingLys.size() < 4) - return; - //double inPressure = soundingLys.get(currentSoundingLayerIndex).getPressure(); - double aboveLayerPressure, belowLayerPressure; - double aboveLayerT=0, aboveLayerD=0, belowLayerT=0, belowLayerD=0; - int aboveLayerIndex, belowLayerIndex; - double plotAboveT, plotBelowT; - if(currentSoundingLayerIndex ==0){ - aboveLayerIndex = currentSoundingLayerIndex; - belowLayerIndex = currentSoundingLayerIndex+1; - } - else if(currentSoundingLayerIndex == soundingLys.size()-1 ){ - belowLayerIndex = currentSoundingLayerIndex; - aboveLayerIndex = currentSoundingLayerIndex-1; - } - else{ - belowLayerIndex = currentSoundingLayerIndex + 1; - aboveLayerIndex = currentSoundingLayerIndex - 1; - } - aboveLayerPressure = soundingLys.get(aboveLayerIndex).getPressure(); - aboveLayerT = soundingLys.get(aboveLayerIndex).getTemperature(); - aboveLayerD = soundingLys.get(aboveLayerIndex).getDewpoint(); - belowLayerPressure = soundingLys.get(belowLayerIndex).getPressure(); - belowLayerT = soundingLys.get(belowLayerIndex).getTemperature(); - belowLayerD = soundingLys.get(belowLayerIndex).getDewpoint(); - - if(currentTempCurveType == TEMP_TYPE){ - plotAboveT = aboveLayerT; - plotBelowT = belowLayerT; + float currentLayerTemp, currentLayerDewP; + Coordinate inC = NsharpWxMath.reverseSkewTXY(this.getWorld().unMap( + interactiveTempPointCoordinate)); + float inTemp = (float) inC.x; + float smallestGap = getTempDewPtSmallestGap(); + float tempShiftedDist; + currentLayerTemp = soundingLys.get(currentSoundingLayerIndex) + .getTemperature(); + currentLayerDewP = soundingLys.get(currentSoundingLayerIndex) + .getDewpoint(); + if (currentTempCurveType == TEMP_TYPE) { + if (inTemp < currentLayerTemp) { + // shift to left, tempShiftedDist should be a negative number + if ((currentLayerTemp - inTemp) > smallestGap) { + tempShiftedDist = -smallestGap; + } else { + tempShiftedDist = inTemp - currentLayerTemp; + } + } else { + // shift to right, tempShiftedDist should be a positive number + tempShiftedDist = inTemp - currentLayerTemp; + } + } else { + if (inTemp < currentLayerDewP) { + // shift to left, tempShiftedDist should be a negative number + tempShiftedDist = inTemp - currentLayerDewP; + } else { + // shift to right, tempShiftedDist should be a positive number + if ((inTemp - currentLayerDewP) > smallestGap) { + tempShiftedDist = smallestGap; + } else { + tempShiftedDist = inTemp - currentLayerDewP; + } + } + } + Coordinate c0 = null; + // draw the line + for (NcSoundingLayer layer : soundingLys) { + double t; + if (currentTempCurveType == TEMP_TYPE) + t = layer.getTemperature(); + else + t = layer.getDewpoint(); + double pressure = layer.getPressure(); + if (t != NsharpNativeConstants.NSHARP_NATIVE_INVALID_DATA) { - } - else{ - plotAboveT = aboveLayerD; - plotBelowT = belowLayerD; + Coordinate c1 = NsharpWxMath.getSkewTXY(pressure, t + + tempShiftedDist); - } - Coordinate c1 = NsharpWxMath.getSkewTXY(aboveLayerPressure, plotAboveT); - c1.x = world.mapX(c1.x); - c1.y = world.mapY(c1.y); - target.drawLine(c1.x, c1.y, 0.0, interactiveTempPointCoordinate.x, interactiveTempPointCoordinate.y, 0.0, color, - commonLinewidth, LineStyle.DASHED); - c1 = NsharpWxMath.getSkewTXY(belowLayerPressure,plotBelowT); - c1.x = world.mapX(c1.x); - c1.y = world.mapY(c1.y); - target.drawLine(c1.x, c1.y, 0.0, interactiveTempPointCoordinate.x, interactiveTempPointCoordinate.y, 0.0, color, - commonLinewidth, LineStyle.DASHED); - //System.out.println("In pressure="+ inPressure+ " above P="+aboveLayerPressure+ " below P="+belowLayerPressure); - } - public static Comparator windSpeedComparator() { + c1.x = world.mapX(c1.x); + c1.y = world.mapY(c1.y); + if (c0 != null) { + target.drawLine(c1.x, c1.y, 0.0, c0.x, c0.y, 0.0, color, + commonLinewidth, LineStyle.SOLID); + } + c0 = c1; + } + + } + + } + + @SuppressWarnings("deprecation") + private void plotNsharpInteractiveEditingTemp(IGraphicsTarget target, + double zoomLevel, WGraphics world, RGB color) throws VizException { + if (soundingLys.size() < 4) + return; + // double inPressure = + // soundingLys.get(currentSoundingLayerIndex).getPressure(); + double aboveLayerPressure, belowLayerPressure; + double aboveLayerT = 0, aboveLayerD = 0, belowLayerT = 0, belowLayerD = 0; + int aboveLayerIndex, belowLayerIndex; + double plotAboveT, plotBelowT; + if (currentSoundingLayerIndex == 0) { + aboveLayerIndex = currentSoundingLayerIndex; + belowLayerIndex = currentSoundingLayerIndex + 1; + } else if (currentSoundingLayerIndex == soundingLys.size() - 1) { + belowLayerIndex = currentSoundingLayerIndex; + aboveLayerIndex = currentSoundingLayerIndex - 1; + } else { + belowLayerIndex = currentSoundingLayerIndex + 1; + aboveLayerIndex = currentSoundingLayerIndex - 1; + } + aboveLayerPressure = soundingLys.get(aboveLayerIndex).getPressure(); + aboveLayerT = soundingLys.get(aboveLayerIndex).getTemperature(); + aboveLayerD = soundingLys.get(aboveLayerIndex).getDewpoint(); + belowLayerPressure = soundingLys.get(belowLayerIndex).getPressure(); + belowLayerT = soundingLys.get(belowLayerIndex).getTemperature(); + belowLayerD = soundingLys.get(belowLayerIndex).getDewpoint(); + + if (currentTempCurveType == TEMP_TYPE) { + plotAboveT = aboveLayerT; + plotBelowT = belowLayerT; + + } else { + plotAboveT = aboveLayerD; + plotBelowT = belowLayerD; + + } + Coordinate c1 = NsharpWxMath.getSkewTXY(aboveLayerPressure, plotAboveT); + c1.x = world.mapX(c1.x); + c1.y = world.mapY(c1.y); + target.drawLine(c1.x, c1.y, 0.0, interactiveTempPointCoordinate.x, + interactiveTempPointCoordinate.y, 0.0, color, commonLinewidth, + LineStyle.DASHED); + c1 = NsharpWxMath.getSkewTXY(belowLayerPressure, plotBelowT); + c1.x = world.mapX(c1.x); + c1.y = world.mapY(c1.y); + target.drawLine(c1.x, c1.y, 0.0, interactiveTempPointCoordinate.x, + interactiveTempPointCoordinate.y, 0.0, color, commonLinewidth, + LineStyle.DASHED); + // System.out.println("In pressure="+ inPressure+ + // " above P="+aboveLayerPressure+ " below P="+belowLayerPressure); + } + + public static Comparator windSpeedComparator() { return new Comparator() { @@ -767,148 +900,169 @@ public class NsharpSkewTPaneResource extends NsharpAbstractPaneResource{ int retValue = 0; if (layerA != layerB) { // reverse sort relative to pressure! - retValue = Double.compare(layerB.getWindSpeed(), layerA.getWindSpeed()); + retValue = Double.compare(layerB.getWindSpeed(), + layerA.getWindSpeed()); } return retValue; } }; } - - enum eleState { - RE_MAX_WIND, PICKED, UNPICKED - }; - class windPickedElement { - NcSoundingLayer layer; - eleState myState; - public windPickedElement(NcSoundingLayer layer, eleState myState) { - super(); - this.layer = layer; - this.myState = myState; - } - - }; - /** + + enum eleState { + RE_MAX_WIND, PICKED, UNPICKED + }; + + class windPickedElement { + NcSoundingLayer layer; + + eleState myState; + + public windPickedElement(NcSoundingLayer layer, eleState myState) { + super(); + this.layer = layer; + this.myState = myState; + } + + }; + + /** * - * Draws Wind barb vs height - * This function followed algorithm in plot_barbs (void) at xwvid1.c - * to choose wind bulbs with minimum distance defined @ graphConfigProperty.getWindBarbDistance() + * Draws Wind barb vs height This function followed algorithm in plot_barbs + * (void) at xwvid1.c to choose wind bulbs with minimum distance defined @ + * graphConfigProperty.getWindBarbDistance() * */ private void drawNsharpWindBarb(IGraphicsTarget target, double zoomLevel, - WGraphics world, RGB iicolor, List sndLys, double xPosition, double botPress)throws VizException { - if(sndLys.size()< 4) - return; - //ArrayList> windList = new ArrayList>(); - List layerStateList = new ArrayList(); + WGraphics world, RGB iicolor, List sndLys, + double xPosition, double botPress) throws VizException { + if (sndLys.size() < 4) + return; + // ArrayList> windList = new + // ArrayList>(); + List layerStateList = new ArrayList(); float lastHeight = -9999; - RGB icolor = iicolor;//graphConfigProperty.getWindBarbColor(); - //#1: find relative max wind layers. I.e. a layer's wind is stronger than immediate above and below layers + RGB icolor = iicolor;// graphConfigProperty.getWindBarbColor(); + // #1: find relative max wind layers. I.e. a layer's wind is stronger + // than immediate above and below layers NcSoundingLayer curLayer, aboveLayer, belowLayer; - for (int i=0; i < sndLys.size(); i++) { - curLayer = sndLys.get(i); - float spd = curLayer.getWindSpeed(); - if(spd <0) - continue; - windPickedElement newEle = new windPickedElement(curLayer, eleState.UNPICKED); - layerStateList.add(newEle); - if ( i==0 || i== sndLys.size()-1) { - continue; - } - aboveLayer = sndLys.get(i+1); - belowLayer = sndLys.get(i-1); - if (spd> aboveLayer.getWindSpeed() && spd > belowLayer.getWindSpeed()){ - newEle.myState = eleState.RE_MAX_WIND; - //System.out.println( "layer#"+ i+ " RE_MAX_WIND =" + spd ); - } + for (int i = 0; i < sndLys.size(); i++) { + curLayer = sndLys.get(i); + float spd = curLayer.getWindSpeed(); + if (spd < 0) + continue; + windPickedElement newEle = new windPickedElement(curLayer, + eleState.UNPICKED); + layerStateList.add(newEle); + if (i == 0 || i == sndLys.size() - 1) { + continue; + } + aboveLayer = sndLys.get(i + 1); + belowLayer = sndLys.get(i - 1); + if (spd > aboveLayer.getWindSpeed() + && spd > belowLayer.getWindSpeed()) { + newEle.myState = eleState.RE_MAX_WIND; + // System.out.println( "layer#"+ i+ " RE_MAX_WIND =" + spd ); + } } - //DR16384 : handle when all winds are not positive case + // DR16384 : handle when all winds are not positive case if (layerStateList.isEmpty()) { return; } - //#2: apply minimum distance rule, i.e no two wind layer closer than the minimum distance, also make sure + // #2: apply minimum distance rule, i.e no two wind layer closer than + // the minimum distance, also make sure // relative max wind layer is picked. lastHeight = -9999; - windPickedElement lastEle=layerStateList.get(0); - for(windPickedElement ele: layerStateList){ - float pressure = ele.layer.getPressure(); - float spd = ele.layer.getWindSpeed(); - if ( pressure < botPress || spd < 0 ) { + windPickedElement lastEle = layerStateList.get(0); + for (windPickedElement ele : layerStateList) { + float pressure = ele.layer.getPressure(); + float spd = ele.layer.getWindSpeed(); + if (pressure < botPress || spd < 0) { continue; - } - if ((ele.layer.getGeoHeight() - lastHeight) < graphConfigProperty.getWindBarbDistance() *zoomLevel ){ - if(ele.myState.equals(eleState.RE_MAX_WIND) && spd > lastEle.layer.getWindSpeed()){ - //swapped last picked layer with this relative max wind layer - lastEle.myState = eleState.UNPICKED; - lastHeight = ele.layer.getGeoHeight(); - lastEle = ele; - continue; + } + if ((ele.layer.getGeoHeight() - lastHeight) < graphConfigProperty + .getWindBarbDistance() * zoomLevel) { + if (ele.myState.equals(eleState.RE_MAX_WIND) + && spd > lastEle.layer.getWindSpeed()) { + // swapped last picked layer with this relative max wind + // layer + lastEle.myState = eleState.UNPICKED; + lastHeight = ele.layer.getGeoHeight(); + lastEle = ele; + continue; + } else { + ele.myState = eleState.UNPICKED; + continue; } - else{ - ele.myState = eleState.UNPICKED; - continue; - } + } else { + if (ele.myState.equals(eleState.UNPICKED)) + ele.myState = eleState.PICKED; + lastHeight = ele.layer.getGeoHeight(); + lastEle = ele; } - else{ - if(ele.myState.equals(eleState.UNPICKED)) - ele.myState = eleState.PICKED; - lastHeight = ele.layer.getGeoHeight(); - lastEle = ele; - } - + } - double windX = xPosition; - double windY=0; - //plot wind barbs + double windX = xPosition; + double windY = 0; + // plot wind barbs Color[] colors = new Color[1]; Color color = new Color(icolor.red, icolor.green, icolor.blue); - colors[0]= color; - //DisplayElementFactory df = new DisplayElementFactory (target, this.descriptor); - NsharpDisplayElementFactory df = new NsharpDisplayElementFactory (target, this.descriptor); - ArrayList elements = new ArrayList (); + colors[0] = color; + // DisplayElementFactory df = new DisplayElementFactory (target, + // this.descriptor); + NsharpDisplayElementFactory df = new NsharpDisplayElementFactory( + target, this.descriptor); + ArrayList elements = new ArrayList(); float wbSize = graphConfigProperty.getWindBarbSize(); float wbWidth = graphConfigProperty.getWindBarbLineWidth(); - for(windPickedElement ele: layerStateList){ - NcSoundingLayer layer = ele.layer; + for (windPickedElement ele : layerStateList) { + NcSoundingLayer layer = ele.layer; float pressure = layer.getPressure(); - if(pressure < 100) - continue; + if (pressure < 100) + continue; float spd = layer.getWindSpeed(); float dir = layer.getWindDirection(); - if(currentGraphMode== NsharpConstants.GRAPH_SKEWT){ - windY = NsharpWxMath.getSkewTXY(pressure, 0).y; - } - else if(currentGraphMode== NsharpConstants.GRAPH_ICING ){ - //Chin:Y axis (pressure) is scaled using log scale and increaing downward - //WorldYmin= at pressure 1000,its value actually is 1000 (max), wolrdYmax = at pressure 300, its value is 825 (min) - windY = world.getWorldYmax() + (world.getWorldYmin()-icingBackground.toLogScale(pressure)); - }else if( currentGraphMode== NsharpConstants.GRAPH_TURB){ - //Chin:Y axis (pressure) is scaled using log scale and increaing downward - //WorldYmin= at pressure 1000,its value actually is 1000 (max), wolrdYmax = at pressure 300, its value is 825 (min) - windY = world.getWorldYmax() + (world.getWorldYmin()-turbBackground.toLogScale(pressure)); - } - else - continue; - + if (currentGraphMode == NsharpConstants.GRAPH_SKEWT) { + windY = NsharpWxMath.getSkewTXY(pressure, 0).y; + } else if (currentGraphMode == NsharpConstants.GRAPH_ICING) { + // Chin:Y axis (pressure) is scaled using log scale and + // increaing downward + // WorldYmin= at pressure 1000,its value actually is 1000 (max), + // wolrdYmax = at pressure 300, its value is 825 (min) + windY = world.getWorldYmax() + + (world.getWorldYmin() - icingBackground + .toLogScale(pressure)); + } else if (currentGraphMode == NsharpConstants.GRAPH_TURB) { + // Chin:Y axis (pressure) is scaled using log scale and + // increaing downward + // WorldYmin= at pressure 1000,its value actually is 1000 (max), + // wolrdYmax = at pressure 300, its value is 825 (min) + windY = world.getWorldYmax() + + (world.getWorldYmin() - turbBackground + .toLogScale(pressure)); + } else + continue; + float curWbSize = wbSize; float curWbWidth = wbWidth; - if(ele.myState.equals(eleState.UNPICKED)){ - if(graphConfigProperty.isShowFilteredWindInCircle()){ - //Chin::if we want pgen to draw un-picked wind as a circle, then set this. - spd=0.1f; - curWbSize = 1; - } - else - continue; - } - /* TBDWB - else if(windBarbMagnify==true && cursorTopWindBarb == true && currentWindBarbSoundingLayerIndex == this.soundingLys.indexOf(layer)){ - curWbSize = wbSize*2; - curWbWidth = wbWidth*2; - }*/ - //use PGEN tool - Vector vect= new Vector(); + if (ele.myState.equals(eleState.UNPICKED)) { + if (graphConfigProperty.isShowFilteredWindInCircle()) { + // Chin::if we want pgen to draw un-picked wind as a circle, + // then set this. + spd = 0.1f; + curWbSize = 1; + } else + continue; + } + /* + * TBDWB else if(windBarbMagnify==true && cursorTopWindBarb == true + * && currentWindBarbSoundingLayerIndex == + * this.soundingLys.indexOf(layer)){ curWbSize = wbSize*2; + * curWbWidth = wbWidth*2; } + */ + // use PGEN tool + Vector vect = new Vector(); vect.setVectorType(VectorType.WIND_BARB); vect.setArrowHeadSize(1.0); vect.setDirection(dir); @@ -917,2294 +1071,2906 @@ public class NsharpSkewTPaneResource extends NsharpAbstractPaneResource{ vect.setLineWidth(curWbWidth); vect.setClear(true); vect.setColors(colors); - Coordinate location = new Coordinate(world.mapX(windX), world.mapY(windY)); + Coordinate location = new Coordinate(world.mapX(windX), + world.mapY(windY)); vect.setLocation(location); - ArrayList subelements = df.createDisplayElements(vect,paintProps); + ArrayList subelements = df.createDisplayElements( + vect, paintProps); elements.addAll(subelements); } - for (IDisplayable each : elements) - { - try { - each.draw(target, paintProps); - each.dispose(); - } - catch (Exception e) { - e.printStackTrace(); - //System.out.println("paintInternal caught draw exception!"); - } - } + for (IDisplayable each : elements) { + try { + each.draw(target, paintProps); + each.dispose(); + } catch (Exception e) { + e.printStackTrace(); + // System.out.println("paintInternal caught draw exception!"); + } + } } - + /** * - * create Wind barb wire frame shape vs height - * This function followed algorithm in plot_barbs (void) at xwvid1.c - * to choose wind bulb for drawing around every 400m + * create Wind barb wire frame shape vs height This function followed + * algorithm in plot_barbs (void) at xwvid1.c to choose wind bulb for + * drawing around every 400m * */ - private void createWindBarbWFShape(IGraphicsTarget target, - WGraphics world, List sndLys, double xPosition, double botPress)throws VizException { - if(sndLys.size()< 4) - return; - List layerStateList = new ArrayList(); + private void createWindBarbWFShape(IGraphicsTarget target, WGraphics world, + List sndLys, double xPosition, double botPress) + throws VizException { + if (sndLys.size() < 4) + return; + List layerStateList = new ArrayList(); float lastHeight = -9999; RGB icolor = graphConfigProperty.getWindBarbColor(); float barbLineWidth = graphConfigProperty.getWindBarbLineWidth(); float barbSize = graphConfigProperty.getWindBarbSize(); - //#1: find relative max wind layers. I.e. a layer's wind is stronger than immediate above and below layers + // #1: find relative max wind layers. I.e. a layer's wind is stronger + // than immediate above and below layers NcSoundingLayer curLayer, aboveLayer, belowLayer; - for (int i=0; i < sndLys.size(); i++) { - curLayer = sndLys.get(i); - float spd = curLayer.getWindSpeed(); - if(spd <0) - continue; - windPickedElement newEle = new windPickedElement(curLayer, eleState.UNPICKED); - layerStateList.add(newEle); - if ( i==0 || i== sndLys.size()-1) { - continue; - } - aboveLayer = sndLys.get(i+1); - belowLayer = sndLys.get(i-1); - if (spd> aboveLayer.getWindSpeed() && spd > belowLayer.getWindSpeed()){ - newEle.myState = eleState.RE_MAX_WIND; - //System.out.println( "layer#"+ i+ " RE_MAX_WIND =" + spd ); - } + for (int i = 0; i < sndLys.size(); i++) { + curLayer = sndLys.get(i); + float spd = curLayer.getWindSpeed(); + if (spd < 0) + continue; + windPickedElement newEle = new windPickedElement(curLayer, + eleState.UNPICKED); + layerStateList.add(newEle); + if (i == 0 || i == sndLys.size() - 1) { + continue; + } + aboveLayer = sndLys.get(i + 1); + belowLayer = sndLys.get(i - 1); + if (spd > aboveLayer.getWindSpeed() + && spd > belowLayer.getWindSpeed()) { + newEle.myState = eleState.RE_MAX_WIND; + // System.out.println( "layer#"+ i+ " RE_MAX_WIND =" + spd ); + } } - //#2: apply minimum distance rule, i.e no two wind layer closer than the minimum distance, also make sure + // #2: apply minimum distance rule, i.e no two wind layer closer than + // the minimum distance, also make sure // relative max wind layer is picked. lastHeight = -9999; - windPickedElement lastEle=layerStateList.get(0); - for(windPickedElement ele: layerStateList){ - float pressure = ele.layer.getPressure(); - float spd = ele.layer.getWindSpeed(); - if ( pressure < botPress || spd < 0 ) { + windPickedElement lastEle = layerStateList.get(0); + for (windPickedElement ele : layerStateList) { + float pressure = ele.layer.getPressure(); + float spd = ele.layer.getWindSpeed(); + if (pressure < botPress || spd < 0) { continue; - } - if ((ele.layer.getGeoHeight() - lastHeight) < graphConfigProperty.getWindBarbDistance()){// *zoomLevel ){ - if(ele.myState.equals(eleState.RE_MAX_WIND) && spd > lastEle.layer.getWindSpeed()){ - //swapped last picked layer with this relative max wind layer - lastEle.myState = eleState.UNPICKED; - lastHeight = ele.layer.getGeoHeight(); - lastEle = ele; - continue; - } - else{ - ele.myState = eleState.UNPICKED; - continue; - } } - else{ - if(ele.myState.equals(eleState.UNPICKED)) - ele.myState = eleState.PICKED; - lastHeight = ele.layer.getGeoHeight(); - lastEle = ele; + if ((ele.layer.getGeoHeight() - lastHeight) < graphConfigProperty + .getWindBarbDistance()) {// *zoomLevel ){ + if (ele.myState.equals(eleState.RE_MAX_WIND) + && spd > lastEle.layer.getWindSpeed()) { + // swapped last picked layer with this relative max wind + // layer + lastEle.myState = eleState.UNPICKED; + lastHeight = ele.layer.getGeoHeight(); + lastEle = ele; + continue; + } else { + ele.myState = eleState.UNPICKED; + continue; + } + } else { + if (ele.myState.equals(eleState.UNPICKED)) + ele.myState = eleState.PICKED; + lastHeight = ele.layer.getGeoHeight(); + lastEle = ele; } } - double windX = xPosition; - double windY=0; + double windX = xPosition; + double windY = 0; List locations = new ArrayList(); - //System.out.println("zoom="+zoomLevel +"world viewYmin="+world.getViewYmin()+" viewYmax="+world.getViewYmax()+" wolrdYmin="+ world.getWorldYmin()+" wolrdYmax="+ world.getWorldYmax() - // +"world viewXmin="+world.getViewXmin()+" viewXmax="+world.getViewXmax()+" wolrdXmin="+ world.getWorldXmin()+" wolrdXmax="+ world.getWorldXmax()); - //plot wind barbs + // System.out.println("zoom="+zoomLevel + // +"world viewYmin="+world.getViewYmin()+" viewYmax="+world.getViewYmax()+" wolrdYmin="+ + // world.getWorldYmin()+" wolrdYmax="+ world.getWorldYmax() + // +"world viewXmin="+world.getViewXmin()+" viewXmax="+world.getViewXmax()+" wolrdXmin="+ + // world.getWorldXmin()+" wolrdXmax="+ world.getWorldXmax()); + // plot wind barbs List windVectList = new ArrayList(); Color[] colors = new Color[1]; Color color = new Color(icolor.red, icolor.green, icolor.blue); - colors[0]= color; - DisplayElementFactory df = new DisplayElementFactory (target, this.descriptor); - for(windPickedElement ele: layerStateList){ - - NcSoundingLayer layer = ele.layer; + colors[0] = color; + DisplayElementFactory df = new DisplayElementFactory(target, + this.descriptor); + for (windPickedElement ele : layerStateList) { + + NcSoundingLayer layer = ele.layer; float pressure = layer.getPressure(); float spd = layer.getWindSpeed(); float dir = layer.getWindDirection(); // Get the vertical ordinate. - if(currentGraphMode== NsharpConstants.GRAPH_SKEWT){ - windY = NsharpWxMath.getSkewTXY(pressure, 0).y; + if (currentGraphMode == NsharpConstants.GRAPH_SKEWT) { + windY = NsharpWxMath.getSkewTXY(pressure, 0).y; + } else if (currentGraphMode == NsharpConstants.GRAPH_ICING) { + // Chin:Y axis (pressure) is scaled using log scale and + // increaing downward + // WorldYmin= at pressure 1000,its value actually is 1000 (max), + // wolrdYmax = at pressure 300, its value is 825 (min) + windY = world.getWorldYmax() + + (world.getWorldYmin() - icingBackground + .toLogScale(pressure)); + } else if (currentGraphMode == NsharpConstants.GRAPH_TURB) { + // Chin:Y axis (pressure) is scaled using log scale and + // increaing downward + // WorldYmin= at pressure 1000,its value actually is 1000 (max), + // wolrdYmax = at pressure 300, its value is 825 (min) + windY = world.getWorldYmax() + + (world.getWorldYmin() - turbBackground + .toLogScale(pressure)); + } else + continue; + + if (ele.myState.equals(eleState.UNPICKED)) { + double[] loc = { world.mapX(windX), world.mapY(windY) }; + locations.add(loc); + // continue; if dont want to draw un-picked wind, then should + // drop it here. + // to plot un-picked wind with a small circle? change wind speed + // to smaller than 0.5, then PGEN tool + // will take care of it. + spd = 0.1f; } - else if(currentGraphMode== NsharpConstants.GRAPH_ICING ){ - //Chin:Y axis (pressure) is scaled using log scale and increaing downward - //WorldYmin= at pressure 1000,its value actually is 1000 (max), wolrdYmax = at pressure 300, its value is 825 (min) - windY = world.getWorldYmax() + (world.getWorldYmin()-icingBackground.toLogScale(pressure)); - }else if( currentGraphMode== NsharpConstants.GRAPH_TURB){ - //Chin:Y axis (pressure) is scaled using log scale and increaing downward - //WorldYmin= at pressure 1000,its value actually is 1000 (max), wolrdYmax = at pressure 300, its value is 825 (min) - windY = world.getWorldYmax() + (world.getWorldYmin()-turbBackground.toLogScale(pressure)); - } - else - continue; - - if(ele.myState.equals(eleState.UNPICKED)){ - double[] loc= {world.mapX(windX), world.mapY(windY)}; - locations.add(loc); - //continue; if dont want to draw un-picked wind, then should drop it here. - //to plot un-picked wind with a small circle? change wind speed to smaller than 0.5, then PGEN tool - // will take care of it. - spd=0.1f; - } - //use PGEN tool - Vector vect= new Vector(); + // use PGEN tool + Vector vect = new Vector(); vect.setVectorType(VectorType.WIND_BARB); vect.setArrowHeadSize(1.0); - dir= (dir+180.0f)%360.0f; //change direction 180 degree for Nsharp drawing style + dir = (dir + 180.0f) % 360.0f; // change direction 180 degree for + // Nsharp drawing style vect.setDirection(dir); vect.setSpeed(spd); vect.setSizeScale(barbSize); vect.setLineWidth(barbLineWidth); - vect.setClear(true); + vect.setClear(true); vect.setColors(colors); - Coordinate location = new Coordinate(world.mapX(windX-2), world.mapY(windY)); + Coordinate location = new Coordinate(world.mapX(windX - 2), + world.mapY(windY)); vect.setLocation(location); - ArrayList newlst= df.createDisplayElements(vect,paintProps); + ArrayList newlst = df.createDisplayElements(vect, + paintProps); windBarbShapeList.addAll(newlst); } - + } + @SuppressWarnings("deprecation") - private void drawNsharpSkewtCursorData(IGraphicsTarget target) throws VizException{ - IFont myFont; - myFont = target.initializeFont("Monospace", curseToggledFontLevel, null); - myFont.setSmoothing(false); - myFont.setScaleFont(false); - - Coordinate c = NsharpWxMath.reverseSkewTXY(world.unMap(cursorCor.x, cursorCor.y)); - //System.out.println("Cusrso.x="+cursorCor.x+" Cusrso.y="+cursorCor.y); - //System.out.println("Skewt.x="+c.x+" Skewt.y="+c.y); - double p_mb = c.y; - double temp = c.x; - float htFt, htM, relh=-1; - String curStrFormat, curStrFormat1; - String curStr, curStr1;//, curStr2,curStr3; - VerticalAlignment vAli; - HorizontalAlignment hAli; - - //curStr3 = rscHandler.getPickedStnInfoStr()+"\n"; + private void drawNsharpSkewtCursorData(IGraphicsTarget target) + throws VizException { + IFont myFont; + myFont = target + .initializeFont("Monospace", curseToggledFontLevel, null); + myFont.setSmoothing(false); + myFont.setScaleFont(false); - htM = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib.ihght((float)p_mb)); - htFt= nsharpNative.nsharpLib.mtof(htM); - if (nsharpNative.nsharpLib.itemp((float)p_mb) > -9998.0 && nsharpNative.nsharpLib.idwpt((float)p_mb) > -9998.0){ - FloatByReference parm= new FloatByReference(0); - relh= nsharpNative.nsharpLib.relh((float)p_mb, parm); - curStrFormat= "%4.0f/%.0fkt %4.0fmb %5.0fft/%.0fm agl %2.0f%%\n"; - curStr = String.format(curStrFormat, nsharpNative.nsharpLib.iwdir((float)p_mb), - nsharpNative.nsharpLib.iwspd((float)p_mb), p_mb,htFt,htM,relh); - } - else{ - curStrFormat= "%4.0f/%.0fkt %4.0fmb %5.0fft/%.0fm agl\n"; - curStr = String.format(curStrFormat, nsharpNative.nsharpLib.iwdir((float)p_mb), - nsharpNative.nsharpLib.iwspd((float)p_mb),p_mb,htFt,htM); - } - /*curStrFormat1 = "%s/%s %4.1f/%4.1f%cC %4.0f/%.0f kt\n"; - curStr1 = String.format(curStrFormat1,sTemperatureC,sTemperatureF, nsharpNative.nsharpLib.itemp((float)p_mb), - nsharpNative.nsharpLib.idwpt((float)p_mb),NsharpConstants.DEGREE_SYMBOL, nsharpNative.nsharpLib.iwdir((float)p_mb), - nsharpNative.nsharpLib.iwspd((float)p_mb));*/ - - curStrFormat1 = "%s(%s) %4.1f/%4.1f%cF(%4.1f/%4.1f%cC)\n"; - temp = nsharpNative.nsharpLib.itemp((float)p_mb); - UnitConverter celciusToFahrenheit = SI.CELSIUS.getConverterTo(NonSI.FAHRENHEIT); - double tempF= celciusToFahrenheit.convert(temp); - double dp = nsharpNative.nsharpLib.idwpt((float)p_mb); - double dpF= celciusToFahrenheit.convert(dp); - curStr1 = String.format(curStrFormat1,sTemperatureF,sTemperatureC, tempF,dpF, NsharpConstants.DEGREE_SYMBOL,temp, - dp,NsharpConstants.DEGREE_SYMBOL); + Coordinate c = NsharpWxMath.reverseSkewTXY(world.unMap(cursorCor.x, + cursorCor.y)); + // System.out.println("Cusrso.x="+cursorCor.x+" Cusrso.y="+cursorCor.y); + // System.out.println("Skewt.x="+c.x+" Skewt.y="+c.y); + double p_mb = c.y; + double temp = c.x; + float htFt, htM, relh = -1; + String curStrFormat, curStrFormat1; + String curStr, curStr1;// , curStr2,curStr3; + VerticalAlignment vAli; + HorizontalAlignment hAli; - //String tempS= String.format("%5.1f%cC ",temp,NsharpConstants.DEGREE_SYMBOL); - //curStr2 =sThetaInK+" "+sWThetaInK+" "+sEThetaInK+"\n"; + // curStr3 = rscHandler.getPickedStnInfoStr()+"\n"; - //Adjust string plotting position - if(cursorCor.x < skewtXOrig + (200/currentZoomLevel)*xRatio){ - hAli = HorizontalAlignment.LEFT; - } - else { - hAli = HorizontalAlignment.RIGHT; - } - if(cursorCor.y > skewtYOrig + (50/currentZoomLevel)*yRatio){ - vAli = VerticalAlignment.BOTTOM; - } - else { - vAli = VerticalAlignment.TOP; - } - //vAli = VerticalAlignment.BOTTOM; - target.drawString(myFont,curStr+curStr1/*+curStr2+curStr3*/, cursorCor.x, - cursorCor.y, 0.0, TextStyle.NORMAL, - NsharpConstants.color_yellow, hAli, - vAli, null); - myFont.dispose(); + htM = nsharpNative.nsharpLib.agl(nsharpNative.nsharpLib + .ihght((float) p_mb)); + htFt = nsharpNative.nsharpLib.mtof(htM); + if (nsharpNative.nsharpLib.itemp((float) p_mb) > -9998.0 + && nsharpNative.nsharpLib.idwpt((float) p_mb) > -9998.0) { + FloatByReference parm = new FloatByReference(0); + relh = nsharpNative.nsharpLib.relh((float) p_mb, parm); + curStrFormat = "%4.0f/%.0fkt %4.0fmb %5.0fft/%.0fm agl %2.0f%%\n"; + curStr = String.format(curStrFormat, + nsharpNative.nsharpLib.iwdir((float) p_mb), + nsharpNative.nsharpLib.iwspd((float) p_mb), p_mb, htFt, + htM, relh); + } else { + curStrFormat = "%4.0f/%.0fkt %4.0fmb %5.0fft/%.0fm agl\n"; + curStr = String + .format(curStrFormat, + nsharpNative.nsharpLib.iwdir((float) p_mb), + nsharpNative.nsharpLib.iwspd((float) p_mb), p_mb, + htFt, htM); + } + /* + * curStrFormat1 = "%s/%s %4.1f/%4.1f%cC %4.0f/%.0f kt\n"; curStr1 = + * String.format(curStrFormat1,sTemperatureC,sTemperatureF, + * nsharpNative.nsharpLib.itemp((float)p_mb), + * nsharpNative.nsharpLib.idwpt + * ((float)p_mb),NsharpConstants.DEGREE_SYMBOL, + * nsharpNative.nsharpLib.iwdir((float)p_mb), + * nsharpNative.nsharpLib.iwspd((float)p_mb)); + */ + + curStrFormat1 = "%s(%s) %4.1f/%4.1f%cF(%4.1f/%4.1f%cC)\n"; + temp = nsharpNative.nsharpLib.itemp((float) p_mb); + UnitConverter celciusToFahrenheit = SI.CELSIUS + .getConverterTo(NonSI.FAHRENHEIT); + double tempF = celciusToFahrenheit.convert(temp); + double dp = nsharpNative.nsharpLib.idwpt((float) p_mb); + double dpF = celciusToFahrenheit.convert(dp); + curStr1 = String.format(curStrFormat1, sTemperatureF, sTemperatureC, + tempF, dpF, NsharpConstants.DEGREE_SYMBOL, temp, dp, + NsharpConstants.DEGREE_SYMBOL); + + // String tempS= + // String.format("%5.1f%cC ",temp,NsharpConstants.DEGREE_SYMBOL); + // curStr2 =sThetaInK+" "+sWThetaInK+" "+sEThetaInK+"\n"; + + // Adjust string plotting position + if (cursorCor.x < skewtXOrig + (200 / currentZoomLevel) * xRatio) { + hAli = HorizontalAlignment.LEFT; + } else { + hAli = HorizontalAlignment.RIGHT; + } + if (cursorCor.y > skewtYOrig + (50 / currentZoomLevel) * yRatio) { + vAli = VerticalAlignment.BOTTOM; + } else { + vAli = VerticalAlignment.TOP; + } + // vAli = VerticalAlignment.BOTTOM; + target.drawString(myFont, curStr + curStr1/* +curStr2+curStr3 */, + cursorCor.x, cursorCor.y, 0.0, TextStyle.NORMAL, + NsharpConstants.color_yellow, hAli, vAli, null); + myFont.dispose(); } @SuppressWarnings({ "deprecation", "unused" }) - private void drawNsharpSkewtDynamicData(IGraphicsTarget target, double zoomLevel, - WGraphics world) throws VizException { - double dispX; - double dispY; - IExtent ext = getDescriptor().getRenderableDisplay().getExtent(); - dispX = ext.getMinX() + 20 * zoomLevel* xRatio; - dispY = ext.getMinY() + 60 * zoomLevel* yRatio; - //Column 1: pressure, C and F - target.drawString(font10, sPressure, dispX, dispY, 0.0, - TextStyle.NORMAL, NsharpConstants.color_white, HorizontalAlignment.LEFT, + private void drawNsharpSkewtDynamicData(IGraphicsTarget target, + double zoomLevel, WGraphics world) throws VizException { + double dispX; + double dispY; + IExtent ext = getDescriptor().getRenderableDisplay().getExtent(); + dispX = ext.getMinX() + 20 * zoomLevel * xRatio; + dispY = ext.getMinY() + 60 * zoomLevel * yRatio; + // Column 1: pressure, C and F + target.drawString(font10, sPressure, dispX, dispY, 0.0, + TextStyle.NORMAL, NsharpConstants.color_white, + HorizontalAlignment.LEFT, VerticalAlignment.BOTTOM, null); + + target.drawString(font10, sTemperatureC, dispX, dispY + 15 * zoomLevel + * yRatio, 0.0, TextStyle.NORMAL, NsharpConstants.color_red, + HorizontalAlignment.LEFT, VerticalAlignment.BOTTOM, null); + target.drawString(font10, sTemperatureF, dispX, dispY + 30 * zoomLevel + * yRatio, 0.0, TextStyle.NORMAL, NsharpConstants.color_red, + HorizontalAlignment.LEFT, VerticalAlignment.BOTTOM, null); + // column 2: m, ft, mixing ratio + float heightM = nsharpNative.nsharpLib.ihght((float) dPressure); + String sHeightM = String.format("%.0fm", heightM); + target.drawString(font10, sHeightM, dispX + 40 * zoomLevel * xRatio, + dispY, 0.0, TextStyle.NORMAL, NsharpConstants.color_cyan, + HorizontalAlignment.LEFT, VerticalAlignment.BOTTOM, null); + String sHeightFt = String.format("%.0fft", + NsharpConstants.metersToFeet.convert(heightM)); + target.drawString(font10, sHeightFt, dispX + 40 * zoomLevel * xRatio, + dispY + 15 * zoomLevel * yRatio, 0.0, TextStyle.NORMAL, + NsharpConstants.color_cyan, HorizontalAlignment.LEFT, + VerticalAlignment.BOTTOM, null); + target.drawString(font10, sMixingRatio, + dispX + 40 * zoomLevel * xRatio, dispY + 30 * zoomLevel + * yRatio, 0.0, TextStyle.NORMAL, + NsharpConstants.color_green, HorizontalAlignment.LEFT, + VerticalAlignment.BOTTOM, null); + // column 3: Theta, ThetaW, ThetaE + target.drawString(font10, sThetaInK, dispX + 80 * zoomLevel * xRatio, + dispY, 0.0, TextStyle.NORMAL, NsharpConstants.color_yellow, + HorizontalAlignment.LEFT, VerticalAlignment.BOTTOM, null); + target.drawString(font10, sWThetaInK, dispX + 80 * zoomLevel * xRatio, + dispY + 15 * zoomLevel * yRatio, 0.0, TextStyle.NORMAL, + NsharpConstants.color_yellow, HorizontalAlignment.LEFT, + VerticalAlignment.BOTTOM, null); + target.drawString(font10, sEThetaInK, dispX + 80 * zoomLevel * xRatio, + dispY + 30 * zoomLevel * yRatio, 0.0, TextStyle.NORMAL, + NsharpConstants.color_yellow, HorizontalAlignment.LEFT, VerticalAlignment.BOTTOM, null); - target.drawString(font10, sTemperatureC, dispX, dispY+15* zoomLevel* yRatio, 0.0, - TextStyle.NORMAL, NsharpConstants.color_red, HorizontalAlignment.LEFT, - VerticalAlignment.BOTTOM, null); - target.drawString(font10, sTemperatureF, dispX, dispY+30* zoomLevel* yRatio, 0.0, - TextStyle.NORMAL, NsharpConstants.color_red, HorizontalAlignment.LEFT, - VerticalAlignment.BOTTOM, null); - //column 2: m, ft, mixing ratio - float heightM = nsharpNative.nsharpLib.ihght((float)dPressure); - String sHeightM = String.format("%.0fm",heightM); - target.drawString(font10, sHeightM, dispX+40* zoomLevel* xRatio, dispY, 0.0, - TextStyle.NORMAL, NsharpConstants.color_cyan, HorizontalAlignment.LEFT, - VerticalAlignment.BOTTOM, null); - String sHeightFt = String.format("%.0fft",NsharpConstants.metersToFeet.convert(heightM)); - target.drawString(font10, sHeightFt, dispX+40* zoomLevel* xRatio, dispY+15* zoomLevel* yRatio, 0.0, - TextStyle.NORMAL, NsharpConstants.color_cyan, HorizontalAlignment.LEFT, - VerticalAlignment.BOTTOM, null); - target.drawString(font10, sMixingRatio, dispX+40* zoomLevel* xRatio, dispY+30* zoomLevel* yRatio, 0.0, - TextStyle.NORMAL, NsharpConstants.color_green, HorizontalAlignment.LEFT, - VerticalAlignment.BOTTOM, null); - //column 3: Theta, ThetaW, ThetaE - target.drawString(font10, sThetaInK, dispX+80* zoomLevel* xRatio, dispY, 0.0, - TextStyle.NORMAL, NsharpConstants.color_yellow, HorizontalAlignment.LEFT, - VerticalAlignment.BOTTOM, null); - target.drawString(font10, sWThetaInK, dispX+80* zoomLevel* xRatio, dispY+15* zoomLevel* yRatio, 0.0, - TextStyle.NORMAL, NsharpConstants.color_yellow, HorizontalAlignment.LEFT, - VerticalAlignment.BOTTOM, null); - target.drawString(font10, sEThetaInK, dispX+80* zoomLevel* xRatio, dispY+30* zoomLevel* yRatio, 0.0, - TextStyle.NORMAL, NsharpConstants.color_yellow, HorizontalAlignment.LEFT, - VerticalAlignment.BOTTOM, null); - } - private void paintIcing(double zoomLevel,IGraphicsTarget target) throws VizException{ - WGraphics plotWorld = icingBackground.getWorld(); - target.setupClippingPlane(icingBackground.getPe()); - try { - if((graphConfigProperty!=null && graphConfigProperty.isWindBarb() == true) || graphConfigProperty== null) { - plotWorld.setWorldCoordinates(NsharpConstants.ICING_RELATIVE_HUMIDITY_LEFT, icingBackground.toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_BOTTOM), - NsharpConstants.ICING_RELATIVE_HUMIDITY_RIGHT, icingBackground.toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_TOP)); - //NsharpLineProperty lp =linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_WIND_BARB]); - double xPos = icingBackground.getWindBarbXPosition();//90;// - //System.out.println("ice wind x pos="+xPos); - drawNsharpWindBarb(target, zoomLevel, plotWorld,graphConfigProperty.getWindBarbColor()/*lp.getLineColor()*/, this.soundingLys,xPos, NsharpConstants.ICING_PRESSURE_LEVEL_TOP); - } - } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - //Chin NOTE: icining wireframeshapes are created dynamically ONLY when icing display is to be shown - //However, Skewt wireframeshapes are created when new sounding is loaded. - if(icingRHShape==null){ - // current WorldCoordinates for RH already loaded - plotWorld.setWorldCoordinates(NsharpConstants.ICING_RELATIVE_HUMIDITY_LEFT, icingBackground.toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_TOP), - NsharpConstants.ICING_RELATIVE_HUMIDITY_RIGHT, icingBackground.toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_BOTTOM)); - - createIcingRHShape(plotWorld); - } - if(icingRHShape != null){ - NsharpLineProperty lp =linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_ICING_RH]); - target.drawWireframeShape(icingRHShape,lp.getLineColor(), lp.getLineWidth(),lp.getLineStyle(),font10); - } - if(icingTempShape==null){ - plotWorld.setWorldCoordinates(NsharpConstants.ICING_TEMPERATURE_LEFT, icingBackground.toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_TOP), - NsharpConstants.ICING_TEMPERATURE_RIGHT, icingBackground.toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_BOTTOM)); - createIcingTempShape(plotWorld); - } - if(icingTempShape != null){ - NsharpLineProperty lp =linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_ICING_TEMP]); - target.drawWireframeShape(icingTempShape,lp.getLineColor(), lp.getLineWidth(),lp.getLineStyle(),font10); - } - if(icingEPIShape==null){ - plotWorld.setWorldCoordinates(NsharpConstants.ICING_TEMPERATURE_LEFT, icingBackground.toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_TOP), - NsharpConstants.ICING_TEMPERATURE_RIGHT, icingBackground.toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_BOTTOM)); - createIcingEPIShape(plotWorld); - } - if(icingEPIShape != null){ - NsharpLineProperty lp =linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_ICING_EPI]); - target.drawWireframeShape(icingEPIShape,lp.getLineColor(), lp.getLineWidth(),lp.getLineStyle(),font10); - } - - target.clearClippingPlane(); - - - } - private void paintTurbulence(double zoomLevel,IGraphicsTarget target) throws VizException{ - WGraphics plotWorld = turbBackground.getWorld(); - target.setupClippingPlane(turbBackground.getPe()); - //Chin NOTE: turbulence wireframeshapes are created dynamically ONLY when turbulence display is to be shown - //However, Skewt wireframeshapes are created when new sounding is loaded. - try { - //Chin:NOTE: LN Richardson number is plotted with positive number increase to left and netagive number decrease to its right side. - // Therefore, we have to set its world X coordintion in a reverse way as plotting Icing wind barb. - if((graphConfigProperty!=null && graphConfigProperty.isWindBarb() == true) || graphConfigProperty== null) { - plotWorld.setWorldCoordinates(NsharpConstants.TURBULENCE_LN_RICHARDSON_NUMBER_RIGHT, turbBackground.toLogScale(NsharpConstants.TURBULENCE_PRESSURE_LEVEL_BOTTOM), - NsharpConstants.TURBULENCE_LN_RICHARDSON_NUMBER_LEFT, turbBackground.toLogScale(NsharpConstants.TURBULENCE_PRESSURE_LEVEL_TOP)); - //NsharpLineProperty lp =linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_WIND_BARB]); - double xPos = turbBackground.getWindBarbXPosition(); - //System.out.println("turb wind x pos="+xPos); - drawNsharpWindBarb(target, zoomLevel, plotWorld, graphConfigProperty.getWindBarbColor()/*lp.getLineColor()*/, this.soundingLys, xPos/*7*/, NsharpConstants.TURBULENCE_PRESSURE_LEVEL_TOP); - } - }catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - if(turbLnShape==null || turbWindShearShape==null){ - createTurbulenceShapes(plotWorld); - } - if(turbLnShape != null){ - NsharpLineProperty lp =linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_TURBULENCE_LN]); - target.drawWireframeShape(turbLnShape, lp.getLineColor(), lp.getLineWidth(),lp.getLineStyle(),font10); - - } - if(turbWindShearShape != null){ - NsharpLineProperty lp =linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_TURBULENCE_WS]); - target.drawWireframeShape(turbWindShearShape, lp.getLineColor(), lp.getLineWidth(),lp.getLineStyle(),font10); - } - - target.clearClippingPlane(); - - } - public void updatePsblWatchColor(){ - int wwtype = nsharpNative.nsharpLib.cave_ww_type(); - - //System.out.println("sk ww type="+ wwtype); - //See nsharpNative.nsharpLib.cave_ww_type() for returned wwtype definitions - switch(wwtype){ - case 1: - wwTypeColor = NsharpConstants.color_skyblue; - break; - case 2: - wwTypeColor = NsharpConstants.color_cyan; - break; - case 3: - wwTypeColor = NsharpConstants.color_red; - break; - case 4: - wwTypeColor = NsharpConstants.color_red; - break; - case 5: - wwTypeColor = NsharpConstants.color_magenta; - break; - default: - wwTypeColor = NsharpConstants.color_gold; - break; - } - } - private void drawNsharpFileNameAndSampling(IGraphicsTarget target, double zoomLevel) - throws VizException { - double dispX, xmin; - double dispY, ymin; - IExtent ext = getDescriptor().getRenderableDisplay().getExtent(); - xmin = ext.getMinX(); //Extent's viewable envelope min x and y - ymin = ext.getMinY(); - dispX = xmin + 20 * zoomLevel* xRatio; - dispY = ymin + 35 * zoomLevel* yRatio; - //System.out.println("zoomLevel="+zoomLevel+" xmin="+xmin+" dispX="+dispX); - RGB pickedStnColor = NsharpConstants.color_green; - String pickedStnInfoStr=""; - String latlonStr=""; - if(rscHandler.isOverlayIsOn()){ - NsharpSoundingElementStateProperty preSndProfileProp= rscHandler.getPreSndProfileProp(); - if(preSndProfileProp!= null){ - pickedStnColor = linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_OVERLAY2]).getLineColor(); - String stnInfoStr = preSndProfileProp.getElementDescription(); - latlonStr = Math.rint(preSndProfileProp.getStnInfo().getLatitude()*100)/100 + "," + Math.rint(preSndProfileProp.getStnInfo().getLongitude()*100)/100; - DrawableString str =new DrawableString( stnInfoStr+" "+latlonStr,pickedStnColor); - str.font = font10; - str.setCoordinates(dispX + 300 * zoomLevel* xRatio, dispY); - str.horizontalAlignment = HorizontalAlignment.LEFT; - str.verticallAlignment = VerticalAlignment.TOP; - target.drawStrings(str); - } - pickedStnColor = linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_OVERLAY1]).getLineColor(); - } - //dispX = skewtXOrig+20; - pickedStnInfoStr = rscHandler.getPickedStnInfoStr(); - //Also draw stn lat/lon info string and sounding type string - NsharpStationInfo pickedStnInfo = rscHandler.getPickedStnInfo(); - if(pickedStnInfo != null){ - latlonStr = Math.rint(pickedStnInfo.getLatitude()*100)/100 + "," + Math.rint(pickedStnInfo.getLongitude()*100)/100; - } - double hRatio = paintProps.getView().getExtent().getWidth() / paintProps.getCanvasBounds().width; - double vRatio = paintProps.getView().getExtent().getHeight() / paintProps.getCanvasBounds().height; - DrawableString str =new DrawableString( pickedStnInfoStr+" "+latlonStr,pickedStnColor); - str.font = font10; - str.setCoordinates(dispX, dispY); - str.horizontalAlignment = HorizontalAlignment.LEFT; - str.verticallAlignment = VerticalAlignment.TOP; - Rectangle2D rect = target.getStringsBounds(str); - PixelExtent boxExt; - if(cursorInSkewT== true && currentGraphMode == NsharpConstants.GRAPH_SKEWT){ - boxExt = new PixelExtent(dispX,dispX+(rect.getWidth()+1)*hRatio,dispY-1*vRatio, dispY+rect.getHeight()*vRatio*4); - //blank out box, should draw this first and then draw data on top of it - target.drawShadedRect(boxExt, NsharpConstants.color_black, 1f, null); - //draw dynamic temp, theta, height - //Column 1: pressure, C and F - DrawableString str1 =new DrawableString(sPressure+" ",NsharpConstants.color_white); - str1.font = font10; - dispY = dispY+target.getStringsBounds(str).getHeight()*vRatio ; - str1.setCoordinates(dispX, dispY); - str1.horizontalAlignment = HorizontalAlignment.LEFT; - str1.verticallAlignment = VerticalAlignment.TOP; - DrawableString str2 =new DrawableString(sTemperatureC,NsharpConstants.color_red); - str2.font = font10; - dispY = dispY+target.getStringsBounds(str).getHeight()*vRatio ; - str2.setCoordinates(dispX, dispY); - str2.horizontalAlignment = HorizontalAlignment.LEFT; - str2.verticallAlignment = VerticalAlignment.TOP; - DrawableString str3 =new DrawableString(sTemperatureF,NsharpConstants.color_red); - str3.font = font10; - dispY = dispY+target.getStringsBounds(str).getHeight()*vRatio ; - str3.setCoordinates(dispX, dispY); - str3.horizontalAlignment = HorizontalAlignment.LEFT; - str3.verticallAlignment = VerticalAlignment.TOP; - //column 2: m, ft, mixing ratio - float heightM = nsharpNative.nsharpLib.ihght((float)dPressure); - String sHeightM = String.format("%.0fm",heightM); - dispX = dispX +target.getStringsBounds(str1).getWidth()*hRatio; - dispY = ymin + 35 * zoomLevel* yRatio+target.getStringsBounds(str).getHeight()*vRatio ; - DrawableString str4 =new DrawableString(sHeightM,NsharpConstants.color_cyan); - str4.font = font10; - str4.setCoordinates(dispX, dispY); - str4.horizontalAlignment = HorizontalAlignment.LEFT; - str4.verticallAlignment = VerticalAlignment.TOP; - String sHeightFt = String.format("%.0fft",NsharpConstants.metersToFeet.convert(heightM)); - DrawableString str5 =new DrawableString(sHeightFt+" ",NsharpConstants.color_cyan); - str5.font = font10; - dispY = dispY+target.getStringsBounds(str).getHeight()*vRatio ; - str5.setCoordinates(dispX, dispY); - str5.horizontalAlignment = HorizontalAlignment.LEFT; - str5.verticallAlignment = VerticalAlignment.TOP; - DrawableString str6 =new DrawableString(sMixingRatio,NsharpConstants.color_green); - str6.font = font10; - dispY = dispY+target.getStringsBounds(str).getHeight()*vRatio ; - str6.setCoordinates(dispX, dispY); - str6.horizontalAlignment = HorizontalAlignment.LEFT; - str6.verticallAlignment = VerticalAlignment.TOP; - - //column 3: Theta, ThetaW, ThetaE - dispX = dispX +target.getStringsBounds(str5).getWidth()*hRatio; - dispY = ymin + 35 * zoomLevel* yRatio+target.getStringsBounds(str).getHeight()*vRatio ; - DrawableString str7 =new DrawableString(sThetaInK,NsharpConstants.color_yellow); - str7.font = font10; - str7.setCoordinates(dispX, dispY); - str7.horizontalAlignment = HorizontalAlignment.LEFT; - str7.verticallAlignment = VerticalAlignment.TOP; - DrawableString str8 =new DrawableString(sWThetaInK,NsharpConstants.color_yellow); - str8.font = font10; - dispY = dispY+target.getStringsBounds(str).getHeight()*vRatio ; - str8.setCoordinates(dispX, dispY); - str8.horizontalAlignment = HorizontalAlignment.LEFT; - str8.verticallAlignment = VerticalAlignment.TOP; - DrawableString str9 =new DrawableString(sEThetaInK,NsharpConstants.color_yellow); - str9.font = font10; - dispY = dispY+target.getStringsBounds(str).getHeight()*vRatio ; - str9.setCoordinates(dispX, dispY); - str9.horizontalAlignment = HorizontalAlignment.LEFT; - str9.verticallAlignment = VerticalAlignment.TOP; - target.drawStrings(str, str1, str2, str3, str4, str5, str6, str7,str8,str9); - } - else { - boxExt = new PixelExtent(dispX,dispX+(rect.getWidth()+1)*hRatio,dispY-1*vRatio, dispY+rect.getHeight()*vRatio); - target.drawShadedRect(boxExt, NsharpConstants.color_black, 1f, null); //blank out box - } - target.drawStrings(str); - target.drawRect(boxExt, wwTypeColor, 2f, 1f); // box border line colored with "Psbl Watch Type" color - } - - - @Override - protected void paintInternal(IGraphicsTarget target, - PaintProperties paintProps) throws VizException { - this.paintProps = paintProps; - super.paintInternal(target, paintProps); - if(soundingLys==null){ - drawNoDataMessage(target);// FixMark:clickOnTimeStnPane - return; - } - - //System.out.println("skew paintInternal zoomL="+currentZoomLevel); - if(rscHandler== null) - return; - //System.out.println("myPerspective="+myPerspective); - //D2D5Pane.ID_PERSPECTIVE = "com.raytheon.uf.viz.d2d.ui.perspectives.D2D5Pane" - if(myPerspective.equals(D2D5Pane.ID_PERSPECTIVE)){ - //rscHandler.repopulateSndgData();//CHIN swapping - if(justMoveToSidePane){ - reentryLock.lock(); - //to check a scenario that sounding data is removed while thread is locked - if(soundingLys==null ||(soundingLys!=null && soundingLys.size()<=0)){ - reentryLock.unlock(); - return; - } - rscHandler.repopulateSndgData(); - handleResize(); - justMoveToSidePane = false; - reentryLock.unlock(); - }else if(justBackToMainPane ){ - reentryLock.lock(); - if(soundingLys==null ||(soundingLys!=null && soundingLys.size()<=0)){ - reentryLock.unlock(); - return; - } - rscHandler.repopulateSndgData();//CHIN swapping - createRscWireFrameShapes(); - justBackToMainPane = false; - reentryLock.unlock(); - NsharpPaletteWindow paletteWin = NsharpPaletteWindow.getInstance(); - if(paletteWin!=null){ - paletteWin.restorePaletteWindow(paneConfigurationName, rscHandler.getCurrentGraphMode(), - rscHandler.isInterpolateIsOn(), rscHandler.isOverlayIsOn(), - rscHandler.isCompareStnIsOn(),rscHandler.isCompareTmIsOn(),rscHandler.isEditGraphOn(), rscHandler.isCompareSndIsOn()); - } - } - } - /* Chin : turn it off for now - skewTBackground.setCurrentFont(currentFont10Size); - icingBackground.setCurrentFont(currentFont10Size); - skewTBackground.magnifyFont(currentZoomLevel); - icingBackground.magnifyFont(currentZoomLevel);*/ - - if(currentGraphMode== NsharpConstants.GRAPH_SKEWT) - skewTBackground.paint(target, paintProps); - else if(currentGraphMode == NsharpConstants.GRAPH_ICING) - icingBackground.paint(target, paintProps); - else if(currentGraphMode == NsharpConstants.GRAPH_TURB) - turbBackground.paint(target, paintProps); - else - //default - skewTBackground.paint(target, paintProps); - - if(soundingLys!= null){ - this.font10.setSmoothing(false); - this.font10.setScaleFont(false); - this.font9.setSmoothing(false); - this.font9.setScaleFont(false); - this.font12.setSmoothing(false); - this.font12.setScaleFont(false); - //nsharpNative.populateSndgData(soundingLys); - if(currentGraphMode== NsharpConstants.GRAPH_SKEWT){ - target.setupClippingPlane(pe); - //plot temp curve, when constructing pressureTempRscShapeList, it already considered - // comparison, overlay, etc..so, just draw it. - for(NsharpShapeAndLineProperty shapeNLp: pressureTempRscShapeList){ - target.drawWireframeShape(shapeNLp.getShape(), shapeNLp.getLp().getLineColor(), shapeNLp.getLp().getLineWidth(), shapeNLp.getLp().getLineStyle(),font10);//commonLinewidth*2,commonLineStyle,font10); - } - //plot real temp parcel trace, when constructing parcelRtShapeList, it already considered - // comparison, overlay, etc..so, just draw it. - //color is following comparison/overlay lines' configuration. - //line width and line style are following parcel line configuration - if(graphConfigProperty.isParcel() == true ){ - NsharpLineProperty parcelLp =linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_PARCEL]); - for(NsharpShapeAndLineProperty shapeNLp: parcelRtShapeList){ - target.drawWireframeShape(shapeNLp.getShape(), shapeNLp.getLp().getLineColor(), parcelLp.getLineWidth(), parcelLp.getLineStyle(),font10);//commonLinewidth*2,commonLineStyle,font10); - } - } - boolean compareStnIsOn = rscHandler.isCompareStnIsOn(); - boolean compareSndIsOn = rscHandler.isCompareSndIsOn(); - boolean compareTmIsOn = rscHandler.isCompareTmIsOn(); - boolean editGraphOn= rscHandler.isEditGraphOn(); - boolean overlayIsOn = rscHandler.isOverlayIsOn(); - if(graphConfigProperty != null ){ - if(graphConfigProperty.isTemp() == true && !compareStnIsOn && !compareTmIsOn){ - if(editGraphOn) - plotPressureTempEditPoints(target, world, NsharpConstants.color_red, TEMP_TYPE, this.soundingLys); - } - // dew point curve - if(graphConfigProperty.isDewp() == true && !compareStnIsOn && !compareTmIsOn){ - if(editGraphOn) - plotPressureTempEditPoints(target, world, NsharpConstants.color_green, DEWPOINT_TYPE, this.soundingLys); - } - //plot wet bulb trace - if(graphConfigProperty.isWetBulb() == true && !compareStnIsOn && !compareTmIsOn){ - NsharpLineProperty lp =linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_WETBULB]); - target.drawWireframeShape(wetBulbTraceRscShape, lp.getLineColor(),lp.getLineWidth(),lp.getLineStyle(),font10); - } - //plot virtual temperature trace - if(graphConfigProperty.isVTemp() == true && !compareStnIsOn && !compareTmIsOn){ - NsharpLineProperty lp =linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_VIRTUAL_TEMP]); - target.drawWireframeShape(vtempTraceCurveRscShape,lp.getLineColor(),lp.getLineWidth(),lp.getLineStyle(),font10); - } - // virtual temperature parcel trace curve - if(graphConfigProperty.isParcelTv() == true && !compareStnIsOn && !compareTmIsOn && !overlayIsOn){ - if(soundingLys.size() > 0){ - NsharpLineProperty lp =linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_PARCEL_TV]); - target.drawWireframeShape(parcelVtTraceRscShape, lp.getLineColor(),lp.getLineWidth(),lp.getLineStyle(),font10); - } - } - - if(graphConfigProperty.isDcape() == true && dacpeTraceRscShape != null && !compareStnIsOn && !compareTmIsOn && !overlayIsOn){ - if(soundingLys.size() > 0){ - NsharpLineProperty lp =linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_DCAPE]); - target.drawWireframeShape(dacpeTraceRscShape, lp.getLineColor(),lp.getLineWidth(),lp.getLineStyle(),font10); - - } - } - if(graphConfigProperty.isEffLayer() == true && !compareStnIsOn && !compareTmIsOn ){ - //draw effective layer lines - //drawEffectiveLayerLines(target); - target.drawWireframeShape(effectiveLayerLineShape, NsharpConstants.color_cyan_md, 2, - commonLineStyle,font10); - } - //cloud - if(graphConfigProperty.isCloud() == true && !compareStnIsOn && !compareTmIsOn){ - if(cloudFMShape!= null) - target.drawShadedShape(cloudFMShape, 1f); - if(cloudFMLabelShape!= null) - target.drawWireframeShape(cloudFMLabelShape, NsharpConstants.color_chocolate, commonLinewidth*3, - commonLineStyle,font9); - if(cloudCEShape!= null) - target.drawShadedShape(cloudCEShape, 1f); - } - if(graphConfigProperty.isOmega() == true&& !compareStnIsOn && !compareTmIsOn){ - if(NsharpLoadDialog.getAccess()!= null && - (NsharpLoadDialog.getAccess().getActiveLoadSoundingType()== NsharpLoadDialog.MODEL_SND || - NsharpLoadDialog.getAccess().getActiveLoadSoundingType()== NsharpLoadDialog.PFC_SND )){ - //plot omega - drawOmega(); - } - } - } - else{ - //by default, draw everything - if(!compareStnIsOn && !compareTmIsOn){ - if(editGraphOn) - plotPressureTempEditPoints(target, world, NsharpConstants.color_red, TEMP_TYPE, this.soundingLys); - // dew point curve - if(editGraphOn) - plotPressureTempEditPoints(target, world, NsharpConstants.color_green, DEWPOINT_TYPE, this.soundingLys); - //plot wetbulb trace - NsharpLineProperty lp =linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_WETBULB]); - target.drawWireframeShape(wetBulbTraceRscShape, lp.getLineColor(),lp.getLineWidth(),lp.getLineStyle(),font10); - //plot virtual temp trace - lp =linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_VIRTUAL_TEMP]); - target.drawWireframeShape(vtempTraceCurveRscShape,lp.getLineColor(),lp.getLineWidth(),lp.getLineStyle(),font10); - - //virtual temperature parcel trace curve - if(!overlayIsOn){ - lp =linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_PARCEL_TV]); - target.drawWireframeShape(parcelVtTraceRscShape, lp.getLineColor(),lp.getLineWidth(),lp.getLineStyle(),font10); - if(dacpeTraceRscShape != null){ - lp =linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_DCAPE]); - target.drawWireframeShape(dacpeTraceRscShape, lp.getLineColor(),lp.getLineWidth(),lp.getLineStyle(),font10); - } - } - //draw effective layer lines - //drawEffectiveLayerLines(target); - target.drawWireframeShape(effectiveLayerLineShape, NsharpConstants.color_cyan_md, 2, - commonLineStyle,font10); - if(NsharpLoadDialog.getAccess()!= null && - (NsharpLoadDialog.getAccess().getActiveLoadSoundingType()== NsharpLoadDialog.MODEL_SND || - NsharpLoadDialog.getAccess().getActiveLoadSoundingType()== NsharpLoadDialog.PFC_SND )){ - //plot omega - drawOmega(); - } - } - } - if(plotInteractiveTemp == true ){ - if(currentSkewTEditMode == NsharpConstants.SKEWT_EDIT_MODE_EDITPOINT) - plotNsharpInteractiveEditingTemp( target, currentZoomLevel, - world, NsharpConstants.color_white); - else if(currentSkewTEditMode == NsharpConstants.SKEWT_EDIT_MODE_MOVELINE) - plotNsharpMovingTempLine( target, - world, NsharpConstants.color_white); - - } - target.clearClippingPlane(); - - - // Wind Barb - if((graphConfigProperty!=null && graphConfigProperty.isWindBarb() == true) || graphConfigProperty== null) { - double xPos = skewTBackground.getWindBarbXPosition(); - if(overlayIsOn == true && this.previousSoundingLys!=null){ - drawNsharpWindBarb(target, currentZoomLevel, world, linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_OVERLAY1]).getLineColor(), this.soundingLys, xPos,100); - if(!previousSoundingLys.equals(soundingLys)) - drawNsharpWindBarb(target, currentZoomLevel, world, linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_OVERLAY2]).getLineColor(), this.previousSoundingLys, xPos - NsharpResourceHandler.BARB_LENGTH,100); - } - else{ - if(!compareStnIsOn && !compareTmIsOn && !compareSndIsOn){ - drawNsharpWindBarb(target, currentZoomLevel, world, graphConfigProperty.getWindBarbColor(), this.soundingLys, xPos,100); - } - else{ - int currentTimeListIndex = rscHandler.getCurrentTimeElementListIndex(); - int currentStnListIndex = rscHandler.getCurrentStnElementListIndex(); - int currentSndListIndex = rscHandler.getCurrentSndElementListIndex(); - List stnElemList = rscHandler.getStnElementList(); - List timeElemList = rscHandler.getTimeElementList(); - List sndElemList = rscHandler.getSndElementList(); - List>> stnTimeSndTable = rscHandler.getStnTimeSndTable(); - if(compareTmIsOn && currentStnListIndex >=0 && currentSndListIndex >=0){ - int colorIndex; - for(NsharpOperationElement elm: timeElemList) { - if(elm.getActionState() == NsharpConstants.ActState.ACTIVE && - stnTimeSndTable.get(currentStnListIndex).get(timeElemList.indexOf(elm)).get(currentSndListIndex)!=null){ - List soundingLayeys = stnTimeSndTable.get(currentStnListIndex).get(timeElemList.indexOf(elm)).get(currentSndListIndex).getSndLyLst(); - colorIndex = stnTimeSndTable.get(currentStnListIndex).get(timeElemList.indexOf(elm)).get(currentSndListIndex).getCompColorIndex(); - NsharpLineProperty lp = linePropertyMap.get(NsharpConstants.lineNameArray[colorIndex]); - drawNsharpWindBarb(target, currentZoomLevel, world, lp.getLineColor(), soundingLayeys, xPos,100); - } - } - } else if(compareStnIsOn && currentTimeListIndex >=0 && currentSndListIndex >=0){ - int colorIndex ; - for(NsharpOperationElement elm: stnElemList) { - if(elm.getActionState() == NsharpConstants.ActState.ACTIVE && - stnTimeSndTable.get(stnElemList.indexOf(elm)).get(currentTimeListIndex).get(currentSndListIndex)!=null){ - List soundingLayeys = stnTimeSndTable.get(stnElemList.indexOf(elm)).get(currentTimeListIndex).get(currentSndListIndex).getSndLyLst(); - colorIndex = stnTimeSndTable.get(stnElemList.indexOf(elm)).get(currentTimeListIndex).get(currentSndListIndex).getCompColorIndex(); - NsharpLineProperty lp = linePropertyMap.get(NsharpConstants.lineNameArray[colorIndex]); - drawNsharpWindBarb(target, currentZoomLevel, world, lp.getLineColor(), soundingLayeys, xPos,100); - } - } - } else if(compareSndIsOn && currentStnListIndex >=0 && currentTimeListIndex >=0){ - int colorIndex; - for(NsharpOperationElement elm: sndElemList) { - if(elm.getActionState() == NsharpConstants.ActState.ACTIVE && - stnTimeSndTable.get(currentStnListIndex).get(currentTimeListIndex).get(sndElemList.indexOf(elm))!=null){ - List soundingLayeys = stnTimeSndTable.get(currentStnListIndex).get(currentTimeListIndex).get(sndElemList.indexOf(elm)).getSndLyLst(); - colorIndex = stnTimeSndTable.get(currentStnListIndex).get(currentTimeListIndex).get(sndElemList.indexOf(elm)).getCompColorIndex(); - NsharpLineProperty lp = linePropertyMap.get(NsharpConstants.lineNameArray[colorIndex]); - drawNsharpWindBarb(target, currentZoomLevel, world, lp.getLineColor(), soundingLayeys, xPos,100); - } - } - } - } - } - //System.out.println("x1 pos"+xPos+ " x2 pos="+ (xPos - NsharpResourceHandler.BARB_LENGTH)); - } - drawHeightMark(target); - //draw EL, LFC, LCL, FZL, -20C, -30C lines - //drawLclLine(target); - target.drawWireframeShape(lclShape,NsharpConstants.color_green, 2,LineStyle.SOLID, font10); - target.drawWireframeShape(elShape,NsharpConstants.color_red, 2,LineStyle.SOLID, font10); - target.drawWireframeShape(lfcShape,NsharpConstants.color_yellow, 2,LineStyle.SOLID, font10); - target.drawWireframeShape(fzlShape,NsharpConstants.color_cyan, 2,LineStyle.SOLID, font10); - // draw cursor data - if(cursorInSkewT== true){ - if((curseToggledFontLevel < CURSER_STRING_OFF)&& - (cursorTopWindBarb == false || windBarbMagnify == false) - ) - drawNsharpSkewtCursorData(target); - } - }// end of currentGraphMode= NsharpConstants.GRAPH_SKEWT - else if(currentGraphMode == NsharpConstants.GRAPH_ICING){ - paintIcing( currentZoomLevel, target); - } - else if(currentGraphMode == NsharpConstants.GRAPH_TURB){ - paintTurbulence( currentZoomLevel, target); - } - drawNsharpFileNameAndSampling(target, currentZoomLevel); - } - } - - @Override - protected void initInternal(IGraphicsTarget target) throws VizException { - super.initInternal(target); - currentCanvasBoundWidth = NsharpConstants.SKEWT_PANE_REC_WIDTH; - currentCanvasBoundHeight = NsharpConstants.SKEWT_PANE_REC_HEIGHT; - myDefaultCanvasWidth = NsharpConstants.SKEWT_PANE_REC_WIDTH; - myDefaultCanvasHeight = NsharpConstants.SKEWT_PANE_REC_HEIGHT; - //System.out.print("NsharpSkewTPaneResource ::: initInternal entered!!!!!\n"); - this.rectangle = new Rectangle(skewtXOrig, skewtYOrig, - skewtWidth, skewtHeight); - pe = new PixelExtent(this.rectangle); - world = new WGraphics(this.rectangle); - - world.setWorldCoordinates(NsharpConstants.left, NsharpConstants.top, - NsharpConstants.right, NsharpConstants.bottom); - skewTBackground.initInternal(target); - icingBackground.initInternal(target); - turbBackground.initInternal(target); - titleBoxShape = target.createWireframeShape(false,descriptor ); - titleBoxShape.allocate(8); - createRscWireFrameShapes(); - - } - - public String updateDynamicData(Coordinate c) throws VizException { - this.cursorCor = c; - try { - //System.out.println(" updateDynamicData entered!!!!!C.x="+c.x + " c.y="+c.y); - - if (skewTBackground.contains(c)) { - c = NsharpWxMath.reverseSkewTXY(skewTBackground.getWorld() - .unMap(c.x, c.y)); - double p_mb = c.y; - double t_C = c.x; // Celsius - double t_F = celciusToFahrenheit.convert(c.x); - double theta = celciusToKelvin.convert(WxMath.theta(p_mb, t_C, - 1000)); - double wtheta = celciusToKelvin.convert(WxMath.thetaw(p_mb, - t_C, t_C)); - double etheta = celciusToKelvin.convert(WxMath.thetae(p_mb, - t_C, t_C)); - double mixRatio = WxMath.mixingRatio(p_mb, t_C); - dPressure = p_mb; - - sPressure = String.format( - "%.0f mb",p_mb, NsharpConstants.THETA_SYMBOL); - sTemperatureC = String.format("%.1f%cC", - t_C, NsharpConstants.DEGREE_SYMBOL); - sTemperatureF = String.format("%.1f%cF", - t_F,NsharpConstants.DEGREE_SYMBOL); - - sThetaInK = String.format("%c=%.0fK", - NsharpConstants.THETA_SYMBOL,theta); - sWThetaInK = String.format("%cw=%.0fK", - NsharpConstants.THETA_SYMBOL,wtheta); - sEThetaInK = String.format("%ce=%.0fK", - NsharpConstants.THETA_SYMBOL,etheta); - sMixingRatio = String.format("%.0fg/Kg",mixRatio); - } - } catch (Exception e) { - UFStatus.getHandler().handle(Priority.PROBLEM, "Exception translating coordinate", e); - } - return ""; - } - //Creating real temperature parcel trace shape list - considering normal/comparison/overlay scenarios - public void createRscParcelRtTraceShapesList( short parcelType, float userPre){ - if(target==null) - return; - if(parcelRtShapeList.size()>0){ - for(NsharpShapeAndLineProperty shapeColor: parcelRtShapeList){ - shapeColor.getShape().dispose(); - } - parcelRtShapeList.clear(); - } - - int currentTimeListIndex = rscHandler.getCurrentTimeElementListIndex(); - int currentStnListIndex = rscHandler.getCurrentStnElementListIndex(); - int currentSndListIndex = rscHandler.getCurrentSndElementListIndex(); - List stnElemList = rscHandler.getStnElementList(); - List timeElemList = rscHandler.getTimeElementList(); - List sndElemList = rscHandler.getSndElementList(); - List>> stnTimeSndTable = rscHandler.getStnTimeSndTable(); - if(rscHandler.isCompareStnIsOn() && currentTimeListIndex >=0 && currentSndListIndex >=0){ - for(NsharpOperationElement elm: stnElemList) { - if(elm.getActionState() == NsharpConstants.ActState.ACTIVE && - stnTimeSndTable.get(stnElemList.indexOf(elm)).get(currentTimeListIndex).get(currentSndListIndex)!=null){ - List soundingLayeys = stnTimeSndTable.get(stnElemList.indexOf(elm)).get(currentTimeListIndex).get(currentSndListIndex).getSndLyLst(); - int colorIndex = stnTimeSndTable.get(stnElemList.indexOf(elm)).get(currentTimeListIndex).get(currentSndListIndex).getCompColorIndex(); - NsharpLineProperty lp = linePropertyMap.get(NsharpConstants.lineNameArray[colorIndex]); - IWireframeShape shape = createRTParcelTraceShapes( parcelType, userPre, soundingLayeys); - NsharpShapeAndLineProperty shNLp = new NsharpShapeAndLineProperty(); - shNLp.setShape(shape); - shNLp.setLp(lp); - parcelRtShapeList.add(shNLp); - } - } - } - else if(rscHandler.isCompareTmIsOn() && currentStnListIndex >=0 && currentSndListIndex >=0 ){ - //tk#1004int lpIndex =NsharpConstants.LINE_COMP1; - for(NsharpOperationElement elm: timeElemList) { - if(elm.getActionState() == NsharpConstants.ActState.ACTIVE && - stnTimeSndTable.get(currentStnListIndex).get(timeElemList.indexOf(elm)).get(currentSndListIndex)!=null){ - List soundingLayeys = stnTimeSndTable.get(currentStnListIndex).get(timeElemList.indexOf(elm)).get(currentSndListIndex).getSndLyLst(); - int colorIndex = stnTimeSndTable.get(currentStnListIndex).get(timeElemList.indexOf(elm)).get(currentSndListIndex).getCompColorIndex(); - NsharpLineProperty lp = linePropertyMap.get(NsharpConstants.lineNameArray[colorIndex]); - IWireframeShape shape = createRTParcelTraceShapes( parcelType, userPre, soundingLayeys); - NsharpShapeAndLineProperty shNLp = new NsharpShapeAndLineProperty(); - shNLp.setShape(shape); - shNLp.setLp(lp); - parcelRtShapeList.add(shNLp); - } - } - } - else if(rscHandler.isCompareSndIsOn() && currentStnListIndex >=0 && currentTimeListIndex >=0){ - for(NsharpOperationElement elm: sndElemList) { - if(elm.getActionState() == NsharpConstants.ActState.ACTIVE && - stnTimeSndTable.get(currentStnListIndex).get(currentTimeListIndex).get(sndElemList.indexOf(elm))!=null){ - List soundingLayeys = stnTimeSndTable.get(currentStnListIndex).get(currentTimeListIndex).get(sndElemList.indexOf(elm)).getSndLyLst(); - int colorIndex = stnTimeSndTable.get(currentStnListIndex).get(currentTimeListIndex).get(sndElemList.indexOf(elm)).getCompColorIndex(); - NsharpLineProperty lp = linePropertyMap.get(NsharpConstants.lineNameArray[colorIndex]); - IWireframeShape shape = createRTParcelTraceShapes( parcelType, userPre, soundingLayeys); - NsharpShapeAndLineProperty shNLp = new NsharpShapeAndLineProperty(); - shNLp.setShape(shape); - shNLp.setLp(lp); - parcelRtShapeList.add(shNLp); - } - } - } - else if(rscHandler.isOverlayIsOn() == true ){ - previousSoundingLys = rscHandler.getPreviousSoundingLys(); - IWireframeShape shape = createRTParcelTraceShapes( parcelType, userPre, this.soundingLys); - NsharpShapeAndLineProperty shNLp = new NsharpShapeAndLineProperty(); - shNLp.setShape(shape); - shNLp.setLp(linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_OVERLAY1])); - parcelRtShapeList.add(shNLp); - if(this.previousSoundingLys!=null && !previousSoundingLys.equals(soundingLys)){ - shape = createRTParcelTraceShapes( parcelType, userPre, previousSoundingLys); - shNLp = new NsharpShapeAndLineProperty(); - shNLp.setShape(shape); - shNLp.setLp(linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_OVERLAY2])); - parcelRtShapeList.add(shNLp); - } - } - else { - IWireframeShape shape = createRTParcelTraceShapes( parcelType, userPre, this.soundingLys); - NsharpShapeAndLineProperty shNLp = new NsharpShapeAndLineProperty(); - shNLp.setShape(shape); - shNLp.setLp(linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_PARCEL])); - parcelRtShapeList.add(shNLp); - } - } - //Creating real temperature parcel trace shape - private IWireframeShape createRTParcelTraceShapes( short parcelType, float userPre, List soundingLays){ - IWireframeShape parcelRtShape; - parcelRtShape= target.createWireframeShape(false,descriptor ); - parcelRtShape.allocate(40); - //the input soundingLays list may not be current sounding list, therfore need to populate it to - //native library. - nsharpNative.populateSndgData(soundingLays); - //call native define_parcel() with parcel type and user defined pressure (if user defined it) - nsharpNative.nsharpLib.define_parcel(parcelType,userPre); - - _lplvalues lpvls = new _lplvalues(); - nsharpNative.nsharpLib.get_lpvaluesData(lpvls); - - float sfctemp, sfcdwpt, sfcpres; - sfctemp = lpvls.temp; - sfcdwpt = lpvls.dwpt; - sfcpres = lpvls.pres; - - - FloatByReference p2 = new FloatByReference(0), t2 = new FloatByReference(0);; - nsharpNative.nsharpLib.drylift (sfcpres, sfctemp, sfcdwpt, p2, t2); - - - Coordinate a1 = NsharpWxMath.getSkewTXY(sfcpres, sfctemp); - a1.x = world.mapX(a1.x); - a1.y = world.mapY(a1.y); - Coordinate a2 = NsharpWxMath.getSkewTXY(p2.getValue(), t2.getValue()); - a2.x = world.mapX(a2.x); - a2.y = world.mapY(a2.y); - - double [][] alines = {{a1.x, a1.y},{a2.x, a2.y}}; - parcelRtShape.addLineSegment(alines); - a1 = a2; - - float t3; - for (float i = p2.getValue() - 50; i >= 100; i = i - 50) - { - t3 = nsharpNative.nsharpLib.wetlift (p2.getValue(), t2.getValue(), i); - - - a2 = NsharpWxMath.getSkewTXY(i, t3); - a2.x = world.mapX(a2.x); - a2.y = world.mapY(a2.y); - double [][] alines1 = {{a1.x, a1.y},{a2.x, a2.y}}; - parcelRtShape.addLineSegment(alines1); - a1 = a2; - } - - t3 = nsharpNative.nsharpLib.wetlift (p2.getValue(), t2.getValue(), 100); - - - a2 = NsharpWxMath.getSkewTXY(100, t3); - a2.x = world.mapX(a2.x); - a2.y = world.mapY(a2.y); - double [][] alines1 = {{a1.x, a1.y},{a2.x, a2.y}}; - parcelRtShape.addLineSegment(alines1); - - parcelRtShape.compile(); - - //re-populate sounding data back to current sounding - nsharpNative.populateSndgData(this.soundingLys); - return parcelRtShape; - } - - //Creating Virtual Temperature parcel and DCAPE trace Shapes - public void createRscParcelTraceShapes( short parcelType, float userPre){ - if(target==null) - return; - //System.out.println("createRscParcelTraceShape called defoine_parcel pType="+parcelType+" pre="+ userPre+ " BY:"+this.toString()); - if(parcelVtTraceRscShape != null){ - parcelVtTraceRscShape.dispose(); - parcelVtTraceRscShape = null; - } - if(dacpeTraceRscShape != null){ - dacpeTraceRscShape.dispose(); - dacpeTraceRscShape = null; - } - parcelVtTraceRscShape= target.createWireframeShape(false,descriptor ); - parcelVtTraceRscShape.allocate(40); - dacpeTraceRscShape= target.createWireframeShape(false,descriptor ); - dacpeTraceRscShape.allocate(40); - //call native define_parcel() with parcel type and user defined pressure (if user defined it) - nsharpNative.nsharpLib.define_parcel(parcelType,userPre); - - _lplvalues lpvls = new _lplvalues(); - nsharpNative.nsharpLib.get_lpvaluesData(lpvls); - - float sfctemp, sfcdwpt, sfcpres; - sfctemp = lpvls.temp; - sfcdwpt = lpvls.dwpt; - sfcpres = lpvls.pres; - - float vtemp = nsharpNative.nsharpLib.virtemp (sfcpres, sfctemp, sfcdwpt); - Coordinate c1 = NsharpWxMath.getSkewTXY(sfcpres, vtemp); - c1.x = world.mapX(c1.x); - c1.y = world.mapY(c1.y); - FloatByReference p2 = new FloatByReference(0), t2 = new FloatByReference(0);; - nsharpNative.nsharpLib.drylift (sfcpres, sfctemp, sfcdwpt, p2, t2); - vtemp = nsharpNative.nsharpLib.virtemp (p2.getValue(), t2.getValue(), t2.getValue()); - Coordinate c2 = NsharpWxMath.getSkewTXY(p2.getValue(), vtemp); - c2.x = world.mapX(c2.x); - c2.y = world.mapY(c2.y); - - double [][] lines = {{c1.x, c1.y},{c2.x, c2.y}}; - parcelVtTraceRscShape.addLineSegment(lines); - c1 = c2; - - float t3; - for (float i = p2.getValue() - 50; i >= 100; i = i - 50) - { - t3 = nsharpNative.nsharpLib.wetlift (p2.getValue(), t2.getValue(), i); - vtemp = nsharpNative.nsharpLib.virtemp (i, t3, t3); - c2 = NsharpWxMath.getSkewTXY(i, vtemp); - c2.x = world.mapX(c2.x); - c2.y = world.mapY(c2.y); - - double [][] lines1 = {{c1.x, c1.y},{c2.x, c2.y}}; - parcelVtTraceRscShape.addLineSegment(lines1); - c1 = c2; - - } - - t3 = nsharpNative.nsharpLib.wetlift (p2.getValue(), t2.getValue(), 100); - vtemp = nsharpNative.nsharpLib.virtemp (100, t3, t3); - c2 = NsharpWxMath.getSkewTXY(100, vtemp); - c2.x = world.mapX(c2.x); - c2.y = world.mapY(c2.y); - - double [][] lines2 = {{c1.x, c1.y},{c2.x, c2.y}}; - parcelVtTraceRscShape.addLineSegment(lines2); - - parcelVtTraceRscShape.compile(); - - //DCAPE------------------ - //Downdraft Convective Available Potential Energy - DCAPE - //see trace_dcape() in xwvid1.c for original source - /* ----- Find highest observation in layer ----- */ - @SuppressWarnings("unused") - float mine, minep, tp1, tp2, te1, te2, pe1, pe2, h1, h2; - FloatByReference value1= new FloatByReference(-999); - FloatByReference value2= new FloatByReference(-999); - FloatByReference Surfpressure = new FloatByReference(-999); - nsharpNative.nsharpLib.get_surface(Surfpressure, value1, value2); - int p5=0; - if(nsharpNative.nsharpLib.qc(Surfpressure.getValue()) == 1) { - NcSoundingLayer layer; - for (int i = this.soundingLys.size()-1; i >=0 ; i--) { - layer = this.soundingLys.get(i); - if(layer.getPressure() > Surfpressure.getValue() -400){ - p5 = i; - break; - } - } - } - - - /* ----- Find min ThetaE layer ----- */ - mine=1000; minep=-999; - for (int i=0;i=0 ; i--) { - layer = this.soundingLys.get(i); - if(layer.getPressure() > upper){ - uptr = i; - break; - } - } - - - /* ----- Define parcel starting point ----- */ - tp1 = nsharpNative.nsharpLib.wetbulb(upper, nsharpNative.nsharpLib.itemp(upper), nsharpNative.nsharpLib.idwpt(upper)); - pe1 = upper; - te1 = nsharpNative.nsharpLib.itemp(pe1); - h1 = nsharpNative.nsharpLib.ihght(pe1); - float ent2; - - c1 = NsharpWxMath.getSkewTXY(pe1, tp1); - c1.x = world.mapX(c1.x); - c1.y = world.mapY(c1.y); - for (int i=uptr;i>=0;i--) { - layer = this.soundingLys.get(i); - pe2 = layer.getPressure(); - if(pe2 > Surfpressure.getValue()) - break; - te2 = layer.getTemperature(); - h2 = layer.getGeoHeight(); - tp2 = nsharpNative.nsharpLib.wetlift(pe1, tp1, pe2); - if( (nsharpNative.nsharpLib.qc(te2) == 1) && - nsharpNative.nsharpLib.qc(tp2) == 1){ - /* Account for Entrainment */ - ent2 = NsharpNativeConstants.ENTRAIN_DEFAULT * ((h1 - h2) / 1000); - tp2 = tp2 + ((te2 - tp2) * ent2); - c2 = NsharpWxMath.getSkewTXY(pe2, tp2); - c2.x = world.mapX(c2.x); - c2.y = world.mapY(c2.y); - - double [][] lines3 = {{c1.x, c1.y},{c2.x, c2.y}}; - dacpeTraceRscShape.addLineSegment(lines3); - c1 = c2; - h1 = h2; - pe1 = pe2; - tp1 = tp2; - } - } - - dacpeTraceRscShape.compile(); - } - //start FixMark:clickOnTimeStnPane - private void drawNoDataMessage(IGraphicsTarget target){ - IExtent ext = descriptor.getRenderableDisplay().getExtent(); - double xmin = ext.getMinX(); //Extent's viewable envelope min x and y - double xmax = ext.getMaxX(); - double xDefault = world.mapX(NsharpConstants.left); - if(xmin -200 && layer.getPressure() >= 100){ - t1 = nsharpNative.nsharpLib.wetbulb(layer.getPressure(), layer.getTemperature(), - layer.getDewpoint()); - - c1 = NsharpWxMath.getSkewTXY(layer.getPressure(), t1); - c1.x = world.mapX(c1.x); - c1.y = world.mapY(c1.y); - if(c2!= null){ - - double [][] lines = {{c1.x, c1.y},{c2.x, c2.y}}; - wetBulbTraceRscShape.addLineSegment(lines); - - } - c2 = c1; - } - } - wetBulbTraceRscShape.compile(); - } - private void createTurbulenceShapes(WGraphics world){ - if(turbLnShape!=null) - turbLnShape.dispose(); - turbLnShape = target.createWireframeShape(false,descriptor ); - - turbLnShape.allocate(this.soundingLys.size() * 2); - turbWindShearShape = target.createWireframeShape(false,descriptor ); - turbWindShearShape.allocate(this.soundingLys.size() * 2); - Coordinate pointALn = null; - Coordinate pointBLn=null; - Coordinate pointAWsh = null; - Coordinate pointBWsh=null; - double g= 9.8f, Ri; - double t0,t1,v0,v1, u0,u1, windshear0, windshearsqrd,tke_windshear_prod; - double pressure0=0, pressure1,midpressure0, p, high0=0,high1; - double theta1=0, theta0=0,dthetadz0,meanTheta; - boolean first=true; - NcSoundingLayer layer0, layer1; - for (int i=0; i< soundingLys.size()-1; i++) { - layer0 = soundingLys.get(i); - pressure0= layer0.getPressure(); - t0= layer0.getTemperature(); - high0= layer0.getGeoHeight(); - layer1 = soundingLys.get(i+1); - t1= layer1.getTemperature(); - high1= layer1.getGeoHeight(); - if( t0<= NsharpNativeConstants.NSHARP_NATIVE_INVALID_DATA || t1<= NsharpNativeConstants.NSHARP_NATIVE_INVALID_DATA|| - pressure0 <= NsharpConstants.TURBULENCE_PRESSURE_LEVEL_TOP ) - continue; - pressure1= layer1.getPressure(); - v0=nsharpNative.nsharpLib.iwndv((float)pressure0); - v1=nsharpNative.nsharpLib.iwndv((float)pressure1); - u0=nsharpNative.nsharpLib.iwndu((float)pressure0); - u1=nsharpNative.nsharpLib.iwndu((float)pressure1); - windshear0=Math.sqrt((u1-u0)*(u1-u0)+(v1-v0)*(v1-v0))*.51479/(high1-high0); - midpressure0 = (pressure1+pressure0)/2; - theta0=WxMath.theta(pressure0,t0, 1000)+273.15; - theta1=WxMath.theta(pressure1,t1, 1000)+273.15; - meanTheta=(theta1+theta0)/2.0f; - dthetadz0=(theta1-theta0)/(high1-high0); - if (windshear0 != 0.0 ) { - windshearsqrd=(windshear0*windshear0); - Ri=(g/meanTheta)*(dthetadz0/windshearsqrd); - world.setWorldCoordinates(NsharpConstants.TURBULENCE_LN_RICHARDSON_NUMBER_LEFT, turbBackground.toLogScale(NsharpConstants.TURBULENCE_PRESSURE_LEVEL_TOP), - NsharpConstants.TURBULENCE_LN_RICHARDSON_NUMBER_RIGHT, turbBackground.toLogScale(NsharpConstants.TURBULENCE_PRESSURE_LEVEL_BOTTOM)); - //System.out.println("world viewYmin="+world.getViewYmin()+" viewYmax="+world.getViewYmax()+" wolrdYmin="+ world.getWorldYmin()+" wolrdYmax="+ world.getWorldYmax() - // +" viewXmin="+world.getViewXmin()+" viewXmax="+world.getViewXmax()+" wolrdXmin="+ world.getWorldXmin()+" wolrdXmax="+ world.getWorldXmax()); - - pointALn = new Coordinate(); - p = turbBackground.toLogScale(midpressure0); - pointALn.x = world.mapX(Math.log(Ri)); - pointALn.y = world.mapY(p); - world.setWorldCoordinates(NsharpConstants.TURBULENCE_WIND_SHEAR_TKE_LEFT, turbBackground.toLogScale(NsharpConstants.TURBULENCE_PRESSURE_LEVEL_TOP), - NsharpConstants.TURBULENCE_WIND_SHEAR_TKE_RIGHT, turbBackground.toLogScale(NsharpConstants.TURBULENCE_PRESSURE_LEVEL_BOTTOM)); - pointAWsh = new Coordinate(); - tke_windshear_prod=0.54*(high1-high0)*windshearsqrd; - pointAWsh.x = world.mapX( tke_windshear_prod*100); - pointAWsh.y = world.mapY(p); - //System.out.println("P0="+pressure0+" dthetadz0="+dthetadz0+" theta0="+theta0+" log(Ri)="+Math.log(Ri)+ " pointAx="+pointALn.x+ " y="+pointALn.y); - if (! first) { - double [][] linesLn = {{pointALn.x, pointALn.y},{pointBLn.x, pointBLn.y}}; - double [][] linesWsh = {{pointAWsh.x, pointAWsh.y},{pointBWsh.x, pointBWsh.y}}; - turbLnShape.addLineSegment(linesLn); - turbWindShearShape.addLineSegment(linesWsh); - - } - else{ - first=false; - } - pointBLn = pointALn; - pointBWsh = pointAWsh; - } - } - - turbLnShape.compile(); - turbWindShearShape.compile(); - } - - /* - * Chin:: NOTE::: - * This plotting function is based on the algorithm of draw_ICG() at xwvid1.c of AWC Nsharp source code - * by LARRY J. HINSON AWC/KCMO - * - */ - private void createIcingRHShape(WGraphics world){ - //System.out.println("world viewYmin="+world.getViewYmin()+" viewYmax="+world.getViewYmax()+" wolrdYmin="+ world.getWorldYmin()+" wolrdYmax="+ world.getWorldYmax() - // +" viewXmin="+world.getViewXmin()+" viewXmax="+world.getViewXmax()+" wolrdXmin="+ world.getWorldXmin()+" wolrdXmax="+ world.getWorldXmax()); - - - icingRHShape = target.createWireframeShape(false,descriptor ); - icingRHShape.allocate(this.soundingLys.size() * 2); - Coordinate c0 = null; - - for (NcSoundingLayer layer : soundingLys) { - double pressure = layer.getPressure(); - if (pressure >= NsharpConstants.ICING_PRESSURE_LEVEL_TOP - && pressure <= NsharpConstants.ICING_PRESSURE_LEVEL_BOTTOM) { - - FloatByReference parm= new FloatByReference(0); - float relh= nsharpNative.nsharpLib.relh((float)pressure, parm); - Coordinate c1 = new Coordinate(); - double p = icingBackground.toLogScale(pressure); - c1.x = world.mapX(relh); - c1.y = world.mapY(p); - //System.out.println("RH="+relh+ " p="+pressure+ " x="+c1.x+ " y="+c1.y); - if (c0 != null) { - double [][] lines = {{c0.x, c0.y},{c1.x, c1.y}}; - icingRHShape.addLineSegment(lines); - } - c0 = c1; + if ((graphConfigProperty != null && graphConfigProperty + .isWindBarb() == true) || graphConfigProperty == null) { + plotWorld + .setWorldCoordinates( + NsharpConstants.ICING_RELATIVE_HUMIDITY_LEFT, + icingBackground + .toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_BOTTOM), + NsharpConstants.ICING_RELATIVE_HUMIDITY_RIGHT, + icingBackground + .toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_TOP)); + // NsharpLineProperty lp + // =linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_WIND_BARB]); + double xPos = icingBackground.getWindBarbXPosition();// 90;// + // System.out.println("ice wind x pos="+xPos); + drawNsharpWindBarb(target, zoomLevel, plotWorld, + graphConfigProperty.getWindBarbColor()/* + * lp.getLineColor( + * ) + */, + this.soundingLys, xPos, + NsharpConstants.ICING_PRESSURE_LEVEL_TOP); } + } catch (VizException e) { + // TODO Auto-generated catch block + e.printStackTrace(); } - - icingRHShape.compile(); - } + // Chin NOTE: icining wireframeshapes are created dynamically ONLY when + // icing display is to be shown + // However, Skewt wireframeshapes are created when new sounding is + // loaded. + if (icingRHShape == null) { + // current WorldCoordinates for RH already loaded + plotWorld + .setWorldCoordinates( + NsharpConstants.ICING_RELATIVE_HUMIDITY_LEFT, + icingBackground + .toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_TOP), + NsharpConstants.ICING_RELATIVE_HUMIDITY_RIGHT, + icingBackground + .toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_BOTTOM)); - private void createIcingEPIShape(WGraphics world){ - //System.out.println("world viewYmin="+world.getViewYmin()+" viewYmax="+world.getViewYmax()+" wolrdYmin="+ world.getWorldYmin()+" wolrdYmax="+ world.getWorldYmax() - // +" viewXmin="+world.getViewXmin()+" viewXmax="+world.getViewXmax()+" wolrdXmin="+ world.getWorldXmin()+" wolrdXmax="+ world.getWorldXmax()); - - - icingEPIShape = target.createWireframeShape(false,descriptor ); - icingEPIShape.allocate(this.soundingLys.size() * 2); - Coordinate pointA = null; - Coordinate pointB=null; - boolean firstround=true; - double t0,t1; - double pressure0=0, pressure1,midpressure0, p, high0=0,high1; - double const1=2500000.0/1004.0; - double theta1=0,thetase1, theta0=0,thetase0=0,mixratio0,mixratio1,dthetasedz0; - NcSoundingLayer layer0, layer1; - for (int i=0; i< soundingLys.size()-1; i++) { - layer0 = soundingLys.get(i); - layer1 = soundingLys.get(i+1); - t0= layer0.getTemperature(); - t1= layer1.getTemperature(); - pressure0 = layer0.getPressure(); - pressure1 = layer1.getPressure(); - if( t0<= NsharpNativeConstants.NSHARP_NATIVE_INVALID_DATA || t1<= NsharpNativeConstants.NSHARP_NATIVE_INVALID_DATA|| - (pressure0 < NsharpConstants.ICING_PRESSURE_LEVEL_TOP && pressure1 < NsharpConstants.ICING_PRESSURE_LEVEL_TOP)) - continue; - theta1=WxMath.theta(pressure1,t1, 1000)+273.15; - mixratio1 = WxMath.mixingRatio(pressure1, t1); - thetase1 = theta1*Math.exp(const1*mixratio1*.001/(t1+273.15)); - high1= layer1.getGeoHeight(); - theta0=WxMath.theta(pressure0,t0, 1000)+273.15; - mixratio0 = WxMath.mixingRatio(pressure0, t0); - thetase0 = theta0*Math.exp(const1*mixratio0*.001/(t0+273.15)); - high0= layer0.getGeoHeight(); - //Do D-Theta-se/dz - dthetasedz0=(thetase1-thetase0)/(high1-high0)*1E3; - midpressure0 = (pressure1+pressure0)/2; - pointA = new Coordinate(); - p = icingBackground.toLogScale(midpressure0); - pointA.x = world.mapX(dthetasedz0); - pointA.y = world.mapY(p); - if(!firstround){ - //System.out.println("Temp="+t0+ " p="+pressure0+ "pointAx="+pointA.x+ " y="+pointA.y+ " pointBx="+pointB.x+ " y="+pointB.y); - double [][] lines = {{pointA.x, pointA.y},{pointB.x, pointB.y}}; - icingEPIShape.addLineSegment(lines); - - } - else - {//this is first round, we need two pints for a line segment. We only have first point now. - firstround= false; - } - pointB = pointA; - - } - icingEPIShape.compile(); - } - /* - * Chin:: NOTE::: - * This plotting function is based on the algorithm of draw_ICG() at xwvid1.c of AWC Nsharp source code - * by LARRY J. HINSON AWC/KCMO - * - */ - private void createIcingTempShape(WGraphics world){ - //System.out.println("world viewYmin="+world.getViewYmin()+" viewYmax="+world.getViewYmax()+" wolrdYmin="+ world.getWorldYmin()+" wolrdYmax="+ world.getWorldYmax() - // +" viewXmin="+world.getViewXmin()+" viewXmax="+world.getViewXmax()+" wolrdXmin="+ world.getWorldXmin()+" wolrdXmax="+ world.getWorldXmax()); - - - icingTempShape = target.createWireframeShape(false,descriptor ); - icingTempShape.allocate(this.soundingLys.size() * 2); - Coordinate c0 = null; - - for (NcSoundingLayer layer : soundingLys) { - double t= layer.getTemperature(); - //if( t > NsharpConstants.ICING_TEMPERATURE_RIGHT || t< NsharpConstants.ICING_TEMPERATURE_LEFT) - // continue; - double pressure = layer.getPressure(); - if (pressure >= NsharpConstants.ICING_PRESSURE_LEVEL_TOP - && pressure <= NsharpConstants.ICING_PRESSURE_LEVEL_BOTTOM) { - - Coordinate c1 = new Coordinate(); - double p = icingBackground.toLogScale(pressure); - c1.x = world.mapX(t); - c1.y = world.mapY(p); - //System.out.println("Temp="+t+ " p="+pressure+ " x="+c1.x+ " y="+c1.y); - if (c0 != null) { - double [][] lines = {{c0.x, c0.y},{c1.x, c1.y}}; - icingTempShape.addLineSegment(lines); - } - c0 = c1; - } - } - - icingTempShape.compile(); - } - private void createRscPressTempCurveShape(WGraphics WGc, List soundingLays, NsharpLineProperty lineP, IGraphicsTarget target){ - IWireframeShape shapeT = target.createWireframeShape(false,descriptor ); - shapeT.allocate(soundingLays.size() * 2); - IWireframeShape shapeD = target.createWireframeShape(false,descriptor ); - shapeD.allocate(soundingLays.size() * 2); - NsharpShapeAndLineProperty shNcolorT = new NsharpShapeAndLineProperty(); - NsharpShapeAndLineProperty shNcolorD = new NsharpShapeAndLineProperty(); - double maxPressure = NsharpWxMath.reverseSkewTXY(new Coordinate(0, WGc - .getWorldYmax())).y; - double minPressure = NsharpWxMath.reverseSkewTXY(new Coordinate(0, WGc - .getWorldYmin())).y; - boolean drawTemp=true, drawDew=true; - //NsharpParametersSelectionConfigDialog configD = NsharpParametersSelectionConfigDialog.getAccess(); - graphConfigProperty = rscHandler.getGraphConfigProperty(); - if(graphConfigProperty!=null){ - drawTemp = graphConfigProperty.isTemp(); - drawDew = graphConfigProperty.isDewp(); - } - Coordinate c0 = null, c01=null; - int count=0; - for (NcSoundingLayer layer : soundingLays) { - double t, d; - t = layer.getTemperature(); - d = layer.getDewpoint(); - - double pressure = layer.getPressure(); - if (t != NsharpNativeConstants.NSHARP_NATIVE_INVALID_DATA && pressure >= minPressure - && pressure <= maxPressure) { - - Coordinate c1 = NsharpWxMath.getSkewTXY(pressure, t); - - c1.x = WGc.mapX(c1.x); - c1.y = WGc.mapY(c1.y); - if (c0 != null) { - double [][] lines = {{c0.x, c0.y},{c1.x, c1.y}}; - count++; - shapeT.addLineSegment(lines); - } - c0 = c1; - } - if (d > -999 && pressure >= minPressure - && pressure <= maxPressure) { - - Coordinate c11 = NsharpWxMath.getSkewTXY(pressure, d); - - c11.x = WGc.mapX(c11.x); - c11.y = WGc.mapY(c11.y); - if (c01 != null) { - double [][] lines = {{c01.x, c01.y},{c11.x, c11.y}}; - shapeD.addLineSegment(lines); - } - c01 = c11; - } - } - //System.out.println("createRscPressTempCurveShape T count="+ count); - shapeT.compile(); - shapeD.compile(); - - shNcolorT.setShape(shapeT); - shNcolorD.setShape(shapeD); - if(!rscHandler.isOverlayIsOn() && !rscHandler.isCompareStnIsOn() && !rscHandler.isCompareTmIsOn() && !rscHandler.isCompareSndIsOn()){ - //use default color - - if(linePropertyMap!=null){ - shNcolorT.setLp( linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_TEMP]));//chin new config NsharpConstants.color_red; - shNcolorD.setLp( linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_DEWP]));//NsharpConstants.color_green; - } - } - else - { - shNcolorT.setLp( lineP); - shNcolorD.setLp( lineP); - } - //check draw temp and dew here. It is easier to do this way, otherwise, we have to check it every where - if(drawTemp) - pressureTempRscShapeList.add(shNcolorT); - else - shNcolorT.getShape().dispose(); - if(drawDew) - pressureTempRscShapeList.add(shNcolorD); - else - shNcolorD.getShape().dispose(); - } - public void createRscPressTempCurveShapeAll(IGraphicsTarget target){ - - if(pressureTempRscShapeList.size()>0){ - for(NsharpShapeAndLineProperty shapeColor: pressureTempRscShapeList){ - shapeColor.getShape().dispose(); - } - pressureTempRscShapeList.clear(); - } - - int currentTimeListIndex = rscHandler.getCurrentTimeElementListIndex(); - int currentStnListIndex = rscHandler.getCurrentStnElementListIndex(); - int currentSndListIndex = rscHandler.getCurrentSndElementListIndex(); - List stnElemList = rscHandler.getStnElementList(); - List timeElemList = rscHandler.getTimeElementList(); - List sndElemList = rscHandler.getSndElementList(); - List>> stnTimeSndTable = rscHandler.getStnTimeSndTable(); - if(rscHandler.isCompareStnIsOn()&& currentTimeListIndex >=0 && currentSndListIndex >=0){ - int colorIndex ; - for(NsharpOperationElement elm: stnElemList) { - if(elm.getActionState() == NsharpConstants.ActState.ACTIVE && - stnTimeSndTable.get(stnElemList.indexOf(elm)).get(currentTimeListIndex).get(currentSndListIndex)!=null){ - List soundingLayeys = stnTimeSndTable.get(stnElemList.indexOf(elm)).get(currentTimeListIndex).get(currentSndListIndex).getSndLyLst(); - colorIndex = stnTimeSndTable.get(stnElemList.indexOf(elm)).get(currentTimeListIndex).get(currentSndListIndex).getCompColorIndex(); - NsharpLineProperty lp = linePropertyMap.get(NsharpConstants.lineNameArray[colorIndex]); - createRscPressTempCurveShape(world, soundingLayeys, lp, target); - } - } - } - else if(rscHandler.isCompareTmIsOn() && currentStnListIndex >=0 && currentSndListIndex >=0){ - int colorIndex; - for(NsharpOperationElement elm: timeElemList) { - if(elm.getActionState() == NsharpConstants.ActState.ACTIVE && - stnTimeSndTable.get(currentStnListIndex).get(timeElemList.indexOf(elm)).get(currentSndListIndex)!=null){ - List soundingLayeys = stnTimeSndTable.get(currentStnListIndex).get(timeElemList.indexOf(elm)).get(currentSndListIndex).getSndLyLst(); - colorIndex = stnTimeSndTable.get(currentStnListIndex).get(timeElemList.indexOf(elm)).get(currentSndListIndex).getCompColorIndex(); - NsharpLineProperty lp = linePropertyMap.get(NsharpConstants.lineNameArray[colorIndex]); - createRscPressTempCurveShape(world, soundingLayeys, lp, target); - } - } - } - else if(rscHandler.isCompareSndIsOn() & currentStnListIndex >=0 && currentTimeListIndex >=0){ - int colorIndex; - for(NsharpOperationElement elm: sndElemList) { - if(elm.getActionState() == NsharpConstants.ActState.ACTIVE && - stnTimeSndTable.get(currentStnListIndex).get(currentTimeListIndex).get(sndElemList.indexOf(elm))!=null){ - List soundingLayeys = stnTimeSndTable.get(currentStnListIndex).get(currentTimeListIndex).get(sndElemList.indexOf(elm)).getSndLyLst(); - colorIndex = stnTimeSndTable.get(currentStnListIndex).get(currentTimeListIndex).get(sndElemList.indexOf(elm)).getCompColorIndex(); - NsharpLineProperty lp = linePropertyMap.get(NsharpConstants.lineNameArray[colorIndex]); - createRscPressTempCurveShape(world, soundingLayeys, lp, target); - } - } - } - else if(rscHandler.isOverlayIsOn() == true ){ - - previousSoundingLys = rscHandler.getPreviousSoundingLys(); - createRscPressTempCurveShape(world, this.soundingLys, linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_OVERLAY1]), target); - if(this.previousSoundingLys!=null && !previousSoundingLys.equals(soundingLys)){ - createRscPressTempCurveShape(world, this.previousSoundingLys, linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_OVERLAY2]), target); - } - - } - else { - - createRscPressTempCurveShape(world, this.soundingLys, null, target); - } - } - - public void createRscVTempTraceShape(){ - - if((soundingLys == null) || (soundingLys.size()==0)) - return; - float t1; - if(vtempTraceCurveRscShape!=null){ - vtempTraceCurveRscShape.dispose(); - vtempTraceCurveRscShape=null; - } - - Coordinate c2 = null; - Coordinate c1; - // draw trace - vtempTraceCurveRscShape = target.createWireframeShape(false,descriptor ); - vtempTraceCurveRscShape.allocate(this.soundingLys.size() * 2); - for (NcSoundingLayer layer : this.soundingLys) { - if ((layer.getTemperature() != NsharpNativeConstants.NSHARP_NATIVE_INVALID_DATA) && (layer.getDewpoint() != NsharpNativeConstants.NSHARP_NATIVE_INVALID_DATA) && layer.getPressure()>= 100){ - t1 = nsharpNative.nsharpLib.ivtmp(layer.getPressure()); - - c1 = NsharpWxMath.getSkewTXY(layer.getPressure(), t1); - c1.x = world.mapX(c1.x); - c1.y = world.mapY(c1.y); - if(c2!= null){ - //target.drawLine(c1.x, c1.y, 0.0, c2.x, c2.y, 0.0, color, - // lineWidth, LineStyle.DASHED); - double [][] lines = {{c1.x, c1.y},{c2.x, c2.y}}; - vtempTraceCurveRscShape.addLineSegment(lines); - } - c2 = c1; - } + createIcingRHShape(plotWorld); } - vtempTraceCurveRscShape.compile(); - } - /* - * Chin:: NOTE::: - * This plotting function is based on the algorithm of draw_Clouds() at xwvid1.c of AWC Nsharp source code - * Using Fred Mosher's Algorithm & Chernykh and Eskridge Algorithm - * - */ - private void createCloudsShape() { - NsharpNative.NsharpLibrary.CloudInfoStr cloudInfo = new NsharpNative.NsharpLibrary.CloudInfoStr(); - nsharpNative.nsharpLib.draw_Clouds(cloudInfo); - // draw FM model: Fred Mosher's Algorithm - if(cloudInfo.getSizeFM() > 0){ - cloudFMShape = target.createShadedShape(false, descriptor, false); - cloudFMLabelShape = target.createWireframeShape(false,descriptor ); - cloudFMLabelShape.allocate(2); - double [][] lines = {{0, 0},{0,0}}; - cloudFMLabelShape.addLineSegment(lines); - for (int i=0; i < cloudInfo.getSizeFM() ; i++){ - double lowY = world.mapY(NsharpWxMath.getSkewTXY(cloudInfo.getPreStartFM()[i], -50).y); - double highY = world.mapY(NsharpWxMath.getSkewTXY(cloudInfo.getPreEndFM()[i], -50).y); - Coordinate[] coords = new Coordinate[4]; - coords[0] = new Coordinate(skewtXOrig+150, lowY); - coords[1] = new Coordinate(skewtXOrig+200, lowY); - coords[2] = new Coordinate(skewtXOrig+200, highY); - coords[3] = new Coordinate(skewtXOrig+150, highY); - - /* - * Create LineString[] from Coordinates[] - */ - GeometryFactory gf = new GeometryFactory(); - LineString[] ls = new LineString[] { gf.createLineString(coords) }; - - cloudFMShape.addPolygonPixelSpace(ls, NsharpConstants.color_yellow); - double [] lblXy = { skewtXOrig+175, (lowY+highY)/2}; - cloudFMLabelShape.addLabel(NsharpNative.NsharpLibrary.CLOUD_TYPE[cloudInfo.cloudTypeFM[i]], lblXy); - } - cloudFMShape.compile(); - cloudFMLabelShape.compile(); - } - // draw CE model : Chernykh and Eskridge Algorithm - if(cloudInfo.getSizeCE() > 0){ - cloudCEShape = target.createShadedShape(false, descriptor, false); - - for (int i=0; i < cloudInfo.getSizeCE() ; i++){ - double lowY = world.mapY(NsharpWxMath.getSkewTXY(cloudInfo.getPreStartCE()[i], -50).y); - double highY = world.mapY(NsharpWxMath.getSkewTXY(cloudInfo.getPreEndCE()[i], -50).y); - Coordinate[] coords = new Coordinate[4]; - coords[0] = new Coordinate(skewtXOrig+100, lowY); - coords[1] = new Coordinate(skewtXOrig+150, lowY); - coords[2] = new Coordinate(skewtXOrig+150, highY); - coords[3] = new Coordinate(skewtXOrig+100, highY); - - /* - * Create LineString[] from Coordinates[] - */ - GeometryFactory gf = new GeometryFactory(); - LineString[] ls = new LineString[] { gf.createLineString(coords) }; - - cloudCEShape.addPolygonPixelSpace(ls, NsharpConstants.color_red); - - } - cloudCEShape.compile(); - - } + if (icingRHShape != null) { + NsharpLineProperty lp = linePropertyMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_ICING_RH]); + target.drawWireframeShape(icingRHShape, lp.getLineColor(), + lp.getLineWidth(), lp.getLineStyle(), font10); + } + if (icingTempShape == null) { + plotWorld + .setWorldCoordinates( + NsharpConstants.ICING_TEMPERATURE_LEFT, + icingBackground + .toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_TOP), + NsharpConstants.ICING_TEMPERATURE_RIGHT, + icingBackground + .toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_BOTTOM)); + createIcingTempShape(plotWorld); + } + if (icingTempShape != null) { + NsharpLineProperty lp = linePropertyMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_ICING_TEMP]); + target.drawWireframeShape(icingTempShape, lp.getLineColor(), + lp.getLineWidth(), lp.getLineStyle(), font10); + } + if (icingEPIShape == null) { + plotWorld + .setWorldCoordinates( + NsharpConstants.ICING_TEMPERATURE_LEFT, + icingBackground + .toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_TOP), + NsharpConstants.ICING_TEMPERATURE_RIGHT, + icingBackground + .toLogScale(NsharpConstants.ICING_PRESSURE_LEVEL_BOTTOM)); + createIcingEPIShape(plotWorld); + } + if (icingEPIShape != null) { + NsharpLineProperty lp = linePropertyMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_ICING_EPI]); + target.drawWireframeShape(icingEPIShape, lp.getLineColor(), + lp.getLineWidth(), lp.getLineStyle(), font10); + } + + target.clearClippingPlane(); + } - @SuppressWarnings("unused") - private void createRscOmegaShape(){ - //draw label and vertical lines - omegaBkgShape = target.createWireframeShape(false,descriptor ); - omegaBkgShape.allocate(6); - IExtent ext = descriptor.getRenderableDisplay().getExtent(); - float xmin = (float) ext.getMinX(); - //System.out.println("ex xmin="+ xmin+ " ymin= "+ ext.getMinY() + " ymax="+ ext.getMaxY()); - float xWoldMin = (float)world.mapX(NsharpConstants.left); - if(xmin > xWoldMin) - omegaXOrig = xmin+40*xRatio*(float)currentZoomLevel; - else - omegaXOrig = xWoldMin+40*xRatio*(float)currentZoomLevel; - //we dont really care about temp, as we use pressure for Y axis. - //left dash line - double [][] lines = {{omegaXOrig+omegaWidth*currentZoomLevel, omegaYOrig},{omegaXOrig+omegaWidth*currentZoomLevel, omegaYEnd}}; - omegaBkgShape.addLineSegment(lines); - //center line - double [][] lines1 = {{omegaXOrig+omegaWidth*currentZoomLevel*0.5f, omegaYOrig},{omegaXOrig+omegaWidth*currentZoomLevel*0.5f, omegaYEnd}}; - omegaBkgShape.addLineSegment(lines1); - //right dash line, - double [][] lines2 = {{omegaXOrig, omegaYOrig},{omegaXOrig, omegaYEnd}}; - omegaBkgShape.addLineSegment(lines2); - double [] lblXy = {omegaXOrig+omegaWidth*currentZoomLevel*0.5f, omegaYOrig+10*yRatio}; - omegaBkgShape.addLabel("+1 OMEGA -1", lblXy); - omegaBkgShape.compile(); - omegaRscShape = target.createWireframeShape(false,descriptor ); - omegaRscShape.allocate(soundingLys.size() * 2); - float p, omega, t; - double xAxisOrigin=omegaXOrig+omegaWidth*currentZoomLevel*0.5f; - for (NcSoundingLayer layer : this.soundingLys) { - p = layer.getPressure(); - t = layer.getTemperature(); - if (layer.getOmega() > -999){ - omega = -layer.getOmega()* omegaWidth*(float)currentZoomLevel*0.5f; - Coordinate c1 = NsharpWxMath.getSkewTXY(p, t); - Coordinate c2 = new Coordinate();; - c2.y = world.mapY(c1.y); // what we need here is only pressure for Y-axix, - //System.out.println("p="+p+" t=" + t+" c1y="+c1.y+ " c2y="+c2.y); - double [][] lines3 = {{xAxisOrigin, c2.y},{xAxisOrigin+ omega, c2.y}}; - omegaRscShape.addLineSegment(lines3); - } + private void paintTurbulence(double zoomLevel, IGraphicsTarget target) + throws VizException { + WGraphics plotWorld = turbBackground.getWorld(); + target.setupClippingPlane(turbBackground.getPe()); + // Chin NOTE: turbulence wireframeshapes are created dynamically ONLY + // when turbulence display is to be shown + // However, Skewt wireframeshapes are created when new sounding is + // loaded. + try { + // Chin:NOTE: LN Richardson number is plotted with positive number + // increase to left and netagive number decrease to its right side. + // Therefore, we have to set its world X coordintion in a reverse + // way as plotting Icing wind barb. + if ((graphConfigProperty != null && graphConfigProperty + .isWindBarb() == true) || graphConfigProperty == null) { + plotWorld + .setWorldCoordinates( + NsharpConstants.TURBULENCE_LN_RICHARDSON_NUMBER_RIGHT, + turbBackground + .toLogScale(NsharpConstants.TURBULENCE_PRESSURE_LEVEL_BOTTOM), + NsharpConstants.TURBULENCE_LN_RICHARDSON_NUMBER_LEFT, + turbBackground + .toLogScale(NsharpConstants.TURBULENCE_PRESSURE_LEVEL_TOP)); + // NsharpLineProperty lp + // =linePropertyMap.get(NsharpConstants.lineNameArray[NsharpConstants.LINE_WIND_BARB]); + double xPos = turbBackground.getWindBarbXPosition(); + // System.out.println("turb wind x pos="+xPos); + drawNsharpWindBarb(target, zoomLevel, plotWorld, + graphConfigProperty.getWindBarbColor()/* + * lp.getLineColor( + * ) + */, + this.soundingLys, xPos/* 7 */, + NsharpConstants.TURBULENCE_PRESSURE_LEVEL_TOP); + } + } catch (VizException e) { + // TODO Auto-generated catch block + e.printStackTrace(); } - omegaRscShape.compile(); - } - // Chin: to handle dynamically moving omega within viewable zone when zooming, I could not use wireframeShape successfully - // It will chop off lower part of omega. Therefore use this draw function for omega. - @SuppressWarnings("deprecation") - private void drawOmega() { - //draw label and vertical lines - IExtent ext = descriptor.getRenderableDisplay().getExtent(); - float xmin = (float) ext.getMinX(); - //System.out.println("ex xmin="+ xmin+ " ymin= "+ ext.getMinY() + " ymax="+ ext.getMaxY()); - float xWoldMin = (float)world.mapX(NsharpConstants.left); - if(xmin > xWoldMin) - omegaXOrig = xmin+40*xRatio*(float)currentZoomLevel; - else - omegaXOrig = xWoldMin+40*xRatio*(float)currentZoomLevel; - //we dont really care about temp, as we use pressure for Y axis. - try { - //left dash line - target.drawLine( omegaXOrig+omegaWidth*currentZoomLevel, omegaYOrig, 0.0, omegaXOrig+omegaWidth*currentZoomLevel, omegaYEnd, 0.0, - NsharpConstants.color_violet_red, 1,LineStyle.DASHED); + if (turbLnShape == null || turbWindShearShape == null) { + createTurbulenceShapes(plotWorld); + } + if (turbLnShape != null) { + NsharpLineProperty lp = linePropertyMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_TURBULENCE_LN]); + target.drawWireframeShape(turbLnShape, lp.getLineColor(), + lp.getLineWidth(), lp.getLineStyle(), font10); - //center line - target.drawLine(omegaXOrig+omegaWidth*currentZoomLevel*0.5f, omegaYOrig, 0.0, omegaXOrig+omegaWidth*currentZoomLevel*0.5f, omegaYEnd, 0.0, - NsharpConstants.color_violet_red, 1,LineStyle.DASHED); - //right dash line, - target.drawLine(omegaXOrig, omegaYOrig, 0.0, omegaXOrig, omegaYEnd, 0.0, - NsharpConstants.color_violet_red, 1,LineStyle.DASHED); - target.drawString(font10,"+1 OMEGA -1", omegaXOrig+omegaWidth*currentZoomLevel*0.5f, omegaYOrig+10*yRatio, 0.0, TextStyle.NORMAL, - NsharpConstants.color_violet_red, HorizontalAlignment.CENTER, - VerticalAlignment.BOTTOM, null); + } + if (turbWindShearShape != null) { + NsharpLineProperty lp = linePropertyMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_TURBULENCE_WS]); + target.drawWireframeShape(turbWindShearShape, lp.getLineColor(), + lp.getLineWidth(), lp.getLineStyle(), font10); + } + target.clearClippingPlane(); - float p, omega, t; - double xAxisOrigin=omegaXOrig+omegaWidth*currentZoomLevel*0.5f; - for (NcSoundingLayer layer : this.soundingLys) { - p = layer.getPressure(); - t = layer.getTemperature(); - if (layer.getOmega() > -999){ - omega = -layer.getOmega()* omegaWidth*(float)currentZoomLevel*0.5f; - Coordinate c1 = NsharpWxMath.getSkewTXY(p, t); - Coordinate c2 = new Coordinate();; - c2.y = world.mapY(c1.y); // what we need here is only pressure for Y-axix, - //System.out.println("p="+p+" t=" + t+" c1y="+c1.y+ " c2y="+c2.y); - target.drawLine(xAxisOrigin, c2.y, 0.0,xAxisOrigin+ omega, c2.y, 0.0, - NsharpConstants.color_cyan, 1); - } - } - } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } + } - /** - * Create all wire frame shapes at one place. - * Should be used only when a new resource is becoming Current active resource to be displayed. - * - */ - - public void createRscWireFrameShapes(){ - //System.out.println("createRscWireFrameShapes called"); - if(target!=null){ - disposeRscWireFrameShapes(); - if(soundingLys != null){ - //createRscOmegaShape(); - //createRscHeightMarkShape(); - createRscwetBulbTraceShape(); - createRscPressTempCurveShapeAll(target); - createRscVTempTraceShape(); - createRscParcelRtTraceShapesList(rscHandler.getCurrentParcel(),rscHandler.getCurrentParcelLayerPressure());//real temp trace - createRscParcelTraceShapes(rscHandler.getCurrentParcel(),rscHandler.getCurrentParcelLayerPressure()); //Virtual Temp Trace and DCAPE trace - createLCLEtcLinesShape(); - createEffectiveLayerLinesShape(); - createCloudsShape(); - updatePsblWatchColor(); - } - } - } - - public void disposeRscWireFrameShapes(){ - if(omegaBkgShape!=null){ - omegaBkgShape.dispose(); - omegaBkgShape=null; - } - if(omegaRscShape!=null){ - omegaRscShape.dispose(); - omegaRscShape=null; - } - if(heightMarkRscShape!=null){ - heightMarkRscShape.dispose(); - heightMarkRscShape=null; - } - if(wetBulbTraceRscShape!=null){ - wetBulbTraceRscShape.dispose(); - wetBulbTraceRscShape=null; - } - if(vtempTraceCurveRscShape!=null){ - vtempTraceCurveRscShape.dispose(); - vtempTraceCurveRscShape=null; - } - if(cloudFMShape!=null){ - cloudFMShape.dispose(); - cloudFMShape=null; - } - if(cloudCEShape!=null){ - cloudCEShape.dispose(); - cloudCEShape=null; - } - if(cloudFMLabelShape!=null){ - cloudFMLabelShape.dispose(); - cloudFMLabelShape=null; - } - if(icingTempShape!=null){ - icingTempShape.dispose(); - icingTempShape= null; - } - if(icingRHShape!=null){ - icingRHShape.dispose(); - icingRHShape=null; - } - if(icingEPIShape!=null){ - icingEPIShape.dispose(); - icingEPIShape=null; - } - if(turbWindShearShape!=null){ - turbWindShearShape.dispose(); - turbWindShearShape=null; - } - if(turbLnShape!=null){ - turbLnShape.dispose(); - turbLnShape=null; - } - if(parcelRtShapeList.size()>0){ - for(NsharpShapeAndLineProperty shapeColor: parcelRtShapeList){ - shapeColor.getShape().dispose(); - } - parcelRtShapeList.clear(); - } - if(parcelVtTraceRscShape != null){ - parcelVtTraceRscShape.dispose(); - parcelVtTraceRscShape = null; - } - if(dacpeTraceRscShape != null){ - dacpeTraceRscShape.dispose(); - dacpeTraceRscShape = null; - } - if(pressureTempRscShapeList.size()>0){ - for(NsharpShapeAndLineProperty shapeColor: pressureTempRscShapeList){ - shapeColor.getShape().dispose(); - } - pressureTempRscShapeList.clear(); + public void updatePsblWatchColor() { + int wwtype = nsharpNative.nsharpLib.cave_ww_type(); - } - if(lclShape != null){ - lclShape.dispose(); - lclShape = null; - } - if(elShape != null){ - elShape.dispose(); - elShape = null; - } - if(fzlShape != null){ - fzlShape.dispose(); - fzlShape = null; - } - if(lfcShape != null){ - lfcShape.dispose(); - lfcShape = null; - } - } - /* - * Return the closest wind barb origin point to the input point - * Also set currentWindBarbSoundingLayerIndex for wind barb magnification plotting later - */ - public Coordinate findClosestWindBarbPoint(Coordinate currentCursorSkewTCoord){ - //wind barb X position - double windX = skewTBackground.getWindBarbXPosition(); - - Coordinate currentCursorPresTempCoord = NsharpWxMath.reverseSkewTXY(world.unMap(currentCursorSkewTCoord)); - double curCursorPressure = currentCursorPresTempCoord.y; - double curCursorTemp = currentCursorPresTempCoord.x; - double prevPressure=1000; - double prevT=0; - Coordinate closetWindBarbCoord = new Coordinate(0,0,0); - - /* - * Note: soundingLys list sorted with highest pressure as first element - */ - for (NcSoundingLayer layer : this.soundingLys) { - - if( layer.getPressure() < 100 ) - continue; - double pressure = layer.getPressure(); - double temperatureAtWBOrigin; - // get windBrb Y position at temp 0 - double windY = NsharpWxMath.getSkewTXY(pressure, 0).y; + // System.out.println("sk ww type="+ wwtype); + // See nsharpNative.nsharpLib.cave_ww_type() for returned wwtype + // definitions + switch (wwtype) { + case 1: + wwTypeColor = NsharpConstants.color_skyblue; + break; + case 2: + wwTypeColor = NsharpConstants.color_cyan; + break; + case 3: + wwTypeColor = NsharpConstants.color_red; + break; + case 4: + wwTypeColor = NsharpConstants.color_red; + break; + case 5: + wwTypeColor = NsharpConstants.color_magenta; + break; + default: + wwTypeColor = NsharpConstants.color_gold; + break; + } + } - // get wind barb temperature at windX(= skewTBackground.getWindBarbXPosition()), windY - temperatureAtWBOrigin = NsharpWxMath.reverseSkewTXY(new Coordinate(windX,windY)).x; - //System.out.println(" pressure "+ pressure + " temp "+ temperatureAtWBOrigin + " prevPressure="+prevPressure); - if( pressure <= curCursorPressure){ - // decide which pressure (layer) should be used. current one or previous one - double disCurrentP = Math.abs(pressure -curCursorPressure ); - double disPreviousP = Math.abs(prevPressure -curCursorPressure ); - double pickedPressure, pickedTemp; + private void drawNsharpFileNameAndSampling(IGraphicsTarget target, + double zoomLevel) throws VizException { + double dispX, xmin; + double dispY, ymin; + IExtent ext = getDescriptor().getRenderableDisplay().getExtent(); + xmin = ext.getMinX(); // Extent's viewable envelope min x and y + ymin = ext.getMinY(); + dispX = xmin + 20 * zoomLevel * xRatio; + dispY = ymin + 35 * zoomLevel * yRatio; + double hRatio = paintProps.getView().getExtent().getWidth() + / paintProps.getCanvasBounds().width; + double vRatio = paintProps.getView().getExtent().getHeight() + / paintProps.getCanvasBounds().height; + // System.out.println("zoomLevel="+zoomLevel+" xmin="+xmin+" dispX="+dispX); + RGB pickedStnColor = NsharpConstants.color_green; + String pickedStnInfoStr = ""; + String latlon = ""; + if (rscHandler.isOverlayIsOn()) { + NsharpSoundingElementStateProperty preSndProfileProp = rscHandler + .getPreSndProfileProp(); + if (preSndProfileProp != null) { + pickedStnColor = linePropertyMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_OVERLAY2]) + .getLineColor(); + String stnInfoStr = preSndProfileProp.getElementDescription(); + latlon = Math + .rint(preSndProfileProp.getStnInfo().getLatitude() * 100) + / 100 + + "," + + Math.rint(preSndProfileProp.getStnInfo() + .getLongitude() * 100) / 100; + DrawableString str = new DrawableString(stnInfoStr, + pickedStnColor); + str.font = font20; // d2dlite + str.setCoordinates(dispX + 300 * zoomLevel * xRatio, dispY); + str.horizontalAlignment = HorizontalAlignment.LEFT; + str.verticallAlignment = VerticalAlignment.TOP; + DrawableString latlonstr = new DrawableString(latlon, + pickedStnColor); + latlonstr.font = font20; // d2dlite + latlonstr.setCoordinates(dispX + 300 * zoomLevel * xRatio, + dispY + target.getStringsBounds(str).getHeight() + * vRatio); + latlonstr.horizontalAlignment = HorizontalAlignment.LEFT; + latlonstr.verticallAlignment = VerticalAlignment.TOP; + target.drawStrings(str, latlonstr); + } + pickedStnColor = linePropertyMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_OVERLAY1]) + .getLineColor(); + } + // dispX = skewtXOrig+20; + pickedStnInfoStr = rscHandler.getPickedStnInfoStr(); - if(disPreviousP <= disCurrentP){ - pickedPressure = prevPressure; - pickedTemp = prevT; + // Also draw stn lat/lon info string and sounding type string + NsharpStationInfo pickedStnInfo = rscHandler.getPickedStnInfo(); + if (pickedStnInfo != null) { + latlon = Math.rint(pickedStnInfo.getLatitude() * 100) / 100 + "," + + Math.rint(pickedStnInfo.getLongitude() * 100) / 100; + } - if(this.soundingLys.indexOf(layer) == 0) - currentWindBarbSoundingLayerIndex = this.soundingLys.indexOf(layer); - else - currentWindBarbSoundingLayerIndex = this.soundingLys.indexOf(layer)-1; - } - else { - pickedPressure = pressure; - pickedTemp = temperatureAtWBOrigin; + DrawableString str = new DrawableString(pickedStnInfoStr, + pickedStnColor); + str.font = font20; // d2dlite + str.setCoordinates(dispX, dispY); + str.horizontalAlignment = HorizontalAlignment.LEFT; + str.verticallAlignment = VerticalAlignment.TOP; + DrawableString latlonstr = new DrawableString(latlon, pickedStnColor); + latlonstr.font = font20; // d2dlite + latlonstr.setCoordinates(dispX, dispY + + target.getStringsBounds(str).getHeight() * vRatio); + latlonstr.horizontalAlignment = HorizontalAlignment.LEFT; + latlonstr.verticallAlignment = VerticalAlignment.TOP; + Rectangle2D rect = target.getStringsBounds(str); + // rect.setRect(rect.getX(), rect.getY(), rect.getWidth(), + // 2 * rect.getHeight()); + PixelExtent boxExt; + if (cursorInSkewT == true) { + double boxMinX = dispX, boxMinY = dispY, sampleStrsWidth; + dispY = dispY + target.getStringsBounds(str).getHeight() * vRatio; + // draw dynamic temp, theta, height + // Column 1: pressure, C and F + DrawableString str1 = new DrawableString(sPressure + " ", + NsharpConstants.color_white); + str1.font = font20; + dispY = dispY + target.getStringsBounds(str).getHeight() * vRatio; + str1.setCoordinates(dispX, dispY); + str1.horizontalAlignment = HorizontalAlignment.LEFT; + str1.verticallAlignment = VerticalAlignment.TOP; + DrawableString str2 = new DrawableString(sTemperatureC, + NsharpConstants.color_red); + str2.font = font20; + dispY = dispY + target.getStringsBounds(str).getHeight() * vRatio; + str2.setCoordinates(dispX, dispY); + str2.horizontalAlignment = HorizontalAlignment.LEFT; + str2.verticallAlignment = VerticalAlignment.TOP; + DrawableString str3 = new DrawableString(sTemperatureF, + NsharpConstants.color_red); + str3.font = font20; + dispY = dispY + target.getStringsBounds(str).getHeight() * vRatio; + str3.setCoordinates(dispX, dispY); + str3.horizontalAlignment = HorizontalAlignment.LEFT; + str3.verticallAlignment = VerticalAlignment.TOP; - currentWindBarbSoundingLayerIndex = this.soundingLys.indexOf(layer); - } - double disTemp = Math.abs(pickedTemp- curCursorTemp); - //if distancw is not within 5 * currentZoomLevel degree, then return with (0,0); - if(disTemp > 5 * currentZoomLevel){ - setCursorTopWindBarb(false); - return closetWindBarbCoord; - } - else { - //System.out.println("pickedP="+pickedPressure+" pickedT="+pickedTemp+ " inPressure"+inPressure+" inTemp="+ inTemp+" temp dis="+disTemp+ " rangeT="+ 5 * currentZoomLevel); - closetWindBarbCoord = NsharpWxMath.getSkewTXY(pickedPressure, pickedTemp); - closetWindBarbCoord = world.map(closetWindBarbCoord); - setCursorTopWindBarb(true); - return closetWindBarbCoord; - } - } - prevPressure = pressure; - prevT = temperatureAtWBOrigin; - - } - //This is the case that inC is above highest layer (lowest pressure), then we picked highest layer, if within temp range - if(Math.abs(prevT- curCursorTemp) > 5 * currentZoomLevel){ - setCursorTopWindBarb(false); - return closetWindBarbCoord; - } - closetWindBarbCoord = NsharpWxMath.getSkewTXY(prevPressure, prevT); - closetWindBarbCoord = world.map(closetWindBarbCoord); - //System.out.println("pickedP="+prevPressure+" pickedT="+prevT+ " inPressure"+inPressure+" inTemp="+ inTemp); - setCursorTopWindBarb(true); - return closetWindBarbCoord; - } - /* - * Return the closest point to the input point on either Temp or Dewpoint trace line - * Also set currentSoundingLayerIndex for plotting later - */ - public Coordinate getPickedTempPoint(Coordinate c){ - - //System.out.println("picked pt X "+ x + " Y "+ y); - //System.out.println("picked pt CX "+ c.x + " CY "+ c.y); - - - Coordinate inC = NsharpWxMath.reverseSkewTXY(world.unMap(c)); - double inPressure = inC.y; - double inTemp = inC.x; - //System.out.println("user inout pt pressure "+ inPressure+ " temp "+inTemp ); - double prevPressure=1000; - double prevT=0, prevD=0; - Coordinate closeptC = new Coordinate(0,0,0); - boolean firstPrevPicked= false; - - /* - * Note: soundingLys list sorted with highest pressure as first element - */ - - for (NcSoundingLayer layer : this.soundingLys) { - double t, d; - t = layer.getTemperature(); - d = layer.getDewpoint(); - double pressure = layer.getPressure(); - if(firstPrevPicked==false){ - // this is to handle the case, if picked point has same pressure (largest pressure) as first layer - firstPrevPicked = true; - prevPressure = pressure; - prevT = t; - prevD = d; - } - //System.out.println(" pressure "+ pressure ); - if( pressure >= 100 && pressure <= inPressure){ - // decide which pressure (layer) should be used. current one or previous one - double disCurrentP = Math.abs(pressure -inPressure ); - double disPreviousP = Math.abs(prevPressure -inPressure ); - double pickedPressure, pickedTemp, pickedDewpoint; - if(disPreviousP <= disCurrentP){ - pickedPressure = prevPressure; - pickedTemp = prevT; - pickedDewpoint = prevD; - if(this.soundingLys.indexOf(layer) == 0) - currentSoundingLayerIndex = this.soundingLys.indexOf(layer); - else - currentSoundingLayerIndex = this.soundingLys.indexOf(layer)-1; - } - else { - pickedPressure = pressure; - pickedTemp = t; - pickedDewpoint = d; - currentSoundingLayerIndex = this.soundingLys.indexOf(layer); - } - double disTemp = Math.abs(pickedTemp- inTemp); - double disDew = Math.abs(pickedDewpoint- inTemp); - //if both dis is not witin editing distance, ie. 4 degree, then return with (0,0); - if(disTemp > 4 && disDew > 4){ - return closeptC; - } - - //decide which line, temp or dewpoint, closer to user picked point - if(disTemp <= disDew){ - closeptC = NsharpWxMath.getSkewTXY(pickedPressure, pickedTemp); - closeptC = world.map(closeptC); - currentTempCurveType = TEMP_TYPE; - //System.out.println("picked pressure "+ pickedPressure + " temp " +pickedTemp); - } - else { - closeptC = NsharpWxMath.getSkewTXY(pickedPressure, pickedDewpoint); - closeptC = world.map(closeptC); - currentTempCurveType = DEWPOINT_TYPE; - //System.out.println("picked pressure "+ pickedPressure + " dewpoint " +pickedDewpoint); - } - - //System.out.println("currentSoundingLayerIndex P = "+ this.soundingLys.get(currentSoundingLayerIndex).getPressure()); - break; - } - prevPressure = pressure; - prevT = t; - prevD = d; - } - - return closeptC; - } - public void setCursorInSkewT(boolean cursorInSkewT) { - this.cursorInSkewT = cursorInSkewT; - } - public void toggleCurseDisplay() { - curseToggledFontLevel = curseToggledFontLevel + CURSER_FONT_INC_STEP; - if(curseToggledFontLevel > CURSER_STRING_OFF) - curseToggledFontLevel = CURSER_FONT_10; - /*NsharpEditor editor = NsharpEditor.getActiveNsharpEditor(); - if (editor != null) { - editor.refresh(); - }*/ - rscHandler.refreshPane(); - } + // column 2: m, ft, mixing ratio + float heightM = nsharpNative.nsharpLib.ihght((float) dPressure); + String sHeightM = String.format("%.0fm", heightM); + dispX = dispX + target.getStringsBounds(str1).getWidth() * hRatio; + dispY = ymin + 35 * zoomLevel * yRatio + 2 + * target.getStringsBounds(str).getHeight() * vRatio; + DrawableString str4 = new DrawableString(sHeightM, + NsharpConstants.color_cyan); + str4.font = font20; + str4.setCoordinates(dispX, dispY); + str4.horizontalAlignment = HorizontalAlignment.LEFT; + str4.verticallAlignment = VerticalAlignment.TOP; + String sHeightFt = String.format("%.0fft", + NsharpConstants.metersToFeet.convert(heightM)); + DrawableString str5 = new DrawableString(sHeightFt + " ", + NsharpConstants.color_cyan); + str5.font = font20; + dispY = dispY + target.getStringsBounds(str).getHeight() * vRatio; + str5.setCoordinates(dispX, dispY); + str5.horizontalAlignment = HorizontalAlignment.LEFT; + str5.verticallAlignment = VerticalAlignment.TOP; + DrawableString str6 = new DrawableString(sMixingRatio, + NsharpConstants.color_green); + str6.font = font20; + dispY = dispY + target.getStringsBounds(str).getHeight() * vRatio; + str6.setCoordinates(dispX, dispY); + str6.horizontalAlignment = HorizontalAlignment.LEFT; + str6.verticallAlignment = VerticalAlignment.TOP; - public NsharpSkewTPaneBackground getSkewTBackground() { - return skewTBackground; - } + // column 3: Theta, ThetaW, ThetaE + dispX = dispX + target.getStringsBounds(str5).getWidth() * hRatio; + dispY = ymin + 35 * zoomLevel * yRatio + 2 + * target.getStringsBounds(str).getHeight() * vRatio; + DrawableString str7 = new DrawableString(sThetaInK, + NsharpConstants.color_yellow); + str7.font = font20; + str7.setCoordinates(dispX, dispY); + str7.horizontalAlignment = HorizontalAlignment.LEFT; + str7.verticallAlignment = VerticalAlignment.TOP; + DrawableString str8 = new DrawableString(sWThetaInK, + NsharpConstants.color_yellow); + str8.font = font20; + dispY = dispY + target.getStringsBounds(str).getHeight() * vRatio; + str8.setCoordinates(dispX, dispY); + str8.horizontalAlignment = HorizontalAlignment.LEFT; + str8.verticallAlignment = VerticalAlignment.TOP; + DrawableString str9 = new DrawableString(sEThetaInK, + NsharpConstants.color_yellow); + str9.font = font20; + dispY = dispY + target.getStringsBounds(str).getHeight() * vRatio; + str9.setCoordinates(dispX, dispY); + str9.horizontalAlignment = HorizontalAlignment.LEFT; + str9.verticallAlignment = VerticalAlignment.TOP; + sampleStrsWidth = target.getStringsBounds(str1).getWidth() + + target.getStringsBounds(str5).getWidth() + + target.getStringsBounds(str8).getWidth(); + double boxWidth; + if (rect.getWidth() < sampleStrsWidth) { + boxWidth = sampleStrsWidth + 1; + } else { + boxWidth = rect.getWidth() + 1; + } + boxExt = new PixelExtent(boxMinX, boxMinX + boxWidth * hRatio, + boxMinY - 1 * vRatio, boxMinY + rect.getHeight() * vRatio + * 5); + // blank out box, should draw this first and then draw data on top + // of it + target.drawShadedRect(boxExt, NsharpConstants.color_black, 1f, null); + target.drawStrings(str, str1, str2, str3, str4, str5, str6, str7, + str8, str9); + } else { + boxExt = new PixelExtent(dispX, dispX + (rect.getWidth() + 1) + * hRatio, dispY - 1 * vRatio, dispY + 2 * rect.getHeight() + * vRatio); + target.drawShadedRect(boxExt, NsharpConstants.color_black, 1f, null); // blank + // out + // box + } + target.drawStrings(str, latlonstr); + target.drawRect(boxExt, wwTypeColor, 2f, 1f); // box border line colored + // with "Psbl Watch Type" + // color + } - public NsharpIcingPaneBackground getIcingBackground() { - return icingBackground; - } - - public NsharpTurbulencePaneBackground getTurbBackground() { - return turbBackground; - } - public NsharpGenericPaneBackground getActiveBackground(){ - if(currentGraphMode == NsharpConstants.GRAPH_SKEWT){ - return skewTBackground; - } - else if(currentGraphMode == NsharpConstants.GRAPH_ICING){ - return icingBackground; - } - else if(currentGraphMode == NsharpConstants.GRAPH_TURB){ - return turbBackground; - } - return null; - } - public void setCurrentGraphMode(int currentGraphMode) { - this.currentGraphMode = currentGraphMode; - handleResize(); - //System.out.println("setCurrentGraphMode to "+ currentGraphMode); - if(rscHandler.getWitoPaneRsc()!=null) - //simple D2D pane does not display WITO pane - rscHandler.getWitoPaneRsc().handleResize(); - } - - public void setPlotInteractiveTemp(boolean plotInteractiveTemp) { - this.plotInteractiveTemp = plotInteractiveTemp; - } - - public void setInteractiveTempPointCoordinate( - Coordinate interactiveTempPointCoordinate) { - this.interactiveTempPointCoordinate = interactiveTempPointCoordinate; - } - - public int getCurrentTempCurveType() { - return currentTempCurveType; - } - - - public int getCurrentSkewTEditMode() { - return currentSkewTEditMode; - } - - public void setCurrentSkewTEditMode(int currentSkewTEditMode) { - this.currentSkewTEditMode = currentSkewTEditMode; - } - - @Override - public void handleResize() { - //System.out.println("NsharpSkewTPaneResource handleResize called! "+ this.toString()); - super.handleResize(); - if(getDescriptor().getRenderableDisplay() == null) - return; - IExtent ext = getDescriptor().getRenderableDisplay().getExtent(); - ext.reset(); - if (ext.getWidth() == 0.0 || ext.getHeight() == 0.0) { + @Override + protected void paintInternal(IGraphicsTarget target, + PaintProperties paintProps) throws VizException { + this.paintProps = paintProps; + super.paintInternal(target, paintProps); + if (soundingLys == null) { + drawNoDataMessage(target);// FixMark:clickOnTimeStnPane return; } - //System.out.println("skewtPane: handleResize"); - this.rectangle = new Rectangle((int)ext.getMinX(), (int) ext.getMinY(), - (int) ext.getWidth(), (int) ext.getHeight()); + // System.out.println("skew paintInternal zoomL="+currentZoomLevel); + if (rscHandler == null) + return; + // System.out.println("myPerspective="+myPerspective); + // D2D5Pane.ID_PERSPECTIVE = + // "com.raytheon.uf.viz.d2d.ui.perspectives.D2D5Pane" + if (myPerspective.equals(D2D5Pane.ID_PERSPECTIVE)) { + // rscHandler.repopulateSndgData();//CHIN swapping + if (justMoveToSidePane) { + reentryLock.lock(); + // to check a scenario that sounding data is removed while + // thread is locked + if (soundingLys == null + || (soundingLys != null && soundingLys.size() <= 0)) { + reentryLock.unlock(); + return; + } + rscHandler.repopulateSndgData(); + handleResize(); + justMoveToSidePane = false; + reentryLock.unlock(); + } else if (justBackToMainPane) { + reentryLock.lock(); + if (soundingLys == null + || (soundingLys != null && soundingLys.size() <= 0)) { + reentryLock.unlock(); + return; + } + rscHandler.repopulateSndgData();// CHIN swapping + createRscWireFrameShapes(); + justBackToMainPane = false; + reentryLock.unlock(); + NsharpPaletteWindow paletteWin = NsharpPaletteWindow + .getInstance(); + if (paletteWin != null) { + paletteWin.restorePaletteWindow(paneConfigurationName, + rscHandler.getCurrentGraphMode(), + rscHandler.isInterpolateIsOn(), + rscHandler.isOverlayIsOn(), + rscHandler.isCompareStnIsOn(), + rscHandler.isCompareTmIsOn(), + rscHandler.isEditGraphOn(), + rscHandler.isCompareSndIsOn()); + } + } + } + /* + * Chin : turn it off for now + * skewTBackground.setCurrentFont(currentFont10Size); + * icingBackground.setCurrentFont(currentFont10Size); + * skewTBackground.magnifyFont(currentZoomLevel); + * icingBackground.magnifyFont(currentZoomLevel); + */ + + if (currentGraphMode == NsharpConstants.GRAPH_SKEWT) + skewTBackground.paint(target, paintProps); + else if (currentGraphMode == NsharpConstants.GRAPH_ICING) + icingBackground.paint(target, paintProps); + else if (currentGraphMode == NsharpConstants.GRAPH_TURB) + turbBackground.paint(target, paintProps); + else + // default + skewTBackground.paint(target, paintProps); + + if (soundingLys != null) { + this.font10.setSmoothing(false); + this.font10.setScaleFont(false); + this.font9.setSmoothing(false); + this.font9.setScaleFont(false); + this.font12.setSmoothing(false); + this.font12.setScaleFont(false); + // nsharpNative.populateSndgData(soundingLys); + if (currentGraphMode == NsharpConstants.GRAPH_SKEWT) { + target.setupClippingPlane(pe); + // plot temp curve, when constructing pressureTempRscShapeList, + // it already considered + // comparison, overlay, etc..so, just draw it. + for (NsharpShapeAndLineProperty shapeNLp : pressureTempRscShapeList) { + target.drawWireframeShape(shapeNLp.getShape(), shapeNLp + .getLp().getLineColor(), shapeNLp.getLp() + .getLineWidth(), shapeNLp.getLp().getLineStyle(), + font10);// commonLinewidth*2,commonLineStyle,font10); + } + // plot real temp parcel trace, when constructing + // parcelRtShapeList, it already considered + // comparison, overlay, etc..so, just draw it. + // color is following comparison/overlay lines' configuration. + // line width and line style are following parcel line + // configuration + if (graphConfigProperty.isParcel() == true) { + NsharpLineProperty parcelLp = linePropertyMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_PARCEL]); + for (NsharpShapeAndLineProperty shapeNLp : parcelRtShapeList) { + target.drawWireframeShape(shapeNLp.getShape(), shapeNLp + .getLp().getLineColor(), parcelLp + .getLineWidth(), parcelLp.getLineStyle(), + font10);// commonLinewidth*2,commonLineStyle,font10); + } + } + boolean compareStnIsOn = rscHandler.isCompareStnIsOn(); + boolean compareSndIsOn = rscHandler.isCompareSndIsOn(); + boolean compareTmIsOn = rscHandler.isCompareTmIsOn(); + boolean editGraphOn = rscHandler.isEditGraphOn(); + boolean overlayIsOn = rscHandler.isOverlayIsOn(); + if (graphConfigProperty != null) { + if (graphConfigProperty.isTemp() == true && !compareStnIsOn + && !compareTmIsOn) { + if (editGraphOn) + plotPressureTempEditPoints(target, world, + NsharpConstants.color_red, TEMP_TYPE, + this.soundingLys); + } + // dew point curve + if (graphConfigProperty.isDewp() == true && !compareStnIsOn + && !compareTmIsOn) { + if (editGraphOn) + plotPressureTempEditPoints(target, world, + NsharpConstants.color_green, DEWPOINT_TYPE, + this.soundingLys); + } + // plot wet bulb trace + if (graphConfigProperty.isWetBulb() == true + && !compareStnIsOn && !compareTmIsOn) { + NsharpLineProperty lp = linePropertyMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_WETBULB]); + target.drawWireframeShape(wetBulbTraceRscShape, + lp.getLineColor(), lp.getLineWidth(), + lp.getLineStyle(), font10); + } + // plot virtual temperature trace + if (graphConfigProperty.isVTemp() == true + && !compareStnIsOn && !compareTmIsOn) { + NsharpLineProperty lp = linePropertyMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_VIRTUAL_TEMP]); + target.drawWireframeShape(vtempTraceCurveRscShape, + lp.getLineColor(), lp.getLineWidth(), + lp.getLineStyle(), font10); + } + // virtual temperature parcel trace curve + if (graphConfigProperty.isParcelTv() == true + && !compareStnIsOn && !compareTmIsOn + && !overlayIsOn) { + if (soundingLys.size() > 0) { + NsharpLineProperty lp = linePropertyMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_PARCEL_TV]); + target.drawWireframeShape(parcelVtTraceRscShape, + lp.getLineColor(), lp.getLineWidth(), + lp.getLineStyle(), font10); + } + } + + if (graphConfigProperty.isDcape() == true + && dacpeTraceRscShape != null && !compareStnIsOn + && !compareTmIsOn && !overlayIsOn) { + if (soundingLys.size() > 0) { + NsharpLineProperty lp = linePropertyMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_DCAPE]); + target.drawWireframeShape(dacpeTraceRscShape, + lp.getLineColor(), lp.getLineWidth(), + lp.getLineStyle(), font10); + + } + } + if (graphConfigProperty.isEffLayer() == true + && !compareStnIsOn && !compareTmIsOn) { + // draw effective layer lines + // drawEffectiveLayerLines(target); + target.drawWireframeShape(effectiveLayerLineShape, + NsharpConstants.color_cyan_md, 2, + commonLineStyle, font10); + } + // cloud + if (graphConfigProperty.isCloud() == true + && !compareStnIsOn && !compareTmIsOn) { + if (cloudFMShape != null) + target.drawShadedShape(cloudFMShape, 1f); + if (cloudFMLabelShape != null) + target.drawWireframeShape(cloudFMLabelShape, + NsharpConstants.color_chocolate, + commonLinewidth * 3, commonLineStyle, font9); + if (cloudCEShape != null) + target.drawShadedShape(cloudCEShape, 1f); + } + if (graphConfigProperty.isOmega() == true + && !compareStnIsOn && !compareTmIsOn) { + if (NsharpLoadDialog.getAccess() != null + && (NsharpLoadDialog.getAccess() + .getActiveLoadSoundingType() == NsharpLoadDialog.MODEL_SND || NsharpLoadDialog + .getAccess() + .getActiveLoadSoundingType() == NsharpLoadDialog.PFC_SND)) { + // plot omega + drawOmega(); + } + } + } else { + // by default, draw everything + if (!compareStnIsOn && !compareTmIsOn) { + if (editGraphOn) + plotPressureTempEditPoints(target, world, + NsharpConstants.color_red, TEMP_TYPE, + this.soundingLys); + // dew point curve + if (editGraphOn) + plotPressureTempEditPoints(target, world, + NsharpConstants.color_green, DEWPOINT_TYPE, + this.soundingLys); + // plot wetbulb trace + NsharpLineProperty lp = linePropertyMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_WETBULB]); + target.drawWireframeShape(wetBulbTraceRscShape, + lp.getLineColor(), lp.getLineWidth(), + lp.getLineStyle(), font10); + // plot virtual temp trace + lp = linePropertyMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_VIRTUAL_TEMP]); + target.drawWireframeShape(vtempTraceCurveRscShape, + lp.getLineColor(), lp.getLineWidth(), + lp.getLineStyle(), font10); + + // virtual temperature parcel trace curve + if (!overlayIsOn) { + lp = linePropertyMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_PARCEL_TV]); + target.drawWireframeShape(parcelVtTraceRscShape, + lp.getLineColor(), lp.getLineWidth(), + lp.getLineStyle(), font10); + if (dacpeTraceRscShape != null) { + lp = linePropertyMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_DCAPE]); + target.drawWireframeShape(dacpeTraceRscShape, + lp.getLineColor(), lp.getLineWidth(), + lp.getLineStyle(), font10); + } + } + // draw effective layer lines + // drawEffectiveLayerLines(target); + target.drawWireframeShape(effectiveLayerLineShape, + NsharpConstants.color_cyan_md, 2, + commonLineStyle, font10); + if (NsharpLoadDialog.getAccess() != null + && (NsharpLoadDialog.getAccess() + .getActiveLoadSoundingType() == NsharpLoadDialog.MODEL_SND || NsharpLoadDialog + .getAccess() + .getActiveLoadSoundingType() == NsharpLoadDialog.PFC_SND)) { + // plot omega + drawOmega(); + } + } + } + if (plotInteractiveTemp == true) { + if (currentSkewTEditMode == NsharpConstants.SKEWT_EDIT_MODE_EDITPOINT) + plotNsharpInteractiveEditingTemp(target, + currentZoomLevel, world, + NsharpConstants.color_white); + else if (currentSkewTEditMode == NsharpConstants.SKEWT_EDIT_MODE_MOVELINE) + plotNsharpMovingTempLine(target, world, + NsharpConstants.color_white); + + } + target.clearClippingPlane(); + + // Wind Barb + if ((graphConfigProperty != null && graphConfigProperty + .isWindBarb() == true) || graphConfigProperty == null) { + double xPos = skewTBackground.getWindBarbXPosition(); + if (overlayIsOn == true && this.previousSoundingLys != null) { + drawNsharpWindBarb( + target, + currentZoomLevel, + world, + linePropertyMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_OVERLAY1]) + .getLineColor(), this.soundingLys, + xPos, 100); + if (!previousSoundingLys.equals(soundingLys)) + drawNsharpWindBarb( + target, + currentZoomLevel, + world, + linePropertyMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_OVERLAY2]) + .getLineColor(), + this.previousSoundingLys, + xPos - NsharpResourceHandler.BARB_LENGTH, + 100); + } else { + if (!compareStnIsOn && !compareTmIsOn + && !compareSndIsOn) { + drawNsharpWindBarb(target, currentZoomLevel, world, + graphConfigProperty.getWindBarbColor(), + this.soundingLys, xPos, 100); + } else { + int currentTimeListIndex = rscHandler + .getCurrentTimeElementListIndex(); + int currentStnListIndex = rscHandler + .getCurrentStnElementListIndex(); + int currentSndListIndex = rscHandler + .getCurrentSndElementListIndex(); + List stnElemList = rscHandler + .getStnElementList(); + List timeElemList = rscHandler + .getTimeElementList(); + List sndElemList = rscHandler + .getSndElementList(); + List>> stnTimeSndTable = rscHandler + .getStnTimeSndTable(); + if (compareTmIsOn && currentStnListIndex >= 0 + && currentSndListIndex >= 0) { + int colorIndex; + for (NsharpOperationElement elm : timeElemList) { + if (elm.getActionState() == NsharpConstants.ActState.ACTIVE + && stnTimeSndTable + .get(currentStnListIndex) + .get(timeElemList + .indexOf(elm)) + .get(currentSndListIndex) != null) { + List soundingLayeys = stnTimeSndTable + .get(currentStnListIndex) + .get(timeElemList.indexOf(elm)) + .get(currentSndListIndex) + .getSndLyLst(); + colorIndex = stnTimeSndTable + .get(currentStnListIndex) + .get(timeElemList.indexOf(elm)) + .get(currentSndListIndex) + .getCompColorIndex(); + NsharpLineProperty lp = linePropertyMap + .get(NsharpConstants.lineNameArray[colorIndex]); + drawNsharpWindBarb(target, + currentZoomLevel, world, + lp.getLineColor(), + soundingLayeys, xPos, 100); + } + } + } else if (compareStnIsOn + && currentTimeListIndex >= 0 + && currentSndListIndex >= 0) { + int colorIndex; + for (NsharpOperationElement elm : stnElemList) { + if (elm.getActionState() == NsharpConstants.ActState.ACTIVE + && stnTimeSndTable + .get(stnElemList + .indexOf(elm)) + .get(currentTimeListIndex) + .get(currentSndListIndex) != null) { + List soundingLayeys = stnTimeSndTable + .get(stnElemList.indexOf(elm)) + .get(currentTimeListIndex) + .get(currentSndListIndex) + .getSndLyLst(); + colorIndex = stnTimeSndTable + .get(stnElemList.indexOf(elm)) + .get(currentTimeListIndex) + .get(currentSndListIndex) + .getCompColorIndex(); + NsharpLineProperty lp = linePropertyMap + .get(NsharpConstants.lineNameArray[colorIndex]); + drawNsharpWindBarb(target, + currentZoomLevel, world, + lp.getLineColor(), + soundingLayeys, xPos, 100); + } + } + } else if (compareSndIsOn + && currentStnListIndex >= 0 + && currentTimeListIndex >= 0) { + int colorIndex; + // start FixMark:nearByStnCompSnd + List sndCompElementList = rscHandler + .getCompSndSelectedElemList(); + for (NsharpResourceHandler.CompSndSelectedElem compElem : sndCompElementList) { + NsharpSoundingElementStateProperty elemProp = stnTimeSndTable + .get(compElem.getStnIndex()) + .get(compElem.getTimeIndex()) + .get(compElem.getSndIndex()); + if (sndElemList.get(compElem.getSndIndex()) + .getActionState() == NsharpConstants.ActState.ACTIVE + && elemProp != null) { + List soundingLayeys = elemProp + .getSndLyLst(); + colorIndex = elemProp + .getCompColorIndex(); + NsharpLineProperty lp = linePropertyMap + .get(NsharpConstants.lineNameArray[colorIndex]); + drawNsharpWindBarb(target, + currentZoomLevel, world, + lp.getLineColor(), + soundingLayeys, xPos, 100); + } + } + + /* + * original code for(NsharpOperationElement elm: + * sndElemList) { if(elm.getActionState() == + * NsharpConstants.ActState.ACTIVE && + * stnTimeSndTable.get(currentStnListIndex).get( + * currentTimeListIndex + * ).get(sndElemList.indexOf(elm))!=null){ + * List soundingLayeys = + * stnTimeSndTable.get(currentStnListIndex).get( + * currentTimeListIndex + * ).get(sndElemList.indexOf( + * elm)).getSndLyLst(); colorIndex = + * stnTimeSndTable.get(currentStnListIndex).get( + * currentTimeListIndex + * ).get(sndElemList.indexOf( + * elm)).getCompColorIndex(); NsharpLineProperty + * lp = + * linePropertyMap.get(NsharpConstants.lineNameArray + * [colorIndex]); drawNsharpWindBarb(target, + * currentZoomLevel, world, lp.getLineColor(), + * soundingLayeys, xPos,100); } } + */ + // end start FixMark:nearByStnCompSnd + } + } + } + // System.out.println("x1 pos"+xPos+ " x2 pos="+ (xPos - + // NsharpResourceHandler.BARB_LENGTH)); + } + drawHeightMark(target); + // draw EL, LFC, LCL, FZL, -20C, -30C lines + // drawLclLine(target); + target.drawWireframeShape(lclShape, + NsharpConstants.color_green, 2, LineStyle.SOLID, font10); + target.drawWireframeShape(elShape, NsharpConstants.color_red, + 2, LineStyle.SOLID, font10); + target.drawWireframeShape(lfcShape, + NsharpConstants.color_yellow, 2, LineStyle.SOLID, + font10); + target.drawWireframeShape(fzlShape, NsharpConstants.color_cyan, + 2, LineStyle.SOLID, font10); + drawNsharpFileNameAndSampling(target, currentZoomLevel); + // draw cursor data + if (cursorInSkewT == true) { + if ((curseToggledFontLevel < CURSER_STRING_OFF) + && (cursorTopWindBarb == false || windBarbMagnify == false)) + drawNsharpSkewtCursorData(target); + } + }// end of currentGraphMode= NsharpConstants.GRAPH_SKEWT + else if (currentGraphMode == NsharpConstants.GRAPH_ICING) { + paintIcing(currentZoomLevel, target); + } else if (currentGraphMode == NsharpConstants.GRAPH_TURB) { + paintTurbulence(currentZoomLevel, target); + } + // drawNsharpFileNameAndSampling(target, currentZoomLevel); + } + } + + @Override + protected void initInternal(IGraphicsTarget target) throws VizException { + super.initInternal(target); + currentCanvasBoundWidth = NsharpConstants.SKEWT_PANE_REC_WIDTH; + currentCanvasBoundHeight = NsharpConstants.SKEWT_PANE_REC_HEIGHT; + myDefaultCanvasWidth = NsharpConstants.SKEWT_PANE_REC_WIDTH; + myDefaultCanvasHeight = NsharpConstants.SKEWT_PANE_REC_HEIGHT; + // System.out + // .print("NsharpSkewTPaneResource ::: initInternal entered!!!!!\n"); + this.rectangle = new Rectangle(skewtXOrig, skewtYOrig, skewtWidth, + skewtHeight); pe = new PixelExtent(this.rectangle); - getDescriptor().setNewPe(pe); - //System.out.println("NsharpSkewTPaneResource handleResize called! "+ this.toString()+" RenderableDisplay="+getDescriptor().getRenderableDisplay().toString()+","+ (int)ext.getMinX()+","+ (int) ext.getMinY()+","+ - // (int) ext.getWidth()+","+ (int) ext.getHeight()); - world = new WGraphics(this.rectangle); - world.setWorldCoordinates(NsharpConstants.left, NsharpConstants.top, - NsharpConstants.right, NsharpConstants.bottom); - float prevHeight = skewtHeight; - float prevWidth = skewtWidth; - skewtXOrig = (int) (ext.getMinX()); - skewtYOrig = (int) ext.getMinY(); - skewtWidth = (int) (ext.getWidth()); - skewtHeight = (int) ext.getHeight(); - //skewtXEnd = skewtXOrig+ skewtWidth; - //skewtYEnd = skewtYOrig+ skewtHeight; - xRatio = xRatio* skewtWidth/prevWidth; - yRatio = yRatio* skewtHeight/prevHeight; - omegaYOrig = skewtYOrig; - omegaWidth = skewtWidth*0.05f; - omegaHeight = skewtHeight; - omegaYEnd = omegaYOrig + omegaHeight; - createRscWireFrameShapes(); - if(currentGraphMode== NsharpConstants.GRAPH_SKEWT) - skewTBackground.handleResize(ext); - else if(currentGraphMode == NsharpConstants.GRAPH_ICING) - icingBackground.handleResize(ext); - else if(currentGraphMode == NsharpConstants.GRAPH_TURB) - turbBackground.handleResize(ext); - - //System.out.println(descriptor.getPaneNumber()+":calling wito handle resize"); - if(rscHandler != null && rscHandler.getWitoPaneRsc()!=null ) - //simple D2D pane does not display WITO pane - rscHandler.getWitoPaneRsc().handleResize(); - } + world = new WGraphics(this.rectangle); - @Override - public void handleZooming() { - - if(heightMarkRscShape!=null) - heightMarkRscShape.dispose(); - if(omegaBkgShape!=null){ - omegaBkgShape.dispose(); - omegaBkgShape=null; - } - if(omegaRscShape!=null){ - omegaRscShape.dispose(); - omegaRscShape=null; - } - - //createRscHeightMarkShape(); - //createRscOmegaShape(); - skewTBackground.handleZooming(); - turbBackground.handleZooming(); - icingBackground.handleZooming(); - if(rscHandler.getWitoPaneRsc()!=null) - //simple D2D pane does not display WITO pane - rscHandler.getWitoPaneRsc().handleZooming(); + world.setWorldCoordinates(NsharpConstants.left, NsharpConstants.top, + NsharpConstants.right, NsharpConstants.bottom); + skewTBackground.initInternal(target); + icingBackground.initInternal(target); + turbBackground.initInternal(target); + titleBoxShape = target.createWireframeShape(false, descriptor); + titleBoxShape.allocate(8); + if (rscHandler != null) { + currentGraphMode = rscHandler.getCurrentGraphMode(); + } else + currentGraphMode = NsharpConstants.GRAPH_SKEWT; + createRscWireFrameShapes(); - } + } + + public String updateDynamicData(Coordinate c) throws VizException { + this.cursorCor = c; + try { + // System.out.println(" updateDynamicData entered!!!!!C.x="+c.x + + // " c.y="+c.y); + + if (skewTBackground.contains(c)) { + c = NsharpWxMath.reverseSkewTXY(skewTBackground.getWorld() + .unMap(c.x, c.y)); + double p_mb = c.y; + double t_C = c.x; // Celsius + double t_F = celciusToFahrenheit.convert(c.x); + double theta = celciusToKelvin.convert(WxMath.theta(p_mb, t_C, + 1000)); + double wtheta = celciusToKelvin.convert(WxMath.thetaw(p_mb, + t_C, t_C)); + double etheta = celciusToKelvin.convert(WxMath.thetae(p_mb, + t_C, t_C)); + double mixRatio = WxMath.mixingRatio(p_mb, t_C); + dPressure = p_mb; + + sPressure = String.format("%.0f mb", p_mb, + NsharpConstants.THETA_SYMBOL); + sTemperatureC = String.format("%.1f%cC", t_C, + NsharpConstants.DEGREE_SYMBOL); + sTemperatureF = String.format("%.1f%cF", t_F, + NsharpConstants.DEGREE_SYMBOL); + + sThetaInK = String.format("%c=%.0fK", + NsharpConstants.THETA_SYMBOL, theta); + sWThetaInK = String.format("%cw=%.0fK", + NsharpConstants.THETA_SYMBOL, wtheta); + sEThetaInK = String.format("%ce=%.0fK", + NsharpConstants.THETA_SYMBOL, etheta); + sMixingRatio = String.format("%.0fg/Kg", mixRatio); + } + } catch (Exception e) { + UFStatus.getHandler().handle(Priority.PROBLEM, + "Exception translating coordinate", e); + } + return ""; + } + + // Creating real temperature parcel trace shape list - considering + // normal/comparison/overlay scenarios + public void createRscParcelRtTraceShapesList(short parcelType, float userPre) { + if (target == null) + return; + if (parcelRtShapeList.size() > 0) { + for (NsharpShapeAndLineProperty shapeColor : parcelRtShapeList) { + shapeColor.getShape().dispose(); + } + parcelRtShapeList.clear(); + } + + int currentTimeListIndex = rscHandler.getCurrentTimeElementListIndex(); + int currentStnListIndex = rscHandler.getCurrentStnElementListIndex(); + int currentSndListIndex = rscHandler.getCurrentSndElementListIndex(); + List stnElemList = rscHandler + .getStnElementList(); + List timeElemList = rscHandler + .getTimeElementList(); + List sndElemList = rscHandler + .getSndElementList(); + List>> stnTimeSndTable = rscHandler + .getStnTimeSndTable(); + if (rscHandler.isCompareStnIsOn() && currentTimeListIndex >= 0 + && currentSndListIndex >= 0) { + for (NsharpOperationElement elm : stnElemList) { + if (elm.getActionState() == NsharpConstants.ActState.ACTIVE + && stnTimeSndTable.get(stnElemList.indexOf(elm)) + .get(currentTimeListIndex) + .get(currentSndListIndex) != null) { + List soundingLayeys = stnTimeSndTable + .get(stnElemList.indexOf(elm)) + .get(currentTimeListIndex).get(currentSndListIndex) + .getSndLyLst(); + int colorIndex = stnTimeSndTable + .get(stnElemList.indexOf(elm)) + .get(currentTimeListIndex).get(currentSndListIndex) + .getCompColorIndex(); + NsharpLineProperty lp = linePropertyMap + .get(NsharpConstants.lineNameArray[colorIndex]); + IWireframeShape shape = createRTParcelTraceShapes( + parcelType, userPre, soundingLayeys); + NsharpShapeAndLineProperty shNLp = new NsharpShapeAndLineProperty(); + shNLp.setShape(shape); + shNLp.setLp(lp); + parcelRtShapeList.add(shNLp); + } + } + } else if (rscHandler.isCompareTmIsOn() && currentStnListIndex >= 0 + && currentSndListIndex >= 0) { + // tk#1004int lpIndex =NsharpConstants.LINE_COMP1; + for (NsharpOperationElement elm : timeElemList) { + if (elm.getActionState() == NsharpConstants.ActState.ACTIVE + && stnTimeSndTable.get(currentStnListIndex) + .get(timeElemList.indexOf(elm)) + .get(currentSndListIndex) != null) { + List soundingLayeys = stnTimeSndTable + .get(currentStnListIndex) + .get(timeElemList.indexOf(elm)) + .get(currentSndListIndex).getSndLyLst(); + int colorIndex = stnTimeSndTable.get(currentStnListIndex) + .get(timeElemList.indexOf(elm)) + .get(currentSndListIndex).getCompColorIndex(); + NsharpLineProperty lp = linePropertyMap + .get(NsharpConstants.lineNameArray[colorIndex]); + IWireframeShape shape = createRTParcelTraceShapes( + parcelType, userPre, soundingLayeys); + NsharpShapeAndLineProperty shNLp = new NsharpShapeAndLineProperty(); + shNLp.setShape(shape); + shNLp.setLp(lp); + parcelRtShapeList.add(shNLp); + } + } + } else if (rscHandler.isCompareSndIsOn() && currentStnListIndex >= 0 + && currentTimeListIndex >= 0) { + for (NsharpOperationElement elm : sndElemList) { + if (elm.getActionState() == NsharpConstants.ActState.ACTIVE + && stnTimeSndTable.get(currentStnListIndex) + .get(currentTimeListIndex) + .get(sndElemList.indexOf(elm)) != null) { + List soundingLayeys = stnTimeSndTable + .get(currentStnListIndex).get(currentTimeListIndex) + .get(sndElemList.indexOf(elm)).getSndLyLst(); + int colorIndex = stnTimeSndTable.get(currentStnListIndex) + .get(currentTimeListIndex) + .get(sndElemList.indexOf(elm)).getCompColorIndex(); + NsharpLineProperty lp = linePropertyMap + .get(NsharpConstants.lineNameArray[colorIndex]); + IWireframeShape shape = createRTParcelTraceShapes( + parcelType, userPre, soundingLayeys); + NsharpShapeAndLineProperty shNLp = new NsharpShapeAndLineProperty(); + shNLp.setShape(shape); + shNLp.setLp(lp); + parcelRtShapeList.add(shNLp); + } + } + } else if (rscHandler.isOverlayIsOn() == true) { + previousSoundingLys = rscHandler.getPreviousSoundingLys(); + IWireframeShape shape = createRTParcelTraceShapes(parcelType, + userPre, this.soundingLys); + NsharpShapeAndLineProperty shNLp = new NsharpShapeAndLineProperty(); + shNLp.setShape(shape); + shNLp.setLp(linePropertyMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_OVERLAY1])); + parcelRtShapeList.add(shNLp); + if (this.previousSoundingLys != null + && !previousSoundingLys.equals(soundingLys)) { + shape = createRTParcelTraceShapes(parcelType, userPre, + previousSoundingLys); + shNLp = new NsharpShapeAndLineProperty(); + shNLp.setShape(shape); + shNLp.setLp(linePropertyMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_OVERLAY2])); + parcelRtShapeList.add(shNLp); + } + } else { + IWireframeShape shape = createRTParcelTraceShapes(parcelType, + userPre, this.soundingLys); + NsharpShapeAndLineProperty shNLp = new NsharpShapeAndLineProperty(); + shNLp.setShape(shape); + shNLp.setLp(linePropertyMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_PARCEL])); + parcelRtShapeList.add(shNLp); + } + } + + // Creating real temperature parcel trace shape + private IWireframeShape createRTParcelTraceShapes(short parcelType, + float userPre, List soundingLays) { + IWireframeShape parcelRtShape; + parcelRtShape = target.createWireframeShape(false, descriptor); + parcelRtShape.allocate(40); + // the input soundingLays list may not be current sounding list, + // therfore need to populate it to + // native library. + nsharpNative.populateSndgData(soundingLays); + // call native define_parcel() with parcel type and user defined + // pressure (if user defined it) + nsharpNative.nsharpLib.define_parcel(parcelType, userPre); + + _lplvalues lpvls = new _lplvalues(); + nsharpNative.nsharpLib.get_lpvaluesData(lpvls); + + float sfctemp, sfcdwpt, sfcpres; + sfctemp = lpvls.temp; + sfcdwpt = lpvls.dwpt; + sfcpres = lpvls.pres; + + FloatByReference p2 = new FloatByReference(0), t2 = new FloatByReference( + 0); + ; + nsharpNative.nsharpLib.drylift(sfcpres, sfctemp, sfcdwpt, p2, t2); + + Coordinate a1 = NsharpWxMath.getSkewTXY(sfcpres, sfctemp); + a1.x = world.mapX(a1.x); + a1.y = world.mapY(a1.y); + Coordinate a2 = NsharpWxMath.getSkewTXY(p2.getValue(), t2.getValue()); + a2.x = world.mapX(a2.x); + a2.y = world.mapY(a2.y); + + double[][] alines = { { a1.x, a1.y }, { a2.x, a2.y } }; + parcelRtShape.addLineSegment(alines); + a1 = a2; + + float t3; + for (float i = p2.getValue() - 50; i >= 100; i = i - 50) { + t3 = nsharpNative.nsharpLib + .wetlift(p2.getValue(), t2.getValue(), i); + + a2 = NsharpWxMath.getSkewTXY(i, t3); + a2.x = world.mapX(a2.x); + a2.y = world.mapY(a2.y); + double[][] alines1 = { { a1.x, a1.y }, { a2.x, a2.y } }; + parcelRtShape.addLineSegment(alines1); + a1 = a2; + } + + t3 = nsharpNative.nsharpLib.wetlift(p2.getValue(), t2.getValue(), 100); + + a2 = NsharpWxMath.getSkewTXY(100, t3); + a2.x = world.mapX(a2.x); + a2.y = world.mapY(a2.y); + double[][] alines1 = { { a1.x, a1.y }, { a2.x, a2.y } }; + parcelRtShape.addLineSegment(alines1); + + parcelRtShape.compile(); + + // re-populate sounding data back to current sounding + nsharpNative.populateSndgData(this.soundingLys); + return parcelRtShape; + } + + // Creating Virtual Temperature parcel and DCAPE trace Shapes + public void createRscParcelTraceShapes(short parcelType, float userPre) { + if (target == null) + return; + // System.out.println("createRscParcelTraceShape called defoine_parcel pType="+parcelType+" pre="+ + // userPre+ " BY:"+this.toString()); + if (parcelVtTraceRscShape != null) { + parcelVtTraceRscShape.dispose(); + parcelVtTraceRscShape = null; + } + if (dacpeTraceRscShape != null) { + dacpeTraceRscShape.dispose(); + dacpeTraceRscShape = null; + } + parcelVtTraceRscShape = target.createWireframeShape(false, descriptor); + parcelVtTraceRscShape.allocate(40); + dacpeTraceRscShape = target.createWireframeShape(false, descriptor); + dacpeTraceRscShape.allocate(40); + // call native define_parcel() with parcel type and user defined + // pressure (if user defined it) + nsharpNative.nsharpLib.define_parcel(parcelType, userPre); + + _lplvalues lpvls = new _lplvalues(); + nsharpNative.nsharpLib.get_lpvaluesData(lpvls); + + float sfctemp, sfcdwpt, sfcpres; + sfctemp = lpvls.temp; + sfcdwpt = lpvls.dwpt; + sfcpres = lpvls.pres; + + float vtemp = nsharpNative.nsharpLib.virtemp(sfcpres, sfctemp, sfcdwpt); + Coordinate c1 = NsharpWxMath.getSkewTXY(sfcpres, vtemp); + c1.x = world.mapX(c1.x); + c1.y = world.mapY(c1.y); + FloatByReference p2 = new FloatByReference(0), t2 = new FloatByReference( + 0); + ; + nsharpNative.nsharpLib.drylift(sfcpres, sfctemp, sfcdwpt, p2, t2); + vtemp = nsharpNative.nsharpLib.virtemp(p2.getValue(), t2.getValue(), + t2.getValue()); + Coordinate c2 = NsharpWxMath.getSkewTXY(p2.getValue(), vtemp); + c2.x = world.mapX(c2.x); + c2.y = world.mapY(c2.y); + + double[][] lines = { { c1.x, c1.y }, { c2.x, c2.y } }; + parcelVtTraceRscShape.addLineSegment(lines); + c1 = c2; + + float t3; + for (float i = p2.getValue() - 50; i >= 100; i = i - 50) { + t3 = nsharpNative.nsharpLib + .wetlift(p2.getValue(), t2.getValue(), i); + vtemp = nsharpNative.nsharpLib.virtemp(i, t3, t3); + c2 = NsharpWxMath.getSkewTXY(i, vtemp); + c2.x = world.mapX(c2.x); + c2.y = world.mapY(c2.y); + + double[][] lines1 = { { c1.x, c1.y }, { c2.x, c2.y } }; + parcelVtTraceRscShape.addLineSegment(lines1); + c1 = c2; + + } + + t3 = nsharpNative.nsharpLib.wetlift(p2.getValue(), t2.getValue(), 100); + vtemp = nsharpNative.nsharpLib.virtemp(100, t3, t3); + c2 = NsharpWxMath.getSkewTXY(100, vtemp); + c2.x = world.mapX(c2.x); + c2.y = world.mapY(c2.y); + + double[][] lines2 = { { c1.x, c1.y }, { c2.x, c2.y } }; + parcelVtTraceRscShape.addLineSegment(lines2); + + parcelVtTraceRscShape.compile(); + + // DCAPE------------------ + // Downdraft Convective Available Potential Energy - DCAPE + // see trace_dcape() in xwvid1.c for original source + /* ----- Find highest observation in layer ----- */ + @SuppressWarnings("unused") + float mine, minep, tp1, tp2, te1, te2, pe1, pe2, h1, h2; + FloatByReference value1 = new FloatByReference(-999); + FloatByReference value2 = new FloatByReference(-999); + FloatByReference Surfpressure = new FloatByReference(-999); + nsharpNative.nsharpLib.get_surface(Surfpressure, value1, value2); + int p5 = 0; + if (nsharpNative.nsharpLib.qc(Surfpressure.getValue()) == 1) { + NcSoundingLayer layer; + for (int i = this.soundingLys.size() - 1; i >= 0; i--) { + layer = this.soundingLys.get(i); + if (layer.getPressure() > Surfpressure.getValue() - 400) { + p5 = i; + break; + } + } + } + + /* ----- Find min ThetaE layer ----- */ + mine = 1000; + minep = -999; + for (int i = 0; i < p5; i++) { + NcSoundingLayer layer = this.soundingLys.get(i); + if ((nsharpNative.nsharpLib.qc(layer.getDewpoint()) == 1) + && nsharpNative.nsharpLib.qc(nsharpNative.nsharpLib + .itemp(layer.getPressure() + 100)) == 1) { + nsharpNative.nsharpLib.Mean_thetae(value1, layer.getPressure(), + layer.getPressure() - 100); + if (nsharpNative.nsharpLib.qc(value1.getValue()) == 1 + && value1.getValue() < mine) { + mine = value1.getValue(); + minep = layer.getPressure() - 50; + } + } + } + if (minep < 0) + return; + + float upper = minep; + dacpeTraceRscShape = target.createWireframeShape(false, descriptor); + dacpeTraceRscShape.allocate(40); + + /* ----- Find highest observation in layer ----- */ + NcSoundingLayer layer; + int uptr = 0; + for (int i = this.soundingLys.size() - 1; i >= 0; i--) { + layer = this.soundingLys.get(i); + if (layer.getPressure() > upper) { + uptr = i; + break; + } + } + + /* ----- Define parcel starting point ----- */ + tp1 = nsharpNative.nsharpLib.wetbulb(upper, + nsharpNative.nsharpLib.itemp(upper), + nsharpNative.nsharpLib.idwpt(upper)); + pe1 = upper; + te1 = nsharpNative.nsharpLib.itemp(pe1); + h1 = nsharpNative.nsharpLib.ihght(pe1); + float ent2; + + c1 = NsharpWxMath.getSkewTXY(pe1, tp1); + c1.x = world.mapX(c1.x); + c1.y = world.mapY(c1.y); + for (int i = uptr; i >= 0; i--) { + layer = this.soundingLys.get(i); + pe2 = layer.getPressure(); + if (pe2 > Surfpressure.getValue()) + break; + te2 = layer.getTemperature(); + h2 = layer.getGeoHeight(); + tp2 = nsharpNative.nsharpLib.wetlift(pe1, tp1, pe2); + if ((nsharpNative.nsharpLib.qc(te2) == 1) + && nsharpNative.nsharpLib.qc(tp2) == 1) { + /* Account for Entrainment */ + ent2 = NsharpNativeConstants.ENTRAIN_DEFAULT + * ((h1 - h2) / 1000); + tp2 = tp2 + ((te2 - tp2) * ent2); + c2 = NsharpWxMath.getSkewTXY(pe2, tp2); + c2.x = world.mapX(c2.x); + c2.y = world.mapY(c2.y); + + double[][] lines3 = { { c1.x, c1.y }, { c2.x, c2.y } }; + dacpeTraceRscShape.addLineSegment(lines3); + c1 = c2; + h1 = h2; + pe1 = pe2; + tp1 = tp2; + } + } + + dacpeTraceRscShape.compile(); + } + + // start FixMark:clickOnTimeStnPane + private void drawNoDataMessage(IGraphicsTarget target) { + IExtent ext = descriptor.getRenderableDisplay().getExtent(); + double xmin = ext.getMinX(); // Extent's viewable envelope min x and y + double xmax = ext.getMaxX(); + double xDefault = world.mapX(NsharpConstants.left); + if (xmin < xDefault) + xmin = xDefault; + double x = xmin + 15 * currentZoomLevel * xRatio; + x = (xmax - xmin) / 4; + double y = world.mapY(NsharpWxMath.getSkewTXY(300, 0).y); + try { + target.drawString( + font12, + "Data is not loaded at selected current time line/station/source", + x, y, 0.0, TextStyle.BOXED, NsharpConstants.color_red, + HorizontalAlignment.LEFT, VerticalAlignment.MIDDLE, null); + } catch (VizException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + // end FixMark:clickOnTimeStnPane + // Chin: to handle dynamically moving height mark within viewable zone when + // zooming, I could not use wireframeShape successfully + // It will chop off lower part of marks. Therefore use this draw function. + @SuppressWarnings("deprecation") + private void drawHeightMark(IGraphicsTarget target) { + // plot meter scales... + if (soundingLys.size() <= 0) + return; + IExtent ext = descriptor.getRenderableDisplay().getExtent(); + double xmin = ext.getMinX(); // Extent's viewable envelope min x and y + double xDefault = world.mapX(NsharpConstants.left); + if (xmin < xDefault) + xmin = xDefault; + double dispX1 = xmin + 15 * currentZoomLevel * xRatio; + double dispX2 = xmin + 30 * currentZoomLevel * xRatio; + for (int j = 0; j < NsharpConstants.HEIGHT_LEVEL_METERS.length; j++) { + int meters = NsharpConstants.HEIGHT_LEVEL_METERS[j]; + // plot the meters scale + double pressure = nsharpNative.nsharpLib.ipres(meters + + (int) (soundingLys.get(0).getGeoHeight())); + double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, 0).y); + // System.out.println("world.mapX(NsharpConstants.left) + 20 =" + + // (world.mapX(NsharpConstants.left) + 20)); + try { + target.drawLine(dispX1, y, 0.0, dispX2, y, 0.0, + NsharpConstants.color_red, 1); + + target.drawString(font10, Integer.toString(meters / 1000) + + " km", dispX2, y - 5, 0.0, TextStyle.NORMAL, + NsharpConstants.color_red, HorizontalAlignment.LEFT, + VerticalAlignment.MIDDLE, null); + } catch (VizException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + // plot surface level mark{ + if (soundingLys.get(0).getGeoHeight() != NsharpNativeConstants.NSHARP_NATIVE_INVALID_DATA) { + double y = world.mapY(NsharpWxMath.getSkewTXY(soundingLys.get(0) + .getPressure(), 0).y); + try { + target.drawLine(dispX1, y, 0.0, dispX2, y, 0.0, + NsharpConstants.color_red, 1); + + target.drawString( + font10, + "SFC(" + + Integer.toString((int) (soundingLys.get(0) + .getGeoHeight())) + "m)", dispX2, + y - 5, 0.0, TextStyle.NORMAL, + NsharpConstants.color_red, HorizontalAlignment.LEFT, + VerticalAlignment.MIDDLE, null); + } catch (VizException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + } + + @SuppressWarnings("unused") + private void createRscHeightMarkShape() { + + heightMarkRscShape = target.createWireframeShape(false, descriptor); + heightMarkRscShape.allocate(20); + // plot meter scales... + IExtent ext = descriptor.getRenderableDisplay().getExtent(); + double xmin = ext.getMinX(); // Extent's viewable envelope min x and y + double xDefault = world.mapX(NsharpConstants.left); + if (xmin < xDefault) + xmin = xDefault; + double dispX1 = xmin + 15 * currentZoomLevel * xRatio; + double dispX2 = xmin + 40 * currentZoomLevel * xRatio; + for (int j = 0; j < NsharpConstants.HEIGHT_LEVEL_METERS.length; j++) { + int meters = NsharpConstants.HEIGHT_LEVEL_METERS[j]; + // plot the meters scale + double pressure = nsharpNative.nsharpLib.ipres(meters + + (int) (soundingLys.get(0).getGeoHeight())); + double y = world.mapY(NsharpWxMath.getSkewTXY(pressure, 0).y); + // System.out.println("world.mapX(NsharpConstants.left) + 20 =" + + // (world.mapX(NsharpConstants.left) + 20)); + double[][] lines = { { dispX1, y }, { dispX2, y } }; + heightMarkRscShape.addLineSegment(lines); + double[] lblXy = { dispX2, y - 5 }; + heightMarkRscShape.addLabel( + Integer.toString(meters / 1000) + " km", lblXy); + } + // plot surface level mark{ + if (soundingLys.get(0).getGeoHeight() != NsharpNativeConstants.NSHARP_NATIVE_INVALID_DATA) { + double y = world.mapY(NsharpWxMath.getSkewTXY(soundingLys.get(0) + .getPressure(), 0).y); + double[][] lines = { { dispX1, y }, { dispX2, y } }; + heightMarkRscShape.addLineSegment(lines); + double[] lblXy = { dispX2, y - 5 }; + heightMarkRscShape.addLabel( + "SFC(" + + Integer.toString((int) (soundingLys.get(0) + .getGeoHeight())) + "m)", lblXy); + } + heightMarkRscShape.compile(); + } + + public void createRscwetBulbTraceShape() { + if (wetBulbTraceRscShape != null) { + wetBulbTraceRscShape.dispose(); + wetBulbTraceRscShape = null; + } + wetBulbTraceRscShape = target.createWireframeShape(false, descriptor); + wetBulbTraceRscShape.allocate(soundingLys.size() * 2); + float t1; + + Coordinate c2 = null; + Coordinate c1; + // draw trace + + for (NcSoundingLayer layer : this.soundingLys) { + if (layer.getDewpoint() > -200 && layer.getPressure() >= 100) { + t1 = nsharpNative.nsharpLib.wetbulb(layer.getPressure(), + layer.getTemperature(), layer.getDewpoint()); + + c1 = NsharpWxMath.getSkewTXY(layer.getPressure(), t1); + c1.x = world.mapX(c1.x); + c1.y = world.mapY(c1.y); + if (c2 != null) { + + double[][] lines = { { c1.x, c1.y }, { c2.x, c2.y } }; + wetBulbTraceRscShape.addLineSegment(lines); + + } + c2 = c1; + } + } + wetBulbTraceRscShape.compile(); + } + + private void createTurbulenceShapes(WGraphics world) { + if (turbLnShape != null) + turbLnShape.dispose(); + turbLnShape = target.createWireframeShape(false, descriptor); + + turbLnShape.allocate(this.soundingLys.size() * 2); + turbWindShearShape = target.createWireframeShape(false, descriptor); + turbWindShearShape.allocate(this.soundingLys.size() * 2); + Coordinate pointALn = null; + Coordinate pointBLn = null; + Coordinate pointAWsh = null; + Coordinate pointBWsh = null; + double g = 9.8f, Ri; + double t0, t1, v0, v1, u0, u1, windshear0, windshearsqrd, tke_windshear_prod; + double pressure0 = 0, pressure1, midpressure0, p, high0 = 0, high1; + double theta1 = 0, theta0 = 0, dthetadz0, meanTheta; + boolean first = true; + NcSoundingLayer layer0, layer1; + for (int i = 0; i < soundingLys.size() - 1; i++) { + layer0 = soundingLys.get(i); + pressure0 = layer0.getPressure(); + t0 = layer0.getTemperature(); + high0 = layer0.getGeoHeight(); + layer1 = soundingLys.get(i + 1); + t1 = layer1.getTemperature(); + high1 = layer1.getGeoHeight(); + if (t0 <= NsharpNativeConstants.NSHARP_NATIVE_INVALID_DATA + || t1 <= NsharpNativeConstants.NSHARP_NATIVE_INVALID_DATA + || pressure0 <= NsharpConstants.TURBULENCE_PRESSURE_LEVEL_TOP) + continue; + pressure1 = layer1.getPressure(); + v0 = nsharpNative.nsharpLib.iwndv((float) pressure0); + v1 = nsharpNative.nsharpLib.iwndv((float) pressure1); + u0 = nsharpNative.nsharpLib.iwndu((float) pressure0); + u1 = nsharpNative.nsharpLib.iwndu((float) pressure1); + windshear0 = Math.sqrt((u1 - u0) * (u1 - u0) + (v1 - v0) + * (v1 - v0)) + * .51479 / (high1 - high0); + midpressure0 = (pressure1 + pressure0) / 2; + theta0 = WxMath.theta(pressure0, t0, 1000) + 273.15; + theta1 = WxMath.theta(pressure1, t1, 1000) + 273.15; + meanTheta = (theta1 + theta0) / 2.0f; + dthetadz0 = (theta1 - theta0) / (high1 - high0); + if (windshear0 != 0.0) { + windshearsqrd = (windshear0 * windshear0); + Ri = (g / meanTheta) * (dthetadz0 / windshearsqrd); + world.setWorldCoordinates( + NsharpConstants.TURBULENCE_LN_RICHARDSON_NUMBER_LEFT, + turbBackground + .toLogScale(NsharpConstants.TURBULENCE_PRESSURE_LEVEL_TOP), + NsharpConstants.TURBULENCE_LN_RICHARDSON_NUMBER_RIGHT, + turbBackground + .toLogScale(NsharpConstants.TURBULENCE_PRESSURE_LEVEL_BOTTOM)); + // System.out.println("world viewYmin="+world.getViewYmin()+" viewYmax="+world.getViewYmax()+" wolrdYmin="+ + // world.getWorldYmin()+" wolrdYmax="+ world.getWorldYmax() + // +" viewXmin="+world.getViewXmin()+" viewXmax="+world.getViewXmax()+" wolrdXmin="+ + // world.getWorldXmin()+" wolrdXmax="+ world.getWorldXmax()); + + pointALn = new Coordinate(); + p = turbBackground.toLogScale(midpressure0); + pointALn.x = world.mapX(Math.log(Ri)); + pointALn.y = world.mapY(p); + world.setWorldCoordinates( + NsharpConstants.TURBULENCE_WIND_SHEAR_TKE_LEFT, + turbBackground + .toLogScale(NsharpConstants.TURBULENCE_PRESSURE_LEVEL_TOP), + NsharpConstants.TURBULENCE_WIND_SHEAR_TKE_RIGHT, + turbBackground + .toLogScale(NsharpConstants.TURBULENCE_PRESSURE_LEVEL_BOTTOM)); + pointAWsh = new Coordinate(); + tke_windshear_prod = 0.54 * (high1 - high0) * windshearsqrd; + pointAWsh.x = world.mapX(tke_windshear_prod * 100); + pointAWsh.y = world.mapY(p); + // System.out.println("P0="+pressure0+" dthetadz0="+dthetadz0+" theta0="+theta0+" log(Ri)="+Math.log(Ri)+ + // " pointAx="+pointALn.x+ " y="+pointALn.y); + if (!first) { + double[][] linesLn = { { pointALn.x, pointALn.y }, + { pointBLn.x, pointBLn.y } }; + double[][] linesWsh = { { pointAWsh.x, pointAWsh.y }, + { pointBWsh.x, pointBWsh.y } }; + turbLnShape.addLineSegment(linesLn); + turbWindShearShape.addLineSegment(linesWsh); + + } else { + first = false; + } + pointBLn = pointALn; + pointBWsh = pointAWsh; + } + } + + turbLnShape.compile(); + turbWindShearShape.compile(); + } + + /* + * Chin:: NOTE::: This plotting function is based on the algorithm of + * draw_ICG() at xwvid1.c of AWC Nsharp source code by LARRY J. HINSON + * AWC/KCMO + */ + private void createIcingRHShape(WGraphics world) { + // System.out.println("world viewYmin="+world.getViewYmin()+" viewYmax="+world.getViewYmax()+" wolrdYmin="+ + // world.getWorldYmin()+" wolrdYmax="+ world.getWorldYmax() + // +" viewXmin="+world.getViewXmin()+" viewXmax="+world.getViewXmax()+" wolrdXmin="+ + // world.getWorldXmin()+" wolrdXmax="+ world.getWorldXmax()); + + icingRHShape = target.createWireframeShape(false, descriptor); + icingRHShape.allocate(this.soundingLys.size() * 2); + Coordinate c0 = null; + + for (NcSoundingLayer layer : soundingLys) { + double pressure = layer.getPressure(); + if (pressure >= NsharpConstants.ICING_PRESSURE_LEVEL_TOP + && pressure <= NsharpConstants.ICING_PRESSURE_LEVEL_BOTTOM) { + + FloatByReference parm = new FloatByReference(0); + float relh = nsharpNative.nsharpLib + .relh((float) pressure, parm); + Coordinate c1 = new Coordinate(); + double p = icingBackground.toLogScale(pressure); + c1.x = world.mapX(relh); + c1.y = world.mapY(p); + // System.out.println("RH="+relh+ " p="+pressure+ " x="+c1.x+ + // " y="+c1.y); + if (c0 != null) { + double[][] lines = { { c0.x, c0.y }, { c1.x, c1.y } }; + icingRHShape.addLineSegment(lines); + } + c0 = c1; + } + } + + icingRHShape.compile(); + } + + private void createIcingEPIShape(WGraphics world) { + // System.out.println("world viewYmin="+world.getViewYmin()+" viewYmax="+world.getViewYmax()+" wolrdYmin="+ + // world.getWorldYmin()+" wolrdYmax="+ world.getWorldYmax() + // +" viewXmin="+world.getViewXmin()+" viewXmax="+world.getViewXmax()+" wolrdXmin="+ + // world.getWorldXmin()+" wolrdXmax="+ world.getWorldXmax()); + + icingEPIShape = target.createWireframeShape(false, descriptor); + icingEPIShape.allocate(this.soundingLys.size() * 2); + Coordinate pointA = null; + Coordinate pointB = null; + boolean firstround = true; + double t0, t1; + double pressure0 = 0, pressure1, midpressure0, p, high0 = 0, high1; + double const1 = 2500000.0 / 1004.0; + double theta1 = 0, thetase1, theta0 = 0, thetase0 = 0, mixratio0, mixratio1, dthetasedz0; + NcSoundingLayer layer0, layer1; + for (int i = 0; i < soundingLys.size() - 1; i++) { + layer0 = soundingLys.get(i); + layer1 = soundingLys.get(i + 1); + t0 = layer0.getTemperature(); + t1 = layer1.getTemperature(); + pressure0 = layer0.getPressure(); + pressure1 = layer1.getPressure(); + if (t0 <= NsharpNativeConstants.NSHARP_NATIVE_INVALID_DATA + || t1 <= NsharpNativeConstants.NSHARP_NATIVE_INVALID_DATA + || (pressure0 < NsharpConstants.ICING_PRESSURE_LEVEL_TOP && pressure1 < NsharpConstants.ICING_PRESSURE_LEVEL_TOP)) + continue; + theta1 = WxMath.theta(pressure1, t1, 1000) + 273.15; + mixratio1 = WxMath.mixingRatio(pressure1, t1); + thetase1 = theta1 + * Math.exp(const1 * mixratio1 * .001 / (t1 + 273.15)); + high1 = layer1.getGeoHeight(); + theta0 = WxMath.theta(pressure0, t0, 1000) + 273.15; + mixratio0 = WxMath.mixingRatio(pressure0, t0); + thetase0 = theta0 + * Math.exp(const1 * mixratio0 * .001 / (t0 + 273.15)); + high0 = layer0.getGeoHeight(); + // Do D-Theta-se/dz + dthetasedz0 = (thetase1 - thetase0) / (high1 - high0) * 1E3; + midpressure0 = (pressure1 + pressure0) / 2; + pointA = new Coordinate(); + p = icingBackground.toLogScale(midpressure0); + pointA.x = world.mapX(dthetasedz0); + pointA.y = world.mapY(p); + if (!firstround) { + // System.out.println("Temp="+t0+ " p="+pressure0+ + // "pointAx="+pointA.x+ " y="+pointA.y+ " pointBx="+pointB.x+ + // " y="+pointB.y); + double[][] lines = { { pointA.x, pointA.y }, + { pointB.x, pointB.y } }; + icingEPIShape.addLineSegment(lines); + + } else {// this is first round, we need two pints for a line + // segment. We only have first point now. + firstround = false; + } + pointB = pointA; + + } + icingEPIShape.compile(); + } + + /* + * Chin:: NOTE::: This plotting function is based on the algorithm of + * draw_ICG() at xwvid1.c of AWC Nsharp source code by LARRY J. HINSON + * AWC/KCMO + */ + private void createIcingTempShape(WGraphics world) { + // System.out.println("world viewYmin="+world.getViewYmin()+" viewYmax="+world.getViewYmax()+" wolrdYmin="+ + // world.getWorldYmin()+" wolrdYmax="+ world.getWorldYmax() + // +" viewXmin="+world.getViewXmin()+" viewXmax="+world.getViewXmax()+" wolrdXmin="+ + // world.getWorldXmin()+" wolrdXmax="+ world.getWorldXmax()); + + icingTempShape = target.createWireframeShape(false, descriptor); + icingTempShape.allocate(this.soundingLys.size() * 2); + Coordinate c0 = null; + + for (NcSoundingLayer layer : soundingLys) { + double t = layer.getTemperature(); + // if( t > NsharpConstants.ICING_TEMPERATURE_RIGHT || t< + // NsharpConstants.ICING_TEMPERATURE_LEFT) + // continue; + double pressure = layer.getPressure(); + if (pressure >= NsharpConstants.ICING_PRESSURE_LEVEL_TOP + && pressure <= NsharpConstants.ICING_PRESSURE_LEVEL_BOTTOM) { + + Coordinate c1 = new Coordinate(); + double p = icingBackground.toLogScale(pressure); + c1.x = world.mapX(t); + c1.y = world.mapY(p); + // System.out.println("Temp="+t+ " p="+pressure+ " x="+c1.x+ + // " y="+c1.y); + if (c0 != null) { + double[][] lines = { { c0.x, c0.y }, { c1.x, c1.y } }; + icingTempShape.addLineSegment(lines); + } + c0 = c1; + } + } + + icingTempShape.compile(); + } + + private void createRscPressTempCurveShape(WGraphics WGc, + List soundingLays, NsharpLineProperty lineP, + IGraphicsTarget target) { + IWireframeShape shapeT = target.createWireframeShape(false, descriptor); + shapeT.allocate(soundingLays.size() * 2); + IWireframeShape shapeD = target.createWireframeShape(false, descriptor); + shapeD.allocate(soundingLays.size() * 2); + NsharpShapeAndLineProperty shNcolorT = new NsharpShapeAndLineProperty(); + NsharpShapeAndLineProperty shNcolorD = new NsharpShapeAndLineProperty(); + double maxPressure = NsharpWxMath.reverseSkewTXY(new Coordinate(0, WGc + .getWorldYmax())).y; + double minPressure = NsharpWxMath.reverseSkewTXY(new Coordinate(0, WGc + .getWorldYmin())).y; + boolean drawTemp = true, drawDew = true; + // NsharpParametersSelectionConfigDialog configD = + // NsharpParametersSelectionConfigDialog.getAccess(); + graphConfigProperty = rscHandler.getGraphConfigProperty(); + if (graphConfigProperty != null) { + drawTemp = graphConfigProperty.isTemp(); + drawDew = graphConfigProperty.isDewp(); + } + Coordinate c0 = null, c01 = null; + int count = 0; + for (NcSoundingLayer layer : soundingLays) { + double t, d; + t = layer.getTemperature(); + d = layer.getDewpoint(); + + double pressure = layer.getPressure(); + if (t != NsharpNativeConstants.NSHARP_NATIVE_INVALID_DATA + && pressure >= minPressure && pressure <= maxPressure) { + + Coordinate c1 = NsharpWxMath.getSkewTXY(pressure, t); + + c1.x = WGc.mapX(c1.x); + c1.y = WGc.mapY(c1.y); + if (c0 != null) { + double[][] lines = { { c0.x, c0.y }, { c1.x, c1.y } }; + count++; + shapeT.addLineSegment(lines); + } + c0 = c1; + } + if (d > -999 && pressure >= minPressure && pressure <= maxPressure) { + + Coordinate c11 = NsharpWxMath.getSkewTXY(pressure, d); + + c11.x = WGc.mapX(c11.x); + c11.y = WGc.mapY(c11.y); + if (c01 != null) { + double[][] lines = { { c01.x, c01.y }, { c11.x, c11.y } }; + shapeD.addLineSegment(lines); + } + c01 = c11; + } + } + // System.out.println("createRscPressTempCurveShape T count="+ count); + shapeT.compile(); + shapeD.compile(); + + shNcolorT.setShape(shapeT); + shNcolorD.setShape(shapeD); + if (!rscHandler.isOverlayIsOn() && !rscHandler.isCompareStnIsOn() + && !rscHandler.isCompareTmIsOn() + && !rscHandler.isCompareSndIsOn()) { + // use default color + + if (linePropertyMap != null) { + shNcolorT + .setLp(linePropertyMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_TEMP]));// chin + // new + // config + // NsharpConstants.color_red; + shNcolorD + .setLp(linePropertyMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_DEWP]));// NsharpConstants.color_green; + } + } else { + shNcolorT.setLp(lineP); + shNcolorD.setLp(lineP); + } + // check draw temp and dew here. It is easier to do this way, otherwise, + // we have to check it every where + if (drawTemp) + pressureTempRscShapeList.add(shNcolorT); + else + shNcolorT.getShape().dispose(); + if (drawDew) + pressureTempRscShapeList.add(shNcolorD); + else + shNcolorD.getShape().dispose(); + } + + public void createRscPressTempCurveShapeAll(IGraphicsTarget target) { + + if (pressureTempRscShapeList.size() > 0) { + for (NsharpShapeAndLineProperty shapeColor : pressureTempRscShapeList) { + shapeColor.getShape().dispose(); + } + pressureTempRscShapeList.clear(); + } + + int currentTimeListIndex = rscHandler.getCurrentTimeElementListIndex(); + int currentStnListIndex = rscHandler.getCurrentStnElementListIndex(); + int currentSndListIndex = rscHandler.getCurrentSndElementListIndex(); + List stnElemList = rscHandler + .getStnElementList(); + List timeElemList = rscHandler + .getTimeElementList(); + List sndElemList = rscHandler + .getSndElementList(); + List>> stnTimeSndTable = rscHandler + .getStnTimeSndTable(); + if (rscHandler.isCompareStnIsOn() && currentTimeListIndex >= 0 + && currentSndListIndex >= 0) { + int colorIndex; + for (NsharpOperationElement elm : stnElemList) { + if (elm.getActionState() == NsharpConstants.ActState.ACTIVE + && stnTimeSndTable.get(stnElemList.indexOf(elm)) + .get(currentTimeListIndex) + .get(currentSndListIndex) != null) { + List soundingLayeys = stnTimeSndTable + .get(stnElemList.indexOf(elm)) + .get(currentTimeListIndex).get(currentSndListIndex) + .getSndLyLst(); + colorIndex = stnTimeSndTable.get(stnElemList.indexOf(elm)) + .get(currentTimeListIndex).get(currentSndListIndex) + .getCompColorIndex(); + NsharpLineProperty lp = linePropertyMap + .get(NsharpConstants.lineNameArray[colorIndex]); + createRscPressTempCurveShape(world, soundingLayeys, lp, + target); + } + } + } else if (rscHandler.isCompareTmIsOn() && currentStnListIndex >= 0 + && currentSndListIndex >= 0) { + int colorIndex; + for (NsharpOperationElement elm : timeElemList) { + if (elm.getActionState() == NsharpConstants.ActState.ACTIVE + && stnTimeSndTable.get(currentStnListIndex) + .get(timeElemList.indexOf(elm)) + .get(currentSndListIndex) != null) { + List soundingLayeys = stnTimeSndTable + .get(currentStnListIndex) + .get(timeElemList.indexOf(elm)) + .get(currentSndListIndex).getSndLyLst(); + colorIndex = stnTimeSndTable.get(currentStnListIndex) + .get(timeElemList.indexOf(elm)) + .get(currentSndListIndex).getCompColorIndex(); + NsharpLineProperty lp = linePropertyMap + .get(NsharpConstants.lineNameArray[colorIndex]); + createRscPressTempCurveShape(world, soundingLayeys, lp, + target); + } + } + } else if (rscHandler.isCompareSndIsOn() & currentStnListIndex >= 0 + && currentTimeListIndex >= 0) { + int colorIndex; + // start FixMark:nearByStnCompSnd + List sndCompElementList = rscHandler + .getCompSndSelectedElemList(); + for (NsharpResourceHandler.CompSndSelectedElem compElem : sndCompElementList) { + NsharpSoundingElementStateProperty elemProp = stnTimeSndTable + .get(compElem.getStnIndex()) + .get(compElem.getTimeIndex()) + .get(compElem.getSndIndex()); + if (sndElemList.get(compElem.getSndIndex()).getActionState() == NsharpConstants.ActState.ACTIVE + && elemProp != null) { + List soundingLayeys = elemProp + .getSndLyLst(); + colorIndex = elemProp.getCompColorIndex(); + NsharpLineProperty lp = linePropertyMap + .get(NsharpConstants.lineNameArray[colorIndex]); + createRscPressTempCurveShape(world, soundingLayeys, lp, + target); + } + } + /* + * code before fixing for(NsharpOperationElement elm: sndElemList) { + * if(elm.getActionState() == NsharpConstants.ActState.ACTIVE && + * stnTimeSndTable + * .get(currentStnListIndex).get(currentTimeListIndex) + * .get(sndElemList.indexOf(elm))!=null){ List + * soundingLayeys = + * stnTimeSndTable.get(currentStnListIndex).get(currentTimeListIndex + * ).get(sndElemList.indexOf(elm)).getSndLyLst(); colorIndex = + * stnTimeSndTable + * .get(currentStnListIndex).get(currentTimeListIndex) + * .get(sndElemList.indexOf(elm)).getCompColorIndex(); + * NsharpLineProperty lp = + * linePropertyMap.get(NsharpConstants.lineNameArray[colorIndex]); + * createRscPressTempCurveShape(world, soundingLayeys, lp, target); + * } } + */ + // end FixMark:nearByStnCompSnd + } else if (rscHandler.isOverlayIsOn() == true) { + + previousSoundingLys = rscHandler.getPreviousSoundingLys(); + createRscPressTempCurveShape( + world, + this.soundingLys, + linePropertyMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_OVERLAY1]), + target); + if (this.previousSoundingLys != null + && !previousSoundingLys.equals(soundingLys)) { + createRscPressTempCurveShape( + world, + this.previousSoundingLys, + linePropertyMap + .get(NsharpConstants.lineNameArray[NsharpConstants.LINE_OVERLAY2]), + target); + } + + } else { + + createRscPressTempCurveShape(world, this.soundingLys, null, target); + } + } + + public void createRscVTempTraceShape() { + + if ((soundingLys == null) || (soundingLys.size() == 0)) + return; + float t1; + if (vtempTraceCurveRscShape != null) { + vtempTraceCurveRscShape.dispose(); + vtempTraceCurveRscShape = null; + } + + Coordinate c2 = null; + Coordinate c1; + // draw trace + vtempTraceCurveRscShape = target + .createWireframeShape(false, descriptor); + vtempTraceCurveRscShape.allocate(this.soundingLys.size() * 2); + for (NcSoundingLayer layer : this.soundingLys) { + if ((layer.getTemperature() != NsharpNativeConstants.NSHARP_NATIVE_INVALID_DATA) + && (layer.getDewpoint() != NsharpNativeConstants.NSHARP_NATIVE_INVALID_DATA) + && layer.getPressure() >= 100) { + t1 = nsharpNative.nsharpLib.ivtmp(layer.getPressure()); + + c1 = NsharpWxMath.getSkewTXY(layer.getPressure(), t1); + c1.x = world.mapX(c1.x); + c1.y = world.mapY(c1.y); + if (c2 != null) { + // target.drawLine(c1.x, c1.y, 0.0, c2.x, c2.y, 0.0, color, + // lineWidth, LineStyle.DASHED); + double[][] lines = { { c1.x, c1.y }, { c2.x, c2.y } }; + vtempTraceCurveRscShape.addLineSegment(lines); + } + c2 = c1; + } + } + vtempTraceCurveRscShape.compile(); + } + + /* + * Chin:: NOTE::: This plotting function is based on the algorithm of + * draw_Clouds() at xwvid1.c of AWC Nsharp source code Using Fred Mosher's + * Algorithm & Chernykh and Eskridge Algorithm + */ + private void createCloudsShape() { + NsharpNative.NsharpLibrary.CloudInfoStr cloudInfo = new NsharpNative.NsharpLibrary.CloudInfoStr(); + nsharpNative.nsharpLib.draw_Clouds(cloudInfo); + // draw FM model: Fred Mosher's Algorithm + if (cloudInfo.getSizeFM() > 0) { + cloudFMShape = target.createShadedShape(false, descriptor, false); + cloudFMLabelShape = target.createWireframeShape(false, descriptor); + cloudFMLabelShape.allocate(2); + double[][] lines = { { 0, 0 }, { 0, 0 } }; + cloudFMLabelShape.addLineSegment(lines); + for (int i = 0; i < cloudInfo.getSizeFM(); i++) { + double lowY = world.mapY(NsharpWxMath.getSkewTXY( + cloudInfo.getPreStartFM()[i], -50).y); + double highY = world.mapY(NsharpWxMath.getSkewTXY( + cloudInfo.getPreEndFM()[i], -50).y); + Coordinate[] coords = new Coordinate[4]; + coords[0] = new Coordinate(skewtXOrig + 150, lowY); + coords[1] = new Coordinate(skewtXOrig + 200, lowY); + coords[2] = new Coordinate(skewtXOrig + 200, highY); + coords[3] = new Coordinate(skewtXOrig + 150, highY); + + /* + * Create LineString[] from Coordinates[] + */ + GeometryFactory gf = new GeometryFactory(); + LineString[] ls = new LineString[] { gf + .createLineString(coords) }; + + cloudFMShape.addPolygonPixelSpace(ls, + NsharpConstants.color_yellow); + double[] lblXy = { skewtXOrig + 175, (lowY + highY) / 2 }; + cloudFMLabelShape + .addLabel( + NsharpNative.NsharpLibrary.CLOUD_TYPE[cloudInfo.cloudTypeFM[i]], + lblXy); + } + cloudFMShape.compile(); + cloudFMLabelShape.compile(); + } + // draw CE model : Chernykh and Eskridge Algorithm + if (cloudInfo.getSizeCE() > 0) { + cloudCEShape = target.createShadedShape(false, descriptor, false); + + for (int i = 0; i < cloudInfo.getSizeCE(); i++) { + double lowY = world.mapY(NsharpWxMath.getSkewTXY( + cloudInfo.getPreStartCE()[i], -50).y); + double highY = world.mapY(NsharpWxMath.getSkewTXY( + cloudInfo.getPreEndCE()[i], -50).y); + Coordinate[] coords = new Coordinate[4]; + coords[0] = new Coordinate(skewtXOrig + 100, lowY); + coords[1] = new Coordinate(skewtXOrig + 150, lowY); + coords[2] = new Coordinate(skewtXOrig + 150, highY); + coords[3] = new Coordinate(skewtXOrig + 100, highY); + + /* + * Create LineString[] from Coordinates[] + */ + GeometryFactory gf = new GeometryFactory(); + LineString[] ls = new LineString[] { gf + .createLineString(coords) }; + + cloudCEShape + .addPolygonPixelSpace(ls, NsharpConstants.color_red); + + } + cloudCEShape.compile(); + + } + } + + @SuppressWarnings("unused") + private void createRscOmegaShape() { + // draw label and vertical lines + omegaBkgShape = target.createWireframeShape(false, descriptor); + omegaBkgShape.allocate(6); + IExtent ext = descriptor.getRenderableDisplay().getExtent(); + float xmin = (float) ext.getMinX(); + // System.out.println("ex xmin="+ xmin+ " ymin= "+ ext.getMinY() + + // " ymax="+ ext.getMaxY()); + float xWoldMin = (float) world.mapX(NsharpConstants.left); + if (xmin > xWoldMin) + omegaXOrig = xmin + 40 * xRatio * (float) currentZoomLevel; + else + omegaXOrig = xWoldMin + 40 * xRatio * (float) currentZoomLevel; + // we dont really care about temp, as we use pressure for Y axis. + // left dash line + double[][] lines = { + { omegaXOrig + omegaWidth * currentZoomLevel, omegaYOrig }, + { omegaXOrig + omegaWidth * currentZoomLevel, omegaYEnd } }; + omegaBkgShape.addLineSegment(lines); + // center line + double[][] lines1 = { + { omegaXOrig + omegaWidth * currentZoomLevel * 0.5f, omegaYOrig }, + { omegaXOrig + omegaWidth * currentZoomLevel * 0.5f, omegaYEnd } }; + omegaBkgShape.addLineSegment(lines1); + // right dash line, + double[][] lines2 = { { omegaXOrig, omegaYOrig }, + { omegaXOrig, omegaYEnd } }; + omegaBkgShape.addLineSegment(lines2); + double[] lblXy = { omegaXOrig + omegaWidth * currentZoomLevel * 0.5f, + omegaYOrig + 10 * yRatio }; + omegaBkgShape.addLabel("+1 OMEGA -1", lblXy); + omegaBkgShape.compile(); + + omegaRscShape = target.createWireframeShape(false, descriptor); + omegaRscShape.allocate(soundingLys.size() * 2); + float p, omega, t; + double xAxisOrigin = omegaXOrig + omegaWidth * currentZoomLevel * 0.5f; + for (NcSoundingLayer layer : this.soundingLys) { + p = layer.getPressure(); + t = layer.getTemperature(); + if (layer.getOmega() > -999) { + omega = -layer.getOmega() * omegaWidth + * (float) currentZoomLevel * 0.5f; + Coordinate c1 = NsharpWxMath.getSkewTXY(p, t); + Coordinate c2 = new Coordinate(); + ; + c2.y = world.mapY(c1.y); // what we need here is only pressure + // for Y-axix, + // System.out.println("p="+p+" t=" + t+" c1y="+c1.y+ + // " c2y="+c2.y); + double[][] lines3 = { { xAxisOrigin, c2.y }, + { xAxisOrigin + omega, c2.y } }; + omegaRscShape.addLineSegment(lines3); + } + } + omegaRscShape.compile(); + } + + // Chin: to handle dynamically moving omega within viewable zone when + // zooming, I could not use wireframeShape successfully + // It will chop off lower part of omega. Therefore use this draw function + // for omega. + @SuppressWarnings("deprecation") + private void drawOmega() { + // draw label and vertical lines + IExtent ext = descriptor.getRenderableDisplay().getExtent(); + float xmin = (float) ext.getMinX(); + // System.out.println("ex xmin="+ xmin+ " ymin= "+ ext.getMinY() + + // " ymax="+ ext.getMaxY()); + float xWoldMin = (float) world.mapX(NsharpConstants.left); + if (xmin > xWoldMin) + omegaXOrig = xmin + 40 * xRatio * (float) currentZoomLevel; + else + omegaXOrig = xWoldMin + 40 * xRatio * (float) currentZoomLevel; + // we dont really care about temp, as we use pressure for Y axis. + try { + // left dash line + target.drawLine(omegaXOrig + omegaWidth * currentZoomLevel, + omegaYOrig, 0.0, + omegaXOrig + omegaWidth * currentZoomLevel, omegaYEnd, 0.0, + NsharpConstants.color_violet_red, 1, LineStyle.DASHED); + + // center line + target.drawLine(omegaXOrig + omegaWidth * currentZoomLevel * 0.5f, + omegaYOrig, 0.0, omegaXOrig + omegaWidth * currentZoomLevel + * 0.5f, omegaYEnd, 0.0, + NsharpConstants.color_violet_red, 1, LineStyle.DASHED); + // right dash line, + target.drawLine(omegaXOrig, omegaYOrig, 0.0, omegaXOrig, omegaYEnd, + 0.0, NsharpConstants.color_violet_red, 1, LineStyle.DASHED); + target.drawString(font10, "+1 OMEGA -1", omegaXOrig + omegaWidth + * currentZoomLevel * 0.5f, omegaYOrig + 10 * yRatio, 0.0, + TextStyle.NORMAL, NsharpConstants.color_violet_red, + HorizontalAlignment.CENTER, VerticalAlignment.BOTTOM, null); + + float p, omega, t; + double xAxisOrigin = omegaXOrig + omegaWidth * currentZoomLevel + * 0.5f; + for (NcSoundingLayer layer : this.soundingLys) { + p = layer.getPressure(); + t = layer.getTemperature(); + if (layer.getOmega() > -999) { + omega = -layer.getOmega() * omegaWidth + * (float) currentZoomLevel * 0.5f; + Coordinate c1 = NsharpWxMath.getSkewTXY(p, t); + Coordinate c2 = new Coordinate(); + ; + c2.y = world.mapY(c1.y); // what we need here is only + // pressure for Y-axix, + // System.out.println("p="+p+" t=" + t+" c1y="+c1.y+ + // " c2y="+c2.y); + target.drawLine(xAxisOrigin, c2.y, 0.0, + xAxisOrigin + omega, c2.y, 0.0, + NsharpConstants.color_cyan, 1); + } + } + } catch (VizException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + + /** + * Create all wire frame shapes at one place. Should be used only when a new + * resource is becoming Current active resource to be displayed. + * + */ + + public void createRscWireFrameShapes() { + // System.out.println("createRscWireFrameShapes called"); + if (target != null) { + disposeRscWireFrameShapes(); + if (soundingLys != null) { + // createRscOmegaShape(); + // createRscHeightMarkShape(); + createRscwetBulbTraceShape(); + createRscPressTempCurveShapeAll(target); + createRscVTempTraceShape(); + createRscParcelRtTraceShapesList(rscHandler.getCurrentParcel(), + rscHandler.getCurrentParcelLayerPressure());// real temp + // trace + createRscParcelTraceShapes(rscHandler.getCurrentParcel(), + rscHandler.getCurrentParcelLayerPressure()); // Virtual + // Temp + // Trace + // and + // DCAPE + // trace + createLCLEtcLinesShape(); + createEffectiveLayerLinesShape(); + createCloudsShape(); + updatePsblWatchColor(); + } + } + } + + public void disposeRscWireFrameShapes() { + if (omegaBkgShape != null) { + omegaBkgShape.dispose(); + omegaBkgShape = null; + } + if (omegaRscShape != null) { + omegaRscShape.dispose(); + omegaRscShape = null; + } + if (heightMarkRscShape != null) { + heightMarkRscShape.dispose(); + heightMarkRscShape = null; + } + if (wetBulbTraceRscShape != null) { + wetBulbTraceRscShape.dispose(); + wetBulbTraceRscShape = null; + } + if (vtempTraceCurveRscShape != null) { + vtempTraceCurveRscShape.dispose(); + vtempTraceCurveRscShape = null; + } + if (cloudFMShape != null) { + cloudFMShape.dispose(); + cloudFMShape = null; + } + if (cloudCEShape != null) { + cloudCEShape.dispose(); + cloudCEShape = null; + } + if (cloudFMLabelShape != null) { + cloudFMLabelShape.dispose(); + cloudFMLabelShape = null; + } + if (icingTempShape != null) { + icingTempShape.dispose(); + icingTempShape = null; + } + if (icingRHShape != null) { + icingRHShape.dispose(); + icingRHShape = null; + } + if (icingEPIShape != null) { + icingEPIShape.dispose(); + icingEPIShape = null; + } + if (turbWindShearShape != null) { + turbWindShearShape.dispose(); + turbWindShearShape = null; + } + if (turbLnShape != null) { + turbLnShape.dispose(); + turbLnShape = null; + } + if (parcelRtShapeList.size() > 0) { + for (NsharpShapeAndLineProperty shapeColor : parcelRtShapeList) { + shapeColor.getShape().dispose(); + } + parcelRtShapeList.clear(); + } + if (parcelVtTraceRscShape != null) { + parcelVtTraceRscShape.dispose(); + parcelVtTraceRscShape = null; + } + if (dacpeTraceRscShape != null) { + dacpeTraceRscShape.dispose(); + dacpeTraceRscShape = null; + } + if (pressureTempRscShapeList.size() > 0) { + for (NsharpShapeAndLineProperty shapeColor : pressureTempRscShapeList) { + shapeColor.getShape().dispose(); + } + pressureTempRscShapeList.clear(); + + } + if (lclShape != null) { + lclShape.dispose(); + lclShape = null; + } + if (elShape != null) { + elShape.dispose(); + elShape = null; + } + if (fzlShape != null) { + fzlShape.dispose(); + fzlShape = null; + } + if (lfcShape != null) { + lfcShape.dispose(); + lfcShape = null; + } + } + + /* + * Return the closest wind barb origin point to the input point Also set + * currentWindBarbSoundingLayerIndex for wind barb magnification plotting + * later + */ + public Coordinate findClosestWindBarbPoint( + Coordinate currentCursorSkewTCoord) { + // wind barb X position + double windX = skewTBackground.getWindBarbXPosition(); + + Coordinate currentCursorPresTempCoord = NsharpWxMath + .reverseSkewTXY(world.unMap(currentCursorSkewTCoord)); + double curCursorPressure = currentCursorPresTempCoord.y; + double curCursorTemp = currentCursorPresTempCoord.x; + double prevPressure = 1000; + double prevT = 0; + Coordinate closetWindBarbCoord = new Coordinate(0, 0, 0); + + /* + * Note: soundingLys list sorted with highest pressure as first element + */ + for (NcSoundingLayer layer : this.soundingLys) { + + if (layer.getPressure() < 100) + continue; + double pressure = layer.getPressure(); + double temperatureAtWBOrigin; + // get windBrb Y position at temp 0 + double windY = NsharpWxMath.getSkewTXY(pressure, 0).y; + + // get wind barb temperature at windX(= + // skewTBackground.getWindBarbXPosition()), windY + temperatureAtWBOrigin = NsharpWxMath.reverseSkewTXY(new Coordinate( + windX, windY)).x; + // System.out.println(" pressure "+ pressure + " temp "+ + // temperatureAtWBOrigin + " prevPressure="+prevPressure); + if (pressure <= curCursorPressure) { + // decide which pressure (layer) should be used. current one or + // previous one + double disCurrentP = Math.abs(pressure - curCursorPressure); + double disPreviousP = Math + .abs(prevPressure - curCursorPressure); + double pickedPressure, pickedTemp; + + if (disPreviousP <= disCurrentP) { + pickedPressure = prevPressure; + pickedTemp = prevT; + + if (this.soundingLys.indexOf(layer) == 0) + currentWindBarbSoundingLayerIndex = this.soundingLys + .indexOf(layer); + else + currentWindBarbSoundingLayerIndex = this.soundingLys + .indexOf(layer) - 1; + } else { + pickedPressure = pressure; + pickedTemp = temperatureAtWBOrigin; + + currentWindBarbSoundingLayerIndex = this.soundingLys + .indexOf(layer); + } + double disTemp = Math.abs(pickedTemp - curCursorTemp); + // if distancw is not within 5 * currentZoomLevel degree, then + // return with (0,0); + if (disTemp > 5 * currentZoomLevel) { + setCursorTopWindBarb(false); + return closetWindBarbCoord; + } else { + // System.out.println("pickedP="+pickedPressure+" pickedT="+pickedTemp+ + // " inPressure"+inPressure+" inTemp="+ + // inTemp+" temp dis="+disTemp+ " rangeT="+ 5 * + // currentZoomLevel); + closetWindBarbCoord = NsharpWxMath.getSkewTXY( + pickedPressure, pickedTemp); + closetWindBarbCoord = world.map(closetWindBarbCoord); + setCursorTopWindBarb(true); + return closetWindBarbCoord; + } + } + prevPressure = pressure; + prevT = temperatureAtWBOrigin; + + } + // This is the case that inC is above highest layer (lowest pressure), + // then we picked highest layer, if within temp range + if (Math.abs(prevT - curCursorTemp) > 5 * currentZoomLevel) { + setCursorTopWindBarb(false); + return closetWindBarbCoord; + } + closetWindBarbCoord = NsharpWxMath.getSkewTXY(prevPressure, prevT); + closetWindBarbCoord = world.map(closetWindBarbCoord); + // System.out.println("pickedP="+prevPressure+" pickedT="+prevT+ + // " inPressure"+inPressure+" inTemp="+ inTemp); + setCursorTopWindBarb(true); + return closetWindBarbCoord; + } + + /* + * Return the closest point to the input point on either Temp or Dewpoint + * trace line Also set currentSoundingLayerIndex for plotting later + */ + public Coordinate getPickedTempPoint(Coordinate c) { + + // System.out.println("picked pt X "+ x + " Y "+ y); + // System.out.println("picked pt CX "+ c.x + " CY "+ c.y); + + Coordinate inC = NsharpWxMath.reverseSkewTXY(world.unMap(c)); + double inPressure = inC.y; + double inTemp = inC.x; + // System.out.println("user inout pt pressure "+ inPressure+ + // " temp "+inTemp ); + double prevPressure = 1000; + double prevT = 0, prevD = 0; + Coordinate closeptC = new Coordinate(0, 0, 0); + boolean firstPrevPicked = false; + + /* + * Note: soundingLys list sorted with highest pressure as first element + */ + + for (NcSoundingLayer layer : this.soundingLys) { + double t, d; + t = layer.getTemperature(); + d = layer.getDewpoint(); + double pressure = layer.getPressure(); + if (firstPrevPicked == false) { + // this is to handle the case, if picked point has same pressure + // (largest pressure) as first layer + firstPrevPicked = true; + prevPressure = pressure; + prevT = t; + prevD = d; + } + // System.out.println(" pressure "+ pressure ); + if (pressure >= 100 && pressure <= inPressure) { + // decide which pressure (layer) should be used. current one or + // previous one + double disCurrentP = Math.abs(pressure - inPressure); + double disPreviousP = Math.abs(prevPressure - inPressure); + double pickedPressure, pickedTemp, pickedDewpoint; + if (disPreviousP <= disCurrentP) { + pickedPressure = prevPressure; + pickedTemp = prevT; + pickedDewpoint = prevD; + if (this.soundingLys.indexOf(layer) == 0) + currentSoundingLayerIndex = this.soundingLys + .indexOf(layer); + else + currentSoundingLayerIndex = this.soundingLys + .indexOf(layer) - 1; + } else { + pickedPressure = pressure; + pickedTemp = t; + pickedDewpoint = d; + currentSoundingLayerIndex = this.soundingLys.indexOf(layer); + } + double disTemp = Math.abs(pickedTemp - inTemp); + double disDew = Math.abs(pickedDewpoint - inTemp); + // if both dis is not witin editing distance, ie. 4 degree, then + // return with (0,0); + if (disTemp > 4 && disDew > 4) { + return closeptC; + } + + // decide which line, temp or dewpoint, closer to user picked + // point + if (disTemp <= disDew) { + closeptC = NsharpWxMath.getSkewTXY(pickedPressure, + pickedTemp); + closeptC = world.map(closeptC); + currentTempCurveType = TEMP_TYPE; + // System.out.println("picked pressure "+ pickedPressure + + // " temp " +pickedTemp); + } else { + closeptC = NsharpWxMath.getSkewTXY(pickedPressure, + pickedDewpoint); + closeptC = world.map(closeptC); + currentTempCurveType = DEWPOINT_TYPE; + // System.out.println("picked pressure "+ pickedPressure + + // " dewpoint " +pickedDewpoint); + } + + // System.out.println("currentSoundingLayerIndex P = "+ + // this.soundingLys.get(currentSoundingLayerIndex).getPressure()); + break; + } + prevPressure = pressure; + prevT = t; + prevD = d; + } + + return closeptC; + } + + public void setCursorInSkewT(boolean cursorInSkewT) { + this.cursorInSkewT = cursorInSkewT; + } + + public void toggleCurseDisplay() { + curseToggledFontLevel = curseToggledFontLevel + CURSER_FONT_INC_STEP; + if (curseToggledFontLevel > CURSER_STRING_OFF) + curseToggledFontLevel = CURSER_FONT_10; + /* + * NsharpEditor editor = NsharpEditor.getActiveNsharpEditor(); if + * (editor != null) { editor.refresh(); } + */ + rscHandler.refreshPane(); + } + + public NsharpSkewTPaneBackground getSkewTBackground() { + return skewTBackground; + } + + public NsharpIcingPaneBackground getIcingBackground() { + return icingBackground; + } + + public NsharpTurbulencePaneBackground getTurbBackground() { + return turbBackground; + } + + public NsharpGenericPaneBackground getActiveBackground() { + if (currentGraphMode == NsharpConstants.GRAPH_SKEWT) { + return skewTBackground; + } else if (currentGraphMode == NsharpConstants.GRAPH_ICING) { + return icingBackground; + } else if (currentGraphMode == NsharpConstants.GRAPH_TURB) { + return turbBackground; + } + return null; + } + + public void setCurrentGraphMode(int currentGraphMode) { + this.currentGraphMode = currentGraphMode; + handleResize(); + // System.out.println("setCurrentGraphMode to "+ currentGraphMode); + if (rscHandler.getWitoPaneRsc() != null) + // simple D2D pane does not display WITO pane + rscHandler.getWitoPaneRsc().handleResize(); + } + + public void setPlotInteractiveTemp(boolean plotInteractiveTemp) { + this.plotInteractiveTemp = plotInteractiveTemp; + } + + public void setInteractiveTempPointCoordinate( + Coordinate interactiveTempPointCoordinate) { + this.interactiveTempPointCoordinate = interactiveTempPointCoordinate; + } + + public int getCurrentTempCurveType() { + return currentTempCurveType; + } + + public int getCurrentSkewTEditMode() { + return currentSkewTEditMode; + } + + public void setCurrentSkewTEditMode(int currentSkewTEditMode) { + this.currentSkewTEditMode = currentSkewTEditMode; + } + + @Override + public void handleResize() { + // System.out.println("NsharpSkewTPaneResource handleResize called! "+ + // this.toString()); + super.handleResize(); + if (getDescriptor().getRenderableDisplay() == null) + return; + IExtent ext = getDescriptor().getRenderableDisplay().getExtent(); + ext.reset(); + if (ext.getWidth() == 0.0 || ext.getHeight() == 0.0) { + return; + } + + // System.out.println("skewtPane: handleResize"); + this.rectangle = new Rectangle((int) ext.getMinX(), + (int) ext.getMinY(), (int) ext.getWidth(), + (int) ext.getHeight()); + pe = new PixelExtent(this.rectangle); + getDescriptor().setNewPe(pe); + // System.out.println("NsharpSkewTPaneResource handleResize called! "+ + // this.toString()+" RenderableDisplay="+getDescriptor().getRenderableDisplay().toString()+","+ + // (int)ext.getMinX()+","+ (int) ext.getMinY()+","+ + // (int) ext.getWidth()+","+ (int) ext.getHeight()); + world = new WGraphics(this.rectangle); + world.setWorldCoordinates(NsharpConstants.left, NsharpConstants.top, + NsharpConstants.right, NsharpConstants.bottom); + float prevHeight = skewtHeight; + float prevWidth = skewtWidth; + skewtXOrig = (int) (ext.getMinX()); + skewtYOrig = (int) ext.getMinY(); + skewtWidth = (int) (ext.getWidth()); + skewtHeight = (int) ext.getHeight(); + // skewtXEnd = skewtXOrig+ skewtWidth; + // skewtYEnd = skewtYOrig+ skewtHeight; + xRatio = xRatio * skewtWidth / prevWidth; + yRatio = yRatio * skewtHeight / prevHeight; + omegaYOrig = skewtYOrig; + omegaWidth = skewtWidth * 0.05f; + omegaHeight = skewtHeight; + omegaYEnd = omegaYOrig + omegaHeight; + createRscWireFrameShapes(); + if (currentGraphMode == NsharpConstants.GRAPH_SKEWT) + skewTBackground.handleResize(ext); + else if (currentGraphMode == NsharpConstants.GRAPH_ICING) + icingBackground.handleResize(ext); + else if (currentGraphMode == NsharpConstants.GRAPH_TURB) + turbBackground.handleResize(ext); + + // System.out.println(descriptor.getPaneNumber()+":calling wito handle resize"); + if (rscHandler != null && rscHandler.getWitoPaneRsc() != null) + // simple/lite D2D panes do not display WITO pane + rscHandler.getWitoPaneRsc().handleResize(); + } + + @Override + public void handleZooming() { + + if (heightMarkRscShape != null) + heightMarkRscShape.dispose(); + if (omegaBkgShape != null) { + omegaBkgShape.dispose(); + omegaBkgShape = null; + } + if (omegaRscShape != null) { + omegaRscShape.dispose(); + omegaRscShape = null; + } + + // createRscHeightMarkShape(); + // createRscOmegaShape(); + skewTBackground.handleZooming(); + turbBackground.handleZooming(); + icingBackground.handleZooming(); + if (rscHandler.getWitoPaneRsc() != null) + // simple D2D pane does not display WITO pane + rscHandler.getWitoPaneRsc().handleZooming(); + + } + + @Override + protected void adjustFontSize(float canvasW, float canvasH) { + // TODO Auto-generated method stub + super.adjustFontSize(canvasW, canvasH); + // make a bit bigger font10 size for skewT + float font10Size = 10; + if (font10 != null) { + font10Size = font10.getFontSize() + 1; + font10.dispose(); + } + font10 = target.initializeFont("Monospace", font10Size, null); + } - @Override - protected void adjustFontSize(float canvasW, float canvasH) { - // TODO Auto-generated method stub - super.adjustFontSize(canvasW, canvasH); - //make a bit bigger font10 size for skewT - float font10Size=10; - if(font10!=null){ - font10Size = font10.getFontSize()+1; - font10.dispose(); - } - font10 = target.initializeFont("Monospace", font10Size, null); - } - } diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpTimeStnPaneResource.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpTimeStnPaneResource.java index 3156ddae86..5b83ac4583 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpTimeStnPaneResource.java +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpTimeStnPaneResource.java @@ -1,4 +1,5 @@ package gov.noaa.nws.ncep.ui.nsharp.display.rsc; + /** * * @@ -32,7 +33,6 @@ import com.raytheon.uf.viz.core.DrawableString; import com.raytheon.uf.viz.core.IExtent; import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment; -import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle; import com.raytheon.uf.viz.core.IGraphicsTarget.VerticalAlignment; import com.raytheon.uf.viz.core.PixelExtent; import com.raytheon.uf.viz.core.drawables.PaintProperties; @@ -40,734 +40,847 @@ import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.rsc.AbstractResourceData; import com.raytheon.uf.viz.core.rsc.LoadProperties; -public class NsharpTimeStnPaneResource extends NsharpAbstractPaneResource{ - private Rectangle timeLineRectangle; - private Rectangle stnIdRectangle; - private Rectangle sndRectangle; - private Rectangle colorNoteRectangle; - private List stnElemList; - private List timeElemList; - private List sndElemList; - private List>> stnTimeSndTable; - private int curTimeLineIndex=0; - private int curStnIndex=0; - private int curSndIndex=0; - private int curTimeLinePage=1; - private int curStnIdPage=1; - private int curSndPage=1; - private int totalTimeLinePage=1; - private int totalStnIdPage=1; - private int totalSndPage=1; +public class NsharpTimeStnPaneResource extends NsharpAbstractPaneResource { + private Rectangle timeLineRectangle; + + private Rectangle stnIdRectangle; + + private Rectangle sndRectangle; + + private Rectangle colorNoteRectangle; + + private List stnElemList; + + private List timeElemList; + + private List sndElemList; + + private List>> stnTimeSndTable; + + private int curTimeLineIndex = 0; + + private int curStnIndex = 0; + + private int curSndIndex = 0; + + private int curTimeLinePage = 1; + + private int curStnIdPage = 1; + + private int curSndPage = 1; + + private int totalTimeLinePage = 1; + + private int totalStnIdPage = 1; + + private int totalSndPage = 1; + + private int numLineToShowPerPage = 1; // d2dlite + private int paneWidth = NsharpConstants.TIMESTN_PANE_REC_WIDTH; + private int paneHeight = NsharpConstants.TIMESTN_PANE_REC_HEIGHT; + private int dtXOrig = NsharpConstants.DATA_TIMELINE_X_ORIG; + private int dtYOrig = NsharpConstants.DATA_TIMELINE_Y_ORIG; + private int dtXEnd = NsharpConstants.DATA_TIMELINE_X_END; + private int dtWidth = NsharpConstants.DATA_TIMELINE_WIDTH; + private int dtHeight = NsharpConstants.DATA_TIMELINE_HEIGHT; + private int dtNextPageEnd = NsharpConstants.DATA_TIMELINE_NEXT_PAGE_END_; + private int stnXOrig = NsharpConstants.STATION_ID_X_ORIG; + private int stnYOrig = NsharpConstants.STATION_ID_Y_ORIG; + private int stnXEnd = NsharpConstants.STATION_ID_X_END; + private int stnWidth = NsharpConstants.STATION_ID_WIDTH; + private int stnHeight = NsharpConstants.STATION_ID_HEIGHT; + private int sndXOrig = NsharpConstants.SND_TYPE_X_ORIG; + private int sndYOrig = NsharpConstants.SND_TYPE_Y_ORIG; + private int sndXEnd = NsharpConstants.SND_TYPE_X_END; + private int sndWidth = NsharpConstants.SND_TYPE_WIDTH; + private int sndHeight = NsharpConstants.SND_TYPE_HEIGHT; + private int cnXOrig = NsharpConstants.COLOR_NOTATION_X_ORIG; + private int cnYOrig = NsharpConstants.COLOR_NOTATION_Y_ORIG; - //private int cnXEnd = NsharpConstants.COLOR_NOTATION_X_END; + private int cnWidth = NsharpConstants.COLOR_NOTATION_WIDTH; + private int cnHeight = NsharpConstants.COLOR_NOTATION_HEIGHT; - private float xRatio=1; - private float yRatio=1; - private static String sndTypeStr="NA"; - private static String timelineStr="NA"; - private static String stationStr="NA"; - private boolean compareStnIsOn; - private boolean compareTmIsOn; - private boolean compareSndIsOn; - - public NsharpTimeStnPaneResource(AbstractResourceData resourceData, - LoadProperties loadProperties, NsharpAbstractPaneDescriptor desc) { - super(resourceData, loadProperties, desc); - - timeLineRectangle = new Rectangle(dtXOrig,dtYOrig, - dtWidth,dtHeight); - stnIdRectangle = new Rectangle(stnXOrig,stnYOrig, - stnWidth,stnHeight); - sndRectangle = new Rectangle(sndXOrig,sndYOrig, - sndWidth,sndHeight); - colorNoteRectangle = new Rectangle(cnXOrig,cnYOrig, - cnWidth,cnHeight); - } - - private void drawNsharpColorNotation(IGraphicsTarget target, Rectangle rect) throws VizException { - - PixelExtent extent = new PixelExtent(rect); - RGB color; - target.setupClippingPlane(extent); - target.drawRect(extent,NsharpConstants.backgroundColor, 1.0f, 1.0f); - //plot notations: - if(dtHeight >= paneHeight) - return; - //draw time line page title etc. only when pane box height is larger than timeline box height - double x = cnXOrig+5*xRatio; - double y = cnYOrig+1.5*charHeight; - - //double xGap = paneWidth/3*xRatio; - color = NsharpConstants.color_white; - DrawableString str =new DrawableString( "Line State:",color); - str.font = font10; - str.setCoordinates(x, y); - double horizRatio = paintProps.getView().getExtent().getWidth() / paintProps.getCanvasBounds().width; - x = x + target.getStringsBounds(str).getWidth() * horizRatio ; - - color = NsharpConstants.color_green; - DrawableString str1 =new DrawableString( "Current", color); - str1.setCoordinates(x, y); - str1.font = font10; - x = x + target.getStringsBounds(str1).getWidth() * horizRatio *1.1; - color = NsharpConstants.color_yellow; - DrawableString str2 =new DrawableString( "Active", color); - str2.setCoordinates(x, y); - str2.font = font10; - x = x + target.getStringsBounds(str2).getWidth() * horizRatio * 1.1; + private float xRatio = 1; - color = NsharpConstants.color_white; - DrawableString str3 =new DrawableString( "InActive", color); - str3.setCoordinates(x, y); - str3.font = font10; - - x = cnXOrig+5*xRatio; - y=y+charHeight*1.3; - color = NsharpConstants.color_white; - DrawableString str4 =new DrawableString( "Load Status:", color); - str4.setCoordinates(x, y); - str4.font = font10; - x = x + target.getStringsBounds(str4).getWidth() * horizRatio * 1.1; - color = NsharpConstants.color_red; - DrawableString str5 =new DrawableString( "* :Loaded", color); - str5.setCoordinates(x, y); - str5.font = font10; - x = x + target.getStringsBounds(str5).getWidth() * horizRatio * 1.1; - color = NsharpConstants.color_purple; - DrawableString str6 =new DrawableString( "* :UnLoaded", color); - str6.setCoordinates(x, y); - str6.font = font10; - target.drawStrings(str,str1,str2,str3,str4,str5,str6); - - if(compareStnIsOn || compareSndIsOn || compareTmIsOn){ - x = cnXOrig+5*xRatio; - y=y+charHeight*1.3; - color = NsharpConstants.color_white; - String baseStr=""; - String cursndType, stnId, tl; - if(curTimeLineIndex<0){ - tl=timelineStr; - } - else { - timelineStr = tl = timeElemList.get(curTimeLineIndex).getElementDescription(); - } - if(curSndIndex<0){ - cursndType = sndTypeStr; - } - else { - sndTypeStr = cursndType = sndElemList.get(curSndIndex).getElementDescription() ; - } - if(curStnIndex <0){ - stnId=stationStr; - } - else{ - stationStr = stnId = stnElemList.get(curStnIndex).getElementDescription() ; - } - if(compareStnIsOn) - baseStr = "Comp Stn Based on: "+ tl + "-" + cursndType; - else if(compareSndIsOn) - baseStr = "Comp Src Based on: "+ tl + "-" + stnId; - else - baseStr = "Comp Tm Based on: "+ cursndType + "-" +stnId; + private float yRatio = 1; - DrawableString baseDrawStr =new DrawableString(baseStr, color); - baseDrawStr.setCoordinates(x, y); - baseDrawStr.font = font10; - target.drawStrings( baseDrawStr); - } - target.clearClippingPlane(); + private static String sndTypeStr = "NA"; - } - @SuppressWarnings("deprecation") - private void drawNsharpTimelinBox(IGraphicsTarget target, Rectangle rect) throws VizException { - PixelExtent extent = new PixelExtent(rect); - target.setupClippingPlane(extent); - target.drawRect(extent,NsharpConstants.backgroundColor, 1.0f, 1.0f); - double x; - double y; - String s; - if(dtHeight < paneHeight){ - //draw time line page title etc. only when pane box height is larger than timeline box height - x = dtXOrig; - y = dtYOrig-1.5*charHeight*yRatio; - s = timeElemList.size() + " time lines, page " + curTimeLinePage+"/"+totalTimeLinePage; - target.drawString(font10, s, x, - y, 0.0, - IGraphicsTarget.TextStyle.NORMAL, - NsharpConstants.color_green, - HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - y = dtYOrig; - target.drawLine(dtXOrig, y, 0.0,dtXEnd , y, 0.0,NsharpConstants.color_white,1, LineStyle.SOLID); - + private static String timelineStr = "NA"; - x = dtXOrig +dtWidth/2; - // line divide nextPage and prevPage strings - target.drawLine(x, y, 0.0, - x , y+1.2*charHeight*yRatio, 0.0, - NsharpConstants.color_white,1, LineStyle.SOLID); + private static String stationStr = "NA"; - x = dtXOrig + 5; - y = y+1.2*charHeight*yRatio; - s = "nextPage"; - target.drawString(font10, s, x, - y, 0.0, - IGraphicsTarget.TextStyle.NORMAL, - NsharpConstants.color_yellow, - HorizontalAlignment.LEFT, - VerticalAlignment.BOTTOM, null); - x= dtXOrig + dtWidth/2 + 5; - s = "prevPage"; - target.drawString(font10, s, x, - y, 0.0, - IGraphicsTarget.TextStyle.NORMAL, - NsharpConstants.color_yellow, - HorizontalAlignment.LEFT, - VerticalAlignment.BOTTOM, null); + private boolean compareStnIsOn; - //line below nextPage string - target.drawLine(dtXOrig, y, 0.0, - dtXEnd , y, 0.0, - NsharpConstants.color_white,1, LineStyle.SOLID); + private boolean compareTmIsOn; - } - int numTimeLineToShowPerPage = (cnYOrig-dtNextPageEnd)/charHeight; - if(numTimeLineToShowPerPage <1){ - numTimeLineToShowPerPage = dtHeight/charHeight; - if(numTimeLineToShowPerPage <1) - numTimeLineToShowPerPage=1; - } - int startIndex = (curTimeLinePage-1) * numTimeLineToShowPerPage; - if(startIndex<0) - startIndex =0; - if(timeElemList!= null){ - int colorIndex; - double ly = dtNextPageEnd + charHeight; - RGB color; - double hRatio = paintProps.getView().getExtent().getWidth() / paintProps.getCanvasBounds().width; - Rectangle2D strBD = target.getStringBounds(font10, "*"); - double xGap = 2*strBD.getWidth()*hRatio; - for (int j = startIndex; j< timeElemList.size(); j++) - { - x = dtXOrig + 5; - boolean avail=false; - NsharpOperationElement elm = timeElemList.get(j); - NsharpConstants.ActState sta = elm.getActionState(); + private boolean compareSndIsOn; - if(sta == NsharpConstants.ActState.ACTIVE && j == curTimeLineIndex) - sta = NsharpConstants.ActState.CURRENT; - if(curStnIndex>=0 && curSndIndex >=0) { - s = "*"; - if ( stnTimeSndTable.get(curStnIndex).get(j).get(curSndIndex)!=null){ - avail = true; - } - if(avail){ - color = NsharpConstants.color_red; - if(sta == NsharpConstants.ActState.CURRENT) - color = NsharpConstants.color_green; - } - else { - color = NsharpConstants.color_purple; - } - //System.out.println("selectedTimeList: "+ s); + public NsharpTimeStnPaneResource(AbstractResourceData resourceData, + LoadProperties loadProperties, NsharpAbstractPaneDescriptor desc) { + super(resourceData, loadProperties, desc); - target.drawString(font10, s, x, - ly, 0.0, - IGraphicsTarget.TextStyle.NORMAL, - color, - HorizontalAlignment.LEFT, - VerticalAlignment.BOTTOM, null); - } - - x=x+xGap; - RGB tmLnColor = rscHandler.getElementColorMap().get(sta.name()); - String tmDesStr = elm.getElementDescription(); - double tmX=x; - - if(compareTmIsOn && elm.getActionState() == NsharpConstants.ActState.ACTIVE - && avail){ - colorIndex = stnTimeSndTable.get(curStnIndex).get(j).get(curSndIndex).getCompColorIndex(); - strBD = target.getStringBounds(font10, tmDesStr); - String colorIndexStr =""+ (colorIndex % NsharpConstants.LINE_COMP1 + 1);//compIndex; - x=x+ strBD.getWidth()*hRatio+5; - target.drawString(font10,colorIndexStr, x, - ly, 0.0, - IGraphicsTarget.TextStyle.NORMAL, - linePropertyMap.get(NsharpConstants.lineNameArray[colorIndex]).getLineColor(), - HorizontalAlignment.LEFT, - VerticalAlignment.BOTTOM, null); - tmLnColor = linePropertyMap.get(NsharpConstants.lineNameArray[colorIndex]).getLineColor(); - } - else if((compareStnIsOn||compareSndIsOn) && elm.getActionState() == NsharpConstants.ActState.ACTIVE && timeElemList.indexOf(elm) == curTimeLineIndex - && avail){ - colorIndex = stnTimeSndTable.get(curStnIndex).get(curTimeLineIndex).get(curSndIndex).getCompColorIndex(); - strBD = target.getStringBounds(font10, tmDesStr); - String colorIndexStr =""+ (colorIndex % NsharpConstants.LINE_COMP1 + 1);//compIndex; - x=x+ strBD.getWidth()*hRatio+5; - target.drawString(font10,colorIndexStr, x, - ly, 0.0, - IGraphicsTarget.TextStyle.NORMAL, - linePropertyMap.get(NsharpConstants.lineNameArray[colorIndex]).getLineColor(), - HorizontalAlignment.LEFT, - VerticalAlignment.BOTTOM, null); - tmLnColor = linePropertyMap.get(NsharpConstants.lineNameArray[colorIndex]).getLineColor(); - } - target.drawString(font10, tmDesStr, tmX, - ly, 0.0, - IGraphicsTarget.TextStyle.NORMAL, - tmLnColor, - HorizontalAlignment.LEFT, - VerticalAlignment.BOTTOM, null); - ly = ly + charHeight; - if (ly >= cnYOrig)//-charHeight) - //we dont show time line that extends below time line box - break; - } - } + timeLineRectangle = new Rectangle(dtXOrig, dtYOrig, dtWidth, dtHeight); + stnIdRectangle = new Rectangle(stnXOrig, stnYOrig, stnWidth, stnHeight); + sndRectangle = new Rectangle(sndXOrig, sndYOrig, sndWidth, sndHeight); + colorNoteRectangle = new Rectangle(cnXOrig, cnYOrig, cnWidth, cnHeight); } - @SuppressWarnings("deprecation") - private void drawNsharpStationIdBox(IGraphicsTarget target, Rectangle rect) throws VizException { + + private void drawNsharpColorNotation(IGraphicsTarget target, Rectangle rect) + throws VizException { + PixelExtent extent = new PixelExtent(rect); - target.setupClippingPlane(extent); - target.drawRect(extent,NsharpConstants.backgroundColor, 1.0f, 1.0f); - double x; - double y; - String s; - if(dtHeight < paneHeight){ - //draw time line page title etc. only when pane box height is larger than timeline box height - x = stnXOrig; - y = stnYOrig -1.5*charHeight*yRatio; - s = stnElemList.size() + " stations, page " + curStnIdPage+"/"+totalStnIdPage; - target.drawString(font10, s, x, - y, 0.0, - IGraphicsTarget.TextStyle.NORMAL, - NsharpConstants.color_green, - HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - y = dtYOrig; - target.drawLine(stnXOrig, y, 0.0,stnXEnd , y, 0.0,NsharpConstants.color_white,1, LineStyle.SOLID); - //System.out.println("drawNsharpDataTimelines picked stn info: "+ pickedStnInfoStr); - x = stnXOrig +stnWidth/2; - // line divide nextPage and prevPage strings - target.drawLine(x, y, 0.0, - x , y+1.2*charHeight*yRatio, 0.0, - NsharpConstants.color_white,1, LineStyle.SOLID); + RGB color; + target.setupClippingPlane(extent); + target.drawRect(extent, NsharpConstants.backgroundColor, 1.0f, 1.0f); + // plot notations: + if (dtHeight >= paneHeight) + return; + // draw time line page title etc. only when pane box height is larger + // than timeline box height + double x = cnXOrig + 5 * xRatio; + double y = cnYOrig + 1.5 * charHeight; - x = stnXOrig + 5; - y = y+1.2*charHeight*yRatio; - s = "nextPage"; - target.drawString(font10, s, x, - y, 0.0, - IGraphicsTarget.TextStyle.NORMAL, - NsharpConstants.color_yellow, - HorizontalAlignment.LEFT, - VerticalAlignment.BOTTOM, null); + // double xGap = paneWidth/3*xRatio; + color = NsharpConstants.color_white; + DrawableString str = new DrawableString("Line State:", color); + str.font = font12; + str.setCoordinates(x, y); + double horizRatio = paintProps.getView().getExtent().getWidth() + / paintProps.getCanvasBounds().width; + x = x + target.getStringsBounds(str).getWidth() * horizRatio; - x= stnXOrig + stnWidth/2 + 5; - s = "prevPage"; - target.drawString(font10, s, x, - y, 0.0, - IGraphicsTarget.TextStyle.NORMAL, - NsharpConstants.color_yellow, - HorizontalAlignment.LEFT, - VerticalAlignment.BOTTOM, null); + color = NsharpConstants.color_green; + DrawableString str1 = new DrawableString("Current", color); + str1.setCoordinates(x, y); + str1.font = font12; + x = x + target.getStringsBounds(str1).getWidth() * horizRatio * 1.1; + color = NsharpConstants.color_yellow; + DrawableString str2 = new DrawableString("Active", color); + str2.setCoordinates(x, y); + str2.font = font12; + x = x + target.getStringsBounds(str2).getWidth() * horizRatio * 1.1; - //line below neextPage string - target.drawLine(stnXOrig, y, 0.0, - stnXEnd , y, 0.0, - NsharpConstants.color_white,1, LineStyle.SOLID); - } + color = NsharpConstants.color_white; + DrawableString str3 = new DrawableString("InActive", color); + str3.setCoordinates(x, y); + str3.font = font12; - int numStnToShow = (cnYOrig-dtNextPageEnd)/charHeight; - if(numStnToShow <1){ - numStnToShow = dtHeight/charHeight; - if(numStnToShow <1) - numStnToShow=1; - } - int startIndex = (rscHandler.getCurStnIdPage()-1) * numStnToShow; - if(startIndex<0) - startIndex =0; - int colorIndex; - double ly = dtNextPageEnd + charHeight; - RGB color; - Rectangle2D strBD = target.getStringBounds(font10, "*"); - double hRatio = paintProps.getView().getExtent().getWidth() / paintProps.getCanvasBounds().width; - double xGap = 2*strBD.getWidth()*hRatio; - for (int j = startIndex; j< stnElemList.size(); j++) - { - boolean avail=false; - x = stnXOrig + 5; - NsharpOperationElement elm = stnElemList.get(j); - NsharpConstants.ActState sta = elm.getActionState(); - if(sta == NsharpConstants.ActState.ACTIVE && j == curStnIndex) - sta = NsharpConstants.ActState.CURRENT; - - - if (curTimeLineIndex>=0 && curSndIndex >=0){ - if(stnTimeSndTable.get(j).get(curTimeLineIndex).get(curSndIndex)!=null ){ - avail =true; - } - s = "*"; - if(avail){ - color = NsharpConstants.color_red; - if(sta == NsharpConstants.ActState.CURRENT) - color = NsharpConstants.color_green; - } - else { - color = NsharpConstants.color_purple; - } - target.drawString(font10, s, x, - ly, 0.0, - IGraphicsTarget.TextStyle.NORMAL, - color, - HorizontalAlignment.LEFT, - VerticalAlignment.BOTTOM, null); - } - x=x+xGap; - String stnId = elm.elementDescription; - double stnIdX = x; - color = rscHandler.getElementColorMap().get(sta.name()); - - if( elm.getActionState() == NsharpConstants.ActState.ACTIVE && avail){ - if(compareStnIsOn){ - strBD = target.getStringBounds(font10, stnId); - //colorIndex = (compIndex-1)%(NsharpConstants.LINE_COMP10-NsharpConstants.LINE_COMP1+1)+ NsharpConstants.LINE_COMP1; - colorIndex = stnTimeSndTable.get(j).get(curTimeLineIndex).get(curSndIndex).getCompColorIndex(); - color = linePropertyMap.get(NsharpConstants.lineNameArray[colorIndex]).getLineColor(); - s =""+ (colorIndex % NsharpConstants.LINE_COMP1 + 1); - x=x+ strBD.getWidth()*hRatio+5; - target.drawString(font10,s, x, - ly, 0.0, - IGraphicsTarget.TextStyle.NORMAL, - color, - HorizontalAlignment.LEFT, - VerticalAlignment.BOTTOM, null); - } - else if((compareTmIsOn||compareSndIsOn) && j == curStnIndex){ - strBD = target.getStringBounds(font10, stnId); - //colorIndex = (compIndex-1)%(NsharpConstants.LINE_COMP10-NsharpConstants.LINE_COMP1+1)+ NsharpConstants.LINE_COMP1; - colorIndex = stnTimeSndTable.get(curStnIndex).get(curTimeLineIndex).get(curSndIndex).getCompColorIndex(); - color = linePropertyMap.get(NsharpConstants.lineNameArray[colorIndex]).getLineColor(); - s =""+ (colorIndex % NsharpConstants.LINE_COMP1 + 1); - x=x+ strBD.getWidth()*hRatio+5; - target.drawString(font10,s, x, - ly, 0.0, - IGraphicsTarget.TextStyle.NORMAL, - color, - HorizontalAlignment.LEFT, - VerticalAlignment.BOTTOM, null); - } - } - target.drawString(font10, stnId, stnIdX, - ly, 0.0, - IGraphicsTarget.TextStyle.NORMAL, - color, - HorizontalAlignment.LEFT, - VerticalAlignment.BOTTOM, null); - ly = ly + charHeight; - if (ly >= cnYOrig) - //we dont show stn id that extends below box - break; + x = cnXOrig + 5 * xRatio; + y = y + charHeight * 1.3; + color = NsharpConstants.color_white; + DrawableString str4 = new DrawableString("Load Status:", color); + str4.setCoordinates(x, y); + str4.font = font12; + x = x + target.getStringsBounds(str4).getWidth() * horizRatio * 1.1; + color = NsharpConstants.color_red; + DrawableString str5 = new DrawableString("* :Loaded", color); + str5.setCoordinates(x, y); + str5.font = font12; + x = x + target.getStringsBounds(str5).getWidth() * horizRatio * 1.1; + color = NsharpConstants.color_purple; + DrawableString str6 = new DrawableString("* :UnLoaded", color); + str6.setCoordinates(x, y); + str6.font = font12; + target.drawStrings(str, str1, str2, str3, str4, str5, str6); + + if (compareStnIsOn || compareSndIsOn || compareTmIsOn) { + x = cnXOrig + 5 * xRatio; + y = y + charHeight * 1.3; + color = NsharpConstants.color_white; + String baseStr = ""; + String cursndType, stnId, tl; + if (curTimeLineIndex < 0) { + tl = timelineStr; + } else { + timelineStr = tl = timeElemList.get(curTimeLineIndex) + .getElementDescription(); + } + if (curSndIndex < 0) { + cursndType = sndTypeStr; + } else { + sndTypeStr = cursndType = sndElemList.get(curSndIndex) + .getElementDescription(); + } + if (curStnIndex < 0) { + stnId = stationStr; + } else { + stationStr = stnId = stnElemList.get(curStnIndex) + .getElementDescription(); + } + if (compareStnIsOn) + baseStr = "Comp Stn Based on: " + tl + "-" + cursndType; + else if (compareSndIsOn) + baseStr = "Comp Src Based on: " + tl + "-" + stnId; + else + baseStr = "Comp Tm Based on: " + cursndType + "-" + stnId; + + DrawableString baseDrawStr = new DrawableString(baseStr, color); + baseDrawStr.setCoordinates(x, y); + baseDrawStr.font = font12; + target.drawStrings(baseDrawStr); + } + target.clearClippingPlane(); + + } + + @SuppressWarnings("deprecation") + private void drawNsharpTimelinBox(IGraphicsTarget target, Rectangle rect) + throws VizException { + PixelExtent extent = new PixelExtent(rect); + target.setupClippingPlane(extent); + target.drawRect(extent, NsharpConstants.backgroundColor, 1.0f, 1.0f); + double x; + double y; + String s; + if (dtHeight < paneHeight) { + // draw time line page title etc. only when pane box height is + // larger than timeline box height + // start d2dlite + + x = dtXOrig; + y = dtYOrig - 1.5 * charHeight * yRatio; + s = timeElemList.size() + " times, p " + curTimeLinePage + "/" + + totalTimeLinePage; + target.drawString(font12, s, x, y, 0.0, + IGraphicsTarget.TextStyle.NORMAL, + NsharpConstants.color_green, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + y = dtYOrig; + PixelExtent boxExt = new PixelExtent(dtXOrig, dtXOrig + dtWidth, + dtYOrig + 2 * charHeight * yRatio, dtYOrig); + // blank out box, should draw this first and then draw data on top + // of it + target.drawShadedRect(boxExt, NsharpConstants.color_lightblue, 1f, + null); + PixelExtent boxExt1 = new PixelExtent(dtXOrig, dtXOrig + dtWidth + / 2, dtYOrig + 2 * charHeight * yRatio, dtYOrig); + target.drawRect(boxExt1, NsharpConstants.color_red, 4, 1); + PixelExtent boxExt2 = new PixelExtent(dtXOrig + dtWidth / 2, + dtXOrig + dtWidth, dtYOrig + 2 * charHeight * yRatio, + dtYOrig); + target.drawRect(boxExt2, NsharpConstants.color_red, 4, 1); + x = dtXOrig + 5; + y = y + 2 * charHeight * yRatio; + + s = " NxP "; + target.drawString(font20, s, x, y, 0.0, + IGraphicsTarget.TextStyle.DROP_SHADOW, + NsharpConstants.color_black, HorizontalAlignment.LEFT, + VerticalAlignment.BOTTOM, null); + x = dtXOrig + dtWidth / 2 + 5; + s = " PvP "; + target.drawString(font20, s, x, y, 0.0, + IGraphicsTarget.TextStyle.DROP_SHADOW, + NsharpConstants.color_black, HorizontalAlignment.LEFT, + VerticalAlignment.BOTTOM, null); + + // end d2dlite + + } + int startIndex = (curTimeLinePage - 1) * numLineToShowPerPage; + if (startIndex < 0) + startIndex = 0; + if (timeElemList != null) { + int colorIndex; + double ly = dtNextPageEnd + charHeight; + RGB color; + double hRatio = paintProps.getView().getExtent().getWidth() + / paintProps.getCanvasBounds().width; + Rectangle2D strBD = target.getStringBounds(font12, "*"); + double xGap = 2 * strBD.getWidth() * hRatio; + for (int j = startIndex, count = 0; j < timeElemList.size() + && count < numLineToShowPerPage; j++, count++) { + x = dtXOrig + 5; + boolean avail = false; + NsharpOperationElement elm = timeElemList.get(j); + NsharpConstants.ActState sta = elm.getActionState(); + + if (sta == NsharpConstants.ActState.ACTIVE + && j == curTimeLineIndex) + sta = NsharpConstants.ActState.CURRENT; + if (curStnIndex >= 0 && curSndIndex >= 0) { + s = "*"; + if (stnTimeSndTable.get(curStnIndex).get(j) + .get(curSndIndex) != null) { + avail = true; + } + if (avail) { + color = NsharpConstants.color_red; + if (sta == NsharpConstants.ActState.CURRENT) + color = NsharpConstants.color_green; + } else { + color = NsharpConstants.color_purple; + } + // System.out.println("selectedTimeList: "+ s); + + target.drawString(font12, s, x, ly, 0.0, + IGraphicsTarget.TextStyle.NORMAL, color, + HorizontalAlignment.LEFT, VerticalAlignment.BOTTOM, + null); + } + + x = x + xGap; + RGB tmLnColor = rscHandler.getElementColorMap().get(sta.name()); + String tmDesStr = elm.getElementDescription(); + // d2dlite - convert timeDesStr for GUI display + + double tmX = x; + + if (compareTmIsOn + && elm.getActionState() == NsharpConstants.ActState.ACTIVE + && avail) { + colorIndex = stnTimeSndTable.get(curStnIndex).get(j) + .get(curSndIndex).getCompColorIndex(); + strBD = target.getStringBounds(font12, tmDesStr); + String colorIndexStr = "" + + (colorIndex % NsharpConstants.LINE_COMP1 + 1);// compIndex; + x = x + strBD.getWidth() * hRatio + 5; + target.drawString( + font12, + colorIndexStr, + x, + ly, + 0.0, + IGraphicsTarget.TextStyle.NORMAL, + linePropertyMap.get( + NsharpConstants.lineNameArray[colorIndex]) + .getLineColor(), HorizontalAlignment.LEFT, + VerticalAlignment.BOTTOM, null); + tmLnColor = linePropertyMap.get( + NsharpConstants.lineNameArray[colorIndex]) + .getLineColor(); + } else if ((compareStnIsOn || compareSndIsOn) + && elm.getActionState() == NsharpConstants.ActState.ACTIVE + && timeElemList.indexOf(elm) == curTimeLineIndex + && avail) { + colorIndex = stnTimeSndTable.get(curStnIndex) + .get(curTimeLineIndex).get(curSndIndex) + .getCompColorIndex(); + strBD = target.getStringBounds(font12, tmDesStr); + String colorIndexStr = "" + + (colorIndex % NsharpConstants.LINE_COMP1 + 1);// compIndex; + x = x + strBD.getWidth() * hRatio + 5; + target.drawString( + font12, + colorIndexStr, + x, + ly, + 0.0, + IGraphicsTarget.TextStyle.NORMAL, + linePropertyMap.get( + NsharpConstants.lineNameArray[colorIndex]) + .getLineColor(), HorizontalAlignment.LEFT, + VerticalAlignment.BOTTOM, null); + tmLnColor = linePropertyMap.get( + NsharpConstants.lineNameArray[colorIndex]) + .getLineColor(); + } + target.drawString(font12, tmDesStr, tmX, ly, 0.0, + IGraphicsTarget.TextStyle.NORMAL, tmLnColor, + HorizontalAlignment.LEFT, VerticalAlignment.BOTTOM, + null); + ly = ly + lineHeight; + if (ly >= cnYOrig) + // we dont show time line that extends below time line box + break; + } } } - + @SuppressWarnings("deprecation") - private void drawNsharpSndTypeBox(IGraphicsTarget target, Rectangle rect) throws VizException { + private void drawNsharpStationIdBox(IGraphicsTarget target, Rectangle rect) + throws VizException { PixelExtent extent = new PixelExtent(rect); - target.setupClippingPlane(extent); - target.drawRect(extent,NsharpConstants.backgroundColor, 1.0f, 1.0f); - double x; - double y; - String s; - if(dtHeight < paneHeight){ - //draw time line page title etc. only when pane box height is larger than timeline box height - x = sndXOrig; - y = sndYOrig -1.5*charHeight*yRatio; - s = sndElemList.size() + " srcs, page " + curSndPage+"/"+totalSndPage; - target.drawString(font10, s, x, - y, 0.0, - IGraphicsTarget.TextStyle.NORMAL, - NsharpConstants.color_green, - HorizontalAlignment.LEFT, - VerticalAlignment.TOP, null); - y = sndYOrig; - target.drawLine(sndXOrig, y, 0.0,sndXEnd , y, 0.0,NsharpConstants.color_white,1, LineStyle.SOLID); - //System.out.println("drawNsharpDataTimelines picked stn info: "+ pickedStnInfoStr); - x = sndXOrig +sndWidth/2; - // line divide nextPage and prevPage strings - target.drawLine(x, y, 0.0, - x , y+1.2*charHeight*yRatio, 0.0, - NsharpConstants.color_white,1, LineStyle.SOLID); + target.setupClippingPlane(extent); + target.drawRect(extent, NsharpConstants.backgroundColor, 1.0f, 1.0f); + double x; + double y; + String s; + if (dtHeight < paneHeight) { + // draw time line page title etc. only when pane box height is + // larger than timeline box height + // start d2dlite + x = stnXOrig; + y = stnYOrig - 1.5 * charHeight * yRatio; + s = stnElemList.size() + " stn, p " + curStnIdPage + "/" + + totalStnIdPage; + target.drawString(font12, s, x, y, 0.0, + IGraphicsTarget.TextStyle.NORMAL, + NsharpConstants.color_green, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + y = dtYOrig; + PixelExtent boxExt = new PixelExtent(stnXOrig, stnXOrig + stnWidth, + stnYOrig + 2 * charHeight * yRatio, stnYOrig); + // blank out box, should draw this first and then draw data on top + // of it + target.drawShadedRect(boxExt, NsharpConstants.color_lightblue, 1f, + null); + PixelExtent boxExt1 = new PixelExtent(stnXOrig, stnXOrig + stnWidth + / 2, stnYOrig + 2 * charHeight * yRatio, stnYOrig); + target.drawRect(boxExt1, NsharpConstants.color_red, 4, 1); + PixelExtent boxExt2 = new PixelExtent(stnXOrig + stnWidth / 2, + stnXOrig + stnWidth, stnYOrig + 2 * charHeight * yRatio, + stnYOrig); + target.drawRect(boxExt2, NsharpConstants.color_red, 4, 1); - x = sndXOrig + 5; - y = y+1.2*charHeight*yRatio; - s = "nextPage"; - target.drawString(font10, s, x, - y, 0.0, - IGraphicsTarget.TextStyle.NORMAL, - NsharpConstants.color_yellow, - HorizontalAlignment.LEFT, - VerticalAlignment.BOTTOM, null); + x = stnXOrig + 5; + y = y + 2 * charHeight * yRatio; + s = "NxP "; + target.drawString(font20, s, x, y, 0.0, + IGraphicsTarget.TextStyle.DROP_SHADOW, + NsharpConstants.color_black, HorizontalAlignment.LEFT, + VerticalAlignment.BOTTOM, null); + x = stnXOrig + stnWidth / 2 + 5; + s = "PvP "; + target.drawString(font20, s, x, y, 0.0, + IGraphicsTarget.TextStyle.DROP_SHADOW, + NsharpConstants.color_black, HorizontalAlignment.LEFT, + VerticalAlignment.BOTTOM, null); - x= sndXOrig + sndWidth/2 + 5; - s = "prevPage"; - target.drawString(font10, s, x, - y, 0.0, - IGraphicsTarget.TextStyle.NORMAL, - NsharpConstants.color_yellow, - HorizontalAlignment.LEFT, - VerticalAlignment.BOTTOM, null); + // end d2dlite + } - //line below neextPage string - target.drawLine(sndXOrig, y, 0.0, - sndXEnd , y, 0.0, - NsharpConstants.color_white,1, LineStyle.SOLID); - } - - int numStnToShow = (cnYOrig-dtNextPageEnd)/charHeight; - if(numStnToShow <1){ - numStnToShow = dtHeight/charHeight; - if(numStnToShow <1) - numStnToShow=1; - } - int startIndex = (rscHandler.getCurSndPage()-1) * numStnToShow; - if(startIndex<0) - startIndex =0; + int startIndex = (rscHandler.getCurStnIdPage() - 1) + * numLineToShowPerPage; + if (startIndex < 0) + startIndex = 0; int colorIndex; - double ly = dtNextPageEnd + charHeight; - RGB color; - Rectangle2D strBD = target.getStringBounds(font10, "*"); - double hRatio = paintProps.getView().getExtent().getWidth() / paintProps.getCanvasBounds().width; - double xGap = 2*strBD.getWidth()*hRatio; - for (int j = startIndex; j< sndElemList.size(); j++) - { - boolean avail=false; - x = sndXOrig + 5; - NsharpOperationElement elm = sndElemList.get(j); - NsharpConstants.ActState sta = elm.getActionState(); - if(sta == NsharpConstants.ActState.ACTIVE && j == curSndIndex) - sta = NsharpConstants.ActState.CURRENT; - - - if (curTimeLineIndex>=0 && curStnIndex >=0){ - if(stnTimeSndTable.get(curStnIndex).get(curTimeLineIndex).get(j)!=null ){ - avail =true; - } - s = "*"; - if(avail){ - color = NsharpConstants.color_red; - if(sta == NsharpConstants.ActState.CURRENT) - color = NsharpConstants.color_green; - } - else { - color = NsharpConstants.color_purple; - } - target.drawString(font10, s, x, - ly, 0.0, - IGraphicsTarget.TextStyle.NORMAL, - color, - HorizontalAlignment.LEFT, - VerticalAlignment.BOTTOM, null); - } - x=x+xGap; - String sndType = elm.elementDescription; - double sndX = x; - color = rscHandler.getElementColorMap().get(sta.name()); - - if( elm.getActionState() == NsharpConstants.ActState.ACTIVE && avail){ - if(compareSndIsOn){ - strBD = target.getStringBounds(font10, sndType); - //colorIndex = (compIndex-1)%(NsharpConstants.LINE_COMP10-NsharpConstants.LINE_COMP1+1)+ NsharpConstants.LINE_COMP1; - colorIndex = stnTimeSndTable.get(curStnIndex).get(curTimeLineIndex).get(j).getCompColorIndex(); - color = linePropertyMap.get(NsharpConstants.lineNameArray[colorIndex]).getLineColor(); - s =""+ (colorIndex % NsharpConstants.LINE_COMP1 + 1); - x=x+ strBD.getWidth()*hRatio+5; - target.drawString(font10,s, x, - ly, 0.0, - IGraphicsTarget.TextStyle.NORMAL, - color, - HorizontalAlignment.LEFT, - VerticalAlignment.BOTTOM, null); - } - else if((compareTmIsOn||compareStnIsOn) && j == curSndIndex){ - strBD = target.getStringBounds(font10, sndType); - //colorIndex = (compIndex-1)%(NsharpConstants.LINE_COMP10-NsharpConstants.LINE_COMP1+1)+ NsharpConstants.LINE_COMP1; - colorIndex = stnTimeSndTable.get(curStnIndex).get(curTimeLineIndex).get(curSndIndex).getCompColorIndex(); - color = linePropertyMap.get(NsharpConstants.lineNameArray[colorIndex]).getLineColor(); - s =""+ (colorIndex % NsharpConstants.LINE_COMP1 + 1); - x=x+ strBD.getWidth()*hRatio+5; - target.drawString(font10,s, x, - ly, 0.0, - IGraphicsTarget.TextStyle.NORMAL, - color, - HorizontalAlignment.LEFT, - VerticalAlignment.BOTTOM, null); - } - } - target.drawString(font10, sndType, sndX, - ly, 0.0, - IGraphicsTarget.TextStyle.NORMAL, - color, - HorizontalAlignment.LEFT, - VerticalAlignment.BOTTOM, null); - ly = ly + charHeight; - if (ly >= cnYOrig) - //we dont show stn id that extends below box - break; + double ly = dtNextPageEnd + charHeight; + RGB color; + Rectangle2D strBD = target.getStringBounds(font12, "*"); + double hRatio = paintProps.getView().getExtent().getWidth() + / paintProps.getCanvasBounds().width; + double xGap = 2 * strBD.getWidth() * hRatio; + for (int j = startIndex, count = 0; j < stnElemList.size() + && count < numLineToShowPerPage; j++, count++) { + boolean avail = false; + x = stnXOrig + 5; + NsharpOperationElement elm = stnElemList.get(j); + NsharpConstants.ActState sta = elm.getActionState(); + if (sta == NsharpConstants.ActState.ACTIVE && j == curStnIndex) + sta = NsharpConstants.ActState.CURRENT; + + if (curTimeLineIndex >= 0 && curSndIndex >= 0) { + if (stnTimeSndTable.get(j).get(curTimeLineIndex) + .get(curSndIndex) != null) { + avail = true; + } + s = "*"; + if (avail) { + color = NsharpConstants.color_red; + if (sta == NsharpConstants.ActState.CURRENT) + color = NsharpConstants.color_green; + } else { + color = NsharpConstants.color_purple; + } + target.drawString(font12, s, x, ly, 0.0, + IGraphicsTarget.TextStyle.NORMAL, color, + HorizontalAlignment.LEFT, VerticalAlignment.BOTTOM, + null); + } + x = x + xGap; + String stnId = elm.elementDescription; + double stnIdX = x; + color = rscHandler.getElementColorMap().get(sta.name()); + + if (elm.getActionState() == NsharpConstants.ActState.ACTIVE + && avail) { + if (compareStnIsOn) { + strBD = target.getStringBounds(font12, stnId); + // colorIndex = + // (compIndex-1)%(NsharpConstants.LINE_COMP10-NsharpConstants.LINE_COMP1+1)+ + // NsharpConstants.LINE_COMP1; + colorIndex = stnTimeSndTable.get(j).get(curTimeLineIndex) + .get(curSndIndex).getCompColorIndex(); + color = linePropertyMap.get( + NsharpConstants.lineNameArray[colorIndex]) + .getLineColor(); + s = "" + (colorIndex % NsharpConstants.LINE_COMP1 + 1); + x = x + strBD.getWidth() * hRatio + 5; + target.drawString(font12, s, x, ly, 0.0, + IGraphicsTarget.TextStyle.NORMAL, color, + HorizontalAlignment.LEFT, VerticalAlignment.BOTTOM, + null); + } else if ((compareTmIsOn || compareSndIsOn) + && j == curStnIndex) { + strBD = target.getStringBounds(font12, stnId); + // colorIndex = + // (compIndex-1)%(NsharpConstants.LINE_COMP10-NsharpConstants.LINE_COMP1+1)+ + // NsharpConstants.LINE_COMP1; + colorIndex = stnTimeSndTable.get(curStnIndex) + .get(curTimeLineIndex).get(curSndIndex) + .getCompColorIndex(); + color = linePropertyMap.get( + NsharpConstants.lineNameArray[colorIndex]) + .getLineColor(); + s = "" + (colorIndex % NsharpConstants.LINE_COMP1 + 1); + x = x + strBD.getWidth() * hRatio + 5; + target.drawString(font12, s, x, ly, 0.0, + IGraphicsTarget.TextStyle.NORMAL, color, + HorizontalAlignment.LEFT, VerticalAlignment.BOTTOM, + null); + } + } + target.drawString(font12, stnId, stnIdX, ly, 0.0, + IGraphicsTarget.TextStyle.NORMAL, color, + HorizontalAlignment.LEFT, VerticalAlignment.BOTTOM, null); + ly = ly + lineHeight; + if (ly >= cnYOrig) + // we dont show stn id that extends below box + break; } } - @Override - protected void paintInternal(IGraphicsTarget target, - PaintProperties paintProps) throws VizException { - super.paintInternal(target, paintProps); - //defineCharHeight(font10); - //System.out.println("timeStn paintInternal zoomL="+currentZoomLevel); - if(rscHandler== null) - return; - stnElemList = rscHandler.getStnElementList(); - timeElemList = rscHandler.getTimeElementList(); - sndElemList = rscHandler.getSndElementList(); - curTimeLineIndex = rscHandler.getCurrentTimeElementListIndex(); - curStnIndex = rscHandler.getCurrentStnElementListIndex(); - curSndIndex = rscHandler.getCurrentSndElementListIndex(); - curTimeLinePage = rscHandler.getCurTimeLinePage(); - curStnIdPage = rscHandler.getCurStnIdPage(); - curSndPage = rscHandler.getCurSndPage(); - totalTimeLinePage = rscHandler.getTotalTimeLinePage(); - totalStnIdPage = rscHandler.getTotalStnIdPage(); - totalSndPage = rscHandler.getTotalSndPage(); - compareStnIsOn = rscHandler.isCompareStnIsOn(); - compareSndIsOn = rscHandler.isCompareSndIsOn(); - compareTmIsOn = rscHandler.isCompareTmIsOn(); - stnTimeSndTable = rscHandler.getStnTimeSndTable(); - this.font10.setSmoothing(false); - this.font10.setScaleFont(false); - this.font9.setSmoothing(false); - this.font9.setScaleFont(false); - this.font12.setSmoothing(false); - this.font12.setScaleFont(false); - //plot data time line - drawNsharpTimelinBox(target, timeLineRectangle); + @SuppressWarnings("deprecation") + private void drawNsharpSndTypeBox(IGraphicsTarget target, Rectangle rect) + throws VizException { + PixelExtent extent = new PixelExtent(rect); + target.setupClippingPlane(extent); + target.drawRect(extent, NsharpConstants.backgroundColor, 1.0f, 1.0f); + double x; + double y; + String s; + if (dtHeight < paneHeight) { + // draw time line page title etc. only when pane box height is + // larger than timeline box height + // start d2dlite + x = sndXOrig; + y = sndYOrig - 1.5 * charHeight * yRatio; + s = sndElemList.size() + " srcs, p " + curSndPage + "/" + + totalSndPage; + target.drawString(font12, s, x, y, 0.0, + IGraphicsTarget.TextStyle.NORMAL, + NsharpConstants.color_green, HorizontalAlignment.LEFT, + VerticalAlignment.TOP, null); + y = sndYOrig; + PixelExtent boxExt = new PixelExtent(sndXOrig, sndXOrig + sndWidth, + sndYOrig + 2 * charHeight * yRatio, sndYOrig); + // blank out box, should draw this first and then draw data on top + // of it + target.drawShadedRect(boxExt, NsharpConstants.color_lightblue, 1f, + null); + PixelExtent boxExt1 = new PixelExtent(sndXOrig, sndXOrig + sndWidth + / 2, sndYOrig + 2 * charHeight * yRatio, sndYOrig); + target.drawRect(boxExt1, NsharpConstants.color_red, 4, 1); + PixelExtent boxExt2 = new PixelExtent(sndXOrig + sndWidth / 2, + sndXOrig + sndWidth, sndYOrig + 2 * charHeight * yRatio, + sndYOrig); + target.drawRect(boxExt2, NsharpConstants.color_red, 4, 1); - //plot station id - drawNsharpStationIdBox(target, stnIdRectangle); - - drawNsharpSndTypeBox(target, sndRectangle); - //plot color notations - drawNsharpColorNotation(target, colorNoteRectangle ); + x = sndXOrig + 5; + y = y + 2 * charHeight * yRatio; + s = " NxP "; + target.drawString(font20, s, x, y, 0.0, + IGraphicsTarget.TextStyle.DROP_SHADOW, + NsharpConstants.color_black, HorizontalAlignment.LEFT, + VerticalAlignment.BOTTOM, null); - } + x = sndXOrig + sndWidth / 2 + 5; + s = " PvP "; + target.drawString(font20, s, x, y, 0.0, + IGraphicsTarget.TextStyle.DROP_SHADOW, + NsharpConstants.color_black, HorizontalAlignment.LEFT, + VerticalAlignment.BOTTOM, null); - @Override - protected void initInternal(IGraphicsTarget target) throws VizException { - super.initInternal(target); - /*if(paneConfigurationNumber == NsharpConstants.PANE_CONFIGURATION_0){ - currentCanvasBoundWidth = (int)(NsharpConstants.DISPLAY_WIDTH * (1-NsharpConstants.PC0_LEFT_GP_WIDTH_RATIO)* NsharpConstants.PC0_TIMESTN_WIDTH_RATIO); - currentCanvasBoundHeight = (int)(NsharpConstants.DISPLAY_HEIGHT* NsharpConstants.PC0_TIMESTN_HEIGHT_RATIO); - myDefaultCanvasWidth = currentCanvasBoundWidth; - myDefaultCanvasHeight = currentCanvasBoundHeight; - } else if(paneConfigurationNumber == NsharpConstants.PANE_CONFIGURATION_1){ - currentCanvasBoundWidth = (int)(NsharpConstants.DISPLAY_WIDTH * NsharpConstants.PC1_LEFT_GP_WIDTH_RATIO* NsharpConstants.PC1_TIMESTN_WIDTH_RATIO); - currentCanvasBoundHeight = (int)(NsharpConstants.DISPLAY_HEIGHT* NsharpConstants.PC1_TIMESTN_HEIGHT_RATIO); - myDefaultCanvasWidth = currentCanvasBoundWidth; - myDefaultCanvasHeight = currentCanvasBoundHeight; - }*/ - } - @Override - protected void disposeInternal() { - - super.disposeInternal(); - } - public Rectangle getTimeLineRectangle() { - return timeLineRectangle; - } - public Rectangle getStnIdRectangle() { - return stnIdRectangle; - } - - public Rectangle getSndRectangle() { - return sndRectangle; - } + // end d2dlite + } - public Rectangle getColorNoteRectangle() { - return colorNoteRectangle; - } - @Override - public void handleResize() { - - super.handleResize(); - IExtent ext = getDescriptor().getRenderableDisplay().getExtent(); - ext.reset(); - this.rectangle = new Rectangle((int)ext.getMinX(), (int) ext.getMinY(), - (int) ext.getWidth(), (int) ext.getHeight()); - pe = new PixelExtent(this.rectangle); - getDescriptor().setNewPe(pe); - defineCharHeight(font10); - paneHeight = (int) ext.getHeight(); - paneWidth = (int) (ext.getWidth()); - //xRatio = xRatio* paneWidth/prevWidth; - //DEBUGGING yRatio = yRatio* paneHeight/prevHeight; - xRatio = 1; - yRatio = 1; - //if pane height is less than 10 char height, then just plot time line. not plot "messages/title/notations" etc.. - if(paneHeight > (int)(10* charHeight*yRatio)){ - dtYOrig = (int) ext.getMinY()+(int)(2* charHeight*yRatio); - cnHeight = (int)(4* charHeight*yRatio); - dtHeight = paneHeight-(int)(6* charHeight*yRatio); - dtNextPageEnd = dtYOrig+ (int) (2*charHeight*yRatio); - } - else { - dtYOrig = (int) (ext.getMinY()); - cnHeight = 0; - dtHeight = paneHeight; - dtNextPageEnd = dtYOrig; - } - dtXOrig = (int) (ext.getMinX()); - dtWidth = paneWidth* 40/100; - dtXEnd = dtXOrig + dtWidth; - stnXOrig = dtXEnd; - stnYOrig = dtYOrig; - stnWidth = paneWidth * 30/100; - stnXEnd = stnXOrig+ stnWidth; - sndXOrig = stnXEnd; - sndYOrig = stnYOrig; - sndWidth = paneWidth * 30/100; - sndXEnd = sndXOrig+ sndWidth; - stnHeight = dtHeight; - cnXOrig = dtXOrig; - cnYOrig = dtYOrig+ dtHeight; - cnWidth = paneWidth; - //cnXEnd = cnXOrig+cnWidth; - timeLineRectangle = new Rectangle(dtXOrig,(int) ext.getMinY(), - dtWidth,paneHeight-cnHeight); - stnIdRectangle = new Rectangle(stnXOrig,(int) ext.getMinY(), - stnWidth,paneHeight-cnHeight); - sndRectangle = new Rectangle(sndXOrig,(int) ext.getMinY(), - sndWidth,paneHeight-cnHeight); - colorNoteRectangle = new Rectangle(cnXOrig,cnYOrig, - cnWidth,cnHeight); - rscHandler.setTimeStnBoxData( cnYOrig, dtNextPageEnd, dtYOrig ,dtXOrig, dtWidth, charHeight); - } + int startIndex = (rscHandler.getCurSndPage() - 1) + * numLineToShowPerPage; + if (startIndex < 0) + startIndex = 0; + int colorIndex; + double ly = dtNextPageEnd + charHeight; + RGB color; + Rectangle2D strBD = target.getStringBounds(font12, "*"); + double hRatio = paintProps.getView().getExtent().getWidth() + / paintProps.getCanvasBounds().width; + double xGap = 2 * strBD.getWidth() * hRatio; + for (int j = startIndex, count = 0; j < sndElemList.size() + && count < numLineToShowPerPage; j++, count++) { + boolean avail = false; + x = sndXOrig + 5; + NsharpOperationElement elm = sndElemList.get(j); + NsharpConstants.ActState sta = elm.getActionState(); + if (sta == NsharpConstants.ActState.ACTIVE && j == curSndIndex) + sta = NsharpConstants.ActState.CURRENT; + + if (curTimeLineIndex >= 0 && curStnIndex >= 0) { + if (stnTimeSndTable.get(curStnIndex).get(curTimeLineIndex) + .get(j) != null) { + avail = true; + } + s = "*"; + if (avail) { + color = NsharpConstants.color_red; + if (sta == NsharpConstants.ActState.CURRENT) + color = NsharpConstants.color_green; + } else { + color = NsharpConstants.color_purple; + } + target.drawString(font12, s, x, ly, 0.0, + IGraphicsTarget.TextStyle.NORMAL, color, + HorizontalAlignment.LEFT, VerticalAlignment.BOTTOM, + null); + } + x = x + xGap; + String sndType = elm.elementDescription; + double sndX = x; + color = rscHandler.getElementColorMap().get(sta.name()); + + if (elm.getActionState() == NsharpConstants.ActState.ACTIVE) { // FixMark:nearByStnCompSnd + // && + // avail){ + if (compareSndIsOn) { + strBD = target.getStringBounds(font12, sndType); + // start FixMark:nearByStnCompSnd + List sndCompElementList = rscHandler + .getCompSndSelectedElemList(); + s = ""; + for (NsharpResourceHandler.CompSndSelectedElem compElem : sndCompElementList) { + if (compElem.getSndIndex() != j) + continue; + if (stnTimeSndTable.get(compElem.getStnIndex()) + .get(compElem.getTimeIndex()) + .get(compElem.getSndIndex()) == null) + continue; + colorIndex = stnTimeSndTable + .get(compElem.getStnIndex()) + .get(compElem.getTimeIndex()) + .get(compElem.getSndIndex()) + .getCompColorIndex(); + color = linePropertyMap.get( + NsharpConstants.lineNameArray[colorIndex]) + .getLineColor(); + s = s + (colorIndex % NsharpConstants.LINE_COMP1 + 1) + + ","; + } + if (s.length() > 0) + s = s.substring(0, s.length() - 1); + x = x + strBD.getWidth() * hRatio + 5; + target.drawString(font12, s, x, ly, 0.0, + IGraphicsTarget.TextStyle.NORMAL, color, + HorizontalAlignment.LEFT, VerticalAlignment.BOTTOM, + null); + /* + * original code colorIndex = + * stnTimeSndTable.get(curStnIndex + * ).get(curTimeLineIndex).get(j).getCompColorIndex(); color + * = + * linePropertyMap.get(NsharpConstants.lineNameArray[colorIndex + * ]).getLineColor(); s =""+ (colorIndex % + * NsharpConstants.LINE_COMP1 + 1); x=x+ + * strBD.getWidth()*hRatio+5; target.drawString(font10,s, x, + * ly, 0.0, IGraphicsTarget.TextStyle.NORMAL, color, + * HorizontalAlignment.LEFT, VerticalAlignment.BOTTOM, + * null); + * + * // + */// end FixMark:nearByStnCompSnd + } else if ((compareTmIsOn || compareStnIsOn) + && j == curSndIndex && avail) { + strBD = target.getStringBounds(font12, sndType); + // colorIndex = + // (compIndex-1)%(NsharpConstants.LINE_COMP10-NsharpConstants.LINE_COMP1+1)+ + // NsharpConstants.LINE_COMP1; + colorIndex = stnTimeSndTable.get(curStnIndex) + .get(curTimeLineIndex).get(curSndIndex) + .getCompColorIndex(); + color = linePropertyMap.get( + NsharpConstants.lineNameArray[colorIndex]) + .getLineColor(); + s = "" + (colorIndex % NsharpConstants.LINE_COMP1 + 1); + x = x + strBD.getWidth() * hRatio + 5; + target.drawString(font12, s, x, ly, 0.0, + IGraphicsTarget.TextStyle.NORMAL, color, + HorizontalAlignment.LEFT, VerticalAlignment.BOTTOM, + null); + } + } + target.drawString(font12, sndType, sndX, ly, 0.0, + IGraphicsTarget.TextStyle.NORMAL, color, + HorizontalAlignment.LEFT, VerticalAlignment.BOTTOM, null); + ly = ly + lineHeight; + if (ly >= cnYOrig) + // we dont show stn id that extends below box + break; + } + } + + @Override + protected void paintInternal(IGraphicsTarget target, + PaintProperties paintProps) throws VizException { + super.paintInternal(target, paintProps); + // defineCharHeight(font10); + // System.out.println("timeStn paintInternal zoomL="+currentZoomLevel); + if (rscHandler == null) + return; + stnElemList = rscHandler.getStnElementList(); + timeElemList = rscHandler.getTimeElementList(); + sndElemList = rscHandler.getSndElementList(); + curTimeLineIndex = rscHandler.getCurrentTimeElementListIndex(); + curStnIndex = rscHandler.getCurrentStnElementListIndex(); + curSndIndex = rscHandler.getCurrentSndElementListIndex(); + curTimeLinePage = rscHandler.getCurTimeLinePage(); + curStnIdPage = rscHandler.getCurStnIdPage(); + curSndPage = rscHandler.getCurSndPage(); + totalTimeLinePage = rscHandler.getTotalTimeLinePage(); + totalStnIdPage = rscHandler.getTotalStnIdPage(); + totalSndPage = rscHandler.getTotalSndPage(); + compareStnIsOn = rscHandler.isCompareStnIsOn(); + compareSndIsOn = rscHandler.isCompareSndIsOn(); + compareTmIsOn = rscHandler.isCompareTmIsOn(); + stnTimeSndTable = rscHandler.getStnTimeSndTable(); + this.font10.setSmoothing(false); + this.font10.setScaleFont(false); + this.font9.setSmoothing(false); + this.font9.setScaleFont(false); + this.font12.setSmoothing(false); + this.font12.setScaleFont(false); + + // plot data time line + drawNsharpTimelinBox(target, timeLineRectangle); + + // plot station id + drawNsharpStationIdBox(target, stnIdRectangle); + + drawNsharpSndTypeBox(target, sndRectangle); + // plot color notations + drawNsharpColorNotation(target, colorNoteRectangle); + + } + + @Override + protected void initInternal(IGraphicsTarget target) throws VizException { + super.initInternal(target); + /* + * if(paneConfigurationNumber == NsharpConstants.PANE_CONFIGURATION_0){ + * currentCanvasBoundWidth = (int)(NsharpConstants.DISPLAY_WIDTH * + * (1-NsharpConstants.PC0_LEFT_GP_WIDTH_RATIO)* + * NsharpConstants.PC0_TIMESTN_WIDTH_RATIO); currentCanvasBoundHeight = + * (int)(NsharpConstants.DISPLAY_HEIGHT* + * NsharpConstants.PC0_TIMESTN_HEIGHT_RATIO); myDefaultCanvasWidth = + * currentCanvasBoundWidth; myDefaultCanvasHeight = + * currentCanvasBoundHeight; } else if(paneConfigurationNumber == + * NsharpConstants.PANE_CONFIGURATION_1){ currentCanvasBoundWidth = + * (int)(NsharpConstants.DISPLAY_WIDTH * + * NsharpConstants.PC1_LEFT_GP_WIDTH_RATIO* + * NsharpConstants.PC1_TIMESTN_WIDTH_RATIO); currentCanvasBoundHeight = + * (int)(NsharpConstants.DISPLAY_HEIGHT* + * NsharpConstants.PC1_TIMESTN_HEIGHT_RATIO); myDefaultCanvasWidth = + * currentCanvasBoundWidth; myDefaultCanvasHeight = + * currentCanvasBoundHeight; } + */ + } + + @Override + protected void disposeInternal() { + + super.disposeInternal(); + } + + public Rectangle getTimeLineRectangle() { + return timeLineRectangle; + } + + public Rectangle getStnIdRectangle() { + return stnIdRectangle; + } + + public Rectangle getSndRectangle() { + return sndRectangle; + } + + public Rectangle getColorNoteRectangle() { + return colorNoteRectangle; + } + + @Override + public void handleResize() { + + super.handleResize(); + IExtent ext = getDescriptor().getRenderableDisplay().getExtent(); + ext.reset(); + this.rectangle = new Rectangle((int) ext.getMinX(), + (int) ext.getMinY(), (int) ext.getWidth(), + (int) ext.getHeight()); + pe = new PixelExtent(this.rectangle); + getDescriptor().setNewPe(pe); + defineCharHeight(font12); + paneHeight = (int) ext.getHeight(); + paneWidth = (int) (ext.getWidth()); + // xRatio = xRatio* paneWidth/prevWidth; + // DEBUGGING yRatio = yRatio* paneHeight/prevHeight; + xRatio = 1; + yRatio = 1; + // if pane height is less than 10 char height, then just plot time line. + // not plot "messages/title/notations" etc.. + if (paneHeight > (int) (10 * charHeight * yRatio)) { + dtYOrig = (int) ext.getMinY() + (int) (2 * charHeight * yRatio); + cnHeight = (int) (4 * charHeight * yRatio); + dtHeight = paneHeight - (int) (6 * charHeight * yRatio); + dtNextPageEnd = dtYOrig + (int) (3 * charHeight * yRatio); + } else { + dtYOrig = (int) (ext.getMinY()); + cnHeight = 0; + dtHeight = paneHeight; + dtNextPageEnd = dtYOrig; + } + dtXOrig = (int) (ext.getMinX()); + dtWidth = paneWidth * 40 / 100;// FixMark:nearByStnCompSnd d2dlite + dtXEnd = dtXOrig + dtWidth; + stnXOrig = dtXEnd; + stnYOrig = dtYOrig; + stnWidth = paneWidth * 25 / 100;// FixMark:nearByStnCompSnd + stnXEnd = stnXOrig + stnWidth; + sndXOrig = stnXEnd; + sndYOrig = stnYOrig; + sndWidth = paneWidth * 35 / 100;// FixMark:nearByStnCompSnd + sndXEnd = sndXOrig + sndWidth; + stnHeight = dtHeight; + cnXOrig = dtXOrig; + cnYOrig = dtYOrig + dtHeight; + cnWidth = paneWidth; + // cnXEnd = cnXOrig+cnWidth; + timeLineRectangle = new Rectangle(dtXOrig, (int) ext.getMinY(), + dtWidth, paneHeight - cnHeight); + stnIdRectangle = new Rectangle(stnXOrig, (int) ext.getMinY(), stnWidth, + paneHeight - cnHeight); + sndRectangle = new Rectangle(sndXOrig, (int) ext.getMinY(), sndWidth, + paneHeight - cnHeight); + colorNoteRectangle = new Rectangle(cnXOrig, cnYOrig, cnWidth, cnHeight); + + // start d2dlite + numLineToShowPerPage = (cnYOrig - dtNextPageEnd) / (int) lineHeight - 1; + if (numLineToShowPerPage < 1) { + numLineToShowPerPage = dtHeight / (int) lineHeight - 1; + if (numLineToShowPerPage < 1) + numLineToShowPerPage = 1; + } + rscHandler.setTimeStnBoxData(cnYOrig, dtNextPageEnd, dtYOrig, dtXOrig, + dtWidth, charHeight, lineHeight, numLineToShowPerPage); + // end d2dlite + } } diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/natives/NsharpNativeConstants.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/natives/NsharpNativeConstants.java index 81bf99c6a4..9e1b76e9b3 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/natives/NsharpNativeConstants.java +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/natives/NsharpNativeConstants.java @@ -20,362 +20,585 @@ */ package gov.noaa.nws.ncep.ui.nsharp.natives; +import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingLayer; + import java.util.HashMap; import java.util.Map; -import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingLayer; - public class NsharpNativeConstants { - public static final float NSHARP_NATIVE_INVALID_DATA = NcSoundingLayer.MISSING; //-9999f - //Note: legacy NSHARP lib return -999 as invalid data - public static final float NSHARP_LEGACY_LIB_INVALID_DATA = NcSoundingLayer.MISSING; //-9999f - public static final float PI = 3.14159265F; - /* - * PAGE1 CANVAS1 string definitions - */ - public static final String PAGE1TEXT1_SB_STR ="SB PARCEL "; - public static final String PAGE1TEXT1_ML_STR ="ML PARCEL "; - public static final String PAGE1TEXT1_FCST_STR ="FCST PARCEL"; - public static final String PAGE1TEXT1_MU_STR ="MU PARCEL "; - public static final String PAGE1TEXT1_USER_STR ="USER PARCEL"; - public static final String PAGE1TEXT1_EFF_STR ="EFF PARCEL "; - //PARCELTYPES_STR array: order of array element should follow PARCELTYPE_* definitions below. - //public static final String[] PARCELTYPES_STR = {"", PAGE1TEXT1_SB_STR, PAGE1TEXT1_FCST_STR,PAGE1TEXT1_ML_STR, - // PAGE1TEXT1_MU_STR, PAGE1TEXT1_USER_STR, PAGE1TEXT1_EFF_STR - //}; - /* - * PAGE1 Panel2 string definitions - */ - public static final String[] STORM_MOTION_TYPE_STR1 = { "SFC-1km", "SFC_2km", - "SFC_3km", "Eff Inflow Layer" - }; - public static final String[] STORM_MOTION_TYPE_STR2 = { "SFC-6km","SFC-8km", "LCL-EL(Cloud Layer)", - "Lower Half Storm Depth" - }; - public static final float[][] STORM_MOTION_HEIGHT1 = { {0,1000}, {0,2000}, {0,3000}, {0,0} - }; - public static final float[][] STORM_MOTION_HEIGHT2 = { {0,6000}, - {0, 8000}, {0,0},{0,0} - }; - /* - * PARCEL DATA string definitions - */ - //PARCEL type flags to be used for define_parcel() - public static final short PARCELTYPE_CUIRRENT_SELECTION = -1; - public static final short PARCELTYPE_OBS_SFC = 1; - public static final short PARCELTYPE_FCST_SFC = 2; - public static final short PARCELTYPE_MOST_UNSTABLE = 3;//BigNsharp - public static final short PARCELTYPE_MEAN_MIXING = 4; //BigNsharp - public static final short PARCELTYPE_USER_DEFINED = 5; - public static final short PARCELTYPE_EFF = 6; //BigNsharp - public static final short PARCEL_MAX = PARCELTYPE_EFF; - - //default pressure for parcel as defined in BigNsharp - public static final float OBS_LAYER = 0.0f; - public static final float FCST_LAYER = 0.0f; - public static final float MML_LAYER = 100.0f; /* mean-mixed layer */ - public static final float MU_LAYER = 400.0f; /* most-unstable layer */ - public static final float USER_LAYER = 850.0f; /* default user-defined level */ - public static final float EFF_LAYER = MU_LAYER; //Chin, need to check with John - /*1 = Observed sfc parcel */ - /* 2 = Fcst sfc parcel */ - /* 3 = Most unstable parcel */ - /* 4 = Mean mixlyr parcel */ - /* 5 = User defined parcel */ - /* 6 = Mean Effective Layer parcel - * - */ - //parcel header string - public static final String PARCEL_DATA_STR = "\t\t\t\tPARCEL DATA \r\n"; - public static final String PARCEL_OBS_SFC_STR = "\t\t*** SFC PARCEL ***\r\n"; - public static final String PARCEL_FORECAST_SFC_STR = "\t\t*** FCST SFC PARCEL ***\r\n"; - public static final String PARCEL_MEAN_MIXING_STR = "\t\t*** MEAN MIXING LAYER PARCEL ***\r\n"; - public static final String PARCEL_MOST_UNSTABLE_STR = "\t\t*** MOST UNSTABLE PARCEL ***\r\n"; - public static final String PARCEL_MEAN_EFF_STR = "\t\t*** MEAN EFFECTIVE PARCEL ***\r\n"; - public static final String PARCEL_USR_DEFINED_STR = "\t\t*** %.1f mb PARCEL ***\r\n"; - //parcel lines - public static final String PARCEL_LPL_LINE = "LPL:\t%dmb\t%dC/%dC\t%dF/%dF\r\n\r\n"; - public static final String PARCEL_LPL_LINE_ = "LPL:_%dmb_%dC/%dC_%dF/%dF"; - public static final String PARCEL_CAPE_LINE = "CAPE = %.0f J/Kg"; - public static final String PARCEL_CAPE_MISSING = "CAPE = M"; - public static final String PARCEL_LI_LINE = "LI(500mb) =%5.0fC\r\n"; - public static final String PARCEL_LI_MISSING = "LI(500mb) = M\r\n"; - public static final String PARCEL_BFZL_LINE = "BFZL = %.0f J/Kg"; - public static final String PARCEL_BFZL_MISSING = "BFZL = M"; - public static final String PARCEL_LIMIN_LINE = "LImin = %4.0fC /%4.0fmb\r\n"; - public static final String PARCEL_LIMIN_MISSING = "LImin = M / M\r\n"; - public static final String PARCEL_CINH_LINE = "CINH = %.0f J/Kg"; - public static final String PARCEL_CINH_MISSING = "CINH = M"; - public static final String PARCEL_CAP_LINE = "Cap = %4.0fC /%4.0fmb\r\n\r\n"; - public static final String PARCEL_CAP_MISSING = "Cap = M / M\r\n\r\n"; - public static final String PARCEL_LEVEL_LINE = "LEVEL\t\tPRES\t\tHGT(AGL)\t\tTEMP\r\n____________________________________________________\r\n"; - public static final String PARCEL_LEVEL_LINE_ = "LEVEL_PRES_HGT(AGL)_TEMP"; - public static final String PARCEL_LCL_LINE = "LCL\t\t%5.0fmb\t\t%7.0fft\r\n"; - public static final String PARCEL_LCL_LINE_ = "LCL_%5.0fmb_%7.0fft_ "; - public static final String PARCEL_LCL_MISSING = "LCL\t\tM \t\tM\r\n"; - public static final String PARCEL_LCL_MISSING_ = "LCL_M_M_ "; - public static final String PARCEL_LFC_LINE = "LFC\t\t%5.0fmb\t\t%7.0fft\t%6.0fC\r\n"; - public static final String PARCEL_LFC_LINE_ = "LFC_%5.0fmb_%7.0fft_%6.0fC"; - public static final String PARCEL_LFC_MISSING = "LFC\t\tM \t\tM \t\t\tM\r\n"; - public static final String PARCEL_LFC_MISSING_ = "LFC_M_M_M"; - public static final String PARCEL_EL_LINE = "EL \t\t%5.0fmb\t\t%7.0fft\t%6.0fC\r\n"; - public static final String PARCEL_EL_LINE_ = "EL_%5.0fmb_%7.0fft_%6.0fC"; - public static final String PARCEL_EL_MISSING = "EL \t\tM \t\tM \t\t\tM\r\n"; - public static final String PARCEL_EL_MISSING_ = "EL_M_M_M"; - public static final String PARCEL_MPL_LINE = "MPL\t\t%5.0fmb\t\t%7.0fft\r\n"; - public static final String PARCEL_MPL_LINE_ = "MPL_%5.0fmb_%7.0fft_ "; - public static final String PARCEL_MPL_MISSING = "MPL\t\tM \t\tM\r\n"; - public static final String PARCEL_MPL_MISSING_ = "MPL_M_M_ "; - - /* - * THERMODYNAMIC DATA string definitions - */ - // THERMODYNAMIC HEADER STR - public static final String THERMO_DATA_STR = "\t\t\t\tTHERMODYNAMIC DATA \r\n"; - public static final String THERMO_MOISTURE_STR = "\t\t------ AVAILABLE MOISTURE ------\r\n"; - public static final String THERMO_INSTABILITY_STR = "\t\t------ CONDITIONAL INSTABILITY ------\r\n"; - public static final String THERMO_MISC_PARMS_STR = "\t\t------ MISC PARAMETERS ------\r\n"; - // THERMODYNAMIC LINE STRING - public static final String THERMO_PWATER_LINE = "P. Water = %2.2f in\t\t"; - public static final String THERMO_PWATER_MISSING = "P. Water = M \t\t"; - public static final String THERMO_MEANRH_LINE = "Mean RH = %.0f %c \r\n"; - public static final String THERMO_MEANRH_MISSING = "Mean RH = M\r\n"; - public static final String THERMO_MEANW_LINE = "Mean W = %.1fg/Kg\t\t"; - public static final String THERMO_MEANW_MISSING = "Mean W = M\t\t\t"; - public static final String THERMO_MEANLRH_LINE = "Mean LRH = %.0f %c \r\n"; - public static final String THERMO_MEANLRH_MISSING = "Mean LRH = M\r\n"; - public static final String THERMO_TOP_LINE = "Top of Moist Lyr = %.0f mb / %.0f ft\r\n"; - public static final String THERMO_TOP_MISSING = "Top of Moist Lyr = \t\tM / M\r\n\r\n"; - public static final String THERMO_700500mb_LINE = "700-500mb Lapse Rate = %.0f C / %.1f C/Km\r\n"; - public static final String THERMO_700500mb_MISSING = "700-500mb Lapse Rate = M / M\r\n\r\n"; - public static final String THERMO_850500mb_LINE = "850-500mb Lapse Rate = %.0f C / %.1f C/Km\r\n"; - public static final String THERMO_850500mb_MISSING = "850-500mb Lapse Rate = M / M\r\n\r\n"; - public static final String THERMO_TOTAL_LINE = "Total Totals = %.0f\t\t"; - public static final String THERMO_TOTAL_MISSING = "Total Totals = M \t\t"; - public static final String THERMO_KINDEX_LINE = "K-Index = %.0f\r\n"; - public static final String THERMO_KINDEX_MISSING = "K-Index = M\r\n"; - public static final String THERMO_SWEAT_LINE = "SWEAT Index = %.0f\t\t"; - public static final String THERMO_SWEAT_MISSING = "SWEAT Index = M\t\t"; - public static final String THERMO_MAXT_LINE = "Max Temp = %.0fF\r\n"; - public static final String THERMO_MAXT_MISSING = "Max Temp = M\r\n"; - public static final String THERMO_THETAE_LINE = "ThetaE Diff = %.0fC\t\t"; - public static final String THERMO_THETAE_MISSING = "ThetaE Diff = M \t\t"; - public static final String THERMO_CONVT_LINE = "Conv Temp = %.0fF\r\n"; - public static final String THERMO_CONVT_MISSING = "Conv Temp = M\r\n"; - public static final String THERMO_FGZ_MISSING = "FGZ level = M\r\n"; - public static final String THERMO_FGZ_LINE = "FGZ level = %.0fft\r\n"; - public static final String THERMO_WBZ_MISSING = "WBZ level = M \t\t"; - public static final String THERMO_WBZ_LINE = "WBZ level = %3.0fft\t"; - - /* - * OPC LOW LEVEL STABILITY data string - */ - public static final String OPC_LOW_LEVEL_STR = "\t\t\t OPC LOW LEVEL STABILITY \r\n"; + public static final float NSHARP_NATIVE_INVALID_DATA = NcSoundingLayer.MISSING; // -9999f + + // Note: legacy NSHARP lib return -999 as invalid data + public static final float NSHARP_LEGACY_LIB_INVALID_DATA = NcSoundingLayer.MISSING; // -9999f + + public static final float PI = 3.14159265F; + + /* + * PAGE1 CANVAS1 string definitions + */ + public static final String PAGE1TEXT1_SB_STR = "SB PARCEL "; + + public static final String PAGE1TEXT1_ML_STR = "ML PARCEL "; + + public static final String PAGE1TEXT1_FCST_STR = "FCST PARCEL"; + + public static final String PAGE1TEXT1_MU_STR = "MU PARCEL "; + + public static final String PAGE1TEXT1_USER_STR = "USER PARCEL"; + + public static final String PAGE1TEXT1_EFF_STR = "EFF PARCEL "; + + // PARCELTYPES_STR array: order of array element should follow PARCELTYPE_* + // definitions below. + // public static final String[] PARCELTYPES_STR = {"", PAGE1TEXT1_SB_STR, + // PAGE1TEXT1_FCST_STR,PAGE1TEXT1_ML_STR, + // PAGE1TEXT1_MU_STR, PAGE1TEXT1_USER_STR, PAGE1TEXT1_EFF_STR + // }; + /* + * PAGE1 Panel2 string definitions + */ + public static final String[] STORM_MOTION_TYPE_STR1 = { "SFC-1km", + "SFC-2km", "SFC-3km", "Eff Inflow Layer" }; + + public static final String[] STORM_MOTION_TYPE_STR2 = { "SFC-6km", + "SFC-8km", "LCL-EL(Cloud Layer)", "Lower Half Storm Depth" }; + + public static final float[][] STORM_MOTION_HEIGHT1 = { { 0, 1000 }, + { 0, 2000 }, { 0, 3000 }, { 0, 0 } }; + + public static final float[][] STORM_MOTION_HEIGHT2 = { { 0, 6000 }, + { 0, 8000 }, { 0, 0 }, { 0, 0 } }; + + /* + * PARCEL DATA string definitions + */ + // PARCEL type flags to be used for define_parcel() + public static final short PARCELTYPE_CUIRRENT_SELECTION = -1; + + public static final short PARCELTYPE_OBS_SFC = 1; + + public static final short PARCELTYPE_FCST_SFC = 2; + + public static final short PARCELTYPE_MOST_UNSTABLE = 3;// BigNsharp + + public static final short PARCELTYPE_MEAN_MIXING = 4; // BigNsharp + + public static final short PARCELTYPE_USER_DEFINED = 5; + + public static final short PARCELTYPE_EFF = 6; // BigNsharp + + public static final short PARCEL_MAX = PARCELTYPE_EFF; + + public static final short PARCEL_D2DLITE_MAX = PARCELTYPE_MOST_UNSTABLE; // d2dlite + + // default pressure for parcel as defined in BigNsharp + public static final float OBS_LAYER = 0.0f; + + public static final float FCST_LAYER = 0.0f; + + public static final float MML_LAYER = 100.0f; /* mean-mixed layer */ + + public static final float MU_LAYER = 400.0f; /* most-unstable layer */ + + public static final float USER_LAYER = 850.0f; /* default user-defined level */ + + public static final float EFF_LAYER = MU_LAYER; // Chin, need to check with + // John + + /* 1 = Observed sfc parcel */ + /* 2 = Fcst sfc parcel */ + /* 3 = Most unstable parcel */ + /* 4 = Mean mixlyr parcel */ + /* 5 = User defined parcel */ + /* + * 6 = Mean Effective Layer parcel + */ + // parcel header string + public static final String PARCEL_DATA_STR = "\t\t\t\tPARCEL DATA \r\n"; + + public static final String PARCEL_OBS_SFC_STR = "\t\t*** SFC PARCEL ***\r\n"; + + public static final String PARCEL_FORECAST_SFC_STR = "\t\t*** FCST SFC PARCEL ***\r\n"; + + public static final String PARCEL_MEAN_MIXING_STR = "\t\t*** MEAN MIXING LAYER PARCEL ***\r\n"; + + public static final String PARCEL_MOST_UNSTABLE_STR = "\t\t*** MOST UNSTABLE PARCEL ***\r\n"; + + public static final String PARCEL_MEAN_EFF_STR = "\t\t*** MEAN EFFECTIVE PARCEL ***\r\n"; + + public static final String PARCEL_USR_DEFINED_STR = "\t\t*** %.1f mb PARCEL ***\r\n"; + + // parcel lines + public static final String PARCEL_LPL_LINE = "LPL:\t%dmb\t%dC/%dC\t%dF/%dF\r\n\r\n"; + + public static final String PARCEL_LPL_LINE_ = "LPL:_%dmb_%dC/%dC_%dF/%dF"; + + public static final String PARCEL_CAPE_LINE = "CAPE = %.0f J/Kg"; + + public static final String PARCEL_CAPE_MISSING = "CAPE = M"; + + public static final String PARCEL_LI_LINE = "LI(500mb) =%5.0fC\r\n"; + + public static final String PARCEL_LI_MISSING = "LI(500mb) = M\r\n"; + + public static final String PARCEL_BFZL_LINE = "BFZL = %.0f J/Kg"; + + public static final String PARCEL_BFZL_MISSING = "BFZL = M"; + + public static final String PARCEL_LIMIN_LINE = "LImin = %4.0fC /%4.0fmb\r\n"; + + public static final String PARCEL_LIMIN_MISSING = "LImin = M / M\r\n"; + + public static final String PARCEL_CINH_LINE = "CINH = %.0f J/Kg"; + + public static final String PARCEL_CINH_MISSING = "CINH = M"; + + public static final String PARCEL_CAP_LINE = "Cap = %4.0fC /%4.0fmb\r\n\r\n"; + + public static final String PARCEL_CAP_MISSING = "Cap = M / M\r\n\r\n"; + + public static final String PARCEL_LEVEL_LINE = "LEVEL\t\tPRES\t\tHGT(AGL)\t\tTEMP\r\n____________________________________________________\r\n"; + + public static final String PARCEL_LEVEL_LINE_ = "LEVEL_PRES_HGT(AGL)_TEMP"; + + public static final String PARCEL_LCL_LINE = "LCL\t\t%5.0fmb\t\t%7.0fft\r\n"; + + public static final String PARCEL_LCL_LINE_ = "LCL_%5.0fmb_%7.0fft_ "; + + public static final String PARCEL_LCL_MISSING = "LCL\t\tM \t\tM\r\n"; + + public static final String PARCEL_LCL_MISSING_ = "LCL_M_M_ "; + + public static final String PARCEL_LFC_LINE = "LFC\t\t%5.0fmb\t\t%7.0fft\t%6.0fC\r\n"; + + public static final String PARCEL_LFC_LINE_ = "LFC_%5.0fmb_%7.0fft_%6.0fC"; + + public static final String PARCEL_LFC_MISSING = "LFC\t\tM \t\tM \t\t\tM\r\n"; + + public static final String PARCEL_LFC_MISSING_ = "LFC_M_M_M"; + + public static final String PARCEL_EL_LINE = "EL \t\t%5.0fmb\t\t%7.0fft\t%6.0fC\r\n"; + + public static final String PARCEL_EL_LINE_ = "EL_%5.0fmb_%7.0fft_%6.0fC"; + + public static final String PARCEL_EL_MISSING = "EL \t\tM \t\tM \t\t\tM\r\n"; + + public static final String PARCEL_EL_MISSING_ = "EL_M_M_M"; + + public static final String PARCEL_MPL_LINE = "MPL\t\t%5.0fmb\t\t%7.0fft\r\n"; + + public static final String PARCEL_MPL_LINE_ = "MPL_%5.0fmb_%7.0fft_ "; + + public static final String PARCEL_MPL_MISSING = "MPL\t\tM \t\tM\r\n"; + + public static final String PARCEL_MPL_MISSING_ = "MPL_M_M_ "; + + /* + * THERMODYNAMIC DATA string definitions + */ + // THERMODYNAMIC HEADER STR + public static final String THERMO_DATA_STR = "\t\t\t\tTHERMODYNAMIC DATA \r\n"; + + public static final String THERMO_MOISTURE_STR = "\t\t------ AVAILABLE MOISTURE ------\r\n"; + + public static final String THERMO_INSTABILITY_STR = "\t\t------ CONDITIONAL INSTABILITY ------\r\n"; + + public static final String THERMO_MISC_PARMS_STR = "\t\t------ MISC PARAMETERS ------\r\n"; + + // THERMODYNAMIC LINE STRING + public static final String THERMO_PWATER_LINE = "P. Water = %2.2f in\t\t"; + + public static final String THERMO_PWATER_MISSING = "P. Water = M \t\t"; + + public static final String THERMO_MEANRH_LINE = "Mean RH = %.0f %c \r\n"; + + public static final String THERMO_MEANRH_MISSING = "Mean RH = M\r\n"; + + public static final String THERMO_MEANW_LINE = "Mean W = %.1fg/Kg\t\t"; + + public static final String THERMO_MEANW_MISSING = "Mean W = M\t\t\t"; + + public static final String THERMO_MEANLRH_LINE = "Mean LRH = %.0f %c \r\n"; + + public static final String THERMO_MEANLRH_MISSING = "Mean LRH = M\r\n"; + + public static final String THERMO_TOP_LINE = "Top of Moist Lyr = %.0f mb / %.0f ft\r\n"; + + public static final String THERMO_TOP_MISSING = "Top of Moist Lyr = \t\tM / M\r\n\r\n"; + + public static final String THERMO_700500mb_LINE = "700-500mb Lapse Rate = %.0f C / %.1f C/Km\r\n"; + + public static final String THERMO_700500mb_MISSING = "700-500mb Lapse Rate = M / M\r\n\r\n"; + + public static final String THERMO_850500mb_LINE = "850-500mb Lapse Rate = %.0f C / %.1f C/Km\r\n"; + + public static final String THERMO_850500mb_MISSING = "850-500mb Lapse Rate = M / M\r\n\r\n"; + + public static final String THERMO_TOTAL_LINE = "Total Totals = %.0f\t\t"; + + public static final String THERMO_TOTAL_MISSING = "Total Totals = M \t\t"; + + public static final String THERMO_KINDEX_LINE = "K-Index = %.0f\r\n"; + + public static final String THERMO_KINDEX_MISSING = "K-Index = M\r\n"; + + public static final String THERMO_SWEAT_LINE = "SWEAT Index = %.0f\t\t"; + + public static final String THERMO_SWEAT_MISSING = "SWEAT Index = M\t\t"; + + public static final String THERMO_MAXT_LINE = "Max Temp = %.0fF\r\n"; + + public static final String THERMO_MAXT_MISSING = "Max Temp = M\r\n"; + + public static final String THERMO_THETAE_LINE = "ThetaE Diff = %.0fC\t\t"; + + public static final String THERMO_THETAE_MISSING = "ThetaE Diff = M \t\t"; + + public static final String THERMO_CONVT_LINE = "Conv Temp = %.0fF\r\n"; + + public static final String THERMO_CONVT_MISSING = "Conv Temp = M\r\n"; + + public static final String THERMO_FGZ_MISSING = "FGZ level = M\r\n"; + + public static final String THERMO_FGZ_LINE = "FGZ level = %.0fft\r\n"; + + public static final String THERMO_WBZ_MISSING = "WBZ level = M \t\t"; + + public static final String THERMO_WBZ_LINE = "WBZ level = %3.0fft\t"; + + /* + * OPC LOW LEVEL STABILITY data string + */ + public static final String OPC_LOW_LEVEL_STR = "\t\t\t OPC LOW LEVEL STABILITY \r\n"; + + // OPC page header string + public static final String OPC_SURFACE975_STR = " ----- SURFACE-975 hPa TEMP GRADIENT -----\r\n"; + + public static final String OPC_LOWEST_INV_STR = "\r\n -------- LOWEST INVERSION HEIGHT --------\r\n"; + + public static final String OPC_MIXING_HGT_STR = " ------------- MIXING HEIGHT -------------\r\n"; + + // OPC SURFACE975 line strings + public static final String OPC_LEVEL_LINE = "LEVEL\t\tPRES\t\tHEIGHT\t\tTEMP\r\n_______________________________________________\r\n"; + + public static final String OPC_LEVEL_LINE_ = "LEVEL_PRES_HEIGHT_TEMP"; + + public static final String OPC_975_LINE = "975 hPa\t\t 975 mb\t\t%4.0f m\t\t%.2f C\r\n"; + + public static final String OPC_975_LINE_ = "975 hPa_975 mb_%4.0f m_%.2f C"; + + public static final String OPC_975_LINE_MISSING = "975 hPa\t\t 975 mb\t\tM \t\t\tM \r\n"; + + public static final String OPC_975_LINE_MISSING_ = "975 hPa_975 mb_M_M"; + + public static final String OPC_SURFACE_LINE = "Surface\t\t%4.0f mb\t\t%4.0f m\t\t%.2f C\r\n\r\n"; + + public static final String OPC_SURFACE_LINE_ = "Surface_%4.0f mb_%4.0f m_%.2f C"; + + public static final String OPC_SURFACE_MISSING = "Surface\t\t M mb\t\t M m\t\t M\r\n"; + + public static final String OPC_SURFACE_MISSING_ = "Surface_M_M_M"; + + public static final String OPC_975_SURFACE_LINE = "975-Sfc Gradient = %.2f C\r\n"; + + public static final String OPC_975_SURFACE_MISSING = "975-Sfc Gradient = M\r\n"; + + // lowest inversion height line strings + public static final String OPC_BASEHEIGHT_LINE = "Base Height = %.0f m\r\n"; + + public static final String OPC_BASEHEIGHT_MISSING = "Base Height = M\r\n"; + + public static final String OPC_BASEPRESSURE_LINE = "Base Pressure = %.0f mb\r\n"; - //OPC page header string - public static final String OPC_SURFACE975_STR = " ----- SURFACE-975 hPa TEMP GRADIENT -----\r\n"; - public static final String OPC_LOWEST_INV_STR = "\r\n -------- LOWEST INVERSION HEIGHT --------\r\n"; - public static final String OPC_MIXING_HGT_STR = " ------------- MIXING HEIGHT -------------\r\n"; - //OPC SURFACE975 line strings - public static final String OPC_LEVEL_LINE = "LEVEL\t\tPRES\t\tHEIGHT\t\tTEMP\r\n_______________________________________________\r\n"; - public static final String OPC_LEVEL_LINE_ = "LEVEL_PRES_HEIGHT_TEMP"; - public static final String OPC_975_LINE = "975 hPa\t\t 975 mb\t\t%4.0f m\t\t%.2f C\r\n"; - public static final String OPC_975_LINE_ = "975 hPa_975 mb_%4.0f m_%.2f C"; - public static final String OPC_975_LINE_MISSING = "975 hPa\t\t 975 mb\t\tM \t\t\tM \r\n"; - public static final String OPC_975_LINE_MISSING_ = "975 hPa_975 mb_M_M"; - public static final String OPC_SURFACE_LINE = "Surface\t\t%4.0f mb\t\t%4.0f m\t\t%.2f C\r\n\r\n"; - public static final String OPC_SURFACE_LINE_ = "Surface_%4.0f mb_%4.0f m_%.2f C"; - public static final String OPC_SURFACE_MISSING = "Surface\t\t M mb\t\t M m\t\t M\r\n"; - public static final String OPC_SURFACE_MISSING_ = "Surface_M_M_M"; - public static final String OPC_975_SURFACE_LINE = "975-Sfc Gradient = %.2f C\r\n"; - public static final String OPC_975_SURFACE_MISSING = "975-Sfc Gradient = M\r\n"; - // lowest inversion height line strings - public static final String OPC_BASEHEIGHT_LINE = "Base Height = %.0f m\r\n"; - public static final String OPC_BASEHEIGHT_MISSING = "Base Height = M\r\n"; - public static final String OPC_BASEPRESSURE_LINE = "Base Pressure = %.0f mb\r\n"; public static final String OPC_BASEPRESSURE_MISSING = "Base Pressure = M\r\n"; - public static final String OPC_CHANGE_IN_TEMP_LINE = "Change in Temp = %.2f C\r\n"; - public static final String OPC_CHANGE_IN_TEMP_MISSING = "Change in Temp = M\r\n"; - - // mixing height line strings - public static final String OPC_LAYER_BASED_STR = "\t\t\t\t*** Layer Based ***\r\n"; - public static final String OPC_SURFACE_BASED_STR = "\t\t\t\t*** Surface Based ***\r\n"; - public static final String OPC_DRY_AD_LINE = "Dry Ad Lapse Rate _= 9.8 C/Km\r\n"; - public static final String OPC_THRESH_LAPSE_LINE = "Thresh Lapse Rate _= 8.3 C/Km\r\n"; - public static final String OPC_MIXINGHEIGHT_LINE = "Mixing Height _= %.0f m\r\n"; - public static final String OPC_MIXINGPRESSURE_LINE ="Mixing Pressure _= %.0f mb\r\n"; - public static final String OPC_TOPMIXLAYER_LINE = "Top Mix Layer Wind _= %d%c/%d kt\r\n"; - public static final String OPC_MIXLAYERMAX_LINE = "Mix Layer Max Wind _= %d%c/%d kt\r\n"; - public static final String OPC_MIXINGHEIGHT_MISSING="Mixing Height _= M\r\n"; -public static final String OPC_MIXINGPRESSURE_MISSING = "Mixing Pressure _= M\r\n"; - public static final String OPC_TOPMIXLAYER_MISSING ="Top Mix Layer Wind _= M / M\r\n"; - public static final String OPC_MIXLAYERMAX_MISSING ="Mix Layer Max Wind _= M / M r\n"; - public static final String OPC_LAYER_LAPSE_LINE = "Layer Lapse Rate _= %.2f C/%.1fC/Km\r\n"; - public static final String OPC_LAYER_LAPSE_MISSING ="Layer Lapse Rate _= M / M\r\n"; - - /* - * STORM RELATIVE data string - */ - public static final String STORM_RELATIVE_STR = "\t\t\tSTORM RELATIVE \r\n"; - // SR header strings - public static final String STORM_HELICITY_STR = "\t\t------ SR HELICITY ------\r\n"; - public static final String STORM_WIND_STR = "\r\n \t\t------ SR WINDS ------\r\n"; - //SR Helicity line strings - public static final String STORM_MOTION_LINE = "%3.0f%c / %3.0f kt ( %.0f m/s )\r\n"; - public static final String STORM_MOTION_MISSING = "M / M (M)\r\n"; - public static final String STORM_LAYER_POS_STR = "LAYER_POS_NEG_TOT\r\n"; - public static final String STORM_SFC2KM_LINE = "Sfc - 2 km_%.0f_%4.0f_%.0f m%c/s%c\r\n"; - public static final String STORM_SFC3KM_LINE = "Sfc - 3 km_%.0f_%4.0f_%.0f m%c/s%c\r\n"; - public static final String STORM_LPL_LFC_LINE = "LPL - LFC_%.0f_%4.0f_%.0f m%c/s%c\r\n"; - public static final String STORM_SFC3KM_MISSING = "Sfc - 3 km_M _M _M\r\n"; - public static final String STORM_SFC2KM_MISSING = "Sfc - 2 km_M _M _M\r\n"; - public static final String STORM_LPL_LFC_MISSING= "LPL - LFC _M _M _M\r\n"; - public static final String STORM_LAYER_VECTOR_STR = "LAYER_VECTOR\r\n"; - public static final String STORM_SFC2KM_VECT_LINE = "Sfc - 2 km_%3.0f / %3.0f kt (%3.0f m/s)\r\n"; - public static final String STORM_SFC2KM_VECT_MISSING = "Sfc - 2 km_ M / M (M)\r\n"; - public static final String STORM_4_6KM_VECT_LINE = "4 - 6 km _%3.0f / %3.0f kt (%3.0f m/s)\r\n"; - public static final String STORM_4_6KM_VECT_MISSING = "4 - 6 km_ M / M (M)\r\n"; - public static final String STORM_9_11KM_VECT_LINE = "9 - 11 km_%3.0f / %3.0f kt (%3.0f m/s)\r\n"; - public static final String STORM_9_11KM_VECT_MISSING = "9 - 11 km_ M / M (M)\r\n"; - - /* - * MEAN WIND data string - */ - public static final String MEAN_WIND_STR = "\t\t\t\tMEAN WIND \r\n"; - //Mean Wind line strings - public static final String MEANWIND_SFC6KM_LINE = "Sfc - 6 km_%3.0f /\t%3.0f kt\t(%.0f m/s)\r\n"; - public static final String MEANWIND_LFC_EL_LINE = "LFC - EL_%3.0f /\t%3.0f kt\t(%.0f m/s)\r\n"; - public static final String MEANWIND_850_200MB_LINE = "850 - 200 mb_%3.0f /\t%3.0f kt\t(%.0f m/s)\r\n"; - public static final String MEANWIND_SFC6KM_MISSING = "Sfc - 6 km_M / \tM \t(M)\r\n"; - public static final String MEANWIND_LFC_EL_MISSING = "LFC - EL_M / \tM \t(M)\r\n"; - public static final String MEANWIND_850_200MB_MISSING = "850 - 200 mb_M / \tM \t(M)\r\n"; - /* - * ENVIRONMENTAL SHEAR data string - */ - public static final String ENVIRONMENTAL_SHEAR_STR = "\t\t\tENVIRONMENTAL SHEAR \r\n"; - //ENVIRONMENTAL SHEAR line strings - public static final String SHEAR_LAYER_DELTA_STR = "LAYER_DELTA V_TOT SHR\r\n"; - public static final String SHEAR_LOW_3KM_LINE = "Low - 3 km_%3.0f kt (%3.0f m/s)_%.0f\r\n"; - public static final String SHEAR_LOW_3KM_MISSING = "Low - 3 km_M ( M )_M\r\n"; - public static final String SHEAR_SFC_2KM_LINE = "Sfc - 2 km_%3.0f kt (%3.0f m/s)_%.0f\r\n"; - public static final String SHEAR_SFC_2KM_MISSING = "Sfc - 2 km_M ( M )_M\r\n"; - public static final String SHEAR_SFC_6KM_LINE = "Sfc - 6 km_%3.0f kt (%3.0f m/s)_%.0f\r\n"; - public static final String SHEAR_SFC_6KM_MISSING = "Sfc - 6 km_M ( M )_M\r\n"; - public static final String SHEAR_SFC_12KM_LINE = "Sfc - 12 km_%3.0f kt (%3.0f m/s)_%.0f\r\n"; - public static final String SHEAR_SFC_12KM_MISSING = "Sfc - 12 km_M ( M ) _M\r\n"; - - /* - * CONVECTIVE INITIATION data strings - */ - public static final String CONVECTIVE_INITIATION_STR = "\t\t\t\tCONVECTIVE INITIATION \r\n"; - public static final String CONVECTIVE_CINH_LINE = "CINH_= %6.0f J/Kg"; - public static final String CONVECTIVE_KINDEX_LINE = "K-Index_= %6.0f"; - public static final String CONVECTIVE_CINH_MISSING = "CINH_= M"; - public static final String CONVECTIVE_KINDEX_MISSING = "K-Index_= M"; - public static final String CONVECTIVE_CAP_LINE = "Cap_= %.0fC / %.0fmb\n"; - public static final String CONVECTIVE_MEANRH_LINE = "Mean RH_= %.0f %c"; - public static final String CONVECTIVE_CAP_MISSING = "Cap_= M / M\r\n"; - public static final String CONVECTIVE_MEANRH_MISSING = "Mean RH_= M\r\n"; - public static final String CONVECTIVE_TOP_LINE = "Top of Moist Lyr = %.0f mb / %.0f ft\r\n"; - public static final String CONVECTIVE_TOP_MISSING = "Top of Moist Lyr = M / M\r\n"; - public static final String CONVECTIVE_LFC_LINE = "LFC Height = %.0f mb / %.0f ft\r\n"; - public static final String CONVECTIVE_LFC_MISSING = "LFC Height = M / M\r\n"; + public static final String OPC_CHANGE_IN_TEMP_LINE = "Change in Temp = %.2f C\r\n"; - /* - * STORM TYPE data strings - */ - public static final String STORM_TYPE_STR = "\t\t\t\t STORM TYPE \r\n"; - public static final String STORM_TYPE_CAPE_LINE = "CAPE _= %6.0f J/Kg\t"; - public static final String STORM_TYPE_EHI_LINE = "EHI _= %6.1f \t"; - public static final String STORM_TYPE_BRN_LINE = "BRN _= %6.0f \t"; - public static final String STORM_TYPE_CAPE_MISSING = "CAPE _= M"; - public static final String STORM_TYPE_EHI_MISSING = "EHI _= M"; - public static final String STORM_TYPE_BRN_MISSING = "BRN _= M"; - public static final String STORM_TYPE_EFF_LINE = "Eff. SREH _= %.0f m%c/s%c\r\n"; - public static final String STORM_TYPE_EFF_MISSING = "Eff. SREH _= M\r\n"; - public static final String STORM_TYPE_3KM_LINE = "3km Shear _= %.0f m/s\r\n"; - public static final String STORM_TYPE_3KM_MISSING = "3km Shear _= M\r\n"; - public static final String STORM_TYPE_BRNSHEAR_LINE = "BRN Shear _= %.0f m%c/s%c\r\n"; - public static final String STORM_TYPE_BRNSHEAR_MISSING = "BRN Shear _= M\r\n"; - /* - * SEVERE POTENTIAL data strings - */ - public static final String SEVERE_POTENTIAL_STR = "\t\t\t\tSEVERE POTENTIAL \r\n"; - // SEVERE POTENTIAL HEADER STR - public static final String SEVERE_HAIL_POTENTIAL_STR = "\t\t------ HAIL POTENTIAL ------\r\n"; - public static final String SEVERE_TORNADO_POTENTIAL_STR = "\t\t------ TORNADO POTENTIAL ------\r\n"; - // SEVERE POTENTIAL LINE STRING - public static final String SEVERE_CAPE_LINE = "CAPE_= %5.0f J/Kg"; - public static final String SEVERE_MIDRH_LINE = "Mid Lvl RH_= %5.0f %c"; - public static final String SEVERE_CHI1_LINE = "CHI1_= %5.1f "; - public static final String SEVERE_CAPE_MISSING = "CAPE_= M"; - public static final String SEVERE_MIDRH_MISSING = "Mid Lvl RH_= M"; - public static final String SEVERE_CHI1_MISSING = "CHI1_= M"; - public static final String SEVERE_WBZ_LINE = "WBZ level_= %.0fft\r\n"; - public static final String SEVERE_FGZ_LINE = "FGZ level_= %.0fft\r\n"; - public static final String SEVERE_CHI2_LINE ="CHI2_= %.1f\r\n"; - public static final String SEVERE_WBZ_MISSING = "WBZ level_= M\r\n"; - public static final String SEVERE_FGZ_MISSING = "FGZ level_= M\r\n"; - public static final String SEVERE_CHI2_MISSING ="CHI2_= M\r\n"; - public static final String SEVERE_ELSTORM_LINE = "EL Storm Relative Wind Speed = %.0f kt \r\n"; - public static final String SEVERE_ELSTORM_MISSING = "EL Storm Relative Wind Speed = M \r\n"; - public static final String SEVERE_AVGBL_LINE = "Avg BL Wetbulb Temp = %.1f %cC \r\n"; - public static final String SEVERE_AVGBL_MISSING = "Avg BL Wetbulb Temp = M \r\n"; - public static final String SEVERE_LOWSRWSFC_LINE = "Low SRW (Sfc - LFC) _= %.0f kt\r\n"; - public static final String SEVERE_MIDSRW_LINE = "Mid SRW (LFC - LFC+4km) _= %.0f kt\r\n"; - public static final String SEVERE_LOWSRWEL_LINE = "Low SRW (EL-4km - EL) _= %.0f kt\r\n"; - public static final String SEVERE_LOWSRWSFC_MISSING = "Low SRW (Sfc - LFC) _= M \r\n"; - public static final String SEVERE_MIDSRW_MISSING = "Mid SRW (LFC - LFC+4km) _= M \r\n"; - public static final String SEVERE_LOWSRWEL_MISSING = "Low SRW (EL-4km - EL) _= M \r\n"; + public static final String OPC_CHANGE_IN_TEMP_MISSING = "Change in Temp = M\r\n"; - /* - * PRECIPITATION TYPE data strings - */ - public static final String PRECIPITATION_TYPE_STR = "\t\t\t\t PRECIPITATION TYPE \r\n"; - public static final String PRECIPITATION_MELTING_LINE = "Melting Level = %.0f ft / %.0f mb\r\n"; - public static final String PRECIPITATION_MELTING_MISSING = "Melting Level = M \r\n"; + // mixing height line strings + public static final String OPC_LAYER_BASED_STR = "\t\t\t\t*** Layer Based ***\r\n"; - /* - * HEAVY RAINFALL data strings - */ - public static final String HEAVY_RAINFALL_STR = "\t\t\t\t HEAVY RAINFALL \r\n"; - // change Rogash QPF to Rainfall Rate (TL) - public static final String HEAVY_ROGASH_LINE = "Rogash Rainfall Rate = %.2f in/hr\r\n"; - public static final String HEAVY_ROGASH_MISSING = "Rogash Rainfall Rate = M \r\n"; + public static final String OPC_SURFACE_BASED_STR = "\t\t\t\t*** Surface Based ***\r\n"; - - // use parcel type to retrieve parcel header string for display - public static final Map parcelToHdrStrMap = new HashMap(){ - private static final long serialVersionUID = 1L; + public static final String OPC_DRY_AD_LINE = "Dry Ad Lapse Rate _= 9.8 C/Km\r\n"; - { + public static final String OPC_THRESH_LAPSE_LINE = "Thresh Lapse Rate _= 8.3 C/Km\r\n"; + + public static final String OPC_MIXINGHEIGHT_LINE = "Mixing Height _= %.0f m\r\n"; + + public static final String OPC_MIXINGPRESSURE_LINE = "Mixing Pressure _= %.0f mb\r\n"; + + public static final String OPC_TOPMIXLAYER_LINE = "Top Mix Layer Wind _= %d%c/%d kt\r\n"; + + public static final String OPC_MIXLAYERMAX_LINE = "Mix Layer Max Wind _= %d%c/%d kt\r\n"; + + public static final String OPC_MIXINGHEIGHT_MISSING = "Mixing Height _= M\r\n"; + + public static final String OPC_MIXINGPRESSURE_MISSING = "Mixing Pressure _= M\r\n"; + + public static final String OPC_TOPMIXLAYER_MISSING = "Top Mix Layer Wind _= M / M\r\n"; + + public static final String OPC_MIXLAYERMAX_MISSING = "Mix Layer Max Wind _= M / M r\n"; + + public static final String OPC_LAYER_LAPSE_LINE = "Layer Lapse Rate _= %.2f C/%.1fC/Km\r\n"; + + public static final String OPC_LAYER_LAPSE_MISSING = "Layer Lapse Rate _= M / M\r\n"; + + /* + * STORM RELATIVE data string + */ + public static final String STORM_RELATIVE_STR = "\t\t\tSTORM RELATIVE \r\n"; + + // SR header strings + public static final String STORM_HELICITY_STR = "\t\t------ SR HELICITY ------\r\n"; + + public static final String STORM_WIND_STR = "\r\n \t\t------ SR WINDS ------\r\n"; + + // SR Helicity line strings + public static final String STORM_MOTION_LINE = "%3.0f%c / %3.0f kt ( %.0f m/s )\r\n"; + + public static final String STORM_MOTION_MISSING = "M / M (M)\r\n"; + + public static final String STORM_LAYER_POS_STR = "LAYER_POS_NEG_TOT\r\n"; + + public static final String STORM_SFC2KM_LINE = "Sfc - 2 km_%.0f_%4.0f_%.0f m%c/s%c\r\n"; + + public static final String STORM_SFC3KM_LINE = "Sfc - 3 km_%.0f_%4.0f_%.0f m%c/s%c\r\n"; + + public static final String STORM_LPL_LFC_LINE = "LPL - LFC_%.0f_%4.0f_%.0f m%c/s%c\r\n"; + + public static final String STORM_SFC3KM_MISSING = "Sfc - 3 km_M _M _M\r\n"; + + public static final String STORM_SFC2KM_MISSING = "Sfc - 2 km_M _M _M\r\n"; + + public static final String STORM_LPL_LFC_MISSING = "LPL - LFC _M _M _M\r\n"; + + public static final String STORM_LAYER_VECTOR_STR = "LAYER_VECTOR\r\n"; + + public static final String STORM_SFC2KM_VECT_LINE = "Sfc - 2 km_%3.0f / %3.0f kt (%3.0f m/s)\r\n"; + + public static final String STORM_SFC2KM_VECT_MISSING = "Sfc - 2 km_ M / M (M)\r\n"; + + public static final String STORM_4_6KM_VECT_LINE = "4 - 6 km _%3.0f / %3.0f kt (%3.0f m/s)\r\n"; + + public static final String STORM_4_6KM_VECT_MISSING = "4 - 6 km_ M / M (M)\r\n"; + + public static final String STORM_9_11KM_VECT_LINE = "9 - 11 km_%3.0f / %3.0f kt (%3.0f m/s)\r\n"; + + public static final String STORM_9_11KM_VECT_MISSING = "9 - 11 km_ M / M (M)\r\n"; + + /* + * MEAN WIND data string + */ + public static final String MEAN_WIND_STR = "\t\t\t\tMEAN WIND \r\n"; + + // Mean Wind line strings + public static final String MEANWIND_SFC6KM_LINE = "Sfc - 6 km_%3.0f /\t%3.0f kt\t(%.0f m/s)\r\n"; + + public static final String MEANWIND_LFC_EL_LINE = "LFC - EL_%3.0f /\t%3.0f kt\t(%.0f m/s)\r\n"; + + public static final String MEANWIND_850_200MB_LINE = "850 - 200 mb_%3.0f /\t%3.0f kt\t(%.0f m/s)\r\n"; + + public static final String MEANWIND_SFC6KM_MISSING = "Sfc - 6 km_M / \tM \t(M)\r\n"; + + public static final String MEANWIND_LFC_EL_MISSING = "LFC - EL_M / \tM \t(M)\r\n"; + + public static final String MEANWIND_850_200MB_MISSING = "850 - 200 mb_M / \tM \t(M)\r\n"; + + /* + * ENVIRONMENTAL SHEAR data string + */ + public static final String ENVIRONMENTAL_SHEAR_STR = "\t\t\tENVIRONMENTAL SHEAR \r\n"; + + // ENVIRONMENTAL SHEAR line strings + public static final String SHEAR_LAYER_DELTA_STR = "LAYER_DELTA V_TOT SHR\r\n"; + + public static final String SHEAR_LOW_3KM_LINE = "Low - 3 km_%3.0f kt (%3.0f m/s)_%.0f\r\n"; + + public static final String SHEAR_LOW_3KM_MISSING = "Low - 3 km_M ( M )_M\r\n"; + + public static final String SHEAR_SFC_2KM_LINE = "Sfc - 2 km_%3.0f kt (%3.0f m/s)_%.0f\r\n"; + + public static final String SHEAR_SFC_2KM_MISSING = "Sfc - 2 km_M ( M )_M\r\n"; + + public static final String SHEAR_SFC_6KM_LINE = "Sfc - 6 km_%3.0f kt (%3.0f m/s)_%.0f\r\n"; + + public static final String SHEAR_SFC_6KM_MISSING = "Sfc - 6 km_M ( M )_M\r\n"; + + public static final String SHEAR_SFC_12KM_LINE = "Sfc - 12 km_%3.0f kt (%3.0f m/s)_%.0f\r\n"; + + public static final String SHEAR_SFC_12KM_MISSING = "Sfc - 12 km_M ( M ) _M\r\n"; + + /* + * CONVECTIVE INITIATION data strings + */ + public static final String CONVECTIVE_INITIATION_STR = "\t\t\t\tCONVECTIVE INITIATION \r\n"; + + public static final String CONVECTIVE_CINH_LINE = "CINH_= %6.0f J/Kg"; + + public static final String CONVECTIVE_KINDEX_LINE = "K-Index_= %6.0f"; + + public static final String CONVECTIVE_CINH_MISSING = "CINH_= M"; + + public static final String CONVECTIVE_KINDEX_MISSING = "K-Index_= M"; + + public static final String CONVECTIVE_CAP_LINE = "Cap_= %.0fC / %.0fmb\n"; + + public static final String CONVECTIVE_MEANRH_LINE = "Mean RH_= %.0f %c"; + + public static final String CONVECTIVE_CAP_MISSING = "Cap_= M / M\r\n"; + + public static final String CONVECTIVE_MEANRH_MISSING = "Mean RH_= M\r\n"; + + public static final String CONVECTIVE_TOP_LINE = "Top of Moist Lyr = %.0f mb / %.0f ft\r\n"; + + public static final String CONVECTIVE_TOP_MISSING = "Top of Moist Lyr = M / M\r\n"; + + public static final String CONVECTIVE_LFC_LINE = "LFC Height = %.0f mb / %.0f ft\r\n"; + + public static final String CONVECTIVE_LFC_MISSING = "LFC Height = M / M\r\n"; + + /* + * STORM TYPE data strings + */ + public static final String STORM_TYPE_STR = "\t\t\t\t STORM TYPE \r\n"; + + public static final String STORM_TYPE_CAPE_LINE = "CAPE _= %6.0f J/Kg\t"; + + public static final String STORM_TYPE_EHI_LINE = "EHI _= %6.1f \t"; + + public static final String STORM_TYPE_BRN_LINE = "BRN _= %6.0f \t"; + + public static final String STORM_TYPE_CAPE_MISSING = "CAPE _= M"; + + public static final String STORM_TYPE_EHI_MISSING = "EHI _= M"; + + public static final String STORM_TYPE_BRN_MISSING = "BRN _= M"; + + public static final String STORM_TYPE_EFF_LINE = "Eff. SREH _= %.0f m%c/s%c\r\n"; + + public static final String STORM_TYPE_EFF_MISSING = "Eff. SREH _= M\r\n"; + + public static final String STORM_TYPE_3KM_LINE = "3km Shear _= %.0f m/s\r\n"; + + public static final String STORM_TYPE_3KM_MISSING = "3km Shear _= M\r\n"; + + public static final String STORM_TYPE_BRNSHEAR_LINE = "BRN Shear _= %.0f m%c/s%c\r\n"; + + public static final String STORM_TYPE_BRNSHEAR_MISSING = "BRN Shear _= M\r\n"; + + /* + * SEVERE POTENTIAL data strings + */ + public static final String SEVERE_POTENTIAL_STR = "\t\t\t\tSEVERE POTENTIAL \r\n"; + + // SEVERE POTENTIAL HEADER STR + public static final String SEVERE_HAIL_POTENTIAL_STR = "\t\t------ HAIL POTENTIAL ------\r\n"; + + public static final String SEVERE_TORNADO_POTENTIAL_STR = "\t\t------ TORNADO POTENTIAL ------\r\n"; + + // SEVERE POTENTIAL LINE STRING + public static final String SEVERE_CAPE_LINE = "CAPE_= %5.0f J/Kg"; + + public static final String SEVERE_MIDRH_LINE = "Mid Lvl RH_= %5.0f %c"; + + public static final String SEVERE_CHI1_LINE = "CHI1_= %5.1f "; + + public static final String SEVERE_CAPE_MISSING = "CAPE_= M"; + + public static final String SEVERE_MIDRH_MISSING = "Mid Lvl RH_= M"; + + public static final String SEVERE_CHI1_MISSING = "CHI1_= M"; + + public static final String SEVERE_WBZ_LINE = "WBZ level_= %.0fft\r\n"; + + public static final String SEVERE_FGZ_LINE = "FGZ level_= %.0fft\r\n"; + + public static final String SEVERE_CHI2_LINE = "CHI2_= %.1f\r\n"; + + public static final String SEVERE_WBZ_MISSING = "WBZ level_= M\r\n"; + + public static final String SEVERE_FGZ_MISSING = "FGZ level_= M\r\n"; + + public static final String SEVERE_CHI2_MISSING = "CHI2_= M\r\n"; + + public static final String SEVERE_ELSTORM_LINE = "EL Storm Relative Wind Speed = %.0f kt \r\n"; + + public static final String SEVERE_ELSTORM_MISSING = "EL Storm Relative Wind Speed = M \r\n"; + + public static final String SEVERE_AVGBL_LINE = "Avg BL Wetbulb Temp = %.1f %cC \r\n"; + + public static final String SEVERE_AVGBL_MISSING = "Avg BL Wetbulb Temp = M \r\n"; + + public static final String SEVERE_LOWSRWSFC_LINE = "Low SRW (Sfc - LFC) _= %.0f kt\r\n"; + + public static final String SEVERE_MIDSRW_LINE = "Mid SRW (LFC - LFC+4km) _= %.0f kt\r\n"; + + public static final String SEVERE_LOWSRWEL_LINE = "Low SRW (EL-4km - EL) _= %.0f kt\r\n"; + + public static final String SEVERE_LOWSRWSFC_MISSING = "Low SRW (Sfc - LFC) _= M \r\n"; + + public static final String SEVERE_MIDSRW_MISSING = "Mid SRW (LFC - LFC+4km) _= M \r\n"; + + public static final String SEVERE_LOWSRWEL_MISSING = "Low SRW (EL-4km - EL) _= M \r\n"; + + /* + * PRECIPITATION TYPE data strings + */ + public static final String PRECIPITATION_TYPE_STR = "\t\t\t\t PRECIPITATION TYPE \r\n"; + + public static final String PRECIPITATION_MELTING_LINE = "Melting Level = %.0f ft / %.0f mb\r\n"; + + public static final String PRECIPITATION_MELTING_MISSING = "Melting Level = M \r\n"; + + /* + * HEAVY RAINFALL data strings + */ + public static final String HEAVY_RAINFALL_STR = "\t\t\t\t HEAVY RAINFALL \r\n"; + + // change Rogash QPF to Rainfall Rate (TL) + public static final String HEAVY_ROGASH_LINE = "Rogash Rainfall Rate = %.2f in/hr\r\n"; + + public static final String HEAVY_ROGASH_MISSING = "Rogash Rainfall Rate = M \r\n"; + + // use parcel type to retrieve parcel header string for display + public static final Map parcelToHdrStrMap = new HashMap() { + private static final long serialVersionUID = 1L; + + { put(NsharpNativeConstants.PARCELTYPE_OBS_SFC, PARCEL_OBS_SFC_STR); - put(NsharpNativeConstants.PARCELTYPE_FCST_SFC, PARCEL_FORECAST_SFC_STR); - put(NsharpNativeConstants.PARCELTYPE_MEAN_MIXING, PARCEL_MEAN_MIXING_STR); - put(NsharpNativeConstants.PARCELTYPE_MOST_UNSTABLE, PARCEL_MOST_UNSTABLE_STR); - put(NsharpNativeConstants.PARCELTYPE_USER_DEFINED, PARCEL_USR_DEFINED_STR); + put(NsharpNativeConstants.PARCELTYPE_FCST_SFC, + PARCEL_FORECAST_SFC_STR); + put(NsharpNativeConstants.PARCELTYPE_MEAN_MIXING, + PARCEL_MEAN_MIXING_STR); + put(NsharpNativeConstants.PARCELTYPE_MOST_UNSTABLE, + PARCEL_MOST_UNSTABLE_STR); + put(NsharpNativeConstants.PARCELTYPE_USER_DEFINED, + PARCEL_USR_DEFINED_STR); put(NsharpNativeConstants.PARCELTYPE_EFF, PARCEL_MEAN_EFF_STR); } }; - - public static final Map parcelToTypeStrMap = new HashMap(){ - private static final long serialVersionUID = 1L; - { + public static final Map parcelToTypeStrMap = new HashMap() { + private static final long serialVersionUID = 1L; + + { put(NsharpNativeConstants.PARCELTYPE_OBS_SFC, PAGE1TEXT1_SB_STR); put(NsharpNativeConstants.PARCELTYPE_FCST_SFC, PAGE1TEXT1_FCST_STR); put(NsharpNativeConstants.PARCELTYPE_MEAN_MIXING, PAGE1TEXT1_ML_STR); - put(NsharpNativeConstants.PARCELTYPE_MOST_UNSTABLE, PAGE1TEXT1_MU_STR); - put(NsharpNativeConstants.PARCELTYPE_USER_DEFINED, PAGE1TEXT1_USER_STR); - put(NsharpNativeConstants.PARCELTYPE_EFF,PAGE1TEXT1_EFF_STR ); + put(NsharpNativeConstants.PARCELTYPE_MOST_UNSTABLE, + PAGE1TEXT1_MU_STR); + put(NsharpNativeConstants.PARCELTYPE_USER_DEFINED, + PAGE1TEXT1_USER_STR); + put(NsharpNativeConstants.PARCELTYPE_EFF, PAGE1TEXT1_EFF_STR); } }; - - public static final Map parcelToLayerMap = new HashMap(){ - private static final long serialVersionUID = 1L; - { + public static final Map parcelToLayerMap = new HashMap() { + private static final long serialVersionUID = 1L; + + { put(NsharpNativeConstants.PARCELTYPE_OBS_SFC, OBS_LAYER); put(NsharpNativeConstants.PARCELTYPE_FCST_SFC, FCST_LAYER); put(NsharpNativeConstants.PARCELTYPE_MEAN_MIXING, MML_LAYER); @@ -384,26 +607,48 @@ public static final String OPC_MIXINGPRESSURE_MISSING = "Mixing Pressure put(NsharpNativeConstants.PARCELTYPE_EFF, EFF_LAYER); } }; - public static final String TEMP_TRACE = "Temperature Trace"; - public static final String DEWP_TRACE = "Dewpoint Trace"; - public static final String PARCEL_VT_TRACE= "Parcel Tv Trace"; - public static final String PARCEL_T_TRACE= "Parcel Trace"; - public static final String DCAPE_TRACE = "DCAPE Trace"; - public static final String VTEMP_TRACE = "Virtual Temperature Trace"; - public static final String WETBULB_TRACE= "WetbulbTrace"; - public static final String MIXING_RATIO= "Mixing Ratio"; - public static final String DRY_ADIABAT= "Dry Adiabat"; - public static final String MOIST_ADIABAT= "Moist Adiabat"; - public static final String OMEGA = "Omega"; - public static final String MEAN_WIND_VECTOR = "Mean Wind Vector"; - public static final String STORM_MOTION_VECTOR_3075 = "30/75 Storm Motion Vector"; - public static final String STORM_MOTION_VECTOR_1585 = "15/85 Storm Motion Vector"; - public static final String STORM_MOTION_VECTOR_BUNKERS_R = "Bunkers R Storm Motion Vector"; - public static final String STORM_MOTION_VECTOR_BUNKERS_L = "Bunkers L Storm Motion Vector"; - public static final String CORFIDI_VECTORS = "Corfidi Vectors"; - public static final String HODOGRAPH = "Hodograph Trace"; - public static final String EFFECTIVE_LAYER = "Effective Layer"; - public static final String CLOUD = "Cloud"; - public static final String WINDBARB="Wind Barb"; - public static final float ENTRAIN_DEFAULT = 0.0f; + + public static final String TEMP_TRACE = "Temperature Trace"; + + public static final String DEWP_TRACE = "Dewpoint Trace"; + + public static final String PARCEL_VT_TRACE = "Parcel Tv Trace"; + + public static final String PARCEL_T_TRACE = "Parcel Trace"; + + public static final String DCAPE_TRACE = "DCAPE Trace"; + + public static final String VTEMP_TRACE = "Virtual Temperature Trace"; + + public static final String WETBULB_TRACE = "WetbulbTrace"; + + public static final String MIXING_RATIO = "Mixing Ratio"; + + public static final String DRY_ADIABAT = "Dry Adiabat"; + + public static final String MOIST_ADIABAT = "Moist Adiabat"; + + public static final String OMEGA = "Omega"; + + public static final String MEAN_WIND_VECTOR = "Mean Wind Vector"; + + public static final String STORM_MOTION_VECTOR_3075 = "30/75 Storm Motion Vector"; + + public static final String STORM_MOTION_VECTOR_1585 = "15/85 Storm Motion Vector"; + + public static final String STORM_MOTION_VECTOR_BUNKERS_R = "Bunkers R Storm Motion Vector"; + + public static final String STORM_MOTION_VECTOR_BUNKERS_L = "Bunkers L Storm Motion Vector"; + + public static final String CORFIDI_VECTORS = "Corfidi Vectors"; + + public static final String HODOGRAPH = "Hodograph Trace"; + + public static final String EFFECTIVE_LAYER = "Effective Layer"; + + public static final String CLOUD = "Cloud"; + + public static final String WINDBARB = "Wind Barb"; + + public static final float ENTRAIN_DEFAULT = 0.0f; } diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpDataPageConfigDialog.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpDataPageConfigDialog.java index 639f9312cb..2a7e88cd50 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpDataPageConfigDialog.java +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpDataPageConfigDialog.java @@ -25,308 +25,416 @@ import org.eclipse.swt.widgets.Text; import com.raytheon.uf.viz.core.exception.VizException; public class NsharpDataPageConfigDialog extends Dialog { - private MessageBox mb; - private NsharpConfigStore configStore=null; - private NsharpConfigManager mgr; - private NsharpDataPageProperty dpp; - private NsharpDataPageProperty editingDpp; - private static NsharpDataPageConfigDialog instance=null; - //this array is used to store page display "order" - private int[] pageOrderNumberArray = new int[NsharpConstants.PAGE_MAX_NUMBER+1];//element 0 is dummy one - private int[] editingOrderNumberArray = new int[NsharpConstants.PAGE_MAX_NUMBER+1];//element 0 is dummy one - - private int lblWidth = 200; - private int lblHeight = 20; - private int textWidth = 80; - - private int numberPagePerDisplay = 2; - private Label curLbl; - private Text newText; - private Text[] newOrderTextArray= new Text[NsharpConstants.PAGE_MAX_NUMBER+1];//element 0 is dummy one - private Label[] curOrderLblArray = new Label[NsharpConstants.PAGE_MAX_NUMBER+1];//element 0 is dummy one - private Label[] pageNameLblArray = new Label[NsharpConstants.PAGE_MAX_NUMBER+1];//element 0 is dummy one - public static NsharpDataPageConfigDialog getInstance(Shell parentShell) { - if(instance == null) - instance = new NsharpDataPageConfigDialog(parentShell); - return instance; - } - protected NsharpDataPageConfigDialog(Shell parentShell) { - super(parentShell); - instance = this; - mgr =NsharpConfigManager.getInstance(); - configStore = mgr.retrieveNsharpConfigStoreFromFs(); - dpp = configStore.getDataPageProperty(); - pageOrderNumberArray[NsharpConstants.PAGE_SUMMARY1 ] = dpp.getSummary1Page(); - pageOrderNumberArray[NsharpConstants.PAGE_SUMMARY2 ] = dpp.getSummary2Page(); - pageOrderNumberArray[NsharpConstants.PAGE_PARCEL_DATA ] = dpp.getParcelDataPage(); - pageOrderNumberArray[NsharpConstants.PAGE_THERMODYNAMIC_DATA ] = dpp.getThermodynamicDataPage(); - pageOrderNumberArray[NsharpConstants.PAGE_OPC_DATA ] = dpp.getOpcDataPage(); - pageOrderNumberArray[NsharpConstants.PAGE_MIXING_HEIGHT] = dpp.getMixingHeightPage(); - pageOrderNumberArray[NsharpConstants.PAGE_STORM_RELATIVE ] = dpp.getStormRelativePage(); - pageOrderNumberArray[NsharpConstants.PAGE_MEAN_WIND ] = dpp.getMeanWindPage(); - pageOrderNumberArray[NsharpConstants.PAGE_CONVECTIVE_INITIATION ] = dpp.getConvectiveInitiationPage(); - pageOrderNumberArray[NsharpConstants.PAGE_SEVERE_POTENTIAL ] = dpp.getSeverePotentialPage(); - editingOrderNumberArray = pageOrderNumberArray.clone(); - numberPagePerDisplay = dpp.getNumberPagePerDisplay(); - mb = new MessageBox(parentShell, SWT.ICON_WARNING - | SWT.OK ); - - } - /* + private MessageBox mb; + + private NsharpConfigStore configStore = null; + + private NsharpConfigManager mgr; + + private NsharpDataPageProperty dpp; + + private NsharpDataPageProperty editingDpp; + + private String paneConfigurationName; // d2dlite + + private Group btnGp; + + private static NsharpDataPageConfigDialog instance = null; + + // this array is used to store page display "order" + private int[] pageOrderNumberArray = new int[NsharpConstants.PAGE_MAX_NUMBER + 1];// element + // 0 + // is + // dummy + // one + + private int[] editingOrderNumberArray = new int[NsharpConstants.PAGE_MAX_NUMBER + 1];// element + // 0 + // is + // dummy + // one + + private int lblWidth = 200; + + private int lblHeight = 20; + + private int textWidth = 80; + + private int numberPagePerDisplay = 2; + + private Label curLbl; + + private Text newText; + + private Text[] newOrderTextArray = new Text[NsharpConstants.PAGE_MAX_NUMBER + 1];// element + // 0 + // is + // dummy + // one + + private Label[] curOrderLblArray = new Label[NsharpConstants.PAGE_MAX_NUMBER + 1];// element + // 0 + // is + // dummy + // one + + private Label[] pageNameLblArray = new Label[NsharpConstants.PAGE_MAX_NUMBER + 1];// element + // 0 + // is + // dummy + // one + + public static NsharpDataPageConfigDialog getInstance(Shell parentShell) { + if (instance == null) + instance = new NsharpDataPageConfigDialog(parentShell); + return instance; + } + + protected NsharpDataPageConfigDialog(Shell parentShell) { + super(parentShell); + instance = this; + mgr = NsharpConfigManager.getInstance(); + configStore = mgr.retrieveNsharpConfigStoreFromFs(); + dpp = configStore.getDataPageProperty(); + paneConfigurationName = configStore.getGraphProperty() + .getPaneConfigurationName(); + pageOrderNumberArray[NsharpConstants.PAGE_SUMMARY1] = dpp + .getSummary1Page(); + pageOrderNumberArray[NsharpConstants.PAGE_SUMMARY2] = dpp + .getSummary2Page(); + pageOrderNumberArray[NsharpConstants.PAGE_PARCEL_DATA] = dpp + .getParcelDataPage(); + pageOrderNumberArray[NsharpConstants.PAGE_THERMODYNAMIC_DATA] = dpp + .getThermodynamicDataPage(); + pageOrderNumberArray[NsharpConstants.PAGE_OPC_DATA] = dpp + .getOpcDataPage(); + pageOrderNumberArray[NsharpConstants.PAGE_MIXING_HEIGHT] = dpp + .getMixingHeightPage(); + pageOrderNumberArray[NsharpConstants.PAGE_STORM_RELATIVE] = dpp + .getStormRelativePage(); + pageOrderNumberArray[NsharpConstants.PAGE_MEAN_WIND] = dpp + .getMeanWindPage(); + pageOrderNumberArray[NsharpConstants.PAGE_CONVECTIVE_INITIATION] = dpp + .getConvectiveInitiationPage(); + pageOrderNumberArray[NsharpConstants.PAGE_SEVERE_POTENTIAL] = dpp + .getSeverePotentialPage(); + pageOrderNumberArray[NsharpConstants.PAGE_D2DLITE] = dpp + .getD2dLitePage(); // d2dlite + pageOrderNumberArray[NsharpConstants.PAGE_FUTURE] = dpp.getFuturePage(); // d2dlite + editingOrderNumberArray = pageOrderNumberArray.clone(); + numberPagePerDisplay = dpp.getNumberPagePerDisplay(); + mb = new MessageBox(parentShell, SWT.ICON_WARNING | SWT.OK); + + } + + /* * (non-Javadoc) * - * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) - */ - @Override - protected void configureShell( Shell shell ) { - super.configureShell( shell ); - shell.setText( "Data Page Display Configuration" ); - - } - @Override - public int open( ) { - if ( this.getShell() == null ){ - this.create(); - } - this.getShell().setLocation(this.getShell().getParent().getLocation().x+1100, - this.getShell().getParent().getLocation().y+200); - return super.open(); - - } - @Override - public void createButtonsForButtonBar(Composite parent) { - // create OK button but using Apply label for applying user entered data - //Chin note: when "apply" button is selected or Return key is entered, - // okPressed() will be called. So, handle event at one place, ie.e at okPressed(). - createButton(parent, IDialogConstants.OK_ID, - "Apply", - true); - - Button saveBtn = createButton(parent, IDialogConstants.INTERNAL_ID, - "Save",false); - saveBtn.addListener( SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - //System.out.println("save listener is called, also apply changes"); - if(sanityCheck()== false){ - System.out.println("sanity check failed"); - return; - } - applyChange(); - dpp.setSummary1Page(pageOrderNumberArray[NsharpConstants.PAGE_SUMMARY1 ]); - dpp.setSummary2Page(pageOrderNumberArray[NsharpConstants.PAGE_SUMMARY2 ]); - dpp.setParcelDataPage(pageOrderNumberArray[NsharpConstants.PAGE_PARCEL_DATA ]); - dpp.setThermodynamicDataPage(pageOrderNumberArray[NsharpConstants.PAGE_THERMODYNAMIC_DATA ] ); - dpp.setOpcDataPage(pageOrderNumberArray[NsharpConstants.PAGE_OPC_DATA ]); - dpp.setMixingHeightPage(pageOrderNumberArray[NsharpConstants.PAGE_MIXING_HEIGHT]); - dpp.setStormRelativePage(pageOrderNumberArray[NsharpConstants.PAGE_STORM_RELATIVE ] ); - dpp.setMeanWindPage(pageOrderNumberArray[NsharpConstants.PAGE_MEAN_WIND ] ); - dpp.setConvectiveInitiationPage(pageOrderNumberArray[NsharpConstants.PAGE_CONVECTIVE_INITIATION ] ); - dpp.setSeverePotentialPage(pageOrderNumberArray[NsharpConstants.PAGE_SEVERE_POTENTIAL ] ); - dpp.setNumberPagePerDisplay(numberPagePerDisplay); - try { - //save to xml - mgr.saveConfigStoreToFs(configStore); - } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - - } - } ); + * @see + * org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets + * .Shell) + */ + @Override + protected void configureShell(Shell shell) { + super.configureShell(shell); + shell.setText("Data Page Display Configuration"); - Button canBtn = createButton(parent, IDialogConstants.CLOSE_ID, - IDialogConstants.CLOSE_LABEL, false); - canBtn.addListener( SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - //System.out.println("close listener is called"); - close(); - } - } ); - } - /* - * To make sure user does not configure same page order number for different page. - */ - private boolean sanityCheck(){ - for(int i=1; i <= NsharpConstants.PAGE_MAX_NUMBER; i++){ - String textStr = newOrderTextArray[i ].getText(); - if((textStr != null) && !(textStr.isEmpty())){ - if(!textStr.contains("-") || textStr.length() > 1){ - int pnum = Integer.decode(textStr); - if(pnum >=1 && pnum <= NsharpConstants.PAGE_MAX_NUMBER) - editingOrderNumberArray[i]= pnum; - else{ - System.out.println("wrong order ="+pnum); - mb.setMessage( "Wrong Configuration! Order number should be within [1-10]"); - mb.open(); - return false; - } - } - } - } - for(int i=1; i<= NsharpConstants.PAGE_MAX_NUMBER; i++){ - for(int j=1; j< NsharpConstants.PAGE_MAX_NUMBER; j++){ - if((i!=j) && editingOrderNumberArray[i]==editingOrderNumberArray[j]){ - mb.setMessage( "Wrong Configuration! Multiple pages with same order."); - mb.open(); - return false; - } - } - } - return true; - } - private void applyChange(){ - pageOrderNumberArray = editingOrderNumberArray.clone(); - for(int i=1; i <= NsharpConstants.PAGE_MAX_NUMBER; i++){ - curOrderLblArray[i].setText(Integer.toString(pageOrderNumberArray[i])); - } - NsharpEditor editor = NsharpEditor.getActiveNsharpEditor(); - if (editor != null) { - NsharpResourceHandler rsc = editor.getRscHandler(); - editingDpp = new NsharpDataPageProperty(); - editingDpp.setSummary1Page(pageOrderNumberArray[NsharpConstants.PAGE_SUMMARY1 ]); - editingDpp.setSummary2Page(pageOrderNumberArray[NsharpConstants.PAGE_SUMMARY2 ]); - editingDpp.setParcelDataPage(pageOrderNumberArray[NsharpConstants.PAGE_PARCEL_DATA ]); - editingDpp.setThermodynamicDataPage(pageOrderNumberArray[NsharpConstants.PAGE_THERMODYNAMIC_DATA ] ); - editingDpp.setOpcDataPage(pageOrderNumberArray[NsharpConstants.PAGE_OPC_DATA ]); - editingDpp.setMixingHeightPage(pageOrderNumberArray[NsharpConstants.PAGE_MIXING_HEIGHT]); - editingDpp.setStormRelativePage(pageOrderNumberArray[NsharpConstants.PAGE_STORM_RELATIVE ] ); - editingDpp.setMeanWindPage(pageOrderNumberArray[NsharpConstants.PAGE_MEAN_WIND ] ); - editingDpp.setConvectiveInitiationPage(pageOrderNumberArray[NsharpConstants.PAGE_CONVECTIVE_INITIATION ] ); - editingDpp.setSeverePotentialPage(pageOrderNumberArray[NsharpConstants.PAGE_SEVERE_POTENTIAL ] ); - editingDpp.setNumberPagePerDisplay(numberPagePerDisplay); - rsc.setDataPageProperty(editingDpp); - editor.refresh(); + } + + @Override + public int open() { + if (this.getShell() == null) { + this.create(); } - } - /*private void setDisplay(){ - int pageIndex = 0; - for(int orderNum=1; orderNum <= NsharpConstants.PAGE_MAX_NUMBER; orderNum++){ - for(int j=1; j <= NsharpConstants.PAGE_MAX_NUMBER; j++){ - //find the page with order number equal to orderNum - if(orderNum == pageOrderNumberArray[j]){ - pageIndex = j; - break; - } - } - curOrderLblArray[orderNum].setText(Integer.toString(pageOrderNumberArray[pageIndex])); - newOrderTextArray[orderNum].setText(Integer.toString(pageOrderNumberArray[pageIndex])); - pageNameLblArray[orderNum].setText(NsharpConstants.PAGE_NAME_ARRAY[pageIndex]); - } - }*/ - @Override - public void okPressed() { - //"Enter" key is pressed, or "Apply" button is pressed. - //Chin: handle user entered configuration, sanity checking and apply its changes. - //System.out.println("CR is pressed"); - setReturnCode(OK); - if(sanityCheck()== false){ - System.out.println("sanity check failed"); - return; - } - applyChange(); - } - - @Override - protected Control createDialogArea(Composite parent) { - Composite top; - top = (Composite) super.createDialogArea(parent); - // Create the main layout for the shell. - GridLayout mainLayout = new GridLayout(1, false); - mainLayout.marginHeight = 3; - mainLayout.marginWidth = 3; - top.setLayout(mainLayout); - - Group btnGp = new Group(top, SWT.SHADOW_ETCHED_IN); - btnGp.setText("number of page per display"); - //.setFont(newFont); - Button oneBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); - oneBtn.setText("1"); - oneBtn.setEnabled( true ); - oneBtn.setBounds(btnGp.getBounds().x+ NsharpConstants.btnGapX, btnGp.getBounds().y + NsharpConstants.labelGap, NsharpConstants.btnWidth,NsharpConstants.btnHeight); - //oneBtn.setFont(newFont); - oneBtn.addListener( SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - numberPagePerDisplay=1; - //System.out.println("new obvSnd dialog uair btn"); - } - } ); - - - Button twoBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); - twoBtn.setText("2"); - twoBtn.setEnabled( true ); - twoBtn.setBounds(btnGp.getBounds().x+ NsharpConstants.btnGapX, oneBtn.getBounds().y + oneBtn.getBounds().height+ NsharpConstants.btnGapY, NsharpConstants.btnWidth,NsharpConstants.btnHeight); - //twoBtn.setFont(newFont); - twoBtn.addListener( SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - numberPagePerDisplay=2; - } - } ); - if(numberPagePerDisplay==1) - oneBtn.setSelection(true); - else - twoBtn.setSelection(true); - Group configGp = new Group(top, SWT.SHADOW_ETCHED_IN | SWT.NO_RADIO_GROUP); - Label nameLbl = new Label(configGp, SWT.BORDER ); - nameLbl.setText(" Page Name"); - nameLbl.setBounds(configGp.getBounds().x, configGp.getBounds().y, lblWidth,lblHeight); - Label curOrderLbl = new Label(configGp, SWT.BORDER ); - curOrderLbl.setText("Current"); - curOrderLbl.setBounds(nameLbl.getBounds().x+nameLbl.getBounds().width, nameLbl.getBounds().y,textWidth,lblHeight); - Label newOrderLbl =new Label(configGp, SWT.BORDER ); - //newOrderLbl.setText(Integer.toString(summary1Page)); - newOrderLbl.setBounds(curOrderLbl.getBounds().x+curOrderLbl.getBounds().width, nameLbl.getBounds().y,textWidth,lblHeight); - newOrderLbl.setText("New Order"); - Label prevLbl = nameLbl; - Label pageLbl; - for(int i=1; i <= NsharpConstants.PAGE_MAX_NUMBER; i++){ - pageLbl = pageNameLblArray[i] = new Label(configGp, SWT.BORDER ); - pageLbl.setText(NsharpConstants.PAGE_NAME_ARRAY[i]); - pageLbl.setBounds(configGp.getBounds().x, prevLbl.getBounds().y+lblHeight, lblWidth,lblHeight); - curLbl = curOrderLblArray[i] =new Label(configGp, SWT.BORDER ); - curLbl.setText(Integer.toString(pageOrderNumberArray[i])); - curLbl.setBounds(pageLbl.getBounds().x+pageLbl.getBounds().width, pageLbl.getBounds().y,textWidth,lblHeight); - newText = newOrderTextArray[i] = new Text(configGp, SWT.BORDER | SWT.SINGLE); - newText.setBounds(curLbl.getBounds().x+curLbl.getBounds().width, pageLbl.getBounds().y,textWidth,lblHeight); - newText.setEditable(true); - newText.setText(Integer.toString(pageOrderNumberArray[i])); - //to make sure user enter digits only - newText.addListener (SWT.Verify, new EditListener (newText) ); - prevLbl = pageLbl; - } - return top; - } - public class EditListener implements Listener { - Text newOrderText; - public void handleEvent (Event e) { - String string = e.text; - char [] chars = new char [string.length ()]; - string.getChars (0, chars.length, chars, 0); - //System.out.println("entered s="+ string); - //Chin note: when "Delete", "Backspace" entered, this handler will be called, but - // its chars.length = 0 - if(chars.length == 1 && newOrderText!=null){ - if(chars [0] == '-' ){ - //if "-" is not first char - String textStr = newOrderText.getText(); - if((textStr != null) && (textStr.length() >= 1) && (textStr.contains("-"))){ - e.doit = false; - return; - } - }else if (!('0' <= chars [0] && chars [0] <= '9')) { - e.doit = false; - return; - } + this.getShell().setLocation( + this.getShell().getParent().getLocation().x + 1100, + this.getShell().getParent().getLocation().y + 200); + mgr = NsharpConfigManager.getInstance(); + configStore = mgr.retrieveNsharpConfigStoreFromFs(); + dpp = configStore.getDataPageProperty(); + paneConfigurationName = configStore.getGraphProperty() + .getPaneConfigurationName(); + if (paneConfigurationName.equals(NsharpConstants.PANE_LITE_D2D_CFG_STR)) // d2dlite + btnGp.setVisible(false); + else + btnGp.setVisible(true); + return super.open(); - } - } + } + + @Override + public void createButtonsForButtonBar(Composite parent) { + // create OK button but using Apply label for applying user entered data + // Chin note: when "apply" button is selected or Return key is entered, + // okPressed() will be called. So, handle event at one place, ie.e at + // okPressed(). + createButton(parent, IDialogConstants.OK_ID, "Apply", true); + + Button saveBtn = createButton(parent, IDialogConstants.INTERNAL_ID, + "Save", false); + saveBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + // System.out.println("save listener is called, also apply changes"); + if (sanityCheck() == false) { + System.out.println("sanity check failed"); + return; + } + applyChange(); + dpp.setSummary1Page(pageOrderNumberArray[NsharpConstants.PAGE_SUMMARY1]); + dpp.setSummary2Page(pageOrderNumberArray[NsharpConstants.PAGE_SUMMARY2]); + dpp.setParcelDataPage(pageOrderNumberArray[NsharpConstants.PAGE_PARCEL_DATA]); + dpp.setThermodynamicDataPage(pageOrderNumberArray[NsharpConstants.PAGE_THERMODYNAMIC_DATA]); + dpp.setOpcDataPage(pageOrderNumberArray[NsharpConstants.PAGE_OPC_DATA]); + dpp.setMixingHeightPage(pageOrderNumberArray[NsharpConstants.PAGE_MIXING_HEIGHT]); + dpp.setStormRelativePage(pageOrderNumberArray[NsharpConstants.PAGE_STORM_RELATIVE]); + dpp.setMeanWindPage(pageOrderNumberArray[NsharpConstants.PAGE_MEAN_WIND]); + dpp.setConvectiveInitiationPage(pageOrderNumberArray[NsharpConstants.PAGE_CONVECTIVE_INITIATION]); + dpp.setSeverePotentialPage(pageOrderNumberArray[NsharpConstants.PAGE_SEVERE_POTENTIAL]); + dpp.setD2dLitePage(pageOrderNumberArray[NsharpConstants.PAGE_D2DLITE]);// d2dlite + dpp.setFuturePage(pageOrderNumberArray[NsharpConstants.PAGE_FUTURE]);// d2dlite + dpp.setNumberPagePerDisplay(numberPagePerDisplay); + try { + // save to xml + mgr.saveConfigStoreToFs(configStore); + } catch (VizException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + }); + + Button canBtn = createButton(parent, IDialogConstants.CLOSE_ID, + IDialogConstants.CLOSE_LABEL, false); + canBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + // System.out.println("close listener is called"); + close(); + } + }); + } + + /* + * To make sure user does not configure same page order number for different + * page. + */ + private boolean sanityCheck() { + for (int i = 1; i <= NsharpConstants.PAGE_MAX_NUMBER; i++) { + String textStr = newOrderTextArray[i].getText(); + if ((textStr != null) && !(textStr.isEmpty())) { + if (!textStr.contains("-") || textStr.length() > 1) { + int pnum = Integer.decode(textStr); + if (pnum >= 1 && pnum <= NsharpConstants.PAGE_MAX_NUMBER) + editingOrderNumberArray[i] = pnum; + else { + System.out.println("wrong order =" + pnum); + mb.setMessage("Wrong Configuration! Order number should be within [1-12]"); + mb.open(); + return false; + } + } + } + } + for (int i = 1; i <= NsharpConstants.PAGE_MAX_NUMBER; i++) { + for (int j = 1; j < NsharpConstants.PAGE_MAX_NUMBER; j++) { + if ((i != j) + && editingOrderNumberArray[i] == editingOrderNumberArray[j]) { + mb.setMessage("Wrong Configuration! Multiple pages with same order."); + mb.open(); + return false; + } + } + } + return true; + } + + private void applyChange() { + pageOrderNumberArray = editingOrderNumberArray.clone(); + for (int i = 1; i <= NsharpConstants.PAGE_MAX_NUMBER; i++) { + curOrderLblArray[i].setText(Integer + .toString(pageOrderNumberArray[i])); + } + NsharpEditor editor = NsharpEditor.getActiveNsharpEditor(); + if (editor != null) { + NsharpResourceHandler rsc = editor.getRscHandler(); + editingDpp = new NsharpDataPageProperty(); + editingDpp + .setSummary1Page(pageOrderNumberArray[NsharpConstants.PAGE_SUMMARY1]); + editingDpp + .setSummary2Page(pageOrderNumberArray[NsharpConstants.PAGE_SUMMARY2]); + editingDpp + .setParcelDataPage(pageOrderNumberArray[NsharpConstants.PAGE_PARCEL_DATA]); + editingDpp + .setThermodynamicDataPage(pageOrderNumberArray[NsharpConstants.PAGE_THERMODYNAMIC_DATA]); + editingDpp + .setOpcDataPage(pageOrderNumberArray[NsharpConstants.PAGE_OPC_DATA]); + editingDpp + .setMixingHeightPage(pageOrderNumberArray[NsharpConstants.PAGE_MIXING_HEIGHT]); + editingDpp + .setStormRelativePage(pageOrderNumberArray[NsharpConstants.PAGE_STORM_RELATIVE]); + editingDpp + .setMeanWindPage(pageOrderNumberArray[NsharpConstants.PAGE_MEAN_WIND]); + editingDpp + .setConvectiveInitiationPage(pageOrderNumberArray[NsharpConstants.PAGE_CONVECTIVE_INITIATION]); + editingDpp + .setSeverePotentialPage(pageOrderNumberArray[NsharpConstants.PAGE_SEVERE_POTENTIAL]); + editingDpp + .setD2dLitePage(pageOrderNumberArray[NsharpConstants.PAGE_D2DLITE]); // d2dlite + editingDpp + .setFuturePage(pageOrderNumberArray[NsharpConstants.PAGE_FUTURE]); // d2dlite + editingDpp.setNumberPagePerDisplay(numberPagePerDisplay); + rsc.setDataPageProperty(editingDpp); + editor.refresh(); + } + } + + /* + * private void setDisplay(){ int pageIndex = 0; for(int orderNum=1; + * orderNum <= NsharpConstants.PAGE_MAX_NUMBER; orderNum++){ for(int j=1; j + * <= NsharpConstants.PAGE_MAX_NUMBER; j++){ //find the page with order + * number equal to orderNum if(orderNum == pageOrderNumberArray[j]){ + * pageIndex = j; break; } } + * curOrderLblArray[orderNum].setText(Integer.toString + * (pageOrderNumberArray[pageIndex])); + * newOrderTextArray[orderNum].setText(Integer + * .toString(pageOrderNumberArray[pageIndex])); + * pageNameLblArray[orderNum].setText + * (NsharpConstants.PAGE_NAME_ARRAY[pageIndex]); } } + */ + @Override + public void okPressed() { + // "Enter" key is pressed, or "Apply" button is pressed. + // Chin: handle user entered configuration, sanity checking and apply + // its changes. + // System.out.println("CR is pressed"); + setReturnCode(OK); + if (sanityCheck() == false) { + System.out.println("sanity check failed"); + return; + } + applyChange(); + } + + @Override + protected Control createDialogArea(Composite parent) { + Composite top; + top = (Composite) super.createDialogArea(parent); + // Create the main layout for the shell. + GridLayout mainLayout = new GridLayout(1, false); + mainLayout.marginHeight = 3; + mainLayout.marginWidth = 3; + top.setLayout(mainLayout); + + btnGp = new Group(top, SWT.SHADOW_ETCHED_IN); + btnGp.setText("number of page per display"); + if (paneConfigurationName.equals(NsharpConstants.PANE_LITE_D2D_CFG_STR)) // d2dlite + btnGp.setVisible(false); + + Button oneBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); + oneBtn.setText("1"); + oneBtn.setEnabled(true); + oneBtn.setBounds(btnGp.getBounds().x + NsharpConstants.btnGapX, + btnGp.getBounds().y + NsharpConstants.labelGap, + NsharpConstants.btnWidth, NsharpConstants.btnHeight); + // oneBtn.setFont(newFont); + oneBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + numberPagePerDisplay = 1; + // System.out.println("new obvSnd dialog uair btn"); + } + }); + + Button twoBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); + twoBtn.setText("2"); + twoBtn.setEnabled(true); + twoBtn.setBounds(btnGp.getBounds().x + NsharpConstants.btnGapX, + oneBtn.getBounds().y + oneBtn.getBounds().height + + NsharpConstants.btnGapY, NsharpConstants.btnWidth, + NsharpConstants.btnHeight); + // twoBtn.setFont(newFont); + twoBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + numberPagePerDisplay = 2; + } + }); + if (numberPagePerDisplay == 1) + oneBtn.setSelection(true); + else + twoBtn.setSelection(true); + Group configGp = new Group(top, SWT.SHADOW_ETCHED_IN + | SWT.NO_RADIO_GROUP); + Label nameLbl = new Label(configGp, SWT.BORDER); + nameLbl.setText(" Page Name"); + nameLbl.setBounds(configGp.getBounds().x, configGp.getBounds().y, + lblWidth, lblHeight); + Label curOrderLbl = new Label(configGp, SWT.BORDER); + curOrderLbl.setText("Current"); + curOrderLbl.setBounds( + nameLbl.getBounds().x + nameLbl.getBounds().width, + nameLbl.getBounds().y, textWidth, lblHeight); + Label newOrderLbl = new Label(configGp, SWT.BORDER); + // newOrderLbl.setText(Integer.toString(summary1Page)); + newOrderLbl.setBounds( + curOrderLbl.getBounds().x + curOrderLbl.getBounds().width, + nameLbl.getBounds().y, textWidth, lblHeight); + newOrderLbl.setText("New Order"); + Label prevLbl = nameLbl; + Label pageLbl; + for (int i = 1; i <= NsharpConstants.PAGE_MAX_NUMBER; i++) { + pageLbl = pageNameLblArray[i] = new Label(configGp, SWT.BORDER); + pageLbl.setText(NsharpConstants.PAGE_NAME_ARRAY[i]); + pageLbl.setBounds(configGp.getBounds().x, prevLbl.getBounds().y + + lblHeight, lblWidth, lblHeight); + curLbl = curOrderLblArray[i] = new Label(configGp, SWT.BORDER); + curLbl.setText(Integer.toString(pageOrderNumberArray[i])); + curLbl.setBounds(pageLbl.getBounds().x + pageLbl.getBounds().width, + pageLbl.getBounds().y, textWidth, lblHeight); + newText = newOrderTextArray[i] = new Text(configGp, SWT.BORDER + | SWT.SINGLE); + newText.setBounds(curLbl.getBounds().x + curLbl.getBounds().width, + pageLbl.getBounds().y, textWidth, lblHeight); + newText.setEditable(true); + newText.setText(Integer.toString(pageOrderNumberArray[i])); + // to make sure user enter digits only + newText.addListener(SWT.Verify, new EditListener(newText)); + prevLbl = pageLbl; + } + return top; + } + + public class EditListener implements Listener { + Text newOrderText; + + public void handleEvent(Event e) { + String string = e.text; + char[] chars = new char[string.length()]; + string.getChars(0, chars.length, chars, 0); + // System.out.println("entered s="+ string); + // Chin note: when "Delete", "Backspace" entered, this handler will + // be called, but + // its chars.length = 0 + if (chars.length == 1 && newOrderText != null) { + if (chars[0] == '-') { + // if "-" is not first char + String textStr = newOrderText.getText(); + if ((textStr != null) && (textStr.length() >= 1) + && (textStr.contains("-"))) { + e.doit = false; + return; + } + } else if (!('0' <= chars[0] && chars[0] <= '9')) { + e.doit = false; + return; + } + + } + } + + public EditListener(Text newOrderText) { + super(); + this.newOrderText = newOrderText; + } + + } - public EditListener(Text newOrderText) { - super(); - this.newOrderText = newOrderText; - } - - } - } diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpGpdObsSoundingDialogContents.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpGpdObsSoundingDialogContents.java new file mode 100644 index 0000000000..ba66c1d342 --- /dev/null +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpGpdObsSoundingDialogContents.java @@ -0,0 +1,420 @@ +/** + * + * gov.noaa.nws.ncep.ui.nsharp.view.GpdProductDialogContents + * + * This java class performs the NSHARP NsharpLoadDialog functions. + * This code has been developed by the NCEP-SIB for use in the AWIPS2 system. + * + *
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    	Engineer    Description
+ * -------		------- 	-------- 	-----------
+ * 08/2013	    			Chin Chen	Initial coding
+ *
+ * 
+ * + * @author Chin Chen + * @version 1.0 + */ +package gov.noaa.nws.ncep.ui.nsharp.view; + +import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingStnInfo; +import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingStnInfoCollection; +import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingTimeLines; +import gov.noaa.nws.ncep.ui.nsharp.NsharpConstants; +import gov.noaa.nws.ncep.ui.nsharp.NsharpStationInfo; +import gov.noaa.nws.ncep.ui.nsharp.display.map.NsharpMapResource; +import gov.noaa.nws.ncep.viz.common.soundingQuery.NcSoundingQuery; + +import java.sql.Timestamp; +import java.text.DateFormatSymbols; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.List; +import java.util.TimeZone; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Listener; + +// import gov.noaa.nws.ncep.viz.rsc.gpd.query.GpdQuery; + +public class NsharpGpdObsSoundingDialogContents { + private Composite parent; + + private org.eclipse.swt.widgets.List sndTimeList = null, prodList = null; + + // private Text newProdNameText, curProdNameText; + private Group sndTimeListGp, topGp, prodGp; + + private boolean timeLimit = false; + + // private boolean rawData = false; + private Button timeBtn; + + // private String FILE_DROP = "DROP"; + private String currentProdName = ""; + + private NsharpLoadDialog ldDia; + + // private Label curProdLbl, newProdLbl; + private ArrayList selectedTimeList = new ArrayList(); + + private Font newFont; + + private String[] sel = new String[1]; + + public String getCurrentProdName() { + return currentProdName; + } + + public void setCurrentProdName(String currentProdName) { + this.currentProdName = currentProdName; + } + + public NsharpGpdObsSoundingDialogContents(Composite parent) { + this.parent = parent; + ldDia = NsharpLoadDialog.getAccess(); + newFont = ldDia.getNewFont(); + } + + private void createProdList() { + if (prodList != null) + prodList.removeAll(); + if (sndTimeList != null) + sndTimeList.removeAll(); + ldDia.startWaitCursor(); + List prodStrLst = null; + // TBDGPD List prodStrLst = GpdQuery + // .getGpdAvailProducts(GenericPointDataReqType.GET_GPD_AVAILABLE_OBSERVED_SOUNDING_PRODUCTS); + if (prodList != null) { + for (String prod : prodStrLst) + prodList.add(prod); + } + ldDia.stopWaitCursor(); + } + + private void createSndList() { + /* + * /testing List prodList = + * GpdQuery.getGpdAvailProducts(GenericPointDataReqType + * .GET_GPD_AVAILABLE_SURFACE_PRODUCTS); if(prodList != null && + * prodList.size() > 0){ for(String prod: prodList) + * System.out.println("GPD product = "+ prod); } //edn testing + */ + if (currentProdName.equals("") == true) + return; + if (sndTimeList != null) + sndTimeList.removeAll(); + + // use NcSoundingQuery to query + ldDia.startWaitCursor(); + NcSoundingTimeLines timeLines = null; + // TBDGPD NcSoundingTimeLines timeLines = + // GpdQuery.getGpdSoundingTimeLines(currentProdName); + + if (timeLines != null && timeLines.getTimeLines() != null) { + DateFormatSymbols dfs = new DateFormatSymbols(); + String[] defaultDays = dfs.getShortWeekdays(); + Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + + for (Object timeLine : timeLines.getTimeLines()) { + Timestamp synoptictime = (Timestamp) timeLine; + if (synoptictime != null) { + // need to format synoptictime to GMT time string. + // Timestamp.toString produce a local time Not GMT time + cal.setTimeInMillis(synoptictime.getTime()); + String dayOfWeek = defaultDays[cal + .get(Calendar.DAY_OF_WEEK)]; + // String gmtTimeStr = + // String.format("%1$ty%1$tm%1$td/%1$tH%1$tM %2$s", cal, + // currentSndType.toString()); + String gmtTimeStr = String.format( + "%1$ty%1$tm%1$td/%1$tH(%3$s) %2$s", cal, + currentProdName.toString(), dayOfWeek); + if (!timeLimit) { + // System.out.println("not 00z and 12z only"); + sndTimeList.add(gmtTimeStr); + } else { + int hour = cal.get(Calendar.HOUR_OF_DAY); + // System.out.println("00z and 12z only hour = "+ hour); + if ((hour == 0) || (hour == 12)) + sndTimeList.add(gmtTimeStr); + } + } + } + } else + System.out.println("EDEX timeline query return null"); + + ldDia.stopWaitCursor(); + + } + + private void queryAndMarkStn(String selectedSndTime) { + String selectTimetr = NcSoundingQuery + .convertSoundTimeDispStringToRangeStartTimeFormat(selectedSndTime); + NsharpMapResource nsharpMapResource = NsharpMapResource + .getOrCreateNsharpMapResource(); + double lat, lon; + String stnInfoStr; + + // use NcSoundingQuery to query stn info + + // TBDGPD NcSoundingStnInfoCollection sndStnInfoCol = + // GpdQuery.getGpdStationInfoCollection(currentProdName, selectTimetr); + NcSoundingStnInfoCollection sndStnInfoCol = null; + if (sndStnInfoCol != null && sndStnInfoCol.getStationInfo() != null) { + + NcSoundingStnInfo[] stnInfoAry = sndStnInfoCol.getStationInfo(); + // System.out.println("gpdobs station number = " + + // stnInfoAry.length); + // Note: A same station may have many reports + for (int i = 0; i < stnInfoAry.length; i++) { + NcSoundingStnInfo stnInfo = stnInfoAry[i]; + Timestamp synoptictime = null; + stnInfoStr = stnInfo.getStnId(); + if (stnInfoStr == null || stnInfoStr.length() < 1) + stnInfoStr = "*"; + lat = stnInfo.getStationLatitude(); + lon = stnInfo.getStationLongitude(); + // elv = stnInfo.getStationElevation(); + synoptictime = (Timestamp) stnInfo.getSynopTime(); + + // convert to Nsharp's own station info struct + NsharpStationInfo stn = new NsharpStationInfo(); + String packedStnInfoStr = stnInfoStr.replace(" ", "_"); + int endIndex = Math.min( + NsharpConstants.MAX_SOUNDING_SOURCE_STR_LENGTH, + currentProdName.length()); + stn.setStnDisplayInfo(packedStnInfoStr + " " + selectedSndTime + + " " + currentProdName.substring(0, endIndex)); + stn.setLongitude(lon); + stn.setLatitude(lat); + stn.setStnId(stnInfoStr); + stn.setReftime(synoptictime); + stn.setRangestarttime(synoptictime); + stn.setSndType(currentProdName.toString()); + // System.out.println("sndType= "+currentSndType); + // System.out.println("stn lat ="+stn.getLatitude() + + // " lon="+stn.getLongitude()); + nsharpMapResource.addPoint(stn); + } + + NsharpMapResource.bringMapEditorToTop(); + } + } + + private void handleSndTimeSelection() { + String selectedSndTime = null; + if (sndTimeList.getSelectionCount() > 0) { + NsharpMapResource nsharpMapResource = NsharpMapResource + .getOrCreateNsharpMapResource();// NsharpLoadDialog.getAccess().getNsharpMapResource(); + nsharpMapResource.setPoints(null); + selectedTimeList.clear(); + ldDia.startWaitCursor(); + for (int i = 0; i < sndTimeList.getSelectionCount(); i++) { + selectedSndTime = sndTimeList.getSelection()[i]; + selectedTimeList.add(selectedSndTime); + // System.out.println("selected sounding time is " + + // selectedSndTime); + int endIndex = selectedSndTime.indexOf(" "); + String queryingSndTime = selectedSndTime.substring(0, endIndex); + queryAndMarkStn(queryingSndTime); + + } + ldDia.setGpdSelectedTimeList(selectedTimeList); + ldDia.stopWaitCursor(); + } + } + + public void createGpdObsDialogContents() { + currentProdName = ldDia.getActiveGpdProdName(); + + // System.out.println("createGpdDialogContents"); + // timeLimit =false; + // rawData = false; + topGp = new Group(parent, SWT.SHADOW_ETCHED_IN); + topGp.setLayout(new GridLayout(2, false)); + ldDia.createSndTypeList(topGp); + /* + * prodNameGp = new Group(topGp, SWT.SHADOW_ETCHED_IN); + * prodNameGp.setLayout( new GridLayout( 2, true ) ); + * prodNameGp.setText("Product Name"); prodNameGp.setFont(newFont); + * curProdLbl = new Label(prodNameGp, SWT.NONE | SWT.BORDER); + * //curProdLbl.setBounds(prodNameGp.getBounds().x, + * prodNameGp.getBounds().y + NsharpConstants.btnGapY, + * prodNameGp.getBounds().width/2,NsharpConstants.btnHeight); + * curProdLbl.setText("Current Product:"); curProdLbl.setFont(newFont); + * curProdNameText = new Text(prodNameGp, SWT.NONE ); + * //curProdNameText.setBounds + * (curProdLbl.getBounds().x+curProdLbl.getBounds().width, + * prodNameGp.getBounds().y + NsharpConstants.btnGapY, + * prodNameGp.getBounds().width/2,NsharpConstants.btnHeight); + * curProdNameText.setText(currentProdName); + * curProdNameText.setFont(newFont); curProdNameText.setTextLimit(20); + * curProdNameText.setEditable(false); Color color = new + * Color(Display.getDefault(), NsharpConstants.backgroundColor); + * curProdNameText.setBackground(color); newProdLbl = new + * Label(prodNameGp, SWT.NONE | SWT.BORDER); + * //curProdLbl.setBounds(prodNameGp.getBounds().x, + * prodNameGp.getBounds().y + NsharpConstants.btnGapY, + * prodNameGp.getBounds().width/2,NsharpConstants.btnHeight); + * newProdLbl.setText("New Product:"); newProdLbl.setFont(newFont); + * + * newProdNameText = new Text(prodNameGp, SWT.BORDER | SWT.SINGLE); + * //GridData data1 = new GridData (SWT.FILL,SWT.FILL, true, true); + * //prodNameText.setLayoutData (data1); + * //prodNameText.setBounds(stationBtn.getBounds().x, + * locationLbl.getBounds().y,450,NsharpConstants.btnHeight); + * newProdNameText.setTextLimit(20); newProdNameText.setFont(newFont); + * //prodNameText.addListener (SWT.Verify, new Listener () { //public + * void handleEvent (Event e) { //String userInputStr = e.text; // + * System.out.println(userInputStr); //} //}); Button setBtn = new + * Button(prodNameGp, SWT.PUSH); setBtn.setText("Set Product Name"); + * setBtn.setFont(newFont); setBtn.setEnabled( true ); + * setBtn.setBounds(prodNameGp.getBounds().x+ NsharpConstants.btnGapX, + * curProdLbl.getBounds().y + curProdLbl.getBounds().height+ + * NsharpConstants.btnGapY, + * NsharpConstants.btnWidth,NsharpConstants.btnHeight); + * setBtn.addListener( SWT.MouseUp, new Listener() { public void + * handleEvent(Event event) { String textStr = + * newProdNameText.getText(); if((textStr != null) && + * !(textStr.isEmpty())){ //textStr = textStr.trim(); currentProdName = + * textStr; currentProdName = currentProdName.trim(); + * //System.out.println(currentProdName); + * curProdNameText.setText(currentProdName); curProdNameText.redraw(); + * createSndList(); ldDia.setActiveGpdProdName(currentProdName); } } } + * ); + */ + prodGp = new Group(topGp, SWT.SHADOW_ETCHED_IN); + prodGp.setText("Gpd Observed Sounding List"); + prodGp.setFont(newFont); + prodList = new org.eclipse.swt.widgets.List(prodGp, SWT.BORDER + | SWT.V_SCROLL); + prodList.setBounds(prodGp.getBounds().x, prodGp.getBounds().y + + NsharpConstants.labelGap, NsharpConstants.filelistWidth, + NsharpConstants.listHeight); + // query to get and add available sounding models from DB + prodList.setFont(newFont); + createProdList(); + + // create a selection listener to handle user's selection on list + prodList.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event e) { + if (prodList.getSelectionCount() > 0) { + currentProdName = prodList.getSelection()[0]; + ldDia.setActiveGpdProdName(currentProdName); + createSndList(); + } + } + }); + + timeBtn = new Button(topGp, SWT.CHECK | SWT.BORDER); + timeBtn.setText("00Z and 12Z only"); + timeBtn.setEnabled(true); + timeBtn.setFont(newFont); + timeBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (timeLimit) + timeLimit = false; + else + timeLimit = true; + + // refresh sounding list if file type is selected already + if (sndTimeList != null && currentProdName.equals("") == false) { + createSndList(); + } + + } + }); + // create file widget list + sndTimeListGp = new Group(parent, SWT.SHADOW_ETCHED_IN); + sndTimeListGp.setText("Sounding Times:"); + sndTimeListGp.setFont(newFont); + sndTimeList = new org.eclipse.swt.widgets.List(sndTimeListGp, + SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); + sndTimeList.setBounds(sndTimeListGp.getBounds().x + + NsharpConstants.btnGapX, sndTimeListGp.getBounds().y + + NsharpConstants.labelGap, NsharpConstants.listWidth, + NsharpConstants.listHeight * 7); + sndTimeList.setFont(newFont); + + // create a selection listener to handle user's selection on list + sndTimeList.addListener(SWT.Selection, new Listener() { + // private String selectedSndTime=null; + public void handleEvent(Event e) { + handleSndTimeSelection(); + } + }); + + if (currentProdName.equals("") == false) { + sel[0] = currentProdName; + prodList.setSelection(sel); + createSndList(); + selectedTimeList = ldDia.getGpdSelectedTimeList(); + Object[] selTimeObjectArray = selectedTimeList.toArray(); + String[] selTimeStringArray = Arrays.copyOf(selTimeObjectArray, + selTimeObjectArray.length, String[].class); + sndTimeList.setSelection(selTimeStringArray); + handleSndTimeSelection(); + } + } + + public void cleanup() { + if (sndTimeList != null) { + sndTimeList.removeListener(SWT.Selection, + sndTimeList.getListeners(SWT.Selection)[0]); + sndTimeList.dispose(); + sndTimeList = null; + } + if (sndTimeListGp != null) { + sndTimeListGp.dispose(); + sndTimeListGp = null; + } + if (prodList != null) { + if (prodList.getListeners(SWT.Selection).length > 0) + prodList.removeListener(SWT.Selection, + prodList.getListeners(SWT.Selection)[0]); + prodList.dispose(); + prodList = null; + } + + if (prodGp != null) { + prodGp.dispose(); + prodGp = null; + } + + NsharpLoadDialog ldDia = NsharpLoadDialog.getAccess(); + ldDia.cleanSndTypeList(); + if (topGp != null) { + topGp.dispose(); + topGp = null; + } + } + /* + * public static NcSoundingTimeLines gpdSoundingTimeLineQuery (String + * productName){ NcSoundingTimeLines timeLines = null; + * GenericPointDataReqMsg reqMsg = new GenericPointDataReqMsg(); + * reqMsg.setReqType + * (GenericPointDataReqType.GET_GPD_PRODUCT_TIMELINE_OBJECT); + * reqMsg.setProductName(productName); try { Object rslts = + * ThriftClient.sendRequest( reqMsg ); if( (rslts instanceof + * NcSoundingTimeLines) ) { // timeLines = (NcSoundingTimeLines)rslts; } + * else { System.out.println("Request Failed: "); + * + * } } catch (Exception e) { // TODO Auto-generated catch block + * e.printStackTrace(); } + * + * + * return timeLines; + * + * } + */ +} diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpGpdPfcSoundingDialogContents.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpGpdPfcSoundingDialogContents.java new file mode 100644 index 0000000000..36a8f4ef4e --- /dev/null +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpGpdPfcSoundingDialogContents.java @@ -0,0 +1,490 @@ +/** + * + * gov.noaa.nws.ncep.ui.nsharp.view.PfcSoundingDialogContents + * + * This java class performs the NSHARP NsharpLoadDialog functions. + * This code has been developed by the NCEP-SIB for use in the AWIPS2 system. + * + *
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    	Engineer    Description
+ * -------		------- 	-------- 	-----------
+ * 01/2011	229			Chin Chen	Initial coding
+ *
+ * 
+ * + * @author Chin Chen + * @version 1.0 + */ +package gov.noaa.nws.ncep.ui.nsharp.view; + +import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingProfile; +import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingStnInfo; +import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingStnInfoCollection; +import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingTimeLines; +import gov.noaa.nws.ncep.ui.nsharp.NsharpConstants; +import gov.noaa.nws.ncep.ui.nsharp.NsharpStationInfo; +import gov.noaa.nws.ncep.ui.nsharp.display.map.NsharpMapResource; +import gov.noaa.nws.ncep.viz.common.soundingQuery.NcSoundingQuery; + +import java.sql.Timestamp; +import java.text.DateFormatSymbols; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.List; +import java.util.TimeZone; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Listener; +//import gov.noaa.nws.ncep.viz.rsc.gpd.query.GpdQuery; + +public class NsharpGpdPfcSoundingDialogContents { + private Composite parent; + + private org.eclipse.swt.widgets.List prodList, availablefileList, + sndTimeList; + + private Group topGp, prodGp, bottomGp, availableFileGp, sndTimeListGp; + + private Button namBtn, gfsBtn, timeBtn; + + private boolean timeLimit = false; + + private List selectedFileList = new ArrayList(); + + private List selectedTimeList = new ArrayList(); + + private List stnPoints = new ArrayList(); + + private NcSoundingProfile.PfcSndType currentSndType = NcSoundingProfile.PfcSndType.NONE; + + private NsharpLoadDialog ldDia; + + private Font newFont; + + private String currentProdName = ""; + + private String[] sel = new String[1]; + + public NcSoundingProfile.PfcSndType getCurrentSndType() { + return currentSndType; + } + + public NsharpGpdPfcSoundingDialogContents() { + } + + public NsharpGpdPfcSoundingDialogContents(Composite parent) { + this.parent = parent; + ldDia = NsharpLoadDialog.getAccess(); + newFont = ldDia.getNewFont(); + } + + private void createPFCAvailableFileList() { + sndTimeList.removeAll(); + ; + availablefileList.removeAll(); + // query using NcSoundingQuery class to query + NcSoundingTimeLines timeLines = null; + // TBDGPD NcSoundingTimeLines timeLines = + // GpdQuery.getGpdSoundingTimeLines(currentProdName); + if (timeLines != null && timeLines.getTimeLines() != null) { + ldDia.startWaitCursor(); + for (Object timeLine : timeLines.getTimeLines()) { + Timestamp reftime = (Timestamp) timeLine; + if (reftime != null) { + // need to format reftime to GMT time string. + // Timestamp.toString produce a local time Not GMT time + Calendar cal = Calendar.getInstance(TimeZone + .getTimeZone("GMT")); + cal.setTimeInMillis(reftime.getTime()); + String gmtTimeStr = String.format( + "%1$tY-%1$tm-%1$td %1$tH", cal); + // System.out.println("GMT time " + gmtTimeStr); + availablefileList.add(gmtTimeStr); + + } + + } + ldDia.stopWaitCursor(); + } else + System.out.println("SQL: query return null"); + } + + private void createPFCSndTimeList(List selectedFlLst) { + if (selectedFlLst.size() <= 0) + return; + sndTimeList.removeAll(); + ldDia.startWaitCursor(); + String sndStr = currentProdName; + int endIndex = Math.min(3, sndStr.length()); + String dispSndStr = sndStr.substring(0, endIndex); + DateFormatSymbols dfs = new DateFormatSymbols(); + String[] defaultDays = dfs.getShortWeekdays(); + Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + + for (int i = 0; i < selectedFlLst.size(); i++) { + String fl = selectedFlLst.get(i); + long reftimeMs = NcSoundingQuery.convertRefTimeStr(fl); + // System.out.println("reftime="+fl + " in ms="+reftimeMs); + NcSoundingTimeLines timeLines = null; + // TBDGPD NcSoundingTimeLines timeLines = + // GpdQuery.getGpdRangeStartTimes(currentProdName, fl); + if (timeLines != null && timeLines.getTimeLines().length > 0) { + for (Object obj : timeLines.getTimeLines()) { + Timestamp rangestart = (Timestamp) obj; + + // need to format rangestart to GMT time string. + // Timestamp.toString produce a local time Not GMT time + cal.setTimeInMillis(rangestart.getTime()); + long vHour = (cal.getTimeInMillis() - reftimeMs) / 3600000; + String dayOfWeek = defaultDays[cal + .get(Calendar.DAY_OF_WEEK)]; + // String gmtTimeStr = + // String.format("%1$ty%1$tm%1$td/%1$tH%1$tMV%2$03d %3$s", + // cal, vHour,dispSndStr); + String gmtTimeStr = String.format( + "%1$ty%1$tm%1$td/%1$tH(%4$s)V%2$03d %3$s", cal, + vHour, dispSndStr, dayOfWeek); + if (sndTimeList.indexOf(gmtTimeStr) != -1) { + // this indicate that gmtTimeStr is already in the + // sndTimeList, then we dont need to add it to list + // again. + continue; + } + + // System.out.println("GMT time " + gmtTimeStr); + if (!timeLimit) + sndTimeList.add(gmtTimeStr); + else { + int hour = cal.get(Calendar.HOUR_OF_DAY); + if ((hour == 0) || (hour == 12)) + sndTimeList.add(gmtTimeStr); + } + + } + } + } + ldDia.stopWaitCursor(); + } + + private void handleAvailFileListSelection() { + String selectedFile = null; + if (availablefileList.getSelectionCount() > 0) { + selectedFileList.clear(); + for (int i = 0; i < availablefileList.getSelectionCount(); i++) { + selectedFile = availablefileList.getSelection()[i]; + // System.out.println("selected sounding file is " + + // selectedFile); + selectedFileList.add(selectedFile); + } + ldDia.setPfcSelectedFileList(selectedFileList); + createPFCSndTimeList(selectedFileList); + } + } + + private void handleSndTimeSelection() { + String selectedSndTime = null; + if (sndTimeList.getSelectionCount() > 0) { + NsharpMapResource nsharpMapResource = NsharpMapResource + .getOrCreateNsharpMapResource(); + nsharpMapResource.setPoints(null); + selectedTimeList.clear(); + ldDia.startWaitCursor(); + List queriedTimeList = new ArrayList(); + for (int i = 0; i < sndTimeList.getSelectionCount(); i++) { + selectedSndTime = sndTimeList.getSelection()[i]; + selectedTimeList.add(selectedSndTime); + int endIndex = selectedSndTime.indexOf(" "); + String querySndTime = selectedSndTime.substring(0, endIndex); + // System.out.println("selected sounding time is " + + // selectedSndTime); + // refTimeStr is same as "PFC file" name in Load dialog display + String refTimeStr = NcSoundingQuery + .convertSoundTimeDispStringToForecastTime(querySndTime); + // while rangeStartStr is same as "sounding Times + String rangeStartStr = NcSoundingQuery + .convertSoundTimeDispStringToRangeStartTimeFormat(querySndTime); + if (queriedTimeList.contains(refTimeStr) == true) { + // for all range start times of one reference time, they + // should have same stations, therefore, only + // query once, the rest will be just marked. + addStnPtWithoutQuery(refTimeStr, rangeStartStr, + querySndTime); + } else { + queriedTimeList.add(refTimeStr); + queryAndMarkStn(refTimeStr, rangeStartStr, querySndTime); + } + } + + ldDia.stopWaitCursor(); + + nsharpMapResource.setPoints(stnPoints); + NsharpMapResource.bringMapEditorToTop(); + } + } + + private void createProdList() { + if (prodList != null) + prodList.removeAll(); + if (sndTimeList != null) + sndTimeList.removeAll(); + if (availablefileList != null) + availablefileList.removeAll(); + ldDia.startWaitCursor(); + List prodStrLst = null; + // TBDGPD List prodStrLst = + // GpdQuery.getGpdAvailProducts(GenericPointDataReqType.GET_GPD_AVAILABLE_MODEL_SOUNDING_PRODUCTS); + for (String prod : prodStrLst) + prodList.add(prod); + ldDia.stopWaitCursor(); + } + + public void createGpdPfcDialogContents() { + topGp = new Group(parent, SWT.SHADOW_ETCHED_IN); + topGp.setLayout(new GridLayout(2, false)); + + currentSndType = ldDia.getActivePfcSndType(); + ldDia.createSndTypeList(topGp); + + prodGp = new Group(topGp, SWT.SHADOW_ETCHED_IN); + prodGp.setText("Gpd Pfc Sounding List"); + prodGp.setFont(newFont); + prodList = new org.eclipse.swt.widgets.List(prodGp, SWT.BORDER + | SWT.V_SCROLL); + prodList.setBounds(prodGp.getBounds().x, prodGp.getBounds().y + + NsharpConstants.labelGap, NsharpConstants.filelistWidth, + NsharpConstants.listHeight); + // query to get and add available sounding models from DB + prodList.setFont(newFont); + createProdList(); + + // create a selection listener to handle user's selection on list + prodList.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event e) { + if (prodList.getSelectionCount() > 0) { + currentProdName = prodList.getSelection()[0]; + ldDia.setActiveGpdProdName(currentProdName); + createPFCAvailableFileList(); + } + } + }); + timeBtn = new Button(parent, SWT.CHECK | SWT.BORDER); + timeBtn.setText("00Z and 12Z only"); + timeBtn.setEnabled(true); + // timeBtn.setBounds(fileTypeGp.getBounds().x+ NsharpConstants.btnGapX, + // browseBtn.getBounds().y + browseBtn.getBounds().height+ + // NsharpConstants.btnGapY, + // NsharpConstants.btnWidth,NsharpConstants.btnHeight); + timeBtn.setFont(newFont); + timeBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (timeLimit) + timeLimit = false; + else + timeLimit = true; + + // refresh sounding list if file type is selected already + if (!currentSndType.equals("NA") && selectedFileList.size() > 0) { + createPFCSndTimeList(selectedFileList); + } + + } + }); + + bottomGp = new Group(parent, SWT.SHADOW_ETCHED_IN); + bottomGp.setLayout(new GridLayout(2, false)); + + availableFileGp = new Group(bottomGp, SWT.SHADOW_ETCHED_IN); + availableFileGp.setText("Available PFC files:"); + availableFileGp.setFont(newFont); + availablefileList = new org.eclipse.swt.widgets.List(availableFileGp, + SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); + availablefileList.setBounds(availableFileGp.getBounds().x, + availableFileGp.getBounds().y + NsharpConstants.labelGap, + NsharpConstants.filelistWidth, + NsharpConstants.listHeight * 36 / 5); + // create a selection listener to handle user's selection on list + availablefileList.setFont(newFont); + availablefileList.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event e) { + handleAvailFileListSelection(); + } + }); + + // create Sounding Times widget list + sndTimeListGp = new Group(bottomGp, SWT.SHADOW_ETCHED_IN); + sndTimeListGp.setText("Sounding Times:"); + sndTimeListGp.setFont(newFont); + sndTimeList = new org.eclipse.swt.widgets.List(sndTimeListGp, + SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); + sndTimeList.removeAll(); + sndTimeList.setFont(newFont); + sndTimeList.setBounds(sndTimeListGp.getBounds().x, + sndTimeListGp.getBounds().y + NsharpConstants.labelGap, + NsharpConstants.listWidth, NsharpConstants.listHeight * 36 / 5); + sndTimeList.addListener(SWT.Selection, new Listener() { + // private String selectedSndTime=null; + public void handleEvent(Event e) { + handleSndTimeSelection(); + } + + }); + if (currentProdName.equals("") == false) { + sel[0] = currentProdName; + prodList.setSelection(sel); + createPFCAvailableFileList(); + selectedFileList = ldDia.getPfcSelectedFileList(); + Object[] selFileObjectArray = selectedFileList.toArray(); + String[] selFileStringArray = Arrays.copyOf(selFileObjectArray, + selFileObjectArray.length, String[].class); + availablefileList.setSelection(selFileStringArray); + handleAvailFileListSelection(); + selectedTimeList = ldDia.getPfcSelectedTimeList(); + Object[] selTimeObjectArray = selectedTimeList.toArray(); + String[] selTimeStringArray = Arrays.copyOf(selTimeObjectArray, + selTimeObjectArray.length, String[].class); + sndTimeList.setSelection(selTimeStringArray); + handleSndTimeSelection(); + } + } + + private void addStnPtWithoutQuery(String refTimeStr, String rangeStartStr, + String selectedSndTime) { + long reftimeMs = NcSoundingQuery.convertRefTimeStr(refTimeStr); + Timestamp refTime = new Timestamp(reftimeMs); + for (NsharpStationInfo stn : stnPoints) { + if (refTime.equals(stn.getReftime()) == true) { + long rangetimeMs = NcSoundingQuery + .convertRefTimeStr(rangeStartStr); + Timestamp rangeStartTime = new Timestamp(rangetimeMs); + NsharpStationInfo.timeLineSpecific timeLinsSpc = stn.new timeLineSpecific(); + String sndTypeStr = currentProdName; + int endIndex = Math.min( + NsharpConstants.MAX_SOUNDING_SOURCE_STR_LENGTH, + sndTypeStr.length()); + String dispInfo = stn.getStnId() + " " + selectedSndTime + " " + + sndTypeStr.substring(0, endIndex); + timeLinsSpc.setDisplayInfo(dispInfo); + timeLinsSpc.setTiemLine(rangeStartTime); + stn.addToTimeLineSpList(timeLinsSpc); + } + } + // System.out.println("addStnPtWithoutQuery stn num ="+ + // stnPoints.size()+ " for pfc refTime(file) "+refTimeStr); + } + + private void queryAndMarkStn(String refTimeStr, String rangeStartStr, + String selectedSndTime) { + // use NcSoundingQuery to query stn info + String sndTypeStr = currentProdName; + NcSoundingStnInfoCollection sndStnInfoCol = null; + // TBDGPD NcSoundingStnInfoCollection sndStnInfoCol + // =GpdQuery.getGpdStationInfoCollection(currentProdName,refTimeStr,rangeStartStr); + if (sndStnInfoCol != null && sndStnInfoCol.getStationInfo() != null) { + + NcSoundingStnInfo[] stnInfoAry = sndStnInfoCol.getStationInfo(); + System.out.println("gpdpfc station number = " + stnInfoAry.length); + // System.out.println("queryAndMarkStn stn num ="+ + // stnInfoAry.length+ " for pfc refTime(file) "+refTimeStr); + for (int i = 0; i < stnInfoAry.length; i++) { + NcSoundingStnInfo stnInfo = stnInfoAry[i]; + NsharpStationInfo stn = new NsharpStationInfo(); + NsharpStationInfo.timeLineSpecific timeLinsSpc = stn.new timeLineSpecific(); + + int endIndex = Math.min( + NsharpConstants.MAX_SOUNDING_SOURCE_STR_LENGTH, + sndTypeStr.length()); + String packedStnIdStr = stnInfo.getStnId().replace(" ", "_"); + String dispInfo = packedStnIdStr + " " + selectedSndTime + " " + + sndTypeStr.substring(0, endIndex); + timeLinsSpc.setDisplayInfo(dispInfo); + timeLinsSpc.setTiemLine(stnInfo.getRangeStartTime()); + stn.addToTimeLineSpList(timeLinsSpc); + stn.setLongitude(stnInfo.getStationLongitude()); + stn.setLatitude(stnInfo.getStationLatitude()); + stn.setReftime(stnInfo.getSynopTime()); + stn.setStnId(stnInfo.getStnId()); + stn.setSndType(sndTypeStr); + // if(i <10) + // System.out.println( + // "disP="+dispInfo+" refT= "+stnInfo.getSynopTime()+ + // " rangSt="+stnInfo.getRangeStartTime()); + stnPoints.add(stn); + } + + } + } + + public void cleanup() { + if (namBtn != null && namBtn.isDisposed() == false) { + namBtn.removeListener(SWT.MouseUp, + namBtn.getListeners(SWT.MouseUp)[0]); + namBtn.dispose(); + namBtn = null; + } + if (gfsBtn != null) { + gfsBtn.removeListener(SWT.MouseUp, + gfsBtn.getListeners(SWT.MouseUp)[0]); + gfsBtn.dispose(); + gfsBtn = null; + } + NsharpLoadDialog ldDia = NsharpLoadDialog.getAccess(); + ldDia.cleanSndTypeList(); + if (prodList != null) { + if (prodList.getListeners(SWT.Selection).length > 0) + prodList.removeListener(SWT.Selection, + prodList.getListeners(SWT.Selection)[0]); + prodList.dispose(); + prodList = null; + } + if (prodGp != null) { + prodGp.dispose(); + prodGp = null; + } + if (topGp != null) { + topGp.dispose(); + topGp = null; + } + + if (timeBtn != null) { + timeBtn.removeListener(SWT.MouseUp, + timeBtn.getListeners(SWT.MouseUp)[0]); + timeBtn.dispose(); + timeBtn = null; + } + + if (availablefileList != null) { + availablefileList.removeListener(SWT.Selection, + availablefileList.getListeners(SWT.Selection)[0]); + availablefileList.dispose(); + availablefileList = null; + } + + if (availableFileGp != null) { + availableFileGp.dispose(); + availableFileGp = null; + } + if (sndTimeList != null) { + sndTimeList.removeListener(SWT.Selection, + sndTimeList.getListeners(SWT.Selection)[0]); + sndTimeList.dispose(); + sndTimeList = null; + } + if (sndTimeListGp != null) { + sndTimeListGp.dispose(); + sndTimeListGp = null; + } + if (bottomGp != null) { + bottomGp.dispose(); + bottomGp = null; + } + } +} diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpLoadDialog.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpLoadDialog.java index 28663979af..fcbe9c80f6 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpLoadDialog.java +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpLoadDialog.java @@ -19,15 +19,14 @@ */ package gov.noaa.nws.ncep.ui.nsharp.view; - -import java.util.ArrayList; -import java.util.List; - import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingProfile; import gov.noaa.nws.ncep.ui.nsharp.NsharpConstants; import gov.noaa.nws.ncep.ui.nsharp.display.NsharpEditor; import gov.noaa.nws.ncep.ui.nsharp.display.map.NsharpMapResource; +import java.util.ArrayList; +import java.util.List; + import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.swt.SWT; @@ -47,445 +46,551 @@ import org.eclipse.swt.widgets.Text; import com.raytheon.uf.viz.core.exception.VizException; public class NsharpLoadDialog extends Dialog { - - private final static int DIALOG_WIDTH = 350; - private final static int DIALOG_HEIGHT = 920; - - protected Composite top; - private static Composite dialogParent; - private static NsharpLoadDialog INSTANCE = null; - private static Shell shell; - private org.eclipse.swt.widgets.List soundingTypeList; - public static final String[] soundingTypeStringArray = { - "Observed Soundings" , "Model Soundings", "PFC Soundings", "Archive Files","ACARS Soundings" - }; - // define index to loadStringArray - public static final int OBSER_SND = 0; - public static final int MODEL_SND = 1; - public static final int PFC_SND = 2; - public static final int ARCHIVE = 3; - public static final int ACARS_SND = 4; - private ObservedSoundingDialogContents obsDialog; - private PfcSoundingDialogContents pfcDialog; - private ModelSoundingDialogContents mdlDialog; - private Group soundingTypeGp, acarsGp; - private int activeLoadSoundingType; - private NcSoundingProfile.ObsSndType activeObsSndType=NcSoundingProfile.ObsSndType.NCUAIR; - private ArrayList obsSelectedTimeList = new ArrayList(); - private NcSoundingProfile.PfcSndType activePfcSndType=NcSoundingProfile.PfcSndType.NAMSND; - private List pfcSelectedFileList = new ArrayList(); - private List pfcSelectedTimeList = new ArrayList(); - private String activeMdlSndMdlType=""; - private List mdlSelectedFileList = new ArrayList(); - private List mdlSelectedTimeList = new ArrayList(); - private Text text1; - private MessageBox mb; - private Cursor waitCursor=null; - private Font newFont; - - public Font getNewFont() { - return newFont; - } - public ObservedSoundingDialogContents getObsDialog() { - return obsDialog; - } - public PfcSoundingDialogContents getPfcDialog() { - return pfcDialog; - } - public void setAndOpenMb(String msg) { - if (mb != null) { - mb.setMessage(msg); - try { - mb.open(); - }catch (Exception e) { - mb = new MessageBox(shell, SWT.ICON_WARNING - | SWT.OK); - mb.setMessage(msg); - mb.open(); - //e.printStackTrace(); - } - } - } - public ModelSoundingDialogContents getMdlDialog() { - return mdlDialog; - } - public void createSndTypeList(Group TopLoadGp) { - soundingTypeGp = new Group(TopLoadGp,SWT.SHADOW_ETCHED_IN); - soundingTypeGp.setText("Sounding Type"); - soundingTypeGp.setFont(newFont); - soundingTypeList = new org.eclipse.swt.widgets.List(soundingTypeGp, SWT.SINGLE | SWT.V_SCROLL ); - soundingTypeList.setBounds(soundingTypeGp.getBounds().x + NsharpConstants.btnGapX, soundingTypeGp.getBounds().y +NsharpConstants.labelGap, NsharpConstants.filelistWidth, NsharpConstants.listHeight); + + private final static int DIALOG_WIDTH = 350; + + private final static int DIALOG_HEIGHT = 920; + + protected Composite top; + + private static Composite dialogParent; + + private static NsharpLoadDialog INSTANCE = null; + + private static Shell shell; + + private org.eclipse.swt.widgets.List soundingTypeList; + + public static final String[] soundingTypeStringArray = { + "Observed Soundings", "Model Soundings", "PFC Soundings",/* + * TBDGPD + * "GPD Observed" + * , + * "GPD PFC" + * , + */ + "Archive Files" }; + + // define index to loadStringArray + public static final int OBSER_SND = 0; + + public static final int MODEL_SND = 1; + + public static final int PFC_SND = 2; + + // TBDGPD public static final int GPD_OBS_SND = 3; + // TBDGPDpublic static final int GPD_PFC_SND = 4; + public static final int ARCHIVE = 3; // TBDGPD 5; + + private NsharpObservedSoundingDialogContents obsDialog; + + private NsharpPfcSoundingDialogContents pfcDialog; + + // TBDGPD private NsharpGpdPfcSoundingDialogContents gpdPfcDialog; + // TBDGPD private NsharpGpdObsSoundingDialogContents gpdObsDialog; + private NsharpModelSoundingDialogContents mdlDialog; + + private Group soundingTypeGp; + + private int activeLoadSoundingType; + + private NcSoundingProfile.ObsSndType activeObsSndType = NcSoundingProfile.ObsSndType.NCUAIR; + + private ArrayList obsSelectedTimeList = new ArrayList(); + + private String activeGpdProdName = ""; + + private ArrayList gpdSelectedTimeList = new ArrayList(); + + private NcSoundingProfile.PfcSndType activePfcSndType = NcSoundingProfile.PfcSndType.NAMSND; + + private List pfcSelectedFileList = new ArrayList(); + + private List pfcSelectedTimeList = new ArrayList(); + + private String activeMdlSndMdlType = ""; + + private List mdlSelectedFileList = new ArrayList(); + + private List mdlSelectedTimeList = new ArrayList(); + + private Text text1; + + private MessageBox mb; + + private Cursor waitCursor = null; + + private Font newFont; + + public Font getNewFont() { + return newFont; + } + + public NsharpObservedSoundingDialogContents getObsDialog() { + return obsDialog; + } + + public NsharpPfcSoundingDialogContents getPfcDialog() { + return pfcDialog; + } + + // TBDGPD + // public NsharpGpdObsSoundingDialogContents getGpdDialog() { + // return gpdObsDialog; + // } + public void setAndOpenMb(String msg) { + if (mb != null) { + mb.setMessage(msg); + try { + mb.open(); + } catch (Exception e) { + mb = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK); + mb.setMessage(msg); + mb.open(); + // e.printStackTrace(); + } + } + } + + public NsharpModelSoundingDialogContents getMdlDialog() { + return mdlDialog; + } + + public void createSndTypeList(Group TopLoadGp) { + soundingTypeGp = new Group(TopLoadGp, SWT.SHADOW_ETCHED_IN); + soundingTypeGp.setText("Sounding Type"); + soundingTypeGp.setFont(newFont); + soundingTypeList = new org.eclipse.swt.widgets.List(soundingTypeGp, + SWT.SINGLE | SWT.V_SCROLL); + soundingTypeList.setBounds(soundingTypeGp.getBounds().x + + NsharpConstants.btnGapX, soundingTypeGp.getBounds().y + + NsharpConstants.labelGap, NsharpConstants.filelistWidth, + NsharpConstants.filelistHeight); soundingTypeList.setFont(newFont); - for(String loadStr : soundingTypeStringArray){ - soundingTypeList.add( loadStr ); - } - //create a selection listener to handle user's selection on list - soundingTypeList.addListener ( SWT.Selection, new Listener () { - private String selectedProduct=null; - public void handleEvent (Event e) { - if (soundingTypeList.getSelectionCount() > 0 ) { + for (String loadStr : soundingTypeStringArray) { + soundingTypeList.add(loadStr); + } + // create a selection listener to handle user's selection on list + soundingTypeList.addListener(SWT.Selection, new Listener() { + private String selectedProduct = null; - selectedProduct = soundingTypeList.getSelection()[0]; - NsharpMapResource nsharpMapResource = NsharpMapResource.getOrCreateNsharpMapResource();//NsharpLoadDialog.getAccess().getNsharpMapResource(); - nsharpMapResource.setPoints(null); - NsharpEditor editor = NsharpEditor.getActiveNsharpEditor(); - if(editor!=null) - editor.refresh(); - //shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); + public void handleEvent(Event e) { + if (soundingTypeList.getSelectionCount() > 0) { + selectedProduct = soundingTypeList.getSelection()[0]; + NsharpMapResource nsharpMapResource = NsharpMapResource + .getOrCreateNsharpMapResource();// NsharpLoadDialog.getAccess().getNsharpMapResource(); + nsharpMapResource.setPoints(null); + NsharpMapResource.getMapEditor().refresh(); + NsharpEditor editor = NsharpEditor.getActiveNsharpEditor(); + if (editor != null) + editor.refresh(); + // shell = + // PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); - if(selectedProduct.equals(soundingTypeStringArray[OBSER_SND])){ - //System.out.println("OBSER_SND enter"); - - if(activeLoadSoundingType != OBSER_SND){ - cleanupDialog(activeLoadSoundingType); //clean up before resetting activeLoadType - activeLoadSoundingType = OBSER_SND; - obsDialog.createObsvdDialogContents(); - //shell.setSize(DIALOG_WIDTH, DIALOG_HEIGHT); - dialogParent.pack(); - dialogParent.layout(true); - dialogParent.redraw(); - soundingTypeList.setSelection(OBSER_SND); - } - } - else if(selectedProduct.equals(soundingTypeStringArray[MODEL_SND])){ - //System.out.println("MODEL_SND enter"); - if(activeLoadSoundingType != MODEL_SND) { - cleanupDialog(activeLoadSoundingType);//clean up before resetting activeLoadType - activeLoadSoundingType = MODEL_SND; - mdlDialog.createMdlDialogContents(); - dialogParent.pack(); - dialogParent.layout(true); - dialogParent.redraw(); - soundingTypeList.setSelection(MODEL_SND); - - } - } - else if(selectedProduct.equals(soundingTypeStringArray[PFC_SND])){ - //System.out.println("PFC_SND enter"); - if(activeLoadSoundingType != PFC_SND){ - cleanupDialog(activeLoadSoundingType); //clean up before resetting activeLoadType - activeLoadSoundingType = PFC_SND; - pfcDialog.createPfcDialogContents(); - dialogParent.pack(); - dialogParent.layout(true); - dialogParent.redraw(); - soundingTypeList.setSelection(PFC_SND); - - } + if (selectedProduct + .equals(soundingTypeStringArray[OBSER_SND])) { + // System.out.println("OBSER_SND enter"); - } - else if(selectedProduct.equals(soundingTypeStringArray[ARCHIVE])){ - //System.out.println("ARCHIVE enter"); - - if(activeLoadSoundingType != ARCHIVE) { - cleanupDialog(activeLoadSoundingType);//clean up before resetting activeLoadType - activeLoadSoundingType = ARCHIVE; - NsharpHandleArchiveFile.openArchiveFile(shell); - close(); - } + if (activeLoadSoundingType != OBSER_SND) { + cleanupDialog(activeLoadSoundingType); // clean up + // before + // resetting + // activeLoadType + activeLoadSoundingType = OBSER_SND; + obsDialog.createObsvdDialogContents(); + // shell.setSize(DIALOG_WIDTH, DIALOG_HEIGHT); + dialogParent.pack(); + dialogParent.layout(true); + dialogParent.redraw(); + soundingTypeList.setSelection(OBSER_SND); + } + } else if (selectedProduct + .equals(soundingTypeStringArray[MODEL_SND])) { + // System.out.println("MODEL_SND enter"); + if (activeLoadSoundingType != MODEL_SND) { + cleanupDialog(activeLoadSoundingType);// clean up + // before + // resetting + // activeLoadType + activeLoadSoundingType = MODEL_SND; + mdlDialog.createMdlDialogContents(); + dialogParent.pack(); + dialogParent.layout(true); + dialogParent.redraw(); + soundingTypeList.setSelection(MODEL_SND); - } - else if(selectedProduct.equals(soundingTypeStringArray[ACARS_SND])){ - //System.out.println("ACARS_SND enter"); - if(activeLoadSoundingType != ACARS_SND) { - cleanupDialog(activeLoadSoundingType);//clean up before resetting activeLoadType - activeLoadSoundingType = ACARS_SND; - //setShellSize(false); - acarsGp = new Group(dialogParent,SWT.SHADOW_ETCHED_IN); - acarsGp.setLayout( new GridLayout( 1, false ) ); - createSndTypeList(acarsGp); - text1 = new Text(acarsGp, SWT.MULTI | SWT.BORDER | SWT.WRAP ); - text1.setText("Acars Soundings\nis still under\ndevelopment!"); - dialogParent.pack(); - dialogParent.layout(true); - dialogParent.redraw(); - soundingTypeList.setSelection(ACARS_SND); - - } - } - } - } + } + } else if (selectedProduct + .equals(soundingTypeStringArray[PFC_SND])) { + // System.out.println("PFC_SND enter"); + if (activeLoadSoundingType != PFC_SND) { + cleanupDialog(activeLoadSoundingType); // clean up + // before + // resetting + // activeLoadType + activeLoadSoundingType = PFC_SND; + pfcDialog.createPfcDialogContents(); + dialogParent.pack(); + dialogParent.layout(true); + dialogParent.redraw(); + soundingTypeList.setSelection(PFC_SND); + + } + + } else if (selectedProduct + .equals(soundingTypeStringArray[ARCHIVE])) { + // System.out.println("ARCHIVE enter"); + + if (activeLoadSoundingType != ARCHIVE) { + cleanupDialog(activeLoadSoundingType);// clean up + // before + // resetting + // activeLoadType + activeLoadSoundingType = ARCHIVE; + NsharpHandleArchiveFile.openArchiveFile(shell); + close(); + } + + } + /* + * TBDGPD else + * if(selectedProduct.equals(soundingTypeStringArray + * [GPD_OBS_SND])){ if(activeLoadSoundingType != + * GPD_OBS_SND){ cleanupDialog(activeLoadSoundingType); + * //clean up before resetting activeLoadType + * activeLoadSoundingType = GPD_OBS_SND; + * gpdObsDialog.createGpdObsDialogContents(); + * //shell.setSize(DIALOG_WIDTH, DIALOG_HEIGHT); + * dialogParent.pack(); dialogParent.layout(true); + * dialogParent.redraw(); + * soundingTypeList.setSelection(GPD_OBS_SND); } } else + * if(selectedProduct + * .equals(soundingTypeStringArray[GPD_PFC_SND])){ + * if(activeLoadSoundingType != GPD_PFC_SND){ + * cleanupDialog(activeLoadSoundingType); //clean up before + * resetting activeLoadType activeLoadSoundingType = + * GPD_PFC_SND; gpdPfcDialog.createGpdPfcDialogContents(); + * //shell.setSize(DIALOG_WIDTH, DIALOG_HEIGHT); + * dialogParent.pack(); dialogParent.layout(true); + * dialogParent.redraw(); + * soundingTypeList.setSelection(GPD_PFC_SND); } } + */ + } + } }); - } - public void cleanSndTypeList(){ - if(soundingTypeList!= null){ - soundingTypeList.removeListener(SWT.Selection, soundingTypeList.getListeners(SWT.Selection)[0]); - soundingTypeList.dispose(); - soundingTypeList = null; - } - if(soundingTypeGp!=null){ - soundingTypeGp.dispose(); - soundingTypeGp=null; - } - } - - private void cleanSelf(){ - - if(text1 != null){ - text1.dispose(); - text1 = null; - } - } - - private void cleanupDialog(int activeLoadType){ - switch (activeLoadType) { - case OBSER_SND: - obsDialog.cleanup(); - break; - case MODEL_SND: - mdlDialog.cleanup(); - break; - case PFC_SND: - pfcDialog.cleanup(); - break; - case ACARS_SND: - if(text1 != null){ - text1.dispose(); - text1 = null; - } - if(acarsGp!= null){ - acarsGp.dispose(); - acarsGp = null; - } - break; - case ARCHIVE: - break; - default: - break; - } - - } - - public void setActiveLoadSoundingType(int activeLoadSoundingType) { - this.activeLoadSoundingType = activeLoadSoundingType; - } - public int getActiveLoadSoundingType() { - return activeLoadSoundingType; - } + } - public List getPfcSelectedFileList() { - return pfcSelectedFileList; - } - public void setPfcSelectedFileList(List pfcSelectedFileList) { - this.pfcSelectedFileList = pfcSelectedFileList; - } - public List getPfcSelectedTimeList() { - return pfcSelectedTimeList; - } - public void setPfcSelectedTimeList(List pfcSelectedTimeList) { - this.pfcSelectedTimeList = pfcSelectedTimeList; - } - public ArrayList getObsSelectedTimeList() { - return obsSelectedTimeList; - } - public void setObsSelectedTimeList(ArrayList obsSelectedTimeList) { - this.obsSelectedTimeList = obsSelectedTimeList; - } - public NcSoundingProfile.ObsSndType getActiveObsSndType() { - return activeObsSndType; - } - public void setActiveObsSndType(NcSoundingProfile.ObsSndType activeObsSndType) { - this.activeObsSndType = activeObsSndType; - } - public NcSoundingProfile.PfcSndType getActivePfcSndType() { - return activePfcSndType; - } - public void setActivePfcSndType(NcSoundingProfile.PfcSndType activePfcSndType) { - this.activePfcSndType = activePfcSndType; - } - public String getActiveMdlSndMdlType() { - return activeMdlSndMdlType; - } - public void setActiveMdlSndMdlType(String activeMdlSndMdlType) { - this.activeMdlSndMdlType = activeMdlSndMdlType; - } + public void cleanSndTypeList() { + if (soundingTypeList != null) { + soundingTypeList.removeListener(SWT.Selection, + soundingTypeList.getListeners(SWT.Selection)[0]); + soundingTypeList.dispose(); + soundingTypeList = null; + } + if (soundingTypeGp != null) { + soundingTypeGp.dispose(); + soundingTypeGp = null; + } + } - public List getMdlSelectedFileList() { - return mdlSelectedFileList; - } - public void setMdlSelectedFileList(List mdlSelectedFileList) { - this.mdlSelectedFileList = mdlSelectedFileList; - } - public List getMdlSelectedTimeList() { - return mdlSelectedTimeList; - } - public void setMdlSelectedTimeList(List mdlSelectedTimeList) { - this.mdlSelectedTimeList = mdlSelectedTimeList; - } + private void cleanSelf() { - static int count = 0; + if (text1 != null) { + text1.dispose(); + text1 = null; + } + } - public static NsharpLoadDialog getAccess() { - return INSTANCE; - } + private void cleanupDialog(int activeLoadType) { + switch (activeLoadType) { + case OBSER_SND: + obsDialog.cleanup(); + break; + case MODEL_SND: + mdlDialog.cleanup(); + break; + case PFC_SND: + pfcDialog.cleanup(); + break; + /* + * TBDGPD case GPD_OBS_SND: gpdObsDialog.cleanup(); break; case + * GPD_PFC_SND: gpdPfcDialog.cleanup(); break; + */ + case ARCHIVE: + break; + default: + break; + } - public NsharpLoadDialog(Shell parentShell)throws VizException { - super(parentShell); - // set modeless, so mouse button can be used by others - this.setShellStyle(SWT.TITLE | SWT.MODELESS | SWT.CLOSE |SWT.SHELL_TRIM); - - //System.out.println("loadDia constructed"); - activeLoadSoundingType = OBSER_SND; + } - } + public void setActiveLoadSoundingType(int activeLoadSoundingType) { + this.activeLoadSoundingType = activeLoadSoundingType; + } - /* + public int getActiveLoadSoundingType() { + return activeLoadSoundingType; + } + + public List getPfcSelectedFileList() { + return pfcSelectedFileList; + } + + public void setPfcSelectedFileList(List pfcSelectedFileList) { + this.pfcSelectedFileList = pfcSelectedFileList; + } + + public List getPfcSelectedTimeList() { + return pfcSelectedTimeList; + } + + public void setPfcSelectedTimeList(List pfcSelectedTimeList) { + this.pfcSelectedTimeList = pfcSelectedTimeList; + } + + public ArrayList getObsSelectedTimeList() { + return obsSelectedTimeList; + } + + public void setObsSelectedTimeList(ArrayList obsSelectedTimeList) { + this.obsSelectedTimeList = obsSelectedTimeList; + } + + public ArrayList getGpdSelectedTimeList() { + return gpdSelectedTimeList; + } + + public void setGpdSelectedTimeList(ArrayList gpdSelectedTimeList) { + this.gpdSelectedTimeList = gpdSelectedTimeList; + } + + public NcSoundingProfile.ObsSndType getActiveObsSndType() { + return activeObsSndType; + } + + public void setActiveObsSndType( + NcSoundingProfile.ObsSndType activeObsSndType) { + this.activeObsSndType = activeObsSndType; + } + + public NcSoundingProfile.PfcSndType getActivePfcSndType() { + return activePfcSndType; + } + + public void setActivePfcSndType( + NcSoundingProfile.PfcSndType activePfcSndType) { + this.activePfcSndType = activePfcSndType; + } + + public String getActiveMdlSndMdlType() { + return activeMdlSndMdlType; + } + + public void setActiveMdlSndMdlType(String activeMdlSndMdlType) { + this.activeMdlSndMdlType = activeMdlSndMdlType; + } + + public String getActiveGpdProdName() { + return activeGpdProdName; + } + + public void setActiveGpdProdName(String activeGpdProdName) { + this.activeGpdProdName = activeGpdProdName; + } + + public List getMdlSelectedFileList() { + return mdlSelectedFileList; + } + + public void setMdlSelectedFileList(List mdlSelectedFileList) { + this.mdlSelectedFileList = mdlSelectedFileList; + } + + public List getMdlSelectedTimeList() { + return mdlSelectedTimeList; + } + + public void setMdlSelectedTimeList(List mdlSelectedTimeList) { + this.mdlSelectedTimeList = mdlSelectedTimeList; + } + + static int count = 0; + + public static NsharpLoadDialog getAccess() { + return INSTANCE; + } + + public NsharpLoadDialog(Shell parentShell) throws VizException { + super(parentShell); + // set modeless, so mouse button can be used by others + this.setShellStyle(SWT.TITLE | SWT.MODELESS | SWT.CLOSE + | SWT.SHELL_TRIM); + + // System.out.println("loadDia constructed"); + activeLoadSoundingType = OBSER_SND; + + } + + /* * (non-Javadoc) * - * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) - */ - @Override - protected void configureShell( Shell shell ) { - super.configureShell( shell ); - NsharpLoadDialog.shell = shell; + * @see + * org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets + * .Shell) + */ + @Override + protected void configureShell(Shell shell) { + super.configureShell(shell); + NsharpLoadDialog.shell = shell; shell.setSize(DIALOG_WIDTH, DIALOG_HEIGHT); - shell.setText( "Load" ); - mb = new MessageBox(shell, SWT.ICON_WARNING - | SWT.OK); + shell.setText("Load"); + mb = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK); - mb.setMessage( "User Input Error!"); - Font font = shell.getFont(); - FontData[] fontData = font.getFontData(); - for (int i = 0; i < fontData.length; i++) { - fontData[i].setHeight(7); - //fontData[i].setName("courier"); - } - newFont = new Font(font.getDevice(), fontData); - shell.setFont(newFont); + mb.setMessage("User Input Error!"); + Font font = shell.getFont(); + FontData[] fontData = font.getFontData(); + for (int i = 0; i < fontData.length; i++) { + fontData[i].setHeight(7); + // fontData[i].setName("courier"); + } + newFont = new Font(font.getDevice(), fontData); + shell.setFont(newFont); } - private void createLoadContents(Composite parent) { - /* CHIN 1331 - NsharpMapResource nsharpMapResource = NsharpMapResource.getOrCreateNsharpMapResource();//NsharpLoadDialog.getAccess().getNsharpMapResource(); - nsharpMapResource.setPoints(null); - NsharpEditor editor = NsharpEditor.getActiveNsharpEditor(); - if (editor != null) { - NsharpResourceHandler rsc = editor.getRscHandler(); - rsc.cleanUpRsc(); - editor.refresh(); - }*/ - dialogParent = parent; - obsDialog = new ObservedSoundingDialogContents(dialogParent); - pfcDialog = new PfcSoundingDialogContents(dialogParent); - mdlDialog = new ModelSoundingDialogContents(dialogParent); - switch(activeLoadSoundingType){ - case MODEL_SND: - mdlDialog.createMdlDialogContents(); - break; - case PFC_SND: - pfcDialog.createPfcDialogContents(); - break; - default: //OBSER_SND is default for all other cases, also set activeLoadSoundingType to OBSER_SND - obsDialog.createObsvdDialogContents(); - activeLoadSoundingType = OBSER_SND; - break; - } - - soundingTypeList.setSelection(activeLoadSoundingType); - - } - - /** - * Creates the dialog area - */ - @Override - public Control createDialogArea(Composite parent) { - - top = (Composite) super.createDialogArea(parent); + private void createLoadContents(Composite parent) { + /* + * CHIN 1331 NsharpMapResource nsharpMapResource = + * NsharpMapResource.getOrCreateNsharpMapResource + * ();//NsharpLoadDialog.getAccess().getNsharpMapResource(); + * nsharpMapResource.setPoints(null); NsharpEditor editor = + * NsharpEditor.getActiveNsharpEditor(); if (editor != null) { + * NsharpResourceHandler rsc = editor.getRscHandler(); rsc.cleanUpRsc(); + * editor.refresh(); } + */ + dialogParent = parent; + obsDialog = new NsharpObservedSoundingDialogContents(dialogParent); + pfcDialog = new NsharpPfcSoundingDialogContents(dialogParent); + mdlDialog = new NsharpModelSoundingDialogContents(dialogParent); + // TBDGPD gpdObsDialog = new + // NsharpGpdObsSoundingDialogContents(dialogParent); + // TBDGPD gpdPfcDialog = new + // NsharpGpdPfcSoundingDialogContents(dialogParent); + switch (activeLoadSoundingType) { + case MODEL_SND: + mdlDialog.createMdlDialogContents(); + break; + case PFC_SND: + pfcDialog.createPfcDialogContents(); + break; + /* + * TBDGPD case GPD_OBS_SND: gpdObsDialog.createGpdObsDialogContents(); + * break; case GPD_PFC_SND: gpdPfcDialog.createGpdPfcDialogContents(); + * break; + */ + default: // OBSER_SND is default for all other cases, also set + // activeLoadSoundingType to OBSER_SND + obsDialog.createObsvdDialogContents(); + activeLoadSoundingType = OBSER_SND; + break; + } - // Create the main layout for the shell. - GridLayout mainLayout = new GridLayout(1, false); - mainLayout.marginHeight = 3; - mainLayout.marginWidth = 3; - - //top.setLayout(mainLayout); - //System.out.println("createDialogArea called"); - // Initialize all of the menus, controls, and layouts - createLoadContents(top); - //shell.setSize(DIALOG_WIDTH, DIALOG_HEIGHT); - if(waitCursor==null) - waitCursor = new Cursor( top.getDisplay(), SWT.CURSOR_WAIT); - return top; - } + soundingTypeList.setSelection(activeLoadSoundingType); - - @Override - public int open( ) { - //System.out.println("loadDia opened"); - - if ( this.getShell() == null ){ - this.create(); - } - this.getShell().setLocation(this.getShell().getParent().getLocation().x+1100, - this.getShell().getParent().getLocation().y+200); - NsharpMapResource.bringMapEditorToTop(); - return super.open(); - } - @Override - public boolean close() { - NsharpMapResource nsharpMapResource = NsharpMapResource.getMapRsc(); - if(nsharpMapResource!=null) - nsharpMapResource.setPoints(null); - //System.out.println("loadDia closed"); - cleanSelf(); - cleanupDialog(activeLoadSoundingType); - //INSTANCE = null; - if(waitCursor!=null) - waitCursor.dispose(); - waitCursor=null; - newFont.dispose(); - return (super.close()); + + /** + * Creates the dialog area + */ + @Override + public Control createDialogArea(Composite parent) { + + top = (Composite) super.createDialogArea(parent); + + // Create the main layout for the shell. + GridLayout mainLayout = new GridLayout(1, false); + mainLayout.marginHeight = 3; + mainLayout.marginWidth = 3; + + // top.setLayout(mainLayout); + // System.out.println("createDialogArea called"); + // Initialize all of the menus, controls, and layouts + createLoadContents(top); + // shell.setSize(DIALOG_WIDTH, DIALOG_HEIGHT); + if (waitCursor == null) + waitCursor = new Cursor(top.getDisplay(), SWT.CURSOR_WAIT); + return top; } - - public boolean closeDiaOnly() { - cleanSelf(); - return (super.close()); - } - - //Only use Cancel button but NOT ok button - @Override - public void createButtonsForButtonBar(Composite parent) { - - // create Cancel buttons by default, but use close label - createButton(parent, IDialogConstants.CANCEL_ID, - IDialogConstants.CLOSE_LABEL, false); - - - //cancelBtn.setBounds(cancelBtn.getBounds().x, cancelBtn.getBounds().y+DIALOG_HEIGHT, 20, 10); - //System.out.println("createButtonsForButtonBar cancelBtn bound"+cancelBtn.getBounds()); - } - + @Override + public int open() { + // System.out.println("loadDia opened"); - public static NsharpLoadDialog getInstance( Shell parShell){ - //System.out.println("getInstance called"); - if ( INSTANCE == null ){ - try { - INSTANCE = new NsharpLoadDialog( parShell ); - //System.out.println("new load dialog INSTANCE created"); - } catch (VizException e) { - e.printStackTrace(); - } - - } - return INSTANCE; - - } + if (this.getShell() == null) { + this.create(); + } + this.getShell().setLocation( + this.getShell().getParent().getLocation().x + 1100, + this.getShell().getParent().getLocation().y + 200); + NsharpMapResource.bringMapEditorToTop(); + return super.open(); - //public void setShellSize(boolean big){ - // if(big == true) { - - // } - // else { - // shell.setSize(DIALOG_WIDTH, DIALOG_HEIGHT-100); - // } - //} - public void startWaitCursor(){ - if(waitCursor!=null) - top.setCursor(waitCursor); - } - public void stopWaitCursor(){ - top.setCursor(null); - } + } + + @Override + public boolean close() { + NsharpMapResource nsharpMapResource = NsharpMapResource.getMapRsc(); + if (nsharpMapResource != null) + nsharpMapResource.setPoints(null); + // System.out.println("loadDia closed"); + cleanSelf(); + cleanupDialog(activeLoadSoundingType); + // INSTANCE = null; + if (waitCursor != null) + waitCursor.dispose(); + waitCursor = null; + newFont.dispose(); + return (super.close()); + } + + public boolean closeDiaOnly() { + cleanSelf(); + return (super.close()); + } + + // Only use Cancel button but NOT ok button + @Override + public void createButtonsForButtonBar(Composite parent) { + + // create Cancel buttons by default, but use close label + createButton(parent, IDialogConstants.CANCEL_ID, + IDialogConstants.CLOSE_LABEL, false); + + // cancelBtn.setBounds(cancelBtn.getBounds().x, + // cancelBtn.getBounds().y+DIALOG_HEIGHT, 20, 10); + // System.out.println("createButtonsForButtonBar cancelBtn bound"+cancelBtn.getBounds()); + } + + public static NsharpLoadDialog getInstance(Shell parShell) { + // System.out.println("getInstance called"); + if (INSTANCE == null) { + try { + INSTANCE = new NsharpLoadDialog(parShell); + // System.out.println("new load dialog INSTANCE created"); + } catch (VizException e) { + e.printStackTrace(); + } + + } + return INSTANCE; + + } + + public void startWaitCursor() { + if (waitCursor != null) + top.setCursor(waitCursor); + } + + public void stopWaitCursor() { + top.setCursor(null); + } } diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpModelSoundingDialogContents.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpModelSoundingDialogContents.java new file mode 100644 index 0000000000..17d44f6668 --- /dev/null +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpModelSoundingDialogContents.java @@ -0,0 +1,868 @@ +/** + * + * gov.noaa.nws.ncep.ui.nsharp.view.ModelSoundingDialogContents + * + * This java class performs the NSHARP NsharpLoadDialog functions. + * This code has been developed by the NCEP-SIB for use in the AWIPS2 system. + * + *
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    	Engineer    Description
+ * -------		------- 	-------- 	-----------
+ * 01/2011	229			Chin Chen	Initial coding
+ *
+ * 
+ * + * @author Chin Chen + * @version 1.0 + */ +package gov.noaa.nws.ncep.ui.nsharp.view; + +import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingCube; +import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingLayer; +import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingProfile; +import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingTimeLines; +import gov.noaa.nws.ncep.ui.nsharp.NsharpConfigManager; +import gov.noaa.nws.ncep.ui.nsharp.NsharpConfigStore; +import gov.noaa.nws.ncep.ui.nsharp.NsharpConstants; +import gov.noaa.nws.ncep.ui.nsharp.NsharpGraphProperty; +import gov.noaa.nws.ncep.ui.nsharp.NsharpGridInventory; +import gov.noaa.nws.ncep.ui.nsharp.NsharpStationInfo; +import gov.noaa.nws.ncep.ui.nsharp.SurfaceStationPointData; +import gov.noaa.nws.ncep.ui.nsharp.display.NsharpEditor; +import gov.noaa.nws.ncep.ui.nsharp.display.map.NsharpMapResource; +import gov.noaa.nws.ncep.ui.nsharp.display.rsc.NsharpResourceHandler; +import gov.noaa.nws.ncep.ui.nsharp.natives.NsharpDataHandling; +import gov.noaa.nws.ncep.viz.common.soundingQuery.NcSoundingQuery; + +import java.sql.Timestamp; +import java.text.DateFormatSymbols; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.TimeZone; + +import org.eclipse.swt.SWT; +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.Event; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Text; + +import com.raytheon.uf.common.dataquery.requests.RequestConstraint; +import com.vividsolutions.jts.geom.Coordinate; + +public class NsharpModelSoundingDialogContents { + private Composite parent; + + private org.eclipse.swt.widgets.List modelTypeList = null, + availableFileList = null, sndTimeList = null; + + // timeLineToFileMap maps time line (rangeStart time in sndTimeList) to + // available file (reftime in availableFileList) + private Map timeLineToFileMap = new HashMap(); + + // soundingLysLstMap maps "lat;lon timeline" string to its queried sounding + // layer list + private Map> soundingLysLstMap = new HashMap>(); + + private Group modelTypeGp, bottomGp, availableFileGp, sndTimeListGp, topGp, + locationMainGp; + + private Button timeBtn, latlonBtn, stationBtn, loadBtn; + + private Text locationText; + + private Label locationLbl; + + private boolean timeLimit = false; + + private NsharpLoadDialog ldDia; + + private Font newFont; + + private List selectedFileList = new ArrayList(); + + private List selectedTimeList = new ArrayList(); + + // private NcSoundingProfile.MdlSndType currentSndType = + // NcSoundingProfile.MdlSndType.NONE; + private float lat, lon; + + private String stnStr = ""; + + private final String GOOD_LATLON_STR = " A good input looked like this:\n 38.95;-77.45 or 38.95,-77.45"; + + private final String GOOD_STN_STR = " A good input looked like this:\n GAI or gai"; + + String gribDecoderName = "grid";// NcSoundingQuery.NCGRIB_PLUGIN_NAME; + + private String selectedModel = ""; + + // private DBType currentDb = DBType.NCGRIB; + private static final String SND_TIMELINE_NOT_AVAIL_STRING = "No Sounding Time for Nsharp"; + + public enum LocationType { + LATLON, STATION + } + + public enum DBType { + GRIB, NCGRIB + } + + private LocationType currentLocType = LocationType.LATLON; + + public LocationType getCurrentLocType() { + return currentLocType; + } + + public Text getLocationText() { + return locationText; + } + + public NsharpModelSoundingDialogContents(Composite parent) { + this.parent = parent; + ldDia = NsharpLoadDialog.getAccess(); + newFont = ldDia.getNewFont(); + /* + * if( VizPerspectiveListener.getCurrentPerspectiveManager()!= null){ + * if( + * VizPerspectiveListener.getCurrentPerspectiveManager().getPerspectiveId + * ().equals(NmapCommon.NatlCntrsPerspectiveID)) gribDecoderName = + * NcSoundingQuery.NCGRIB_PLUGIN_NAME; else gribDecoderName = + * NcSoundingQuery.GRIB_PLUGIN_NAME; + * + * + * //for testing //gribDecoderName = NcSoundingQuery.GRIB_PLUGIN_NAME; + * //System.out.println("perspective id = " + + * VizPerspectiveListener.getCurrentPerspectiveManager + * ().getPerspectiveId()); } + */ + } + + private void createMDLAvailableFileList() { + if (sndTimeList != null) + sndTimeList.removeAll(); + if (availableFileList != null) + availableFileList.removeAll(); + HashMap rcMap = new HashMap(); + rcMap.put("info.datasetId", new RequestConstraint(selectedModel)); + ldDia.startWaitCursor(); + ArrayList queryRsltsList1 = NsharpGridInventory.getInstance() + .searchInventory(rcMap, "dataTime");// .refTime" ); + /* + * Chin Note: with this query, the returned string has this format, + * "grid/ruc13/2012-01-17_16:00:00.0(6)xxxxx" We will have to strip off + * "ncgrib/ruc13/" and ":00:00.0(6)xxxxx", also replace "_" with space, + * to get grid file name like this "2012-01-17 16". + */ + /* + * fixMarkA Chin 12/11/2013: at this moment, the returned string format + * is like this, 2012-01-17_16:00:00.0_(6) We will have to strip off + * ":00:00.0_(6)", also replace first "_" with space, to get grid file + * name like this "2012-01-17 16". fixMarkA + */ + // fixMarkAchar fileSep = File.pathSeparatorChar; + // fixMarkA String header = "grid"+fileSep+ selectedModel +fileSep; + if (queryRsltsList1 != null && !queryRsltsList1.isEmpty()) { + Collections.sort(queryRsltsList1, String.CASE_INSENSITIVE_ORDER); + Collections.reverse(queryRsltsList1); + + for (String queryRslt : queryRsltsList1) { + // fixMarkA queryRslt = queryRslt.substring(header.length()); + String refTime = queryRslt.substring(0, queryRslt.indexOf('_')); + refTime = refTime + + " " + + queryRslt.substring(queryRslt.indexOf('_') + 1, + queryRslt.indexOf(':')); + // System.out.println("ret for disp="+refTime ); + // Chin: a same refTime may be returned more than once. + int index = availableFileList.indexOf(refTime); + if (index == -1) // index = -1 means it is not in the list + availableFileList.add(refTime); + } + } + ldDia.stopWaitCursor(); + + } + + /* + * private void createMDLAvailableFileListOld() { if(sndTimeList!=null) + * sndTimeList.removeAll(); if(availableFileList!=null) + * availableFileList.removeAll(); + * + * //query using NcSoundingQuery class to query NcSoundingTimeLines + * timeLines = NcSoundingQuery.mdlSoundingTimeLineQuery(selectedModel, + * gribDecoderName); if(timeLines!= null && timeLines.getTimeLines() != + * null){ ldDia.startWaitCursor(); for(Object timeLine : + * timeLines.getTimeLines()){ Timestamp reftime = (Timestamp)timeLine; + * if(reftime != null){ //need to format reftime to GMT time string. + * Timestamp.toString produce a local time Not GMT time Calendar cal = + * Calendar.getInstance(TimeZone.getTimeZone("GMT")); + * cal.setTimeInMillis(reftime.getTime()); String gmtTimeStr = + * String.format("%1$tY-%1$tm-%1$td %1$tH", cal); + * //System.out.println("GMT time " + gmtTimeStr); + * availableFileList.add(gmtTimeStr); + * + * } + * + * } ldDia.stopWaitCursor(); } else + * System.out.println("SQL: query return null"); } + */ + private void createMDLSndTimeList(List selectedFlLst) { + if (selectedFlLst.size() <= 0) + return; + if (sndTimeList != null) + sndTimeList.removeAll(); + if (timeLineToFileMap != null) + timeLineToFileMap.clear(); + int nameLen = Math.min(6, selectedModel.length()); + String modelName = selectedModel.substring(0, nameLen); + // query using NcSoundingQuery to query + DateFormatSymbols dfs = new DateFormatSymbols(); + String[] defaultDays = dfs.getShortWeekdays(); + Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + ldDia.startWaitCursor(); + for (int i = 0; i < selectedFlLst.size(); i++) { + String fl = selectedFlLst.get(i); + long reftimeMs = NcSoundingQuery.convertRefTimeStr(fl); + NcSoundingTimeLines timeLines = NcSoundingQuery + .mdlSoundingRangeTimeLineQuery(selectedModel, fl, + gribDecoderName); + if (timeLines != null && timeLines.getTimeLines().length > 0) { + for (Object obj : timeLines.getTimeLines()) { + Timestamp rangestart = (Timestamp) obj; + // need to format rangestart to GMT time string. + // Timestamp.toString produce a local time Not GMT time + cal.setTimeInMillis(rangestart.getTime()); + long vHour = (cal.getTimeInMillis() - reftimeMs) / 3600000; + String dayOfWeek = defaultDays[cal + .get(Calendar.DAY_OF_WEEK)]; + // String gmtTimeStr = + // String.format("%1$ty%1$tm%1$td/%1$tH%1$tMV%2$03d %3$s", + // cal, vHour,modelName); + String gmtTimeStr = String.format( + "%1$ty%1$tm%1$td/%1$tH(%4$s)V%2$03d %3$s", cal, + vHour, modelName, dayOfWeek); + if (sndTimeList.indexOf(gmtTimeStr) != -1) { + // this indicate that gmtTimeStr is already in the + // sndTimeList, then we dont need to add it to list + // again. + continue; + } + + // System.out.println("GMT time " + gmtTimeStr); + if (!timeLimit) { + sndTimeList.add(gmtTimeStr); + timeLineToFileMap.put(gmtTimeStr, fl); + } else { + int hour = cal.get(Calendar.HOUR_OF_DAY); + if ((hour == 0) || (hour == 12)) { + sndTimeList.add(gmtTimeStr); + timeLineToFileMap.put(gmtTimeStr, fl); + } + } + } + } + } + if (sndTimeList != null && sndTimeList.getItemCount() <= 0) { + sndTimeList.add(SND_TIMELINE_NOT_AVAIL_STRING); + } + ldDia.stopWaitCursor(); + } + + private void queryAndLoadData(boolean stnQuery) + throws java.text.ParseException { + soundingLysLstMap.clear(); + ldDia.startWaitCursor(); + Timestamp refTime = null; + // Chin Note: Since NcGrib/Grib HDF5 data file is created based on a + // forecast time line, we can not query + // more than one time line at one time as Edex server just could not + // support such query at one shot. + // This is not the case of PFC sounding (modelsounding db). It has all + // time lines of one forecast report + // saved in one file. Therefore, PFC query is much faster. + for (String timeLine : selectedTimeList) { + // avail file, ie. its refTime + String selectedFileStr = timeLineToFileMap.get(timeLine); + + // start FixMark:nearByStnCompSnd + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH"); + df.parse(selectedFileStr); + Calendar cal = df.getCalendar(); + int offset = cal.get(Calendar.ZONE_OFFSET) + + cal.get(Calendar.DST_OFFSET) / (60 * 1000); + refTime = new Timestamp(cal.getTimeInMillis() + offset); + // end FixMark:nearByStnCompSnd + + String rangeStartStr = NcSoundingQuery + .convertSoundTimeDispStringToRangeStartTimeFormat(timeLine); + float[][] latLon = { { lat, lon } }; + NcSoundingCube cube = NcSoundingQuery.mdlSoundingQueryByLatLon( + selectedFileStr + ":00:00", rangeStartStr, latLon, + gribDecoderName, selectedModel, false, "-1"); + if (cube != null + && cube.getRtnStatus() == NcSoundingCube.QueryStatus.OK) { + // System.out.println("mdlSoundingQueryByLatLon returnd ok"); + + NcSoundingProfile sndPf = cube.getSoundingProfileList().get(0); + + List rtnSndLst = sndPf.getSoundingLyLst(); + if (rtnSndLst != null && rtnSndLst.size() > 1) { + // Remove sounding layers that not used by NSHARP + // System.out.println("numbe of layer returned from query ="+ + // rtnSndLst.size()); + rtnSndLst = NsharpDataHandling.organizeSoundingDataForShow( + rtnSndLst, sndPf.getStationElevation()); + // minimum rtnSndList size will be 2 (50 & 75 mb layers), + // but that is not enough + // We need at least 2 regular layers for plotting + if (rtnSndLst != null && rtnSndLst.size() > 4) { // after + // organized, + // if size + // is still + // good + if (!stnQuery) { + soundingLysLstMap.put(lat + "/" + lon + " " + + timeLine, rtnSndLst); + // System.out.println(lat+";"+lon+" "+timeLine); + } else { + // replaced space to _ in stnStr. + String stnStrPacked = stnStr.replace(" ", "_"); + soundingLysLstMap.put( + stnStrPacked + " " + timeLine, rtnSndLst); + // System.out.println(stnStr+" "+timeLine); + } + continue; + } + + } + // code to this point means query result is not good + NsharpLoadDialog ldDia = NsharpLoadDialog.getAccess(); + if (!stnQuery) { + ldDia.setAndOpenMb("Sounding query with lat/lon (" + lat + + "/" + lon + ") at " + timeLine + + ": Returned\n But without vlaid data"); + } else { + ldDia.setAndOpenMb("Sounding query with stn " + stnStr + + "at lat/lon (" + lat + "/" + lon + ") at " + + timeLine + ": Returned\n But without vlaid data"); + } + // return; + } else { + if (!stnQuery) { + System.out.println("mdlsoundingQueryByLatLon failed"); + NsharpLoadDialog ldDia = NsharpLoadDialog.getAccess(); + if (cube != null) + ldDia.setAndOpenMb("Sounding query with lat/lon (" + + lat + "/" + lon + ") at " + timeLine + + ": failed\nError status:" + + cube.getRtnStatus().toString()); + else + ldDia.setAndOpenMb("Sounding query with lat/lon (" + + lat + "/" + lon + ") at " + timeLine + + ": failed\nError status: NULL returned"); + } else { + System.out.println("mdlsoundingQueryByStn failed"); + NsharpLoadDialog ldDia = NsharpLoadDialog.getAccess(); + if (cube != null) + ldDia.setAndOpenMb("Sounding query with stn " + stnStr + + "at lat/lon (" + lat + "/" + lon + ") at " + + timeLine + ": failed\nError status:" + + cube.getRtnStatus().toString()); + else + ldDia.setAndOpenMb("Sounding query with stn " + stnStr + + "at lat/lon (" + lat + "/" + lon + ") at " + + timeLine + + ": failed\nError status: NULL returned"); + } + // return; + } + } + ldDia.stopWaitCursor(); + NsharpEditor skewtEdt = NsharpEditor.createOrOpenEditor(); + NsharpResourceHandler skewRsc = skewtEdt.getRscHandler(); + // create station info structure + NsharpStationInfo stnInfo = new NsharpStationInfo(); + stnInfo.setSndType(selectedModel); + stnInfo.setLatitude(lat); + stnInfo.setLongitude(lon); + stnInfo.setStnId(stnStr); + stnInfo.setReftime(refTime);// FixMark:nearByStnCompSnd + skewRsc.addRsc(soundingLysLstMap, stnInfo); + skewRsc.setSoundingType(selectedModel); + NsharpEditor.bringEditorToTop(); + } + + private void createModelTypeList() { + if (modelTypeList != null) + modelTypeList.removeAll(); + if (sndTimeList != null) + sndTimeList.removeAll(); + if (availableFileList != null) + availableFileList.removeAll(); + ldDia.startWaitCursor(); + List cfgList = null; + NsharpConfigManager configMgr = NsharpConfigManager.getInstance(); + NsharpConfigStore configStore = configMgr + .retrieveNsharpConfigStoreFromFs(); + NsharpGraphProperty graphConfigProperty = configStore + .getGraphProperty(); + cfgList = graphConfigProperty.getGribModelTypeList(); + HashMap rcMap = new HashMap(); + rcMap.put("pluginName", new RequestConstraint("grid")); + + ArrayList queryRsltsList = NsharpGridInventory.getInstance() + .searchInventory(rcMap, "info.datasetId"); + + /* + * Chin Note: with this query, the returned string has this format, + * "ncgrib/gfsP5" We will have to strip off "ncgrib/" to get model name + * like this "gfsP5". + */ + /* + * fixMarkB Chin: 12/11/2013 at this moment, the returned string has + * this format, "gfsP5", just he model name. Therefore, we do not have + * to process on it. + */ + if (queryRsltsList != null && !queryRsltsList.isEmpty()) { + Collections.sort(queryRsltsList, String.CASE_INSENSITIVE_ORDER); + for (String queryRslt : queryRsltsList) { + // System.out.println("model name:"+queryRslt ); + String modelName = queryRslt;// fixMarkB .substring( + // "grid/".length() ); + if (cfgList != null && cfgList.size() > 0) { + if (cfgList.contains(modelName)) + modelTypeList.add(modelName); + } else + modelTypeList.add(modelName); + } + } + ldDia.stopWaitCursor(); + + } + + private void handleAvailFileListSelection() { + String selectedFile = null; + if (availableFileList.getSelectionCount() > 0) { + selectedFileList.clear(); + for (int i = 0; i < availableFileList.getSelectionCount(); i++) { + selectedFile = availableFileList.getSelection()[i]; + // System.out.println("selected sounding file is " + + // selectedFile); + selectedFileList.add(selectedFile); + } + createMDLSndTimeList(selectedFileList); + } + } + + private void handleSndTimeSelection() { + String selectedSndTime = null; + if (sndTimeList.getSelectionCount() > 0 + && sndTimeList.getSelection()[0] + .equals(SND_TIMELINE_NOT_AVAIL_STRING) == false) { + + selectedTimeList.clear(); + for (int i = 0; i < sndTimeList.getSelectionCount(); i++) { + selectedSndTime = sndTimeList.getSelection()[i]; + // System.out.println("selected sounding time is " + + // selectedSndTime); + selectedTimeList.add(selectedSndTime); + } + NsharpMapResource.bringMapEditorToTop(); + } + } + + public void createMdlDialogContents() { + topGp = new Group(parent, SWT.SHADOW_ETCHED_IN); + topGp.setLayout(new GridLayout(2, false)); + selectedModel = ldDia.getActiveMdlSndMdlType(); + ldDia.createSndTypeList(topGp); + + modelTypeGp = new Group(topGp, SWT.SHADOW_ETCHED_IN); + modelTypeGp.setText("Model Type"); + modelTypeGp.setFont(newFont); + modelTypeList = new org.eclipse.swt.widgets.List(modelTypeGp, + SWT.BORDER | SWT.V_SCROLL); + modelTypeList.setBounds(modelTypeGp.getBounds().x, + modelTypeGp.getBounds().y + NsharpConstants.labelGap, + NsharpConstants.filelistWidth, NsharpConstants.listHeight); + // query to get and add available sounding models from DB + modelTypeList.setFont(newFont); + createModelTypeList(); + + // create a selection listener to handle user's selection on list + modelTypeList.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event e) { + if (modelTypeList.getSelectionCount() > 0) { + selectedModel = modelTypeList.getSelection()[0]; + ldDia.setActiveMdlSndMdlType(selectedModel); + // System.out.println("selected sounding model is " + + // selectedModel); + createMDLAvailableFileList(); + } + } + }); + + availableFileGp = new Group(topGp, SWT.SHADOW_ETCHED_IN); + availableFileGp.setText("Available Grid files:"); + availableFileGp.setFont(newFont); + availableFileList = new org.eclipse.swt.widgets.List(availableFileGp, + SWT.BORDER /* FixMark:nearByStnCompSnd| SWT.MULTI */ + | SWT.V_SCROLL); + availableFileList.setBounds(availableFileGp.getBounds().x, + availableFileGp.getBounds().y + NsharpConstants.labelGap, + NsharpConstants.filelistWidth, NsharpConstants.listHeight);// *32/5 + // ); + availableFileList.setFont(newFont); + // create a selection listener to handle user's selection on list + availableFileList.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event e) { + handleAvailFileListSelection(); + } + }); + + // create Sounding Times widget list + sndTimeListGp = new Group(topGp, SWT.SHADOW_ETCHED_IN); + sndTimeListGp.setText("Sounding Times:"); + sndTimeListGp.setFont(newFont); + sndTimeList = new org.eclipse.swt.widgets.List(sndTimeListGp, + SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); + sndTimeList.removeAll(); + sndTimeList.setFont(newFont); + sndTimeList.setBounds(sndTimeListGp.getBounds().x, + sndTimeListGp.getBounds().y + NsharpConstants.labelGap, + NsharpConstants.listWidth, NsharpConstants.listHeight);// *32/5); + sndTimeList.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event e) { + handleSndTimeSelection(); + } + }); + timeBtn = new Button(topGp, SWT.CHECK | SWT.BORDER); + timeBtn.setText("00Z and 12Z only"); + timeBtn.setEnabled(true); + timeBtn.setFont(newFont); + timeBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (timeLimit) + timeLimit = false; + else + timeLimit = true; + + // refresh sounding list if file type is selected already + if (selectedModel != null && selectedFileList.size() > 0) { + createMDLSndTimeList(selectedFileList); + } + + } + }); + locationMainGp = new Group(parent, SWT.SHADOW_ETCHED_IN); + locationMainGp.setLayout(new GridLayout(5, false)); + locationMainGp.setText("Location"); + locationMainGp.setFont(newFont); + latlonBtn = new Button(locationMainGp, SWT.RADIO | SWT.BORDER); + latlonBtn.setText("Lat/Lon"); + latlonBtn.setFont(newFont); + latlonBtn.setEnabled(true); + latlonBtn.setSelection(true); + latlonBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + currentLocType = LocationType.LATLON; + locationText.setText(""); + } + }); + stationBtn = new Button(locationMainGp, SWT.RADIO | SWT.BORDER); + stationBtn.setText("Station"); + stationBtn.setEnabled(true); + stationBtn.setFont(newFont); + stationBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + currentLocType = LocationType.STATION; + locationText.setText(""); + } + }); + // locationInputGp = new Group(locationMainGp,SWT.SHADOW_ETCHED_IN); + locationLbl = new Label(locationMainGp, SWT.NONE | SWT.BORDER); + // locationLbl.setBounds(latlonBtn.getBounds().x, + // latlonBtn.getBounds().y + latlonBtn.getBounds().height+ + // NsharpConstants.btnGapY, + // bottomGp.getBounds().width/2,NsharpConstants.btnHeight); + locationLbl.setText("Location:"); + locationLbl.setFont(newFont); + locationText = new Text(locationMainGp, SWT.BORDER | SWT.SINGLE); + GridData data1 = new GridData(SWT.FILL, SWT.FILL, true, true); + locationText.setLayoutData(data1); + // locationText.setBounds(stationBtn.getBounds().x, + // locationLbl.getBounds().y,450,NsharpConstants.btnHeight); + locationText.setTextLimit(15); + locationText.setFont(newFont); + locationText.addListener(SWT.Verify, new Listener() { + public void handleEvent(Event e) { + String userInputStr = e.text; + if (userInputStr.length() > 0) { + + if (currentLocType == LocationType.LATLON) { + // to make sure user enter digits and separated by ";" + // or ","only, if lat/lon is used + // System.out.println("user input str" + userInputStr); + if (userInputStr.length() == 1) { + char inputChar = userInputStr.charAt(0); + if (!('0' <= inputChar && inputChar <= '9') + && inputChar != ';' && inputChar != ',' + && inputChar != '-' && inputChar != '.') { + e.doit = false; + return; + } + } + } else { + // do nothing when station type + + } + } + } + }); + + loadBtn = new Button(locationMainGp, SWT.PUSH); + loadBtn.setText("Load "); + loadBtn.setFont(newFont); + loadBtn.setEnabled(true); + loadBtn.setBounds(locationMainGp.getBounds().x + + NsharpConstants.btnGapX, locationLbl.getBounds().y + + locationLbl.getBounds().height + NsharpConstants.btnGapY, + NsharpConstants.btnWidth, NsharpConstants.btnHeight); + loadBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + NsharpLoadDialog ldDia = NsharpLoadDialog.getAccess(); + if (selectedTimeList != null && selectedTimeList.size() == 0) { + ldDia.setAndOpenMb("Time line(s) is not selected!\n Can not load data!"); + return; + } + String textStr = locationText.getText(); + if ((textStr != null) && !(textStr.isEmpty())) { + // textStr = textStr.trim(); + if (currentLocType == LocationType.LATLON) { + // to make sure user enter digits and separated by ";" + // or ","only, if lat/lon is used + int dividerIndex = textStr.indexOf(';'); + boolean indexFound = false; + if (dividerIndex != -1) + indexFound = true; + if (indexFound == false) { + dividerIndex = textStr.indexOf(','); + if (dividerIndex != -1) + indexFound = true; + } + if (indexFound == true) { + try { + lat = Float.parseFloat(textStr.substring(0, + dividerIndex)); + lon = Float.parseFloat(textStr + .substring(dividerIndex + 1)); + if (lat > 90 || lat < -90 || lon > 180 + || lon < -180) { + // System.out.println("bad lat/lon entered =" + // + textStr); + ldDia.setAndOpenMb("lat/lon out of range (" + + textStr + ") entered!\n" + + GOOD_LATLON_STR); + locationText.setText(""); + return; + } + // System.out.println("user enter lat " + lat+ + // " lon " + lon); + queryAndLoadData(false); + + } catch (Exception e) { + System.out + .println("queryAndLoadData failed at (1)" + + textStr); + // ldDia.setAndOpenMb("Bad lat/lon ("+textStr+") entered!\n"+GOOD_LATLON_STR); + // locationText.setText(""); + return; + } + + } else { + // System.out.println("2 bad lat/lon entered =" + + // textStr); + ldDia.setAndOpenMb("Bad lat/lon (" + textStr + + ") entered!\n" + GOOD_LATLON_STR); + locationText.setText(""); + return; + } + } else if (currentLocType == LocationType.STATION) { + // query station lat /lon + try { + textStr = textStr.trim(); // user may start with a + // space before enter a + // station id + stnStr = textStr.toUpperCase(Locale.getDefault()); + Coordinate co = SurfaceStationPointData + .getStnCoordinate(stnStr); + lat = (float) co.y; + lon = (float) co.x; + // System.out.println("user enter station ="+ + // stnStr+" length="+ stnStr.length()+" lat " + lat+ + // " lon " + lon); + if (lat == SurfaceStationPointData.DEFAULT_LATLON) { + // System.out.println("bad stn id entered =" + + // textStr); + ldDia.setAndOpenMb("Bad station id (" + textStr + + ") entered!\n" + GOOD_STN_STR); + locationText.setText(""); + return; + } + queryAndLoadData(true); + } catch (Exception e) { + System.out.println("queryAndLoadData failed at (2)" + + textStr); + // ldDia.setAndOpenMb("Bad lat/lon ("+textStr+") entered!\n"+GOOD_LATLON_STR); + // locationText.setText(""); + return; + } + } + + // ldDia.close(); + } + } + }); + + if (selectedModel != null && selectedModel.equals("") == false) { + String[] selectedModelArray = { selectedModel }; + modelTypeList.setSelection(selectedModelArray); + createMDLAvailableFileList(); + selectedFileList = ldDia.getMdlSelectedFileList(); + Object[] selFileObjectArray = selectedFileList.toArray(); + String[] selFileStringArray = Arrays.copyOf(selFileObjectArray, + selFileObjectArray.length, String[].class); + availableFileList.setSelection(selFileStringArray); + handleAvailFileListSelection(); + + selectedTimeList = ldDia.getMdlSelectedTimeList(); + Object[] selTimeObjectArray = selectedTimeList.toArray(); + String[] selTimeStringArray = Arrays.copyOf(selTimeObjectArray, + selTimeObjectArray.length, String[].class); + sndTimeList.setSelection(selTimeStringArray); + handleSndTimeSelection(); + + } + } + + public void cleanup() { + /* + * if(gfsBtn != null){ gfsBtn.removeListener(SWT.MouseUp, + * gfsBtn.getListeners(SWT.MouseUp)[0]); gfsBtn.dispose(); gfsBtn = + * null; } if(namBtn != null){ namBtn.removeListener(SWT.MouseUp, + * namBtn.getListeners(SWT.MouseUp)[0]); namBtn.dispose(); namBtn = + * null; } if(ngmBtn != null){ ngmBtn.removeListener(SWT.MouseUp, + * ngmBtn.getListeners(SWT.MouseUp)[0]); ngmBtn.dispose(); ngmBtn = + * null; } if(ruc2Btn != null){ ruc2Btn.removeListener(SWT.MouseUp, + * ruc2Btn.getListeners(SWT.MouseUp)[0]); ruc2Btn.dispose(); ruc2Btn = + * null; } if(ukmetBtn != null){ ukmetBtn.removeListener(SWT.MouseUp, + * ukmetBtn.getListeners(SWT.MouseUp)[0]); ukmetBtn.dispose(); ukmetBtn + * = null; } + */ + if (modelTypeList != null) { + if (modelTypeList.getListeners(SWT.Selection).length > 0) + modelTypeList.removeListener(SWT.Selection, + modelTypeList.getListeners(SWT.Selection)[0]); + modelTypeList.dispose(); + modelTypeList = null; + } + if (modelTypeGp != null) { + modelTypeGp.dispose(); + modelTypeGp = null; + } + if (timeBtn != null) { + timeBtn.removeListener(SWT.MouseUp, + timeBtn.getListeners(SWT.MouseUp)[0]); + timeBtn.dispose(); + timeBtn = null; + } + + NsharpLoadDialog ldDia = NsharpLoadDialog.getAccess(); + ldDia.cleanSndTypeList(); + + if (availableFileList != null) { + availableFileList.removeListener(SWT.Selection, + availableFileList.getListeners(SWT.Selection)[0]); + availableFileList.dispose(); + availableFileList = null; + } + + if (availableFileGp != null) { + availableFileGp.dispose(); + availableFileGp = null; + } + if (sndTimeList != null) { + sndTimeList.removeListener(SWT.Selection, + sndTimeList.getListeners(SWT.Selection)[0]); + sndTimeList.dispose(); + sndTimeList = null; + } + if (sndTimeListGp != null) { + sndTimeListGp.dispose(); + sndTimeListGp = null; + } + if (bottomGp != null) { + bottomGp.dispose(); + bottomGp = null; + } + if (topGp != null) { + topGp.dispose(); + topGp = null; + } + + if (loadBtn != null) { + loadBtn.removeListener(SWT.MouseUp, + loadBtn.getListeners(SWT.MouseUp)[0]); + loadBtn.dispose(); + loadBtn = null; + } + if (stationBtn != null) { + stationBtn.removeListener(SWT.MouseUp, + stationBtn.getListeners(SWT.MouseUp)[0]); + stationBtn.dispose(); + stationBtn = null; + } + if (latlonBtn != null) { + latlonBtn.removeListener(SWT.MouseUp, + latlonBtn.getListeners(SWT.MouseUp)[0]); + latlonBtn.dispose(); + latlonBtn = null; + } + if (locationText != null) { + locationText.removeListener(SWT.Verify, + locationText.getListeners(SWT.Verify)[0]); + locationText.dispose(); + locationText = null; + } + + if (locationLbl != null) { + locationLbl.dispose(); + locationLbl = null; + } + if (locationMainGp != null) { + locationMainGp.dispose(); + locationMainGp = null; + } + /* + * if(newTabBtn != null){ newTabBtn.removeListener(SWT.MouseUp, + * newTabBtn.getListeners(SWT.MouseUp)[0]); newTabBtn.dispose(); + * newTabBtn = null; } + */ + + } +} diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpObservedSoundingDialogContents.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpObservedSoundingDialogContents.java new file mode 100644 index 0000000000..f0adac2342 --- /dev/null +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpObservedSoundingDialogContents.java @@ -0,0 +1,391 @@ +/** + * + * gov.noaa.nws.ncep.ui.nsharp.view.ObservedSoundingDialogContents + * + * This java class performs the NSHARP NsharpLoadDialog functions. + * This code has been developed by the NCEP-SIB for use in the AWIPS2 system. + * + *
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    	Engineer    Description
+ * -------		------- 	-------- 	-----------
+ * 01/2011	    229			Chin Chen	Initial coding
+ * 09/14/2011   457         S. Gurung   Renamed H5UAIR to NCUAIR
+ *
+ * 
+ * + * @author Chin Chen + * @version 1.0 + */ +package gov.noaa.nws.ncep.ui.nsharp.view; + +import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingProfile; +import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingStnInfo; +import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingStnInfoCollection; +import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingTimeLines; +import gov.noaa.nws.ncep.ui.nsharp.NsharpConstants; +import gov.noaa.nws.ncep.ui.nsharp.NsharpStationInfo; +import gov.noaa.nws.ncep.ui.nsharp.display.map.NsharpMapResource; +import gov.noaa.nws.ncep.viz.common.soundingQuery.NcSoundingQuery; + +import java.sql.Timestamp; +import java.text.DateFormatSymbols; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.TimeZone; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Listener; + +public class NsharpObservedSoundingDialogContents { + private Composite parent; + + private org.eclipse.swt.widgets.List sndTimeList; + + private Group btnGp, sndTimeListGp, topGp, midGp; + + private boolean timeLimit = false; + + private boolean rawData = false; + + private Button timeBtn, bufruaBtn, uairBtn, rawBtn; + + private String FILE_UAIR = "UAIR"; + + private String FILE_BUFRUA = "BUFRUA"; + + // private String FILE_DROP = "DROP"; + private NcSoundingProfile.ObsSndType currentSndType = NcSoundingProfile.ObsSndType.NONE; + + private NsharpLoadDialog ldDia; + + private ArrayList selectedTimeList = new ArrayList(); + + private Font newFont; + + public boolean isRawData() { + return rawData; + } + + public NcSoundingProfile.ObsSndType getCurrentSndType() { + return currentSndType; + } + + public NsharpObservedSoundingDialogContents(Composite parent) { + this.parent = parent; + ldDia = NsharpLoadDialog.getAccess(); + newFont = ldDia.getNewFont(); + } + + private void createObsvdSndUairList() { + sndTimeList.removeAll(); + + // use NcSoundingQuery to query + NcSoundingTimeLines timeLines = NcSoundingQuery + .soundingTimeLineQuery(currentSndType.toString()); + + if (timeLines != null && timeLines.getTimeLines() != null) { + DateFormatSymbols dfs = new DateFormatSymbols(); + String[] defaultDays = dfs.getShortWeekdays(); + Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + ldDia.startWaitCursor(); + for (Object timeLine : timeLines.getTimeLines()) { + Timestamp synoptictime = (Timestamp) timeLine; + if (synoptictime != null) { + // need to format synoptictime to GMT time string. + // Timestamp.toString produce a local time Not GMT time + cal.setTimeInMillis(synoptictime.getTime()); + String dayOfWeek = defaultDays[cal + .get(Calendar.DAY_OF_WEEK)]; + // String gmtTimeStr = + // String.format("%1$ty%1$tm%1$td/%1$tH%1$tM %2$s", cal, + // currentSndType.toString()); + String gmtTimeStr = String.format( + "%1$ty%1$tm%1$td/%1$tH(%3$s) %2$s", cal, + currentSndType.toString(), dayOfWeek); + if (!timeLimit) { + // System.out.println("not 00z and 12z only"); + sndTimeList.add(gmtTimeStr); + } else { + int hour = cal.get(Calendar.HOUR_OF_DAY); + // System.out.println("00z and 12z only hour = "+ hour); + if ((hour == 0) || (hour == 12)) + sndTimeList.add(gmtTimeStr); + } + } + } + ldDia.stopWaitCursor(); + } else + System.out.println("EDEX timeline query return null"); + + } + + private void queryAndMarkStn(String selectedSndTime) { + String selectTimetr = NcSoundingQuery + .convertSoundTimeDispStringToRangeStartTimeFormat(selectedSndTime); + NsharpMapResource nsharpMapResource = NsharpMapResource + .getOrCreateNsharpMapResource(); + // Chin float lat, lon; + double lat, lon; + String stnInfoStr; + + // use NcSoundingQuery to query stn info + NcSoundingStnInfoCollection sndStnInfoCol = NcSoundingQuery + .soundingStnInfoQuery(currentSndType.toString(), selectTimetr); + if (sndStnInfoCol != null && sndStnInfoCol.getStationInfo() != null) { + + NcSoundingStnInfo[] stnInfoAry = sndStnInfoCol.getStationInfo(); + // System.out.println("obs station number = "+ stnInfoAry.length ); + // Note: A same station may have many reports + for (int i = 0; i < stnInfoAry.length; i++) { + NcSoundingStnInfo stnInfo = stnInfoAry[i]; + Timestamp synoptictime = null; + stnInfoStr = stnInfo.getStnId(); + if (stnInfoStr == null || stnInfoStr.length() < 1) + stnInfoStr = "*"; + lat = stnInfo.getStationLatitude(); + lon = stnInfo.getStationLongitude(); + // elv = stnInfo.getStationElevation(); + synoptictime = (Timestamp) stnInfo.getSynopTime(); + + // convert to Nsharp's own station info struct + NsharpStationInfo stn = new NsharpStationInfo(); + String packedStnInfoStr = stnInfoStr.replace(" ", "_"); + stn.setStnDisplayInfo(packedStnInfoStr + " " + selectedSndTime + + " " + currentSndType.toString()); + stn.setLongitude(lon); + stn.setLatitude(lat); + stn.setStnId(stnInfoStr); + stn.setReftime(synoptictime); + stn.setRangestarttime(synoptictime); + stn.setSndType(currentSndType.toString()); + // System.out.println("sndType= "+currentSndType); + // System.out.println("stn lat ="+stn.getLatitude() + + // " lon="+stn.getLongitude()); + nsharpMapResource.addPoint(stn); + } + + NsharpMapResource.bringMapEditorToTop(); + } + } + + private void handleSndTimeSelection() { + String selectedSndTime = null; + if (sndTimeList.getSelectionCount() > 0) { + NsharpMapResource nsharpMapResource = NsharpMapResource + .getOrCreateNsharpMapResource();// NsharpLoadDialog.getAccess().getNsharpMapResource(); + nsharpMapResource.setPoints(null); + selectedTimeList.clear(); + ldDia.startWaitCursor(); + for (int i = 0; i < sndTimeList.getSelectionCount(); i++) { + selectedSndTime = sndTimeList.getSelection()[i]; + selectedTimeList.add(selectedSndTime); + // System.out.println("selected sounding time is " + + // selectedSndTime); + int endIndex = selectedSndTime.indexOf(" "); + String queryingSndTime = selectedSndTime.substring(0, endIndex); + queryAndMarkStn(queryingSndTime); + + } + ldDia.setObsSelectedTimeList(selectedTimeList); + ldDia.stopWaitCursor(); + } + } + + public void createObsvdDialogContents() { + currentSndType = ldDia.getActiveObsSndType(); + timeLimit = false; + rawData = false; + topGp = new Group(parent, SWT.SHADOW_ETCHED_IN); + topGp.setLayout(new GridLayout(2, false)); + + // ldDia.setShellSize(false); + ldDia.createSndTypeList(topGp); + + btnGp = new Group(topGp, SWT.SHADOW_ETCHED_IN); + btnGp.setText("File Type"); + btnGp.setFont(newFont); + uairBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); + uairBtn.setText(FILE_UAIR); + uairBtn.setEnabled(true); + uairBtn.setBounds(btnGp.getBounds().x + NsharpConstants.btnGapX, + btnGp.getBounds().y + NsharpConstants.labelGap, + NsharpConstants.btnWidth, NsharpConstants.btnHeight); + uairBtn.setFont(newFont); + uairBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + sndTimeList.removeAll(); + currentSndType = NcSoundingProfile.ObsSndType.NCUAIR; + ldDia.setActiveObsSndType(currentSndType); + createObsvdSndUairList(); + // System.out.println("new obvSnd dialog uair btn"); + } + }); + + bufruaBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); + bufruaBtn.setText(FILE_BUFRUA); + bufruaBtn.setEnabled(true); + bufruaBtn.setBounds(btnGp.getBounds().x + NsharpConstants.btnGapX, + uairBtn.getBounds().y + uairBtn.getBounds().height + + NsharpConstants.btnGapY, NsharpConstants.btnWidth, + NsharpConstants.btnHeight); + bufruaBtn.setFont(newFont); + bufruaBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + sndTimeList.removeAll(); + currentSndType = NcSoundingProfile.ObsSndType.BUFRUA; + ldDia.setActiveObsSndType(currentSndType); + createObsvdSndUairList(); + } + }); + + midGp = new Group(parent, SWT.SHADOW_ETCHED_IN); + midGp.setLayout(new GridLayout(2, false)); + timeBtn = new Button(midGp, SWT.CHECK | SWT.BORDER); + timeBtn.setText("00Z and 12Z only"); + timeBtn.setEnabled(true); + // timeBtn.setBounds(btnGp.getBounds().x+ NsharpConstants.btnGapX, + // browseBtn.getBounds().y + browseBtn.getBounds().height+ + // NsharpConstants.btnGapY, + // NsharpConstants.btnWidth,NsharpConstants.btnHeight); + timeBtn.setFont(newFont); + timeBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (timeBtn.getSelection()) + timeLimit = true; + else + timeLimit = false; + + // refresh sounding list if file type is selected already + if (currentSndType == NcSoundingProfile.ObsSndType.NCUAIR + || currentSndType == NcSoundingProfile.ObsSndType.BUFRUA) { + createObsvdSndUairList(); + } + + } + }); + rawBtn = new Button(midGp, SWT.CHECK | SWT.BORDER); + rawBtn.setText("raw data"); + rawBtn.setEnabled(true); + rawBtn.setBounds(timeBtn.getBounds().x + timeBtn.getBounds().width, + timeBtn.getBounds().y, timeBtn.getBounds().width, + timeBtn.getBounds().height); + rawBtn.setFont(newFont); + rawBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (rawBtn.getSelection()) + rawData = true; + else + rawData = false; + ; + } + }); + // create file widget list + sndTimeListGp = new Group(parent, SWT.SHADOW_ETCHED_IN); + sndTimeListGp.setText("Sounding Times:"); + sndTimeListGp.setFont(newFont); + sndTimeList = new org.eclipse.swt.widgets.List(sndTimeListGp, + SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); + sndTimeList.setBounds(btnGp.getBounds().x + NsharpConstants.btnGapX, + sndTimeListGp.getBounds().y + NsharpConstants.labelGap, + NsharpConstants.listWidth, NsharpConstants.listHeight * 7); + sndTimeList.setFont(newFont); + + // create a selection listener to handle user's selection on list + sndTimeList.addListener(SWT.Selection, new Listener() { + // private String selectedSndTime=null; + public void handleEvent(Event e) { + handleSndTimeSelection(); + } + }); + + if (currentSndType == NcSoundingProfile.ObsSndType.NCUAIR + || currentSndType == NcSoundingProfile.ObsSndType.BUFRUA) { + if (currentSndType == NcSoundingProfile.ObsSndType.NCUAIR) + uairBtn.setSelection(true); + else + bufruaBtn.setSelection(true); + createObsvdSndUairList(); + selectedTimeList = ldDia.getObsSelectedTimeList(); + Object[] selTimeObjectArray = selectedTimeList.toArray(); + String[] selTimeStringArray = Arrays.copyOf(selTimeObjectArray, + selTimeObjectArray.length, String[].class); + sndTimeList.setSelection(selTimeStringArray); + handleSndTimeSelection(); + } + } + + public void cleanup() { + if (sndTimeList != null) { + sndTimeList.removeListener(SWT.Selection, + sndTimeList.getListeners(SWT.Selection)[0]); + sndTimeList.dispose(); + sndTimeList = null; + } + if (sndTimeListGp != null) { + sndTimeListGp.dispose(); + sndTimeListGp = null; + } + if (timeBtn != null) { + timeBtn.removeListener(SWT.MouseUp, + timeBtn.getListeners(SWT.MouseUp)[0]); + timeBtn.dispose(); + timeBtn = null; + } + if (rawBtn != null) { + rawBtn.removeListener(SWT.MouseUp, + rawBtn.getListeners(SWT.MouseUp)[0]); + rawBtn.dispose(); + rawBtn = null; + } + if (midGp != null) { + midGp.dispose(); + midGp = null; + } + /* + * if(browseBtn != null){ browseBtn.removeListener(SWT.MouseUp, + * browseBtn.getListeners(SWT.MouseUp)[0]); browseBtn.dispose(); + * browseBtn = null; } + * + * + * if(tamBtn != null){ tamBtn.removeListener(SWT.MouseUp, + * tamBtn.getListeners(SWT.MouseUp)[0]); tamBtn.dispose(); tamBtn = + * null; } + */ + if (bufruaBtn != null) { + bufruaBtn.removeListener(SWT.MouseUp, + bufruaBtn.getListeners(SWT.MouseUp)[0]); + bufruaBtn.dispose(); + bufruaBtn = null; + } + if (uairBtn != null) { + uairBtn.removeListener(SWT.MouseUp, + uairBtn.getListeners(SWT.MouseUp)[0]); + uairBtn.dispose(); + uairBtn = null; + } + if (btnGp != null) { + btnGp.dispose(); + btnGp = null; + } + /* + * if(newTabBtn != null){ newTabBtn.removeListener(SWT.MouseUp, + * newTabBtn.getListeners(SWT.MouseUp)[0]); newTabBtn.dispose(); + * newTabBtn = null; } + */ + NsharpLoadDialog ldDia = NsharpLoadDialog.getAccess(); + ldDia.cleanSndTypeList(); + if (topGp != null) { + topGp.dispose(); + topGp = null; + } + } +} diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpPaletteWindow.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpPaletteWindow.java index 39b2f671ef..390883ca95 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpPaletteWindow.java +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpPaletteWindow.java @@ -52,7 +52,6 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; @@ -80,17 +79,23 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, protected Button loadBtn, unloadBtn, overlayBtn, interpBtn, dataEditBtn, compareStnBtn, compareSndBtn, compareTmBtn, graphEditBtn, graphModeBtnSkew, graphModeBtnIcing, graphModeBtnTurb, - effBulkShearBtn, stpBtn, shipBtn, winterBtn, fireBtn, hailBtn, - sarsBtn, cfgBtn; + graphModeBtnHodo, effBulkShearBtn, stpBtn, shipBtn, winterBtn, + fireBtn, hailBtn, sarsBtn, cfgBtn; private Shell shell; - private Label spcGplbl; + // private Label spcGplbl; private Composite parent; private Group spcGp; + private Group awcGp, d2dliteAwcGp; + + private Group insetGp; + + private Button nextInsetBtn, prevInsetBtn; + private boolean overlayIsOn = false, compareStnIsOn = false, compareSndIsOn = false, compareTmIsOn = false; @@ -145,6 +150,8 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, private boolean spcGpCreated = false; + private boolean awcGpCreated = false; + public static NsharpPaletteWindow getInstance() { if (VizPerspectiveListener.getCurrentPerspectiveManager() != null) { if (VizPerspectiveListener.getCurrentPerspectiveManager() @@ -167,7 +174,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, boolean compareStnIsOn, boolean compareTmIsOn, boolean editGraphOn, boolean compareSndIsOn) { // System.out.println("restorePaletteWindow "+ this.toString()); - updateSpcGraphBtn(paneConfigurationName); + updateSpecialGraphBtn(paneConfigurationName); this.currentGraphMode = currentGraphMode; this.interpolateIsOn = interpolateIsOn; this.overlayIsOn = overlayIsOn; @@ -196,8 +203,8 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, compareSndBtn.setText(COMP_SND_OFF); compareStnBtn.setText(COMP_STN_OFF); if (interpolateIsOn) { - //TTR829 graphEditBtn.setEnabled(false); - //dataEditBtn.setEnabled(false); + // TTR829 graphEditBtn.setEnabled(false); + // dataEditBtn.setEnabled(false); compareTmBtn.setEnabled(false); compareSndBtn.setEnabled(false); compareStnBtn.setEnabled(false); @@ -213,6 +220,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, interpBtn.setEnabled(false); graphModeBtnIcing.setEnabled(false); graphModeBtnTurb.setEnabled(false); + unloadBtn.setEnabled(false); // FixMark:nearByStnCompSnd } else if (compareStnIsOn) { compareStnBtn.setText(COMP_STN_ON); graphEditBtn.setEnabled(false); @@ -223,6 +231,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, interpBtn.setEnabled(false); graphModeBtnIcing.setEnabled(false); graphModeBtnTurb.setEnabled(false); + unloadBtn.setEnabled(false); // FixMark:nearByStnCompSnd } else if (compareSndIsOn) { compareSndBtn.setText(COMP_SND_ON); graphEditBtn.setEnabled(false); @@ -233,6 +242,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, interpBtn.setEnabled(false); graphModeBtnIcing.setEnabled(false); graphModeBtnTurb.setEnabled(false); + unloadBtn.setEnabled(false); // FixMark:nearByStnCompSnd } else if (compareTmIsOn) { compareTmBtn.setText(COMP_TM_ON); compareSndBtn.setEnabled(false); @@ -243,6 +253,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, interpBtn.setEnabled(false); graphModeBtnIcing.setEnabled(false); graphModeBtnTurb.setEnabled(false); + unloadBtn.setEnabled(false); // FixMark:nearByStnCompSnd } else if (editGraphOn) { graphEditBtn.setText(EDIT_GRAPH_ON); dataEditBtn.setEnabled(false); @@ -253,6 +264,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, interpBtn.setEnabled(false); graphModeBtnIcing.setEnabled(false); graphModeBtnTurb.setEnabled(false); + unloadBtn.setEnabled(false); // FixMark:nearByStnCompSnd } } else if (currentGraphMode == NsharpConstants.GRAPH_TURB) { @@ -365,14 +377,13 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, public NsharpPaletteWindow() { super(); instance = this; - boolean imD2d=false; //fixMark:NcInventory + boolean imD2d = false; // fixMark:NcInventory if (VizPerspectiveListener.getCurrentPerspectiveManager() != null) { if (VizPerspectiveListener.getCurrentPerspectiveManager() - .getPerspectiveId().equals(D2D5Pane.ID_PERSPECTIVE)){ + .getPerspectiveId().equals(D2D5Pane.ID_PERSPECTIVE)) { d2dInstance = this; - imD2d = true;//fixMark:NcInventory - } - else if (VizPerspectiveListener.getCurrentPerspectiveManager() + imD2d = true;// fixMark:NcInventory + } else if (VizPerspectiveListener.getCurrentPerspectiveManager() .getPerspectiveId() .equals(NmapCommon.NatlCntrsPerspectiveID)) ncpInstance = this; @@ -390,44 +401,55 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, NsharpGraphProperty graphConfigProperty = configStore .getGraphProperty(); paneConfigurationName = graphConfigProperty.getPaneConfigurationName(); - if(!imD2d){//fixMark:NcInventory - for( int a=1 ; a<=5 ; a++ ) { - if( NsharpGridInventory.getInstance().isInitialized() ) { - break; - } + if (!imD2d) {// fixMark:NcInventory + for (int a = 1; a <= 2; a++) { + if (NsharpGridInventory.getInstance().isInitialized()) { + break; + } - try { - NsharpGridInventory.getInstance().initialize(); - } - catch (VizException e) { - // TODO : could call createInventory() here but for now this will be considered - // an error since the grid inventory should/must be on the server. - System.out.println("NsharpGridInventory initialize attempt #"+a+" failed"); + try { + NsharpGridInventory.getInstance().initialize(); + } catch (VizException e) { + // TODO : could call createInventory() here but for now this + // will be considered + // an error since the grid inventory should/must be on the + // server. + System.out + .println("NsharpGridInventory initialize attempt #" + + a + " failed"); - try { Thread.sleep(a*500); } catch (InterruptedException e1) { } - } - } + try { + Thread.sleep(a * 500); + } catch (InterruptedException e1) { + } + } + } - if( !NsharpGridInventory.getInstance().isInitialized() ) { - // TODO : change to a confirm to create an inventory. - MessageDialog errDlg = new MessageDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error", null, - "Unable to find an Inventory to support Grid Model times. Please wait while one"+ - " is created.", MessageDialog.ERROR, - new String[] { "OK" }, 0); - errDlg.open(); + if (!NsharpGridInventory.getInstance().isInitialized()) { + // TODO : change to a confirm to create an inventory. + MessageDialog errDlg = new MessageDialog( + PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getShell(), + "Error", + null, + "Unable to find an Inventory to support Grid Model times. Please wait while one" + + " is created.", MessageDialog.ERROR, + new String[] { "OK" }, 0); + errDlg.open(); - try { - NsharpGridInventory.createInventory(); - } - catch (VizException e) { - errDlg = new MessageDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Error", null, - "Error creating Inventory to support Grid Model times.", MessageDialog.ERROR, - new String[] { "OK" }, 0); - errDlg.open(); - } - } + try { + NsharpGridInventory.createInventory(); + } catch (VizException e) { + errDlg = new MessageDialog( + PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getShell(), + "Error", + null, + "Error creating Inventory to support Grid Model times.", + MessageDialog.ERROR, new String[] { "OK" }, 0); + errDlg.open(); + } + } } } @@ -572,7 +594,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, loadBtn = new Button(textModeGp, SWT.PUSH); loadBtn.setFont(newFont); - loadBtn.setText(" Load "); + loadBtn.setText(" Load "); loadBtn.setEnabled(true); // loadBtn.setSize(btnWidth,pushbtnHeight); loadBtn.addListener(SWT.MouseUp, new Listener() { @@ -591,7 +613,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, unloadBtn = new Button(textModeGp, SWT.PUSH); unloadBtn.setFont(newFont); - unloadBtn.setText(" UnLoad "); + unloadBtn.setText(" UnLoad "); unloadBtn.setEnabled(true); // loadBtn.setSize(btnWidth,pushbtnHeight); unloadBtn.addListener(SWT.MouseUp, new Listener() { @@ -614,7 +636,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, // Push buttons for SAVE Button saveBtn = new Button(textModeGp, SWT.PUSH); saveBtn.setFont(newFont); - saveBtn.setText(" Save "); + saveBtn.setText(" Save "); saveBtn.setEnabled(true); // saveBtn.setSize(btnWidth,pushbtnHeight); saveBtn.addListener(SWT.MouseUp, new Listener() { @@ -631,7 +653,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, // Push buttons for CONFIGURE cfgBtn = new Button(textModeGp, SWT.PUSH); cfgBtn.setFont(newFont); - cfgBtn.setText(" Configure "); + cfgBtn.setText(" Configure "); cfgBtn.setEnabled(true); // cfgBtn.setSize(btnWidth,pushbtnHeight); cfgBtn.addListener(SWT.MouseUp, new Listener() { @@ -652,7 +674,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, Button resetBtn = new Button(textModeGp, SWT.PUSH); resetBtn.setFont(newFont); - resetBtn.setText(" Reset "); + resetBtn.setText(" Reset "); resetBtn.setEnabled(true); resetBtn.addListener(SWT.MouseUp, new Listener() { public void handleEvent(Event event) { @@ -716,7 +738,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, }); Button resetGfBtn = new Button(textModeGp, SWT.PUSH); resetGfBtn.setFont(newFont); - resetGfBtn.setText("Reset Display"); + resetGfBtn.setText("ResetDisplay"); resetGfBtn.setEnabled(true); resetGfBtn.addListener(SWT.MouseUp, new Listener() { public void handleEvent(Event event) { @@ -727,7 +749,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, Button parcelBtn = new Button(textModeGp, SWT.PUSH); parcelBtn.setFont(newFont); - parcelBtn.setText(" Parcel "); + parcelBtn.setText(" Parcel "); parcelBtn.setEnabled(true); // parcelBtn.setSize(btnWidth,pushbtnHeight); parcelBtn.addListener(SWT.MouseUp, new Listener() { @@ -746,11 +768,33 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, } } }); + // start d2dlite + Group dataGp = new Group(textModeGp, SWT.SHADOW_ETCHED_IN); + dataGp.setLayout(new RowLayout(SWT.HORIZONTAL)); + // Push buttons for Prev PAGE info + Button prevpageBtn = new Button(dataGp, SWT.PUSH); + prevpageBtn.setFont(newFont); + // prevpageBtn.setText(" Prev Data "); + prevpageBtn.setText("PvDt"); + prevpageBtn.setEnabled(true); + prevpageBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getShell(); + if (checkLoadedData()) { + NsharpResourceHandler rsc = getRscHandler(); + if (rsc != null) { + rsc.setPrevTextChapter(); + rsc.refreshPane(); + } + } + } + }); // Push buttons for NEXT PAGE info - Button nextpageBtn = new Button(textModeGp, SWT.PUSH); + Button nextpageBtn = new Button(dataGp, SWT.PUSH); nextpageBtn.setFont(newFont); - nextpageBtn.setText(" Next Data "); + nextpageBtn.setText("NxDt"); nextpageBtn.setEnabled(true); nextpageBtn.addListener(SWT.MouseUp, new Listener() { public void handleEvent(Event event) { @@ -765,25 +809,45 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, } } }); - - // Push buttons for NEXT INSET PAGE info - Button nextInsetBtn = new Button(textModeGp, SWT.PUSH); - nextInsetBtn.setFont(newFont); - nextInsetBtn.setText(" Next Inset "); - nextInsetBtn.setEnabled(true); - nextInsetBtn.addListener(SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() - .getShell(); - if (checkLoadedData()) { - NsharpResourceHandler rsc = getRscHandler(); - if (rsc != null) { - rsc.setNextInsetPage(); - rsc.refreshPane(); - } - } - } - }); + // Group insetGp = new Group(textModeGp, SWT.SHADOW_ETCHED_IN); + // insetGp.setLayout(new RowLayout(SWT.HORIZONTAL)); + // // Push buttons for NEXT INSET PAGE info + // Button nextInsetBtn = new Button(insetGp, SWT.PUSH); + // nextInsetBtn.setFont(newFont); + // nextInsetBtn.setText("NxIns"); + // nextInsetBtn.setEnabled(true); + // nextInsetBtn.addListener(SWT.MouseUp, new Listener() { + // public void handleEvent(Event event) { + // shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() + // .getShell(); + // if (checkLoadedData()) { + // NsharpResourceHandler rsc = getRscHandler(); + // if (rsc != null) { + // rsc.setNextInsetPage(); + // rsc.refreshPane(); + // } + // } + // } + // }); + // // Push buttons for NEXT INSET PAGE info + // Button prevInsetBtn = new Button(insetGp, SWT.PUSH); + // prevInsetBtn.setFont(newFont); + // prevInsetBtn.setText("PvIns"); + // prevInsetBtn.setEnabled(true); + // prevInsetBtn.addListener(SWT.MouseUp, new Listener() { + // public void handleEvent(Event event) { + // shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() + // .getShell(); + // if (checkLoadedData()) { + // NsharpResourceHandler rsc = getRscHandler(); + // if (rsc != null) { + // rsc.setPrevInsetPage(); + // rsc.refreshPane(); + // } + // } + // } + // }); + // end d2dlite // Push buttons for interpolate interpBtn = new Button(textModeGp, SWT.PUSH); @@ -802,8 +866,8 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, if (interpolateIsOn == false) { interpolateIsOn = true; interpBtn.setText(INTP_ON); - //TTR829 graphEditBtn.setEnabled(false); - //dataEditBtn.setEnabled(false); + // TTR829 graphEditBtn.setEnabled(false); + // dataEditBtn.setEnabled(false); compareTmBtn.setEnabled(false); compareSndBtn.setEnabled(false); compareStnBtn.setEnabled(false); @@ -811,8 +875,9 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, } else { interpolateIsOn = false; interpBtn.setText(INTP_OFF); - if (currentGraphMode == NsharpConstants.GRAPH_SKEWT && editGraphOn == false) { - //TTR829 graphEditBtn.setEnabled(true); + if ((currentGraphMode == NsharpConstants.GRAPH_SKEWT || currentGraphMode == NsharpConstants.GRAPH_HODO) + && editGraphOn == false) { + // TTR829 graphEditBtn.setEnabled(true); dataEditBtn.setEnabled(true); compareTmBtn.setEnabled(true); compareSndBtn.setEnabled(true); @@ -880,6 +945,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, graphModeBtnIcing.setEnabled(false); interpBtn.setEnabled(false); cfgBtn.setEnabled(false); + unloadBtn.setEnabled(false);// FixMark:nearByStnCompSnd } else { overlayIsOn = false; overlayBtn.setText(OVLY_OFF); @@ -892,6 +958,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, graphModeBtnIcing.setEnabled(true); interpBtn.setEnabled(true); cfgBtn.setEnabled(true); + unloadBtn.setEnabled(true);// FixMark:nearByStnCompSnd } NsharpResourceHandler rsc = getRscHandler(); if (rsc != null) { @@ -934,6 +1001,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, graphModeBtnIcing.setEnabled(false); interpBtn.setEnabled(false); cfgBtn.setEnabled(false); + unloadBtn.setEnabled(false);// FixMark:nearByStnCompSnd } else { compareStnIsOn = false; compareStnBtn.setText(COMP_STN_OFF); @@ -946,6 +1014,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, graphModeBtnIcing.setEnabled(true); interpBtn.setEnabled(true); cfgBtn.setEnabled(true); + unloadBtn.setEnabled(true);// FixMark:nearByStnCompSnd } NsharpResourceHandler rsc = getRscHandler(); if (rsc != null) { @@ -955,6 +1024,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, } }); + // Push buttons for CompByTm info compareTmBtn = new Button(textModeGp, SWT.PUSH); compareTmBtn.setFont(newFont); @@ -989,6 +1059,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, graphModeBtnIcing.setEnabled(false); interpBtn.setEnabled(false); cfgBtn.setEnabled(false); + unloadBtn.setEnabled(false);// FixMark:nearByStnCompSnd } else { compareTmIsOn = false; compareTmBtn.setText(COMP_TM_OFF); @@ -1001,6 +1072,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, graphModeBtnIcing.setEnabled(true); interpBtn.setEnabled(true); cfgBtn.setEnabled(true); + unloadBtn.setEnabled(true);// FixMark:nearByStnCompSnd } NsharpResourceHandler rsc = getRscHandler(); if (rsc != null) { @@ -1043,6 +1115,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, graphModeBtnIcing.setEnabled(false); interpBtn.setEnabled(false); cfgBtn.setEnabled(false); + unloadBtn.setEnabled(false);// FixMark:nearByStnCompSnd } else { compareSndIsOn = false; compareSndBtn.setText(COMP_SND_OFF); @@ -1055,6 +1128,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, graphModeBtnIcing.setEnabled(true); interpBtn.setEnabled(true); cfgBtn.setEnabled(true); + unloadBtn.setEnabled(true);// FixMark:nearByStnCompSnd } NsharpResourceHandler rsc = getRscHandler(); if (rsc != null) { @@ -1067,8 +1141,8 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, dataEditBtn = new Button(textModeGp, SWT.PUSH); dataEditBtn.setFont(newFont); - dataEditBtn.setText(" Edit Data "); - if (interpolateIsOn || editGraphOn) + dataEditBtn.setText(" EditData "); + if (/* interpolateIsOn || */editGraphOn) dataEditBtn.setEnabled(false); else dataEditBtn.setEnabled(true); @@ -1104,15 +1178,16 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, if (editGraphOn) { editGraphOn = false; graphEditBtn.setText(EDIT_GRAPH_OFF); - if(interpolateIsOn == false){ //TTR829 - graphModeBtnIcing.setEnabled(true); - graphModeBtnTurb.setEnabled(true); - dataEditBtn.setEnabled(true); - //interpBtn.setEnabled(true);TTR829 - compareTmBtn.setEnabled(true); - compareSndBtn.setEnabled(true); - compareStnBtn.setEnabled(true); - overlayBtn.setEnabled(true); + if (interpolateIsOn == false) { // TTR829 + graphModeBtnIcing.setEnabled(true); + graphModeBtnTurb.setEnabled(true); + dataEditBtn.setEnabled(true); + // interpBtn.setEnabled(true);TTR829 + compareTmBtn.setEnabled(true); + compareSndBtn.setEnabled(true); + compareStnBtn.setEnabled(true); + overlayBtn.setEnabled(true); + unloadBtn.setEnabled(true);// FixMark:nearByStnCompSnd } } else { editGraphOn = true; @@ -1120,11 +1195,12 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, graphModeBtnIcing.setEnabled(false); graphModeBtnTurb.setEnabled(false); dataEditBtn.setEnabled(false); - //interpBtn.setEnabled(false); + // interpBtn.setEnabled(false); compareTmBtn.setEnabled(false); compareSndBtn.setEnabled(false); compareStnBtn.setEnabled(false); overlayBtn.setEnabled(false); + unloadBtn.setEnabled(false);// FixMark:nearByStnCompSnd } NsharpResourceHandler rsc = getRscHandler(); if (rsc != null) { @@ -1148,7 +1224,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, // Push buttons for show text info Button showtextBtn = new Button(textModeGp, SWT.PUSH); showtextBtn.setFont(newFont); - showtextBtn.setText(" Show Text "); + showtextBtn.setText(" ShowText "); showtextBtn.setEnabled(true); showtextBtn.addListener(SWT.MouseUp, new Listener() { public void handleEvent(Event event) { @@ -1162,119 +1238,171 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, } } }); - Group graphModeGp = new Group(textModeGp, SWT.SHADOW_ETCHED_IN); - graphModeGp.setLayout(new RowLayout(SWT.HORIZONTAL));// new GridLayout( - // 2, false ) ); - - // Push buttons for graphMode - graphModeBtnSkew = new Button(graphModeGp, SWT.PUSH); - graphModeBtnSkew.setFont(newFont); - graphModeBtnSkew.setText("S"); - graphModeBtnSkew.setEnabled(true); - // colorButtonOriginalBg= graphModeBtnSkew.getBackground(); - rscHandler = getRscHandler(); - if (rscHandler != null) { - currentGraphMode = rscHandler.getCurrentGraphMode(); - } - graphModeBtnSkew.addListener(SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - if (currentGraphMode != NsharpConstants.GRAPH_SKEWT) { - currentGraphMode = NsharpConstants.GRAPH_SKEWT; - graphModeBtnSkew.setBackground(colorBlue); - graphModeBtnTurb.setBackground(colorGrey); - graphModeBtnIcing.setBackground(colorGrey); - if (!interpolateIsOn) { - graphEditBtn.setEnabled(true); - dataEditBtn.setEnabled(true); - compareTmBtn.setEnabled(true); - compareSndBtn.setEnabled(true); - compareStnBtn.setEnabled(true); - overlayBtn.setEnabled(true); - } else { - graphEditBtn.setEnabled(false); - dataEditBtn.setEnabled(false); - compareTmBtn.setEnabled(false); - compareSndBtn.setEnabled(false); - compareStnBtn.setEnabled(false); - overlayBtn.setEnabled(false); - } - NsharpResourceHandler rsc = getRscHandler(); - if (rsc != null) { - rsc.setCurrentGraphMode(currentGraphMode); - // rsc.getSkewtPaneRsc().handleResize(); - } - - } - } - }); - graphModeBtnTurb = new Button(graphModeGp, SWT.PUSH); - graphModeBtnTurb.setFont(newFont); - graphModeBtnTurb.setText("T"); - graphModeBtnTurb.setEnabled(true); - graphModeBtnTurb.addListener(SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - if (currentGraphMode != NsharpConstants.GRAPH_TURB) { - currentGraphMode = NsharpConstants.GRAPH_TURB; - graphModeBtnTurb.setBackground(colorBlue); - graphModeBtnSkew.setBackground(colorGrey); - graphModeBtnIcing.setBackground(colorGrey); - graphEditBtn.setEnabled(false); - dataEditBtn.setEnabled(false); - compareTmBtn.setEnabled(false); - compareSndBtn.setEnabled(false); - compareStnBtn.setEnabled(false); - overlayBtn.setEnabled(false); - NsharpResourceHandler rsc = getRscHandler(); - if (rsc != null) { - rsc.setCurrentGraphMode(currentGraphMode); - rsc.getSkewtPaneRsc().handleResize(); - } - } - } - }); - graphModeBtnIcing = new Button(graphModeGp, SWT.PUSH); - graphModeBtnIcing.setFont(newFont); - graphModeBtnIcing.setText("I"); - graphModeBtnIcing.setEnabled(true); - graphModeBtnIcing.addListener(SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - if (currentGraphMode != NsharpConstants.GRAPH_ICING) { - currentGraphMode = NsharpConstants.GRAPH_ICING; - graphModeBtnIcing.setBackground(colorBlue); - graphModeBtnSkew.setBackground(colorGrey); - graphModeBtnTurb.setBackground(colorGrey); - graphEditBtn.setEnabled(false); - dataEditBtn.setEnabled(false); - compareTmBtn.setEnabled(false); - compareSndBtn.setEnabled(false); - compareStnBtn.setEnabled(false); - overlayBtn.setEnabled(false); - NsharpResourceHandler rsc = getRscHandler(); - if (rsc != null) { - rsc.setCurrentGraphMode(currentGraphMode); - rsc.getSkewtPaneRsc().handleResize(); - } - } - } - }); - if (currentGraphMode == NsharpConstants.GRAPH_SKEWT) { - graphModeBtnSkew.setBackground(colorBlue); - graphModeBtnTurb.setBackground(colorGrey); - graphModeBtnIcing.setBackground(colorGrey); - } else if (currentGraphMode == NsharpConstants.GRAPH_TURB) { - graphModeBtnTurb.setBackground(colorBlue); - graphModeBtnSkew.setBackground(colorGrey); - graphModeBtnIcing.setBackground(colorGrey); - } else if (currentGraphMode == NsharpConstants.GRAPH_ICING) { - graphModeBtnIcing.setBackground(colorBlue); - graphModeBtnSkew.setBackground(colorGrey); - graphModeBtnTurb.setBackground(colorGrey); - } + // Group graphModeGp = new Group(textModeGp, SWT.SHADOW_ETCHED_IN); + // graphModeGp.setLayout(new RowLayout(SWT.HORIZONTAL));// new + // GridLayout( + // // 2, false ) ); + // + // // Push buttons for graphMode + // graphModeBtnSkew = new Button(graphModeGp, SWT.PUSH); + // graphModeBtnSkew.setFont(newFont); + // graphModeBtnSkew.setText("S"); + // graphModeBtnSkew.setEnabled(true); + // // colorButtonOriginalBg= graphModeBtnSkew.getBackground(); + // rscHandler = getRscHandler(); + // if (rscHandler != null) { + // currentGraphMode = rscHandler.getCurrentGraphMode(); + // } + // graphModeBtnSkew.addListener(SWT.MouseUp, new Listener() { + // public void handleEvent(Event event) { + // if (currentGraphMode != NsharpConstants.GRAPH_SKEWT) { + // currentGraphMode = NsharpConstants.GRAPH_SKEWT; + // graphModeBtnSkew.setBackground(colorBlue); + // graphModeBtnHodo.setBackground(colorGrey); + // graphModeBtnTurb.setBackground(colorGrey); + // graphModeBtnIcing.setBackground(colorGrey); + // if (!interpolateIsOn) { + // graphEditBtn.setEnabled(true); + // dataEditBtn.setEnabled(true); + // compareTmBtn.setEnabled(true); + // compareSndBtn.setEnabled(true); + // compareStnBtn.setEnabled(true); + // overlayBtn.setEnabled(true); + // } else { + // graphEditBtn.setEnabled(false); + // dataEditBtn.setEnabled(false); + // compareTmBtn.setEnabled(false); + // compareSndBtn.setEnabled(false); + // compareStnBtn.setEnabled(false); + // overlayBtn.setEnabled(false); + // } + // NsharpResourceHandler rsc = getRscHandler(); + // if (rsc != null) { + // rsc.setCurrentGraphMode(currentGraphMode); + // // rsc.getSkewtPaneRsc().handleResize(); + // } + // + // } + // } + // }); + // + // if + // (paneConfigurationName.equals(NsharpConstants.PANE_LITE_D2D_CFG_STR)) + // { + // graphModeBtnHodo = new Button(graphModeGp, SWT.PUSH); + // graphModeBtnHodo.setFont(newFont); + // graphModeBtnHodo.setText("H"); + // graphModeBtnHodo.setEnabled(true); + // graphModeBtnHodo.addListener(SWT.MouseUp, new Listener() { + // public void handleEvent(Event event) { + // if (currentGraphMode != NsharpConstants.GRAPH_HODO) { + // currentGraphMode = NsharpConstants.GRAPH_HODO; + // graphModeBtnHodo.setBackground(colorBlue); + // graphModeBtnTurb.setBackground(colorGrey); + // graphModeBtnSkew.setBackground(colorGrey); + // graphModeBtnIcing.setBackground(colorGrey); + // if (!interpolateIsOn) { + // graphEditBtn.setEnabled(true); + // dataEditBtn.setEnabled(true); + // compareTmBtn.setEnabled(true); + // compareSndBtn.setEnabled(true); + // compareStnBtn.setEnabled(true); + // overlayBtn.setEnabled(true); + // } else { + // graphEditBtn.setEnabled(false); + // dataEditBtn.setEnabled(false); + // compareTmBtn.setEnabled(false); + // compareSndBtn.setEnabled(false); + // compareStnBtn.setEnabled(false); + // overlayBtn.setEnabled(false); + // } + // NsharpResourceHandler rsc = getRscHandler(); + // if (rsc != null) { + // rsc.setCurrentGraphMode(currentGraphMode); + // // rsc.getSkewtPaneRsc().handleResize(); + // } + // } + // } + // }); + // } + // graphModeBtnTurb = new Button(graphModeGp, SWT.PUSH); + // graphModeBtnTurb.setFont(newFont); + // graphModeBtnTurb.setText("T"); + // graphModeBtnTurb.setEnabled(true); + // graphModeBtnTurb.addListener(SWT.MouseUp, new Listener() { + // public void handleEvent(Event event) { + // if (currentGraphMode != NsharpConstants.GRAPH_TURB) { + // currentGraphMode = NsharpConstants.GRAPH_TURB; + // graphModeBtnTurb.setBackground(colorBlue); + // graphModeBtnHodo.setBackground(colorGrey); + // graphModeBtnSkew.setBackground(colorGrey); + // graphModeBtnIcing.setBackground(colorGrey); + // graphEditBtn.setEnabled(false); + // dataEditBtn.setEnabled(false); + // compareTmBtn.setEnabled(false); + // compareSndBtn.setEnabled(false); + // compareStnBtn.setEnabled(false); + // overlayBtn.setEnabled(false); + // NsharpResourceHandler rsc = getRscHandler(); + // if (rsc != null) { + // rsc.setCurrentGraphMode(currentGraphMode); + // // rsc.getSkewtPaneRsc().handleResize(); + // } + // } + // } + // }); + // graphModeBtnIcing = new Button(graphModeGp, SWT.PUSH); + // graphModeBtnIcing.setFont(newFont); + // graphModeBtnIcing.setText("I"); + // graphModeBtnIcing.setEnabled(true); + // graphModeBtnIcing.addListener(SWT.MouseUp, new Listener() { + // public void handleEvent(Event event) { + // if (currentGraphMode != NsharpConstants.GRAPH_ICING) { + // currentGraphMode = NsharpConstants.GRAPH_ICING; + // graphModeBtnIcing.setBackground(colorBlue); + // graphModeBtnHodo.setBackground(colorGrey); + // graphModeBtnSkew.setBackground(colorGrey); + // graphModeBtnTurb.setBackground(colorGrey); + // graphEditBtn.setEnabled(false); + // dataEditBtn.setEnabled(false); + // compareTmBtn.setEnabled(false); + // compareSndBtn.setEnabled(false); + // compareStnBtn.setEnabled(false); + // overlayBtn.setEnabled(false); + // NsharpResourceHandler rsc = getRscHandler(); + // if (rsc != null) { + // rsc.setCurrentGraphMode(currentGraphMode); + // // rsc.getSkewtPaneRsc().handleResize(); + // } + // } + // } + // }); + // if (currentGraphMode == NsharpConstants.GRAPH_SKEWT) { + // graphModeBtnSkew.setBackground(colorBlue); + // graphModeBtnHodo.setBackground(colorGrey); + // graphModeBtnTurb.setBackground(colorGrey); + // graphModeBtnIcing.setBackground(colorGrey); + // } else if (currentGraphMode == NsharpConstants.GRAPH_HODO) { + // graphModeBtnHodo.setBackground(colorBlue); + // graphModeBtnTurb.setBackground(colorGrey); + // graphModeBtnSkew.setBackground(colorGrey); + // graphModeBtnIcing.setBackground(colorGrey); + // } else if (currentGraphMode == NsharpConstants.GRAPH_TURB) { + // graphModeBtnTurb.setBackground(colorBlue); + // graphModeBtnHodo.setBackground(colorGrey); + // graphModeBtnSkew.setBackground(colorGrey); + // graphModeBtnIcing.setBackground(colorGrey); + // } else if (currentGraphMode == NsharpConstants.GRAPH_ICING) { + // graphModeBtnIcing.setBackground(colorBlue); + // graphModeBtnHodo.setBackground(colorGrey); + // graphModeBtnSkew.setBackground(colorGrey); + // graphModeBtnTurb.setBackground(colorGrey); + // } // Push buttons for Print Button printBtn = new Button(textModeGp, SWT.PUSH); printBtn.setFont(newFont); - printBtn.setText(" Print "); + printBtn.setText(" Print "); printBtn.setEnabled(true); printBtn.addListener(SWT.MouseUp, new Listener() { public void handleEvent(Event event) { @@ -1287,8 +1415,15 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, } }); - if (paneConfigurationName.equals(NsharpConstants.PANE_SPCWS_CFG_STR)) + if (paneConfigurationName.equals(NsharpConstants.PANE_LITE_D2D_CFG_STR)) { + createD2dLiteAwcGp(); + } else { + createAwcGp(); + } + + if (paneConfigurationName.equals(NsharpConstants.PANE_SPCWS_CFG_STR)) { createSPCGp(); + } if (rscHandler != null) { restorePaletteWindow(paneConfigurationName, @@ -1306,13 +1441,53 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, spcGp = new Group(parent, SWT.SHADOW_OUT); spcGp.setLayout(new RowLayout(SWT.HORIZONTAL)); spcGp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - spcGplbl = new Label(spcGp, SWT.NO); - spcGplbl.setText("SPC Graphs"); - if (paneConfigurationName.equals(NsharpConstants.PANE_SPCWS_CFG_STR)) { - spcGplbl.setEnabled(true); - } else { - spcGplbl.setEnabled(false); - } + // spcGplbl = new Label(spcGp, SWT.NO); + // spcGplbl.setText("SPC Graphs"); + // if (paneConfigurationName.equals(NsharpConstants.PANE_SPCWS_CFG_STR)) + // { + // spcGplbl.setEnabled(true); + // } else { + // spcGplbl.setEnabled(false); + // } + insetGp = new Group(spcGp, SWT.SHADOW_ETCHED_IN); + insetGp.setLayout(new RowLayout(SWT.HORIZONTAL)); + + // Push buttons for NEXT INSET PAGE info + prevInsetBtn = new Button(insetGp, SWT.PUSH); + prevInsetBtn.setFont(newFont); + prevInsetBtn.setText("PvIn"); + prevInsetBtn.setEnabled(true); + prevInsetBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getShell(); + if (checkLoadedData()) { + NsharpResourceHandler rsc = getRscHandler(); + if (rsc != null) { + rsc.setPrevInsetPage(); + rsc.refreshPane(); + } + } + } + }); + // Push buttons for NEXT INSET PAGE info + nextInsetBtn = new Button(insetGp, SWT.PUSH); + nextInsetBtn.setFont(newFont); + nextInsetBtn.setText("NxIn"); + nextInsetBtn.setEnabled(true); + nextInsetBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow() + .getShell(); + if (checkLoadedData()) { + NsharpResourceHandler rsc = getRscHandler(); + if (rsc != null) { + rsc.setNextInsetPage(); + rsc.refreshPane(); + } + } + } + }); effBulkShearBtn = new Button(spcGp, SWT.PUSH); effBulkShearBtn.setFont(newFont); effBulkShearBtn.setText("EBS Stats "); @@ -1447,7 +1622,10 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, } private void disposeSpcGp() { - spcGplbl.dispose(); + // spcGplbl.dispose(); + nextInsetBtn.dispose(); + prevInsetBtn.dispose(); + insetGp.dispose(); effBulkShearBtn.dispose(); stpBtn.dispose(); shipBtn.dispose(); @@ -1457,7 +1635,10 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, sarsBtn.dispose(); spcGp.dispose(); - spcGplbl = null; + // spcGplbl = null; + nextInsetBtn = null; + prevInsetBtn = null; + insetGp = null; effBulkShearBtn = null; stpBtn = null; shipBtn = null; @@ -1476,8 +1657,295 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, this.isEditorVisible = isEditorVisible; } - public void updateSpcGraphBtn(String paneConfigurationName) { + private void enableButtons() { + graphEditBtn.setEnabled(true); + dataEditBtn.setEnabled(true); + compareTmBtn.setEnabled(true); + compareSndBtn.setEnabled(true); + compareStnBtn.setEnabled(true); + overlayBtn.setEnabled(true); + } + + private void disableButtons() { + graphEditBtn.setEnabled(false); + dataEditBtn.setEnabled(false); + compareTmBtn.setEnabled(false); + compareSndBtn.setEnabled(false); + compareStnBtn.setEnabled(false); + overlayBtn.setEnabled(false); + } + + private void disableButtons2() { + compareTmBtn.setEnabled(false); + compareSndBtn.setEnabled(false); + compareStnBtn.setEnabled(false); + overlayBtn.setEnabled(false); + graphEditBtn.setEnabled(true); + dataEditBtn.setEnabled(true); + } + + private void createAwcGp() { + awcGp = new Group(parent, SWT.SHADOW_ETCHED_IN); + awcGp.setLayout(new RowLayout(SWT.HORIZONTAL)); + graphModeBtnSkew = new Button(awcGp, SWT.PUSH); + graphModeBtnSkew.setFont(newFont); + graphModeBtnSkew.setText("S"); + graphModeBtnSkew.setEnabled(true); + NsharpResourceHandler rscHandler = getRscHandler(); + if (rscHandler != null) { + currentGraphMode = rscHandler.getCurrentGraphMode(); + } + graphModeBtnSkew.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (currentGraphMode != NsharpConstants.GRAPH_SKEWT) { + currentGraphMode = NsharpConstants.GRAPH_SKEWT; + graphModeBtnSkew.setBackground(colorBlue); + graphModeBtnTurb.setBackground(colorGrey); + graphModeBtnIcing.setBackground(colorGrey); + if (!interpolateIsOn) { + enableButtons(); + } else { + disableButtons2(); + } + NsharpResourceHandler rsc = getRscHandler(); + if (rsc != null) { + rsc.setCurrentGraphMode(currentGraphMode); + } + } + } + }); + graphModeBtnTurb = new Button(awcGp, SWT.PUSH); + graphModeBtnTurb.setFont(newFont); + graphModeBtnTurb.setText("T"); + graphModeBtnTurb.setEnabled(true); + graphModeBtnTurb.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (currentGraphMode != NsharpConstants.GRAPH_TURB) { + currentGraphMode = NsharpConstants.GRAPH_TURB; + graphModeBtnTurb.setBackground(colorBlue); + graphModeBtnSkew.setBackground(colorGrey); + graphModeBtnIcing.setBackground(colorGrey); + disableButtons(); + NsharpResourceHandler rsc = getRscHandler(); + if (rsc != null) { + rsc.setCurrentGraphMode(currentGraphMode); + } + } + } + }); + graphModeBtnIcing = new Button(awcGp, SWT.PUSH); + graphModeBtnIcing.setFont(newFont); + graphModeBtnIcing.setText("I"); + graphModeBtnIcing.setEnabled(true); + graphModeBtnIcing.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (currentGraphMode != NsharpConstants.GRAPH_ICING) { + currentGraphMode = NsharpConstants.GRAPH_ICING; + graphModeBtnIcing.setBackground(colorBlue); + graphModeBtnSkew.setBackground(colorGrey); + graphModeBtnTurb.setBackground(colorGrey); + disableButtons(); + NsharpResourceHandler rsc = getRscHandler(); + if (rsc != null) { + rsc.setCurrentGraphMode(currentGraphMode); + } + } + } + }); + if (currentGraphMode == NsharpConstants.GRAPH_SKEWT) { + graphModeBtnSkew.setBackground(colorBlue); + graphModeBtnTurb.setBackground(colorGrey); + graphModeBtnIcing.setBackground(colorGrey); + if (!interpolateIsOn) { + enableButtons(); + } else { + disableButtons(); + } + } else if (currentGraphMode == NsharpConstants.GRAPH_TURB) { + graphModeBtnTurb.setBackground(colorBlue); + graphModeBtnSkew.setBackground(colorGrey); + graphModeBtnIcing.setBackground(colorGrey); + disableButtons(); + } else if (currentGraphMode == NsharpConstants.GRAPH_ICING) { + graphModeBtnIcing.setBackground(colorBlue); + graphModeBtnSkew.setBackground(colorGrey); + graphModeBtnTurb.setBackground(colorGrey); + disableButtons(); + } + } + + private void createD2dLiteAwcGp() { + d2dliteAwcGp = new Group(parent, SWT.SHADOW_ETCHED_IN); + d2dliteAwcGp.setLayout(new RowLayout(SWT.HORIZONTAL)); + graphModeBtnSkew = new Button(d2dliteAwcGp, SWT.PUSH); + graphModeBtnSkew.setFont(newFont); + graphModeBtnSkew.setText("S"); + graphModeBtnSkew.setEnabled(true); + NsharpResourceHandler rscHandler = getRscHandler(); + if (rscHandler != null) { + currentGraphMode = rscHandler.getCurrentGraphMode(); + } + graphModeBtnSkew.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (currentGraphMode != NsharpConstants.GRAPH_SKEWT) { + currentGraphMode = NsharpConstants.GRAPH_SKEWT; + graphModeBtnSkew.setBackground(colorBlue); + graphModeBtnHodo.setBackground(colorGrey); + graphModeBtnTurb.setBackground(colorGrey); + graphModeBtnIcing.setBackground(colorGrey); + if (!interpolateIsOn) { + enableButtons(); + } else { + disableButtons2(); + } + NsharpResourceHandler rsc = getRscHandler(); + if (rsc != null) { + rsc.setCurrentGraphMode(currentGraphMode); + } + + } + } + }); + + graphModeBtnHodo = new Button(d2dliteAwcGp, SWT.PUSH); + graphModeBtnHodo.setFont(newFont); + graphModeBtnHodo.setText("H"); + graphModeBtnHodo.setEnabled(true); + graphModeBtnHodo.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (currentGraphMode != NsharpConstants.GRAPH_HODO) { + currentGraphMode = NsharpConstants.GRAPH_HODO; + graphModeBtnHodo.setBackground(colorBlue); + graphModeBtnTurb.setBackground(colorGrey); + graphModeBtnSkew.setBackground(colorGrey); + graphModeBtnIcing.setBackground(colorGrey); + if (!interpolateIsOn) { + enableButtons(); + } else { + disableButtons2(); + } + NsharpResourceHandler rsc = getRscHandler(); + if (rsc != null) { + rsc.setCurrentGraphMode(currentGraphMode); + } + } + } + }); + + graphModeBtnTurb = new Button(d2dliteAwcGp, SWT.PUSH); + graphModeBtnTurb.setFont(newFont); + graphModeBtnTurb.setText("T"); + graphModeBtnTurb.setEnabled(true); + graphModeBtnTurb.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (currentGraphMode != NsharpConstants.GRAPH_TURB) { + currentGraphMode = NsharpConstants.GRAPH_TURB; + graphModeBtnTurb.setBackground(colorBlue); + graphModeBtnHodo.setBackground(colorGrey); + graphModeBtnSkew.setBackground(colorGrey); + graphModeBtnIcing.setBackground(colorGrey); + disableButtons(); + NsharpResourceHandler rsc = getRscHandler(); + if (rsc != null) { + rsc.setCurrentGraphMode(currentGraphMode); + } + } + } + }); + graphModeBtnIcing = new Button(d2dliteAwcGp, SWT.PUSH); + graphModeBtnIcing.setFont(newFont); + graphModeBtnIcing.setText("I"); + graphModeBtnIcing.setEnabled(true); + graphModeBtnIcing.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (currentGraphMode != NsharpConstants.GRAPH_ICING) { + currentGraphMode = NsharpConstants.GRAPH_ICING; + graphModeBtnIcing.setBackground(colorBlue); + graphModeBtnHodo.setBackground(colorGrey); + graphModeBtnSkew.setBackground(colorGrey); + graphModeBtnTurb.setBackground(colorGrey); + disableButtons(); + NsharpResourceHandler rsc = getRscHandler(); + if (rsc != null) { + rsc.setCurrentGraphMode(currentGraphMode); + } + } + } + }); + if (currentGraphMode == NsharpConstants.GRAPH_SKEWT) { + graphModeBtnSkew.setBackground(colorBlue); + graphModeBtnHodo.setBackground(colorGrey); + graphModeBtnTurb.setBackground(colorGrey); + graphModeBtnIcing.setBackground(colorGrey); + if (!interpolateIsOn) { + enableButtons(); + } else { + disableButtons(); + } + } else if (currentGraphMode == NsharpConstants.GRAPH_HODO) { + graphModeBtnHodo.setBackground(colorBlue); + graphModeBtnTurb.setBackground(colorGrey); + graphModeBtnSkew.setBackground(colorGrey); + graphModeBtnIcing.setBackground(colorGrey); + if (!interpolateIsOn) { + enableButtons(); + } else { + disableButtons(); + } + } else if (currentGraphMode == NsharpConstants.GRAPH_TURB) { + graphModeBtnTurb.setBackground(colorBlue); + graphModeBtnHodo.setBackground(colorGrey); + graphModeBtnSkew.setBackground(colorGrey); + graphModeBtnIcing.setBackground(colorGrey); + disableButtons(); + } else if (currentGraphMode == NsharpConstants.GRAPH_ICING) { + graphModeBtnIcing.setBackground(colorBlue); + graphModeBtnHodo.setBackground(colorGrey); + graphModeBtnSkew.setBackground(colorGrey); + graphModeBtnTurb.setBackground(colorGrey); + disableButtons(); + } + } + + private void disposeAwcGp() { + graphModeBtnIcing.dispose(); + graphModeBtnSkew.dispose(); + graphModeBtnTurb.dispose(); + awcGp.dispose(); + graphModeBtnIcing = null; + graphModeBtnSkew = null; + graphModeBtnTurb = null; + awcGp = null; + } + + private void disposeD2dLiteAwcGp() { + graphModeBtnIcing.dispose(); + graphModeBtnHodo.dispose(); + graphModeBtnSkew.dispose(); + graphModeBtnTurb.dispose(); + d2dliteAwcGp.dispose(); + graphModeBtnIcing = null; + graphModeBtnHodo = null; + graphModeBtnSkew = null; + graphModeBtnTurb = null; + d2dliteAwcGp = null; + } + + public void updateSpecialGraphBtn(String paneConfigurationName) { this.paneConfigurationName = paneConfigurationName; + + if (paneConfigurationName.equals(NsharpConstants.PANE_LITE_D2D_CFG_STR)) { + if (awcGp != null) + disposeAwcGp(); + if (d2dliteAwcGp == null) + createD2dLiteAwcGp(); + } else { + if (d2dliteAwcGp != null) + disposeD2dLiteAwcGp(); + if (awcGp == null) + createAwcGp(); + } + parent.layout(); if (paneConfigurationName.equals(NsharpConstants.PANE_SPCWS_CFG_STR)) { if (spcGpCreated == false) { createSPCGp(); @@ -1489,10 +1957,8 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, disposeSpcGp(); parent.layout(); } - } } - } /** @@ -1533,7 +1999,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, .getWorkbench().getService(IContextService.class); context = ctxSvc .activateContext("gov.noaa.nws.ncep.ui.nsharp.nsharpContext"); - // System.out.println("Activated " + context.getContextId()); + // System.out.println("Activated " + context.getContextId()); } if (part instanceof NsharpPaletteWindow) { NsharpMapResource rsc = NsharpMapResource.getMapRsc(); @@ -1551,12 +2017,12 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, @Override public void partClosed(IWorkbenchPart part) { - //System.out.println("view closed "); - //*FixMark:SwapPaneShowText - NsharpShowTextDialog textarea = NsharpShowTextDialog.getAccess(); - if(textarea != null){ - textarea.close(); - }//end FixMark:SwapPaneShowText */ + // System.out.println("view closed "); + // *FixMark:SwapPaneShowText + NsharpShowTextDialog textarea = NsharpShowTextDialog.getAccess(); + if (textarea != null) { + textarea.close(); + }// end FixMark:SwapPaneShowText */ } @@ -1567,7 +2033,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, IContextService ctxSvc = (IContextService) PlatformUI .getWorkbench().getService(IContextService.class); ctxSvc.deactivateContext(context); - //System.out.println("view Deactivated " + context.getContextId()); + // System.out.println("view Deactivated " + context.getContextId()); context = null; } } diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpPaneConfigDialog.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpPaneConfigDialog.java index ab153ac64e..b4cd8996c3 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpPaneConfigDialog.java +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpPaneConfigDialog.java @@ -212,7 +212,7 @@ public class NsharpPaneConfigDialog extends Dialog { else { NsharpPaletteWindow paletteWin = NsharpPaletteWindow.getInstance(); if(paletteWin!=null){ - paletteWin.updateSpcGraphBtn(paneConfigurationName); + paletteWin.updateSpecialGraphBtn(paneConfigurationName); } } } diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpParametersSelectionConfigDialog.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpParametersSelectionConfigDialog.java index 5b44569dbe..52e7eae977 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpParametersSelectionConfigDialog.java +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpParametersSelectionConfigDialog.java @@ -1,4 +1,5 @@ package gov.noaa.nws.ncep.ui.nsharp.view; + /** * * gov.noaa.nws.ncep.ui.nsharp.palette.NsharpParametersSelectionConfigDialog @@ -24,7 +25,6 @@ import gov.noaa.nws.ncep.ui.nsharp.NsharpConfigStore; import gov.noaa.nws.ncep.ui.nsharp.NsharpGraphProperty; import gov.noaa.nws.ncep.ui.nsharp.display.NsharpEditor; import gov.noaa.nws.ncep.ui.nsharp.display.rsc.NsharpResourceHandler; -import gov.noaa.nws.ncep.ui.nsharp.view.NsharpLoadDialog; import gov.noaa.nws.ncep.ui.nsharp.natives.NsharpNativeConstants; import org.eclipse.jface.dialogs.Dialog; @@ -44,771 +44,881 @@ import org.eclipse.swt.widgets.Text; import com.raytheon.uf.viz.core.exception.VizException; public class NsharpParametersSelectionConfigDialog extends Dialog { - private static NsharpParametersSelectionConfigDialog thisDialog=null; - private NsharpConfigStore configStore=null; - private NsharpGraphProperty graphProperty=null; - private NsharpConfigManager mgr; - private int btnWidth = 300; - private int btnHeight = 20; - private int labelGap = 20; - private int btnGapX = 5; - private int btnGapY = 5; - private Button tempBtn, dewpBtn, parcelTvBtn,parcelBtn, dcapeBtn,vTempBtn, wetBulbBtn, mixingRatioBtn, - dryAdiabatBtn,moisAdiabatBtn,omegaBtn, meanWindVectorBtn, stormMVector3075Btn, stormMVector1585Btn, - stormMVectorBunkersRightBtn,stormMVectorBunkersLeftBtn, corfidiVectorBtn, hodoBtn, efflayerBtn, cloudBtn, windBarbBtn; - private Text tempOffsetText; - //default value for button initial setup - private boolean temp=true, dewp=true, parcel=true,parcelTv=true,dcape=true, vTemp=true, wetBulb=true, hodo=true, - mixratio=false, dryAdiabat=true, moistAdiabat=false, omega=true, meanWind=true, - smv3075=false, smv1585=false, smvBunkersR=true, smvBunkersL=true,corfidiV=false, effLayer=true, cloud=false, windBarb=true; - //private int windBarbDistance=NsharpNativeConstants.WINDBARB_DISTANCE_DEFAULT; - private int tempOffset = 0; - private void updateGraphProperty(){ - if(graphProperty != null){ - graphProperty.setTemp(temp); - graphProperty.setDewp(dewp); - graphProperty.setParcel(parcel); - graphProperty.setParcelTv(parcelTv); - graphProperty.setDcape(dcape); - graphProperty.setVTemp(vTemp); - graphProperty.setWetBulb(wetBulb); - graphProperty.setHodo(hodo); - graphProperty.setMixratio(mixratio); - graphProperty.setDryAdiabat(dryAdiabat); - graphProperty.setMoistAdiabat(moistAdiabat); - graphProperty.setOmega(omega); - graphProperty.setMeanWind(meanWind); - graphProperty.setSmv3075(smv3075); - graphProperty.setSmv1585(smv1585); - graphProperty.setSmvBunkersR(smvBunkersR); - graphProperty.setSmvBunkersL(smvBunkersL); - graphProperty.setCloud(cloud); - graphProperty.setCorfidiV(corfidiV); - graphProperty.setEffLayer(effLayer); - graphProperty.setWindBarb(windBarb); - //graphProperty.setWindBarbDistance(windBarbDistance); - graphProperty.setTempOffset(tempOffset); - } - } - - public boolean isDcape() { - return dcape; - } + private static NsharpParametersSelectionConfigDialog thisDialog = null; - public boolean isCloud() { - return cloud; - } + private NsharpConfigStore configStore = null; + private NsharpGraphProperty graphProperty = null; - public boolean isEffLayer() { - return effLayer; - } + private NsharpConfigManager mgr; + private int btnWidth = 300; - public boolean isHodo() { - return hodo; - } + private int btnHeight = 20; + private int labelGap = 20; - public boolean isMeanWind() { - return meanWind; - } + private int btnGapX = 5; + private int btnGapY = 5; - public boolean isSmv3075() { - return smv3075; - } + private Button tempBtn, dewpBtn, parcelTvBtn, parcelBtn, dcapeBtn, + vTempBtn, wetBulbBtn, mixingRatioBtn, dryAdiabatBtn, + moisAdiabatBtn, omegaBtn, meanWindVectorBtn, stormMVector3075Btn, + stormMVector1585Btn, stormMVectorBunkersRightBtn, + stormMVectorBunkersLeftBtn, corfidiVectorBtn, hodoBtn, efflayerBtn, + cloudBtn, windBarbBtn; + private Text tempOffsetText; - public boolean isSmv1585() { - return smv1585; - } + private Text sndCompRadiusText;// FixMark:nearByStnCompSnd + private int sndCompRadius = 0;// FixMark:nearByStnCompSnd - public boolean isSmvBunkersR() { - return smvBunkersR; - } + // default value for button initial setup + private boolean temp = true, dewp = true, parcel = true, parcelTv = true, + dcape = true, vTemp = true, wetBulb = true, hodo = true, + mixratio = false, dryAdiabat = true, moistAdiabat = false, + omega = true, meanWind = true, smv3075 = false, smv1585 = false, + smvBunkersR = true, smvBunkersL = true, corfidiV = false, + effLayer = true, cloud = false, windBarb = true; + // private int + // windBarbDistance=NsharpNativeConstants.WINDBARB_DISTANCE_DEFAULT; + private int tempOffset = 0; - public boolean isSmvBunkersL() { - return smvBunkersL; - } + private void updateGraphProperty() { + if (graphProperty != null) { + graphProperty.setTemp(temp); + graphProperty.setDewp(dewp); + graphProperty.setParcel(parcel); + graphProperty.setParcelTv(parcelTv); + graphProperty.setDcape(dcape); + graphProperty.setVTemp(vTemp); + graphProperty.setWetBulb(wetBulb); + graphProperty.setHodo(hodo); + graphProperty.setMixratio(mixratio); + graphProperty.setDryAdiabat(dryAdiabat); + graphProperty.setMoistAdiabat(moistAdiabat); + graphProperty.setOmega(omega); + graphProperty.setMeanWind(meanWind); + graphProperty.setSmv3075(smv3075); + graphProperty.setSmv1585(smv1585); + graphProperty.setSmvBunkersR(smvBunkersR); + graphProperty.setSmvBunkersL(smvBunkersL); + graphProperty.setCloud(cloud); + graphProperty.setCorfidiV(corfidiV); + graphProperty.setEffLayer(effLayer); + graphProperty.setWindBarb(windBarb); + // graphProperty.setWindBarbDistance(windBarbDistance); + graphProperty.setTempOffset(tempOffset); + graphProperty.setSndCompRadius(sndCompRadius);// FixMark:nearByStnCompSnd + } + } + public boolean isDcape() { + return dcape; + } - public boolean isCorfidiV() { - return corfidiV; - } + public boolean isCloud() { + return cloud; + } + public boolean isEffLayer() { + return effLayer; + } - public boolean isOmega() { - return omega; - } + public boolean isHodo() { + return hodo; + } + public boolean isMeanWind() { + return meanWind; + } - public boolean isDryAdiabat() { - return dryAdiabat; - } + public boolean isSmv3075() { + return smv3075; + } - public boolean isMoistAdiabat() { - return moistAdiabat; - } + public boolean isSmv1585() { + return smv1585; + } - public boolean isMixratio() { - return mixratio; - } + public boolean isSmvBunkersR() { + return smvBunkersR; + } - public boolean isTemp() { - return temp; - } + public boolean isSmvBunkersL() { + return smvBunkersL; + } - public boolean isDewp() { - return dewp; - } + public boolean isCorfidiV() { + return corfidiV; + } - public boolean isParcel() { - return parcel; - } + public boolean isOmega() { + return omega; + } - public boolean isParcelAscent() { - return parcelTv; - } - - public boolean isVTemp() { - return vTemp; - } + public boolean isDryAdiabat() { + return dryAdiabat; + } - public boolean isWetBulb() { - return wetBulb; - } - + public boolean isMoistAdiabat() { + return moistAdiabat; + } - public boolean isWindBarb() { - return windBarb; - } + public boolean isMixratio() { + return mixratio; + } + public boolean isTemp() { + return temp; + } - //public int getWindBarbDistance() { - // return windBarbDistance; - //} + public boolean isDewp() { + return dewp; + } + public boolean isParcel() { + return parcel; + } - public static NsharpParametersSelectionConfigDialog getInstance( Shell parShell){ + public boolean isParcelAscent() { + return parcelTv; + } - if ( thisDialog == null ){ - try { - thisDialog = new NsharpParametersSelectionConfigDialog( parShell ); - - } catch (VizException e) { - e.printStackTrace(); - } + public boolean isVTemp() { + return vTemp; + } - } + public boolean isWetBulb() { + return wetBulb; + } - return thisDialog; + public boolean isWindBarb() { + return windBarb; + } - } + // public int getWindBarbDistance() { + // return windBarbDistance; + // } - public static NsharpParametersSelectionConfigDialog getAccess() { - return thisDialog; - } - - public NsharpParametersSelectionConfigDialog(Shell parentShell) throws VizException { - super(parentShell); - thisDialog = this; - mgr =NsharpConfigManager.getInstance(); - configStore = mgr.retrieveNsharpConfigStoreFromFs(); - //if(configStore== null){ - // configStore = new NsharpConfigStore(); - // configStore = setDefaultGraphConfig(configStore); - // configStore=NsharpDataDisplayConfigDialog.setDefaultLineConfig(configStore); - //} - graphProperty = configStore.getGraphProperty(); - if(graphProperty != null){ - temp=graphProperty.isTemp(); - dewp=graphProperty.isDewp(); - parcel=graphProperty.isParcel(); - parcelTv=graphProperty.isParcelTv(); - dcape = graphProperty.isDcape(); - vTemp=graphProperty.isVTemp(); - wetBulb=graphProperty.isWetBulb(); - hodo=graphProperty.isHodo(); - mixratio=graphProperty.isMixratio(); - dryAdiabat=graphProperty.isDryAdiabat(); - moistAdiabat=graphProperty.isMoistAdiabat(); - omega=graphProperty.isOmega(); - meanWind=graphProperty.isMeanWind(); - smv3075=graphProperty.isSmv3075(); - smv1585=graphProperty.isSmv1585(); - smvBunkersR=graphProperty.isSmvBunkersR(); - smvBunkersL=graphProperty.isSmvBunkersL(); - corfidiV=graphProperty.isCorfidiV(); - effLayer=graphProperty.isEffLayer(); - cloud=graphProperty.isCloud(); - windBarb=graphProperty.isWindBarb(); - //windBarbDistance = graphProperty.getWindBarbDistance(); - tempOffset = graphProperty.getTempOffset(); - } - - } - private void createDialogContents(Composite parent){ - - Group btnGp = new Group(parent, SWT.SHADOW_ETCHED_IN | SWT.NO_RADIO_GROUP); + public static NsharpParametersSelectionConfigDialog getInstance( + Shell parShell) { - tempBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); - tempBtn.setText(NsharpNativeConstants.TEMP_TRACE); - tempBtn.setEnabled( true ); - tempBtn.setBounds(btnGp.getBounds().x+ btnGapX, btnGp.getBounds().y + labelGap, btnWidth,btnHeight); - if(temp == true) - tempBtn.setSelection(true); - else - tempBtn.setSelection(false); - tempBtn.addListener( SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - if(temp == true) - temp=false; - else - temp=true; - applyChange(); - } - } ); - dewpBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); - dewpBtn.setText(NsharpNativeConstants.DEWP_TRACE); - dewpBtn.setEnabled( true ); - dewpBtn.setBounds(btnGp.getBounds().x+ btnGapX, tempBtn.getBounds().y + tempBtn.getBounds().height+ btnGapY, btnWidth,btnHeight); - if(dewp == true) - dewpBtn.setSelection(true); - else - dewpBtn.setSelection(false); - dewpBtn.addListener( SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - if(dewp == true) - dewp=false; - else - dewp=true; - applyChange(); - } - } ); - parcelTvBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); - parcelTvBtn.setText(NsharpNativeConstants.PARCEL_VT_TRACE); - parcelTvBtn.setEnabled( true ); - parcelTvBtn.setBounds(btnGp.getBounds().x+ btnGapX, dewpBtn.getBounds().y + dewpBtn.getBounds().height+ btnGapY, btnWidth,btnHeight); - if(parcelTv == true) - parcelTvBtn.setSelection(true); - else - parcelTvBtn.setSelection(false); - parcelTvBtn.addListener( SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - if(parcelTv == true) - parcelTv=false; - else - parcelTv=true; - applyChange(); - } - } ); - parcelBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); - parcelBtn.setText(NsharpNativeConstants.PARCEL_T_TRACE); - parcelBtn.setEnabled( true ); - parcelBtn.setBounds(btnGp.getBounds().x+ btnGapX, parcelTvBtn.getBounds().y + parcelTvBtn.getBounds().height+ btnGapY, btnWidth,btnHeight); - if(parcel == true) - parcelBtn.setSelection(true); - else - parcelBtn.setSelection(false); - parcelBtn.addListener( SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - if(parcel == true) - parcel=false; - else - parcel=true; - applyChange(); - } - } ); - dcapeBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); - dcapeBtn.setText(NsharpNativeConstants.DCAPE_TRACE); - dcapeBtn.setEnabled( true ); - dcapeBtn.setBounds(btnGp.getBounds().x+ btnGapX, parcelBtn.getBounds().y + parcelBtn.getBounds().height+ btnGapY, btnWidth,btnHeight); - if(dcape == true) - dcapeBtn.setSelection(true); - else - dcapeBtn.setSelection(false); - dcapeBtn.addListener( SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - if(dcape == true) - dcape=false; - else - dcape=true; - applyChange(); - } - } ); - - vTempBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); - vTempBtn.setText(NsharpNativeConstants.VTEMP_TRACE); - vTempBtn.setEnabled( true ); - vTempBtn.setBounds(btnGp.getBounds().x+ btnGapX, dcapeBtn.getBounds().y + dcapeBtn.getBounds().height+ btnGapY, btnWidth,btnHeight); - if(vTemp == true) - vTempBtn.setSelection(true); - else - vTempBtn.setSelection(false); - vTempBtn.addListener( SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - if(vTemp == true) - vTemp=false; - else - vTemp=true; - applyChange(); - } - } ); - - wetBulbBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); - wetBulbBtn.setText(NsharpNativeConstants.WETBULB_TRACE); - wetBulbBtn.setEnabled( true ); - wetBulbBtn.setBounds(btnGp.getBounds().x+ btnGapX, vTempBtn.getBounds().y + vTempBtn.getBounds().height+ btnGapY, btnWidth,btnHeight); - if(wetBulb == true) - wetBulbBtn.setSelection(true); - else - wetBulbBtn.setSelection(false); - wetBulbBtn.addListener( SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - if(wetBulb == true) - wetBulb=false; - else - wetBulb=true; - applyChange(); - } - } ); + if (thisDialog == null) { + try { + thisDialog = new NsharpParametersSelectionConfigDialog(parShell); - mixingRatioBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); - mixingRatioBtn.setText(NsharpNativeConstants.MIXING_RATIO); - mixingRatioBtn.setEnabled( true ); - mixingRatioBtn.setBounds(btnGp.getBounds().x+ btnGapX, wetBulbBtn.getBounds().y + wetBulbBtn.getBounds().height+ btnGapY, btnWidth,btnHeight); - if(mixratio == true) - mixingRatioBtn.setSelection(true); - else - mixingRatioBtn.setSelection(false); - mixingRatioBtn.addListener( SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - if(mixratio == true) - mixratio=false; - else - mixratio=true; - applyChange(); - } - } ); - dryAdiabatBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); - dryAdiabatBtn.setText(NsharpNativeConstants.DRY_ADIABAT); - dryAdiabatBtn.setEnabled( true ); - dryAdiabatBtn.setBounds(btnGp.getBounds().x+ btnGapX, mixingRatioBtn.getBounds().y + mixingRatioBtn.getBounds().height+ btnGapY, btnWidth,btnHeight); - if(dryAdiabat == true) - dryAdiabatBtn.setSelection(true); - else - dryAdiabatBtn.setSelection(false); - dryAdiabatBtn.addListener( SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - if(dryAdiabat == true) - dryAdiabat=false; - else - dryAdiabat=true; - applyChange(); - } - } ); + } catch (VizException e) { + e.printStackTrace(); + } - moisAdiabatBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); - moisAdiabatBtn.setText(NsharpNativeConstants.MOIST_ADIABAT); - moisAdiabatBtn.setEnabled( true ); - moisAdiabatBtn.setBounds(btnGp.getBounds().x+ btnGapX, dryAdiabatBtn.getBounds().y + dryAdiabatBtn.getBounds().height+ btnGapY, btnWidth,btnHeight); - if(moistAdiabat == true) - moisAdiabatBtn.setSelection(true); - else - moisAdiabatBtn.setSelection(false); - moisAdiabatBtn.addListener( SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - if(moistAdiabat == true) - moistAdiabat=false; - else - moistAdiabat=true; - applyChange(); - } - } ); - efflayerBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); - efflayerBtn.setText(NsharpNativeConstants.EFFECTIVE_LAYER); - efflayerBtn.setEnabled( true ); - efflayerBtn.setBounds(btnGp.getBounds().x+ btnGapX, moisAdiabatBtn.getBounds().y + moisAdiabatBtn.getBounds().height+ btnGapY, btnWidth,btnHeight); - if(effLayer == true) - efflayerBtn.setSelection(true); - else - efflayerBtn.setSelection(false); - efflayerBtn.addListener( SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - if(effLayer == true) - effLayer=false; - else - effLayer=true; - applyChange(); - } - } ); - cloudBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); - cloudBtn.setText(NsharpNativeConstants.CLOUD); - cloudBtn.setEnabled( true ); - cloudBtn.setBounds(btnGp.getBounds().x+ btnGapX, efflayerBtn.getBounds().y + efflayerBtn.getBounds().height+ btnGapY, btnWidth,btnHeight); - if(cloud == true) - cloudBtn.setSelection(true); - else - cloudBtn.setSelection(false); - cloudBtn.addListener( SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - if(cloud == true) - cloud=false; - else - cloud=true; - applyChange(); - } - } ); - hodoBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); - hodoBtn.setText(NsharpNativeConstants.HODOGRAPH); - hodoBtn.setEnabled( true ); - hodoBtn.setBounds(btnGp.getBounds().x+ btnGapX, cloudBtn.getBounds().y + cloudBtn.getBounds().height+ btnGapY, btnWidth,btnHeight); - if(hodo == true) - hodoBtn.setSelection(true); - else - hodoBtn.setSelection(false); - hodoBtn.addListener( SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - if(hodo == true) - hodo=false; - else - hodo=true; - applyChange(); - } - } ); - meanWindVectorBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); - meanWindVectorBtn.setText(NsharpNativeConstants.MEAN_WIND_VECTOR); - meanWindVectorBtn.setEnabled( true ); - meanWindVectorBtn.setBounds(btnGp.getBounds().x+ btnGapX, hodoBtn.getBounds().y + hodoBtn.getBounds().height+ btnGapY, btnWidth,btnHeight); - if(meanWind == true) - meanWindVectorBtn.setSelection(true); - else - meanWindVectorBtn.setSelection(false); - meanWindVectorBtn.addListener( SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - if(meanWind == true) - meanWind=false; - else - meanWind=true; - applyChange(); - } - } ); - stormMVector3075Btn = new Button(btnGp, SWT.RADIO | SWT.BORDER); - stormMVector3075Btn.setText(NsharpNativeConstants.STORM_MOTION_VECTOR_3075); - stormMVector3075Btn.setEnabled( true ); - stormMVector3075Btn.setBounds(btnGp.getBounds().x+ btnGapX, meanWindVectorBtn.getBounds().y + meanWindVectorBtn.getBounds().height+ btnGapY, btnWidth,btnHeight); - if(smv3075 == true) - stormMVector3075Btn.setSelection(true); - else - stormMVector3075Btn.setSelection(false); - stormMVector3075Btn.addListener( SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - if(smv3075 == true) - smv3075=false; - else - smv3075=true; - applyChange(); - } - } ); - stormMVector1585Btn = new Button(btnGp, SWT.RADIO | SWT.BORDER); - stormMVector1585Btn.setText(NsharpNativeConstants.STORM_MOTION_VECTOR_1585); - stormMVector1585Btn.setEnabled( true ); - stormMVector1585Btn.setBounds(btnGp.getBounds().x+ btnGapX, stormMVector3075Btn.getBounds().y + stormMVector3075Btn.getBounds().height+ btnGapY, btnWidth,btnHeight); - if(smv1585 == true) - stormMVector1585Btn.setSelection(true); - else - stormMVector1585Btn.setSelection(false); - stormMVector1585Btn.addListener( SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - if(smv1585 == true) - smv1585=false; - else - smv1585=true; - applyChange(); - } - } ); - stormMVectorBunkersRightBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); - stormMVectorBunkersRightBtn.setText(NsharpNativeConstants.STORM_MOTION_VECTOR_BUNKERS_R); - stormMVectorBunkersRightBtn.setEnabled( true ); - stormMVectorBunkersRightBtn.setBounds(btnGp.getBounds().x+ btnGapX, stormMVector1585Btn.getBounds().y + stormMVector1585Btn.getBounds().height+ btnGapY, btnWidth,btnHeight); - if(smvBunkersR == true) - stormMVectorBunkersRightBtn.setSelection(true); - else - stormMVectorBunkersRightBtn.setSelection(false); - stormMVectorBunkersRightBtn.addListener( SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - if(smvBunkersR == true) - smvBunkersR=false; - else - smvBunkersR=true; - applyChange(); - } - } ); - stormMVectorBunkersLeftBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); - stormMVectorBunkersLeftBtn.setText(NsharpNativeConstants.STORM_MOTION_VECTOR_BUNKERS_L); - stormMVectorBunkersLeftBtn.setEnabled( true ); - stormMVectorBunkersLeftBtn.setBounds(btnGp.getBounds().x+ btnGapX, stormMVectorBunkersRightBtn.getBounds().y + stormMVectorBunkersRightBtn.getBounds().height+ btnGapY, btnWidth,btnHeight); - if(smvBunkersL == true) - stormMVectorBunkersLeftBtn.setSelection(true); - else - stormMVectorBunkersLeftBtn.setSelection(false); - stormMVectorBunkersLeftBtn.addListener( SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - if(smvBunkersL == true) - smvBunkersL=false; - else - smvBunkersL=true; - applyChange(); - } - } ); - - corfidiVectorBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); - corfidiVectorBtn.setText(NsharpNativeConstants.CORFIDI_VECTORS); - corfidiVectorBtn.setEnabled( true ); - corfidiVectorBtn.setBounds(btnGp.getBounds().x+ btnGapX, stormMVectorBunkersLeftBtn.getBounds().y + stormMVectorBunkersLeftBtn.getBounds().height+ btnGapY, btnWidth,btnHeight); - if(corfidiV == true) - corfidiVectorBtn.setSelection(true); - else - corfidiVectorBtn.setSelection(false); - corfidiVectorBtn.addListener( SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - if(corfidiV == true) - corfidiV=false; - else - corfidiV=true; - applyChange(); - } - } ); - windBarbBtn= new Button(btnGp, SWT.RADIO | SWT.BORDER); - windBarbBtn.setText(NsharpNativeConstants.WINDBARB); - windBarbBtn.setEnabled(true); - windBarbBtn.setBounds(btnGp.getBounds().x+ btnGapX, corfidiVectorBtn.getBounds().y + corfidiVectorBtn.getBounds().height+ btnGapY, btnWidth,btnHeight); - if(windBarb == true) - windBarbBtn.setSelection(true); - else - windBarbBtn.setSelection(false); - windBarbBtn.addListener(SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - if(windBarb == true) - windBarb=false; - else - windBarb=true; - applyChange(); - } - } ); - /* - windBarbText = new Text(btnGp, SWT.BORDER | SWT.SINGLE); - windBarbText.setText(Integer.toString(windBarbDistance)); - windBarbText.setBounds(windBarbBtn.getBounds().x+windBarbBtn.getBounds().width, windBarbBtn.getBounds().y,btnWidth/4,btnHeight); - windBarbText.setEditable(true); - windBarbText.setVisible(true); - //to make sure user enter digits only - windBarbText.addListener (SWT.Verify, new Listener () { - public void handleEvent (Event e) { - String string = e.text; - char [] chars = new char [string.length ()]; - string.getChars (0, chars.length, chars, 0); - //System.out.println("entered "+ string); - - for (int i=0; i= 1) && (textStr.contains("-"))){ - e.doit = false; - return; - } - }else if (!('0' <= chars [0] && chars [0] <= '9')) { - e.doit = false; - return; - } + } - } - } - }); - if(NsharpLoadDialog.getAccess()!= null && - (NsharpLoadDialog.getAccess().getActiveLoadSoundingType()== NsharpLoadDialog.MODEL_SND || - NsharpLoadDialog.getAccess().getActiveLoadSoundingType()== NsharpLoadDialog.PFC_SND )){ - omegaBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); - omegaBtn.setText(NsharpNativeConstants.OMEGA); - omegaBtn.setEnabled( true ); - omegaBtn.setBounds(btnGp.getBounds().x+ btnGapX, tempOffsetLbl.getBounds().y + tempOffsetLbl.getBounds().height+ btnGapY, btnWidth,btnHeight); - if(omega == true) - omegaBtn.setSelection(true); - else - omegaBtn.setSelection(false); - omegaBtn.addListener( SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - if(omega == true) - omega=false; - else - omega=true; - applyChange(); - } - } ); - } + return thisDialog; - } - - @Override - public void createButtonsForButtonBar(Composite parent) { - // create OK button but using Apply label for applying user entered data - //Chin note: when "apply" button is selected or Return key is entered, - // okPressed() will be called. So, handle event at one place, ie.e at okPressed(). - createButton(parent, IDialogConstants.OK_ID, - "Apply", - true); - - /*appBtn.addListener( SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - //System.out.println("App listener is called"); - //String textStr = windBarbText.getText(); - //if((textStr != null) && !(textStr.isEmpty())){ - // windBarbDistance = Integer.decode(textStr); - //} - //applyChange(); - - } - } ); */ - Button saveBtn = createButton(parent, IDialogConstants.INTERNAL_ID, - "Save",false); - saveBtn.addListener( SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - //System.out.println("save listener is called, also apply changes"); - okPressed(); - try { - //save to xml - mgr.saveConfigStoreToFs(configStore); - } catch (VizException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - - } - } ); + } - Button canBtn = createButton(parent, IDialogConstants.CLOSE_ID, - IDialogConstants.CLOSE_LABEL, false); - canBtn.addListener( SWT.MouseUp, new Listener() { - public void handleEvent(Event event) { - //System.out.println("close listener is called"); - close(); - } - } ); - } + public static NsharpParametersSelectionConfigDialog getAccess() { + return thisDialog; + } + public NsharpParametersSelectionConfigDialog(Shell parentShell) + throws VizException { + super(parentShell); + thisDialog = this; + mgr = NsharpConfigManager.getInstance(); + configStore = mgr.retrieveNsharpConfigStoreFromFs(); + // if(configStore== null){ + // configStore = new NsharpConfigStore(); + // configStore = setDefaultGraphConfig(configStore); + // configStore=NsharpDataDisplayConfigDialog.setDefaultLineConfig(configStore); + // } + graphProperty = configStore.getGraphProperty(); + if (graphProperty != null) { + temp = graphProperty.isTemp(); + dewp = graphProperty.isDewp(); + parcel = graphProperty.isParcel(); + parcelTv = graphProperty.isParcelTv(); + dcape = graphProperty.isDcape(); + vTemp = graphProperty.isVTemp(); + wetBulb = graphProperty.isWetBulb(); + hodo = graphProperty.isHodo(); + mixratio = graphProperty.isMixratio(); + dryAdiabat = graphProperty.isDryAdiabat(); + moistAdiabat = graphProperty.isMoistAdiabat(); + omega = graphProperty.isOmega(); + meanWind = graphProperty.isMeanWind(); + smv3075 = graphProperty.isSmv3075(); + smv1585 = graphProperty.isSmv1585(); + smvBunkersR = graphProperty.isSmvBunkersR(); + smvBunkersL = graphProperty.isSmvBunkersL(); + corfidiV = graphProperty.isCorfidiV(); + effLayer = graphProperty.isEffLayer(); + cloud = graphProperty.isCloud(); + windBarb = graphProperty.isWindBarb(); + // windBarbDistance = graphProperty.getWindBarbDistance(); + tempOffset = graphProperty.getTempOffset(); + sndCompRadius = graphProperty.getSndCompRadius();// FixMark:nearByStnCompSnd + } - @Override - public void okPressed() { - //"Enter" key is pressed, or "Apply" button is pressed. - //Chin: handle user entered data and apply its changes. - //System.out.println("CR is pressed"); - //String textStr = windBarbText.getText(); - //if((textStr != null) && !(textStr.isEmpty())){ - // windBarbDistance = Integer.decode(textStr); - //} - String textStr = tempOffsetText.getText(); - if((textStr != null) && !(textStr.isEmpty())){ - if(!textStr.contains("-") || textStr.length() > 1){ - tempOffset = Integer.decode(textStr); - //System.out.println("temp offset is ="+tempOffset); - } - } - applyChange(); - setReturnCode(OK); - } - - /* + } + + private void createDialogContents(Composite parent) { + + Group btnGp = new Group(parent, SWT.SHADOW_ETCHED_IN + | SWT.NO_RADIO_GROUP); + + tempBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); + tempBtn.setText(NsharpNativeConstants.TEMP_TRACE); + tempBtn.setEnabled(true); + tempBtn.setBounds(btnGp.getBounds().x + btnGapX, btnGp.getBounds().y + + labelGap, btnWidth, btnHeight); + if (temp == true) + tempBtn.setSelection(true); + else + tempBtn.setSelection(false); + tempBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (temp == true) + temp = false; + else + temp = true; + applyChange(); + } + }); + dewpBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); + dewpBtn.setText(NsharpNativeConstants.DEWP_TRACE); + dewpBtn.setEnabled(true); + dewpBtn.setBounds(btnGp.getBounds().x + btnGapX, tempBtn.getBounds().y + + tempBtn.getBounds().height + btnGapY, btnWidth, btnHeight); + if (dewp == true) + dewpBtn.setSelection(true); + else + dewpBtn.setSelection(false); + dewpBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (dewp == true) + dewp = false; + else + dewp = true; + applyChange(); + } + }); + parcelTvBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); + parcelTvBtn.setText(NsharpNativeConstants.PARCEL_VT_TRACE); + parcelTvBtn.setEnabled(true); + parcelTvBtn.setBounds(btnGp.getBounds().x + btnGapX, + dewpBtn.getBounds().y + dewpBtn.getBounds().height + btnGapY, + btnWidth, btnHeight); + if (parcelTv == true) + parcelTvBtn.setSelection(true); + else + parcelTvBtn.setSelection(false); + parcelTvBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (parcelTv == true) + parcelTv = false; + else + parcelTv = true; + applyChange(); + } + }); + parcelBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); + parcelBtn.setText(NsharpNativeConstants.PARCEL_T_TRACE); + parcelBtn.setEnabled(true); + parcelBtn.setBounds(btnGp.getBounds().x + btnGapX, + parcelTvBtn.getBounds().y + parcelTvBtn.getBounds().height + + btnGapY, btnWidth, btnHeight); + if (parcel == true) + parcelBtn.setSelection(true); + else + parcelBtn.setSelection(false); + parcelBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (parcel == true) + parcel = false; + else + parcel = true; + applyChange(); + } + }); + dcapeBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); + dcapeBtn.setText(NsharpNativeConstants.DCAPE_TRACE); + dcapeBtn.setEnabled(true); + dcapeBtn.setBounds(btnGp.getBounds().x + btnGapX, + parcelBtn.getBounds().y + parcelBtn.getBounds().height + + btnGapY, btnWidth, btnHeight); + if (dcape == true) + dcapeBtn.setSelection(true); + else + dcapeBtn.setSelection(false); + dcapeBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (dcape == true) + dcape = false; + else + dcape = true; + applyChange(); + } + }); + + vTempBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); + vTempBtn.setText(NsharpNativeConstants.VTEMP_TRACE); + vTempBtn.setEnabled(true); + vTempBtn.setBounds(btnGp.getBounds().x + btnGapX, + dcapeBtn.getBounds().y + dcapeBtn.getBounds().height + btnGapY, + btnWidth, btnHeight); + if (vTemp == true) + vTempBtn.setSelection(true); + else + vTempBtn.setSelection(false); + vTempBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (vTemp == true) + vTemp = false; + else + vTemp = true; + applyChange(); + } + }); + + wetBulbBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); + wetBulbBtn.setText(NsharpNativeConstants.WETBULB_TRACE); + wetBulbBtn.setEnabled(true); + wetBulbBtn.setBounds(btnGp.getBounds().x + btnGapX, + vTempBtn.getBounds().y + vTempBtn.getBounds().height + btnGapY, + btnWidth, btnHeight); + if (wetBulb == true) + wetBulbBtn.setSelection(true); + else + wetBulbBtn.setSelection(false); + wetBulbBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (wetBulb == true) + wetBulb = false; + else + wetBulb = true; + applyChange(); + } + }); + + mixingRatioBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); + mixingRatioBtn.setText(NsharpNativeConstants.MIXING_RATIO); + mixingRatioBtn.setEnabled(true); + mixingRatioBtn.setBounds(btnGp.getBounds().x + btnGapX, + wetBulbBtn.getBounds().y + wetBulbBtn.getBounds().height + + btnGapY, btnWidth, btnHeight); + if (mixratio == true) + mixingRatioBtn.setSelection(true); + else + mixingRatioBtn.setSelection(false); + mixingRatioBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (mixratio == true) + mixratio = false; + else + mixratio = true; + applyChange(); + } + }); + dryAdiabatBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); + dryAdiabatBtn.setText(NsharpNativeConstants.DRY_ADIABAT); + dryAdiabatBtn.setEnabled(true); + dryAdiabatBtn.setBounds(btnGp.getBounds().x + btnGapX, + mixingRatioBtn.getBounds().y + + mixingRatioBtn.getBounds().height + btnGapY, + btnWidth, btnHeight); + if (dryAdiabat == true) + dryAdiabatBtn.setSelection(true); + else + dryAdiabatBtn.setSelection(false); + dryAdiabatBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (dryAdiabat == true) + dryAdiabat = false; + else + dryAdiabat = true; + applyChange(); + } + }); + + moisAdiabatBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); + moisAdiabatBtn.setText(NsharpNativeConstants.MOIST_ADIABAT); + moisAdiabatBtn.setEnabled(true); + moisAdiabatBtn.setBounds(btnGp.getBounds().x + btnGapX, + dryAdiabatBtn.getBounds().y + dryAdiabatBtn.getBounds().height + + btnGapY, btnWidth, btnHeight); + if (moistAdiabat == true) + moisAdiabatBtn.setSelection(true); + else + moisAdiabatBtn.setSelection(false); + moisAdiabatBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (moistAdiabat == true) + moistAdiabat = false; + else + moistAdiabat = true; + applyChange(); + } + }); + efflayerBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); + efflayerBtn.setText(NsharpNativeConstants.EFFECTIVE_LAYER); + efflayerBtn.setEnabled(true); + efflayerBtn.setBounds(btnGp.getBounds().x + btnGapX, + moisAdiabatBtn.getBounds().y + + moisAdiabatBtn.getBounds().height + btnGapY, + btnWidth, btnHeight); + if (effLayer == true) + efflayerBtn.setSelection(true); + else + efflayerBtn.setSelection(false); + efflayerBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (effLayer == true) + effLayer = false; + else + effLayer = true; + applyChange(); + } + }); + cloudBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); + cloudBtn.setText(NsharpNativeConstants.CLOUD); + cloudBtn.setEnabled(true); + cloudBtn.setBounds(btnGp.getBounds().x + btnGapX, + efflayerBtn.getBounds().y + efflayerBtn.getBounds().height + + btnGapY, btnWidth, btnHeight); + if (cloud == true) + cloudBtn.setSelection(true); + else + cloudBtn.setSelection(false); + cloudBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (cloud == true) + cloud = false; + else + cloud = true; + applyChange(); + } + }); + hodoBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); + hodoBtn.setText(NsharpNativeConstants.HODOGRAPH); + hodoBtn.setEnabled(true); + hodoBtn.setBounds(btnGp.getBounds().x + btnGapX, cloudBtn.getBounds().y + + cloudBtn.getBounds().height + btnGapY, btnWidth, btnHeight); + if (hodo == true) + hodoBtn.setSelection(true); + else + hodoBtn.setSelection(false); + hodoBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (hodo == true) + hodo = false; + else + hodo = true; + applyChange(); + } + }); + meanWindVectorBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); + meanWindVectorBtn.setText(NsharpNativeConstants.MEAN_WIND_VECTOR); + meanWindVectorBtn.setEnabled(true); + meanWindVectorBtn.setBounds(btnGp.getBounds().x + btnGapX, + hodoBtn.getBounds().y + hodoBtn.getBounds().height + btnGapY, + btnWidth, btnHeight); + if (meanWind == true) + meanWindVectorBtn.setSelection(true); + else + meanWindVectorBtn.setSelection(false); + meanWindVectorBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (meanWind == true) + meanWind = false; + else + meanWind = true; + applyChange(); + } + }); + stormMVector3075Btn = new Button(btnGp, SWT.RADIO | SWT.BORDER); + stormMVector3075Btn + .setText(NsharpNativeConstants.STORM_MOTION_VECTOR_3075); + stormMVector3075Btn.setEnabled(true); + stormMVector3075Btn.setBounds(btnGp.getBounds().x + btnGapX, + meanWindVectorBtn.getBounds().y + + meanWindVectorBtn.getBounds().height + btnGapY, + btnWidth, btnHeight); + if (smv3075 == true) + stormMVector3075Btn.setSelection(true); + else + stormMVector3075Btn.setSelection(false); + stormMVector3075Btn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (smv3075 == true) + smv3075 = false; + else + smv3075 = true; + applyChange(); + } + }); + stormMVector1585Btn = new Button(btnGp, SWT.RADIO | SWT.BORDER); + stormMVector1585Btn + .setText(NsharpNativeConstants.STORM_MOTION_VECTOR_1585); + stormMVector1585Btn.setEnabled(true); + stormMVector1585Btn.setBounds( + btnGp.getBounds().x + btnGapX, + stormMVector3075Btn.getBounds().y + + stormMVector3075Btn.getBounds().height + btnGapY, + btnWidth, btnHeight); + if (smv1585 == true) + stormMVector1585Btn.setSelection(true); + else + stormMVector1585Btn.setSelection(false); + stormMVector1585Btn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (smv1585 == true) + smv1585 = false; + else + smv1585 = true; + applyChange(); + } + }); + stormMVectorBunkersRightBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); + stormMVectorBunkersRightBtn + .setText(NsharpNativeConstants.STORM_MOTION_VECTOR_BUNKERS_R); + stormMVectorBunkersRightBtn.setEnabled(true); + stormMVectorBunkersRightBtn.setBounds( + btnGp.getBounds().x + btnGapX, + stormMVector1585Btn.getBounds().y + + stormMVector1585Btn.getBounds().height + btnGapY, + btnWidth, btnHeight); + if (smvBunkersR == true) + stormMVectorBunkersRightBtn.setSelection(true); + else + stormMVectorBunkersRightBtn.setSelection(false); + stormMVectorBunkersRightBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (smvBunkersR == true) + smvBunkersR = false; + else + smvBunkersR = true; + applyChange(); + } + }); + stormMVectorBunkersLeftBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); + stormMVectorBunkersLeftBtn + .setText(NsharpNativeConstants.STORM_MOTION_VECTOR_BUNKERS_L); + stormMVectorBunkersLeftBtn.setEnabled(true); + stormMVectorBunkersLeftBtn.setBounds(btnGp.getBounds().x + btnGapX, + stormMVectorBunkersRightBtn.getBounds().y + + stormMVectorBunkersRightBtn.getBounds().height + + btnGapY, btnWidth, btnHeight); + if (smvBunkersL == true) + stormMVectorBunkersLeftBtn.setSelection(true); + else + stormMVectorBunkersLeftBtn.setSelection(false); + stormMVectorBunkersLeftBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (smvBunkersL == true) + smvBunkersL = false; + else + smvBunkersL = true; + applyChange(); + } + }); + + corfidiVectorBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); + corfidiVectorBtn.setText(NsharpNativeConstants.CORFIDI_VECTORS); + corfidiVectorBtn.setEnabled(true); + corfidiVectorBtn.setBounds(btnGp.getBounds().x + btnGapX, + stormMVectorBunkersLeftBtn.getBounds().y + + stormMVectorBunkersLeftBtn.getBounds().height + + btnGapY, btnWidth, btnHeight); + if (corfidiV == true) + corfidiVectorBtn.setSelection(true); + else + corfidiVectorBtn.setSelection(false); + corfidiVectorBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (corfidiV == true) + corfidiV = false; + else + corfidiV = true; + applyChange(); + } + }); + windBarbBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); + windBarbBtn.setText(NsharpNativeConstants.WINDBARB); + windBarbBtn.setEnabled(true); + windBarbBtn.setBounds(btnGp.getBounds().x + btnGapX, + corfidiVectorBtn.getBounds().y + + corfidiVectorBtn.getBounds().height + btnGapY, + btnWidth, btnHeight); + if (windBarb == true) + windBarbBtn.setSelection(true); + else + windBarbBtn.setSelection(false); + windBarbBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (windBarb == true) + windBarb = false; + else + windBarb = true; + applyChange(); + } + }); + /* + * windBarbText = new Text(btnGp, SWT.BORDER | SWT.SINGLE); + * windBarbText.setText(Integer.toString(windBarbDistance)); + * windBarbText + * .setBounds(windBarbBtn.getBounds().x+windBarbBtn.getBounds().width, + * windBarbBtn.getBounds().y,btnWidth/4,btnHeight); + * windBarbText.setEditable(true); windBarbText.setVisible(true); //to + * make sure user enter digits only windBarbText.addListener + * (SWT.Verify, new Listener () { public void handleEvent (Event e) { + * String string = e.text; char [] chars = new char [string.length ()]; + * string.getChars (0, chars.length, chars, 0); + * //System.out.println("entered "+ string); + * + * for (int i=0; i= 1) + && (textStr.contains("-"))) { + e.doit = false; + return; + } + } else if (!('0' <= chars[0] && chars[0] <= '9')) { + e.doit = false; + return; + } + + } + } + }); + // start FixMark:nearByStnCompSnd + Label sndCompRadiusLbl = new Label(btnGp, SWT.BORDER); + sndCompRadiusLbl.setText("Sounding Comp Radius (mile)"); + sndCompRadiusLbl.setBounds(btnGp.getBounds().x + btnGapX, + tempOffsetLbl.getBounds().y + tempOffsetLbl.getBounds().height + + btnGapY, btnWidth, btnHeight); + sndCompRadiusText = new Text(btnGp, SWT.BORDER | SWT.SINGLE); + sndCompRadiusText.setText(Integer.toString(sndCompRadius)); + sndCompRadiusText.setBounds(sndCompRadiusLbl.getBounds().x + + sndCompRadiusLbl.getBounds().width, + sndCompRadiusLbl.getBounds().y, btnWidth / 4, btnHeight); + sndCompRadiusText.setEditable(true); + sndCompRadiusText.setVisible(true); + // to make sure user enter digits only + sndCompRadiusText.addListener(SWT.Verify, new Listener() { + public void handleEvent(Event e) { + String string = e.text; + char[] chars = new char[string.length()]; + string.getChars(0, chars.length, chars, 0); + // System.out.println("entered s=" + string); + // Chin note: when "Delete", "Backspace" entered, this handler + // will be called, but + // its chars.length = 0 + if (chars.length == 1) { + if (!('0' <= chars[0] && chars[0] <= '9')) { + e.doit = false; + return; + } + + } + } + }); + // end FixMark:nearByStnCompSnd + if (NsharpLoadDialog.getAccess() != null + && (NsharpLoadDialog.getAccess().getActiveLoadSoundingType() == NsharpLoadDialog.MODEL_SND || NsharpLoadDialog + .getAccess().getActiveLoadSoundingType() == NsharpLoadDialog.PFC_SND)) { + omegaBtn = new Button(btnGp, SWT.RADIO | SWT.BORDER); + omegaBtn.setText(NsharpNativeConstants.OMEGA); + omegaBtn.setEnabled(true); + omegaBtn.setBounds( + btnGp.getBounds().x + btnGapX, + sndCompRadiusLbl.getBounds().y + + sndCompRadiusLbl.getBounds().height + btnGapY, + btnWidth, btnHeight); + if (omega == true) + omegaBtn.setSelection(true); + else + omegaBtn.setSelection(false); + omegaBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if (omega == true) + omega = false; + else + omega = true; + applyChange(); + } + }); + } + + } + + @Override + public void createButtonsForButtonBar(Composite parent) { + // create OK button but using Apply label for applying user entered data + // Chin note: when "apply" button is selected or Return key is entered, + // okPressed() will be called. So, handle event at one place, ie.e at + // okPressed(). + createButton(parent, IDialogConstants.OK_ID, "Apply", true); + + /* + * appBtn.addListener( SWT.MouseUp, new Listener() { public void + * handleEvent(Event event) { + * //System.out.println("App listener is called"); //String textStr = + * windBarbText.getText(); //if((textStr != null) && + * !(textStr.isEmpty())){ // windBarbDistance = Integer.decode(textStr); + * //} //applyChange(); + * + * } } ); + */ + Button saveBtn = createButton(parent, IDialogConstants.INTERNAL_ID, + "Save", false); + saveBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + // System.out.println("save listener is called, also apply changes"); + okPressed(); + try { + // save to xml + mgr.saveConfigStoreToFs(configStore); + } catch (VizException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + } + }); + + Button canBtn = createButton(parent, IDialogConstants.CLOSE_ID, + IDialogConstants.CLOSE_LABEL, false); + canBtn.addListener(SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + // System.out.println("close listener is called"); + close(); + } + }); + } + + @Override + public void okPressed() { + // "Enter" key is pressed, or "Apply" button is pressed. + // Chin: handle user entered data and apply its changes. + // System.out.println("CR is pressed"); + // String textStr = windBarbText.getText(); + // if((textStr != null) && !(textStr.isEmpty())){ + // windBarbDistance = Integer.decode(textStr); + // } + String textStr = tempOffsetText.getText(); + if ((textStr != null) && !(textStr.isEmpty())) { + if (!textStr.contains("-") || textStr.length() > 1) { + tempOffset = Integer.decode(textStr); + System.out.println("temp offset is =" + tempOffset); + } + } + textStr = sndCompRadiusText.getText(); + if ((textStr != null) && !(textStr.isEmpty())) { + sndCompRadius = Integer.decode(textStr); + System.out.println("snd comp radius is =" + sndCompRadius); + } + applyChange(); + setReturnCode(OK); + } + + /* * (non-Javadoc) * - * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) - */ - @Override - protected void configureShell( Shell shell ) { - super.configureShell( shell ); - shell.setText( "Nsharp Parameters Selection" ); - - } - @Override - public Control createDialogArea(Composite parent) { - Composite top; - top = (Composite) super.createDialogArea(parent); + * @see + * org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets + * .Shell) + */ + @Override + protected void configureShell(Shell shell) { + super.configureShell(shell); + shell.setText("Nsharp Parameters Selection"); - // Create the main layout for the shell. - GridLayout mainLayout = new GridLayout(1, false); - mainLayout.marginHeight = 3; - mainLayout.marginWidth = 3; - top.setLayout(mainLayout); - - // Initialize all of the menus, controls, and layouts - createDialogContents(top); - - return top; - } - - - @Override - public int open( ) { - if ( this.getShell() == null ){ - this.create(); - } - this.getShell().setLocation(this.getShell().getParent().getLocation().x+1100, - this.getShell().getParent().getLocation().y+200); - return super.open(); - - } - @Override - public boolean close() { - tempBtn= dewpBtn= parcelTvBtn= parcelBtn=dcapeBtn=vTempBtn= wetBulbBtn= mixingRatioBtn= - dryAdiabatBtn=moisAdiabatBtn=efflayerBtn=omegaBtn= meanWindVectorBtn= stormMVector3075Btn= stormMVector1585Btn= - stormMVectorBunkersRightBtn=stormMVectorBunkersLeftBtn= corfidiVectorBtn= hodoBtn=windBarbBtn=null; - //thisDialog= null; - return (super.close()); } - public void reset(){ - //windBarbDistance=NsharpNativeConstants.WINDBARB_DISTANCE_DEFAULT; - tempOffset=0; - } + @Override + public Control createDialogArea(Composite parent) { + Composite top; + top = (Composite) super.createDialogArea(parent); - private void applyChange(){ - updateGraphProperty(); - NsharpEditor editor = NsharpEditor.getActiveNsharpEditor(); - if (editor != null) { - NsharpResourceHandler rsc = editor.getRscHandler(); - rsc.setGraphConfigProperty(graphProperty); - editor.refresh(); + // Create the main layout for the shell. + GridLayout mainLayout = new GridLayout(1, false); + mainLayout.marginHeight = 3; + mainLayout.marginWidth = 3; + top.setLayout(mainLayout); + + // Initialize all of the menus, controls, and layouts + createDialogContents(top); + + return top; + } + + @Override + public int open() { + if (this.getShell() == null) { + this.create(); } - } - + this.getShell().setLocation( + this.getShell().getParent().getLocation().x + 1100, + this.getShell().getParent().getLocation().y + 200); + return super.open(); + + } + + @Override + public boolean close() { + tempBtn = dewpBtn = parcelTvBtn = parcelBtn = dcapeBtn = vTempBtn = wetBulbBtn = mixingRatioBtn = dryAdiabatBtn = moisAdiabatBtn = efflayerBtn = omegaBtn = meanWindVectorBtn = stormMVector3075Btn = stormMVector1585Btn = stormMVectorBunkersRightBtn = stormMVectorBunkersLeftBtn = corfidiVectorBtn = hodoBtn = windBarbBtn = null; + // thisDialog= null; + return (super.close()); + } + + public void reset() { + // windBarbDistance=NsharpNativeConstants.WINDBARB_DISTANCE_DEFAULT; + tempOffset = 0; + sndCompRadius = 0; + } + + private void applyChange() { + updateGraphProperty(); + NsharpEditor editor = NsharpEditor.getActiveNsharpEditor(); + if (editor != null) { + NsharpResourceHandler rsc = editor.getRscHandler(); + rsc.setGraphConfigProperty(graphProperty); + editor.refresh(); + } + } + } diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpPfcSoundingDialogContents.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpPfcSoundingDialogContents.java new file mode 100644 index 0000000000..eaf81c8eed --- /dev/null +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpPfcSoundingDialogContents.java @@ -0,0 +1,424 @@ +/** + * + * gov.noaa.nws.ncep.ui.nsharp.view.PfcSoundingDialogContents + * + * This java class performs the NSHARP NsharpLoadDialog functions. + * This code has been developed by the NCEP-SIB for use in the AWIPS2 system. + * + *
+ * SOFTWARE HISTORY
+ * 
+ * Date         Ticket#    	Engineer    Description
+ * -------		------- 	-------- 	-----------
+ * 01/2011	229			Chin Chen	Initial coding
+ *
+ * 
+ * + * @author Chin Chen + * @version 1.0 + */ +package gov.noaa.nws.ncep.ui.nsharp.view; + +import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingProfile; +import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingStnInfo; +import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingStnInfoCollection; +import gov.noaa.nws.ncep.edex.common.sounding.NcSoundingTimeLines; +import gov.noaa.nws.ncep.ui.nsharp.NsharpConstants; +import gov.noaa.nws.ncep.ui.nsharp.NsharpStationInfo; +import gov.noaa.nws.ncep.ui.nsharp.display.map.NsharpMapResource; +import gov.noaa.nws.ncep.viz.common.soundingQuery.NcSoundingQuery; + +import java.sql.Timestamp; +import java.text.DateFormatSymbols; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.List; +import java.util.TimeZone; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Listener; + +public class NsharpPfcSoundingDialogContents { + private Composite parent; + private org.eclipse.swt.widgets.List availablefileList, sndTimeList; + private Group topGp, fileTypeGp, bottomGp, availableFileGp, sndTimeListGp; + private Button namBtn, gfsBtn, timeBtn; + private boolean timeLimit = false; + private List selectedFileList = new ArrayList(); + private List selectedTimeList = new ArrayList(); + private List stnPoints = new ArrayList(); + private NcSoundingProfile.PfcSndType currentSndType = NcSoundingProfile.PfcSndType.NONE; + private NsharpLoadDialog ldDia; + private Font newFont; + public NcSoundingProfile.PfcSndType getCurrentSndType() { + return currentSndType; + } + public NsharpPfcSoundingDialogContents() { + } + public NsharpPfcSoundingDialogContents (Composite parent) { + this.parent = parent; + ldDia = NsharpLoadDialog.getAccess(); + newFont = ldDia.getNewFont(); + } + private void createPFCAvailableFileList() { + sndTimeList.removeAll();; + availablefileList.removeAll(); + //query using NcSoundingQuery class to query + NcSoundingTimeLines timeLines = NcSoundingQuery.soundingTimeLineQuery(currentSndType.toString()); + if(timeLines!= null && timeLines.getTimeLines() != null){ + ldDia.startWaitCursor(); + for(Object timeLine : timeLines.getTimeLines()){ + Timestamp reftime = (Timestamp)timeLine; + if(reftime != null){ + //need to format reftime to GMT time string. Timestamp.toString produce a local time Not GMT time + Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + cal.setTimeInMillis(reftime.getTime()); + String gmtTimeStr = String.format("%1$tY-%1$tm-%1$td %1$tH", cal); + //System.out.println("GMT time " + gmtTimeStr); + availablefileList.add(gmtTimeStr); + + } + + } + ldDia.stopWaitCursor(); + } + else + System.out.println("SQL: query return null"); + } + private void createPFCSndTimeList(List selectedFlLst) { + if(selectedFlLst.size() <=0 ) + return; + //currentDBTblName = MODELSOUNDING_TBL_NAME; + sndTimeList.removeAll(); + //query using NcSoundingQuery to query + ldDia.startWaitCursor(); + String sndStr = currentSndType.toString(); + int endIndex= Math.min(3, sndStr.length()); + String dispSndStr = sndStr.substring(0, endIndex); + DateFormatSymbols dfs= new DateFormatSymbols(); + String[] defaultDays = dfs.getShortWeekdays(); + Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT")); + + for(int i=0; i< selectedFlLst.size(); i++){ + String fl = selectedFlLst.get(i); + long reftimeMs= NcSoundingQuery.convertRefTimeStr(fl); + //System.out.println("reftime="+fl + " in ms="+reftimeMs); + NcSoundingTimeLines timeLines = NcSoundingQuery.soundingRangeTimeLineQuery(sndStr, fl); + if(timeLines != null && timeLines.getTimeLines().length >0) { + for(Object obj : timeLines.getTimeLines()){ + Timestamp rangestart = (Timestamp)obj; + + //need to format rangestart to GMT time string. Timestamp.toString produce a local time Not GMT time + cal.setTimeInMillis(rangestart.getTime()); + long vHour = (cal.getTimeInMillis()- reftimeMs)/3600000; + String dayOfWeek = defaultDays[cal.get(Calendar.DAY_OF_WEEK)]; + //String gmtTimeStr = String.format("%1$ty%1$tm%1$td/%1$tH%1$tMV%2$03d %3$s", cal, vHour,dispSndStr); + String gmtTimeStr = String.format("%1$ty%1$tm%1$td/%1$tH(%4$s)V%2$03d %3$s", cal, vHour,dispSndStr,dayOfWeek); + if(sndTimeList.indexOf(gmtTimeStr) != -1){ + // this indicate that gmtTimeStr is already in the sndTimeList, then we dont need to add it to list again. + continue; + } + + //System.out.println("GMT time " + gmtTimeStr); + if(!timeLimit) + sndTimeList.add(gmtTimeStr); + else { + int hour = cal.get(Calendar.HOUR_OF_DAY); + if((hour == 0) || (hour == 12)) + sndTimeList.add(gmtTimeStr); + } + + } + } + } + ldDia.stopWaitCursor(); + } + private void handleAvailFileListSelection(){ + String selectedFile=null; + if (availablefileList.getSelectionCount() > 0 ) { + selectedFileList.clear(); + for(int i=0; i < availablefileList.getSelectionCount(); i++) { + selectedFile = availablefileList.getSelection()[i]; + //System.out.println("selected sounding file is " + selectedFile); + selectedFileList.add(selectedFile); + } + ldDia.setPfcSelectedFileList(selectedFileList); + createPFCSndTimeList(selectedFileList); + } + } + private void handleSndTimeSelection(){ + String selectedSndTime=null; + if (sndTimeList.getSelectionCount() > 0 ) { + NsharpMapResource nsharpMapResource = NsharpMapResource.getOrCreateNsharpMapResource();//NsharpLoadDialog.getAccess().getNsharpMapResource(); + nsharpMapResource.setPoints(null); + selectedTimeList.clear(); + ldDia.startWaitCursor(); + List queriedTimeList = new ArrayList(); + for(int i=0; i < sndTimeList.getSelectionCount(); i++) { + selectedSndTime = sndTimeList.getSelection()[i]; + selectedTimeList.add(selectedSndTime); + int endIndex = selectedSndTime.indexOf(" "); + String querySndTime = selectedSndTime.substring(0, endIndex); + //System.out.println("selected sounding time is " + selectedSndTime); + //refTimeStr is same as "PFC file" name in Load dialog display + String refTimeStr=NcSoundingQuery.convertSoundTimeDispStringToForecastTime(querySndTime); + //while rangeStartStr is same as "sounding Times + String rangeStartStr = NcSoundingQuery.convertSoundTimeDispStringToRangeStartTimeFormat(querySndTime); + if(queriedTimeList.contains(refTimeStr)== true){ + addStnPtWithoutQuery(refTimeStr,rangeStartStr,querySndTime); + } + else { + queriedTimeList.add(refTimeStr); + queryAndMarkStn(refTimeStr,rangeStartStr,querySndTime); + } + } + + ldDia.stopWaitCursor(); + + nsharpMapResource.setPoints(stnPoints); + NsharpMapResource.bringMapEditorToTop(); + } + } + public void createPfcDialogContents(){ + topGp = new Group(parent,SWT.SHADOW_ETCHED_IN); + topGp.setLayout( new GridLayout( 2, false ) ); + + currentSndType = ldDia.getActivePfcSndType(); + ldDia.createSndTypeList(topGp); + + fileTypeGp = new Group(topGp, SWT.SHADOW_ETCHED_IN); + fileTypeGp.setText("File Type"); + fileTypeGp.setFont(newFont); + namBtn = new Button(fileTypeGp, SWT.RADIO | SWT.BORDER); + namBtn.setText("NAMSND"); + namBtn.setEnabled( true ); + namBtn.setBounds(fileTypeGp.getBounds().x+ NsharpConstants.btnGapX, fileTypeGp.getBounds().y + NsharpConstants.labelGap, NsharpConstants.btnWidth,NsharpConstants.btnHeight); + namBtn.setFont(newFont); + namBtn.addListener( SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + currentSndType = NcSoundingProfile.PfcSndType.NAMSND; + createPFCAvailableFileList(); + ldDia.setActivePfcSndType(currentSndType); + } + } ); + gfsBtn = new Button(fileTypeGp, SWT.RADIO | SWT.BORDER); + gfsBtn.setText("GFSSND"); + gfsBtn.setEnabled( true ); + gfsBtn.setBounds(fileTypeGp.getBounds().x+ NsharpConstants.btnGapX, namBtn.getBounds().y + namBtn.getBounds().height+ NsharpConstants.btnGapY, NsharpConstants.btnWidth,NsharpConstants.btnHeight); + gfsBtn.setFont(newFont); + gfsBtn.addListener( SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + currentSndType = NcSoundingProfile.PfcSndType.GFSSND; + createPFCAvailableFileList(); + ldDia.setActivePfcSndType(currentSndType); + } + } ); + + + timeBtn = new Button(parent, SWT.CHECK | SWT.BORDER); + timeBtn.setText("00Z and 12Z only"); + timeBtn.setEnabled( true ); + //timeBtn.setBounds(fileTypeGp.getBounds().x+ NsharpConstants.btnGapX, browseBtn.getBounds().y + browseBtn.getBounds().height+ NsharpConstants.btnGapY, NsharpConstants.btnWidth,NsharpConstants.btnHeight); + timeBtn.setFont(newFont); + timeBtn.addListener( SWT.MouseUp, new Listener() { + public void handleEvent(Event event) { + if(timeLimit) + timeLimit = false; + else + timeLimit = true; + + //refresh sounding list if file type is selected already + if(!currentSndType.equals("NA") && selectedFileList.size() > 0 ){ + createPFCSndTimeList(selectedFileList); + } + + } + } ); + + bottomGp = new Group(parent,SWT.SHADOW_ETCHED_IN); + bottomGp.setLayout( new GridLayout( 2, false ) ); + + availableFileGp = new Group(bottomGp,SWT.SHADOW_ETCHED_IN); + availableFileGp.setText("Available PFC files:"); + availableFileGp.setFont(newFont); + + availablefileList = new org.eclipse.swt.widgets.List(availableFileGp, SWT.BORDER | /*// FixMark:nearByStnCompSnd SWT.MULTI| */SWT.V_SCROLL ); + availablefileList.setBounds(availableFileGp.getBounds().x, availableFileGp.getBounds().y + NsharpConstants.labelGap , NsharpConstants.filelistWidth, NsharpConstants.listHeight *36/5); + //create a selection listener to handle user's selection on list + availablefileList.setFont(newFont); + availablefileList.addListener ( SWT.Selection, new Listener () { + public void handleEvent (Event e) { + handleAvailFileListSelection(); + } + } ); + + //create Sounding Times widget list + sndTimeListGp = new Group(bottomGp,SWT.SHADOW_ETCHED_IN); + sndTimeListGp.setText("Sounding Times:"); + sndTimeListGp.setFont(newFont); + sndTimeList = new org.eclipse.swt.widgets.List(sndTimeListGp, SWT.BORDER | SWT.MULTI| SWT.V_SCROLL ); + sndTimeList.removeAll(); + sndTimeList.setFont(newFont); + sndTimeList.setBounds(sndTimeListGp.getBounds().x, sndTimeListGp.getBounds().y + NsharpConstants.labelGap, NsharpConstants.listWidth, NsharpConstants.listHeight*36/5 ); + sndTimeList.addListener ( SWT.Selection, new Listener () { + // private String selectedSndTime=null; + public void handleEvent (Event e) { + handleSndTimeSelection(); + } + + }); + if(currentSndType==NcSoundingProfile.PfcSndType.GFSSND || currentSndType==NcSoundingProfile.PfcSndType.NAMSND){ + if(currentSndType==NcSoundingProfile.PfcSndType.GFSSND) + gfsBtn.setSelection(true); + else + namBtn.setSelection(true); + createPFCAvailableFileList(); + selectedFileList = ldDia.getPfcSelectedFileList(); + Object[] selFileObjectArray = selectedFileList.toArray(); + String[] selFileStringArray = Arrays.copyOf(selFileObjectArray, selFileObjectArray.length, String[].class); + availablefileList.setSelection(selFileStringArray); + handleAvailFileListSelection(); + + selectedTimeList = ldDia.getPfcSelectedTimeList(); + Object[] selTimeObjectArray = selectedTimeList.toArray(); + String[] selTimeStringArray = Arrays.copyOf(selTimeObjectArray, selTimeObjectArray.length, String[].class); + sndTimeList.setSelection(selTimeStringArray); + handleSndTimeSelection(); + + + } + } + + private void addStnPtWithoutQuery(String refTimeStr,String rangeStartStr, String selectedSndTime) { + long reftimeMs= NcSoundingQuery.convertRefTimeStr(refTimeStr); + Timestamp refTime = new Timestamp(reftimeMs); + for(NsharpStationInfo stn: stnPoints){ + if(refTime.equals(stn.getReftime())== true){ + long rangetimeMs= NcSoundingQuery.convertRefTimeStr(rangeStartStr); + Timestamp rangeStartTime = new Timestamp(rangetimeMs); + NsharpStationInfo.timeLineSpecific timeLinsSpc = stn.new timeLineSpecific(); + String sndTypeStr = currentSndType.toString(); + int endIndex= Math.min(4, sndTypeStr.length()); + String dispInfo = stn.getStnId()+ " " + selectedSndTime+" "+sndTypeStr.substring(0,endIndex); + timeLinsSpc.setDisplayInfo(dispInfo); + timeLinsSpc.setTiemLine(rangeStartTime); + stn.addToTimeLineSpList(timeLinsSpc); + } + } + //System.out.println("addStnPtWithoutQuery stn num ="+ stnPoints.size()+ " for pfc refTime(file) "+refTimeStr); + } + private void queryAndMarkStn(String refTimeStr,String rangeStartStr, String selectedSndTime) { + //use NcSoundingQuery to query stn info + String sndTypeStr = currentSndType.toString(); + NcSoundingStnInfoCollection sndStnInfoCol = NcSoundingQuery.soundingStnInfoQuery(sndTypeStr,rangeStartStr, refTimeStr); + if(sndStnInfoCol != null && sndStnInfoCol.getStationInfo() != null){ + + NcSoundingStnInfo[] stnInfoAry = sndStnInfoCol.getStationInfo(); + //System.out.println("queryAndMarkStn stn num ="+ stnInfoAry.length+ " for pfc refTime(file) "+refTimeStr); + for(int i=0; i < stnInfoAry.length; i++){ + NcSoundingStnInfo stnInfo = stnInfoAry[i]; + NsharpStationInfo stn = new NsharpStationInfo(); + NsharpStationInfo.timeLineSpecific timeLinsSpc = stn.new timeLineSpecific(); + + int endIndex= Math.min(4, sndTypeStr.length()); + String packedStnIdStr= stnInfo.getStnId().replace(" ", "_"); + String dispInfo = packedStnIdStr + " " + selectedSndTime+" "+sndTypeStr.substring(0,endIndex); + timeLinsSpc.setDisplayInfo(dispInfo); + timeLinsSpc.setTiemLine(stnInfo.getRangeStartTime()); + stn.addToTimeLineSpList(timeLinsSpc); + stn.setLongitude(stnInfo.getStationLongitude()); + stn.setLatitude(stnInfo.getStationLatitude()); + stn.setReftime(stnInfo.getSynopTime()); + stn.setStnId(stnInfo.getStnId()); + stn.setSndType(sndTypeStr); + //if(i <10) + // System.out.println( "disP="+dispInfo+" refT= "+stnInfo.getSynopTime()+ " rangSt="+stnInfo.getRangeStartTime()); + stnPoints.add(stn); + } + + + } + } + public void cleanup(){ + if(namBtn != null&& namBtn.isDisposed()== false){ + namBtn.removeListener(SWT.MouseUp, namBtn.getListeners(SWT.MouseUp)[0]); + namBtn.dispose(); + namBtn = null; + } + if(gfsBtn != null){ + gfsBtn.removeListener(SWT.MouseUp, gfsBtn.getListeners(SWT.MouseUp)[0]); + gfsBtn.dispose(); + gfsBtn = null; + } + /*if(ruc2Btn != null){ + ruc2Btn.removeListener(SWT.MouseUp, ruc2Btn.getListeners(SWT.MouseUp)[0]); + ruc2Btn.dispose(); + ruc2Btn = null; + } + if(rucpBtn != null){ + rucpBtn.removeListener(SWT.MouseUp, rucpBtn.getListeners(SWT.MouseUp)[0]); + rucpBtn.dispose(); + rucpBtn = null; + } + if(browseBtn != null){ + browseBtn.removeListener(SWT.MouseUp, browseBtn.getListeners(SWT.MouseUp)[0]); + browseBtn.dispose(); + browseBtn = null; + + } */ + NsharpLoadDialog ldDia = NsharpLoadDialog.getAccess(); + ldDia.cleanSndTypeList(); + if(topGp!= null){ + topGp.dispose(); + topGp = null; + } + + if(timeBtn != null){ + timeBtn.removeListener(SWT.MouseUp, timeBtn.getListeners(SWT.MouseUp)[0]); + timeBtn.dispose(); + timeBtn = null; + } + + if(fileTypeGp!= null){ + fileTypeGp.dispose(); + fileTypeGp = null; + } + + if(availablefileList!= null){ + availablefileList.removeListener(SWT.Selection, availablefileList.getListeners(SWT.Selection)[0]); + availablefileList.dispose(); + availablefileList = null; + } + + + if(availableFileGp!= null){ + availableFileGp.dispose(); + availableFileGp = null; + } + if(sndTimeList!= null){ + sndTimeList.removeListener(SWT.Selection, sndTimeList.getListeners(SWT.Selection)[0]); + sndTimeList.dispose(); + sndTimeList = null; + } + if(sndTimeListGp!= null){ + sndTimeListGp.dispose(); + sndTimeListGp = null; + } + if(bottomGp!= null){ + bottomGp.dispose(); + bottomGp = null; + } + /*if(newTabBtn != null){ + newTabBtn.removeListener(SWT.MouseUp, newTabBtn.getListeners(SWT.MouseUp)[0]); + newTabBtn.dispose(); + newTabBtn = null; + }*/ + } +} diff --git a/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/nsharp/nsharpConfig.xml b/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/nsharp/nsharpConfig.xml index 8bf2e1678b..284b47511c 100644 --- a/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/nsharp/nsharpConfig.xml +++ b/ncep/gov.noaa.nws.ncep.viz.localization/localization/ncep/nsharp/nsharpConfig.xml @@ -1,6 +1,6 @@ - + @@ -128,5 +128,5 @@ - + diff --git a/ncep/gov.noaa.nws.ncep.viz.ui.perspectives/plugin.xml b/ncep/gov.noaa.nws.ncep.viz.ui.perspectives/plugin.xml index fe81d038f2..7e14262bb5 100644 --- a/ncep/gov.noaa.nws.ncep.viz.ui.perspectives/plugin.xml +++ b/ncep/gov.noaa.nws.ncep.viz.ui.perspectives/plugin.xml @@ -427,6 +427,12 @@ commandId="gov.noaa.nws.ncep.viz.CustomProjection" label="Custom Area..."> + +