Issue #1457 Initial changes for MPE time refactor. Wrote custom resource that handles multiple times and tailored code to use resource instead of old XmrgResource which was not written to support multiple frames

Amend: Cleaned up comments and some bugs in code after review

Amend: Rebased changes

Change-Id: I512b9bb30a08b9a1cfc5e8d9b5008ebc4f352c2d

Former-commit-id: ab74da7808aa343983f532ee076820c7e63fdded
This commit is contained in:
Max Schenkelberg 2013-01-02 16:32:48 -06:00
parent 12e0a100c4
commit db3e7bab99
88 changed files with 5315 additions and 5831 deletions

View file

@ -29,7 +29,6 @@ import javax.measure.unit.SI;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.geotools.coverage.grid.GridGeometry2D;
import org.opengis.metadata.spatial.PixelOrientation;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import com.raytheon.uf.common.geospatial.MapUtil;
@ -66,6 +65,19 @@ public class SetProjection extends AbstractTool {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(SetProjection.class);
public static enum Projection {
FLAT, POLAR, HRAP;
public static Projection fromString(String projection) {
for (Projection p : Projection.values()) {
if (p.name().equalsIgnoreCase(projection)) {
return p;
}
}
return null;
}
}
private static final double NMI_PER_DEG = 60.0;
private static final UnitConverter converter = NonSI.NAUTICAL_MILE
@ -85,7 +97,7 @@ public class SetProjection extends AbstractTool {
String projection = arg0.getParameter("projection");
String prefix = arg0.getParameter("prefix");
setProjection(editor, projection, prefix);
setProjection(editor, Projection.fromString(projection), prefix);
return null;
}
@ -94,7 +106,7 @@ public class SetProjection extends AbstractTool {
AppsDefaults appsDefaults = AppsDefaults.getInstance();
String projection = appsDefaults.getToken(prefix + "_map_projection",
"FLAT");
setProjection(editor, projection, prefix);
setProjection(editor, Projection.fromString(projection), prefix);
}
/**
@ -104,7 +116,10 @@ public class SetProjection extends AbstractTool {
* should be one of "FLAT", "POLAR", or "HRAP"
*/
public static void setProjection(IDisplayPaneContainer editor,
String projection, String prefix) {
Projection projection, String prefix) {
if (projection == null) {
projection = Projection.FLAT;
}
// get these from the token file
AppsDefaults appsDefaults = AppsDefaults.getInstance();
double centerLat = appsDefaults.getDouble(prefix + "_center_lat", 0.0);
@ -117,20 +132,22 @@ public class SetProjection extends AbstractTool {
double zoomLimit = 4.0;
try {
GridGeometry2D gridGeometry;
if ("FLAT".equals(projection)) {
CoordinateReferenceSystem crs = MapUtil.LATLON_PROJECTION;
CoordinateReferenceSystem crs;
GridGeometry2D gridGeometry = null;
switch (projection) {
case FLAT:
crs = MapUtil.LATLON_PROJECTION;
double height_in_degrees = widthInNmi / NMI_PER_DEG * zoomLimit;
gridGeometry = MapDescriptor.createGridGeometry(crs,
new Coordinate(centerLon, centerLat),
height_in_degrees, height_in_degrees);
} else if ("POLAR".equals(projection)) {
CoordinateReferenceSystem crs = MapUtil
.constructNorthPolarStereo(MapUtil.AWIPS_EARTH_RADIUS,
MapUtil.AWIPS_EARTH_RADIUS, 60, centerLon);
break;
case POLAR:
crs = MapUtil.constructNorthPolarStereo(
MapUtil.AWIPS_EARTH_RADIUS, MapUtil.AWIPS_EARTH_RADIUS,
60, centerLon);
double width_in_meters = converter.convert(widthInNmi)
* zoomLimit;
@ -138,33 +155,16 @@ public class SetProjection extends AbstractTool {
gridGeometry = MapDescriptor.createGridGeometry(crs,
new Coordinate(centerLon, centerLat), width_in_meters,
width_in_meters);
} else if ("HRAP".equals(projection)) {
break;
case HRAP:
HRAP hrap = HRAP.getInstance();
Coordinate ll = hrap.gridCoordinateToLatLon(
hrap.getGridPointLL(), PixelOrientation.LOWER_LEFT);
Point p = hrap.getGridPointUR();
p.x++;
p.y++;
Coordinate ur = hrap.gridCoordinateToLatLon(p,
PixelOrientation.LOWER_LEFT);
Rectangle extent = HRAPCoordinates.getHRAPCoordinates();
HRAPSubGrid subGrid = new HRAPSubGrid(extent);
GridGeometry2D subGridGeo = MapUtil.getGridGeometry(subGrid);
// Make sure our location is contained within the default HRAP
// grid
// if (hrap.getGridGeometry().getEnvelope2D()
// .contains(subGridGeo.getEnvelope2D())) {
// CoordinateReferenceSystem crs = subGridGeo
// .getCoordinateReferenceSystem();
//
// gridGeometry = MapDescriptor
// .createGridGeometry(crs, ll, ur);
// If not recompute the projection, with a zoom factor of
// 40%
// } else {
int nx = (subGrid.getNx() + ((subGrid.getNx()) * 6));
int ny = (subGrid.getNy() + ((subGrid.getNy()) * 6));
int factorNx = Math.abs((subGrid.getNx() - nx) / 2);
@ -174,9 +174,8 @@ public class SetProjection extends AbstractTool {
Rectangle newExtent = new Rectangle(newX, newY, nx, ny);
HRAPSubGrid newSubGrid = new HRAPSubGrid(newExtent);
gridGeometry = MapUtil.getGridGeometry(newSubGrid);
// }
} else {
break;
default:
statusHandler.handle(Priority.PROBLEM, "\"" + projection
+ "\" is not a recognized projection.");
return;
@ -185,7 +184,7 @@ public class SetProjection extends AbstractTool {
if (editor == null) {
editor = EditorUtil.getActiveVizContainer();
}
for (IDisplayPane pane : editor.getDisplayPanes()) {
IMapDescriptor md = (IMapDescriptor) pane.getDescriptor();
md.setGridGeometry(gridGeometry);

View file

@ -19,13 +19,15 @@
**/
package com.raytheon.viz.hydrocommon.resource;
import java.awt.Rectangle;
import org.eclipse.swt.graphics.RGB;
import org.opengis.metadata.spatial.PixelOrientation;
import org.geotools.coverage.grid.GridGeometry2D;
import org.opengis.coverage.grid.GridEnvelope;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.datum.PixelInCell;
import org.opengis.referencing.operation.MathTransform;
import com.raytheon.uf.common.hydro.spatial.HRAP;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.geospatial.TransformFactory;
import com.raytheon.uf.common.hydro.spatial.HRAPCoordinates;
import com.raytheon.uf.common.hydro.spatial.HRAPSubGrid;
import com.raytheon.uf.viz.core.IGraphicsTarget;
@ -36,7 +38,6 @@ import com.raytheon.uf.viz.core.map.MapDescriptor;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.capabilities.OutlineCapability;
import com.vividsolutions.jts.geom.Coordinate;
/**
* HydroView and MPE HRAP overlay resource.
@ -56,123 +57,76 @@ import com.vividsolutions.jts.geom.Coordinate;
public class HRAPOverlayResource extends
AbstractVizResource<HRAPOverlayResourceData, MapDescriptor> {
private Rectangle hrapExtent;
private IWireframeShape grid = null;
private IWireframeShape grid;
protected HRAPOverlayResource(HRAPOverlayResourceData resourceData,
LoadProperties loadProperties) {
super(resourceData, loadProperties);
}
/**
* Paint the grid on the map.
*
* @param target
* The IGraphicsTarget
*/
private void paintGrid(IGraphicsTarget target) {
if ((grid != null)
&& (getCapability(OutlineCapability.class).isOutlineOn())) {
try {
target.drawWireframeShape(grid, new RGB(255, 255, 255),
getCapability(OutlineCapability.class)
.getOutlineWidth(),
getCapability(OutlineCapability.class).getLineStyle());
} catch (VizException e) {
e.printStackTrace();
}
}
}
/**
* Load the IWireframeShape
*
* @param target
* The IGraphicsTarget
* @return The IWireframeShape
*/
private IWireframeShape loadGrid(IGraphicsTarget target) {
int x1;
int y1;
int x2;
int y2;
if (hrapExtent == null) {
try {
hrapExtent = HRAPCoordinates.getHRAPCoordinates();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
IWireframeShape grid = target.createWireframeShape(false, descriptor);
HRAP hrap = HRAP.getInstance();
try {
HRAPSubGrid subGrid = hrap.getHRAPSubGrid(hrapExtent);
int minX = subGrid.getExtent().x;
int minY = subGrid.getExtent().y;
int nx = subGrid.getNx();
int ny = subGrid.getNy();
int maxX = minX + nx;
int maxY = minY + ny;
// Vertical Lines
for (int i = 0; i < nx + 1; i++) {
x1 = minX + i;
y1 = minY;
x2 = minX + i;
y2 = maxY;
Coordinate[] ca = new Coordinate[2];
ca[0] = new Coordinate(x1, y1);
ca[0] = hrap.gridCoordinateToLatLon(ca[0],
PixelOrientation.CENTER);
ca[1] = new Coordinate(x2, y2);
ca[1] = hrap.gridCoordinateToLatLon(ca[1],
PixelOrientation.CENTER);
grid.addLineSegment(ca);
}
// Horizontal lines
for (int i = 0; i < ny + 1; i++) {
x1 = minX;
y1 = minY + i;
x2 = maxX;
y2 = minY + i;
Coordinate[] ca = new Coordinate[2];
ca[0] = new Coordinate(x1, y1);
ca[0] = hrap.gridCoordinateToLatLon(ca[0],
PixelOrientation.CENTER);
ca[1] = new Coordinate(x2, y2);
ca[1] = hrap.gridCoordinateToLatLon(ca[1],
PixelOrientation.CENTER);
grid.addLineSegment(ca);
}
} catch (Exception e) {
e.printStackTrace();
}
return grid;
}
@Override
protected void disposeInternal() {
if (grid != null) {
grid.dispose();
grid = null;
}
}
@Override
protected void initInternal(IGraphicsTarget target) throws VizException {
grid = loadGrid(target);
grid = target.createWireframeShape(false, descriptor);
try {
GridGeometry2D gridGeometry = MapUtil
.getGridGeometry(new HRAPSubGrid(HRAPCoordinates
.getHRAPCoordinates()));
MathTransform mt = TransformFactory.gridCellToGridCell(
gridGeometry, PixelInCell.CELL_CORNER,
descriptor.getGridGeometry(), PixelInCell.CELL_CENTER);
GridEnvelope ge = gridGeometry.getGridRange();
int minX = ge.getLow(0);
int width = ge.getSpan(0) + 1;
int minY = ge.getLow(1);
int height = ge.getSpan(1) + 1;
for (int x = 0; x < width; ++x) {
double[][] line = new double[height][];
for (int y = 0; y < height; ++y) {
double[] out = new double[2];
mt.transform(new double[] { minX + x, minY + y }, 0, out,
0, 1);
line[y] = out;
}
grid.addLineSegment(line);
}
for (int y = 0; y < height; ++y) {
double[][] line = new double[height][];
for (int x = 0; x < width; ++x) {
double[] out = new double[2];
mt.transform(new double[] { minX + x, minY + y }, 0, out,
0, 1);
line[x] = out;
}
grid.addLineSegment(line);
}
grid.compile();
} catch (Exception e) {
throw new VizException("Error creating HRAP Overlay", e);
}
}
@Override
protected void paintInternal(IGraphicsTarget target,
PaintProperties paintProps) throws VizException {
paintGrid(target);
if (grid != null) {
OutlineCapability outline = getCapability(OutlineCapability.class);
if (outline.isOutlineOn()) {
target.drawWireframeShape(grid, new RGB(255, 255, 255),
outline.getOutlineWidth(), outline.getLineStyle());
}
}
}
@Override

View file

@ -22,7 +22,8 @@ Require-Bundle: org.eclipse.ui,
com.raytheon.uf.viz.core.maps;bundle-version="1.12.1174",
com.raytheon.uf.common.dataplugin.shef;bundle-version="1.12.1174",
com.raytheon.uf.viz.application,
com.raytheon.viz.ui.personalities.awips;bundle-version="1.12.1174"
com.raytheon.viz.ui.personalities.awips;bundle-version="1.12.1174",
com.raytheon.uf.viz.core.rsc;bundle-version="1.0.0"
Bundle-ActivationPolicy: lazy
Export-Package: com.raytheon.viz.mpe.ui.dialogs.gagetable.xml,
com.raytheon.viz.mpe.ui.displays,

View file

@ -1,5 +1,4 @@
com.raytheon.viz.mpe.ui.rsc.MPERadarRingOverlayResourceData
com.raytheon.viz.mpe.ui.displays.MPEMapRenderableDisplay
com.raytheon.viz.mpe.ui.rsc.XmrgResourceData
com.raytheon.uf.viz.core.rsc.GenericResourceData
com.raytheon.viz.mpe.ui.displays.MPETimeMatcher
com.raytheon.viz.mpe.ui.rsc.RadarGageOverlayRscData

View file

@ -0,0 +1,170 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
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.
-->
<bundle editor="com.raytheon.viz.ui.glmap.GLMapEditor">
<displayList>
<displays xsi:type="mpeMapRenderableDisplay" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<descriptor xsi:type="mapDescriptor">
<resource>
<loadProperties loadWithoutData="false">
<capabilities>
<capability xsi:type="outlineCapability" lineStyle="SOLID"
outlineOn="true" outlineWidth="1" />
<capability xsi:type="colorableCapability"
colorAsString="#9b9b9b" />
</capabilities>
<resourceType>PLAN_VIEW</resourceType>
</loadProperties>
<properties renderingOrderId="MAP_OUTLINE"
isSystemResource="false" isBlinking="false" isMapLayer="true"
isHoverOn="false" opacity="1.0" isVisible="true">
<pdProps maxDisplayWidth="100000000" minDisplayWidth="0" />
</properties>
<resourceData xsi:type="mapResourceGroupData">
<resource>
<loadProperties loadWithoutData="false">
<capabilities>
<capability xsi:type="outlineCapability" lineStyle="SOLID"
outlineOn="true" outlineWidth="1" />
<capability xsi:type="colorableCapability"
colorAsString="#9b9b9b" />
</capabilities>
<resourceType>PLAN_VIEW</resourceType>
</loadProperties>
<properties isSystemResource="false" isBlinking="false"
isMapLayer="true" isHoverOn="false" opacity="1.0" isVisible="true">
<pdProps maxDisplayWidth="100000000" minDisplayWidth="0" />
</properties>
<resourceData xsi:type="dbMapResourceData">
<mapName>World</mapName>
<table>mapdata.world</table>
<geomField>the_geom</geomField>
<constraint>name not in ('CANADA', 'MEXICO', 'UNITED STATES')
</constraint>
</resourceData>
</resource>
<resource>
<loadProperties loadWithoutData="false">
<capabilities>
<capability xsi:type="outlineCapability" lineStyle="SOLID"
outlineOn="true" outlineWidth="1" />
<capability xsi:type="colorableCapability"
colorAsString="#9b9b9b" />
</capabilities>
<resourceType>PLAN_VIEW</resourceType>
</loadProperties>
<properties isSystemResource="false" isBlinking="false"
isMapLayer="true" isHoverOn="false" opacity="1.0" isVisible="true">
<pdProps maxDisplayWidth="100000000" minDisplayWidth="750000" />
</properties>
<resourceData xsi:type="dbMapResourceData">
<mapName>State Boundaries</mapName>
<table>mapdata.states</table>
<geomField>the_geom</geomField>
</resourceData>
</resource>
<resource>
<loadProperties loadWithoutData="false">
<capabilities>
<capability xsi:type="outlineCapability" lineStyle="SOLID"
outlineOn="true" outlineWidth="1" />
<capability xsi:type="colorableCapability"
colorAsString="#9b9b9b" />
</capabilities>
<resourceType>PLAN_VIEW</resourceType>
</loadProperties>
<properties isSystemResource="false" isBlinking="false"
isMapLayer="true" isHoverOn="false" opacity="1.0" isVisible="true">
<pdProps maxDisplayWidth="100000000" minDisplayWidth="0" />
</properties>
<resourceData xsi:type="dbMapResourceData">
<mapName>Canada</mapName>
<table>mapdata.canada</table>
<geomField>the_geom</geomField>
</resourceData>
</resource>
<resource>
<loadProperties loadWithoutData="false">
<capabilities>
<capability xsi:type="outlineCapability" lineStyle="SOLID"
outlineOn="true" outlineWidth="1" />
<capability xsi:type="colorableCapability"
colorAsString="#9b9b9b" />
</capabilities>
<resourceType>PLAN_VIEW</resourceType>
</loadProperties>
<properties isSystemResource="false" isBlinking="false"
isMapLayer="true" isHoverOn="false" opacity="1.0" isVisible="true">
<pdProps maxDisplayWidth="100000000" minDisplayWidth="0" />
</properties>
<resourceData xsi:type="dbMapResourceData">
<mapName>Mexico</mapName>
<table>mapdata.mexico</table>
<geomField>the_geom</geomField>
</resourceData>
</resource>
<resource>
<loadProperties loadWithoutData="false">
<capabilities>
<capability xsi:type="outlineCapability" lineStyle="SOLID"
outlineOn="true" outlineWidth="1" />
<capability xsi:type="colorableCapability"
colorAsString="#9b9b9b" />
</capabilities>
<resourceType>PLAN_VIEW</resourceType>
</loadProperties>
<properties isSystemResource="false" isBlinking="false"
isMapLayer="true" isHoverOn="false" opacity="1.0" isVisible="true">
<pdProps maxDisplayWidth="750000" minDisplayWidth="0" />
</properties>
<resourceData xsi:type="dbMapResourceData">
<mapName>County Boundaries</mapName>
<table>mapdata.county</table>
</resourceData>
</resource>
<mapName>State/County Boundaries</mapName>
</resourceData>
</resource>
<gridGeometry envelopeMaxY="4023747.8031403385"
envelopeMinY="-535763.0304681085" envelopeMaxX="2889016.9103023135"
envelopeMinX="-3217360.2108624117" rangeY="0 9999" rangeX="0 13391">
<CRS>PROJCS["Lambert_Conformal_Conic_1SP",
GEOGCS["WGS84(DD)",
DATUM["WGS84",
SPHEROID["WGS84", 6378137.0, 298.257223563]],
PRIMEM["Greenwich", 0.0],
UNIT["degree", 0.017453292519943295],
AXIS["Geodetic longitude", EAST],
AXIS["Geodetic latitude", NORTH]],
PROJECTION["Lambert_Conformal_Conic_1SP"],
PARAMETER["semi_major", 6371200.0],
PARAMETER["semi_minor", 6371200.0],
PARAMETER["central_meridian", -95.0],
PARAMETER["latitude_of_origin", 25.0],
PARAMETER["false_easting", 0.0],
PARAMETER["false_northing", 0.0],
UNIT["m", 1.0],
AXIS["Easting", EAST],
AXIS["Northing", NORTH]]</CRS>
</gridGeometry>
</descriptor>
</displays>
</displayList>
</bundle>

View file

@ -124,8 +124,6 @@
<mapName>State/County Boundaries</mapName>
</resourceData>
</resource>
<timeMatcher xsi:type="d2DTimeMatcher" loadMode="VALID_TIME_SEQ" deltaFilter="0" forecastFilter="0"/>
<numberOfFrames>12</numberOfFrames>
<gridGeometry envelopeMaxY="4023747.8031403385" envelopeMinY="-535763.0304681085" envelopeMaxX="2889016.9103023135" envelopeMinX="-3217360.2108624117" rangeY="0 9999" rangeX="0 13391">
<CRS>PROJCS["Lambert_Conformal_Conic_1SP",
GEOGCS["WGS84(DD)",

View file

@ -292,7 +292,7 @@
mnemonic="A"
style="radio">
<parameter
name="Missing"
name="org.eclipse.ui.commands.radioStateParameter"
value="MissingAll">
</parameter>
</command>
@ -302,7 +302,7 @@
mnemonic="R"
style="radio">
<parameter
name="Missing"
name="org.eclipse.ui.commands.radioStateParameter"
value="MissingReported">
</parameter>
</command>
@ -312,7 +312,7 @@
mnemonic="N"
style="radio">
<parameter
name="Missing"
name="org.eclipse.ui.commands.radioStateParameter"
value="MissingNone">
</parameter>
</command>
@ -924,10 +924,14 @@
id="com.raytheon.viz.mpe.ui.actions.toggleGageMissing"
name="Show Missing">
<commandParameter
id="Missing"
name="Missing"
id="org.eclipse.ui.commands.radioStateParameter"
name="State"
optional="false">
</commandParameter>
<state
class="org.eclipse.ui.handlers.RadioState:MissingNone"
id="org.eclipse.ui.commands.radioState">
</state>
</command>
<command
id="com.raytheon.viz.mpe.ui.actions.toggleGageColor"
@ -937,12 +941,10 @@
name="State"
optional="false">
</commandParameter>
<!--
<state
class="org.eclipse.ui.handlers.RadioState:Contrast"
class="org.eclipse.ui.handlers.RadioState:Solid"
id="org.eclipse.ui.commands.radioState">
</state>
-->
</command>
<command
id="com.raytheon.viz.mpe.ui.actions.saveBestEstimate"
@ -1234,7 +1236,7 @@
</activeWhen>
</handler>
<handler
class="com.raytheon.viz.mpe.ui.actions.SaveBestEstimate"
class="com.raytheon.viz.mpe.ui.actions.SaveBestEstimateHandler"
commandId="com.raytheon.viz.mpe.ui.actions.saveBestEstimate">
<activeWhen>
<reference
@ -1404,8 +1406,8 @@
<extension
point="com.raytheon.uf.viz.core.resource">
<resource
class="com.raytheon.viz.mpe.ui.rsc.XmrgResource"
name="XMRG"
class="com.raytheon.viz.mpe.ui.rsc.MPEFieldResource"
name="MPEFieldResource"
renderingOrderId="IMAGE_REGION"
resourceType="PLAN_VIEW">
</resource>
@ -1488,12 +1490,6 @@
renderingOrderId="IMAGE_REGION"
resourceType="PLAN_VIEW">
</resource>
<resource
class="com.raytheon.viz.mpe.ui.rsc.TimeLapseResource"
name="Time Lapse Resource"
renderingOrderId="IMAGE_REGION"
resourceType="PLAN_VIEW">
</resource>
<resource
class="com.raytheon.viz.mpe.ui.rsc.MPEPolygonResource"
name="MPEPolygonResource"

View file

@ -0,0 +1,50 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.mpe;
import org.eclipse.ui.IWorkbenchCommandConstants;
/**
* Command constants for MPE, based off of {@link IWorkbenchCommandConstants}
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 29, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public interface MPECommandConstants {
public static final String FONT = "com.raytheon.viz.mpe.ui.actions.setfont";
public static final String GAGE_COLOR = "com.raytheon.viz.mpe.ui.actions.toggleGageColor";
public static final String GAGE_MISSING_OPTION = "com.raytheon.viz.mpe.ui.actions.toggleGageMissing";
public static final String DISPLAY_MODE = "com.raytheon.viz.mpe.ui.actions.toggleDisplayMode";
}

View file

@ -1,82 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.mpe;
import java.text.SimpleDateFormat;
import java.util.TimeZone;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 10, 2009 mpduff Initial creation
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
public class MPEConstants {
private static final String GMT = "GMT";
/**
* yyyyMMddHH format
*/
public static SimpleDateFormat DATE_FORMAT = new SimpleDateFormat(
"yyyyMMddHH");
/**
* MMddyyyyHH format
*/
public static SimpleDateFormat XMRG_DATE_FORMAT = new SimpleDateFormat(
"MMddyyyyHH");
/**
* MMM dd yyyy HH format
*/
public static SimpleDateFormat DATE_FORMAT_MMDDYYYYHH = new SimpleDateFormat(
"MMM dd yyyy HH");
/**
* MMddyyyyHHmm
*/
public static SimpleDateFormat DATE_FORMAT_MMDDYYYYHHMM = new SimpleDateFormat(
"MMddyyyyHHmm");
public static final SimpleDateFormat DATE_FORMAT_YYYYMMDDHHMMSS = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
public static final int NUM_DPA_COLS = 131;
public static final int NUM_DPA_ROWS = 131;
static {
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone(GMT));
DATE_FORMAT_MMDDYYYYHH.setTimeZone(TimeZone.getTimeZone(GMT));
DATE_FORMAT_YYYYMMDDHHMMSS.setTimeZone(TimeZone.getTimeZone(GMT));
DATE_FORMAT_MMDDYYYYHHMM.setTimeZone(TimeZone.getTimeZone(GMT));
XMRG_DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT"));
}
}

View file

@ -0,0 +1,89 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.mpe;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
/**
*
* MPE Date formatter
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 3, 2013 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class MPEDateFormatter {
public static final TimeZone GMT_TIMEZONE = TimeZone.getTimeZone("GMT");
public static final String yyyyMMddHH = "yyyyMMddHH";
public static final String MMM_dd_yyyy_HH = "MMM dd yyyy HH";
public static final String MMddyyyyHH = "MMddyyyyHH";
public static final String MMM = "MMM";
public static final String yyyyMMddHHmmss = "yyyy-MM-dd HH:mm:ss";
public static final String OBS_DATE_FORMAT = yyyyMMddHHmmss;
public static String format_yyyyMMddHH(Date date) {
return format(date, yyyyMMddHH);
}
public static String format_MMddyyyyHH(Date date) {
return format(date, MMddyyyyHH);
}
public static String format_MMM_dd_yyyy_HH(Date date) {
return format(date, MMM_dd_yyyy_HH);
}
public static String format_obs(Date date) {
return format(date, OBS_DATE_FORMAT);
}
public static String format_yyyyMMddHHmmss(Date date) {
return format(date, yyyyMMddHHmmss);
}
public static SimpleDateFormat createSimpleDateFormat(String format) {
SimpleDateFormat sdf = new SimpleDateFormat(format);
sdf.setTimeZone(GMT_TIMEZONE);
return sdf;
}
public static String format(Date date, String format) {
return createSimpleDateFormat(format).format(date);
}
}

View file

@ -0,0 +1,59 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.mpe;
import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
/**
* Interrogation constants for MPE resources to use in returned {@link Map} from
* {@link AbstractVizResource#interrogate(ReferencedCoordinate)}
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 5, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class MPEInterrogationConstants {
public static final String INTERROGATE_BASIN = "Basin";
public static final String INTERROGATE_COUNTY = "County";
public static final String INTERROGATE_LAT_LON = "LatLon";
public static final String INTERROGATE_GRID_CELL = "GridCell";
public static final String INTERROGATE_VALUE = "Value";
public static final String INTERROGATE_VALUE_LABEL = "ValueLabel";
public static final String INTERROGATE_UNIT = "Unit";
}

View file

@ -22,48 +22,60 @@ package com.raytheon.viz.mpe.ui;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "com.raytheon.viz.mpe.ui";
public static final IUFStatusHandler statusHandler = UFStatus
.getHandler(Activator.class);
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
// The plug-in ID
public static final String PLUGIN_ID = "com.raytheon.viz.mpe.ui";
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
// The shared instance
private static Activator plugin;
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* The constructor
*/
public Activator() {
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
* )
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/*
* (non-Javadoc)
*
* @see
* org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
* )
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
}

View file

@ -73,7 +73,10 @@ public class ChangeTimeProvider extends AbstractSourceProvider {
*/
@Override
public Map<String, Boolean> getCurrentState() {
MPEDisplayManager mgr = MPEDisplayManager.getCurrent();
return getCurrentState(MPEDisplayManager.getCurrent());
}
public Map<String, Boolean> getCurrentState(MPEDisplayManager mgr) {
if (mgr == null) {
sourceMap.put(MENU_ENABLED[0], false);
sourceMap.put(MENU_ENABLED[1], false);
@ -85,7 +88,7 @@ public class ChangeTimeProvider extends AbstractSourceProvider {
sourceMap.put(MENU_ENABLED[1], false);
} else {
Date firstDate = dmMgr.getEarliestDate();
Date curDate = mgr.getCurrentDate();
Date curDate = mgr.getCurrentEditDate();
Date latestDate = dmMgr.getLatestDate();
boolean enabled = false;
if (curDate != null && firstDate != null
@ -113,7 +116,7 @@ public class ChangeTimeProvider extends AbstractSourceProvider {
return MENU_ENABLED;
}
public static void update() {
public static void update(MPEDisplayManager displayMgr) {
IWorkbenchWindow window = VizWorkbenchManager.getInstance()
.getCurrentWindow();
if (window != null) {
@ -122,7 +125,7 @@ public class ChangeTimeProvider extends AbstractSourceProvider {
ChangeTimeProvider provider = (ChangeTimeProvider) service
.getSourceProvider(MENU_ENABLED[0]);
provider.fireSourceChanged(ISources.ACTIVE_WORKBENCH_WINDOW,
provider.getCurrentState());
provider.getCurrentState(displayMgr));
}
}
}

View file

@ -69,7 +69,7 @@ public enum DisplayFieldData {
private String displayString;
private DisplayFieldData(String dirToken, String displayString) {
this(dirToken, displayString, 3600, null);
this(dirToken, displayString, 1, null);
}
private DisplayFieldData(String dirToken, String displayString,
@ -107,4 +107,19 @@ public enum DisplayFieldData {
public String toString() {
return displayString;
}
/**
* A case-insensitive version of {@link DisplayFieldData#valueOf(String)}
*
* @param displayFieldData
* @return
*/
public static DisplayFieldData fromString(String displayFieldData) {
for (DisplayFieldData fieldData : DisplayFieldData.values()) {
if (fieldData.name().equalsIgnoreCase(displayFieldData)) {
return fieldData;
}
}
return null;
}
}

View file

@ -168,7 +168,7 @@ public abstract class FieldsPopulator extends CompoundContributionItem {
public void run() {
if (menuData.handler == null) {
SetDisplayField.setDisplayField(
EditorUtil.getActiveVizContainer(), data.name());
EditorUtil.getActiveVizContainer(), data);
} else {
try {
ICommandService commandService = (ICommandService) PlatformUI

View file

@ -53,21 +53,15 @@ public class GageFieldsPopulator extends FieldsPopulator {
@Override
protected DisplayFieldData[] getMenuItems() {
AppsDefaults defaults = AppsDefaults.getInstance();
String rfcSwitch = defaults.getToken("mpe_dqc_options");
if (rfcSwitch.equalsIgnoreCase("off")) {
menuItems = new DisplayFieldData[] {};
if (MPEDisplayManager.isMpeQcOptionEnabled()) {
return menuItems;
}
return menuItems;
return new DisplayFieldData[] {};
}
protected IContributionItem[] getContributionItems() {
AppsDefaults defaults = AppsDefaults.getInstance();
String list = defaults.getToken("mpe_generate_list");
String rfcSwitch = defaults.getToken("mpe_dqc_options");
List<String> fields = new ArrayList<String>();
if (list != null) {
fields = new ArrayList<String>(Arrays.asList(list.split("[,]")));
@ -84,7 +78,7 @@ public class GageFieldsPopulator extends FieldsPopulator {
});
boolean enabled = found >= 0;
if (!enabled && rfcSwitch.equalsIgnoreCase("on")) {
if (!enabled && MPEDisplayManager.isMpeQcOptionEnabled()) {
enabled = true;
}

View file

@ -0,0 +1,45 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.mpe.ui;
/**
* Listener for MPE {@link DisplayFieldData} changing
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 20, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public interface IDisplayFieldChangedListener {
public void displayFieldChanged(DisplayFieldData oldFieldData,
DisplayFieldData newFieldData);
}

View file

@ -0,0 +1,45 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.mpe.ui;
import java.util.Date;
/**
* Listener for MPE edit time changing
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 12, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public interface IEditTimeChangedListener {
public void editTimeChanged(Date oldTime, Date newTime);
}

View file

@ -0,0 +1,63 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.mpe.ui;
/**
* Available MPE plot types
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 6, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public enum MPEPlotType {
T_24hGRID_PRECIP("24hGRID_PRECIP", 24), T_24hMAREAPRECIP("24hMAREAPRECIP",
24), T_6hGRID_PRECIP("6hGRID_PRECIP", 6), T_6hMAREA_PRECIP(
"6hMAREA_PRECIP", 6), T_6hGRID_FREEZL("6hGRID_FREEZL", 6), T_6hMAREA_FREEZL(
"6hMAREA_FREEZL", 6), T_sixhGRID_TEMP("sixhGRID_TEMP", 6), T_sixhMAREA_TEMP(
"sixhMAREA_TEMP", 6), T_maxGRID_TEMP("maxGRID_TEMP", 24), T_minGRID_TEMP(
"minGRID_TEMP", 24);
private final String cv_use;
private final int duration;
private MPEPlotType(String cv_use, int duration) {
this.cv_use = cv_use;
this.duration = duration;
}
public String getCvUse() {
return cv_use;
}
public int getDurationInHrs() {
return duration;
}
}

View file

@ -28,14 +28,12 @@ import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.HandlerUtil;
import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.dialogs.ChooseDataPeriodDialog;
import com.raytheon.viz.mpe.ui.rsc.XmrgResource;
import com.raytheon.viz.ui.EditorUtil;
import com.raytheon.viz.ui.editor.IMultiPaneEditor;
/**
@ -62,9 +60,9 @@ public class ChooseHour extends AbstractHandler {
* .ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
public Object execute(ExecutionEvent event) throws ExecutionException {
int increment = 0;
String s = arg0.getParameter("increment");
String s = event.getParameter("increment");
if (s != null) {
try {
increment = Integer.parseInt(s);
@ -73,7 +71,7 @@ public class ChooseHour extends AbstractHandler {
}
}
IEditorPart editor = EditorUtil.getActiveEditor();
IEditorPart editor = HandlerUtil.getActiveEditor(event);
IDisplayPane pane = null;
if (editor instanceof IMultiPaneEditor) {
IMultiPaneEditor multiPane = (IMultiPaneEditor) editor;
@ -86,11 +84,9 @@ public class ChooseHour extends AbstractHandler {
}
MPEDisplayManager dm = MPEDisplayManager.getInstance(pane);
Date currentDate = dm.getCurrentDate();
dm.clearMPEData();
dm.setDisplayedResource(null);
Date currentDate = dm.getCurrentEditDate();
if ((increment == 0) || (currentDate == null)) {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
Shell shell = HandlerUtil.getActiveWorkbenchWindow(event)
.getShell();
ChooseDataPeriodDialog dialog = new ChooseDataPeriodDialog(shell);
dialog.open();
@ -99,11 +95,7 @@ public class ChooseHour extends AbstractHandler {
cal.setTime(currentDate);
cal.add(Calendar.HOUR_OF_DAY, increment);
Date newDate = cal.getTime();
dm.setCurrentDate(newDate);
if (dm.getDisplayedResource() != null) {
XmrgResource xmrgRsc = (XmrgResource) dm.getDisplayedResource();
xmrgRsc.updateXmrg(false);
}
dm.setCurrentEditDate(newDate);
}
return null;
}

View file

@ -19,32 +19,34 @@
**/
package com.raytheon.viz.mpe.ui.actions;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.handlers.HandlerUtil;
import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.TransmitRFCBiasProvider;
import com.raytheon.viz.ui.EditorUtil;
import com.raytheon.viz.ui.editor.IMultiPaneEditor;
/**
* TODO Add Description
* MPE Users guide specifies this command should clear all MPE data from screen
* and if in split screen mode, return to full screen
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 6, 2008 randerso Initial creation
* Jan 3, 2012 mschenke Initial creation
*
* </pre>
*
* @author randerso
* @author mschenke
* @version 1.0
*/
public class ClearMPEData extends AbstractHandler {
public class ClearMPEData extends FullScreen {
/*
* (non-Javadoc)
@ -54,33 +56,17 @@ public class ClearMPEData extends AbstractHandler {
* .ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
IDisplayPaneContainer editor = EditorUtil.getActiveVizContainer();
IDisplayPane pane = null;
MPEDisplayManager displayMgr = null;
if (editor instanceof IMultiPaneEditor) {
IMultiPaneEditor multiPane = (IMultiPaneEditor) editor;
if (multiPane.getNumberofPanes() > 1) {
for (int i = 0; i < multiPane.getNumberofPanes(); i++) {
pane = multiPane.getDisplayPanes()[i];
displayMgr = MPEDisplayManager.getInstance(pane);
displayMgr.clearMPEData();
}
displayMgr.setDisplayedResource(null);
} else {
pane = multiPane.getDisplayPanes()[0];
displayMgr = MPEDisplayManager.getInstance(pane);
displayMgr.clearMPEData();
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editor = HandlerUtil.getActiveEditor(event);
if (editor instanceof IDisplayPaneContainer) {
IDisplayPaneContainer container = (IDisplayPaneContainer) editor;
for (IDisplayPane pane : container.getDisplayPanes()) {
pane.clear();
}
} else if (editor != null) {
pane = editor.getDisplayPanes()[0];
displayMgr = MPEDisplayManager.getInstance(pane);
displayMgr.clearMPEData();
displayMgr.setDisplayedResource(null);
}
// Ensure in full screen
super.execute(event);
TransmitRFCBiasProvider.setEnabled(false);
return null;
}
}

View file

@ -28,8 +28,8 @@ import java.util.TimeZone;
import javax.measure.unit.NonSI;
import javax.measure.unit.Unit;
import com.raytheon.uf.common.dataplugin.shef.tables.Colorvalue;
import com.raytheon.uf.common.colormap.ColorMap;
import com.raytheon.uf.common.dataplugin.shef.tables.Colorvalue;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
@ -243,8 +243,8 @@ public class DrawDQCStations {
if (instance == null) {
instance = new DrawDQCStations();
}
mpd.clearMPEData();
display = mpd.getRenderableDisplay();
display.clear();
md = (IMapDescriptor) display.getDescriptor();
List<MPELegendResource> rscs = display.getDescriptor()

View file

@ -25,11 +25,12 @@ import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.handlers.HandlerUtil;
import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.rsc.MPEPolygonResource;
import com.raytheon.viz.ui.EditorUtil;
import com.raytheon.viz.ui.input.EditableManager;
/**
@ -51,11 +52,12 @@ public class DrawPolygonAction extends AbstractHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart activeEditor = (IEditorPart) EditorUtil
.getActiveEditorAs(IDisplayPaneContainer.class);
if (activeEditor != null) {
IDisplayPane first = ((IDisplayPaneContainer) activeEditor)
.getDisplayPanes()[0];
IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
if (activeEditor instanceof IDisplayPaneContainer) {
IDisplayPaneContainer container = (IDisplayPaneContainer) activeEditor;
MPEDisplayManager.stopLooping(container);
// Can only draw on top display when in split screen
IDisplayPane first = container.getDisplayPanes()[0];
List<MPEPolygonResource> rscs = first.getDescriptor()
.getResourceList()
.getResourcesByTypeAsType(MPEPolygonResource.class);

View file

@ -22,12 +22,10 @@ package com.raytheon.viz.mpe.ui.actions;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.handlers.RadioState;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.viz.ui.EditorUtil;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
/**
* Sets the font size on the display managers for an editor. Updates radio state
@ -54,13 +52,7 @@ public class FontAction extends AbstractHandler {
return null;
}
String newVal = event.getParameter(RadioState.PARAMETER_ID);
HandlerUtil.updateRadioState(event.getCommand(), newVal);
IEditorPart part = (IEditorPart) EditorUtil
.getActiveEditorAs(IDisplayPaneContainer.class);
if (part != null) {
((IDisplayPaneContainer) part).refresh();
}
MPEDisplayManager.setFontId(newVal);
return null;
}
}

View file

@ -23,6 +23,7 @@ import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.viz.mpe.ui.SaveBestEstimateProvider;
import com.raytheon.viz.ui.EditorUtil;
@ -59,11 +60,9 @@ public class FullScreen extends AbstractHandler {
if (container instanceof IMultiPaneEditor) {
IMultiPaneEditor multiPane = (IMultiPaneEditor) container;
int numPanes = multiPane.getNumberofPanes();
while (numPanes > 1) {
multiPane.hidePane(multiPane.getDisplayPanes()[numPanes - 1]);
multiPane.removePane(multiPane.getDisplayPanes()[numPanes - 1]);
numPanes = multiPane.displayedPaneCount();
IDisplayPane[] panes = multiPane.getDisplayPanes();
for (int i = 1; i < panes.length; ++i) {
multiPane.removePane(panes[i]);
}
}

View file

@ -71,7 +71,7 @@ public class MPEColorScaleMgrAction extends AbstractHandler {
DisplayFieldData dt = MPEDisplayManager.getCurrent()
.getDisplayFieldType();
MPEDisplayManager.getCurrent().setDisplayFieldType(dt);
MPEDisplayManager.getCurrent().displayFieldData(dt);
return null;
}

View file

@ -19,49 +19,323 @@
**/
package com.raytheon.viz.mpe.ui.actions;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriter;
import javax.imageio.stream.FileImageOutputStream;
import com.raytheon.uf.common.dataplugin.shef.tables.Rwresult;
import com.raytheon.uf.common.mpe.util.XmrgFile;
import com.raytheon.uf.common.mpe.util.XmrgFile.XmrgHeader;
import com.raytheon.uf.common.ohd.AppsDefaults;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.SimulatedTime;
import com.raytheon.viz.hydrocommon.whfslib.IHFSDbGenerated;
import com.raytheon.viz.mpe.MPEDateFormatter;
import com.raytheon.viz.mpe.core.MPEDataManager;
import com.raytheon.viz.mpe.core.MPEProcessGrib;
import com.raytheon.viz.mpe.ui.Activator;
import com.raytheon.viz.mpe.ui.DisplayFieldData;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.ui.EditorUtil;
/**
* TODO Add Description
*
* Contains logic for saving best estimate data
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 18, 2008 randerso Initial creation
* Dec 11, 2012 mschenke Initial creation
*
* </pre>
*
* @author randerso
* @author mschenke
* @version 1.0
*/
public class SaveBestEstimate {
public class SaveBestEstimate extends AbstractHandler {
private static final String PROCESS_FLAG_LOCAL = "MPM01 ";
/*
* (non-Javadoc)
private static final String PROCESS_FLAG_SBN = "QPE01 ";
/**
* Saves bestEstField as the best estimate data for the editDate. The
* fieldData array is the data for the field to use with any edits applied
* and the screenShot is a screenshot of the display the displayedField is
* on and will be saved out to images if preferences set
*
* @see
* org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.
* ExecutionEvent)
* @param editDate
* @param bestEstField
* @param fieldData
* @param screenShot
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IDisplayPaneContainer editor = EditorUtil.getActiveVizContainer();
if (editor == null) {
return null;
public static void saveBestEstimate(Date editDate,
DisplayFieldData bestEstField, short[] fieldData,
BufferedImage screenShot) {
AppsDefaults appsDefaults = AppsDefaults.getInstance();
String ST3_FORMAT_STRING = MPEDateFormatter.yyyyMMddHH;
String date_form = appsDefaults.getToken("st3_date_form");
if ((date_form == null) || date_form.isEmpty()
|| date_form.equals("mdY")) {
ST3_FORMAT_STRING = MPEDateFormatter.MMddyyyyHH;
}
/*----------------------------------------------------------*/
/* create date in desired format for use in xmrg filename */
/*----------------------------------------------------------*/
String cdate = MPEDateFormatter.format(editDate, ST3_FORMAT_STRING);
/*----------------------------------------------------------*/
/* create full pathname of binary file (input to MAPX) */
/* filename_xmrg is used by grib encoder */
/*----------------------------------------------------------*/
String fileName = String.format("%s/xmrg%sz",
appsDefaults.getToken("rfcwide_xmrg_dir"), cdate);
String fileNameXmrg = String.format("xmrg%sz", cdate);
/*----------------------------------------------------------*/
/* update RWResult table */
/* write merged (mosaicked) field to file */
/* replace missing values with 0.0 */
/*----------------------------------------------------------*/
String rfc = MPEDataManager.getInstance().getRFC();
update_rwr_save(rfc, editDate, bestEstField.getCv_use());
XmrgFile xmrgFile = MPEDisplayManager.getXmrgFile(bestEstField,
editDate);
try {
xmrgFile.load();
} catch (IOException e) {
Activator.statusHandler.handle(Priority.PROBLEM,
"Could not load xmrg file to save", e);
return;
}
XmrgHeader header = xmrgFile.getHeader();
try {
short[] data = Arrays.copyOf(fieldData, fieldData.length);
// Make copy since we will are editing here
for (int i = 0; i < data.length; i++) {
if (data[i] < 0) {
data[i] = 0;
}
}
xmrgFile.setData(data);
header.setProcessFlag(PROCESS_FLAG_LOCAL);
xmrgFile.save(new File(fileName));
/*
* Is the mpe_send_qpe_to_sbn token set to ON? If so create a second
* QPE file with the proc_flag set to QPE01.
*/
if (appsDefaults.getBoolean("mpe_send_qpe_to_sbn", false)) {
fileName = String.format("%s/xmrg%sz",
appsDefaults.getToken("mpe_qpe_sbn_dir"), cdate);
header.setProcessFlag(PROCESS_FLAG_SBN);
xmrgFile.save(new File(fileName));
}
} catch (IOException e) {
Activator.statusHandler.handle(Priority.PROBLEM,
"Error saving xmrg data for " + header.getProcessFlag(), e);
}
/*-----------------------------------------------------------*/
/* generate and save files depending on values of */
/* mpe_save_... tokens read from .Apps_defaults */
/* */
/* create filenames for netCDF, gif, grib and jpeg files */
/* if mpe_xxxx_id token not found or blank, then no string */
/* is prepended to filename */
/* in all cases, filenames contain date in form yyyymmddhh */
/*-----------------------------------------------------------*/
cdate = MPEDateFormatter.format_yyyyMMddHH(editDate);
/*--------------------------------------*/
/* generate and save gif image */
/*--------------------------------------*/
String save_flag = appsDefaults.getToken("mpe_save_gif");
if ("save".equalsIgnoreCase(save_flag)) {
String gif_dir = appsDefaults.getToken("mpe_gif_dir");
String ftype = appsDefaults.getToken("mpe_gif_id");
String fnamgif;
if ((ftype == null) || ftype.isEmpty()) {
fnamgif = String.format("%s/%sz.gif", gif_dir, cdate);
} else {
fnamgif = String.format("%s/%s%sz.gif", gif_dir, ftype, cdate);
}
mpegui_save_image(screenShot, "gif", fnamgif);
} else {
Activator.statusHandler.handle(Priority.VERBOSE,
"gif file not saved");
}
/*--------------------------------------*/
/* generate and save jpeg image */
/*--------------------------------------*/
save_flag = appsDefaults.getToken("mpe_save_jpeg");
if ("save".equalsIgnoreCase(save_flag)) {
String jpeg_dir = appsDefaults.getToken("mpe_jpeg_dir");
String ftype = appsDefaults.getToken("mpe_jpeg_id");
String fnamjpeg;
if ((ftype == null) || ftype.isEmpty()) {
fnamjpeg = String.format("%s/%sz.jpeg", jpeg_dir, cdate);
} else {
fnamjpeg = String.format("%s/%s%sz.jpeg", jpeg_dir, ftype,
cdate);
}
mpegui_save_image(screenShot, "jpeg", fnamjpeg);
} else {
Activator.statusHandler.handle(Priority.VERBOSE,
"jpeg file not saved \n");
}
/*--------------------------------------*/
/* generate and save netCDF file */
/*--------------------------------------*/
save_flag = appsDefaults.getToken("mpe_save_netcdf");
if ("save".equalsIgnoreCase(save_flag)) {
// TODO: Implement? There was lots of commented out code in
// MPEDisplayManager and it did nothing
} else {
Activator.statusHandler.handle(Priority.VERBOSE,
"netCDF file not saved");
}
/*--------------------------------------*/
/* generate and save grib file */
/*--------------------------------------*/
save_flag = appsDefaults.getToken("mpe_save_grib");
if ("save".equalsIgnoreCase(save_flag)) {
String ftype = appsDefaults.getToken("mpe_grib_id");
String fnamgrib;
if ((ftype == null) || ftype.isEmpty()) {
fnamgrib = String.format("%sz.grib", cdate);
} else {
fnamgrib = String.format("%s%sz.grib", ftype, cdate);
}
String dirname = appsDefaults.getToken("mpe_grib_dir");
Activator.statusHandler.handle(Priority.VERBOSE, String.format(
"Saving grib encoded file in %s/%s\n", dirname, fnamgrib));
MPEProcessGrib mpgr = new MPEProcessGrib();
mpgr.saveGrib(fileNameXmrg, fnamgrib);
} else {
Activator.statusHandler.handle(Priority.VERBOSE,
"grib encoded file not saved \n");
}
/* Check if the RFC Bias needs to be sent across the WAN. */
boolean transmit_rfc_bias = appsDefaults.getBoolean(
"mpe_transmit_bias", true);
boolean transmit_bias_on_save = appsDefaults.getBoolean(
"transmit_bias_on_save", true);
if (transmit_rfc_bias && transmit_bias_on_save) {
// sprintf ( command_string, "%s/transmit_rfc_bias %s",
// precip_proc_bin_dir, cdate );
// UFStatus.handle(Priority.VERBOSE, Activator.PLUGIN_ID,
// StatusConstants.CATEGORY_MPE, null,
// String.format("Invoking transmit_rfc_bias script using command:\n"
// "%s\n", command_string ));
// system ( command_string );
}
IDisplayPane pane = editor.getDisplayPanes()[0];
MPEDisplayManager.getInstance(pane).save_rfcwide();
return null;
}
private static void mpegui_save_image(BufferedImage bi, String format,
String path) {
Activator.statusHandler.handle(Priority.VERBOSE,
String.format("Saving %s file in %s\n", format, path));
Iterator<ImageWriter> iter = ImageIO
.getImageWritersByFormatName(format);
ImageWriter writer = iter.next();
try {
writer.setOutput(new FileImageOutputStream(new File(path)));
writer.write(bi);
} catch (IOException e) {
Activator.statusHandler.error("Error creating file ", e);
}
}
private static void update_rwr_save(String rfc, Date dt, String fldtype) {
String asave = "F";
String drpr = "F";
// RWA: this flag doesn't appear to be set anywhere
// if ( applyprecip_flag == 1 )
// {
// drpr = "T";
// }
/* Build the obstime time string. */
String datetime_obs_xmrg = MPEDateFormatter.format_obs(dt);
/*
* Build the where clause. This can be used for both the select and the
* update.
*/
String where = String.format("WHERE id.rfc='%s' AND id.obstime='%s'",
rfc, datetime_obs_xmrg);
/* Get the record to update from the RWResult table. */
List<Rwresult> pRWResultHead = IHFSDbGenerated.GetRWResult(where);
if (pRWResultHead.size() == 0) {
Activator.statusHandler
.handle(Priority.PROBLEM,
String.format(
"In routine 'update_rwr_save': Could not select a record from the RWResult table for query '%s'.\n",
where));
} else {
Rwresult pRWResultNode = pRWResultHead.get(0);
/* Update the elements in the RWResult node. */
pRWResultNode.setMapxFieldType(fldtype);
pRWResultNode.setAutoSave(asave);
pRWResultNode.setDrawPrecip(drpr);
pRWResultNode.setLastSaveTime(SimulatedTime.getSystemTime()
.getTime());
/* Update the record in the database. */
int status = IHFSDbGenerated.UpdateRWResult(pRWResultNode);
if (status == -1) {
Activator.statusHandler
.handle(Priority.PROBLEM,
String.format(
"In routine 'update_rwr_save': could not update record in RWResult for query '%s'.",
where));
}
/* Free the memory used by the linked list of RWResult structures. */
pRWResultHead.clear();
}
}
}

View file

@ -19,13 +19,8 @@
**/
package com.raytheon.viz.mpe.ui.actions;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.ui.EditorUtil;
/**
* Handler for saving best estimate bottom
@ -43,23 +38,22 @@ import com.raytheon.viz.ui.EditorUtil;
* @version 1.0
*/
public class SaveBestEstimateBottom extends SaveBestEstimate {
public class SaveBestEstimateBottom extends SaveBestEstimateHandler {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.
* ExecutionEvent)
* com.raytheon.viz.mpe.ui.actions.SaveBestEstimate#getPaneToSave(com.raytheon
* .uf.viz.core.IDisplayPaneContainer)
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IDisplayPaneContainer editor = EditorUtil.getActiveVizContainer();
if (editor == null) {
return null;
protected IDisplayPane getPaneToSave(IDisplayPaneContainer container) {
IDisplayPane[] panes = container.getDisplayPanes();
if (panes.length == 2) {
return panes[1];
}
IDisplayPane pane = editor.getDisplayPanes()[1];
MPEDisplayManager.getInstance(pane).save_rfcwide();
return null;
}
}

View file

@ -0,0 +1,126 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.mpe.ui.actions;
import java.util.Date;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.viz.mpe.ui.Activator;
import com.raytheon.viz.mpe.ui.DisplayFieldData;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.rsc.MPEFieldResource;
/**
* Handler class for saving the current best estimate
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 2, 2013 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class SaveBestEstimateHandler extends AbstractHandler {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.
* ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart part = HandlerUtil.getActiveEditor(event);
if (part instanceof IDisplayPaneContainer) {
IDisplayPaneContainer container = (IDisplayPaneContainer) part;
IDisplayPane toSave = getPaneToSave(container);
if (toSave != null) {
MPEDisplayManager.stopLooping(container);
IWorkbenchWindow activeWindow = HandlerUtil
.getActiveWorkbenchWindow(event);
Shell shell = activeWindow.getShell();
try {
shell.setCursor(shell.getDisplay().getSystemCursor(
SWT.CURSOR_WAIT));
MPEDisplayManager displayMgr = MPEDisplayManager
.getInstance(toSave);
MPEFieldResource resource = displayMgr
.getDisplayedFieldResource();
if (resource == null) {
// Ensure there is not a displayed resource on the pane
MessageBox box = new MessageBox(shell, SWT.ERROR);
box.setText("Cannot Save");
box.setMessage("No Data Available, cannot save");
box.open();
} else {
Date editDate = displayMgr.getCurrentEditDate();
// TODO: Ensure not base field
DisplayFieldData displayedField = displayMgr
.getDisplayFieldType();
short[] editedData = resource.getData(new DataTime(
editDate));
SaveBestEstimate.saveBestEstimate(editDate,
displayedField, editedData, toSave.getTarget()
.screenshot());
}
} catch (VizException e) {
Activator.statusHandler.handle(Priority.PROBLEM,
"Error getting data from display for storing", e);
} finally {
// Reset cursor
shell.setCursor(null);
}
}
}
return null;
}
protected IDisplayPane getPaneToSave(IDisplayPaneContainer container) {
IDisplayPane[] panes = container.getDisplayPanes();
if (panes.length > 0) {
return panes[0];
}
return null;
}
}

View file

@ -2543,7 +2543,7 @@ public class SaveLevel2Data {
private void cancel_dbase() {
// String qcarea = DailyQcUtils.currentQcArea;
qdays = DailyQcUtils.qcDays;
currntDate = MPEDisplayManager.getCurrent().getCurrentDate();
currntDate = MPEDisplayManager.getCurrent().getCurrentEditDate();
/* The datasets have all been QC'd and saved to the database. */
/* Go ahead and load the new DailyQC dataset. */

View file

@ -23,13 +23,13 @@ import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.handlers.HandlerUtil;
import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.viz.mpe.ui.DisplayFieldData;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.rsc.XmrgResource;
import com.raytheon.viz.ui.EditorUtil;
import com.raytheon.viz.mpe.ui.rsc.MPEFieldResource;
import com.raytheon.viz.ui.editor.IMultiPaneEditor;
/**
@ -59,46 +59,37 @@ public class SetDisplayField extends AbstractHandler {
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
String f = event.getParameter("Field");
IEditorPart editor = (IEditorPart) EditorUtil
.getActiveEditorAs(IDisplayPaneContainer.class);
if (editor != null) {
return setDisplayField((IDisplayPaneContainer) editor, f);
IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
if (activeEditor instanceof IDisplayPaneContainer) {
String f = event.getParameter("Field");
return setDisplayField((IDisplayPaneContainer) activeEditor,
DisplayFieldData.valueOf(f));
}
return null;
}
public static Object setDisplayField(IDisplayPaneContainer editor, String f) {
public static MPEFieldResource setDisplayField(
IDisplayPaneContainer editor, DisplayFieldData field) {
if (editor == null) {
return null;
}
IDisplayPane pane = (editor).getDisplayPanes()[0];
if (editor instanceof IMultiPaneEditor) {
IMultiPaneEditor multiPane = (IMultiPaneEditor) editor;
if (multiPane.getNumberofPanes() > 1) {
pane = multiPane.getSelectedPane(IMultiPaneEditor.LOAD_ACTION);
if (pane == null) {
pane = multiPane.getActiveDisplayPane();
IDisplayPane[] panes = editor.getDisplayPanes();
IDisplayPane pane = panes[0];
if (panes.length > 1) {
if (editor instanceof IMultiPaneEditor) {
IMultiPaneEditor multiPane = (IMultiPaneEditor) editor;
IDisplayPane loadTo = multiPane
.getSelectedPane(IMultiPaneEditor.LOAD_ACTION);
if (loadTo != null) {
pane = loadTo;
}
} else {
pane = (editor).getDisplayPanes()[0];
}
}
MPEDisplayManager displayMgr = MPEDisplayManager.getInstance(pane);
displayMgr.setAccum_interval(1);
DisplayFieldData field = DisplayFieldData.valueOf(f);
displayMgr.setDisplayFieldType(field);
if (!displayMgr.getOtherDispType().equals(field)) {
displayMgr.setOtherDispType(field);
displayMgr.setAccum_interval(1);
}
displayMgr.displayFieldData(field);
// Update the screen
XmrgResource xmrgRsc = (XmrgResource) displayMgr.getDisplayedResource();
xmrgRsc.updateXmrg(false);
return xmrgRsc;
return displayMgr.getDisplayedFieldResource();
}
}

View file

@ -27,7 +27,6 @@ import org.eclipse.ui.IEditorPart;
import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.SaveBestEstimateProvider;
import com.raytheon.viz.mpe.ui.rsc.XmrgResource;
import com.raytheon.viz.ui.EditorUtil;
import com.raytheon.viz.ui.editor.IMultiPaneEditor;
@ -55,36 +54,24 @@ public class SplitScreen extends AbstractHandler {
* .ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editor = EditorUtil.getActiveEditor();
if (editor instanceof IMultiPaneEditor) {
IMultiPaneEditor multiPane = (IMultiPaneEditor) editor;
if (multiPane.getNumberofPanes() < 2) {
IDisplayPane activePane = multiPane.getActiveDisplayPane();
multiPane.addPane(activePane.getRenderableDisplay()
.createNewDisplay());
IDisplayPane[] panes = multiPane.getDisplayPanes();
if (panes.length == 1) {
IDisplayPane activePane = panes[0];
MPEDisplayManager activeMgr = MPEDisplayManager
.getInstance(activePane);
IDisplayPane newPane = multiPane.addPane(activePane
.getRenderableDisplay().createNewDisplay());
MPEDisplayManager newMgr = MPEDisplayManager
.getInstance(newPane);
SaveBestEstimateProvider.getProvider(arg0).setEnabled(true);
// Synchronize newMgr with activeMgr
newMgr.synchronize(activeMgr);
IDisplayPane[] panes = multiPane.getDisplayPanes();
for (IDisplayPane pane : panes) {
if (pane != activePane) {
MPEDisplayManager newMgr = MPEDisplayManager
.getInstance(pane);
MPEDisplayManager activeMgr = MPEDisplayManager
.getInstance(activePane);
newMgr.setCurrentDate(activeMgr.getCurrentDate());
XmrgResource xmrg = (XmrgResource) newMgr
.getDisplayedResource();
xmrg.updateXmrg(true);
break;
}
}
} else {
for (IDisplayPane pane : multiPane.getDisplayPanes()) {
multiPane.showPane(pane);
}
SaveBestEstimateProvider.getProvider(event).setEnabled(true);
}
}
return null;

View file

@ -22,95 +22,49 @@ package com.raytheon.viz.mpe.ui.actions;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.handlers.HandlerUtil;
import com.raytheon.uf.common.ohd.AppsDefaults;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.uf.viz.core.datastructure.LoopProperties;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.dialogs.timelapse.TimeLapseDlg;
import com.raytheon.viz.mpe.ui.rsc.TimeLapseResource;
import com.raytheon.viz.ui.EditorUtil;
/**
* Action class for MPE's Time Lapse Function.
* Time lapse action, can start/stop time lapsing in MPE
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 10, 2009 mpduff Initial creation
* Dec 7, 2012 mschenke Initial creation
*
* </pre>
*
* @author mpduff
* @author mschenke
* @version 1.0
*/
public class TimeLapseAction extends AbstractHandler {
private static AbstractVizResource<?, ?> prevRsc = null;
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
MPEDisplayManager dman = MPEDisplayManager.getCurrent();
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell();
IDisplayPaneContainer container = EditorUtil.getActiveVizContainer();
if (container != null) {
LoopProperties loopProps = container.getLoopProperties();
int frameRate = Integer.parseInt(AppsDefaults.getInstance()
.getToken("hydroview_mpe_timelapse", "1000"));
loopProps.setFwdFrameTime(frameRate);
if (!dman.isTimeLapseMode()) {
prevRsc = dman.getDisplayedResource();
}
String selection = event.getParameter("Hour");
if (selection.equalsIgnoreCase("6")) {
dman.setTimeLapseHours(6);
dman.setTimeLapseMode(true);
loopProps.setLooping(true);
dman.displayTimeLapse();
} else if (selection.equalsIgnoreCase("12")) {
dman.setTimeLapseHours(12);
dman.setTimeLapseMode(true);
loopProps.setLooping(true);
dman.displayTimeLapse();
} else if (selection.equalsIgnoreCase("24")) {
dman.setTimeLapseHours(24);
dman.setTimeLapseMode(true);
loopProps.setLooping(true);
dman.displayTimeLapse();
} else if (selection.equalsIgnoreCase("O")) {
TimeLapseDlg tld = new TimeLapseDlg(shell);
tld.open();
dman.setTimeLapseMode(true);
loopProps.setLooping(true);
dman.displayTimeLapse();
} else if (selection.equalsIgnoreCase("E")) {
dman.setTimeLapseHours(0);
dman.setTimeLapseMode(false);
loopProps.setLooping(false);
IRenderableDisplay display = MPEDisplayManager.getCurrent()
.getRenderableDisplay();
IDescriptor descriptor = display.getDescriptor();
TimeLapseResource timeLapseRsc = (TimeLapseResource) dman
.getDisplayedResource();
if (descriptor.getResourceList().containsRsc(timeLapseRsc)) {
descriptor.getResourceList().removeRsc(timeLapseRsc);
}
if (timeLapseRsc != null) {
timeLapseRsc.dispose();
}
dman.setDisplayedResource(prevRsc);
display.getContainer().refresh();
IEditorPart part = HandlerUtil.getActiveEditor(event);
if (part instanceof IDisplayPaneContainer) {
IDisplayPaneContainer container = (IDisplayPaneContainer) part;
String hourId = event.getParameter("Hour");
if ("E".equals(hourId)) {
// End looping
MPEDisplayManager.stopLooping(container);
} else if ("O".equals(hourId)) {
// Open looping dialog
TimeLapseDlg dialog = new TimeLapseDlg(part.getEditorSite()
.getShell());
dialog.open();
} else {
// Loop for specified number of hours
int hour = Integer.parseInt(hourId);
MPEDisplayManager.startLooping(container, hour);
}
}

View file

@ -19,19 +19,13 @@
**/
package com.raytheon.viz.mpe.ui.actions;
import java.util.Map;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.commands.IElementUpdater;
import org.eclipse.ui.handlers.RadioState;
import org.eclipse.ui.menus.UIElement;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.MPEDisplayManager.GageColor;
import com.raytheon.viz.ui.EditorUtil;
/**
* TODO Add Description
@ -49,7 +43,8 @@ import com.raytheon.viz.ui.EditorUtil;
* @version 1.0
*/
public class ToggleGageColor extends AbstractHandler implements IElementUpdater {
public class ToggleGageColor extends AbstractHandler {
/*
* (non-Javadoc)
*
@ -61,27 +56,8 @@ public class ToggleGageColor extends AbstractHandler implements IElementUpdater
public Object execute(ExecutionEvent event) throws ExecutionException {
String g = event.getParameter(RadioState.PARAMETER_ID);
GageColor gc = GageColor.valueOf(g);
MPEDisplayManager.getCurrent().setGageColor(gc);
MPEDisplayManager.setGageColor(gc);
return null;
}
@SuppressWarnings("unchecked")
@Override
public void updateElement(UIElement element, Map parameters) {
MPEDisplayManager dm = MPEDisplayManager.getCurrent();
if (dm == null) {
return;
}
GageColor color = dm.getGageColor();
String g = (String) parameters.get(RadioState.PARAMETER_ID);
GageColor val = GageColor.valueOf(g);
element.setChecked(color.equals(val));
IDisplayPaneContainer container = EditorUtil
.getActiveEditorAs(IDisplayPaneContainer.class);
if (container != null) {
container.refresh();
}
}
}

View file

@ -19,13 +19,10 @@
**/
package com.raytheon.viz.mpe.ui.actions;
import java.util.Map;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.commands.IElementUpdater;
import org.eclipse.ui.menus.UIElement;
import org.eclipse.ui.handlers.RadioState;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.MPEDisplayManager.GageMissingOptions;
@ -46,8 +43,7 @@ import com.raytheon.viz.mpe.ui.MPEDisplayManager.GageMissingOptions;
* @version 1.0
*/
public class ToggleGageMissing extends AbstractHandler implements
IElementUpdater {
public class ToggleGageMissing extends AbstractHandler {
/*
* (non-Javadoc)
*
@ -56,26 +52,11 @@ public class ToggleGageMissing extends AbstractHandler implements
* .ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {
String g = arg0.getParameter("Missing");
public Object execute(ExecutionEvent event) throws ExecutionException {
String g = event.getParameter(RadioState.PARAMETER_ID);
GageMissingOptions miss = GageMissingOptions.valueOf(g);
MPEDisplayManager.getCurrent().toggleGageMissing(miss);
MPEDisplayManager.setGageMissing(miss);
return null;
}
@SuppressWarnings("unchecked")
@Override
public void updateElement(UIElement element, Map parameters) {
MPEDisplayManager dm = MPEDisplayManager.getCurrent();
if (dm == null) {
return;
}
GageMissingOptions disp = dm.getGageMissing();
String g = (String) parameters.get("Missing");
GageMissingOptions val = GageMissingOptions.valueOf(g);
element.setChecked(disp.equals(val));
}
}

View file

@ -33,7 +33,7 @@ public class TransmitRFCBias extends AbstractHandler {
}
MPEDisplayManager dm = MPEDisplayManager.getInstance(pane);
Date currentDate = dm.getCurrentDate();
Date currentDate = dm.getCurrentEditDate();
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHH");
String transmitDate = formatter.format(currentDate);

View file

@ -124,7 +124,7 @@ public class AddPseudoGageDialog extends CaveSWTDialog {
@Override
protected void initializeComponents(Shell shell) {
font = new Font(shell.getDisplay(), "Courier", 10, SWT.NORMAL);
datetime = MPEDisplayManager.getCurrent().getCurrentDate();
datetime = MPEDisplayManager.getCurrent().getCurrentEditDate();
sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
@ -219,8 +219,7 @@ public class AddPseudoGageDialog extends CaveSWTDialog {
@Override
public void widgetSelected(SelectionEvent e) {
writePGage();
MPEDisplayManager.getCurrent().setDataSaved(false);
shell.dispose();
close();
}
});

View file

@ -49,14 +49,12 @@ import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.viz.mpe.core.MPEDataManager;
import com.raytheon.viz.mpe.core.MPEDataManager.MPEDateInfo;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.TransmitRFCBiasProvider;
import com.raytheon.viz.mpe.ui.rsc.XmrgResource;
import com.raytheon.viz.ui.EditorUtil;
import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
import com.raytheon.viz.ui.editor.IMultiPaneEditor;
/**
* TODO Add Description
* MPE Dialog for choosing time data should be displaying at
*
* <pre>
* SOFTWARE HISTORY
@ -141,9 +139,9 @@ public class ChooseDataPeriodDialog extends CaveJFACEDialog {
displayMgr = MPEDisplayManager.getInstance(pane);
dataMgr = MPEDataManager.getInstance();
dateMap = dataMgr.getDateMap(false);
qcEnable = displayMgr.isMpeQcOptionEnabled();
qcEnable = MPEDisplayManager.isMpeQcOptionEnabled();
cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
prevDate = displayMgr.getCurrentDate();
prevDate = displayMgr.getCurrentEditDate();
cal.setTime(prevDate);
}
@ -291,17 +289,14 @@ public class ChooseDataPeriodDialog extends CaveJFACEDialog {
@Override
public void widgetSelected(SelectionEvent e) {
close();
displayMgr.setHrFirstTime(false);
displayMgr.setCurrentDate(cal.getTime());
if (displayMgr.getDisplayedResource() != null) {
XmrgResource xmrgRsc = (XmrgResource) displayMgr
.getDisplayedResource();
xmrgRsc.updateXmrg(false);
// Hide so if setCurrentEditDate returns false, we can continue
// to display
hide();
if (displayMgr.setCurrentEditDate(getTime())) {
close();
} else {
restore();
}
TransmitRFCBiasProvider.setEnabled(true);
}
});
@ -468,11 +463,11 @@ public class ChooseDataPeriodDialog extends CaveJFACEDialog {
if (dateInfo != null) {
lastSave.setText(sdf.format(dateInfo.getLastSaveTime()));
lastExec.setText(sdf.format(dateInfo.getLastExecTime()));
if (dateInfo.isAutoSave()){
manuallySaved.setText("NO");
} else{
manuallySaved.setText("YES");
}
if (dateInfo.isAutoSave()) {
manuallySaved.setText("NO");
} else {
manuallySaved.setText("YES");
}
} else {
lastSave.setText("NA");
lastExec.setText("NA");

View file

@ -20,14 +20,10 @@
package com.raytheon.viz.mpe.ui.dialogs;
import java.awt.Rectangle;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import javax.measure.converter.UnitConverter;
import javax.measure.unit.NonSI;
@ -53,27 +49,16 @@ import org.eclipse.swt.widgets.Scale;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.common.colormap.Color;
import com.raytheon.uf.common.colormap.ColorMap;
import com.raytheon.uf.common.dataplugin.shef.tables.Colorvalue;
import com.raytheon.uf.common.mpe.util.XmrgFile;
import com.raytheon.uf.common.ohd.AppsDefaults;
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.util.FileUtil;
import com.raytheon.uf.viz.core.RGBColors;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
import com.raytheon.uf.viz.core.style.DataMappingPreferences;
import com.raytheon.uf.viz.core.style.DataMappingPreferences.DataMappingEntry;
import com.raytheon.viz.hydrocommon.util.MPEColors;
import com.raytheon.viz.hydrocommon.whfslib.colorthreshold.GetColorValues;
import com.raytheon.viz.hydrocommon.whfslib.colorthreshold.NamedColorUseSet;
import com.raytheon.viz.mpe.core.MPEDataManager;
import com.raytheon.viz.mpe.core.MPEDataManager.MPEGageData;
import com.raytheon.viz.mpe.ui.Activator;
import com.raytheon.viz.mpe.ui.DisplayFieldData;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.rsc.XmrgResource;
import com.raytheon.viz.mpe.ui.rsc.MPEFieldResource;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
/**
@ -91,8 +76,6 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
*/
public class Display7x7Dialog extends CaveSWTDialog {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(Display7x7Dialog.class);
private Label gageID;
@ -128,8 +111,8 @@ public class Display7x7Dialog extends CaveSWTDialog {
private static Rectangle extent;
private static XmrgResource xmrgRsc;
private MPEFieldResource resource;
private static MPEGageData selectedGage;
private static MPEGageData workingGage;
@ -142,19 +125,9 @@ public class Display7x7Dialog extends CaveSWTDialog {
private short[][] xmGrid;
private DataMappingPreferences dmPref;
private ColorMap colorMap;
private ColorMapParameters parameters;
private String[] displayType;
private String[] dispTypeName;
private DisplayFieldData[] dfDataMap;
private final HashMap<String, Integer> dispMap = new HashMap<String, Integer>();
private DisplayFieldData[] displayTypes = MPEDisplayManager.mpe_qpe_fields;
private Combo prodSetCbo;
@ -162,8 +135,6 @@ public class Display7x7Dialog extends CaveSWTDialog {
private Composite comp2;
private XmrgFile xmFile;
private Composite compG;
private UnitConverter cvt;
@ -172,18 +143,11 @@ public class Display7x7Dialog extends CaveSWTDialog {
private Composite gridComp;
private boolean first = true;
private MPEGageData gData;
private Button setMissing;
private static final String APPLICATION_NAME = "hmapmpe";
private static final List<NamedColorUseSet> pColorSetGroup = MPEColors
.build_mpe_colors();
private static DisplayFieldData oldFieldData = DisplayFieldData.mMosaic;
private DisplayFieldData selectedFieldData;
private static boolean oldManedit = false;
@ -211,7 +175,6 @@ public class Display7x7Dialog extends CaveSWTDialog {
protected void initializeComponents(Shell shell) {
font = new Font(shell.getDisplay(), "Courier", 10, SWT.NORMAL);
int i = 0;
undoEn = false;
if (gData != null) {
@ -233,29 +196,8 @@ public class Display7x7Dialog extends CaveSWTDialog {
width = 7;
extent = new Rectangle(xOrig, yOrig, ht, width);
xmrgRsc = (XmrgResource) MPEDisplayManager.getCurrent()
.getDisplayedResource();
xmFile = xmrgRsc.getXmrgFile();
populateGrid();
displayType = MPEDisplayManager.mpe_qpe_fields;
dispTypeName = new String[displayType.length];
dfDataMap = new DisplayFieldData[displayType.length];
i = 0;
for (i = 0; i < displayType.length; i++) {
for (DisplayFieldData d : DisplayFieldData.values()) {
if (displayType[i].equalsIgnoreCase(d.name())) {
dispTypeName[i] = d.toString();
dispMap.put(displayType[i], i);
dfDataMap[i] = d;
break;
} else {
continue;
}
}
}
createProductListComp();
createGageGridComp();
createGageComp();
@ -275,21 +217,18 @@ public class Display7x7Dialog extends CaveSWTDialog {
MPEGageData gd = x.next();
MPEDataManager.getInstance().addEditedGage(gd);
}
MPEDisplayManager.getCurrent().setDataSaved(false);
}
if (!badGage.isEmpty() && !editGage.isEmpty()) {
for (int i = 0; i < badGage.size(); i++) {
String gd = badGage.get(i);
MPEDataManager.getInstance().addBadGage(gd);
}
MPEDisplayManager.getCurrent().setDataSaved(false);
}
if (!notBadGage.isEmpty() && !editGage.isEmpty()) {
for (int i = 0; i < notBadGage.size(); i++) {
String gd = notBadGage.get(i);
MPEDataManager.getInstance().removeBadGage(gd);
}
MPEDisplayManager.getCurrent().setDataSaved(false);
}
if ((!notBadGage.isEmpty() || !badGage.isEmpty())
&& !editGage.isEmpty()) {
@ -310,27 +249,39 @@ public class Display7x7Dialog extends CaveSWTDialog {
*
*/
private void populateGrid() {
resource = MPEDisplayManager.getCurrent().getDisplayedFieldResource();
if (resource == null) {
return;
}
parameters = resource.getCapability(ColorMapCapability.class)
.getColorMapParameters();
short[][] data = new short[7][7];
if (xmFile != null) {
Rectangle rect = xmFile.getHrapExtent();
if (resource != null) {
Rectangle rect = resource.getHrapExtent();
if (rect == null) {
return;
}
short[] xmData = xmFile.getData();
for (int i = 0; i < 7; ++i) {
for (int j = 0; j < 7; ++j) {
short val = -999;
int tmpJ = extent.x - rect.x + j;
int tmpI = rect.height - 1
- (extent.y + extent.height - 1 - rect.y) + i;
if (tmpI >= 0 && tmpJ >= 0 && tmpI < rect.height
&& tmpJ < rect.width) {
val = xmData[tmpI * rect.width + tmpJ];
try {
short[] xmData = resource.getData();
for (int i = 0; i < 7; ++i) {
for (int j = 0; j < 7; ++j) {
short val = -999;
int tmpJ = extent.x - rect.x + j;
int tmpI = rect.height - 1
- (extent.y + extent.height - 1 - rect.y) + i;
if (tmpI >= 0 && tmpJ >= 0 && tmpI < rect.height
&& tmpJ < rect.width) {
val = xmData[tmpI * rect.width + tmpJ];
}
data[i][j] = val;
}
data[i][j] = val;
}
} catch (VizException e) {
Activator.statusHandler.handle(Priority.PROBLEM,
"Error getting displayed MPE field data", e);
}
}
xmGrid = data;
@ -362,26 +313,25 @@ public class Display7x7Dialog extends CaveSWTDialog {
int selector = 0;
DisplayFieldData dstype = MPEDisplayManager.getCurrent()
.getDisplayFieldType();
oldFieldData = dstype;
if ((dstype != null) && dispMap.containsKey(dstype.name())) {
selector = dispMap.get(dstype.name());
selectedFieldData = dstype;
for (; selector < displayTypes.length; ++selector) {
if (displayTypes[selector] == dstype) {
break;
}
}
String[] displayTypeNames = new String[displayTypes.length];
for (int i = 0; i < displayTypes.length; ++i) {
displayTypeNames[i] = displayTypes[i].toString();
}
prodSetCbo.setTextLimit(35);
prodSetCbo.setLayoutData(gd);
prodSetCbo.setItems(dispTypeName);
prodSetCbo.setItems(displayTypeNames);
prodSetCbo.select(selector);
prodSetCbo.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
* .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
updateGridField(dfDataMap[prodSetCbo.getSelectionIndex()]);
updateGridField(displayTypes[prodSetCbo.getSelectionIndex()]);
}
});
}
@ -479,15 +429,16 @@ public class Display7x7Dialog extends CaveSWTDialog {
gageVal = String.format("%.2f", workingGage.getGval())
+ " in.";
if (workingGage.getGval() == 0) {
scaleVal = (0);
scaleValLab = String.format("%4.2f", 0.0);
scaleVal = (0);
scaleValLab = String.format("%4.2f", 0.0);
} else {
scaleVal = ((int) (100 * workingGage.getGval() - 0.01));
if (scaleVal == 0) {
scaleValLab = String.format("%4.2f", 0.0);
} else {
scaleValLab = String.format("%4.2f", (scaleVal / 100.0f));
}
scaleVal = ((int) (100 * workingGage.getGval() - 0.01));
if (scaleVal == 0) {
scaleValLab = String.format("%4.2f", 0.0);
} else {
scaleValLab = String.format("%4.2f",
(scaleVal / 100.0f));
}
}
}
}
@ -696,7 +647,8 @@ public class Display7x7Dialog extends CaveSWTDialog {
private void create7x7GridComp() {
comp2 = new Composite(compG, SWT.NONE);
comp2.setLayout(new GridLayout(1, true));
loadColors();
parameters = resource.getCapability(ColorMapCapability.class)
.getColorMapParameters();
gridComp = new Composite(comp2, SWT.NONE);
GridLayout layout = new GridLayout(7, true);
gridComp.setLayout(layout);
@ -809,39 +761,8 @@ public class Display7x7Dialog extends CaveSWTDialog {
return composite;
}
private void loadColors() {
if ((oldFieldData != dfDataMap[prodSetCbo.getSelectionIndex()])
|| first) {
List<Colorvalue> colorSet = MPEDisplayManager.getCurrent()
.getGageColorMap();
colorMap = new ColorMap(colorSet.size());
colorMap.setName(dfDataMap[prodSetCbo.getSelectionIndex()]
.getCv_use());
dmPref = new DataMappingPreferences();
int i = 0;
for (Colorvalue cv : colorSet) {
RGB rgb = RGBColors.getRGBColor(cv.getColorname()
.getColorName());
colorMap.setColor(i, new Color(rgb.red / 255f,
rgb.green / 255f, rgb.blue / 255f));
DataMappingEntry entry = new DataMappingEntry();
entry.setPixelValue((double) i);
entry.setDisplayValue(cv.getId().getThresholdValue());
dmPref.addEntry(entry);
i++;
}
if (parameters == null) {
parameters = xmrgRsc.getCapability(ColorMapCapability.class)
.getColorMapParameters();
}
first = false;
}
}
private RGB setColor(double val) {
double value = val;
private RGB setColor(float val) {
float value = val;
if (value == -999.0 || value == -9.0) {
value = -9999.0f;
@ -850,29 +771,9 @@ public class Display7x7Dialog extends CaveSWTDialog {
value = -8888.0f;
}
int i = 0;
RGB gageColor = null;
for (DataMappingEntry entry : dmPref.getEntries()) {
if (value <= entry.getDisplayValue()) {
if (i <= 2) {
gageColor = ColorMapParameters.colorToRGB(colorMap
.getColors().get(i));
} else {
gageColor = ColorMapParameters.colorToRGB(colorMap
.getColors().get(i - 1));
}
break;
}
i++;
}
if (gageColor == null) {
i = dmPref.getEntries().size();
gageColor = ColorMapParameters.colorToRGB(colorMap.getColors().get(
i - 1));
}
return gageColor;
Color color = parameters.getColorByValue(value);
return new RGB((int) (color.getRed() * 255),
(int) (color.getGreen() * 255), (int) (color.getBlue() * 255));
}
public void updateGageData(MPEGageData data) {
@ -993,116 +894,17 @@ public class Display7x7Dialog extends CaveSWTDialog {
if (gageVal.equalsIgnoreCase("missing")) {
setMissing.setEnabled(false);
}
updateGridField(dfDataMap[prodSetCbo.getSelectionIndex()]);
updateGridField(displayTypes[prodSetCbo.getSelectionIndex()]);
}
private void updateGridField(DisplayFieldData fieldType) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHH");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
SimpleDateFormat sxf = new SimpleDateFormat("MMddyyyyHH");
sxf.setTimeZone(TimeZone.getTimeZone("GMT"));
AppsDefaults appsDefaults = AppsDefaults.getInstance();
switch (fieldType) {
case avgrMosaic:
case bMosaic:
case gageOnly:
case Height:
case Index:
case lMosaic:
case Locbias:
case Locspan:
case satPre:
case lsatPre:
case maxrMosaic:
case mlMosaic:
case mMosaic:
case p3lMosaic:
case localField1:
case localField2:
case localField3:
case rfcbMosaic:
case rfcmMosaic:
case rMosaic:
case sgMosaic:
case srgMosaic:
case srMosaic:
case qmosaic:
case lqmosaic:
case mlqmosaic: {
String cv_use = fieldType.getCv_use();
String dirname = appsDefaults.getToken(fieldType.getDirToken());
String fname = FileUtil.join(
dirname,
cv_use
+ sdf.format(MPEDisplayManager.getCurrent()
.getCurrentDate()) + "z");
load_field(fname);
break;
MPEDisplayManager mgr = MPEDisplayManager.getCurrent();
if (selectedFieldData != fieldType) {
selectedFieldData = fieldType;
mgr.displayFieldData(fieldType);
populateGrid();
gridComp.notifyListeners(SWT.Paint, new Event());
}
case Xmrg: {
String cv_use = fieldType.getCv_use();
String dirname = appsDefaults.getToken(fieldType.getDirToken());
String fname = FileUtil.join(
dirname,
cv_use.toLowerCase()
+ sxf.format(MPEDisplayManager.getCurrent()
.getCurrentDate()) + "z");
load_field(fname);
break;
}
case rfcMosaic:
String cv_use = fieldType.getCv_use();
String dirname = appsDefaults.getToken(fieldType.getDirToken());
String fname = FileUtil.join(
dirname,
cv_use
+ "01+"
+ sdf.format(MPEDisplayManager.getCurrent()
.getCurrentDate()) + "z");
load_field(fname);
break;
default:
statusHandler.handle(Priority.PROBLEM,
"In routine display_mpe_data: Unrecognized MPE field type: "
+ fieldType.name());
break;
}
}
private void load_field(String fname) {
String user_id = System.getProperty("user.name");
String app_name = APPLICATION_NAME;
DisplayFieldData fieldType = dfDataMap[prodSetCbo.getSelectionIndex()];
if (oldFieldData != fieldType) {
List<Colorvalue> pColorSet = GetColorValues.get_colorvalues(
user_id, app_name, fieldType.getCv_use(),
fieldType.getCv_duration(), "E", pColorSetGroup);
xmFile = new XmrgFile(fname);
xmrgRsc = new XmrgResource(MPEDisplayManager.getCurrent(),
fieldType, xmFile, pColorSet);
loadColors();
oldFieldData = fieldType;
try {
xmFile.load();
} catch (IOException e) {
System.out.println("XMRG File not found " + fname);
}
}
populateGrid();
gridComp.notifyListeners(SWT.Paint, new Event());
}
/**

View file

@ -32,10 +32,12 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.viz.mpe.core.RegenHrFlds;
import com.raytheon.viz.mpe.ui.DisplayFieldData;
import com.raytheon.viz.mpe.ui.Activator;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.rsc.MPEFieldResource;
import com.raytheon.viz.ui.dialogs.CaveJFACEDialog;
/**
@ -93,28 +95,25 @@ public class DisplayFieldGenDialog extends CaveJFACEDialog {
yesButton.setText("Yes");
yesButton.setLayoutData(gd);
yesButton.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
* .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
MPEDisplayManager instance = MPEDisplayManager.getCurrent();
Date dt = instance.getCurrentDate();
Date dt = instance.getCurrentEditDate();
try {
// TODO: This process should send alert message that things
// were regenerated to keep CAVEs in sync with each other.
// TODO: Should this clear polygon edits/does it delete them
// on the file system?
RegenHrFlds.getInstance().regenFields(dt);
DisplayFieldData fldType = instance.getDisplayFieldType();
instance.setDisplayFieldType(fldType);
MPEFieldResource rsc = instance.getDisplayedFieldResource();
if (rsc != null) {
rsc.getResourceData().update(dt);
}
} catch (VizException ex) {
ex.printStackTrace();
Activator.statusHandler.handle(Priority.PROBLEM,
"Error regenerating hourly fields", ex);
}
DisplayFieldGenDialog.this.close();
instance.setDataSaved(true);
MPEDisplayManager.getCurrent().setCurrentDate(dt);
}
});
@ -125,14 +124,6 @@ public class DisplayFieldGenDialog extends CaveJFACEDialog {
noButton.setText("No");
noButton.setLayoutData(gd);
noButton.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
* .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
DisplayFieldGenDialog.this.close();

View file

@ -21,8 +21,6 @@ package com.raytheon.viz.mpe.ui.dialogs;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.TimeZone;
import org.eclipse.swt.SWT;
@ -35,28 +33,23 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Layout;
import org.eclipse.swt.widgets.Scale;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Spinner;
import org.eclipse.swt.widgets.Text;
import com.raytheon.uf.common.dataplugin.shef.tables.Colorvalue;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.viz.hydrocommon.util.MPEColors;
import com.raytheon.viz.hydrocommon.whfslib.colorthreshold.GetColorValues;
import com.raytheon.viz.hydrocommon.whfslib.colorthreshold.NamedColorUseSet;
import com.raytheon.viz.mpe.core.MPEDataManager;
import com.raytheon.viz.mpe.ui.DisplayFieldData;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.rsc.DisplayMeanArealPrecipResource;
import com.raytheon.viz.mpe.ui.rsc.DisplayMeanArealPrecipResourceData;
import com.raytheon.viz.mpe.ui.rsc.XmrgResource;
import com.raytheon.viz.mpe.ui.rsc.MPEFieldResource;
import com.raytheon.viz.mpe.ui.rsc.MPEFieldResourceData.ArealDisplay;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
/**
* TODO Add Description
@ -74,18 +67,10 @@ import com.raytheon.viz.mpe.ui.rsc.XmrgResource;
* @version 1.0
*/
public class MultiHourPrecipAccDialog extends Dialog {
private Shell shell;
public class MultiHourPrecipAccDialog extends CaveSWTDialog {
private Font font;
private Button okBtn;
private Button cancelBtn;
private int retval = 0;
private Scale durScale;
private Label durScaleValLbl;
@ -104,133 +89,95 @@ public class MultiHourPrecipAccDialog extends Dialog {
private Button valChk;
private boolean vals = false;
private Button idChk;
private boolean ids = false;
private Combo prodSetCbo;
private final MPEDisplayManager displayMgr = MPEDisplayManager.getCurrent();
private static final List<NamedColorUseSet> pColorSetGroup = MPEColors
.build_mpe_colors();
private final MPEDataManager dataMgr = MPEDataManager.getInstance();
String[] accumAreaTypes = { "Grid", "Basin", "County", "Zone" };
private String[] accumAreaTypes = { "Grid", "Basin", "County", "Zone" };
String[] precipAccumInterval = { "1 Hour", "3 Hour", "6 Hour", "12 Hour",
"24 Hour", "36 Hour", "48 Hour", "72 Hour", "Other..." };
private ArealDisplay[] arealTypeObjects = { ArealDisplay.GRID,
ArealDisplay.BASIN, ArealDisplay.COUNTY, ArealDisplay.ZONE };
int[] precipAccumInt = { 1, 3, 6, 12, 24, 36, 48, 72 };
private String[] precipAccumInterval = { "1 Hour", "3 Hour", "6 Hour",
"12 Hour", "24 Hour", "36 Hour", "48 Hour", "72 Hour", "Other..." };
String[] displayType;
private int[] precipAccumInt = { 1, 3, 6, 12, 24, 36, 48, 72 };
String[] dispTypeName;
private String[] dispTypeName;
private int accum_interval = 1;
private static final String APPLICATION_NAME = "hmapmpe";
HashMap<String, Integer> dispMap = new HashMap<String, Integer>();
DisplayFieldData[] dfDataMap;
String user_id = System.getProperty("user.name");
String app_name = APPLICATION_NAME;
List<Colorvalue> pColorSet = GetColorValues.get_colorvalues(user_id,
app_name, displayMgr.getDisplayFieldType().getCv_use(), displayMgr
.getDisplayFieldType().getCv_duration(), "E",
pColorSetGroup);
private DisplayFieldData[] displayTypes;
private Combo dispCbo;
private DisplayMeanArealPrecipResource dma;
private XmrgResource xmrgRsc;
private IDescriptor descriptor;
public MultiHourPrecipAccDialog(Shell parentShell) {
super(parentShell);
setText("Multi-Hour Precipitation Accumulation");
}
/**
* Open method used to display the Group Edit Stations dialog.
/*
* (non-Javadoc)
*
* @return Null.
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
*/
public int open() {
Shell parent = getParent();
Display display = parent.getDisplay();
shell = new Shell(parent, SWT.DIALOG_TRIM);
shell.setText("Multi-Hour Precipitation Accumulation");
// Create the main layout for the shell.
@Override
protected Layout constructShellLayout() {
GridLayout mainLayout = new GridLayout(1, true);
mainLayout.marginHeight = 1;
mainLayout.marginWidth = 1;
shell.setLayout(mainLayout);
font = new Font(shell.getDisplay(), "Courier", 10, SWT.NORMAL);
// Initialize all of the controls and layouts
initializeComponents();
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
font.dispose();
return retval;
return mainLayout;
}
/**
* Initialize the dialog components.
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
* .eclipse.swt.widgets.Shell)
*/
private void initializeComponents() {
@Override
protected void initializeComponents(Shell shell) {
font = new Font(shell.getDisplay(), "Courier", 10, SWT.NORMAL);
prevDate = displayMgr.getCurrentEditDate();
cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
prevDate = displayMgr.getCurrentDate();
cal.setTime(prevDate);
displayType = MPEDisplayManager.mpe_qpe_fields;
dispTypeName = new String[displayType.length];
dfDataMap = new DisplayFieldData[displayType.length];
int i = 0;
for (i = 0; i < displayType.length; i++) {
for (DisplayFieldData d : DisplayFieldData.values()) {
if (displayType[i].equalsIgnoreCase(d.name())) {
dispTypeName[i] = d.toString();
dispMap.put(displayType[i], i);
dfDataMap[i] = d;
break;
} else {
continue;
}
}
displayTypes = MPEDisplayManager.mpe_qpe_fields;
dispTypeName = new String[displayTypes.length];
for (int i = 0; i < displayTypes.length; i++) {
dispTypeName[i] = displayTypes[i].toString();
}
createProdListComp();
createIntervalComp();
createEndTimeComp();
createProdListComp(shell);
createIntervalComp(shell);
createEndTimeComp(shell);
updateTimeControls();
createAccDispComp();
createButtonComp();
createAccDispComp(shell);
createButtonComp(shell);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
*/
@Override
protected void disposed() {
font.dispose();
}
/**
* Create the data options group and controls.
*/
private void createProdListComp() {
private void createProdListComp(Shell shell) {
// Create a container to hold the label and the combo box.
GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
@ -247,19 +194,25 @@ public class MultiHourPrecipAccDialog extends Dialog {
gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
prodSetCbo = new Combo(prodListComp, SWT.LEFT | SWT.DROP_DOWN
| SWT.READ_ONLY);
int selector = dispMap.get("Xmrg");
DisplayFieldData dstype = MPEDisplayManager.getCurrent()
.getDisplayFieldType();
if ((dstype != null) && dispMap.containsKey(dstype.name())) {
selector = dispMap.get(dstype.name());
int selector = -1;
DisplayFieldData currData = displayMgr.getDisplayFieldType();
if (currData == null) {
currData = DisplayFieldData.Xmrg;
}
for (selector = 0; selector < displayTypes.length; ++selector) {
if (displayTypes[selector] == currData) {
break;
}
}
prodSetCbo.setTextLimit(35);
prodSetCbo.setLayoutData(gd);
prodSetCbo.setItems(dispTypeName);
prodSetCbo.select(selector);
}
private void createIntervalComp() {
private void createIntervalComp(Shell shell) {
Group intervalOptionsGroup = new Group(shell, SWT.NONE);
intervalOptionsGroup.setText("Accumulation Interval Setup");
GridLayout groupLayout = new GridLayout(1, false);
@ -335,7 +288,7 @@ public class MultiHourPrecipAccDialog extends Dialog {
}
private void createEndTimeComp() {
private void createEndTimeComp(Shell shell) {
// create date area
Group dateComp = new Group(shell, SWT.SHADOW_ETCHED_IN);
GridData data = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
@ -410,7 +363,7 @@ public class MultiHourPrecipAccDialog extends Dialog {
});
}
private void createAccDispComp() {
private void createAccDispComp(Shell shell) {
Group accDispCompGroup = new Group(shell, SWT.SHADOW_ETCHED_IN);
GridData data = new GridData(SWT.FILL, SWT.DEFAULT, true, false);
accDispCompGroup.setLayoutData(data);
@ -439,8 +392,6 @@ public class MultiHourPrecipAccDialog extends Dialog {
@Override
public void widgetSelected(SelectionEvent e) {
if (dispCbo.getText().equalsIgnoreCase("Grid")) {
ids = false;
vals = false;
valChk.setEnabled(false);
idChk.setEnabled(false);
} else {
@ -459,26 +410,14 @@ public class MultiHourPrecipAccDialog extends Dialog {
valChk.setText("Values");
valChk.setData(0);
valChk.setEnabled(false);
valChk.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
vals = !vals;
}
});
idChk = new Button(dispComp, SWT.CHECK);
idChk.setText("Ids");
idChk.setData(1);
idChk.setEnabled(false);
idChk.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ids = !ids;
}
});
}
private void createButtonComp() {
private void createButtonComp(Shell shell) {
// Create a container to hold the button.
GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false);
Composite okBtnComp = new Composite(shell, SWT.NONE);
@ -487,96 +426,28 @@ public class MultiHourPrecipAccDialog extends Dialog {
okBtnComp.setLayoutData(gd);
GridData bd = new GridData(110, 30);
okBtn = new Button(okBtnComp, SWT.PUSH);
Button okBtn = new Button(okBtnComp, SWT.PUSH);
okBtn.setText("Show Data");
okBtn.setLayoutData(bd);
okBtn.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
* .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
retval = 1;
displayMgr.clearMPEData();
MPEDisplayManager.getCurrent().setAccum_interval(accum_interval);
MPEDisplayManager.getCurrent().setCurrentDate(cal.getTime());
displayMgr.setAccum_interval(accum_interval);
displayMgr.setOtherDispType(DisplayFieldData.multiHour);
IRenderableDisplay display = displayMgr.getRenderableDisplay();
IDescriptor descriptor = display.getDescriptor();
MultiHourPrecipAccDialog.this.descriptor = descriptor;
xmrgRsc = (XmrgResource) MPEDisplayManager.getCurrent()
.getDisplayedResource();
// Update the screen
if (dispCbo.getText().equalsIgnoreCase("Grid")) {
if (descriptor.getResourceList().containsRsc(dma)) {
descriptor.getResourceList().removeRsc(dma);
dma.dispose();
}
displayMgr.setDisplayFieldType(dfDataMap[prodSetCbo
.getSelectionIndex()]);
xmrgRsc = (XmrgResource) MPEDisplayManager.getCurrent()
.getDisplayedResource();
xmrgRsc.updateXmrg(false);
} else {
if (descriptor.getResourceList().containsRsc(dma)) {
descriptor.getResourceList().removeRsc(dma);
dma.dispose();
}
displayMgr.setDisplayFieldType(dfDataMap[prodSetCbo
.getSelectionIndex()]);
ResourcePair rp = new ResourcePair();
DisplayMeanArealPrecipResourceData dmad = new DisplayMeanArealPrecipResourceData(
displayMgr, dispCbo.getText().toUpperCase(),
pColorSet);
rp.setResourceData(dmad);
descriptor.getResourceList().add(rp);
descriptor.getResourceList().instantiateResources(
descriptor, true);
dma = (DisplayMeanArealPrecipResource) rp.getResource();
DisplayMeanArealPrecipResource.vals = vals;
DisplayMeanArealPrecipResource.ids = ids;
}
showAccumulationData();
}
});
bd = new GridData(110, 30);
cancelBtn = new Button(okBtnComp, SWT.PUSH);
Button cancelBtn = new Button(okBtnComp, SWT.PUSH);
cancelBtn.setText("Close");
cancelBtn.setLayoutData(bd);
cancelBtn.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
* .swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent e) {
retval = 0;
if (dma != null) {
if (descriptor.getResourceList().containsRsc(dma)) {
descriptor.getResourceList().removeRsc(dma);
}
dma.dispose();
displayMgr.getRenderableDisplay().getDescriptor()
.getResourceList().removeRsc(dma);
}
// if (xmrgRsc != null) {
// if (descriptor.getResourceList().containsRsc(xmrgRsc)) {
// descriptor.getResourceList().removeRsc(xmrgRsc);
// }
// xmrgRsc.dispose();
// }
shell.dispose();
close();
}
});
}
@ -593,4 +464,42 @@ public class MultiHourPrecipAccDialog extends Dialog {
daySpinner.setSelection(cal.get(Calendar.DAY_OF_MONTH));
hourSpinner.setSelection(cal.get(Calendar.HOUR_OF_DAY));
}
private void showAccumulationData() {
int accumHrs = accum_interval;
Date editTime = cal.getTime();
ArealDisplay arealDisplay = arealTypeObjects[dispCbo
.getSelectionIndex()];
DisplayFieldData displayField = displayTypes[prodSetCbo
.getSelectionIndex()];
IRenderableDisplay display = displayMgr.getRenderableDisplay();
IDescriptor descriptor = display.getDescriptor();
if (displayMgr.setCurrentEditDate(editTime)) {
if (dma != null) {
descriptor.getResourceList().removeRsc(dma);
dma = null;
}
if (arealDisplay == ArealDisplay.GRID) {
displayMgr.displayFieldData(displayField, accumHrs,
arealDisplay);
MPEFieldResource resource = displayMgr
.getDisplayedFieldResource();
resource.getResourceData().setDisplayIds(idChk.getSelection());
resource.getResourceData().setDisplayValues(
valChk.getSelection());
resource.issueRefresh();
} else {
// TODO: Move functionality of this resource to
// AbstractMPEGriddedResource and delete this one
displayMgr.displayFieldData(displayField);
dma = new DisplayMeanArealPrecipResource(displayMgr,
arealDisplay.name(), displayField, accumHrs);
DisplayMeanArealPrecipResource.vals = valChk.getSelection();
DisplayMeanArealPrecipResource.ids = idChk.getSelection();
descriptor.getResourceList().add(dma);
}
}
}
}

View file

@ -51,7 +51,6 @@ import com.raytheon.viz.mpe.ui.actions.GageQcSelect;
import com.raytheon.viz.mpe.ui.actions.OtherFreezeOptions;
import com.raytheon.viz.mpe.ui.actions.OtherPrecipOptions;
import com.raytheon.viz.mpe.ui.actions.SaveLevel2Data;
import com.raytheon.viz.mpe.ui.rsc.XmrgResource;
import com.raytheon.viz.mpe.util.DailyQcUtils;
import com.raytheon.viz.mpe.util.DailyQcUtils.Ts;
import com.raytheon.viz.mpe.util.DailyQcUtils.Zdata;
@ -194,19 +193,19 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
public Object open() {
Shell parent = this.getParent();
Display display = parent.getDisplay();
Date prevDate = MPEDisplayManager.getCurrent().getCurrentDate();
MPEDisplayManager displayMgr = MPEDisplayManager.getCurrent();
Date prevDate = displayMgr.getCurrentEditDate();
Date currDate = ChooseDataPeriodDialog.prevDate;
String QcArea = ChooseDataPeriodDialog.prevArea;
AppsDefaults appDefaults = AppsDefaults.getInstance();
DisplayFieldData df = MPEDisplayManager.getCurrent()
.getDisplayFieldType();
DisplayFieldData df = displayMgr.getDisplayFieldType();
if (currDate == null) {
currDate = prevDate;
}
if (QcArea == null) {
QcArea = appDefaults.getToken("mpe_site_id");
}
int qcDays = MPEDisplayManager.getCurrent().getDqcDays();
int qcDays = displayMgr.getDqcDays();
// checks to see if area or date has changed since last data load
DailyQcUtils dqcu = new DailyQcUtils();
// reloads data if changed
@ -233,16 +232,16 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
dataType.add("Points+Contours");
dataType.add("None");
dataSet.addAll(dataType);
if (MPEDisplayManager.getCurrent().isQpf()) {
if (displayMgr.isQpf()) {
QcPrecipOptionsDialog.destroy(false);
MPEDisplayManager.getCurrent().setQpf(false);
displayMgr.setQpf(false);
}
if (MPEDisplayManager.getCurrent().isMaxmin()) {
if (displayMgr.isMaxmin()) {
QcTempOptionsDialog.destroy(false);
MPEDisplayManager.getCurrent().setMaxmin(false);
displayMgr.setMaxmin(false);
}
MPEDisplayManager.getCurrent().setZflag(true);
displayMgr.setZflag(true);
ddqc = DrawDQCStations.getInstance();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.MODELESS);
@ -278,20 +277,20 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
shell.pack();
shell.open();
MPEDisplayManager.getCurrent().setZflag(true);
displayMgr.setZflag(true);
isOpen = true;
isfinished = false;
ozo.chg_freeze_time(2);
opo.send_expose();
while (!shell.isDisposed()) {
if (dqc_good == 0) {
MPEDisplayManager.getCurrent().setZflag(false);
displayMgr.setZflag(false);
isOpen = false;
ddqc.destroy();
shell.dispose();
}
if (isOpen == false) {
MPEDisplayManager.getCurrent().setZflag(false);
displayMgr.setZflag(false);
ddqc.destroy();
shell.dispose();
}
@ -300,7 +299,7 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
}
}
ddqc.destroy();
MPEDisplayManager.getCurrent().setZflag(false);
displayMgr.setZflag(false);
isfinished = true;
isOpen = false;
font.dispose();
@ -308,18 +307,17 @@ public class QcFreezeOptionsDialog extends AbstractMPEDialog {
s2.send_dbase_new_area();
DailyQcUtils dc = new DailyQcUtils();
dc.clearData();
MPEDisplayManager.getCurrent().setDisplayFieldType(df);
XmrgResource xmrgRsc = (XmrgResource) MPEDisplayManager.getCurrent()
.getDisplayedResource();
xmrgRsc.updateXmrg(false);
displayMgr.displayFieldData(df);
removePerspectiveListener();
final ChooseDataPeriodDialog dialog = new ChooseDataPeriodDialog(
getParent().getShell());
display.asyncExec(new Runnable() {
public void run() {
dialog.open();
}
});
if (MPEDisplayManager.getCurrent() != null) {
display.asyncExec(new Runnable() {
public void run() {
ChooseDataPeriodDialog dialog = new ChooseDataPeriodDialog(
getParent().getShell());
dialog.open();
}
});
}
return s2;
}

View file

@ -49,7 +49,6 @@ import com.raytheon.viz.mpe.ui.actions.GageQcSelect;
import com.raytheon.viz.mpe.ui.actions.OtherPrecipOptions;
import com.raytheon.viz.mpe.ui.actions.SaveLevel2Data;
import com.raytheon.viz.mpe.ui.actions.ScreeningOptions;
import com.raytheon.viz.mpe.ui.rsc.XmrgResource;
import com.raytheon.viz.mpe.util.DailyQcUtils;
import com.raytheon.viz.mpe.util.DailyQcUtils.Pdata;
import com.raytheon.viz.mpe.util.DailyQcUtils.Ts;
@ -203,19 +202,19 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
public Object open() {
Shell parent = this.getParent();
Display display = parent.getDisplay();
Date prevDate = MPEDisplayManager.getCurrent().getCurrentDate();
MPEDisplayManager displayMgr = MPEDisplayManager.getCurrent();
Date prevDate = displayMgr.getCurrentEditDate();
Date currDate = ChooseDataPeriodDialog.prevDate;
String QcArea = ChooseDataPeriodDialog.prevArea;
AppsDefaults appDefaults = AppsDefaults.getInstance();
DisplayFieldData df = MPEDisplayManager.getCurrent()
.getDisplayFieldType();
DisplayFieldData df = displayMgr.getDisplayFieldType();
if (currDate == null) {
currDate = prevDate;
}
if (QcArea == null) {
QcArea = appDefaults.getToken("mpe_site_id");
}
int qcDays = MPEDisplayManager.getCurrent().getDqcDays();
int qcDays = displayMgr.getDqcDays();
// checks to see if area or date has changed since last data load
DailyQcUtils dqcu = new DailyQcUtils();
// reloads data if changed
@ -243,16 +242,16 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
dataType.add("Points+Contours");
dataType.add("None");
dataSet.addAll(dataType);
if (MPEDisplayManager.getCurrent().isMaxmin()) {
if (displayMgr.isMaxmin()) {
QcTempOptionsDialog.destroy(false);
MPEDisplayManager.getCurrent().setMaxmin(false);
displayMgr.setMaxmin(false);
}
if (MPEDisplayManager.getCurrent().isZflag()) {
if (displayMgr.isZflag()) {
QcFreezeOptionsDialog.destroy(false);
MPEDisplayManager.getCurrent().setZflag(false);
displayMgr.setZflag(false);
}
MPEDisplayManager.getCurrent().setQpf(true);
displayMgr.setQpf(true);
ddqc = DrawDQCStations.getInstance();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.MODELESS);
@ -273,20 +272,20 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
shell.pack();
shell.open();
MPEDisplayManager.getCurrent().setQpf(true);
displayMgr.setQpf(true);
isOpen = true;
isfinished = false;
opo.chg_precip_time(selsix24Cbo.getSelectionIndex() + 2);
opo.send_expose();
while (!shell.isDisposed()) {
if (dqc_good == 0) {
MPEDisplayManager.getCurrent().setQpf(false);
displayMgr.setQpf(false);
isOpen = false;
ddqc.destroy();
shell.dispose();
}
if (isOpen == false) {
MPEDisplayManager.getCurrent().setQpf(false);
displayMgr.setQpf(false);
ddqc.destroy();
shell.dispose();
}
@ -295,7 +294,7 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
}
}
ddqc.destroy();
MPEDisplayManager.getCurrent().setQpf(false);
displayMgr.setQpf(false);
isfinished = true;
isOpen = false;
font.dispose();
@ -303,18 +302,17 @@ public class QcPrecipOptionsDialog extends AbstractMPEDialog {
s2.send_dbase_new_area();
DailyQcUtils dc = new DailyQcUtils();
dc.clearData();
MPEDisplayManager.getCurrent().setDisplayFieldType(df);
XmrgResource xmrgRsc = (XmrgResource) MPEDisplayManager.getCurrent()
.getDisplayedResource();
xmrgRsc.updateXmrg(false);
displayMgr.displayFieldData(df);
removePerspectiveListener();
final ChooseDataPeriodDialog dialog = new ChooseDataPeriodDialog(
getParent().getShell());
display.asyncExec(new Runnable() {
public void run() {
dialog.open();
}
});
if (MPEDisplayManager.getCurrent() != null) {
display.asyncExec(new Runnable() {
public void run() {
ChooseDataPeriodDialog dialog = new ChooseDataPeriodDialog(
getParent().getShell());
dialog.open();
}
});
}
return s2;
}

View file

@ -50,7 +50,6 @@ import com.raytheon.viz.mpe.ui.actions.OtherPrecipOptions;
import com.raytheon.viz.mpe.ui.actions.OtherTempOptions;
import com.raytheon.viz.mpe.ui.actions.SaveLevel2Data;
import com.raytheon.viz.mpe.ui.actions.ScreeningOptions;
import com.raytheon.viz.mpe.ui.rsc.XmrgResource;
import com.raytheon.viz.mpe.util.DailyQcUtils;
import com.raytheon.viz.mpe.util.DailyQcUtils.Tdata;
import com.raytheon.viz.mpe.util.DailyQcUtils.Ts;
@ -195,19 +194,19 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
public Object open() {
Shell parent = this.getParent();
Display display = parent.getDisplay();
Date prevDate = MPEDisplayManager.getCurrent().getCurrentDate();
MPEDisplayManager displayMgr = MPEDisplayManager.getCurrent();
Date prevDate = displayMgr.getCurrentEditDate();
Date currDate = ChooseDataPeriodDialog.prevDate;
String QcArea = ChooseDataPeriodDialog.prevArea;
AppsDefaults appDefaults = AppsDefaults.getInstance();
DisplayFieldData df = MPEDisplayManager.getCurrent()
.getDisplayFieldType();
DisplayFieldData df = displayMgr.getDisplayFieldType();
if (currDate == null) {
currDate = prevDate;
}
if (QcArea == null) {
QcArea = appDefaults.getToken("mpe_site_id");
}
int qcDays = MPEDisplayManager.getCurrent().getDqcDays();
int qcDays = displayMgr.getDqcDays();
// checks to see if area or date has changed since last data load
DailyQcUtils dqcu = new DailyQcUtils();
// reloads data if changed
@ -234,15 +233,15 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
dataType.add("Points+Contours");
dataType.add("None");
dataSet.addAll(dataType);
if (MPEDisplayManager.getCurrent().isQpf()) {
if (displayMgr.isQpf()) {
QcPrecipOptionsDialog.destroy(false);
MPEDisplayManager.getCurrent().setQpf(false);
displayMgr.setQpf(false);
}
if (MPEDisplayManager.getCurrent().isZflag()) {
if (displayMgr.isZflag()) {
QcFreezeOptionsDialog.destroy(false);
}
MPEDisplayManager.getCurrent().setMaxmin(true);
displayMgr.setMaxmin(true);
ddqc = DrawDQCStations.getInstance();
shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.MODELESS);
@ -265,20 +264,20 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
shell.pack();
shell.open();
MPEDisplayManager.getCurrent().setMaxmin(true);
displayMgr.setMaxmin(true);
isOpen = true;
isfinished = false;
oto.chg_maxmin_time(maxminTimeCbo.getSelectionIndex() + 2);
opo.send_expose();
while (!shell.isDisposed()) {
if (dqc_good == 0) {
MPEDisplayManager.getCurrent().setMaxmin(false);
displayMgr.setMaxmin(false);
isOpen = false;
ddqc.destroy();
shell.dispose();
}
if (isOpen == false) {
MPEDisplayManager.getCurrent().setMaxmin(false);
displayMgr.setMaxmin(false);
ddqc.destroy();
shell.dispose();
}
@ -287,7 +286,7 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
}
}
ddqc.destroy();
MPEDisplayManager.getCurrent().setMaxmin(false);
displayMgr.setMaxmin(false);
isfinished = true;
isOpen = false;
font.dispose();
@ -295,18 +294,17 @@ public class QcTempOptionsDialog extends AbstractMPEDialog {
s2.send_dbase_new_area();
DailyQcUtils dc = new DailyQcUtils();
dc.clearData();
MPEDisplayManager.getCurrent().setDisplayFieldType(df);
XmrgResource xmrgRsc = (XmrgResource) MPEDisplayManager.getCurrent()
.getDisplayedResource();
xmrgRsc.updateXmrg(false);
displayMgr.displayFieldData(df);
removePerspectiveListener();
final ChooseDataPeriodDialog dialog = new ChooseDataPeriodDialog(
getParent().getShell());
display.asyncExec(new Runnable() {
public void run() {
dialog.open();
}
});
if (MPEDisplayManager.getCurrent() != null) {
display.asyncExec(new Runnable() {
public void run() {
ChooseDataPeriodDialog dialog = new ChooseDataPeriodDialog(
getParent().getShell());
dialog.open();
}
});
}
return s2;
}

View file

@ -280,7 +280,7 @@ public class RadarBiasTableDialog extends Dialog {
dtLblComp.setLayoutData(bd);
Label tmslotLbl = new Label(dtLblComp, SWT.CENTER);
tmslotLbl.setLayoutData(bd);
Date dt = MPEDisplayManager.getCurrent().getCurrentDate();
Date dt = MPEDisplayManager.getCurrent().getCurrentEditDate();
String dt3 = st3sdf.format(dt);
tmslotLbl.setText(dt3 + "z");
@ -320,7 +320,7 @@ public class RadarBiasTableDialog extends Dialog {
biasListComp
.setSize(biasListComp.computeSize(SWT.DEFAULT, SWT.DEFAULT));
Date dt3 = MPEDisplayManager.getCurrent().getCurrentDate();
Date dt3 = MPEDisplayManager.getCurrent().getCurrentEditDate();
dt = pgsdf.format(dt3);
rsList = new HashMap<String, MPERadarData>(radIds.length);
rsList = MPEDataManager.getInstance().readRadarData(dt3);

View file

@ -227,7 +227,7 @@ public class RadarSpanDialog extends Dialog {
bd = new GridData(SWT.LEFT, SWT.CENTER, true, true);
Label tmslotLbl = new Label(dtLblComp, SWT.CENTER);
tmslotLbl.setLayoutData(bd);
Date dt = MPEDisplayManager.getCurrent().getCurrentDate();
Date dt = MPEDisplayManager.getCurrent().getCurrentEditDate();
String dt3 = st3sdf.format(dt);
tmslotLbl.setText(dt3 + "z");

View file

@ -270,7 +270,7 @@ public class GageTableDataManager {
MPEDataManager mpeDataManager = MPEDataManager.getInstance();
MPEDisplayManager displayManager = MPEDisplayManager.getCurrent();
Date currentDate = displayManager.getCurrentDate();
Date currentDate = displayManager.getCurrentEditDate();
String radarId = "ZZZ";
HRAPSubGrid subGrid = null;
DisplayFieldData dataType = DisplayFieldData.Index;
@ -337,7 +337,7 @@ public class GageTableDataManager {
public short[][] getXmrgData(String path, String type, Rectangle extent)
throws IOException {
MPEDisplayManager displayManager = MPEDisplayManager.getCurrent();
Date currentDate = displayManager.getCurrentDate();
Date currentDate = displayManager.getCurrentEditDate();
if (type.equalsIgnoreCase(GageTableProductManager.MPE_AVGRMOSAIC)) {
if ((avgrMosaic == null) || !currentDate.equals(dataDate)) {
@ -926,7 +926,7 @@ public class GageTableDataManager {
String cv_use = dataType.getCv_use();
String dirname = appsDefaults.getToken(dataType.getDirToken());
String fname = FileUtil.join(dirname,
cv_use + sdf.format(displayManager.getCurrentDate()) + "z");
cv_use + sdf.format(displayManager.getCurrentEditDate()) + "z");
Rectangle extent = dataManager.getHRAPExtent();
@ -966,7 +966,7 @@ public class GageTableDataManager {
*/
public List<MPEGageData> readGageData() {
MPEDisplayManager displayManager = MPEDisplayManager.getCurrent();
Date currentDate = displayManager.getCurrentDate();
Date currentDate = displayManager.getCurrentEditDate();
if ((mpeGageDataList == null) || !currentDate.equals(dataDate)) {
MPEDataManager mpeDataManager = MPEDataManager.getInstance();

View file

@ -88,6 +88,7 @@ import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.ohd.AppsDefaults;
import com.raytheon.viz.mpe.core.MPEDataManager;
import com.raytheon.viz.mpe.core.MPEDataManager.MPEGageData;
import com.raytheon.viz.mpe.ui.IEditTimeChangedListener;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.dialogs.gagetable.xml.GageTableColumnData;
import com.raytheon.viz.mpe.ui.dialogs.gagetable.xml.GageTableSettings;
@ -109,7 +110,7 @@ import com.raytheon.viz.mpe.ui.dialogs.gagetable.xml.GageTableSortType;
* @version 1.0
*/
public class GageTableDlg extends JFrame {
public class GageTableDlg extends JFrame implements IEditTimeChangedListener {
private static final long serialVersionUID = -4230332238083384449L;
/**
@ -200,6 +201,8 @@ public class GageTableDlg extends JFrame {
*/
private final Map<String, GageTableRowData> editMap = new HashMap<String, GageTableRowData>();
private MPEDisplayManager displayManager;
/**
* Constructor.
*/
@ -230,8 +233,8 @@ public class GageTableDlg extends JFrame {
readSettingsFile();
MPEDisplayManager displayManager = MPEDisplayManager.getCurrent();
currentDate = displayManager.getCurrentDate();
displayManager = MPEDisplayManager.getCurrent();
currentDate = displayManager.getCurrentEditDate();
AppsDefaults appsDefaults = AppsDefaults.getInstance();
@ -271,9 +274,9 @@ public class GageTableDlg extends JFrame {
setLocation(xCoord - (bounds.width / 2), yCoord - (bounds.height / 2));
setVisible(true);
// tableModel.refreshTable();
// tableModel.refreshTable();
displayManager.setGageTableDlgReference(this);
displayManager.registerEditTimeChangedListener(this);
}
/**
@ -551,7 +554,6 @@ public class GageTableDlg extends JFrame {
tableModel = null;
setVisible(false);
GageTableDataManager.setNull();
MPEDisplayManager.getCurrent().setGageTableDlgReference(null);
dispose();
}
}
@ -1366,7 +1368,6 @@ public class GageTableDlg extends JFrame {
setVisible(false);
tableModel = null;
GageTableDataManager.setNull();
MPEDisplayManager.getCurrent().setGageTableDlgReference(null);
dispose();
}
@ -1427,4 +1428,30 @@ public class GageTableDlg extends JFrame {
GageTableUpdateEvent event = new GageTableUpdateEvent(this, true);
GageTableProductManager.getInstance().fireUpdateEvent(event);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.mpe.ui.IEditTimeChangedListener#editTimeChanged(java
* .util.Date, java.util.Date)
*/
@Override
public void editTimeChanged(Date oldTime, Date newTime) {
updateDate(newTime);
}
/*
* (non-Javadoc)
*
* @see java.awt.Window#dispose()
*/
@Override
public void dispose() {
if (displayManager != null) {
displayManager.unregisterEditTimeChangedListener(this);
}
super.dispose();
}
}

View file

@ -38,7 +38,7 @@ import org.eclipse.swt.widgets.Spinner;
import com.raytheon.uf.common.dataplugin.shef.tables.Rwradarresult;
import com.raytheon.viz.hydrocommon.whfslib.IHFSDbGenerated;
import com.raytheon.viz.mpe.MPEConstants;
import com.raytheon.viz.mpe.MPEDateFormatter;
import com.raytheon.viz.mpe.core.MPEDataManager;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
@ -233,8 +233,8 @@ public class EditBiasDlg extends CaveSWTDialog {
private void applyBiasUpdate() {
String where = "";
float memspan = -99.0f;
Date dt3 = MPEDisplayManager.getCurrent().getCurrentDate();
String date = MPEConstants.DATE_FORMAT_YYYYMMDDHHMMSS.format(dt3);
Date dt3 = MPEDisplayManager.getCurrent().getCurrentEditDate();
String date = MPEDateFormatter.format_yyyyMMddHHmmss(dt3);
ArrayList<Rwradarresult> rwr = new ArrayList<Rwradarresult>();
Rwradarresult rwrr = new Rwradarresult();

View file

@ -65,7 +65,7 @@ import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.ResourceProperties;
import com.raytheon.viz.hydrocommon.whfslib.colorthreshold.GetColorValues;
import com.raytheon.viz.hydrocommon.whfslib.colorthreshold.NamedColorUseSet;
import com.raytheon.viz.mpe.MPEConstants;
import com.raytheon.viz.mpe.MPEDateFormatter;
import com.raytheon.viz.mpe.core.MPEDataManager;
import com.raytheon.viz.mpe.core.MPEDataManager.MPERadarData;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
@ -184,7 +184,7 @@ public class ReviewHourlyRadarDlg extends CaveSWTDialog implements
biasValue = getBiasValue(radId);
// try {
dpaDate = MPEDisplayManager.getCurrent().getCurrentDate();
dpaDate = MPEDisplayManager.getCurrent().getCurrentEditDate();
// Changed to comply with DR 11395
@ -490,11 +490,10 @@ public class ReviewHourlyRadarDlg extends CaveSWTDialog implements
radarLbl.setBackground(Display.getDefault().getSystemColor(
SWT.COLOR_WIDGET_BACKGROUND));
Date currentDate = MPEDisplayManager.getCurrent().getCurrentDate();
Date currentDate = MPEDisplayManager.getCurrent().getCurrentEditDate();
Label dateLbl = new Label(labelComp, SWT.LEAD | SWT.BORDER);
dateLbl.setText(" "
+ MPEConstants.DATE_FORMAT_MMDDYYYYHH.format(currentDate)
+ "z ");
+ MPEDateFormatter.format_MMM_dd_yyyy_HH(currentDate) + "z ");
dateLbl.setBackground(Display.getDefault().getSystemColor(
SWT.COLOR_WIDGET_BACKGROUND));
@ -526,6 +525,7 @@ public class ReviewHourlyRadarDlg extends CaveSWTDialog implements
List<NamedColorUseSet> pColorSetGroup = MPEDisplayManager
.getCurrent().getColorSetGroup();
// TODO: Replace with resources looking up color maps themselves!!!
List<Colorvalue> colorSet = GetColorValues.get_colorvalues(user_id,
app_name, "RMOSAIC", 3600, "E", pColorSetGroup);
@ -829,8 +829,10 @@ public class ReviewHourlyRadarDlg extends CaveSWTDialog implements
* The Radar Id
*/
private String getBiasValue(String radId) {
MPERadarData radarData = MPEDataManager.getInstance()
.readRadarData(MPEDisplayManager.getCurrent().getCurrentDate())
MPERadarData radarData = MPEDataManager
.getInstance()
.readRadarData(
MPEDisplayManager.getCurrent().getCurrentEditDate())
.get(radId);
return String.format("%-1.2f", radarData.getRwBiasValUsed());
}

View file

@ -37,8 +37,9 @@ import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import com.raytheon.viz.mpe.ui.DisplayFieldData;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.rsc.XmrgResource;
import com.raytheon.viz.mpe.ui.dialogs.polygon.RubberPolyData.PolygonEditAction;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
/**
@ -275,22 +276,29 @@ public class DeletePolygonDlg extends CaveSWTDialog {
}
/**
* Populate the dialog.
* Populate the dialog with polygon edits from {@link PolygonEditManager}
*/
private void populateDlg() {
MPEDisplayManager displayManager = MPEDisplayManager.getCurrent();
Date currentDate = displayManager.getCurrentDate();
PolygonDataManager polyManager = PolygonDataManager.getInstance();
dateTimeTF.setText(sdf.format(currentDate));
Date editDate = displayManager.getCurrentEditDate();
DisplayFieldData fieldData = displayManager.getDisplayFieldType();
dateTimeTF.setText(sdf.format(editDate));
polygonListBox.removeAll();
String type = displayManager.getDisplayFieldType().getCv_use()
.toUpperCase();
productTF.setText(type);
polygonList = PolygonEditManager.getPolygonEdits(fieldData, editDate);
recreatePolygonListBox();
}
// Get the polygons
polygonList = polyManager.getPolygonList();
/**
* Recreates the polygonListBox based on polygonList field
*/
private void recreatePolygonListBox() {
int[] selected = polygonListBox.getSelectionIndices();
polygonListBox.removeAll();
for (int i = 0; i < polygonList.size(); i++) {
RubberPolyData data = polygonList.get(i);
String number = String.valueOf(i + 1);
@ -304,76 +312,53 @@ public class DeletePolygonDlg extends CaveSWTDialog {
persist = "T";
}
String action = null;
if (data.isLower_flag()) {
action = "Lower";
} else if (data.isRaise_flag()) {
action = "Raise";
} else if (data.isScale_flag()) {
action = "Scale";
} else if (data.isSet_flag()) {
action = "Set";
} else if (data.isSnow_flag()) {
action = "Snow";
} else {
action = "Sub";
}
if (action.equals("Sub")) {
PolygonEditAction action = data.getEditAction();
if (action == PolygonEditAction.SUB) {
String value = data.getSubDrawSource().getCv_use();
polygonListBox.add(String.format(format2, number, displayed,
persist, action, value));
persist, action.toPrettyName(), value));
} else {
double value = data.getPrecipValue() / 100;
double value = data.getPrecipValue();
polygonListBox.add(String.format(format, number, displayed,
persist, action, value));
persist, action.toPrettyName(), value));
}
}
int numGood = 0;
for (int idx : selected) {
if (idx >= 0 && idx < polygonListBox.getItemCount()) {
numGood += 1;
}
}
int[] newSelected = new int[numGood];
int i = 0;
for (int idx : selected) {
if (idx >= 0 && idx < polygonListBox.getItemCount()) {
newSelected[i++] = idx;
}
}
polygonListBox.select(newSelected);
}
/**
* Delete the selected polygon.
*/
private void delete() {
PolygonDataManager dataMgr = PolygonDataManager.getInstance();
// Make sure a selection has been made.
if (polygonListBox.getSelectionIndex() < 0) {
return;
}
// Remove selected from list and apply
polygonList.remove(polygonListBox.getSelectionIndex());
dataMgr.setPolygonList(polygonList);
polygonListBox.removeAll();
populateDlg();
PrecipPolyUtils.writePolygons();
applyPolygons();
applyPolygonList();
}
/**
* Delete all polygons.
*/
private void deleteAll() {
PolygonDataManager dataMgr = PolygonDataManager.getInstance();
// Clear the list and list widget
// Clear the list and apply
polygonList.clear();
polygonListBox.removeAll();
// Update the xmrg data by rereading the file
XmrgResource xmrgRsc = (XmrgResource) MPEDisplayManager.getCurrent()
.getDisplayedResource();
xmrgRsc.updateXmrg(true);
// MPEDisplayManager.getCurrent().getPolyResource()
// .setNumDrawPrecipPoly(0);
// TODO: Figure out what to do
// Remove the polygon file since all polygons were deleted
PrecipPolyUtils.writePolygons();
dataMgr.setPolygonList(null);
applyPolygonList();
}
/**
@ -386,28 +371,19 @@ public class DeletePolygonDlg extends CaveSWTDialog {
* The polygon to display/undisplay
*/
private void display(boolean display, int polygon) {
PolygonDataManager dataMgr = PolygonDataManager.getInstance();
if (polygon != -1) {
dataMgr.getPolygonList().get(polygon).setVisible(display);
populateDlg();
if (polygon >= 0 && polygon < polygonList.size()) {
RubberPolyData data = polygonList.get(polygon);
data.setVisible(display);
applyPolygonList();
}
applyPolygons();
}
/**
* Apply all of the RubberPolyData modifications to the data
*/
private void applyPolygons() {
PolygonDataManager dataMgr = PolygonDataManager.getInstance();
XmrgResource xmrgRsc = (XmrgResource) MPEDisplayManager.getCurrent()
.getDisplayedResource();
xmrgRsc.updateXmrg(true);
for (RubberPolyData polyData : dataMgr.getPolygonList()) {
PrecipPolyUtils.writeDrawPrecipData(polyData, false);
}
xmrgRsc.updateXmrg(false);
xmrgRsc.issueRefresh();
private void applyPolygonList() {
MPEDisplayManager displayManager = MPEDisplayManager.getCurrent();
DisplayFieldData fieldData = displayManager.getDisplayFieldType();
Date editDate = displayManager.getCurrentEditDate();
PolygonEditManager.writePolygonEdits(fieldData, editDate, polygonList);
recreatePolygonListBox();
}
}

View file

@ -20,6 +20,7 @@
package com.raytheon.viz.mpe.ui.dialogs.polygon;
import java.awt.Point;
import java.util.Date;
import java.util.List;
import org.eclipse.swt.SWT;
@ -40,6 +41,7 @@ import org.eclipse.swt.widgets.Spinner;
import com.raytheon.viz.mpe.ui.DisplayFieldData;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.dialogs.polygon.RubberPolyData.PolygonEditAction;
import com.raytheon.viz.mpe.ui.rsc.MPEPolygonResource;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
@ -69,11 +71,6 @@ public class DrawPolygonDlg extends CaveSWTDialog {
private static final String MAKE_PERSISTENT = "Make Persistent";
/**
* The operation buttons
*/
private Button setBtn, raiseBtn, lowerBtn, scaleBtn, snowBtn, subBtn;
/**
* Bold Font.
*/
@ -193,14 +190,15 @@ public class DrawPolygonDlg extends CaveSWTDialog {
getSubChecks(subGroup);
// Create Substitute button
subBtn = new Button(subGroup, SWT.PUSH);
final Button subBtn = new Button(subGroup, SWT.PUSH);
subBtn.setData(PolygonEditAction.SUB);
gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false, 2, 1);
subBtn.setText("Substitute");
subBtn.setLayoutData(gd);
subBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
processDrawPrecipValue(event.getSource());
processDrawPrecipValue(subBtn);
}
});
}
@ -286,60 +284,23 @@ public class DrawPolygonDlg extends CaveSWTDialog {
Composite comp = new Composite(groupComp, SWT.NONE);
comp.setLayout(new GridLayout(5, false));
GridData gd = new GridData(60, SWT.DEFAULT);
setBtn = new Button(comp, SWT.PUSH);
setBtn.setText("Set");
setBtn.setLayoutData(gd);
setBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
processDrawPrecipValue(event.getSource());
}
});
PolygonEditAction[] editBtns = new PolygonEditAction[] {
PolygonEditAction.SET, PolygonEditAction.RAISE,
PolygonEditAction.LOWER, PolygonEditAction.SCALE,
PolygonEditAction.SNOW };
gd = new GridData(60, SWT.DEFAULT);
raiseBtn = new Button(comp, SWT.PUSH);
raiseBtn.setText("Raise");
raiseBtn.setLayoutData(gd);
raiseBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
processDrawPrecipValue(event.getSource());
}
});
gd = new GridData(60, SWT.DEFAULT);
lowerBtn = new Button(comp, SWT.PUSH);
lowerBtn.setText("Lower");
lowerBtn.setLayoutData(gd);
lowerBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
processDrawPrecipValue(event.getSource());
}
});
gd = new GridData(60, SWT.DEFAULT);
scaleBtn = new Button(comp, SWT.PUSH);
scaleBtn.setText("Scale");
scaleBtn.setLayoutData(gd);
scaleBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
processDrawPrecipValue(event.getSource());
}
});
gd = new GridData(60, SWT.DEFAULT);
snowBtn = new Button(comp, SWT.PUSH);
snowBtn.setText("Snow");
snowBtn.setLayoutData(gd);
snowBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
processDrawPrecipValue(event.getSource());
}
});
for (PolygonEditAction action : editBtns) {
Button editBtn = new Button(comp, SWT.PUSH);
editBtn.setText(action.toPrettyName());
editBtn.setData(action);
editBtn.setLayoutData(new GridData(60, SWT.DEFAULT));
editBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
processDrawPrecipValue((Button) event.getSource());
}
});
}
}
/**
@ -747,54 +708,39 @@ public class DrawPolygonDlg extends CaveSWTDialog {
* @param btnSource
* Source object
*/
private void processDrawPrecipValue(Object btnSource) {
RubberPolyData polyData = new RubberPolyData();
private void processDrawPrecipValue(Button editBtn) {
MPEDisplayManager dispMgr = MPEDisplayManager.getInstance(resource
.getDescriptor().getRenderableDisplay());
if (dispMgr != null) {
polyData.setDrawSource(dispMgr.getDisplayFieldType());
}
for (Point p : points) {
polyData.addHrapPoint(p);
}
/* Read the value on the slider bar. */
polyData.setPrecipValue(precipSpinner.getSelection());
polyData.setPersistent(persistentChk.getSelection());
/*
* Based on the source of this event, set the polygon action.
*/
if (btnSource == snowBtn) {
polyData.setSnow_flag(true);
} else if (btnSource == setBtn) {
polyData.setSet_flag(true);
} else if (btnSource == raiseBtn) {
polyData.setRaise_flag(true);
} else if (btnSource == lowerBtn) {
polyData.setLower_flag(true);
} else if (btnSource == scaleBtn) {
polyData.setScale_flag(true);
} else if (btnSource == subBtn) {
polyData.setSub_flag(true);
if (subType != null) {
polyData.setSubDrawSource(subType);
}
}
Cursor prevCursor = shell.getCursor();
/* Apply the polygon and save it to the Polygon file. */
shell.setCursor(waitCursor);
try {
/* Apply the polygon and save it to the Polygon file. */
shell.setCursor(waitCursor);
PolygonDataManager.getInstance().addPolygon(polyData);
PrecipPolyUtils.writeDrawPrecipData(polyData, true);
MPEDisplayManager.getCurrent().setDataSaved(false);
shell.setCursor(prevCursor);
// Divide precipSpinner selection by 100 since we have 2 decimal
// digits when created. This give actual precip value
double precipValue = precipSpinner.getSelection() / 100.0;
Point[] editPoints = points.toArray(new Point[0]);
PolygonEditAction action = (PolygonEditAction) editBtn.getData();
boolean persistent = persistentChk.getSelection();
DisplayFieldData subType = null;
if (action == PolygonEditAction.SUB) {
subType = this.subType;
}
resource.clearPolygons();
resource.issueRefresh();
DisplayFieldData displayedField = dispMgr.getDisplayFieldType();
Date editDate = dispMgr.getCurrentEditDate();
RubberPolyData newEdit = new RubberPolyData(action, subType,
precipValue, editPoints, true, persistent);
List<RubberPolyData> polygonEdits = PolygonEditManager
.getPolygonEdits(displayedField, editDate);
polygonEdits.add(newEdit);
PolygonEditManager.writePolygonEdits(displayedField, editDate,
polygonEdits);
} finally {
shell.setCursor(prevCursor);
}
}
/**

View file

@ -0,0 +1,49 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.mpe.ui.dialogs.polygon;
import java.util.Date;
import java.util.List;
import com.raytheon.viz.mpe.ui.DisplayFieldData;
/**
* Listener interface for changes to polygon edit changes made
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 2, 2013 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public interface IPolygonEditsChangedListener {
public void polygonEditsChanged(DisplayFieldData field, Date date,
List<RubberPolyData> polygonEdits);
}

View file

@ -1,179 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.mpe.ui.dialogs.polygon;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.raytheon.viz.mpe.MPEConstants;
import com.raytheon.viz.mpe.ui.DisplayFieldData;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
/**
* Holds the polygon data. TODO: Look into notifying listeners when new one
* added. Find out if we need to store time for edit (Figure out how
* DeletePolygonDlg gets the RubberPolyData)
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 10, 2009 2685 mpduff Initial creation
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
public class PolygonDataManager {
/** Instance of this class. */
private static PolygonDataManager instance = null;
/** List of polygon data objects. */
private List<RubberPolyData> polygonList = null;
/** Private constructor. */
private PolygonDataManager() {
}
/**
* Returns the instance of this class.
*
* @return instance The instance of this class
*/
public final synchronized static PolygonDataManager getInstance() {
if (instance == null) {
instance = new PolygonDataManager();
}
return instance;
}
/**
* Add a polygon to the list.
*
* @param data
* RubberPolyData object to add to the list
*/
public void addPolygon(RubberPolyData data) {
if (polygonList == null) {
polygonList = new ArrayList<RubberPolyData>();
}
polygonList.add(data);
}
/**
* Get the list of polygons.
*
* @param fieldData
* The DisplayFieldData type
* @param date
* The date and hour of the data
* @return List<RubberPolyData> The list of polygons
*/
public List<RubberPolyData> getPolygons(DisplayFieldData fieldData,
Date date) {
MPEDisplayManager dispMgr = MPEDisplayManager.getCurrent();
PolygonDataManager polyManager = PolygonDataManager.getInstance();
List<RubberPolyData> dataList = polyManager.getPolygonList();
String polygonDir = PrecipPolyUtils.getPolygonDir();
/* Get the fieldname corresponding to the field. */
String fieldname = dispMgr.getDisplayFieldType().getCv_use();
/* Build the polygon filename. */
String filename = String.format("%s/DrawPoly%s%sz", polygonDir,
fieldname, MPEConstants.DATE_FORMAT.format(date));
/* Build the persistent polygon filename. */
String persistentFilename = String.format("%s/DrawPoly%s", polygonDir,
fieldname);
/* Check to see if the hourly polygon file exists. */
File hourlyFile = new File(filename);
dataList.clear();
if (hourlyFile.exists()) {
dataList = PrecipPolyUtils.readPolyData(hourlyFile, dataList,
fieldData, false);
}
/* Check to see if the persistent polygon file exists. */
File persistentFile = new File(persistentFilename);
if (persistentFile.exists()) {
dataList = PrecipPolyUtils.readPolyData(persistentFile, dataList,
fieldData, true);
}
/*
* If the user has specified any polygon order preferences, reorder the
* list to reflect these preferences.
*/
if (dataList.size() > 0) {
dataList = PrecipPolyUtils.orderPolygons(dataList);
}
/*
* Set the polygons so that they are numbered sequentially from 1 to N,
* where N is the number of polygons in the linked list.
*/
for (int i = 0; i < dataList.size(); i++) {
dataList.get(i).setPolygonNumber(i + 1);
PrecipPolyUtils.writeDrawPrecipData(dataList.get(i), false);
}
return dataList;
}
/**
* @return the polygonList
*/
public List<RubberPolyData> getPolygonList() {
if (polygonList == null) {
polygonList = new ArrayList<RubberPolyData>();
}
return polygonList;
}
/**
* @param polygonList
* the polygonList to set
*/
public void setPolygonList(List<RubberPolyData> polygonList) {
this.polygonList = polygonList;
}
/**
* Get the last polygon in the list.
*
* @return the last polygon in the list
*/
public RubberPolyData getLastPolygon() {
return polygonList.get(polygonList.size() - 1);
}
}

View file

@ -0,0 +1,378 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.mpe.ui.dialogs.polygon;
import java.awt.Point;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.raytheon.uf.common.ohd.AppsDefaults;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.viz.mpe.MPEDateFormatter;
import com.raytheon.viz.mpe.ui.Activator;
import com.raytheon.viz.mpe.ui.DisplayFieldData;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.dialogs.polygon.RubberPolyData.PolygonEditAction;
/**
*
* Utility functions for retrieving, applying, and saving polygone edits
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 3, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class PolygonEditManager {
/**
* Comparator class that looks at mpe_polygon_action_order for ordering
* preferences
*/
private static class ActionOrderingComparator implements
Comparator<RubberPolyData> {
private static List<PolygonEditAction> actionPrecedence = new ArrayList<PolygonEditAction>();
static {
String none = "None";
String actionOrder = AppsDefaults.getInstance().getToken(
"mpe_polygon_action_order", none);
if (actionOrder != null
&& actionOrder.equalsIgnoreCase(none) == false) {
String[] actions = actionOrder.split("[,]");
for (String action : actions) {
try {
actionPrecedence.add(PolygonEditAction.valueOf(action));
} catch (Throwable t) {
// Ignore, bad action in file
}
}
}
}
@Override
public int compare(RubberPolyData o1, RubberPolyData o2) {
return actionPrecedence.indexOf(o1.getEditAction())
- actionPrecedence.indexOf(o2.getEditAction());
}
}
/**
* Comparator class that looks at mpe_polygon_field_order for substitution
* ordering preferences
*/
private static class SubOrderingComparator implements
Comparator<RubberPolyData> {
private static Map<DisplayFieldData, Integer> subPrecedence = new HashMap<DisplayFieldData, Integer>();
static {
String none = "None";
String fieldOrder = AppsDefaults.getInstance().getToken(
"mpe_polygon_field_order", none);
if (fieldOrder != null
&& fieldOrder.equalsIgnoreCase(none) == false) {
int order = 0;
String[] fields = fieldOrder.split("[,]");
for (String field : fields) {
DisplayFieldData fieldData = DisplayFieldData
.fromString(field);
if (fieldData != null) {
subPrecedence.put(fieldData, order);
order += 1;
}
}
}
}
@Override
public int compare(RubberPolyData o1, RubberPolyData o2) {
Integer subPrecedence1 = subPrecedence.get(o1.getSubDrawSource());
if (subPrecedence1 == null) {
subPrecedence1 = -1;
}
Integer subPrecedence2 = subPrecedence.get(o2.getSubDrawSource());
if (subPrecedence2 == null) {
subPrecedence2 = -1;
}
return subPrecedence1 - subPrecedence2;
}
}
/**
* This value is used as a multiplier in the file since the values before
* this class existed were multiplied by this value due to incorrect
* descaling in the UI class. It is expected that values in the
* {@link RubberPolyData} are now actually set to precip values and not
* scaled by 100*precipValue like before
*/
private static final double BACKWARDS_COMPATIBILITY_VALUE = 100.0;
private final static Set<IPolygonEditsChangedListener> listeners = new LinkedHashSet<IPolygonEditsChangedListener>();
public static void registerListener(IPolygonEditsChangedListener listener) {
synchronized (listeners) {
listeners.add(listener);
}
}
public static void unregisterListener(IPolygonEditsChangedListener listener) {
synchronized (listeners) {
listeners.remove(listener);
}
}
/**
* Reads persisted polygon edit objects for the fieldData for the specified
* date
*
* @param fieldData
* @param date
* @return
*/
public static List<RubberPolyData> getPolygonEdits(
DisplayFieldData fieldData, Date date) {
List<RubberPolyData> polygonEdits = new ArrayList<RubberPolyData>();
/* Check to see if the hourly polygon file exists. */
File hourlyFile = getHourlyEditFile(fieldData, date);
if (hourlyFile.exists()) {
polygonEdits.addAll(readPolygonEdits(hourlyFile, false));
}
/* Check to see if the persistent polygon file exists. */
File persistentFile = getPersistentEditFile(fieldData, date);
if (persistentFile.exists()) {
polygonEdits.addAll(readPolygonEdits(persistentFile, true));
}
orderPolygonEdits(polygonEdits);
return polygonEdits;
}
/**
* Sorts the polygon edits based on action and substitution preferences
*
* @param polygonEdits
*/
private static void orderPolygonEdits(List<RubberPolyData> polygonEdits) {
Collections.sort(polygonEdits, new ActionOrderingComparator());
Collections.sort(polygonEdits, new SubOrderingComparator());
}
public static void writePolygonEdits(DisplayFieldData fieldData, Date date,
List<RubberPolyData> polygonEdits) {
orderPolygonEdits(polygonEdits);
File hourlyFile = getHourlyEditFile(fieldData, date);
StringBuilder hourlyBuffer = new StringBuilder();
File persistentFile = getPersistentEditFile(fieldData, date);
StringBuilder persistentBuffer = new StringBuilder();
if (polygonEdits.size() > 0) {
int persistOrder = 0;
int hourlyOrder = 0;
for (RubberPolyData polyEdit : polygonEdits) {
StringBuilder toUse = null;
int idx = 0;
if (polyEdit.isPersistent()) {
persistOrder++;
toUse = persistentBuffer;
idx = persistOrder;
} else {
hourlyOrder++;
toUse = hourlyBuffer;
idx = hourlyOrder;
}
PolygonEditAction editAction = polyEdit.getEditAction();
DisplayFieldData subDrawSource = polyEdit.getSubDrawSource();
double precipValue = polyEdit.getPrecipValue()
* BACKWARDS_COMPATIBILITY_VALUE;
Point[] editPoints = polyEdit.getEditPoints();
boolean visible = polyEdit.isVisible();
String polyEditStr = editAction
+ " "
+ (subDrawSource != null ? subDrawSource.getCv_use()
: String.format("%6.2f", precipValue)) + " "
+ editPoints.length + " " + (visible ? "1" : "0");
toUse.append(idx + " " + polyEditStr + "\n");
for (Point p : editPoints) {
toUse.append(p.x + " " + p.y + "\n");
}
}
}
// Write persistent file
if (persistentFile.exists()) {
persistentFile.delete();
}
if (persistentBuffer.length() > 0) {
try {
BufferedWriter out = new BufferedWriter(new FileWriter(
persistentFile));
out.write(persistentBuffer.toString());
out.close();
} catch (IOException e) {
Activator.statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
}
// Write hourly file
if (hourlyFile.exists()) {
hourlyFile.delete();
}
if (hourlyBuffer.length() > 0) {
try {
BufferedWriter out = new BufferedWriter(new FileWriter(
hourlyFile));
out.write(hourlyBuffer.toString());
out.close();
} catch (IOException e) {
Activator.statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
}
// Notify listeners of the polygon edit changes
Collection<IPolygonEditsChangedListener> toNotify;
synchronized (listeners) {
toNotify = new LinkedHashSet<IPolygonEditsChangedListener>(
listeners);
}
for (IPolygonEditsChangedListener listener : toNotify) {
listener.polygonEditsChanged(fieldData, date,
new ArrayList<RubberPolyData>(polygonEdits));
}
}
private static File getHourlyEditFile(DisplayFieldData fieldData, Date date) {
String fieldname = fieldData.getCv_use();
String polygonDir = MPEDisplayManager.getPolygonEditDir();
/* Build the polygon filename. */
String filename = String.format("%s/DrawPoly%s%sz", polygonDir,
fieldname, MPEDateFormatter.format_yyyyMMddHH(date));
return new File(filename);
}
private static File getPersistentEditFile(DisplayFieldData fieldData,
Date date) {
String fieldname = fieldData.getCv_use();
String polygonDir = MPEDisplayManager.getPolygonEditDir();
/* Build the persistent polygon filename. */
String persistentFilename = String.format("%s/DrawPoly%s", polygonDir,
fieldname);
return new File(persistentFilename);
}
/**
* @param polygonEditFile
* @return
*/
private static List<RubberPolyData> readPolygonEdits(File polygonEditFile,
boolean persistent) {
List<RubberPolyData> polygonEdits = new ArrayList<RubberPolyData>();
String delimeter = "\\s+";
try {
BufferedReader in = new BufferedReader(new FileReader(
polygonEditFile));
String line = null;
while ((line = in.readLine()) != null) {
String[] pieces = line.trim().split(delimeter);
if (pieces.length == 5) {
// Create new poly data and set current data
PolygonEditAction editAction = PolygonEditAction
.valueOf(pieces[1].toUpperCase());
int numPoints = Integer.parseInt(pieces[3]);
Point[] editPoints = new Point[numPoints];
for (int i = 0; i < numPoints; ++i) {
String pointLine = in.readLine();
String[] xy = pointLine.trim().split(delimeter);
if (xy.length == 2) {
// Add point to polygonEditPoints
int hrapx = Integer.parseInt(xy[0]);
int hrapy = Integer.parseInt(xy[1]);
editPoints[i] = new Point(hrapx, hrapy);
}
}
boolean visible = (pieces[4].equals("0") == false);
if (editAction == PolygonEditAction.SUB) {
String subCvUse = pieces[2];
DisplayFieldData subData = null;
for (DisplayFieldData fieldData : DisplayFieldData
.values()) {
if (fieldData.getCv_use()
.equalsIgnoreCase(subCvUse)) {
subData = fieldData;
break;
}
}
polygonEdits.add(new RubberPolyData(editAction,
subData, -999.0, editPoints, visible,
persistent));
} else {
double precipValue = Double.parseDouble(pieces[2])
/ BACKWARDS_COMPATIBILITY_VALUE;
polygonEdits.add(new RubberPolyData(editAction, null,
precipValue, editPoints, visible, persistent));
}
}
}
in.close();
} catch (IOException e) {
Activator.statusHandler.handle(Priority.PROBLEM,
"Error polygon edits from " + polygonEditFile, e);
}
return polygonEdits;
}
}

View file

@ -1,791 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.mpe.ui.dialogs.polygon;
import java.awt.Point;
import java.awt.Rectangle;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import javax.measure.converter.UnitConverter;
import javax.measure.unit.NonSI;
import javax.measure.unit.SI;
import com.raytheon.uf.common.hydro.spatial.HRAPCoordinates;
import com.raytheon.uf.common.mpe.util.XmrgFile;
import com.raytheon.uf.common.ohd.AppsDefaults;
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.util.FileUtil;
import com.raytheon.viz.mpe.MPEConstants;
import com.raytheon.viz.mpe.ui.DisplayFieldData;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.rsc.XmrgResource;
/**
* Utility class for Precipitation Polygons.
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 7, 2009 2685 mpduff Initial creation
* Aug 21, 2009 2685 mpduff Fixed problem with Scale option
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
public class PrecipPolyUtils {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(PrecipPolyUtils.class);
private static final String POLY_DIR_TOKEN = "rfcwide_drawpre_dir";
private static final String ACTION_TOKEN = "mpe_polygon_action_order";
private static final int REGION_SCALE_FACTOR = 10;
private static final String valueFormat = "%6.2f";
private static final String[] ACTION_NAMES = { "Sub", "Set", "Snow",
"Raise", "Lower", "Scale" };
private static final UnitConverter converter = NonSI.INCH
.getConverterTo(SI.MILLIMETER);
private static String polygonDir = null;
/**
* Specifies the precedence of the actions that can be performed on a
* polygon. The -1 is a sentinel that indicates that no precedence was
* specified for the given action.
*/
private static Map<String, Integer> actionPrecedenceMap;
/**
* Contains the draw precedence of each field that can be substituted in a
* polygon. The -1 is a sentinel that indicates that no precedence was
* specified for the given field.
*/
private static List<String> subPrecedence;
/** First time through? */
private static boolean first = true;
/** Action order */
private static int actionOrder = 0;
/** Substitution order */
private static int subOrder = 0;
/**
* Write polygon info from draw precip mode into file.
*
* @param data
* The polygon data
*/
public static synchronized void writeDrawPrecipData(RubberPolyData data,
boolean write) {
MPEDisplayManager dispMgr = MPEDisplayManager.getCurrent();
XmrgResource xmrgRsc = (XmrgResource) dispMgr.getDisplayedResource();
short[] xmrgData = xmrgRsc.getData();
if (xmrgData != null) {
/* Apply the polygon to the MPE product here. */
if (data.isVisible()
&& (data.isSub_flag() || data.isSet_flag()
|| data.isLower_flag() || data.isRaise_flag()
|| data.isScale_flag() || data.isSnow_flag())) {
xmrgData = applyEditPolygon(data, xmrgData);
}
/* write polygon info to DrawPrecip file */
/* polygon points are stored in HRAP coord */
if (write) {
writePolygons();
}
xmrgRsc.setData(xmrgData);
xmrgRsc.updateXmrg(false);
}
}
/**
* When an MPE product is loaded, this routine determines if there are
* Polygons which must be loaded onto the field. If there are, then it loads
* the polygons in order of their polygon number in the polygon file.
*
* @param polyData
* @param xmrgData
* @return
*/
public static synchronized short[] applyEditPolygon(
RubberPolyData polyData, short[] xmrgData) {
short[] tempData = null;
float precipVal;
// Get the substitute type if needed
try {
if (polyData.getAction().equalsIgnoreCase("Sub")) {
tempData = getXmrgData(polyData.getSubDrawSource());
}
} catch (IOException ioe) {
ioe.printStackTrace();
}
/*
* determine HRAP coordinates bounded by polygon update field array
*/
precipVal = (float) polyData.getPrecipValue();
List<Point> hrapList = polyData.getHrap();
Rectangle extent = null;
try {
extent = HRAPCoordinates.getHRAPCoordinates();
} catch (Exception e) {
e.printStackTrace();
}
for (Point p : hrapList) {
int x = p.x - extent.x;
int y = extent.y + extent.height - 1 - p.y;
int idx = y * extent.width + x;
if ((x >= 0) && (x < extent.width) && (y >= 0)
&& (y < extent.height)) {
switch (polyData.getDrawSource()) {
case avgrMosaic:
case bMosaic:
case gageOnly:
case lMosaic:
case lqmosaic:
case lsatPre:
case maxrMosaic:
case mlMosaic:
case mlqmosaic:
case mMosaic:
case p3lMosaic:
case qmosaic:
case rfcbMosaic:
case rfcmMosaic:
case rfcMosaic:
case Xmrg:
case rMosaic:
case satPre:
case sgMosaic:
case srgMosaic:
case srMosaic:
case subValue:
if (tempData != null) {
xmrgData[idx] = tempData[idx];
} else {
/*
* Updated to make the converter a double. The check for
* < 50 is used if the precipVal is 1 When the precipVal
* is 1 (actually 0.01 but not divided by 100 since it
* is stored a short) the converted value end up being
* 25.4 25.4 gets rounded down to 25 and the loss of
* precision causes the value of "0.01" to be colored as
* 0.00.
*/
double converted = converter.convert((precipVal));
if (converted < 50) {
converted = Math.ceil(converted);
}
if (polyData.isRaise_flag()) {
xmrgData[idx] = (short) Math.max(converted,
xmrgData[idx]);
} else if (polyData.isLower_flag()) {
xmrgData[idx] = (short) Math.min(converted,
xmrgData[idx]);
} else if (polyData.isScale_flag()) {
xmrgData[idx] *= (precipVal / 100.0);
} else if (polyData.isSnow_flag()) {
if (xmrgData[idx] < converted) {
xmrgData[idx] = -9999;
}
} else if (polyData.isSet_flag()) {
xmrgData[idx] = (short) converted;
}
}
break;
default:
}
}
}
return xmrgData;
}
/**
* Get the polygon file's directory.
*
* @return The directory containing the polygon files
*/
public static String getPolygonDir() {
if (polygonDir == null) {
AppsDefaults appsDefaults = AppsDefaults.getInstance();
polygonDir = appsDefaults.getToken(POLY_DIR_TOKEN);
}
return polygonDir;
}
/**
* Read the poly data from the polygon file.
*
* @param file
* The polygon file
* @param persistent
* true if persistent file
*/
public static List<RubberPolyData> readPolyData(File file,
List<RubberPolyData> polygonList, DisplayFieldData fieldData,
boolean persistent) {
RubberPolyData polyNode = new RubberPolyData();
try {
BufferedReader in = new BufferedReader(new FileReader(file));
String str;
int numberPoints = 0;
boolean firstRecord = true;
while ((str = in.readLine()) != null) {
String[] pieces = str.trim().split("\\s+");
// Add the previous data set
if (pieces.length == 5) {
if (!firstRecord) {
polygonList.add(polyNode);
polyNode = new RubberPolyData();
}
firstRecord = false;
/*
* Copy the header information to the rubber_poly_data
* structure.
*/
numberPoints = Integer.parseInt(pieces[3]);
polyNode.setPolygonNumber(Integer.parseInt(pieces[0]));
polyNode.setNumberPoints(numberPoints);
if (!pieces[1].equalsIgnoreCase(ACTION_NAMES[0])) {
polyNode.setPrecipValue(Float.parseFloat(pieces[2]));
}
polyNode.setDrawSource(DisplayFieldData.subValue);
for (int i = 0; i < ACTION_NAMES.length; i++) {
if (pieces[1].equalsIgnoreCase(ACTION_NAMES[0])) { // Sub
polyNode.setSub_flag(true);
// loop through and find the right displayFieldData
DisplayFieldData[] dataTypes = DisplayFieldData
.values();
for (int j = 0; j < dataTypes.length; j++) {
if (dataTypes[j].getCv_use().equalsIgnoreCase(
pieces[2])) {
polyNode.setSubDrawSource(dataTypes[j]);
break;
}
}
break;
} else if (pieces[1].equalsIgnoreCase(ACTION_NAMES[1])) { // Set
polyNode.setSet_flag(true);
polyNode.setDrawSource(fieldData);
break;
} else if (pieces[1].equalsIgnoreCase(ACTION_NAMES[2])) { // Snow
polyNode.setSnow_flag(true);
polyNode.setDrawSource(fieldData);
break;
} else if (pieces[1].equalsIgnoreCase(ACTION_NAMES[3])) { // Raise
polyNode.setRaise_flag(true);
polyNode.setDrawSource(fieldData);
break;
} else if (pieces[1].equalsIgnoreCase(ACTION_NAMES[4])) { // Lower
polyNode.setLower_flag(true);
polyNode.setDrawSource(fieldData);
break;
} else if (pieces[1].equalsIgnoreCase(ACTION_NAMES[5])) { // Scale
polyNode.setScale_flag(true);
polyNode.setDrawSource(fieldData);
break;
}
}
if (pieces[4].equalsIgnoreCase("0")) {
polyNode.setVisible(false);
} else {
polyNode.setVisible(true);
}
polyNode.setPersistent(persistent);
} else if (pieces.length == 2) {
// Reading in polygon vertices
int hrapx = Integer.parseInt(pieces[0]);
int hrapy = Integer.parseInt(pieces[1]);
Point p = new Point(hrapx, hrapy);
polyNode.addHrapPoint(p);
if (p.x < polyNode.getMinx()) {
polyNode.setMinx(p.x);
}
if (p.y < polyNode.getMiny()) {
polyNode.setMiny(p.y);
}
if (p.x > polyNode.getMaxx()) {
polyNode.setMaxx(p.x);
}
if (p.y > polyNode.getMaxy()) {
polyNode.setMaxy(p.y);
}
}
}
// Add the last data set
polygonList.add(polyNode);
in.close();
} catch (IOException e) {
e.printStackTrace();
}
return polygonList;
}
/**
* Order the polygons.
*
* @param dataList
* The list of polygons
* @return The ordered list of polygons
*/
public static List<RubberPolyData> orderPolygons(
List<RubberPolyData> dataList) {
int nodeNumber;
int action;
List<RubberPolyData> orderedList = new ArrayList<RubberPolyData>();
RubberPolyData pNode = null;
RubberPolyData pNodeN = null;
if (first) {
first = false;
actionOrder = initActionOrder();
subOrder = initSubstituteOrder();
}
if ((actionOrder == 1) || (subOrder == 1)) {
/* Polygon precedence does matter ... */
if (actionOrder == 1) {
/* Some action ordering exists. */
nodeNumber = 1;
for (int i = 0; i < ACTION_NAMES.length; i++) {
action = actionPrecedenceMap.get(ACTION_NAMES[i]);
if (action == -1) {
break;
}
/* Walk through the polygon list looking for this element */
for (int j = 0; j < dataList.size(); j++) {
pNode = dataList.get(j);
if (ACTION_NAMES[action].equalsIgnoreCase("Sub")) {
if (pNode.isSub_flag()) {
pNodeN = dataList.get(nodeNumber);
if (pNodeN != pNode) {
orderedList.add(pNodeN);
} else {
orderedList.add(pNode);
}
nodeNumber++;
}
} else if (ACTION_NAMES[action].equalsIgnoreCase("Set")) {
if (pNode.isSet_flag()) {
pNodeN = dataList.get(nodeNumber);
if (pNodeN != pNode) {
orderedList.add(pNodeN);
} else {
orderedList.add(pNode);
}
nodeNumber++;
}
} else if (ACTION_NAMES[action]
.equalsIgnoreCase("Snow")) {
if (pNode.isSnow_flag()) {
pNodeN = dataList.get(nodeNumber);
if (pNodeN != pNode) {
orderedList.add(pNodeN);
} else {
orderedList.add(pNode);
}
nodeNumber++;
}
} else if (ACTION_NAMES[action]
.equalsIgnoreCase("Raise")) {
if (pNode.isRaise_flag()) {
pNodeN = dataList.get(nodeNumber);
if (pNodeN != pNode) {
orderedList.add(pNodeN);
} else {
orderedList.add(pNode);
}
nodeNumber++;
}
} else if (ACTION_NAMES[action]
.equalsIgnoreCase("Lower")) {
if (pNode.isLower_flag()) {
pNodeN = dataList.get(nodeNumber);
if (pNodeN != pNode) {
orderedList.add(pNodeN);
} else {
orderedList.add(pNode);
}
nodeNumber++;
}
} else if (ACTION_NAMES[action]
.equalsIgnoreCase("Scale")) {
if (pNode.isScale_flag()) {
pNodeN = dataList.get(nodeNumber);
if (pNodeN != pNode) {
orderedList.add(pNodeN);
} else {
orderedList.add(pNode);
}
nodeNumber++;
}
} else {
// TODO log this message
// Unrecognized action %d in order "
// "polygons.\n", action
}
}
}
dataList = orderedList;
}
/* Action ordering complete. */
List<RubberPolyData> subOrderedList = new ArrayList<RubberPolyData>();
if (subOrder == 1) {
int listSize = dataList.size();
for (int i = 0; i < subPrecedence.size(); i++) {
for (int j = 0; j < listSize; j++) {
RubberPolyData node = dataList.get(j);
if (node.getDrawSource().getCv_use()
.equalsIgnoreCase(subPrecedence.get(i))) {
subOrderedList.add(node);
}
}
}
dataList = subOrderedList;
}
}
return dataList;
}
/**
* Initialize the action order.
*
* @return
*/
private static int initActionOrder() {
AppsDefaults appsDefaults = AppsDefaults.getInstance();
int order = 0;
int status = 0;
actionPrecedenceMap = new HashMap<String, Integer>();
for (int i = 0; i < ACTION_NAMES.length; i++) {
actionPrecedenceMap.put(ACTION_NAMES[i], -1);
}
String value = appsDefaults.getToken(ACTION_TOKEN);
if (value != null) {
if (!value.equalsIgnoreCase("NONE")) {
StringTokenizer st = new StringTokenizer(value, ",");
DisplayFieldData[] fieldNames = DisplayFieldData.values();
while (st.hasMoreTokens()) {
String token = st.nextToken();
for (int i = 0; i < ACTION_NAMES.length; i++) {
if (token.equalsIgnoreCase(ACTION_NAMES[i])) {
actionPrecedenceMap.put(fieldNames[i].getCv_use(),
order);
order++;
}
}
}
}
}
if (order > 0) {
status = 1;
} else {
status = 0;
}
return status;
}
/**
* Initialize the substitution order.
*
* @return
*/
private static int initSubstituteOrder() {
AppsDefaults appsDefaults = AppsDefaults.getInstance();
int status = 0;
subPrecedence = new ArrayList<String>();
String value = appsDefaults.getToken(ACTION_TOKEN);
if (value != null) {
if (!value.equalsIgnoreCase("NONE")) {
StringTokenizer st = new StringTokenizer(value, ",");
while (st.hasMoreTokens()) {
String token = st.nextToken();
subPrecedence.add(token);
}
}
}
if (subPrecedence.size() > 0) {
status = 1;
} else {
status = 0;
}
return status;
}
/**
* Write the polygon file.
*/
public static void writePolygons() {
StringBuilder hourlyBuffer = new StringBuilder();
StringBuilder persistentBuffer = new StringBuilder();
MPEDisplayManager manager = MPEDisplayManager.getCurrent();
PolygonDataManager polyManager = PolygonDataManager.getInstance();
List<RubberPolyData> polygonList = polyManager.getPolygonList();
String fieldname = manager.getDisplayFieldType().getCv_use()
.toUpperCase();
String persistentFilename = getPolygonDir() + "/DrawPoly" + fieldname;
String hourlyFilename = getPolygonDir() + "/DrawPoly" + fieldname
+ MPEConstants.DATE_FORMAT.format(manager.getCurrentDate())
+ "z";
// If the list is empty then return, nothing to do
if (polygonList.size() > 0) {
int persistOrder = 0;
int hourlyOrder = 0;
int visible = 0;
System.out.println(polygonList.size() + " polygons in the list");
for (RubberPolyData data : polygonList) {
if (data.isPersistent()) {
/* Increment the polygon number and record number. */
persistOrder++;
if (data.isVisible()) {
visible = 1;
} else {
visible = 0;
}
/* Write the header to the file buffer. */
if (data.getAction().equalsIgnoreCase(ACTION_NAMES[0])) {
persistentBuffer
.append(persistOrder + " " + data.getAction()
+ " "
+ data.getSubDrawSource().getCv_use()
+ " " + data.getNumberPoints() + " "
+ visible + "\n");
} else {
persistentBuffer
.append(persistOrder
+ " "
+ data.getAction()
+ " "
+ String.format(valueFormat,
data.getPrecipValue()) + " "
+ data.getNumberPoints() + " "
+ visible + "\n");
}
/* Write the points to the file buffer. */
List<Point> pointList = data.getHrap();
for (int i = 0; i < data.getNpoints(); i++) {
Point p = pointList.get(i);
persistentBuffer.append(p.x + " " + p.y + "\n");
}
} else {
hourlyOrder++;
if (data.isVisible()) {
visible = 1;
} else {
visible = 0;
}
/* Write the header to the file buffer. */
if (data.getAction().equalsIgnoreCase(ACTION_NAMES[0])) {
hourlyBuffer.append(hourlyOrder + " "
+ data.getAction() + " "
+ data.getSubDrawSource().getCv_use() + " "
+ data.getNpoints() + " " + visible + "\n");
} else {
hourlyBuffer.append(hourlyOrder
+ " "
+ data.getAction()
+ " "
+ String.format(valueFormat,
data.getPrecipValue()) + " "
+ data.getNpoints() + " " + visible + "\n");
}
/* Write the points to the file buffer. */
List<Point> pointList = data.getHrap();
for (int i = 0; i < data.getNpoints(); i++) {
Point p = pointList.get(i);
hourlyBuffer.append(p.x + " " + p.y + "\n");
}
}
}
}
// Write the buffers to disk if needed
File file = new File(persistentFilename);
if (persistentBuffer.length() > 0) {
if (file.exists()) {
file.delete();
}
try {
BufferedWriter out = new BufferedWriter(new FileWriter(file));
out.write(persistentBuffer.toString());
out.close();
} catch (IOException e) {
// TODO - Log error message here
e.printStackTrace();
}
} else {
if (file.exists()) {
file.delete();
}
}
file = new File(hourlyFilename);
System.out.println("File = " + file.toString());
if (hourlyBuffer.length() > 0) {
if (file.exists()) {
file.delete();
}
BufferedWriter out;
try {
out = new BufferedWriter(new FileWriter(file));
out.write(hourlyBuffer.toString());
out.flush();
out.close();
} catch (IOException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
} else {
if (file.exists()) {
file.delete();
}
}
}
/**
* Gets the xmrg data from the file.
*
* @param dataType
* DisplayFieldData type
* @return short[][] of data
* @throws IOException
*/
public static short[] getXmrgData(DisplayFieldData dataType)
throws IOException {
String cv_use = dataType.getCv_use();
String fname = "";
if (cv_use.equals("XMRG")) {
cv_use = cv_use.toLowerCase();
}
String dirname = AppsDefaults.getInstance().getToken(
dataType.getDirToken());
if (!cv_use.equals("xmrg")) {
fname = FileUtil.join(
dirname,
cv_use
+ MPEConstants.DATE_FORMAT.format(MPEDisplayManager
.getCurrent().getCurrentDate()) + "z");
} else {
fname = FileUtil.join(
dirname,
cv_use
+ MPEConstants.XMRG_DATE_FORMAT
.format(MPEDisplayManager.getCurrent()
.getCurrentDate()) + "z");
}
XmrgFile file = new XmrgFile(fname);
file.load();
short[] data = file.getData();
return data;
}
}

View file

@ -20,9 +20,6 @@
package com.raytheon.viz.mpe.ui.dialogs.polygon;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
import com.raytheon.viz.mpe.ui.DisplayFieldData;
@ -45,33 +42,29 @@ import com.raytheon.viz.mpe.ui.DisplayFieldData;
*/
public class RubberPolyData {
/** Polygon number */
private int polygonNumber;
public static enum PolygonEditAction {
SUB, SET, SNOW, RAISE, LOWER, SCALE;
/**
* Pretty output name of enum, MUST still match all chars in original
* enum name
*
* @return
*/
public String toPrettyName() {
char[] chars = name().toLowerCase().toCharArray();
chars[0] = Character.toUpperCase(chars[0]);
return new String(chars);
}
}
/** HRAP Points */
private List<Point> hrap = new ArrayList<Point>();
private int isite;
private int xpoly;
private int xpt;
private int close;
private final Point[] editPoints;
private float drawPrecipValue;
private boolean snow_flag;
private boolean set_flag;
private boolean raise_flag;
private boolean lower_flag;
private boolean scale_flag;
private boolean sub_flag;
private PolygonEditAction editAction;
/** Is the polygon visible */
private boolean visible = true;
@ -79,132 +72,36 @@ public class RubberPolyData {
/** Is the polygon persistent */
private boolean persistent;
/** HRAP Extent */
private Rectangle hrapExtent;
/** The precip value */
private double precipValue = -999;
/** Is the polygon closed */
private boolean closed = false;
/** The DisplayFieldData for the display */
private DisplayFieldData drawSource = null;
private double precipValue;
/** The DisplayFieldData for the substituted cells */
private DisplayFieldData subDrawSource = null;
private int numberPoints = 0;
private int minx = 0;
private int maxx = 0;
private int miny = 0;
private int maxy = 0;
/**
* @return the polygonNumber
*/
public int getPolygonNumber() {
return polygonNumber;
public RubberPolyData(PolygonEditAction editAction,
DisplayFieldData subSource, double precipValue, Point[] hrapPoints,
boolean visible, boolean persistent) {
this.editAction = editAction;
this.subDrawSource = subSource;
this.precipValue = precipValue;
this.editPoints = hrapPoints;
this.visible = visible;
}
/**
* @param polygonNumber
* the polygonNumber to set
*/
public void setPolygonNumber(int polygonNumber) {
this.polygonNumber = polygonNumber;
}
/**
* @return the npoints
*/
public int getNpoints() {
return hrap.size();
}
/**
* @return the hrap
*/
public List<Point> getHrap() {
return hrap;
}
/**
* @param hrap
* the hrap to set
*/
public void setHrap(List<Point> hrap) {
this.hrap = hrap;
}
/**
* Add a point to the list.
*
* @param p
* The point to add to the list
* @return
*/
public void addHrapPoint(Point p) {
hrap.add(p);
public PolygonEditAction getEditAction() {
return editAction;
}
/**
* @return the isite
*
* @return
*/
public int getIsite() {
return isite;
}
/**
* @param isite
* the isite to set
*/
public void setIsite(int isite) {
this.isite = isite;
}
/**
* @return the xpoly
*/
public int getXpoly() {
return xpoly;
}
/**
* @param xpoly
* the xpoly to set
*/
public void setXpoly(int xpoly) {
this.xpoly = xpoly;
}
/**
* @return the xpt
*/
public int getXpt() {
return xpt;
}
/**
* @param xpt
* the xpt to set
*/
public void setXpt(int xpt) {
this.xpt = xpt;
}
/**
* @return the close
*/
public int getClose() {
return close;
}
/**
* @param close
* the close to set
*/
public void setClose(int close) {
this.close = close;
public Point[] getEditPoints() {
return editPoints;
}
/**
@ -214,104 +111,6 @@ public class RubberPolyData {
return drawPrecipValue;
}
/**
* @param drawPrecipValue
* the drawPrecipValue to set
*/
public void setDrawPrecipValue(float drawPrecipValue) {
this.drawPrecipValue = drawPrecipValue;
}
/**
* @return the snow_flag
*/
public boolean isSnow_flag() {
return snow_flag;
}
/**
* @param snow_flag
* the snow_flag to set
*/
public void setSnow_flag(boolean snow_flag) {
this.snow_flag = snow_flag;
}
/**
* @return the set_flag
*/
public boolean isSet_flag() {
return set_flag;
}
/**
* @param set_flag
* the set_flag to set
*/
public void setSet_flag(boolean set_flag) {
this.set_flag = set_flag;
}
/**
* @return the raise_flag
*/
public boolean isRaise_flag() {
return raise_flag;
}
/**
* @param raise_flag
* the raise_flag to set
*/
public void setRaise_flag(boolean raise_flag) {
this.raise_flag = raise_flag;
}
/**
* @return the lower_flag
*/
public boolean isLower_flag() {
return lower_flag;
}
/**
* @param lower_flag
* the lower_flag to set
*/
public void setLower_flag(boolean lower_flag) {
this.lower_flag = lower_flag;
}
/**
* @return the scale_flag
*/
public boolean isScale_flag() {
return scale_flag;
}
/**
* @param scale_flag
* the scale_flag to set
*/
public void setScale_flag(boolean scale_flag) {
this.scale_flag = scale_flag;
}
/**
* @return the sub_flag
*/
public boolean isSub_flag() {
return sub_flag;
}
/**
* @param sub_flag
* the sub_flag to set
*/
public void setSub_flag(boolean sub_flag) {
this.sub_flag = sub_flag;
}
/**
* @return the visible
*/
@ -342,21 +141,6 @@ public class RubberPolyData {
this.persistent = persistent;
}
/**
* @return the hrapExtent
*/
public Rectangle getHrapExtent() {
return hrapExtent;
}
/**
* @param hrapExtent
* the hrapExtent to set
*/
public void setHrapExtent(Rectangle hrapExtent) {
this.hrapExtent = hrapExtent;
}
/**
* @return the precipValue
*/
@ -364,111 +148,6 @@ public class RubberPolyData {
return precipValue;
}
/**
* @param precipValue the precipValue to set
*/
public void setPrecipValue(double precipValue) {
this.precipValue = precipValue;
}
/**
* @return the closed
*/
public boolean isClosed() {
return closed;
}
/**
* @param closed the closed to set
*/
public void setClosed(boolean closed) {
this.closed = closed;
}
/**
* @return the numberPoints
*/
public int getNumberPoints() {
return numberPoints;
}
/**
* @param numberPoints the numberPoints to set
*/
public void setNumberPoints(int numberPoints) {
this.numberPoints = numberPoints;
}
/**
* @return the drawSource
*/
public DisplayFieldData getDrawSource() {
return drawSource;
}
/**
* @param drawSource the drawSource to set
*/
public void setDrawSource(DisplayFieldData drawSource) {
this.drawSource = drawSource;
}
/**
* @return the minx
*/
public int getMinx() {
return minx;
}
/**
* @param minx the minx to set
*/
public void setMinx(int minx) {
this.minx = minx;
}
/**
* @return the maxx
*/
public int getMaxx() {
return maxx;
}
/**
* @param maxx the maxx to set
*/
public void setMaxx(int maxx) {
this.maxx = maxx;
}
/**
* @return the miny
*/
public int getMiny() {
return miny;
}
/**
* @param miny the miny to set
*/
public void setMiny(int miny) {
this.miny = miny;
}
/**
* @return the maxy
*/
public int getMaxy() {
return maxy;
}
/**
* @param maxy the maxy to set
*/
public void setMaxy(int maxy) {
this.maxy = maxy;
}
/**
* @return the subDrawSource
*/
@ -476,34 +155,4 @@ public class RubberPolyData {
return subDrawSource;
}
/**
* @param subDrawSource the subDrawSource to set
*/
public void setSubDrawSource(DisplayFieldData subDrawSource) {
this.subDrawSource = subDrawSource;
}
/**
* Return the action.
*
* @return The action
*/
public String getAction() {
String action = null;
if (isLower_flag()) {
action = "Lower";
} else if (isRaise_flag()) {
action = "Raise";
} else if (isScale_flag()) {
action = "Scale";
} else if (isSet_flag()) {
action = "Set";
} else if (isSnow_flag()) {
action = "Snow";
} else if (isSub_flag()){
action = "Sub";
}
return action;
}
}

View file

@ -19,6 +19,7 @@
**/
package com.raytheon.viz.mpe.ui.dialogs.timelapse;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@ -33,7 +34,9 @@ import org.eclipse.swt.widgets.Scale;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Spinner;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.ui.EditorUtil;
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
/**
@ -178,10 +181,17 @@ public class TimeLapseDlg extends CaveSWTDialog {
okBtn.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
int hours = Integer.parseInt(hourSpinner.getText());
MPEDisplayManager man = MPEDisplayManager.getCurrent();
man.setTimeLapseHours(hours);
shell.dispose();
IDisplayPaneContainer container = EditorUtil
.getActiveVizContainer();
if (container != null) {
int hours = Integer.parseInt(hourSpinner.getText());
MPEDisplayManager.startLooping(container, hours);
close();
} else {
MessageDialog.openError(getShell(),
"Could not start time lapse",
"No editor active to start time lapse on");
}
}
});

View file

@ -23,12 +23,16 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.map.MapDescriptor;
import com.raytheon.uf.viz.core.maps.display.MapRenderableDisplay;
import com.raytheon.uf.viz.core.maps.display.PlainMapRenderableDisplay;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.GenericResourceData;
import com.raytheon.uf.viz.core.rsc.ResourceList;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.rsc.AddPseudoGageResource;
import com.raytheon.viz.mpe.ui.rsc.IMpeResource;
import com.raytheon.viz.mpe.ui.rsc.MPEGageResource;
import com.raytheon.viz.mpe.ui.rsc.MPELegendResource;
import com.raytheon.viz.mpe.ui.rsc.MPEPolygonResource;
@ -52,7 +56,7 @@ import com.raytheon.viz.mpe.ui.rsc.MPEPolygonResource;
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement(name = "mpeMapRenderableDisplay")
public class MPEMapRenderableDisplay extends MapRenderableDisplay {
public class MPEMapRenderableDisplay extends PlainMapRenderableDisplay {
public MPEMapRenderableDisplay() {
super();
@ -62,6 +66,33 @@ public class MPEMapRenderableDisplay extends MapRenderableDisplay {
super(desc);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.drawables.AbstractRenderableDisplay#setDescriptor
* (com.raytheon.uf.viz.core.drawables.IDescriptor)
*/
@Override
public void setDescriptor(IDescriptor desc) {
super.setDescriptor(desc);
if (desc.getTimeMatcher() == null) {
desc.setTimeMatcher(new MPETimeMatcher());
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.drawables.AbstractRenderableDisplay#dispose()
*/
@Override
public void dispose() {
super.dispose();
MPEDisplayManager.disposeDisplay(this);
}
@Override
protected void customizeResourceList(ResourceList resourceList) {
super.customizeResourceList(resourceList);
@ -86,4 +117,22 @@ public class MPEMapRenderableDisplay extends MapRenderableDisplay {
MPEGageResource.class)));
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.drawables.AbstractRenderableDisplay#clear(com
* .raytheon.uf.viz.core.IDisplayPane)
*/
@Override
public void clear() {
ResourceList list = descriptor.getResourceList();
for (AbstractVizResource<?, ?> rsc : list
.getResourcesByType(IMpeResource.class)) {
if (rsc.getProperties().isSystemResource() == false) {
list.removeRsc(rsc);
}
}
}
}

View file

@ -0,0 +1,159 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.mpe.ui.displays;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.AbstractTimeMatcher;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.IDescriptor.FramesInfo;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.viz.mpe.core.MPEDataManager;
/**
* MPE time matcher, generates times in hourly increments from
* {@link MPEDataManager}'s latest time to earliest and uses those times for all
* resources
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 10, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class MPETimeMatcher extends AbstractTimeMatcher {
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.AbstractTimeMatcher#redoTimeMatching(com.raytheon
* .uf.viz.core.rsc.AbstractVizResource)
*/
@Override
public void redoTimeMatching(AbstractVizResource<?, ?> resource) {
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.AbstractTimeMatcher#redoTimeMatching(com.raytheon
* .uf.viz.core.drawables.IDescriptor)
*/
@Override
public void redoTimeMatching(IDescriptor descriptor) throws VizException {
MPEDataManager dm = MPEDataManager.getInstance();
// Add all times from MPEDataManager.earliest to latest in hourly
// increments
Date latest = dm.getLatestDate();
Date earliest = dm.getEarliestDate();
Calendar cal = Calendar.getInstance();
cal.setTime(earliest);
List<DataTime> frameTimes = new ArrayList<DataTime>();
Date time = cal.getTime();
do {
frameTimes.add(new DataTime(time));
cal.add(Calendar.HOUR_OF_DAY, 1);
time = cal.getTime();
} while (latest.before(time) == false);
// Get curr info and time
FramesInfo currInfo = descriptor.getFramesInfo();
DataTime currTime = currInfo.getCurrentFrame();
DataTime[] times = frameTimes.toArray(new DataTime[0]);
Map<AbstractVizResource<?, ?>, DataTime[]> rscTimeMap = new HashMap<AbstractVizResource<?, ?>, DataTime[]>();
for (ResourcePair rp : descriptor.getResourceList()) {
if (rp.getResource() != null) {
AbstractVizResource<?, ?> rsc = rp.getResource();
if (rsc.isTimeAgnostic() == false) {
// for now, just put frame times of descriptor in each
// resource, maybe add time availability in MPE
rscTimeMap.put(rsc, Arrays.copyOf(times, times.length));
}
}
}
int newIdx = times.length - 1;
if (currTime != null) {
newIdx = Arrays.binarySearch(times, currTime);
if (newIdx < 0) {
// Fix Arrays.binarySearch returning -insertionIndex-1
newIdx = -newIdx - 1;
}
// Cap index to ensure within bounds of times
if (newIdx < 0) {
newIdx = 0;
} else if (newIdx >= times.length) {
newIdx = times.length - 1;
}
}
descriptor.setFramesInfo(new FramesInfo(times, newIdx, rscTimeMap));
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.AbstractTimeMatcher#handleRemove(com.raytheon
* .uf.viz.core.rsc.AbstractVizResource,
* com.raytheon.uf.viz.core.drawables.IDescriptor)
*/
@Override
public void handleRemove(AbstractVizResource<?, ?> resource,
IDescriptor descriptor) {
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.AbstractTimeMatcher#initialLoad(com.raytheon
* .uf.viz.core.rsc.LoadProperties, com.raytheon.uf.common.time.DataTime[],
* com.raytheon.uf.viz.core.drawables.IDescriptor)
*/
@Override
public DataTime[] initialLoad(LoadProperties loadProps,
DataTime[] availableTimes, IDescriptor descriptor)
throws VizException {
return new DataTime[0];
}
}

View file

@ -28,29 +28,35 @@ import org.eclipse.jface.action.MenuManager;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.contexts.IContextActivation;
import org.eclipse.ui.menus.IMenuService;
import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.PathManagerFactory;
import com.raytheon.uf.common.ohd.AppsDefaults;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.serialization.SerializationUtil;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.DescriptorMap;
import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.uf.viz.core.RGBColors;
import com.raytheon.uf.viz.core.datastructure.LoopProperties;
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.procedures.Bundle;
import com.raytheon.uf.viz.core.rsc.IInputHandler;
import com.raytheon.viz.hydrocommon.actions.SetProjection;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.actions.GroupEditPrecipStns;
import com.raytheon.viz.mpe.ui.actions.GroupEditTempStns;
import com.raytheon.viz.mpe.ui.actions.MPESelectPaneAction;
import com.raytheon.viz.mpe.ui.dialogs.ChooseDataPeriodDialog;
import com.raytheon.viz.mpe.ui.dialogs.EditFreezeStationsDialog;
import com.raytheon.viz.mpe.ui.dialogs.EditPrecipStationsDialog;
import com.raytheon.viz.mpe.ui.dialogs.EditTempStationsDialog;
import com.raytheon.viz.ui.EditorUtil;
import com.raytheon.viz.ui.UiUtil;
import com.raytheon.viz.ui.color.BackgroundColor;
import com.raytheon.viz.ui.editor.AbstractEditor;
import com.raytheon.viz.ui.editor.IMultiPaneEditor;
@ -59,7 +65,7 @@ import com.raytheon.viz.ui.perspectives.AbstractCAVEPerspectiveManager;
import com.vividsolutions.jts.geom.Coordinate;
/**
* TODO Add Description
* Perspective manager for MPE Perspective
*
* <pre>
* SOFTWARE HISTORY
@ -75,18 +81,12 @@ import com.vividsolutions.jts.geom.Coordinate;
*/
public class MPEPerspectiveManager extends AbstractCAVEPerspectiveManager {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(MPEPerspectiveManager.class);
/** The MPE Perspective Class */
public static final String MPE_PERSPECTIVE = MPEPerspective.ID_PERSPECTIVE;
private IContextActivation activation;
private boolean first = false;
private static final String MPE = "mpe";
@Override
public void open() {
// First time opened, set perspective default background color
String cval = AppsDefaults.getInstance().getToken(
"mpe_map_background_color");
if (cval != null) {
@ -95,61 +95,78 @@ public class MPEPerspectiveManager extends AbstractCAVEPerspectiveManager {
BackgroundColor.getInstance(page.getPerspective()).setColor(
BGColorMode.EDITOR, color);
}
loadDefaultBundle("mpe/default-procedure.xml");
first = true;
populate(true);
openNewEditor();
Shell shell = perspectiveWindow.getShell();
ChooseDataPeriodDialog dialog = new ChooseDataPeriodDialog(shell);
dialog.open();
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.ui.perspectives.AbstractVizPerspectiveManager#openNewEditor
* ()
*/
@Override
public void activate() {
if (perspectiveEditors.size() == 0 && opened) {
opened = false;
first = true;
super.activate();
} else if (perspectiveEditors.size() != 0 && opened) {
super.activate();
first = false;
populate(false);
} else {
super.activate();
populate(true);
}
}
@Override
public void close() {
super.close();
depopulate();
}
@Override
public void deactivate() {
super.deactivate();
depopulate();
}
private void populate(boolean pro) {
IDisplayPaneContainer currentEditor = EditorUtil
.getActiveVizContainer();
if (currentEditor != null) {
if (pro == true) {
SetProjection.setDefaultProjection(currentEditor, "mpe");
}
try {
MPEDisplayManager.populate(perspectiveWindow, pro, first);
first = false;
} catch (VizException e) {
statusHandler.handle(Priority.CRITICAL, "Error populating", e);
}
}
}
private void depopulate() {
public AbstractEditor openNewEditor() {
try {
MPEDisplayManager.dePopulate(perspectiveWindow);
} catch (VizException e) {
statusHandler.handle(Priority.CRITICAL, "Error depopulating", e);
// Unmarshal default bundle xml
Object unmarshalled = SerializationUtil.getJaxbManager()
.jaxbUnmarshalFromXmlFile(
PathManagerFactory.getPathManager().getStaticFile(
MPE + IPathManager.SEPARATOR
+ "default-bundle.xml"));
if (unmarshalled instanceof Bundle) {
// Load Bundle to perspective window in new editor
Bundle b = (Bundle) unmarshalled;
String editorId = b.getEditor();
if (editorId != null) {
IRenderableDisplay[] displays = b.getDisplays();
if (displays.length > 0) {
editorId = DescriptorMap.getEditorId(displays[0]
.getDescriptor().getClass().getName());
AbstractEditor editor = UiUtil.createEditor(
perspectiveWindow, editorId, displays);
if (editor != null) {
initialize(editor);
return editor;
} else {
throw new VizException(
"Failed to open new editor on window");
}
} else {
throw new SerializationException(
"No displays to load found in MPE default bundle XML");
}
}
} else {
throw new SerializationException(
"Unexpected type deserialied from mpe bundle file. Expected "
+ Bundle.class.getSimpleName()
+ ", got "
+ (unmarshalled != null ? unmarshalled
.getClass().getSimpleName() : null));
}
} catch (Exception e) {
UFStatus.getHandler().handle(Priority.PROBLEM,
"Error opening new MPE editor: " + e.getLocalizedMessage(),
e);
}
return null;
}
/**
* Initializes a newly created MPE editor
*
* @param editor
* @return
*/
private static void initialize(AbstractEditor editor) {
// Project editor
SetProjection.setDefaultProjection(editor, MPE);
}
@Override
@ -183,15 +200,6 @@ public class MPEPerspectiveManager extends AbstractCAVEPerspectiveManager {
ll));
return true;
}
} else if (MPEDisplayManager.getCurrent().isTimeLapseMode()) {
// Stop the loop where it is
LoopProperties loopProps = container
.getLoopProperties();
if (loopProps != null) {
loopProps.setLooping(false);
}
return true;
}
} else if (mouseButton == 3) {
Coordinate ll = container.translateClick(x, y);

View file

@ -94,7 +94,7 @@ public class ReadBiasTableParam {
/* Build the where clause. */
where = "WHERE radid='" + rid + "' and obstime='"
+ displayManager.getCurrentDate() + "' and office_id = '"
+ displayManager.getCurrentEditDate() + "' and office_id = '"
+ fxa_local_site + "' ORDER BY memspan_ind ";
/*-------------------------------------------------------*/

View file

@ -0,0 +1,323 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.mpe.ui.rsc;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import javax.measure.converter.UnitConverter;
import javax.measure.unit.Unit;
import org.geotools.coverage.grid.GridGeometry2D;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.datum.PixelInCell;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
import com.raytheon.uf.common.hydro.spatial.HRAPSubGrid;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.IMapDescriptor;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.IResourceDataChanged;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.OutlineCapability;
import com.raytheon.uf.viz.core.style.DataMappingPreferences;
import com.raytheon.viz.core.contours.rsc.displays.GriddedContourDisplay;
import com.raytheon.viz.core.rsc.displays.GriddedImageDisplay2;
import com.raytheon.viz.mpe.MPEInterrogationConstants;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.MPEDisplayManager.DisplayMode;
import com.raytheon.viz.mpe.ui.rsc.AbstractMPEGriddedResourceData.Frame;
import com.vividsolutions.jts.geom.Coordinate;
/**
* Abstract MPE resource for displaying gridded data
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 6, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public abstract class AbstractGriddedMPEResource<T extends AbstractMPEGriddedResourceData, F extends Frame>
extends AbstractVizResource<T, IMapDescriptor> implements
IResourceDataChanged, IMpeResource {
protected Rectangle displayExtent;
protected GridGeometry2D gridGeometry;
protected Map<DataTime, F> frames = new HashMap<DataTime, F>();
/** Replace once resource can look up time for itself */
@Deprecated
private DataTime lastPainted;
/**
* @param resourceData
* @param loadProperties
*/
protected AbstractGriddedMPEResource(T resourceData,
LoadProperties loadProperties) {
super(resourceData, loadProperties);
resourceData.addChangeListener(this);
dataTimes = new ArrayList<DataTime>();
getCapability(ColorMapCapability.class).setColorMapParameters(
MPEDisplayManager.createColorMap(resourceData.getCvUseString(),
resourceData.getDurationInHours(),
resourceData.getDataUnits(),
resourceData.getDisplayUnits()));
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.rsc.AbstractVizResource#initInternal(com.raytheon
* .uf.viz.core.IGraphicsTarget)
*/
@Override
protected void initInternal(IGraphicsTarget target) throws VizException {
try {
displayExtent = getHrapSubGridExtent();
gridGeometry = MapUtil.getGridGeometry(new HRAPSubGrid(
displayExtent));
} catch (Exception e) {
throw new VizException("Error computing hrap extent coordinates");
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.rsc.AbstractVizResource#paintInternal(com.raytheon
* .uf.viz.core.IGraphicsTarget,
* com.raytheon.uf.viz.core.drawables.PaintProperties)
*/
@Override
protected void paintInternal(IGraphicsTarget target,
PaintProperties paintProps) throws VizException {
DataTime currTime = lastPainted = paintProps.getDataTime();
if (currTime == null) {
return;
}
F frame = getFrame(currTime);
synchronized (frame) {
if (resourceData.isDisplayed(DisplayMode.Image)) {
if (frame.imageDisplay == null) {
frame.imageDisplay = createFrameImage(frame);
}
frame.imageDisplay.paint(target, paintProps);
}
if (resourceData.isDisplayed(DisplayMode.Contour)) {
if (frame.contourDisplay == null) {
frame.contourDisplay = createFrameContour(frame);
}
frame.contourDisplay.setColor(getCapability(
ColorableCapability.class).getColor());
frame.contourDisplay.setLineStyle(getCapability(
OutlineCapability.class).getLineStyle());
frame.contourDisplay.paint(target, paintProps);
}
}
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.rsc.AbstractVizResource#disposeInternal()
*/
@Override
protected void disposeInternal() {
for (F frame : frames.values()) {
frame.dispose();
}
frames.clear();
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.rsc.AbstractVizResource#project(org.opengis.
* referencing.crs.CoordinateReferenceSystem)
*/
@Override
public void project(CoordinateReferenceSystem crs) throws VizException {
super.project(crs);
for (Frame frame : frames.values()) {
frame.dispose();
}
issueRefresh();
}
/**
* Gets the {@link F} object for the time
*
* @param currTime
* @return
* @throws VizException
*/
protected F getFrame(DataTime currTime) throws VizException {
F frame = frames.get(currTime);
if (frame == null) {
frame = createFrame(currTime);
frames.put(currTime, frame);
dataTimes.add(currTime);
}
return frame;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.rsc.AbstractVizResource#inspect(com.raytheon
* .uf.viz.core.geospatial.ReferencedCoordinate)
*/
@Override
public String inspect(ReferencedCoordinate coord) throws VizException {
Map<String, Object> values = interrogate(coord);
String dataValueLabel = (String) values
.get(MPEInterrogationConstants.INTERROGATE_VALUE_LABEL);
if (dataValueLabel == null) {
return "NO DATA";
}
return dataValueLabel;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.rsc.AbstractVizResource#interrogate(com.raytheon
* .uf.viz.core.geospatial.ReferencedCoordinate)
*/
@Override
public Map<String, Object> interrogate(ReferencedCoordinate coord)
throws VizException {
try {
Map<String, Object> values = new HashMap<String, Object>();
ColorMapParameters parameters = getCapability(
ColorMapCapability.class).getColorMapParameters();
DataMappingPreferences dm = parameters.getDataMapping();
Unit<?> displayUnit = parameters.getDisplayUnit();
values.put(MPEInterrogationConstants.INTERROGATE_UNIT, displayUnit);
double displayValue = Double.NaN;
String displayValueLabel = null;
Coordinate gridCell = coord.asGridCell(gridGeometry,
PixelInCell.CELL_CORNER);
if (lastPainted != null && gridCell.x >= 0 && gridCell.y >= 0
&& gridCell.x < displayExtent.width
&& gridCell.y < displayExtent.height) {
int idx = ((int) gridCell.y) * displayExtent.width
+ ((int) gridCell.x);
short dataValue = getData(lastPainted)[idx];
UnitConverter dataToImage = parameters
.getDataToImageConverter();
double imageValue = dataToImage.convert(dataValue);
displayValueLabel = dm.getLabelValueForDataValue(imageValue);
if (displayValueLabel == null) {
displayValue = parameters.getDataToDisplayConverter()
.convert(dataValue);
displayValueLabel = String.format("%.3f", displayValue);
// This appears to be how A1 MPE works with widgets by
// specifying string lengths, they format using %.3f but
// only display 2 decimal places
displayValueLabel = displayValueLabel.substring(0,
displayValueLabel.length() - 1);
}
}
values.put(MPEInterrogationConstants.INTERROGATE_VALUE,
displayValue);
values.put(MPEInterrogationConstants.INTERROGATE_VALUE_LABEL,
displayValueLabel);
return values;
} catch (Exception e) {
throw new VizException("Error performing interrogation", e);
}
}
/**
* Gets the hrap extent for this resource
*
* @return
*/
public Rectangle getHrapExtent() {
return new Rectangle(displayExtent);
}
/**
* Use {@link #getData(DataTime)} instead
*
* @return
* @throws VizException
*/
@Deprecated
public final short[] getData() throws VizException {
return getData(lastPainted);
}
public short[] getData(DataTime time) throws VizException {
Frame frame = getFrame(time);
return frame.data;
}
/**
* Returns the hrap subgrid extent
*
* @return
*/
protected abstract Rectangle getHrapSubGridExtent();
/**
* @param currTime
* @return
*/
protected abstract F createFrame(DataTime currTime) throws VizException;
protected abstract GriddedContourDisplay createFrameContour(F frame)
throws VizException;
protected abstract GriddedImageDisplay2 createFrameImage(F frame)
throws VizException;
}

View file

@ -0,0 +1,210 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.mpe.ui.rsc;
import java.util.HashSet;
import java.util.Set;
import javax.measure.unit.Unit;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import com.raytheon.uf.viz.core.rsc.AbstractResourceData;
import com.raytheon.uf.viz.core.rsc.IResourceDataChanged.ChangeType;
import com.raytheon.viz.core.contours.rsc.displays.GriddedContourDisplay;
import com.raytheon.viz.core.rsc.displays.GriddedImageDisplay2;
import com.raytheon.viz.mpe.ui.MPEDisplayManager.DisplayMode;
/**
* Generic resource data for MPE plot resources
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 6, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
@XmlAccessorType(XmlAccessType.NONE)
public abstract class AbstractMPEGriddedResourceData extends
AbstractResourceData {
public static class Frame {
public final short[] data;
public GriddedImageDisplay2 imageDisplay;
public GriddedContourDisplay contourDisplay;
public Frame(short[] data) {
this.data = data;
}
public synchronized void dispose() {
disposeImage();
disposeContour();
}
public synchronized void disposeImage() {
if (imageDisplay != null) {
imageDisplay.dispose();
imageDisplay = null;
}
}
public synchronized void disposeContour() {
if (contourDisplay != null) {
contourDisplay.dispose();
contourDisplay = null;
}
}
}
@XmlElement(name = "displayMode")
private Set<DisplayMode> displayModes = new HashSet<DisplayMode>();
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.rsc.AbstractResourceData#update(java.lang.Object
* )
*/
@Override
public void update(Object updateData) {
fireChangeListeners(ChangeType.DATA_UPDATE, updateData);
}
/**
* @return the displayModes
*/
public Set<DisplayMode> getDisplayModes() {
return displayModes;
}
/**
* @param displayModes
* the displayModes to set
*/
public void setDisplayModes(Set<DisplayMode> displayModes) {
this.displayModes = displayModes;
}
/**
* Toggles visibilty of specified display mode
*
* @param displayMode
*/
public void toggleDisplayMode(DisplayMode displayMode) {
if (displayModes.remove(displayMode) == false) {
displayModes.add(displayMode);
}
}
/**
* Checks if the DisplayMode is displayed
*
* @param displayMode
* @return
*/
public boolean isDisplayed(DisplayMode displayMode) {
return displayModes.contains(displayMode);
}
/**
* Get the duration of the gridded data
*
* @return
*/
public abstract int getDurationInHours();
/**
* Gets the cv_use name for the gridded data
*
* @return
*/
public abstract String getCvUseString();
/**
* Get the data units for this type
*
* @return
*/
public abstract Unit<?> getDataUnits();
/**
* TODO: Replace with style rules?
*
* Get the display units for this type
*
* @return
*/
public abstract Unit<?> getDisplayUnits();
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
String cvUse = getCvUseString();
result = prime * result + ((cvUse == null) ? 0 : cvUse.hashCode());
result = prime * result + getDurationInHours();
return result;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
AbstractMPEGriddedResourceData other = (AbstractMPEGriddedResourceData) obj;
String cvUseString = getCvUseString();
String otherCvUseString = other.getCvUseString();
if (cvUseString == null) {
if (otherCvUseString != null)
return false;
} else if (!cvUseString.equals(otherCvUseString))
return false;
if (getDurationInHours() != other.getDurationInHours()) {
return false;
}
return true;
}
}

View file

@ -23,7 +23,6 @@ import java.awt.Rectangle;
import java.nio.FloatBuffer;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.measure.converter.UnitConverter;
@ -40,7 +39,6 @@ import com.raytheon.uf.common.colormap.Color;
import com.raytheon.uf.common.colormap.ColorMap;
import com.raytheon.uf.common.dataplugin.shef.tables.Colorvalue;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
import com.raytheon.uf.common.hydro.spatial.HRAP;
import com.raytheon.uf.common.hydro.spatial.HRAPCoordinates;
import com.raytheon.uf.common.hydro.spatial.HRAPSubGrid;
@ -55,6 +53,7 @@ import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.MapDescriptor;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.GenericResourceData;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability;
@ -89,7 +88,7 @@ import com.vividsolutions.jts.geom.Coordinate;
*/
public class DPAResource extends
AbstractVizResource<XmrgResourceData, MapDescriptor> implements
AbstractVizResource<GenericResourceData, MapDescriptor> implements
IMpeResource {
private static final String MISSING_DATA = "Missing Data";
@ -298,7 +297,7 @@ public class DPAResource extends
Date dtg = RadarDataManager
.getInstance()
.getLatestObstimeDpaRadar(radId,
MPEDisplayManager.getCurrent().getCurrentDate());
MPEDisplayManager.getCurrent().getCurrentEditDate());
// if available == 0
// available = radar availability flag array read from
@ -461,7 +460,7 @@ public class DPAResource extends
screenExtent.getMinY() + 50);
target.drawStrings(mainString);
Date date = MPEDisplayManager.getCurrent().getCurrentDate();
Date date = MPEDisplayManager.getCurrent().getCurrentEditDate();
if (date.equals(lastDate) == false) {
// Check for ignored Radar
ignored = RadarDataManager.getInstance()
@ -496,36 +495,6 @@ public class DPAResource extends
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.rsc.AbstractVizResource#inspect(com.raytheon
* .uf.viz.core.geospatial.ReferencedCoordinate)
*/
@Override
public String inspect(ReferencedCoordinate coord) throws VizException {
Map<String, Object> Values = interrogate(coord);
if (Values == null) {
return "NO DATA";
} else {
return Values.get("Value").toString();
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.rsc.AbstractVizResource#interrogate(com.raytheon
* .uf.viz.core.geospatial.ReferencedCoordinate)
*/
@Override
public Map<String, Object> interrogate(ReferencedCoordinate coord)
throws VizException {
return null;
}
/**
* Update the Xmrg Display.
*

View file

@ -26,23 +26,16 @@ import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Set;
import java.util.TimeZone;
import javax.measure.converter.UnitConverter;
import javax.measure.unit.NonSI;
import javax.measure.unit.SI;
import javax.measure.unit.Unit;
import org.eclipse.swt.graphics.RGB;
import org.geotools.coverage.grid.GridGeometry2D;
import org.geotools.coverage.grid.InvalidGridGeometryException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import com.raytheon.uf.common.colormap.Color;
import com.raytheon.uf.common.colormap.ColorMap;
import com.raytheon.uf.common.dataplugin.shef.tables.Colorvalue;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.hydro.spatial.HRAPCoordinates;
import com.raytheon.uf.common.hydro.spatial.HRAPSubGrid;
@ -64,13 +57,12 @@ import com.raytheon.uf.viz.core.map.MapDescriptor;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
import com.raytheon.uf.viz.core.style.DataMappingPreferences;
import com.raytheon.uf.viz.core.style.DataMappingPreferences.DataMappingEntry;
import com.raytheon.viz.core.ColorUtil;
import com.raytheon.viz.core.contours.rsc.displays.GriddedContourDisplay;
import com.raytheon.viz.core.rsc.displays.GriddedImageDisplay2;
import com.raytheon.viz.hydrocommon.whfslib.GeoUtil;
import com.raytheon.viz.hydrocommon.whfslib.GeoUtil.GeoAreaLineSegs;
import com.raytheon.viz.mpe.ui.DisplayFieldData;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.MPEDisplayManager.DisplayMode;
import com.vividsolutions.jts.geom.Coordinate;
@ -98,10 +90,6 @@ public class DisplayMeanArealPrecipResource extends
MPEDisplayManager displayMgr = null;
private ColorMapParameters parameters = new ColorMapParameters();
private List<Colorvalue> colorSet;
private String area_type = "";
private int xor = 0;
@ -112,6 +100,10 @@ public class DisplayMeanArealPrecipResource extends
private int max_rows = 0;
private int accumInterval;
private DisplayFieldData displayField;
private IFont font = null;
public static enum ImageSize {
@ -136,21 +128,15 @@ public class DisplayMeanArealPrecipResource extends
}
public DisplayMeanArealPrecipResource(MPEDisplayManager displayMgr,
String boundary_type, List<Colorvalue> colorSet) {
String boundary_type, DisplayFieldData displayField,
int accumInterval) {
super(new DisplayMeanArealPrecipResourceData(), new LoadProperties());
this.displayMgr = displayMgr;
this.colorSet = colorSet;
area_type = boundary_type;
loadData();
this.area_type = boundary_type;
this.displayField = displayField;
this.accumInterval = accumInterval;
}
ColorMap colorMap;
DataMappingPreferences dmPref = new DataMappingPreferences();
RGB color;
IGraphicsTarget target;
private GriddedImageDisplay2 gridDisplay;
@ -213,7 +199,8 @@ public class DisplayMeanArealPrecipResource extends
private void compute_mean_areal_precip(FloatBuffer fbuf,
ArrayList<GeoAreaLineSegs> meanAreaNodes, int xor, int yor,
int max_columns, int max_rows) {
ColorMapParameters parameters = getCapability(ColorMapCapability.class)
.getColorMapParameters();
float cur_max;
float cur_min;
int col;
@ -394,7 +381,8 @@ public class DisplayMeanArealPrecipResource extends
}
if (ids == true || vals == true) {
ColorMapParameters parameters = getCapability(
ColorMapCapability.class).getColorMapParameters();
for (GeoAreaLineSegs pMeanPrecip : meanAreaNodes) {
/* Using the MPE Lat/Lon Grid, draw the point. */
@ -472,62 +460,23 @@ public class DisplayMeanArealPrecipResource extends
@Override
protected void initInternal(IGraphicsTarget target) throws VizException {
this.target = target;
getCapability(ColorMapCapability.class)
.setColorMapParameters(
MPEDisplayManager.createColorMap(displayField
.getCv_use(), accumInterval,
MPEFieldResourceData
.getDataUnitsForField(displayField),
MPEFieldResourceData
.getDisplayUnitsForField(displayField)));
loadData();
}
private void loadData() {
min_coverage = Float.parseFloat(appsDefaults
.getToken(min_coverage_token));
colorMap = new ColorMap(colorSet.size());
colorMap.setName(displayMgr.getDisplayFieldType().getCv_use());
dmPref = new DataMappingPreferences();
int i = 0;
for (Colorvalue cv : colorSet) {
RGB rgb = RGBColors.getRGBColor(cv.getColorname().getColorName());
colorMap.setColor(i, new Color(rgb.red / 255f, rgb.green / 255f,
rgb.blue / 255f));
DataMappingEntry entry = new DataMappingEntry();
entry.setPixelValue((double) i);
entry.setDisplayValue(cv.getId().getThresholdValue());
dmPref.addEntry(entry);
i++;
}
DataMappingEntry entry = new DataMappingEntry();
entry.setPixelValue((double) (i - 1));
entry.setDisplayValue(Double.MAX_VALUE);
dmPref.addEntry(entry);
dmPref.getEntries().get(0).setLabel("");
dmPref.getEntries().get(1).setLabel("");
ColorMapCapability cmc = getCapability(ColorMapCapability.class);
parameters = cmc.getColorMapParameters();
if (parameters == null) {
parameters = new ColorMapParameters();
cmc.setColorMapParameters(parameters);
}
parameters.setColorMap(colorMap);
parameters.setDataMapping(dmPref);
Unit<?> displayUnit = Unit.ONE;
Unit<?> dataUnit = Unit.ONE;
displayUnit = NonSI.INCH;
dataUnit = SI.MILLIMETER.divide(100);
parameters.setFormatString("0.00");
parameters.setDisplayUnit(displayUnit);
parameters.setImageUnit(dmPref.getImageUnit(displayUnit));
parameters.setDataUnit(dataUnit);
parameters.setColorMapMax(parameters.getColorMap().getSize() - 1);
parameters.setColorMapMin(0);
parameters.setDataMax(parameters.getColorMap().getSize() - 1);
parameters.setDataMin(0);
ColorMapParameters parameters = getCapability(ColorMapCapability.class)
.getColorMapParameters();
cvt = parameters.getDataToImageConverter();
this.readData();
@ -562,10 +511,7 @@ public class DisplayMeanArealPrecipResource extends
*/
@Override
public String getName() {
String otherDisp = MPEDisplayManager.getCurrent().getOtherDispType()
.toString();
return otherDisp;
return DisplayFieldData.multiHour.toString();
}
/**
@ -637,7 +583,7 @@ public class DisplayMeanArealPrecipResource extends
String dtform = "";
String use = "";
Calendar cal1 = Calendar.getInstance((TimeZone.getTimeZone("GMT")));
cal1.setTime(displayMgr.getCurrentDate());
cal1.setTime(displayMgr.getCurrentEditDate());
if (cv_use.equals("XMRG")) {
dtform = sxf.format(cal1.getTime());
@ -665,7 +611,7 @@ public class DisplayMeanArealPrecipResource extends
xmrg = null;
int numhours = displayMgr.getAccum_interval();
int numhours = accumInterval;
int secsPerHr = 3600;
buf = FloatBuffer.allocate(datasz);
buf2 = FloatBuffer.allocate(buf.capacity());

View file

@ -19,17 +19,15 @@
**/
package com.raytheon.viz.mpe.ui.rsc;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.dataplugin.shef.tables.Colorvalue;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.AbstractResourceData;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.viz.mpe.ui.DisplayFieldData;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
/**
@ -55,7 +53,9 @@ public class DisplayMeanArealPrecipResourceData extends AbstractResourceData {
private String boundary;
private List<Colorvalue> colors;
private DisplayFieldData fieldData;
private int accumInterval;
public DisplayMeanArealPrecipResourceData() {
@ -67,10 +67,11 @@ public class DisplayMeanArealPrecipResourceData extends AbstractResourceData {
* @param colorSet
*/
public DisplayMeanArealPrecipResourceData(MPEDisplayManager displayManager,
String boundary_type, List<Colorvalue> colorSet) {
String boundary_type, DisplayFieldData fieldData, int accumInterval) {
dm = displayManager;
boundary = boundary_type;
colors = colorSet;
this.fieldData = fieldData;
this.accumInterval = accumInterval;
}
/*
@ -85,7 +86,8 @@ public class DisplayMeanArealPrecipResourceData extends AbstractResourceData {
public DisplayMeanArealPrecipResource construct(
LoadProperties loadProperties, IDescriptor descriptor)
throws VizException {
return new DisplayMeanArealPrecipResource(dm, boundary, colors);
return new DisplayMeanArealPrecipResource(dm, boundary, fieldData,
accumInterval);
}
/*

View file

@ -0,0 +1,459 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.mpe.ui.rsc;
import java.awt.Point;
import java.awt.Rectangle;
import java.io.IOException;
import java.nio.FloatBuffer;
import java.nio.ShortBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.measure.converter.UnitConverter;
import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.common.hydro.spatial.HRAPCoordinates;
import com.raytheon.uf.common.mpe.util.XmrgFile;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability;
import com.raytheon.uf.viz.core.style.DataMappingPreferences;
import com.raytheon.uf.viz.core.style.DataMappingPreferences.DataMappingEntry;
import com.raytheon.uf.viz.core.style.LabelingPreferences;
import com.raytheon.viz.core.contours.rsc.displays.GriddedContourDisplay;
import com.raytheon.viz.core.rsc.displays.GriddedImageDisplay2;
import com.raytheon.viz.core.style.contour.ContourPreferences;
import com.raytheon.viz.mpe.MPEDateFormatter;
import com.raytheon.viz.mpe.ui.Activator;
import com.raytheon.viz.mpe.ui.DisplayFieldData;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.dialogs.polygon.IPolygonEditsChangedListener;
import com.raytheon.viz.mpe.ui.dialogs.polygon.PolygonEditManager;
import com.raytheon.viz.mpe.ui.dialogs.polygon.RubberPolyData;
import com.raytheon.viz.mpe.ui.dialogs.polygon.RubberPolyData.PolygonEditAction;
import com.raytheon.viz.mpe.ui.rsc.AbstractMPEGriddedResourceData.Frame;
import com.raytheon.viz.mpe.ui.rsc.MPEFieldResourceData.MPEFieldFrame;
/**
* MPE resource that displays field data. Also supports data editing
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 29, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class MPEFieldResource extends
AbstractGriddedMPEResource<MPEFieldResourceData, MPEFieldFrame>
implements IPolygonEditsChangedListener {
private static final short MISSING_VALUE = -899;
private ContourPreferences contourPreferences;
/**
* @param resourceData
* @param loadProperties
*/
public MPEFieldResource(MPEFieldResourceData resourceData,
LoadProperties loadProperties) {
super(resourceData, loadProperties);
getCapability(ColorableCapability.class).setColor(
new RGB(255, 255, 255));
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.mpe.ui.rsc.AbstractGriddedMPEResource#initInternal(com
* .raytheon.uf.viz.core.IGraphicsTarget)
*/
@Override
protected void initInternal(IGraphicsTarget target) throws VizException {
super.initInternal(target);
contourPreferences = createContourPreferences(getCapability(
ColorMapCapability.class).getColorMapParameters());
PolygonEditManager.registerListener(this);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.mpe.ui.rsc.AbstractGriddedMPEResource#disposeInternal()
*/
@Override
protected void disposeInternal() {
super.disposeInternal();
PolygonEditManager.unregisterListener(this);
}
public List<RubberPolyData> getPolygonEdits(Date date) {
try {
MPEFieldFrame frame = getFrame(new DataTime(date));
return new ArrayList<RubberPolyData>(frame.getPolygonEdits());
} catch (VizException e) {
Activator.statusHandler.handle(
Priority.PROBLEM,
"Error getting polygon edits for "
+ resourceData.getFieldData() + " for time: "
+ date, e);
}
return new ArrayList<RubberPolyData>();
}
/**
* @param frame
* @return
*/
private short[] getEditedData(MPEFieldFrame frame) {
short[] editedData = frame.getEditedData();
if (editedData != null) {
return editedData;
}
short[] data = frame.data;
editedData = Arrays.copyOf(data, data.length);
List<RubberPolyData> polygonEdits = frame.getPolygonEdits();
Map<DisplayFieldData, short[]> dataMap = new HashMap<DisplayFieldData, short[]>();
ColorMapParameters parameters = getCapability(ColorMapCapability.class)
.getColorMapParameters();
UnitConverter displayToData = parameters.getDisplayToDataConverter();
UnitConverter dataToDisplay = parameters.getDataToDisplayConverter();
int width = displayExtent.width;
int height = displayExtent.height;
for (RubberPolyData edit : polygonEdits) {
if (edit.isVisible() == false) {
continue;
}
short[] subData = null;
PolygonEditAction editAction = edit.getEditAction();
if (editAction == PolygonEditAction.SUB) {
subData = dataMap.get(edit.getSubDrawSource());
if (subData == null) {
try {
XmrgFile subFile = MPEDisplayManager.getXmrgFile(
edit.getSubDrawSource(), frame.getDate());
subFile.load();
subData = subFile.getData();
dataMap.put(edit.getSubDrawSource(), subData);
} catch (IOException e) {
Activator.statusHandler.handle(
Priority.INFO,
"Error loading Substitution data from "
+ edit.getSubDrawSource()
+ " for polygon data", e);
}
}
}
double precipValue = edit.getPrecipValue();
double converted = (short) displayToData.convert(precipValue);
// Due to data mapping, this ensures we are never less than original
// precipValue when converting
double testPrecipValue = dataToDisplay.convert(converted);
if (testPrecipValue < precipValue) {
converted += 1.0;
}
for (Point p : edit.getEditPoints()) {
int x = p.x - displayExtent.x;
int y = displayExtent.y + height - p.y - 1;
int idx = y * width + x;
if (subData != null) {
editedData[idx] = subData[idx];
} else {
switch (editAction) {
case RAISE:
editedData[idx] = (short) Math.max(converted,
editedData[idx]);
break;
case LOWER:
editedData[idx] = (short) Math.min(converted,
editedData[idx]);
break;
case SCALE:
editedData[idx] *= precipValue;
break;
case SNOW:
// TODO: According to MPE users guide, SNOW should set
// data to data value and then exclude gages located
// within polygon whose values are < precipValue from
// the MPE Analysis. Old code did not do this and
// incorrectly set values to -9999
case SET:
editedData[idx] = (short) converted;
break;
}
}
}
}
frame.setEditedData(editedData);
return editedData;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.mpe.ui.rsc.AbstractGriddedMPEResource#getData(com.raytheon
* .uf.common.time.DataTime)
*/
@Override
public short[] getData(DataTime time) throws VizException {
MPEFieldFrame frame = getFrame(time);
return frame.getEditedData();
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.rsc.IResourceDataChanged#resourceChanged(com
* .raytheon.uf.viz.core.rsc.IResourceDataChanged.ChangeType,
* java.lang.Object)
*/
@Override
public void resourceChanged(ChangeType type, Object object) {
if (type == ChangeType.DATA_UPDATE) {
if (object instanceof Date) {
// Reload frame for date if created
Frame frame = frames.remove(new DataTime((Date) object));
if (frame != null) {
frame.dispose();
}
}
} else if (type == ChangeType.CAPABILITY) {
if (object instanceof ColorMapCapability) {
ColorMapParameters params = ((ColorMapCapability) object)
.getColorMapParameters();
if (params != null) {
contourPreferences = createContourPreferences(params);
for (MPEFieldFrame frame : frames.values()) {
frame.disposeContour();
}
}
}
}
issueRefresh();
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.mpe.ui.rsc.AbstractGriddedMPEResource#getHrapSubGridExtent
* ()
*/
@Override
protected Rectangle getHrapSubGridExtent() {
try {
return HRAPCoordinates.getHRAPCoordinates();
} catch (Exception e) {
throw new RuntimeException("Error getting hrap sub grid extent");
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.mpe.ui.rsc.AbstractGriddedMPEResource#createFrame(com
* .raytheon.uf.common.time.DataTime)
*/
@Override
protected MPEFieldFrame createFrame(DataTime currTime) throws VizException {
// Get field we are displaying
DisplayFieldData displayField = resourceData.getFieldData();
// Get accumInterval ensuring not less than 1
int accumInterval = Math.max(resourceData.getAccumulationInterval(), 1);
int datasz = displayExtent.height * displayExtent.width;
short[] frameData = new short[datasz];
Arrays.fill(frameData, MISSING_VALUE);
Calendar timeToLoad = Calendar.getInstance();
for (int i = 0; i < accumInterval; ++i) {
timeToLoad.setTime(currTime.getRefTime());
timeToLoad.add(Calendar.HOUR, -i);
XmrgFile file = MPEDisplayManager.getXmrgFile(displayField,
timeToLoad.getTime());
try {
file.load();
} catch (IOException e) {
Activator.statusHandler.handle(
Priority.INFO,
"Error loading XMRG file for "
+ displayField
+ " at time "
+ MPEDateFormatter
.format_MMM_dd_yyyy_HH(timeToLoad
.getTime()), e);
continue;
}
Rectangle fileExtent = file.getHrapExtent();
short[] fileData = file.getData();
for (int y = 0; y < displayExtent.height; ++y) {
for (int x = 0; x < displayExtent.width; ++x) {
int px = x + displayExtent.x;
int py = y + displayExtent.y;
if (px >= fileExtent.x
&& px < (fileExtent.x + fileExtent.width)
&& py >= fileExtent.y
&& py < (fileExtent.y + fileExtent.height)) {
int frameIdx = y * displayExtent.width + x;
int fx = px - fileExtent.x;
int fy = py - fileExtent.y;
int fileIdx = fy * fileExtent.width + fx;
short fi = fileData[fileIdx];
short fc = frameData[frameIdx];
if (fc < 0 && fi >= 0) {
frameData[frameIdx] = fi;
} else if (fc >= 0 && fi > 0) {
frameData[frameIdx] += fi;
}
}
}
}
}
return new MPEFieldFrame(currTime.getRefTime(), frameData,
PolygonEditManager.getPolygonEdits(resourceData.getFieldData(),
currTime.getRefTime()));
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.mpe.ui.rsc.AbstractGriddedMPEResource#createFrameContour
* (com.raytheon.viz.mpe.ui.rsc.AbstractMPEGriddedResourceData.Frame)
*/
@Override
protected GriddedContourDisplay createFrameContour(MPEFieldFrame frame)
throws VizException {
ColorMapParameters params = getCapability(ColorMapCapability.class)
.getColorMapParameters();
UnitConverter dataToDisplay = params.getDataToDisplayConverter();
short[] data = getEditedData(frame);
int length = data.length;
float[] contourData = new float[length];
for (int i = 0; i < length; ++i) {
contourData[i] = (float) dataToDisplay.convert(data[i]);
}
GriddedContourDisplay display = new GriddedContourDisplay(
getDescriptor(), gridGeometry, FloatBuffer.wrap(contourData));
display.setPreferences(contourPreferences);
return display;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.mpe.ui.rsc.AbstractGriddedMPEResource#createFrameImage
* (com.raytheon.viz.mpe.ui.rsc.AbstractMPEGriddedResourceData.Frame)
*/
@Override
protected GriddedImageDisplay2 createFrameImage(MPEFieldFrame frame)
throws VizException {
ColorMapParameters params = getCapability(ColorMapCapability.class)
.getColorMapParameters();
UnitConverter dataToImage = params.getDataToImageConverter();
short[] data = getEditedData(frame);
int length = data.length;
short[] imageData = new short[length];
for (int i = 0; i < length; ++i) {
short value = data[i];
if (value == MISSING_VALUE) {
imageData[i] = 0;
} else {
imageData[i] = (short) dataToImage.convert(value);
}
}
return new GriddedImageDisplay2(ShortBuffer.wrap(imageData),
gridGeometry, this);
}
private ContourPreferences createContourPreferences(
ColorMapParameters parameters) {
ContourPreferences preferences = new ContourPreferences();
DataMappingPreferences prefs = parameters.getDataMapping();
if (prefs != null) {
Collection<DataMappingEntry> entries = prefs.getEntries();
float[] values = new float[entries.size()];
int i = 0;
for (DataMappingEntry entry : entries) {
values[i++] = entry.getDisplayValue().floatValue();
}
LabelingPreferences labelingPreferences = new LabelingPreferences();
labelingPreferences.setValues(values);
labelingPreferences.setLabelFormat("0.00");
preferences.setContourLabeling(labelingPreferences);
}
return preferences;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.mpe.ui.dialogs.polygon.IPolygonEditsChangedListener#
* polygonEditsChanged(com.raytheon.viz.mpe.ui.DisplayFieldData,
* java.util.Date, java.util.List)
*/
@Override
public void polygonEditsChanged(DisplayFieldData field, Date date,
List<RubberPolyData> polygonEdits) {
if (field == resourceData.getFieldData()) {
MPEFieldFrame frame = frames.get(new DataTime(date));
if (frame != null) {
frame.setPolygonEdits(polygonEdits);
issueRefresh();
}
}
}
}

View file

@ -0,0 +1,299 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.mpe.ui.rsc;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.measure.unit.NonSI;
import javax.measure.unit.SI;
import javax.measure.unit.Unit;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.AbstractNameGenerator;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.viz.mpe.ui.DisplayFieldData;
import com.raytheon.viz.mpe.ui.dialogs.polygon.RubberPolyData;
/**
* Resource data for MPEFieldResource
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 29, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
@XmlAccessorType(XmlAccessType.NONE)
public class MPEFieldResourceData extends AbstractMPEGriddedResourceData {
public static enum ArealDisplay {
GRID, BASIN, COUNTY, ZONE;
}
public static class MPEFieldFrame extends Frame {
private final Date date;
private short[] editedData;
private List<RubberPolyData> polygonEdits;
public MPEFieldFrame(Date date, short[] data,
List<RubberPolyData> polygonEdits) {
super(data);
this.date = date;
setPolygonEdits(polygonEdits);
}
public Date getDate() {
return date;
}
public List<RubberPolyData> getPolygonEdits() {
return polygonEdits;
}
public void setPolygonEdits(List<RubberPolyData> polygonEdits) {
dispose();
this.polygonEdits = new ArrayList<RubberPolyData>(polygonEdits);
this.editedData = null;
}
public void setEditedData(short[] editedData) {
this.editedData = editedData;
}
public short[] getEditedData() {
return editedData;
}
}
@XmlElement
private DisplayFieldData fieldData = DisplayFieldData.mMosaic;
@XmlElement
private int accumulationInterval = 0;
@XmlElement
private ArealDisplay arealDisplay = ArealDisplay.GRID;
@XmlAttribute
private boolean displayIds = false;
@XmlAttribute
private boolean displayValues = false;
/**
*
*/
public MPEFieldResourceData() {
this.nameGenerator = new AbstractNameGenerator() {
@Override
public String getName(AbstractVizResource<?, ?> resource) {
// TODO: Get MPELegendResource to append date/other crap
return fieldData.toString();
}
};
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.rsc.AbstractResourceData#construct(com.raytheon
* .uf.viz.core.rsc.LoadProperties,
* com.raytheon.uf.viz.core.drawables.IDescriptor)
*/
@Override
public AbstractVizResource<?, ?> construct(LoadProperties loadProperties,
IDescriptor descriptor) throws VizException {
return new MPEFieldResource(this, loadProperties);
}
/**
* @return the fieldData
*/
public DisplayFieldData getFieldData() {
return fieldData;
}
/**
* @param fieldData
* the fieldData to set
*/
public void setFieldData(DisplayFieldData fieldData) {
this.fieldData = fieldData;
}
/**
* @return the accumulationInterval
*/
public int getAccumulationInterval() {
return accumulationInterval;
}
/**
* @param accumulationInterval
* the accumulationInterval to set
*/
public void setAccumulationInterval(int accumulationInterval) {
this.accumulationInterval = accumulationInterval;
}
/**
* @return the arealDisplay
*/
public ArealDisplay getArealDisplay() {
return arealDisplay;
}
/**
* @param arealDisplay
* the arealDisplay to set
*/
public void setArealDisplay(ArealDisplay arealDisplay) {
this.arealDisplay = arealDisplay;
}
/**
* @return the displayIds
*/
public boolean isDisplayIds() {
return displayIds;
}
/**
* @param displayIds
* the displayIds to set
*/
public void setDisplayIds(boolean displayIds) {
this.displayIds = displayIds;
}
/**
* @return the displayValues
*/
public boolean isDisplayValues() {
return displayValues;
}
/**
* @param displayValues
* the displayValues to set
*/
public void setDisplayValues(boolean displayValues) {
this.displayValues = displayValues;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.mpe.ui.rsc.AbstractMPEGriddedResourceData#getDurationInHours
* ()
*/
@Override
public int getDurationInHours() {
return accumulationInterval;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.mpe.ui.rsc.AbstractMPEGriddedResourceData#getCvUseString
* ()
*/
@Override
public String getCvUseString() {
return fieldData.getCv_use();
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.mpe.ui.rsc.AbstractMPEGriddedResourceData#getDataUnits()
*/
@Override
public Unit<?> getDataUnits() {
return getDataUnitsForField(fieldData);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.mpe.ui.rsc.AbstractMPEGriddedResourceData#getDisplayUnits
* ()
*/
@Override
public Unit<?> getDisplayUnits() {
return getDisplayUnitsForField(fieldData);
}
public static Unit<?> getDisplayUnitsForField(DisplayFieldData fieldData) {
switch (fieldData) {
case Height:
return NonSI.FOOT;
case Index:
case Locspan:
case Locbias:
return Unit.ONE;
case mintempPrism:
case maxtempPrism:
return NonSI.FAHRENHEIT;
}
return NonSI.INCH;
}
public static Unit<?> getDataUnitsForField(DisplayFieldData fieldData) {
switch (fieldData) {
case Locbias:
return Unit.ONE.divide(100);
case Height:
return SI.METER;
case Index:
case Locspan:
return Unit.ONE;
case Prism:
return SI.MILLIMETER;
case mintempPrism:
case maxtempPrism:
return NonSI.FAHRENHEIT.divide(10);
}
return SI.MILLIMETER.divide(100);
}
}

View file

@ -27,6 +27,7 @@ import java.nio.channels.FileChannel;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
@ -43,12 +44,8 @@ import org.eclipse.ui.commands.ICommandService;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import com.raytheon.uf.common.colormap.Color;
import com.raytheon.uf.common.colormap.ColorMap;
import com.raytheon.uf.common.dataplugin.shef.tables.Colorvalue;
import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
import com.raytheon.uf.common.ohd.AppsDefaults;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.DrawableCircle;
import com.raytheon.uf.viz.core.DrawableString;
@ -64,11 +61,13 @@ import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.GenericResourceData;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.style.DataMappingPreferences;
import com.raytheon.uf.viz.core.style.DataMappingPreferences.DataMappingEntry;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
import com.raytheon.viz.core.rsc.jts.JTSCompiler;
import com.raytheon.viz.mpe.core.MPEDataManager;
import com.raytheon.viz.mpe.core.MPEDataManager.MPEGageData;
import com.raytheon.viz.mpe.ui.Activator;
import com.raytheon.viz.mpe.ui.DisplayFieldData;
import com.raytheon.viz.mpe.ui.IDisplayFieldChangedListener;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.MPEDisplayManager.GageColor;
import com.raytheon.viz.mpe.ui.MPEDisplayManager.GageDisplay;
@ -100,14 +99,15 @@ import com.vividsolutions.jts.index.strtree.STRtree;
* @version 1.0
*/
public class MPEGageResource extends AbstractMPEInputResource {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(MPEGageResource.class);
public class MPEGageResource extends AbstractMPEInputResource implements
IDisplayFieldChangedListener {
private static final String GAGE_TRIANGLES = "GAGETRIANGLES%sz";
private static final double POINT_RADIUS = 2;
private static final RGB WHITE = new RGB(255, 255, 255);
private final SimpleDateFormat sdf;
private final Object mutex = new Object();
@ -122,9 +122,7 @@ public class MPEGageResource extends AbstractMPEInputResource {
private final double MILLICVT = 25.4;
private DataMappingPreferences dmPref;
private ColorMap colorMap;
private ColorMapParameters parameters;
private Display7x7Dialog dialog;
@ -134,6 +132,8 @@ public class MPEGageResource extends AbstractMPEInputResource {
private MPEFontFactory fontFactory;
private Set<GageDisplay> displayTypes = new HashSet<GageDisplay>();
/**
* @param resourceData
* @param loadProperties
@ -145,14 +145,26 @@ public class MPEGageResource extends AbstractMPEInputResource {
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
}
/**
* Toggles visibility of {@link GageDisplay} type
*
* @param display
*/
public void toggleGageDisplay(GageDisplay display) {
if (displayTypes.remove(display) == false) {
displayTypes.add(display);
}
}
@Override
protected void initInternal(IGraphicsTarget target) throws VizException {
super.initInternal(target);
displayMgr = MPEDisplayManager.getInstance(descriptor
.getRenderableDisplay());
displayMgr.registerDisplayFieldChangedListener(this);
fontFactory = new MPEFontFactory(target, this);
loadColors();
lastDate = displayMgr.getCurrentDate();
lastDate = displayMgr.getCurrentEditDate();
addPoints(MPEDataManager.getInstance().readGageData(lastDate, lastDate));
}
@ -162,6 +174,7 @@ public class MPEGageResource extends AbstractMPEInputResource {
gageTriangles.dispose();
}
fontFactory.dispose();
displayMgr.unregisterDisplayFieldChangedListener(this);
}
/**
@ -175,7 +188,7 @@ public class MPEGageResource extends AbstractMPEInputResource {
gageTriangles = null;
}
}
lastDate = displayMgr.getCurrentDate();
lastDate = displayMgr.getCurrentEditDate();
addPoints(MPEDataManager.getInstance().readGageData(lastDate, lastDate));
issueRefresh();
}
@ -199,31 +212,33 @@ public class MPEGageResource extends AbstractMPEInputResource {
protected void paintInternal(IGraphicsTarget target,
PaintProperties paintProps) throws VizException {
// set the plot draw or no draw values
Set<MPEDisplayManager.GageDisplay> gd = displayMgr.getGageDisplay();
if (gd.isEmpty()) {
if (displayTypes.isEmpty()) {
// Nothing to paint
return;
}
Date curDate = displayMgr.getCurrentDate();
Date curDate = displayMgr.getCurrentEditDate();
synchronized (mutex) {
if (curDate != null && curDate.equals(lastDate) == false) {
lastDate = curDate;
addPoints(MPEDataManager.getInstance().readGageData(lastDate, lastDate));
addPoints(MPEDataManager.getInstance().readGageData(lastDate,
lastDate));
}
}
if (gd.contains(GageDisplay.Ids) || gd.contains(GageDisplay.Values)) {
paintPlotInfo(target, paintProps, gd.contains(GageDisplay.Ids),
gd.contains(GageDisplay.Values));
if (displayTypes.contains(GageDisplay.Ids)
|| displayTypes.contains(GageDisplay.Values)) {
paintPlotInfo(target, paintProps,
displayTypes.contains(GageDisplay.Ids),
displayTypes.contains(GageDisplay.Values));
}
try {
if (gd.contains(GageDisplay.Triangles)) {
if (displayTypes.contains(GageDisplay.Triangles)) {
paintTriangles(target, paintProps);
}
} catch (Exception e) {
statusHandler
Activator.statusHandler
.handle(Priority.PROBLEM, "Error painting gage triangles: "
+ e.getLocalizedMessage(), e);
}
@ -269,7 +284,7 @@ public class MPEGageResource extends AbstractMPEInputResource {
double lon_2 = in.getDouble();
lon_2 *= (lon_2 > 0) ? -1 : 1;
lat_2 *= (lat_2 < 0) ? -1 : 1;
compiler.handle(gf.createLineString(new Coordinate[] {
new Coordinate(lon_1, lat_1),
new Coordinate(lon_2, lat_2) }));
@ -303,16 +318,23 @@ public class MPEGageResource extends AbstractMPEInputResource {
dataMap.size());
// Fonts are shared and cached, no need to init or dispose
IFont font = fontFactory.getMPEFont(displayMgr.getFontState());
IFont font = fontFactory.getMPEFont(MPEDisplayManager.getFontId());
font.setSmoothing(false);
MPEDisplayManager.GageMissingOptions gm = displayMgr.getGageMissing();
boolean xor = displayMgr.getGageColor() == GageColor.Contrast;
MPEDisplayManager.GageMissingOptions gm = MPEDisplayManager
.getGageMissing();
boolean displayIsEdit = displayMgr.getCurrentEditDate().equals(
paintProps.getDataTime().getRefTime());
boolean xor = MPEDisplayManager.getGageColor() == GageColor.Contrast
&& displayIsEdit;
for (Coordinate point : dataMap.keySet()) {
if (extent.contains(new double[] { point.x, point.y })) {
MPEGageData gageData = dataMap.get(point);
RGB gageColor = getGageColor(gageData);
RGB gageColor = WHITE;
if (displayIsEdit) {
gageColor = getGageColor(gageData);
}
boolean isReportedMissing = gageData.isReported_missing();
boolean isMissing = ((gageData.getGval() == -999.f || gageData
@ -347,13 +369,13 @@ public class MPEGageResource extends AbstractMPEInputResource {
if (!gageData.isManedit()) {
if (gageData.getId().contains("PSEUDO")) {
gageValue = String.format("%5.2f",
gageData.getGval() / MILLICVT);
gageData.getGval() / MILLICVT);
}
} else {
if (gageData.getId().contains("PSEUDO")
&& !isMissing) {
gageValue = String.format("%5.2f",
gageData.getGval() / MILLICVT);
gageData.getGval() / MILLICVT);
}
}
}
@ -395,8 +417,8 @@ public class MPEGageResource extends AbstractMPEInputResource {
private RGB getGageColor(MPEGageData gageData) {
RGB gageColor = new RGB(255, 255, 255);
if (!displayMgr.getGageDisplay().isEmpty()) {
MPEDisplayManager.GageColor gc = displayMgr.getGageColor();
if (displayTypes.isEmpty() == false) {
MPEDisplayManager.GageColor gc = MPEDisplayManager.getGageColor();
switch (gc) {
case Solid:
gageColor = RGBColors.getRGBColor("SandyBrown");
@ -421,7 +443,7 @@ public class MPEGageResource extends AbstractMPEInputResource {
// Check for pseudo gage and convert
float fltVal = gageData.getGval();
if (gageData.getId().contains("PSEUDO")) {
fltVal = (float) (gageData.getGval() / MILLICVT);
fltVal = (float) (gageData.getGval() / MILLICVT);
}
// System.out.println("--- fltVal = " + fltVal);
gageColor = getColorByValue(fltVal);
@ -465,7 +487,7 @@ public class MPEGageResource extends AbstractMPEInputResource {
data.add(latLon);
String newData = "GAGE: " + gageData.getId() + " VALUE: "
+ gageData.getGval();
data.add(newData);
data.add(newData);
strTree.insert(env, data);
}
}
@ -477,50 +499,25 @@ public class MPEGageResource extends AbstractMPEInputResource {
if (value == -999.0) {
value = -9999.0f;
}
int i = 0;
RGB gcol = null;
for (DataMappingEntry entry : dmPref.getEntries()) {
if (value == entry.getDisplayValue().floatValue()) {
gcol = ColorMapParameters.colorToRGB((colorMap.getColors()
.get(i)));
break;
} else if (value < entry.getDisplayValue().floatValue()) {
gcol = ColorMapParameters.colorToRGB((colorMap.getColors()
.get(i - 1)));
break;
}
i++;
}
if (gcol == null) {
i = dmPref.getEntries().size();
gcol = ColorMapParameters.colorToRGB(colorMap.getColors()
.get(i - 1));
}
return gcol;
Color color = parameters.getColorByValue(value);
return new RGB((int) (color.getRed() * 255),
(int) (color.getGreen() * 255), (int) (color.getBlue() * 255));
}
private void loadColors() {
List<Colorvalue> colorSet = displayMgr.getGageColorMap();
if (colorSet == null) {
return;
}
colorMap = new ColorMap(colorSet.size());
colorMap.setName(displayMgr.getDisplayFieldType().getCv_use());
dmPref = new DataMappingPreferences();
int i = 0;
for (Colorvalue cv : colorSet) {
RGB rgb = RGBColors.getRGBColor(cv.getColorname().getColorName());
colorMap.setColor(i, new Color(rgb.red / 255f, rgb.green / 255f,
rgb.blue / 255f));
DataMappingEntry entry = new DataMappingEntry();
entry.setPixelValue((double) i);
entry.setDisplayValue(cv.getId().getThresholdValue());
dmPref.addEntry(entry);
i++;
MPEFieldResource displayedResource = displayMgr
.getDisplayedFieldResource();
if (displayedResource != null) {
parameters = displayedResource.getCapability(
ColorMapCapability.class).getColorMapParameters();
} else {
DisplayFieldData displayedData = displayMgr.getDisplayFieldType();
parameters = MPEDisplayManager
.createColorMap(displayedData.getCv_use(), displayedData
.getCv_duration(), MPEFieldResourceData
.getDataUnitsForField(displayedData),
MPEFieldResourceData
.getDisplayUnitsForField(displayedData));
}
}
@ -608,4 +605,19 @@ public class MPEGageResource extends AbstractMPEInputResource {
return false;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.mpe.ui.IDisplayFieldChangedListener#displayFieldChanged
* (com.raytheon.viz.mpe.ui.DisplayFieldData,
* com.raytheon.viz.mpe.ui.DisplayFieldData)
*/
@Override
public void displayFieldChanged(DisplayFieldData oldFieldData,
DisplayFieldData newFieldData) {
loadColors();
issueRefresh();
}
}

View file

@ -19,6 +19,10 @@
**/
package com.raytheon.viz.mpe.ui.rsc;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.measure.converter.UnitConverter;
@ -26,12 +30,19 @@ import javax.measure.converter.UnitConverter;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Event;
import org.opengis.referencing.datum.PixelInCell;
import com.raytheon.uf.common.colormap.IColorMap;
import com.raytheon.uf.common.geospatial.ISpatialQuery;
import com.raytheon.uf.common.geospatial.ISpatialQuery.SearchMode;
import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
import com.raytheon.uf.common.geospatial.SpatialQueryFactory;
import com.raytheon.uf.common.geospatial.SpatialQueryResult;
import com.raytheon.uf.common.hydro.spatial.HRAP;
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.DataTime;
import com.raytheon.uf.viz.core.DrawableColorMap;
import com.raytheon.uf.viz.core.DrawableString;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
@ -43,6 +54,7 @@ import com.raytheon.uf.viz.core.PixelExtent;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters.LabelEntry;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.IDescriptor.FramesInfo;
import com.raytheon.uf.viz.core.drawables.IFont;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
@ -51,8 +63,13 @@ import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.GenericResourceData;
import com.raytheon.uf.viz.core.rsc.IInputHandler;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.ResourceList;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability;
import com.raytheon.uf.viz.core.rsc.legend.AbstractLegendResource;
import com.raytheon.uf.viz.core.sampling.ISamplingResource;
import com.raytheon.viz.mpe.MPEDateFormatter;
import com.raytheon.viz.mpe.MPEInterrogationConstants;
import com.raytheon.viz.mpe.core.MPEDataManager;
import com.raytheon.viz.mpe.ui.DisplayFieldData;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
@ -62,6 +79,7 @@ import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
import com.raytheon.viz.ui.cmenu.IContextMenuContributor;
import com.raytheon.viz.ui.input.InputAdapter;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.GeometryFactory;
/**
* The MPE Legend Resource
@ -81,8 +99,8 @@ import com.vividsolutions.jts.geom.Coordinate;
* @version 1.0
*/
public class MPELegendResource extends
AbstractVizResource<GenericResourceData, IDescriptor> implements
IMpeResource, IContextMenuContributor, ISamplingResource {
AbstractLegendResource<GenericResourceData> implements IMpeResource,
IContextMenuContributor, ISamplingResource {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(MPELegendResource.class);
@ -121,6 +139,8 @@ public class MPELegendResource extends
}
};
private static final String LAT_LON_FORMAT_STR = "%5.2f";
private MPEDisplayManager displayMgr;
private double scale;
@ -131,8 +151,6 @@ public class MPELegendResource extends
private AbstractVizResource<?, ?> rsc;
private DisplayFieldData otherDispType;
private final String rfc = MPEDataManager.getInstance().getRFC();
private double width;
@ -149,6 +167,9 @@ public class MPELegendResource extends
private IFont font;
private SimpleDateFormat legendFormat = MPEDateFormatter
.createSimpleDateFormat(MPEDateFormatter.MMM_dd_yyyy_HH);
public MPELegendResource(GenericResourceData rscData,
LoadProperties loadProps) {
super(rscData, loadProps);
@ -197,7 +218,7 @@ public class MPELegendResource extends
protected void paintInternal(IGraphicsTarget target,
PaintProperties paintProps) throws VizException {
// Fonts are shared and cached, no need to init or dispose
font = fontFactory.getMPEFont(displayMgr.getFontState());
font = fontFactory.getMPEFont(MPEDisplayManager.getFontId());
IExtent screenExtent = paintProps.getView().getExtent();
scale = (screenExtent.getHeight() / paintProps.getCanvasBounds().height);
@ -226,35 +247,21 @@ public class MPELegendResource extends
screenExtent.getMinX(), screenExtent.getMaxX(), yMax,
textHeight, padding);
} else {
yMax = drawMpeLegend(target, paintProps.getAlpha(),
screenExtent.getMinX(), screenExtent.getMaxX(), yMax,
textHeight, padding);
yMax = drawMpeLegend(target, paintProps, screenExtent.getMinX(),
screenExtent.getMaxX(), yMax, textHeight, padding);
}
target.setupClippingPlane(screenExtent);
super.paintInternal(target, paintProps);
}
private double drawMpeLegend(IGraphicsTarget target, float alpha,
double xMin, double xMax, double yMax, double textHeight,
double padding) throws VizException {
private double drawMpeLegend(IGraphicsTarget target,
PaintProperties paintProps, double xMin, double xMax, double yMax,
double textHeight, double padding) throws VizException {
// TODO: Pass in expected resource
float alpha = paintProps.getAlpha();
double legendHeight = 0;
rsc = displayMgr.getDisplayedResource();
if (rsc == null) {
for (ResourcePair pair : descriptor.getResourceList()) {
if (pair.getResource() instanceof XmrgResource) {
displayMgr = ((XmrgResource) pair.getResource())
.getDisplayMgr();
rsc = displayMgr.getDisplayedResource();
if (!rsc.getStatus().equals(ResourceStatus.INITIALIZED)) {
rsc.init(null);
}
}
}
}
otherDispType = displayMgr.getOtherDispType();
rsc = displayMgr.getDisplayedFieldResource();
if (rsc != null) {
if (rsc.getStatus().equals(ResourceStatus.INITIALIZED)) {
@ -312,15 +319,20 @@ public class MPELegendResource extends
target.drawColorRamp(cmap);
y1 += cmapHeight;
if (!(otherDispType == null)
&& (otherDispType.equals(DisplayFieldData.multiHour))) {
int accum = 0;
if (rsc instanceof MPEFieldResource) {
// IMPEResource.getAccumulationInterval()?
accum = ((MPEFieldResource) rsc).getResourceData()
.getAccumulationInterval();
}
String dateStr = legendFormat.format(paintProps.getFramesInfo()
.getTimeForResource(rsc).getRefTime())
+ "z";
if (accum > 0) {
String qpeString = String.format(
"%d hr Accumulated %s For %s Ending %s (in)",
MPEDisplayManager.getCurrent().getAccum_interval(),
MPEDisplayManager.getCurrent()
.getDisplayFieldType().toString(), rfc,
MPEDisplayManager.getCurrent().getCurrentDate());
"%d hr Accumulated %s For %s Ending %sz (in)",
accum, rsc.getName(), rfc, dateStr);
double xLoc = xMin + padding;
strings.setText(qpeString, textColor);
@ -329,7 +341,9 @@ public class MPELegendResource extends
strings.setCoordinates(xLoc, y1);
target.drawStrings(strings);
} else {
strings.setText(rsc.getName(), textColor);
String fieldString = String.format("%s site=%s %s",
dateStr, rfc, rsc.getName());
strings.setText(fieldString, textColor);
double xLoc = xMin + padding;
strings.horizontalAlignment = HorizontalAlignment.LEFT;
strings.verticallAlignment = VerticalAlignment.TOP;
@ -347,6 +361,7 @@ public class MPELegendResource extends
double padding) throws VizException {
double legendHeight = 0;
// TODO: pass in expected resource type
rsc = displayMgr.getDisplayedResource();
double cmapHeight = textHeight * 1.25;
@ -441,7 +456,8 @@ public class MPELegendResource extends
RGB textColor = new RGB(255, 255, 255);
DrawableString strings = new DrawableString("", textColor);
strings.font = font;
if (isSampling() && rsc != null) {
if (isSampling() && rsc != null
&& rsc.getStatus() == ResourceStatus.INITIALIZED) {
legendHeight = textSpace + 2 * padding;
width = (xMax - xMin)
/ 25
@ -451,7 +467,6 @@ public class MPELegendResource extends
- legendHeight, yMax);
target.drawShadedRect(legendExtent, new RGB(0, 0, 0), alpha, null);
Map<String, Object> values = getMpeInfo(rsc);
String hrapX = "9999";
String hrapY = "9999";
String value = "-----";
@ -460,14 +475,41 @@ public class MPELegendResource extends
String lon = "99.99";
String lat = "9999.99";
Map<String, Object> values = getMpeInfo(rsc);
if (values != null) {
hrapX = values.get("X").toString();
hrapY = values.get("Y").toString();
value = values.get("Value").toString();
county = values.get("County").toString();
basin = values.get("Basin").toString();
lon = values.get("Lon").toString();
lat = values.get("Lat").toString();
String gridValue = (String) values
.get(MPEInterrogationConstants.INTERROGATE_VALUE_LABEL);
if (gridValue != null) {
value = gridValue;
}
}
values = getMpeInfo(this);
if (values != null) {
Coordinate gridCell = (Coordinate) values
.get(MPEInterrogationConstants.INTERROGATE_GRID_CELL);
if (gridCell != null) {
hrapX = Integer.toString((int) gridCell.x);
hrapY = Integer.toString((int) gridCell.y);
}
Coordinate latLon = (Coordinate) values
.get(MPEInterrogationConstants.INTERROGATE_LAT_LON);
if (latLon != null) {
lon = String.format(LAT_LON_FORMAT_STR, latLon.x);
lat = String.format(LAT_LON_FORMAT_STR, latLon.y);
}
String countyValue = (String) values
.get(MPEInterrogationConstants.INTERROGATE_COUNTY);
if (countyValue != null) {
county = countyValue;
}
String basinValue = (String) values
.get(MPEInterrogationConstants.INTERROGATE_BASIN);
if (basinValue != null) {
basin = basinValue;
}
}
double x = xMin + padding;
@ -548,6 +590,57 @@ public class MPELegendResource extends
return yMax - legendHeight;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.rsc.AbstractVizResource#interrogate(com.raytheon
* .uf.common.geospatial.ReferencedCoordinate)
*/
@Override
public Map<String, Object> interrogate(ReferencedCoordinate coord)
throws VizException {
try {
Map<String, Object> values = new HashMap<String, Object>();
Coordinate latLon = coord.asLatLon();
// Get hrap grid cell
Coordinate hrapCell = coord.asGridCell(HRAP.getInstance()
.getGridGeometry(), PixelInCell.CELL_CENTER);
values.put(MPEInterrogationConstants.INTERROGATE_GRID_CELL,
hrapCell);
values.put(MPEInterrogationConstants.INTERROGATE_LAT_LON, latLon);
ISpatialQuery query = SpatialQueryFactory.create();
com.vividsolutions.jts.geom.Point point = new GeometryFactory()
.createPoint(latLon);
SpatialQueryResult[] results = query.query("county",
new String[] { "countyname" }, point, null, false,
SearchMode.WITHIN);
String county = "Not Defined";
if ((results != null) && (results.length > 0)) {
county = (String) results[0].attributes.get("countyname");
}
values.put(MPEInterrogationConstants.INTERROGATE_COUNTY, county);
results = query.query("basins", new String[] { "name" }, point,
null, false, SearchMode.WITHIN);
String basin = "Not Defined";
if ((results != null) && (results.length > 0)) {
basin = (String) results[0].attributes.get("name");
}
values.put(MPEInterrogationConstants.INTERROGATE_BASIN, basin);
return values;
} catch (Exception e) {
throw new VizException("Error interrogating MPE legend resource", e);
}
}
private Map<String, Object> getMpeInfo(AbstractVizResource<?, ?> resource) {
if (sampleCoord != null && resource != null) {
try {
@ -707,4 +800,66 @@ public class MPELegendResource extends
issueRefresh();
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.legend.ILegendDecorator#getLegendData(com.raytheon
* .uf.viz.core.drawables.IDescriptor)
*/
@Override
public LegendEntry[] getLegendData(IDescriptor descriptor) {
FramesInfo frameInfo = descriptor.getFramesInfo();
List<LegendData> labels = new ArrayList<LegendData>();
ResourceList resourceList = descriptor.getResourceList();
if (resourceList != null) {
for (int i = 0; i < resourceList.size(); i++) {
ResourcePair resourcePair = resourceList.get(i);
// See if resource is a system resource (does not
// participate in legend)
boolean system = resourcePair.getProperties()
.isSystemResource();
// See if resource is visible
boolean vis = resourcePair.getProperties().isVisible();
AbstractVizResource<?, ?> rsc = resourcePair.getResource();
if (system) {
continue;
} else {
LegendData legend = new LegendData();
if (rsc == null) {
continue;
} else if (rsc.getStatus() != ResourceStatus.INITIALIZED) {
continue;
} else {
legend.label = rsc.getName();
legend.resource = resourcePair;
if (rsc.isTimeAgnostic() == false) {
DataTime date = frameInfo.getTimeForResource(rsc);
String time = " No Data Available";
if (date != null) {
time = " - " + date.getLegendString() + "z";
}
legend.label += time;
}
}
if (!vis) {
legend.color = new RGB(50, 50, 50);
} else {
legend.color = rsc.getCapability(
ColorableCapability.class).getColor();
}
labels.add(legend);
}
}
}
LegendEntry[] entries = new LegendEntry[labels.size()];
for (int i = 0; i < entries.length; ++i) {
entries[i] = new LegendEntry();
entries[i].legendParts = new LegendData[] { labels.get(i) };
}
return entries;
}
}

View file

@ -0,0 +1,177 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.mpe.ui.rsc;
import java.awt.Rectangle;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.OutlineCapability;
import com.raytheon.viz.core.contours.rsc.displays.GriddedContourDisplay;
import com.raytheon.viz.core.rsc.displays.GriddedImageDisplay2;
import com.raytheon.viz.mpe.ui.rsc.AbstractMPEGriddedResourceData.Frame;
import com.raytheon.viz.mpe.util.DailyQcUtils;
import com.raytheon.viz.mpe.util.DailyQcUtils.Hrap_Grid;
import com.raytheon.viz.mpe.util.DailyQcUtils.Pcp;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 6, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class MPEPlotGriddedResource extends
AbstractGriddedMPEResource<AbstractMPEGriddedResourceData, Frame> {
private Pcp pcp = DailyQcUtils.pcp;
private Pcp spf = DailyQcUtils.spf;
/**
* @param resourceData
* @param loadProperties
*/
public MPEPlotGriddedResource(AbstractMPEGriddedResourceData resourceData,
LoadProperties loadProperties) {
super(resourceData, loadProperties);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.rsc.AbstractVizResource#paintInternal(com.raytheon
* .uf.viz.core.IGraphicsTarget,
* com.raytheon.uf.viz.core.drawables.PaintProperties)
*/
@Override
protected void paintInternal(IGraphicsTarget target,
PaintProperties paintProps) throws VizException {
DataTime currTime = paintProps.getDataTime();
if (currTime == null) {
return;
}
boolean image = true;
boolean contour = false;
Frame frame = getFrame(currTime);
if (image) {
if (frame.imageDisplay == null) {
frame.imageDisplay = createFrameImage(frame);
}
frame.imageDisplay.paint(target, paintProps);
}
if (contour) {
if (frame.contourDisplay == null) {
frame.contourDisplay = createFrameContour(frame);
}
frame.contourDisplay.setColor(getCapability(
ColorableCapability.class).getColor());
frame.contourDisplay.setLineStyle(getCapability(
OutlineCapability.class).getLineStyle());
frame.contourDisplay.paint(target, paintProps);
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.mpe.ui.rsc.AbstractGriddedMPEResource#getHrapSubGridExtent
* ()
*/
@Override
protected Rectangle getHrapSubGridExtent() {
Hrap_Grid hrap_grid = DailyQcUtils.getHrap_grid();
return new Rectangle(hrap_grid.hrap_minx, hrap_grid.hrap_miny,
hrap_grid.maxi, hrap_grid.maxj);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.rsc.IResourceDataChanged#resourceChanged(com
* .raytheon.uf.viz.core.rsc.IResourceDataChanged.ChangeType,
* java.lang.Object)
*/
@Override
public void resourceChanged(ChangeType type, Object object) {
// TODO Auto-generated method stub
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.mpe.ui.rsc.AbstractGriddedMPEResource#createFrame(com
* .raytheon.uf.common.time.DataTime)
*/
@Override
protected Frame createFrame(DataTime currTime) throws VizException {
return null;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.mpe.ui.rsc.AbstractGriddedMPEResource#createFrameContour
* (com.raytheon.viz.mpe.ui.rsc.AbstractMPEGriddedResourceData.Frame)
*/
@Override
protected GriddedContourDisplay createFrameContour(Frame frame)
throws VizException {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.mpe.ui.rsc.AbstractGriddedMPEResource#createFrameImage
* (com.raytheon.viz.mpe.ui.rsc.AbstractMPEGriddedResourceData.Frame)
*/
@Override
protected GriddedImageDisplay2 createFrameImage(Frame frame)
throws VizException {
// TODO Auto-generated method stub
return null;
}
}

View file

@ -0,0 +1,186 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.mpe.ui.rsc;
import javax.measure.unit.NonSI;
import javax.measure.unit.Unit;
import javax.xml.bind.annotation.XmlElement;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.viz.mpe.ui.MPEPlotType;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 6, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class MPEPlotGriddedResourceData extends AbstractMPEGriddedResourceData {
@XmlElement
private MPEPlotType plotType;
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.rsc.AbstractResourceData#construct(com.raytheon
* .uf.viz.core.rsc.LoadProperties,
* com.raytheon.uf.viz.core.drawables.IDescriptor)
*/
@Override
public AbstractVizResource<?, ?> construct(LoadProperties loadProperties,
IDescriptor descriptor) throws VizException {
switch (plotType) {
case T_24hGRID_PRECIP:
case T_6hGRID_PRECIP:
// TODO: Replace PlotGriddedPrecipResource.java
break;
case T_maxGRID_TEMP:
case T_minGRID_TEMP:
case T_sixhGRID_TEMP:
// TODO: Replace PlotGriddedTempResource.java
break;
case T_6hGRID_FREEZL:
// TODO: Replace PlotGriddedFreezeResource.java
break;
case T_24hMAREAPRECIP:
case T_6hMAREA_PRECIP:
// TODO: Replace PlotMeanAreaPreipResource.java
break;
case T_6hMAREA_FREEZL:
// TODO: Replace PlotMeanAreaFreezeResource.java
break;
case T_sixhMAREA_TEMP:
// TODO: Replace PlotMeanAreaTempResource.java
break;
default:
throw new VizException("Unknown MPEPlotType: " + plotType);
}
return null;
}
/**
* @return the plotType
*/
public MPEPlotType getPlotType() {
return plotType;
}
/**
* @param plotType
* the plotType to set
*/
public void setPlotType(MPEPlotType plotType) {
this.plotType = plotType;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.mpe.ui.rsc.AbstractMPEGriddedResourceData#getDurationInHours
* ()
*/
@Override
public int getDurationInHours() {
return plotType != null ? plotType.getDurationInHrs() : 1;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.mpe.ui.rsc.AbstractMPEGriddedResourceData#getCvUseString
* ()
*/
@Override
public String getCvUseString() {
return plotType != null ? plotType.getCvUse() : null;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.mpe.ui.rsc.AbstractMPEGriddedResourceData#getDataUnits()
*/
@Override
public Unit<?> getDataUnits() {
switch (plotType) {
case T_24hGRID_PRECIP:
case T_6hGRID_PRECIP:
case T_24hMAREAPRECIP:
case T_6hMAREA_PRECIP:
return NonSI.INCH.divide(100.0);
case T_6hGRID_FREEZL:
case T_6hMAREA_FREEZL:
return NonSI.FOOT.divide(100.0);
case T_minGRID_TEMP:
case T_maxGRID_TEMP:
case T_sixhGRID_TEMP:
case T_sixhMAREA_TEMP:
return NonSI.FAHRENHEIT.divide(100.0);
}
return null;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.mpe.ui.rsc.AbstractMPEGriddedResourceData#getDisplayUnits
* ()
*/
@Override
public Unit<?> getDisplayUnits() {
switch (plotType) {
case T_24hGRID_PRECIP:
case T_6hGRID_PRECIP:
case T_24hMAREAPRECIP:
case T_6hMAREA_PRECIP:
return NonSI.INCH;
case T_6hGRID_FREEZL:
case T_6hMAREA_FREEZL:
return NonSI.FOOT;
case T_minGRID_TEMP:
case T_maxGRID_TEMP:
case T_sixhGRID_TEMP:
case T_sixhMAREA_TEMP:
return NonSI.FAHRENHEIT;
}
return null;
}
}

View file

@ -87,8 +87,7 @@ public class MPERadarRingOverlayResource extends RadarRingOverlayResource {
MPEDisplayManager displayManager = MPEDisplayManager
.getCurrent();
if (displayManager != null) {
Date displayDate = displayManager.getCurrentDate();
Date displayDate = displayManager.getCurrentEditDate();
for (RadarRingOverlayData rdata : dataMap.values()) {
dao.getRadarAvailable(rdata, displayDate);
if (rdata.isRadAvail()) {

View file

@ -59,6 +59,7 @@ import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.MapDescriptor;
import com.raytheon.uf.viz.core.rsc.AbstractResourceData;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.GenericResourceData;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
import com.raytheon.uf.viz.core.style.DataMappingPreferences;
@ -133,7 +134,7 @@ public class PlotGriddedFreezeResource extends
public PlotGriddedFreezeResource(MPEDisplayManager displayMgr,
LoadProperties loadProperties, List<Colorvalue> colorSet) {
super(new XmrgResourceData(), loadProperties);
super(new GenericResourceData(), loadProperties);
this.displayMgr = displayMgr;
this.colorSet = colorSet;
}

View file

@ -67,6 +67,7 @@ import com.raytheon.viz.core.ColorUtil;
import com.raytheon.viz.core.contours.rsc.displays.GriddedContourDisplay;
import com.raytheon.viz.core.rsc.displays.GriddedImageDisplay.GriddedImagePaintProperties;
import com.raytheon.viz.core.rsc.displays.GriddedImageDisplay2;
import com.raytheon.viz.hydrocommon.resource.XmrgResourceData;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.MPEDisplayManager.DisplayMode;
import com.raytheon.viz.mpe.ui.actions.DrawDQCStations;

View file

@ -481,7 +481,7 @@ public class PointFreezePlotResource extends
this.paintProps = paintProps;
MPEDisplayManager displayMgr = getResourceData().getMPEDisplayManager();
// Fonts are shared and cached, get from factory
font = fontFactory.getMPEFont(displayMgr.getFontState());
font = fontFactory.getMPEFont(MPEDisplayManager.getFontId());
if (DailyQcUtils.points_flag == 1 && displayMgr.isZflag() == true) {
Iterator<String> iter = dataMap.keySet().iterator();

View file

@ -714,7 +714,7 @@ public class PointPrecipPlotResource extends
this.paintProps = paintProps;
MPEDisplayManager displayMgr = getResourceData().getMPEDisplayManager();
// Fonts are shared and cached, no need to init or dispose
font = fontFactory.getMPEFont(displayMgr.getFontState());
font = fontFactory.getMPEFont(MPEDisplayManager.getFontId());
if (DailyQcUtils.points_flag == 1 && displayMgr.isQpf() == true) {
Iterator<String> iter = dataMap.keySet().iterator();

View file

@ -555,7 +555,7 @@ public class PointTempPlotResource extends
this.paintProps = paintProps;
MPEDisplayManager displayMgr = getResourceData().getMPEDisplayManager();
// Fonts are shared and cached, no need to init or dispose
font = fontFactory.getMPEFont(displayMgr.getFontState());
font = fontFactory.getMPEFont(MPEDisplayManager.getFontId());
if (DailyQcUtils.points_flag == 1 && displayMgr.isMaxmin() == true) {
Iterator<String> iter = dataMap.keySet().iterator();

View file

@ -22,7 +22,6 @@ package com.raytheon.viz.mpe.ui.rsc;
import java.awt.Rectangle;
import java.nio.FloatBuffer;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.measure.converter.UnitConverter;
@ -38,7 +37,6 @@ import com.raytheon.uf.common.colormap.Color;
import com.raytheon.uf.common.colormap.ColorMap;
import com.raytheon.uf.common.dataplugin.shef.tables.Colorvalue;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
import com.raytheon.uf.common.hydro.spatial.HRAP;
import com.raytheon.uf.common.hydro.spatial.HRAPCoordinates;
import com.raytheon.uf.common.hydro.spatial.HRAPSubGrid;
@ -56,6 +54,7 @@ import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.MapDescriptor;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.GenericResourceData;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
import com.raytheon.uf.viz.core.style.DataMappingPreferences;
@ -87,7 +86,7 @@ import com.vividsolutions.jts.geom.Coordinate;
*/
public class RadarCoverageResource extends
AbstractVizResource<XmrgResourceData, MapDescriptor> implements
AbstractVizResource<GenericResourceData, MapDescriptor> implements
IMpeResource {
private static final String RADAR_COVERAGE = "Radar Coverage Map";
@ -425,36 +424,6 @@ public class RadarCoverageResource extends
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.rsc.AbstractVizResource#inspect(com.raytheon
* .uf.viz.core.geospatial.ReferencedCoordinate)
*/
@Override
public String inspect(ReferencedCoordinate coord) throws VizException {
Map<String, Object> Values = interrogate(coord);
if (Values == null) {
return "NO DATA";
} else {
return Values.get("Value").toString();
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.rsc.AbstractVizResource#interrogate(com.raytheon
* .uf.viz.core.geospatial.ReferencedCoordinate)
*/
@Override
public Map<String, Object> interrogate(ReferencedCoordinate coord)
throws VizException {
return null;
}
/**
* Update the Xmrg Display.
*

View file

@ -73,7 +73,7 @@ public class RadarGageOverlayRsc extends
public RadarGageOverlayRsc(RadarGageOverlayRscData radarGageOverlayRscData,
LoadProperties loadProperties) {
super(radarGageOverlayRscData, loadProperties);
currentdate = MPEDisplayManager.getCurrent().getCurrentDate();
currentdate = MPEDisplayManager.getCurrent().getCurrentEditDate();
addPoints(getGages(currentdate));
getCapability(ColorableCapability.class).setColor(
getResourceData().getColor());

View file

@ -1,411 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.mpe.ui.rsc;
import java.awt.Rectangle;
import java.io.IOException;
import java.nio.Buffer;
import java.nio.FloatBuffer;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TimeZone;
import javax.measure.converter.UnitConverter;
import javax.measure.unit.NonSI;
import javax.measure.unit.SI;
import javax.measure.unit.Unit;
import org.eclipse.swt.graphics.RGB;
import org.geotools.coverage.grid.GridGeometry2D;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import com.raytheon.uf.common.colormap.Color;
import com.raytheon.uf.common.colormap.ColorMap;
import com.raytheon.uf.common.dataplugin.shef.tables.Colorvalue;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.hydro.spatial.HRAPCoordinates;
import com.raytheon.uf.common.hydro.spatial.HRAPSubGrid;
import com.raytheon.uf.common.mpe.util.XmrgFile;
import com.raytheon.uf.common.ohd.AppsDefaults;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.util.FileUtil;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.RGBColors;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.MapDescriptor;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
import com.raytheon.uf.viz.core.style.DataMappingPreferences;
import com.raytheon.uf.viz.core.style.DataMappingPreferences.DataMappingEntry;
import com.raytheon.viz.core.rsc.displays.GriddedImageDisplay2;
import com.raytheon.viz.hydrocommon.HydroConstants;
import com.raytheon.viz.mpe.core.MPEDataManager;
import com.raytheon.viz.mpe.core.MPEDataManager.MPERadarLoc;
import com.raytheon.viz.mpe.ui.DisplayFieldData;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.MPEDisplayManager.DisplayMode;
/**
* The Time Lapse looping functionality display resource.
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Aug 11, 2009 mpduff Initial creation
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
public class TimeLapseResource extends
AbstractVizResource<XmrgResourceData, MapDescriptor> implements
IMpeResource {
private final MPEDisplayManager displayMgr;
private final List<Colorvalue> colorSet;
private ColorMapParameters parameters;
private final DisplayFieldData dataType;
private Map<DataTime, GriddedImageDisplay2> bufferMap;
private final HashMap<DataTime, GriddedImageData> dataMap;
private XmrgFile xmrg;
private short[] data;
private HRAPSubGrid subGrid;
private GridGeometry2D gridGeometry;
private boolean keepLooping = false;
protected DataTime displayedDate;
private static final SimpleDateFormat sdf;
private static class GriddedImageData {
Buffer buff = null;
GridGeometry2D geometry = null;
}
static {
sdf = new SimpleDateFormat("MMM dd yyyy HH");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
}
public TimeLapseResource(MPEDisplayManager displayMgr,
DisplayFieldData dataType, List<Colorvalue> colorSet) {
super(new XmrgResourceData(), new LoadProperties());
this.displayMgr = displayMgr;
this.dataType = dataType;
this.colorSet = colorSet;
dataTimes = new ArrayList<DataTime>();
descriptor = (MapDescriptor) MPEDisplayManager.getCurrent()
.getRenderableDisplay().getDescriptor();
dataMap = new HashMap<DataTime, GriddedImageData>();
loadData();
}
@Override
protected void disposeInternal() {
if (bufferMap != null) {
bufferMap.clear();
}
for (DataTime dTime : bufferMap.keySet()) {
GriddedImageDisplay2 gDisplay = bufferMap.get(dTime);
if (gDisplay != null) {
gDisplay.dispose();
}
}
bufferMap.clear();
}
private void loadData() {
AppsDefaults appsDefaults = AppsDefaults.getInstance();
ColorMap colorMap = new ColorMap(colorSet.size());
DisplayFieldData fieldData = displayMgr.getDisplayFieldType();
colorMap.setName(fieldData.getCv_use());
DataMappingPreferences dmPref = new DataMappingPreferences();
int index = 0;
for (Colorvalue cv : colorSet) {
RGB rgb = RGBColors.getRGBColor(cv.getColorname().getColorName());
colorMap.setColor(index, new Color(rgb.red / 255f,
rgb.green / 255f, rgb.blue / 255f));
DataMappingEntry entry = new DataMappingEntry();
entry.setPixelValue((double) index);
entry.setDisplayValue(cv.getId().getThresholdValue());
dmPref.addEntry(entry);
index++;
}
DataMappingEntry entry = new DataMappingEntry();
entry.setPixelValue((double) (index - 1));
entry.setDisplayValue(Double.MAX_VALUE);
dmPref.addEntry(entry);
dmPref.getEntries().get(0).setLabel("");
dmPref.getEntries().get(1).setLabel("");
ColorMapCapability cmc = getCapability(ColorMapCapability.class);
parameters = cmc.getColorMapParameters();
if (parameters == null) {
parameters = new ColorMapParameters();
cmc.setColorMapParameters(parameters);
}
parameters.setColorMap(colorMap);
parameters.setDataMapping(dmPref);
Unit<?> displayUnit = NonSI.INCH;
Unit<?> dataUnit = SI.MILLIMETER.divide(100);
parameters.setFormatString("0.00");
switch (dataType) {
case Locbias:
displayUnit = Unit.ONE;
dataUnit = Unit.ONE.divide(100);
break;
case Height:
displayUnit = NonSI.FOOT;
dataUnit = SI.METER;
break;
case Index:
int j = 2;
for (MPERadarLoc radar : MPEDataManager.getInstance().getRadars()) {
dmPref.getEntries().get(j++).setLabel(radar.getId());
}
while (j < dmPref.getEntries().size()) {
dmPref.getEntries().get(j++).setLabel("");
}
case Locspan:
dmPref.getEntries().get(1).setLabel("mis");
displayUnit = Unit.ONE;
dataUnit = Unit.ONE;
break;
case Prism:
displayUnit = NonSI.INCH;
dataUnit = SI.MILLIMETER;
parameters.setFormatString("0.00");
break;
case mintempPrism:
case maxtempPrism:
displayUnit = NonSI.FAHRENHEIT;
dataUnit = NonSI.FAHRENHEIT.divide(10);
break;
default:
displayUnit = NonSI.INCH;
dataUnit = SI.MILLIMETER.divide(100);
parameters.setFormatString("0.00");
}
parameters.setDisplayUnit(displayUnit);
parameters.setImageUnit(dmPref.getImageUnit(displayUnit));
parameters.setDataUnit(dataUnit);
parameters.setColorMapMax(parameters.getColorMap().getSize() - 1);
parameters.setColorMapMin(0);
parameters.setDataMax(parameters.getColorMap().getSize() - 1);
parameters.setDataMin(0);
UnitConverter cvt = parameters.getDataToImageConverter();
// Get all the files for the loop
try {
String cv_use = dataType.getCv_use();
String dirname = appsDefaults.getToken(dataType.getDirToken());
String fname = "";
// lapse hours
int nhours = displayMgr.getTimeLapseHours();
bufferMap = new HashMap<DataTime, GriddedImageDisplay2>(nhours);
Calendar cal1 = Calendar.getInstance((TimeZone.getTimeZone("GMT")));
cal1.setTime(displayMgr.getCurrentDate());
Calendar cal2 = Calendar.getInstance((TimeZone.getTimeZone("GMT")));
cal2.setTime(cal1.getTime());
for (int i = 0; i < nhours; i++) {
cal2.setTime(cal1.getTime());
cal2.add(Calendar.SECOND,
-(i * HydroConstants.SECONDS_PER_HOUR));
DataTime dTime = new DataTime(cal2.getTime());
dataTimes.add(dTime);
String dtform = HydroConstants.FILE_DATE_FORMAT.format(cal2
.getTime());
fname = FileUtil.join(dirname, cv_use + dtform + "z");
XmrgFile wmrg = null;
try {
wmrg = new XmrgFile(fname);
wmrg.load();
} catch (IOException io) {
System.out.println("XMRG file not found " + fname);
continue;
}
xmrg = wmrg;
if (xmrg.getHrapExtent() == null) {
continue;
}
data = xmrg.getData();
Rectangle extent = xmrg.getHrapExtent();
FloatBuffer buf = FloatBuffer.allocate(data.length);
for (short s : data) {
float f = (float) Math.floor(cvt.convert(s));
buf.put(f);
}
buf.rewind();
if ((extent.x == 0) && (extent.y == 0)) {
Rectangle coord = HRAPCoordinates.getHRAPCoordinates();
if ((extent.width == coord.width)
&& (extent.height == coord.height)) {
extent = coord;
} else {
xmrg = null;
return;
}
}
subGrid = new HRAPSubGrid(extent);
gridGeometry = MapUtil.getGridGeometry(subGrid);
GriddedImageData grid = new GriddedImageData();
grid.geometry = gridGeometry;
grid.buff = buf;
dataMap.put(dTime, grid);
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
protected void initInternal(IGraphicsTarget target) throws VizException {
}
@Override
protected void paintInternal(IGraphicsTarget target,
PaintProperties paintProps) throws VizException {
displayedDate = paintProps.getDataTime();
if ((bufferMap == null) || (displayedDate == null)
|| (MPEDisplayManager.getCurrent().isTimeLapseMode() == false)) {
return;
}
Set<DisplayMode> mode = displayMgr.getDisplayMode();
if (mode.contains(DisplayMode.Image)) {
GriddedImageDisplay2 gridDisplay = bufferMap.get(displayedDate);
if (gridDisplay == null) {
GriddedImageData dat = dataMap.get(displayedDate);
gridDisplay = new GriddedImageDisplay2(dat.buff, dat.geometry,
this);
bufferMap.put(displayedDate, gridDisplay);
// project(gridGeometry.getCoordinateReferenceSystem());
gridDisplay = bufferMap.get(displayedDate);
}
if (gridDisplay != null) {
gridDisplay.paint(target, paintProps);
}
}
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.core.rsc.IVizResource#getName()
*/
@Override
public String getName() {
if (xmrg == null) {
return "No Data Available";
}
if (displayedDate == null) {
return "No Data Available";
}
return sdf.format(displayedDate.getRefTime()) + "z site="
+ MPEDataManager.getInstance().getRFC() + " "
+ dataType.toString();
}
@Override
public void project(CoordinateReferenceSystem mapData) throws VizException {
for (DataTime dTime : bufferMap.keySet()) {
GriddedImageDisplay2 gDisplay = bufferMap.get(dTime);
if (gDisplay != null) {
gDisplay.project(descriptor.getGridGeometry());
}
}
}
/**
* @return the keepLooping
*/
public boolean isKeepLooping() {
return keepLooping;
}
/**
* @param keepLooping
* the keepLooping to set
*/
public void setKeepLooping(boolean keepLooping) {
this.keepLooping = keepLooping;
}
}

View file

@ -1,85 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.mpe.ui.rsc;
import java.util.List;
import com.raytheon.uf.common.dataplugin.shef.tables.Colorvalue;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.viz.mpe.ui.DisplayFieldData;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
/**
* TODO Add Description
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 8, 2010 mpduff Initial creation
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
public class TimeLapseResourceData extends AbstractRequestableResourceData {
private DisplayFieldData displayFieldType = null;
private List<Colorvalue> gageColorMap = null;
/**
* @param displayFieldType2
* @param gageColorMap2
*/
public TimeLapseResourceData(DisplayFieldData displayFieldType,
List<Colorvalue> gageColorMap) {
this.displayFieldType = displayFieldType;
this.gageColorMap = gageColorMap;
}
/* (non-Javadoc)
* @see com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData#construct(com.raytheon.uf.viz.core.rsc.LoadProperties, com.raytheon.uf.viz.core.drawables.IDescriptor)
*/
@Override
public AbstractVizResource<?, ?> construct(LoadProperties loadProperties,
IDescriptor descriptor) throws VizException {
return new TimeLapseResource(MPEDisplayManager.getCurrent(), displayFieldType, gageColorMap);
}
/* (non-Javadoc)
* @see com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData#constructResource(com.raytheon.uf.viz.core.rsc.LoadProperties, com.raytheon.uf.common.dataplugin.PluginDataObject[])
*/
@Override
protected AbstractVizResource<?, ?> constructResource(
LoadProperties loadProperties, PluginDataObject[] objects)
throws VizException {
return new TimeLapseResource(MPEDisplayManager.getCurrent(), displayFieldType, gageColorMap);
}
}

View file

@ -1,861 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.mpe.ui.rsc;
import java.awt.Point;
import java.awt.Rectangle;
import java.io.IOException;
import java.nio.FloatBuffer;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TimeZone;
import javax.measure.converter.UnitConverter;
import javax.measure.unit.NonSI;
import javax.measure.unit.SI;
import javax.measure.unit.Unit;
import org.apache.commons.lang.StringUtils;
import org.eclipse.swt.graphics.RGB;
import org.geotools.coverage.grid.GridGeometry2D;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.datum.PixelInCell;
import com.raytheon.uf.common.colormap.Color;
import com.raytheon.uf.common.colormap.ColorMap;
import com.raytheon.uf.common.dataplugin.shef.tables.Colorvalue;
import com.raytheon.uf.common.geospatial.ISpatialQuery;
import com.raytheon.uf.common.geospatial.ISpatialQuery.SearchMode;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
import com.raytheon.uf.common.geospatial.SpatialQueryFactory;
import com.raytheon.uf.common.geospatial.SpatialQueryResult;
import com.raytheon.uf.common.hydro.spatial.HRAP;
import com.raytheon.uf.common.hydro.spatial.HRAPCoordinates;
import com.raytheon.uf.common.hydro.spatial.HRAPSubGrid;
import com.raytheon.uf.common.mpe.util.XmrgFile;
import com.raytheon.uf.common.ohd.AppsDefaults;
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.util.FileUtil;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle;
import com.raytheon.uf.viz.core.RGBColors;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.MapDescriptor;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
import com.raytheon.uf.viz.core.style.DataMappingPreferences;
import com.raytheon.uf.viz.core.style.DataMappingPreferences.DataMappingEntry;
import com.raytheon.viz.core.ColorUtil;
import com.raytheon.viz.core.contours.rsc.displays.GriddedContourDisplay;
import com.raytheon.viz.core.rsc.displays.GriddedImageDisplay.GriddedImagePaintProperties;
import com.raytheon.viz.core.rsc.displays.GriddedImageDisplay2;
import com.raytheon.viz.mpe.core.MPEDataManager;
import com.raytheon.viz.mpe.core.MPEDataManager.MPERadarLoc;
import com.raytheon.viz.mpe.ui.DisplayFieldData;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
import com.raytheon.viz.mpe.ui.MPEDisplayManager.DisplayMode;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.GeometryFactory;
/**
* Resource to display data from XMRG file format
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 23, 2008 randerso Initial creation
* Sep 5, 2012 15079 snaples Updated interrogate method to handle values without rounding errors.
* Jan 7, 2013 15483 wkwock Fix the "Radar coverage field" error
* </pre>
*
* @author randerso
* @version 1.0
*/
public class XmrgResource extends
AbstractVizResource<XmrgResourceData, MapDescriptor> implements
IMpeResource {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(XmrgResource.class);
private static final SimpleDateFormat sdf;
private static final SimpleDateFormat sds;
private static final SimpleDateFormat sdx;
static {
sdf = new SimpleDateFormat("MMM dd yyyy HH");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
sds = new SimpleDateFormat("yyyyMMddHH");
sds.setTimeZone(TimeZone.getTimeZone("GMT"));
sdx = new SimpleDateFormat("MMddyyyyHH");
sdx.setTimeZone(TimeZone.getTimeZone("GMT"));
}
private static final GeometryFactory gf = new GeometryFactory();
private static final double MILLICVT = 25.4;
private XmrgFile xmrg;
private HRAPSubGrid subGrid;
private GriddedImageDisplay2 gridDisplay;
private ColorMapParameters parameters;
private final float brightness = 1.0f;
private final float contrast = 1.0f;
private final boolean isInterpolated = true;
private final MPEDisplayManager displayMgr;
private GriddedContourDisplay contourDisplay;
private GridGeometry2D gridGeometry;
private FloatBuffer buf;
private FloatBuffer cbuf;
private final List<Colorvalue> colorSet;
private final DisplayFieldData dataType;
private short[] data;
private final AppsDefaults appsDefaults = AppsDefaults.getInstance();
private UnitConverter cvt;
private UnitConverter cCvt;
private DataMappingPreferences dmPref;
public XmrgResource(MPEDisplayManager displayMgr,
DisplayFieldData dataType, XmrgFile xmrg, List<Colorvalue> colorSet) {
super(new XmrgResourceData(), new LoadProperties());
this.displayMgr = displayMgr;
this.dataType = dataType;
this.xmrg = xmrg;
this.colorSet = colorSet;
setColorMapParams();
loadData();
}
public XmrgResource(XmrgResourceData xmrgResourceData,
MPEDisplayManager displayMgr, DisplayFieldData dataType,
XmrgFile xmrg, List<Colorvalue> colorSet) {
super(xmrgResourceData, new LoadProperties());
this.displayMgr = displayMgr;
this.dataType = dataType;
this.xmrg = xmrg;
this.colorSet = colorSet;
setColorMapParams();
loadData();
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.core.rsc.IVizResource#dispose()
*/
@Override
protected void disposeInternal() {
if (gridDisplay != null) {
gridDisplay.dispose();
gridDisplay = null;
}
if (contourDisplay != null) {
contourDisplay.dispose();
contourDisplay = null;
}
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.core.rsc.IVizResource#getName()
*/
@Override
public String getName() {
String timeSlot = "";
Date cd = displayMgr.getCurrentDate();
Calendar cl = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
cl.setTime(cd);
if (xmrg == null) {
timeSlot = sdf.format(cd);
return timeSlot + "z site="
+ MPEDataManager.getInstance().getRFC() + " "
+ "No Data Available";
}
// Subtract 10 days from date to make sure that file header has valid
// time. Some data files have epoch date in header, instead of a valid
// date.
cl.add(Calendar.SECOND, -(10 * 86400));
if (xmrg.getHeader().getValidDate().before(cl.getTime())) {
timeSlot = sdf.format(cd);
} else {
timeSlot = sdf.format(xmrg.getHeader().getValidDate());
}
return timeSlot + "z site=" + MPEDataManager.getInstance().getRFC()
+ " " + dataType.toString();
}
/*
* (non-Javadoc)
*
* @seecom.raytheon.viz.core.rsc.IVizResource#init(com.raytheon.viz.core.
* IGraphicsTarget)
*/
@Override
protected void initInternal(IGraphicsTarget target) {
}
private void loadData() {
String cv_use = dataType.getCv_use();
if (displayMgr.getAccum_interval() > 1) {
// this will accumulate all hours requested and display it
// this holds current xmrg values
short[] tempdata = null;
Rectangle extent = null;
try {
extent = HRAPCoordinates.getHRAPCoordinates();
} catch (Exception e) {
// TODO Auto-generated catch block. Please revise as
// appropriate.
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
int datasz = extent.height * extent.width;
// this is used to accumulate all hours
data = new short[datasz];
String dirname = appsDefaults.getToken(dataType.getDirToken());
String fname = "";
int numhours = displayMgr.getAccum_interval();
int secsPerHr = 3600;
buf = FloatBuffer.allocate(datasz);
cbuf = FloatBuffer.allocate(datasz);
Calendar cal1 = Calendar.getInstance((TimeZone.getTimeZone("GMT")));
cal1.setTime(displayMgr.getCurrentDate());
Calendar cal2 = Calendar.getInstance((TimeZone.getTimeZone("GMT")));
cal2.setTime(cal1.getTime());
try {
for (int k = 0; k < numhours; k++) {
cal2.setTime(cal1.getTime());
cal2.add(Calendar.SECOND, -(k * secsPerHr));
String dtform = "";
// If first time through skip loading file
// as it has been loaded already
// if (k != 0) {
if (cv_use.equals("XMRG")) {
dtform = sdx.format(cal2.getTime());
fname = FileUtil.join(dirname, cv_use.toLowerCase()
+ dtform + "z");
} else {
dtform = sds.format(cal2.getTime());
fname = FileUtil.join(dirname, cv_use + dtform + "z");
}
XmrgFile wmrg = null;
try {
wmrg = new XmrgFile(fname);
wmrg.load();
} catch (IOException io) {
System.out.println("XMRG file not found " + fname);
continue;
}
xmrg = wmrg;
extent = xmrg.getHrapExtent();
// }// End if (k != 0)
tempdata = xmrg.getData();
int c = 0;
for (short s : tempdata) {
if (data[c] < 0 && s >= 0) {
data[c] = s;
} else if (data[c] >= 0 && s > 0) {
data[c] += s;
}
c++;
}
}
float f = 0;
// Don't convert missing data, checking to see if we are using
// Temperature data
String temps = "TEMP";
int tempsval = cv_use.indexOf(temps);
for (short s : data) {
if (cv_use.equalsIgnoreCase("Locspan")
|| cv_use.equalsIgnoreCase("Locbias")
|| cv_use.equalsIgnoreCase("Index")) {
// f = s;
f = (float) Math.floor(cvt.convert(s));
} else if (s < 0) {
if (s == -9999 || s == -999 || s == -99
|| (s == -9 && tempsval == -1)) {
f = 0;
} else if (s == -8888 || s == -899) {
f = 1;
} else {
f = (float) Math.floor(cvt.convert(s));
}
} else {
if (s < 30 && s > 24) {
s = 26;
} else if (s > 0 && s <= 24) {
s = 0;
}
f = (float) Math.floor(cvt.convert(s));
}
float g = (float) cCvt.convert(s);
buf.put(f);
if (g < 0) {
g = 0;
}
cbuf.put(g);
}
buf.rewind();
cbuf.rewind();
if ((extent.x == 0) && (extent.y == 0)) {
Rectangle coord = HRAPCoordinates.getHRAPCoordinates();
if ((extent.width == coord.width)
&& (extent.height == coord.height)) {
extent = coord;
} else {
xmrg = null;
return;
}
}
subGrid = new HRAPSubGrid(extent);
gridGeometry = MapUtil.getGridGeometry(subGrid);
project(gridGeometry.getCoordinateReferenceSystem());
} catch (Exception e) {
xmrg = null;
System.err.println("XMRG file not found " + fname);
}
} else {
// this loads only the current working hour requested
try {
xmrg.load();
data = xmrg.getData();
buf = FloatBuffer.allocate(data.length);
cbuf = FloatBuffer.allocate(data.length);
// Don't convert missing data, checking to see if we are using
// Temperature data
String temps = "TEMP";
int tempsval = cv_use.indexOf(temps);
float f = 0;
for (short s : data) {
if (cv_use.equalsIgnoreCase("Locspan")
|| cv_use.equalsIgnoreCase("Locbias")
|| cv_use.equalsIgnoreCase("Index")) {
// f = s;
f = (float) Math.floor(cvt.convert(s));
} else if (s < 0) {
if (s == -9999 || s == -999 || s == -99
|| (s == -9 && tempsval == -1)) {
f = 0;
} else if (s == -8888 || s == -899) {
f = 1;
} else {
f = (float) Math.floor(cvt.convert(s));
}
} else {
if (s < 30 && s > 24) {
s = 26;
} else if (s > 0 && s <= 24) {
s = 0;
}
f = (float) Math.floor(cvt.convert(s));
}
float g = (float) cCvt.convert(s);
buf.put(f);
if (g < 0) {
g = 0;
}
cbuf.put(g);
}
buf.rewind();
cbuf.rewind();
Rectangle extent = xmrg.getHrapExtent();
if ((extent.x == 0) && (extent.y == 0)) {
Rectangle coord = HRAPCoordinates.getHRAPCoordinates();
if ((extent.width == coord.width)
&& (extent.height == coord.height)) {
extent = coord;
} else {
xmrg = null;
return;
}
}
subGrid = new HRAPSubGrid(extent);
gridGeometry = MapUtil.getGridGeometry(subGrid);
project(gridGeometry.getCoordinateReferenceSystem());
} catch (Exception e) {
xmrg = null;
System.err.println("XMRG file not found");
}
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.core.drawables.IRenderable#paint(com.raytheon.viz.core
* .IGraphicsTarget, com.raytheon.viz.core.drawables.PaintProperties)
*/
@Override
protected void paintInternal(IGraphicsTarget target,
PaintProperties paintProps) throws VizException {
if (buf == null) {
return;
}
Set<DisplayMode> mode = displayMgr.getDisplayMode();
if (mode.contains(DisplayMode.Image)) {
if (gridDisplay == null) {
gridDisplay = new GriddedImageDisplay2(buf, gridGeometry, this);
}
GriddedImagePaintProperties giProps = new GriddedImagePaintProperties(
paintProps, brightness, contrast, isInterpolated);
gridDisplay.paint(target, giProps);
}
if (mode.contains(DisplayMode.Contour)) {
if (contourDisplay == null) {
contourDisplay = new GriddedContourDisplay(descriptor,
gridGeometry, cbuf);
contourDisplay.setColor(ColorUtil.WHITE);
contourDisplay.setLineStyle(LineStyle.SOLID);
contourDisplay.setOutlineWidth(1);
}
contourDisplay.paint(target, paintProps);
}
}
@Override
public void project(CoordinateReferenceSystem mapData) throws VizException {
if (gridDisplay != null) {
gridDisplay.dispose();
gridDisplay = null;
}
if (contourDisplay != null) {
contourDisplay.dispose();
contourDisplay = null;
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.rsc.AbstractVizResource#inspect(com.raytheon
* .uf.viz.core.geospatial.ReferencedCoordinate)
*/
@Override
public String inspect(ReferencedCoordinate coord) throws VizException {
Map<String, Object> Values = interrogate(coord);
if (Values == null) {
return "NO DATA";
} else {
return Values.get("Value").toString();
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.rsc.AbstractVizResource#interrogate(com.raytheon
* .uf.viz.core.geospatial.ReferencedCoordinate)
*/
@Override
public Map<String, Object> interrogate(ReferencedCoordinate coord)
throws VizException {
if (xmrg == null) {
return null;
}
Map<String, Object> values = new HashMap<String, Object>();
try {
Coordinate gridCell = coord.asGridCell(HRAP.getInstance()
.getGridGeometry(), PixelInCell.CELL_CENTER);
Point p = new Point((int) gridCell.x, (int) gridCell.y);
Coordinate l = coord.asLatLon();
values.put("X", Integer.toString(p.x));
values.put("Y", Integer.toString(p.y));
values.put("Lon", String.format("%5.2f", l.x));
values.put("Lat", String.format("%4.2f", l.y));
values.put("Value", "-----");
values.put("County", "Not Defined");
values.put("Basin", "Not Defined");
Rectangle extent = subGrid.getExtent();
if (extent.contains(p)) {
int x = p.x - extent.x;
int y = extent.height - 1 - (p.y - extent.y);
short s = data[(y * subGrid.getNx()) + x];
String cv_use = dataType.getCv_use();
if (cv_use.equalsIgnoreCase("INDEX")) {
values.put("Value", parameters.getLabels().get(s + 1)
.getText());
} else {
String tmps = "TEMP";
int tempsval = dataType.getCv_use().indexOf(tmps);
float f = 0;
if (s < 0) {
if (s == -9999 || s == -999 || s == -99
|| (s == -9 && tempsval == -1)) {
f = s;
} else if (s == -8888 || s == -899) {
f = s;
} else {
f = (float) parameters.getDataToDisplayConverter()
.convert(s);
}
} else {
if (s < 30 && s > 24) {
s = 26;
} else if (s > 0 && s <= 24) {
s = 0;
}
if ((cv_use.equalsIgnoreCase("Locbias")
|| cv_use.equalsIgnoreCase("height")
|| cv_use.equalsIgnoreCase("locspan") || tempsval == -1)) {
f = (float) parameters.getDataToDisplayConverter()
.convert(s);
} else {
f = (float) (s / 100 / MILLICVT);
}
}
String da = String.format("%2.2f", f);
values.put("Value", da);
}
}
ISpatialQuery query = SpatialQueryFactory.create();
com.vividsolutions.jts.geom.Point point = gf.createPoint(coord
.asLatLon());
SpatialQueryResult[] results = query.query("county",
new String[] { "countyname" }, point, null, false,
SearchMode.WITHIN);
String county = null;
if ((results != null) && (results.length > 0)) {
county = (String) results[0].attributes.get("countyname");
}
if (!StringUtils.isBlank(county)) {
values.put("County", county);
}
results = query.query("basins", new String[] { "name" }, point,
null, false, SearchMode.WITHIN);
String basin = null;
if ((results != null) && (results.length > 0)) {
basin = (String) results[0].attributes.get("name");
}
if (!StringUtils.isBlank(basin)) {
values.put("Basin", basin);
}
} catch (Exception e) {
throw new VizException("Error performing interrogation", e);
}
return values;
}
/**
* Update the Xmrg Display.
*
* @param reload
* Reread the data from the file if true
*/
public void updateXmrg(boolean reload) {
if (xmrg == null) {
return;
}
String cv_use = dataType.getCv_use();
try {
cvt = parameters.getDataToImageConverter();
if (reload || (data == null)) {
// this.recycle();
// this.init(displayMgr.getDisplayPane().getTarget());
data = xmrg.getData();
}
buf = FloatBuffer.allocate(data.length);
// Don't convert missing data, checking to see if we are using
// Temperature data
String temps = "TEMP";
int tempsval = dataType.getCv_use().indexOf(temps);
float f = 0;
for (short s : data) {
if (cv_use.equalsIgnoreCase("Locspan")
|| cv_use.equalsIgnoreCase("Locbias")
|| cv_use.equalsIgnoreCase("Index")) {
// f = s;
f = (float) Math.floor(cvt.convert(s));
} else if (s < 0) {
if (s == -9999 || s == -999 || s == -99
|| (s == -9 && tempsval == -1)) {
f = 0;
} else if (s == -8888 || s == -899) {
f = 1;
} else {
f = (float) Math.floor(cvt.convert(s));
}
} else {
if (s < 30 && s > 24) {
s = 26;
} else if (s > 0 && s <= 24) {
s = 0;
}
f = (float) Math.floor(cvt.convert(s));
}
float g = (float) cCvt.convert(s);
buf.put(f);
if (g < 0) {
g = 0;
}
cbuf.put(g);
}
buf.rewind();
cbuf.rewind();
Rectangle extent = xmrg.getHrapExtent();
if (extent == null) {
xmrg = null;
return;
}
if ((extent.x == 0) && (extent.y == 0)) {
Rectangle coord = HRAPCoordinates.getHRAPCoordinates();
if ((extent.width == coord.width)
&& (extent.height == coord.height)) {
extent = coord;
} else {
xmrg = null;
return;
}
}
subGrid = new HRAPSubGrid(extent);
gridGeometry = MapUtil.getGridGeometry(subGrid);
project(gridGeometry.getCoordinateReferenceSystem());
issueRefresh();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* @return the xmrg
*/
public XmrgFile getXmrgFile() {
return xmrg;
}
/**
* @return the data
*/
public short[] getData() {
return data;
}
/**
* @param data
* the data to set
*/
public void setData(short[] dta) {
data = null;
data = dta;
}
private void setColorMapParams() {
ColorMap colorMap = new ColorMap(colorSet.size());
colorMap.setName(dataType.getCv_use());
dmPref = new DataMappingPreferences();
int i = 0;
for (Colorvalue cv : colorSet) {
RGB rgb = RGBColors.getRGBColor(cv.getColorname().getColorName());
colorMap.setColor(i, new Color(rgb.red / 255f, rgb.green / 255f,
rgb.blue / 255f));
DataMappingEntry entry = new DataMappingEntry();
entry.setPixelValue((double) i);
entry.setDisplayValue(cv.getId().getThresholdValue());
dmPref.addEntry(entry);
i++;
}
DataMappingEntry entry = new DataMappingEntry();
entry.setPixelValue((double) (i - 1));
entry.setDisplayValue(Double.MAX_VALUE);
dmPref.addEntry(entry);
dmPref.getEntries().get(0).setLabel("");
dmPref.getEntries().get(1).setLabel("");
ColorMapCapability cmc = getCapability(ColorMapCapability.class);
parameters = cmc.getColorMapParameters();
if (parameters == null) {
parameters = new ColorMapParameters();
cmc.setColorMapParameters(parameters);
}
parameters.setColorMap(colorMap);
parameters.setDataMapping(dmPref);
Unit<?> displayUnit = Unit.ONE;
Unit<?> dataUnit = Unit.ONE;
switch (dataType) {
case Locbias:
displayUnit = Unit.ONE;
dataUnit = Unit.ONE.divide(100);
break;
case Height:
displayUnit = NonSI.FOOT;
dataUnit = SI.METER;
break;
case Index:
List<MPERadarLoc> radars= MPEDataManager.getInstance().getRadars();
for (int k=dmPref.getEntries().size();k<radars.size()+2;k++){
DataMappingEntry dme = new DataMappingEntry();
dme.setPixelValue((double) (k));
dme.setDisplayValue(Double.MAX_VALUE);
dmPref.addEntry(dme);
}
int j = 2;
for (MPERadarLoc radar : radars) {
dmPref.getEntries().get(j++).setLabel(radar.getId());
}
while (j < dmPref.getEntries().size()) {
dmPref.getEntries().get(j++).setLabel("");
}
case Locspan:
dmPref.getEntries().get(1).setLabel("mis");
displayUnit = Unit.ONE;
dataUnit = Unit.ONE;
break;
case Prism:
displayUnit = NonSI.INCH;
dataUnit = SI.MILLIMETER;
parameters.setFormatString("0.00");
break;
case mintempPrism:
case maxtempPrism:
displayUnit = NonSI.FAHRENHEIT;
dataUnit = NonSI.FAHRENHEIT.divide(10);
break;
case srMosaic:
case sgMosaic:
case srgMosaic:
case satPre:
case lsatPre:
displayUnit = NonSI.INCH;
dataUnit = SI.MILLIMETER.divide(100);
parameters.setFormatString("0.00");
break;
default:
displayUnit = NonSI.INCH;
dataUnit = SI.MILLIMETER.divide(100);
parameters.setFormatString("0.00");
}
parameters.setDisplayUnit(displayUnit);
parameters.setImageUnit(dmPref.getImageUnit(displayUnit));
parameters.setDataUnit(dataUnit);
parameters.setColorMapMax(parameters.getColorMap().getSize() - 1);
parameters.setColorMapMin(0);
parameters.setDataMax(parameters.getColorMap().getSize() - 1);
parameters.setDataMin(0);
cvt = parameters.getDataToImageConverter();
cCvt = parameters.getDataToDisplayConverter();
cmc.setColorMapParameters(parameters);
}
public MPEDisplayManager getDisplayMgr() {
return displayMgr;
}
public DisplayFieldData getDataType() {
return dataType;
}
}

View file

@ -1,153 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.mpe.ui.rsc;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import com.raytheon.uf.common.dataplugin.shef.tables.Colorvalue;
import com.raytheon.uf.common.mpe.util.XmrgFile;
import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.AbstractResourceData;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.viz.hydrocommon.util.MPEColors;
import com.raytheon.viz.hydrocommon.whfslib.colorthreshold.GetColorValues;
import com.raytheon.viz.mpe.ui.DisplayFieldData;
import com.raytheon.viz.mpe.ui.MPEDisplayManager;
/**
* The Xmrg Resource Data
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 27, 2009 randerso Initial creation
*
* </pre>
*
* @author randerso
* @version 1.0
*/
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement(name = "xmrgResourceData")
@XmlType(name = "xmrgResourceData", namespace = "com.raytheon.viz.mpe.ui.rsc.XmrgResourceData")
public class XmrgResourceData extends AbstractResourceData {
private final MPEDisplayManager dm;
@XmlElement
private DisplayFieldData dt;
@XmlElement
private XmrgFile xmfile;
private List<Colorvalue> colors;
public XmrgResourceData() {
IDisplayPane pane = null;
dm = MPEDisplayManager.getInstance(pane);
}
/**
* @param displayManager
* @param displayFieldType
* @param xmrg
* @param colorSet
*/
public XmrgResourceData(MPEDisplayManager displayManager,
DisplayFieldData displayFieldType, XmrgFile xmrg,
List<Colorvalue> colorSet) {
dm = displayManager;
dt = displayFieldType;
xmfile = xmrg;
colors = colorSet;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.rsc.AbstractResourceData#construct(com.raytheon
* .uf.viz.core.comm.LoadProperties,
* com.raytheon.uf.viz.core.drawables.IDescriptor)
*/
@Override
public XmrgResource construct(LoadProperties loadProperties,
IDescriptor descriptor) throws VizException {
if (colors == null) {
String user_id = System.getProperty("user.name");
colors = GetColorValues.get_colorvalues(user_id,
MPEDisplayManager.APPLICATION_NAME, dt.getCv_use(),
dt.getCv_duration(), "E", MPEColors.build_mpe_colors());
dm.setDisplayFieldType(dt);
}
return new XmrgResource(this, dm, dt, xmfile, colors);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.rsc.AbstractResourceData#update(java.lang.Object
* )
*/
@Override
public void update(Object updateData) {
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((dm == null) ? 0 : dm.hashCode());
return result;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (getClass() != obj.getClass()) {
return false;
}
return true;
}
}

View file

@ -300,9 +300,7 @@ public class RegenHrFlds {
e.printStackTrace();
}
MPEDataManager.getInstance().readGageData(datetime, datetime);
/* Read radar data */
MPEDataManager.getInstance().readRadarData(datetime);
/* Clear gage edits */
MPEDataManager.getInstance().clearEditGages();
shell.setCursor(prev);
}
@ -361,11 +359,11 @@ public class RegenHrFlds {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
int hr = dt.get(Calendar.HOUR_OF_DAY);
//
if (hr==0) {
hr=24;
dt.add(Calendar.DAY_OF_MONTH, -1);
if (hr == 0) {
hr = 24;
dt.add(Calendar.DAY_OF_MONTH, -1);
}
String where = "WHERE lid='" + id + "' AND pe='PP'" + " AND dur="

View file

@ -68,7 +68,9 @@ public class HRAPCoordinates {
+ " in coordinate file: " + coordFile.getAbsolutePath(), e);
} finally {
try {
in.close();
if (in != null) {
in.close();
}
} catch (IOException e) {
e.printStackTrace();
}