Issue #2703 Hook GFEResource into KML Export.

Change-Id: I3baeb829dec4fa650fa9cb86e4fe602b6ad47963

Former-commit-id: 7b1245b0cf [formerly 547e9ac7212b5a9842d064d5669772e8e50a4828]
Former-commit-id: 1897336455
This commit is contained in:
Ben Steffensmeier 2014-01-23 17:37:48 -06:00
parent 922cd8c3a2
commit 48bb8a59a1
14 changed files with 432 additions and 153 deletions

View file

@ -2,26 +2,19 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: KML Export
Bundle-SymbolicName: com.raytheon.uf.viz.kml.export;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.raytheon.uf.viz.kml.export.Activator
Eclipse-RegisterBuddy: com.raytheon.uf.common.serialization
Bundle-Version: 1.14.0.qualifier
Bundle-Vendor: RAYTHEON
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
com.raytheon.uf.common.serialization;bundle-version="1.12.1174",
org.geotools;bundle-version="2.6.4",
com.raytheon.uf.viz.core;bundle-version="1.12.1174",
com.raytheon.uf.viz.core.rsc;bundle-version="1.0.0",
com.raytheon.uf.common.geospatial;bundle-version="1.12.1174",
com.raytheon.uf.common.colormap;bundle-version="1.12.1174",
com.raytheon.uf.common.time;bundle-version="1.12.1174",
com.raytheon.viz.ui;bundle-version="1.12.1174",
com.raytheon.uf.viz.core.maps;bundle-version="1.12.1174",
de.micromata.opengis.kml;bundle-version="1.0.0",
com.raytheon.viz.pointdata;bundle-version="1.12.1174",
com.raytheon.viz.radar;bundle-version="1.12.1174",
com.raytheon.uf.common.dataplugin.radar;bundle-version="1.0.0",
javax.measure;bundle-version="1.0.0",
javax.vecmath;bundle-version="1.3.1"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Require-Bundle: org.eclipse.core.runtime,
com.raytheon.uf.viz.core;bundle-version="1.14.0",
com.raytheon.viz.ui;bundle-version="1.14.0",
de.micromata.opengis.kml,
com.raytheon.uf.common.geospatial,
com.raytheon.uf.common.colormap,
com.raytheon.uf.common.time,
com.raytheon.uf.viz.core.maps,
com.raytheon.viz.pointdata,
com.raytheon.viz.radar,
javax.measure
Export-Package: com.raytheon.uf.viz.kml.export

View file

@ -1,50 +0,0 @@
package com.raytheon.uf.viz.kml.export;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* 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.uf.viz.kml.export"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
/*
* (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

@ -54,9 +54,11 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 5, 2012 bsteffen Initial creation
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Jun 05, 2012 bsteffen Initial creation
* Jan 23, 2014 2703 bsteffen Enable subclasses to add custom frame
* selection options.
*
* </pre>
*
@ -66,7 +68,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
public class KmlExportDialog extends CaveSWTDialog {
private final KmlExportOptions options;
protected final KmlExportOptions options;
private Text locationText;
@ -477,7 +479,7 @@ public class KmlExportDialog extends CaveSWTDialog {
options.setFirstFrameIndex(frame);
options.setLastFrameIndex(frame + 1);
}
} else {
} else if (selectedFramesButton.getSelection()) {
try {
int from = Integer.parseInt(framesFromText.getText()) - 1;
options.setFirstFrameIndex(from);

View file

@ -98,9 +98,11 @@ import de.micromata.opengis.kml.v_2_2_0.Vec2;
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 6, 2012 bsteffen Initial creation
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Jun0 6, 2012 bsteffen Initial creation
* Jan 23, 2014 2703 bsteffen Use framesInfo for frame count.
*
*
* </pre>
*
@ -301,7 +303,8 @@ public class KmlExportJob extends Job {
int startIndex = options.getFirstFrameIndex();
startIndex = Math.max(startIndex, 0);
int lastIndex = options.getLastFrameIndex();
lastIndex = Math.min(lastIndex, descriptor.getNumberOfFrames());
lastIndex = Math.min(lastIndex, descriptor.getFramesInfo()
.getFrameCount());
rscmonitor.beginTask("Saving " + rsc.getName(), lastIndex
- startIndex);
DataTime[] times = descriptor.getFramesInfo().getTimeMap()
@ -518,6 +521,7 @@ public class KmlExportJob extends Job {
try {
Thread.sleep(options.getPaintSleepMillis());
} catch (InterruptedException e) {
/* When interupted try again right away. */
}
if (monitor.isCanceled()) {
break;
@ -535,7 +539,7 @@ public class KmlExportJob extends Job {
}
private void addColorMap(KmlOutputManager out, RGB backcolor,
AbstractVizResource<?, ?> rsc) throws IOException {
AbstractVizResource<?, ?> rsc) {
ColorMapParameters parameters = null;
if (rsc.hasCapability(ColorMapCapability.class)) {
ColorMapCapability cap = rsc
@ -643,6 +647,7 @@ public class KmlExportJob extends Job {
try {
Thread.sleep(300);
} catch (InterruptedException e) {
/* When interupted move on right away. */
}
int r = backgroundPool.getWorkRemaining();
monitor.worked(remaining - r);

View file

@ -51,9 +51,10 @@ import com.raytheon.uf.viz.core.exception.VizException;
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 1, 2012 bsteffen Initial creation
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Jun 01, 2012 bsteffen Initial creation
* Jan 23, 2014 2703 bsteffen Use data to get width and height.
*
* </pre>
*
@ -64,9 +65,9 @@ public class KmlColormappedImage extends KmlImage implements IColormappedImage {
private final IColorMapDataRetrievalCallback dataCallback;
private ColorMapParameters colorMapParameters;
private ColorMapData data;
private Unit<?> dataUnit;
private ColorMapParameters colorMapParameters;
public KmlColormappedImage(IColorMapDataRetrievalCallback dataCallback,
ColorMapParameters colorMapParameters) {
@ -74,9 +75,21 @@ public class KmlColormappedImage extends KmlImage implements IColormappedImage {
this.colorMapParameters = colorMapParameters;
}
/**
* Use the callback to retrieve the data, width, height, and dataUnit. If
* the data has not been loaded {@link #getDataUnit()}, {@link #getWidth()}.
* {@link #getHeight()} will not return correct values.
*
* @throws VizException
*/
public void loadData() throws VizException {
if (this.data == null) {
this.data = dataCallback.getColorMapData();
}
}
public DataSource getData(GridGeometry2D geometry) throws VizException {
ColorMapData data = dataCallback.getColorMapData();
this.dataUnit = data.getDataUnit();
loadData();
switch (data.getDataType()) {
case FLOAT:
return new FloatBufferWrapper(((FloatBuffer) data.getBuffer()),
@ -127,15 +140,33 @@ public class KmlColormappedImage extends KmlImage implements IColormappedImage {
return 0;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.drawables.IColormappedImage#getDataUnit()
*/
@Override
public Unit<?> getDataUnit() {
Unit<?> dataUnit = null;
if (data != null) {
dataUnit = data.getDataUnit();
}
return dataUnit == null ? getColorMapParameters().getDataUnit()
: dataUnit;
}
@Override
public int getWidth() {
if (data != null) {
return data.getDimensions()[0];
} else {
return super.getWidth();
}
}
@Override
public int getHeight() {
if (data != null) {
return data.getDimensions()[1];
} else {
return super.getHeight();
}
}
}

View file

@ -30,11 +30,13 @@ import java.util.Map.Entry;
import org.geotools.coverage.grid.GridEnvelope2D;
import org.geotools.coverage.grid.GridGeometry2D;
import org.geotools.coverage.grid.InvalidGridGeometryException;
import org.geotools.geometry.DirectPosition2D;
import org.geotools.geometry.Envelope2D;
import org.opengis.coverage.grid.GridEnvelope;
import org.opengis.geometry.Envelope;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;
import com.raytheon.uf.common.colormap.prefs.ColorMapParameters;
@ -44,6 +46,8 @@ 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.DrawableImage;
import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback;
import com.raytheon.uf.viz.core.drawables.IColormappedImage;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
@ -63,9 +67,11 @@ import com.raytheon.uf.viz.kml.export.io.KmlOutputManager;
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 1, 2012 bsteffen Initial creation
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Jun 01, 2012 bsteffen Initial creation
* Jan 23, 2014 2703 bsteffen Enable drawing with no mesh.
*
*
* </pre>
*
@ -119,7 +125,43 @@ public class KmlColormappedImageExtension extends
for (DrawableImage image : images) {
KmlColormappedImage kmlImage = (KmlColormappedImage) image
.getImage();
KmlMesh mesh = (KmlMesh) image.getCoverage().getMesh();
PixelCoverage coverage = image.getCoverage();
KmlMesh mesh = (KmlMesh) coverage.getMesh();
if (mesh == null){
try {
kmlImage.loadData();
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
continue;
}
MathTransform grid2crs = gridGeometry.getGridToCRS();
IExtent extent = coverage.getExtent();
DirectPosition2D minCorner = new DirectPosition2D(
extent.getMinX(), extent.getMinY());
DirectPosition2D maxCorner = new DirectPosition2D(
extent.getMaxX(), extent.getMaxY());
try {
grid2crs.transform(minCorner, minCorner);
grid2crs.transform(maxCorner, maxCorner);
} catch (TransformException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
continue;
}
CoordinateReferenceSystem crs = gridGeometry
.getCoordinateReferenceSystem();
minCorner.setCoordinateReferenceSystem(crs);
maxCorner.setCoordinateReferenceSystem(crs);
Envelope userRange = new Envelope2D(minCorner, maxCorner);
GridEnvelope gridRange = new GridEnvelope2D(0, 0,
kmlImage.getWidth(), kmlImage.getHeight());
GridGeometry2D imageGeometry = new GridGeometry2D(
gridRange, userRange);
mesh = new KmlMesh(imageGeometry);
}
try {
if (params == null) {
params = kmlImage.getColorMapParameters();

View file

@ -33,7 +33,8 @@ Require-Bundle: org.eclipse.ui,
com.google.guava;bundle-version="1.0.0",
com.raytheon.uf.common.style;bundle-version="1.0.0",
com.raytheon.uf.common.activetable,
com.raytheon.uf.viz.image.export;bundle-version="1.14.0"
com.raytheon.uf.viz.image.export;bundle-version="1.14.0",
com.raytheon.uf.viz.kml.export
Bundle-ActivationPolicy: lazy
Export-Package: com.raytheon.viz.gfe,
com.raytheon.viz.gfe.constants,

View file

@ -983,6 +983,15 @@
definitionId="com.raytheon.viz.gfe.inGFEActionSet">
</reference>
</activeWhen>
</handler>
<handler
class="com.raytheon.viz.gfe.export.kml.GfeKmlExportHandler"
commandId="com.raytheon.uf.viz.kml.export.exportKML">
<activeWhen>
<reference
definitionId="com.raytheon.viz.gfe.inGFEActionSet">
</reference>
</activeWhen>
</handler>
</extension>
<extension point="com.raytheon.uf.viz.core.resource">

View file

@ -30,6 +30,11 @@ import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlTransient;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.DataTime;
@ -54,23 +59,27 @@ import com.raytheon.viz.gfe.rsc.GFEResource;
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 14, 2012 mschenke Initial creation
* Feb 26, 2013 #1708 randerso Fixed double notification for time change
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Nov 14, 2012 mschenke Initial creation
* Feb 26, 2013 1708 randerso Fixed double notification for time change
* Jan 23, 2014 2703 bsteffen Add JAXB Annotations.
*
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
@XmlAccessorType(XmlAccessType.NONE)
public class GFETimeMatcher extends AbstractTimeMatcher {
/** The selected date, added as a extra frame if not null */
@XmlAttribute
private Date selectedDate;
/** Set of resources used in calculating the descriptor times */
@XmlTransient
private Set<GFEResource> tmbResources = new HashSet<GFEResource>();
/*

View file

@ -79,52 +79,60 @@ public class GfeImageExportDialog extends ImageExportDialog {
@Override
protected void okPressed() {
if (selectedFrameRangeButton.getSelection()) {
DataManager dataManager = DataManagerUIFactory.getCurrentInstance();
ParmOp parmOp = dataManager.getParmOp();
TimeRange selectedRange = parmOp.getSelectionTimeRange();
if (selectedRange == null || !selectedRange.isValid()) {
MessageBox mb = new MessageBox(getShell(), SWT.ICON_ERROR
| SWT.OK);
mb.setText("No Time Range Selected");
mb.setMessage("No Time Range is selected, select a time range in the grid manager.");
mb.open();
return;
}
IDisplayPaneContainer container = EditorUtil
.getActiveVizContainer();
IDisplayPane pane = container.getActiveDisplayPane();
IRenderableDisplay renderableDispaly = pane.getRenderableDisplay();
IDescriptor descriptor = renderableDispaly.getDescriptor();
FramesInfo fi = descriptor.getFramesInfo();
DataTime[] times = fi.getFrameTimes();
int start = -1;
int end = -1;
for (int i = 0; i < times.length; i += 1) {
if (times[i] == null) {
continue;
}
TimeRange validRange = times[i].getValidPeriod();
if (selectedRange.overlaps(validRange)) {
if (start == -1) {
start = i;
}
end = i;
} else if (start != -1) {
break;
}
}
if (start == -1) {
MessageBox mb = new MessageBox(getShell(), SWT.ICON_ERROR
| SWT.OK);
mb.setText("Invalid Selection");
mb.setMessage("The selected time range does not contain any data, choose a new range.");
mb.open();
int[] frameRange = getSelectedFrameRange(getShell(),
renderableDispaly);
if(frameRange == null){
return;
}
options.setFrameSelection(FrameSelection.USER);
options.setFirstFrameIndex(start);
options.setLastFrameIndex(end + 1);
options.setFirstFrameIndex(frameRange[0]);
options.setLastFrameIndex(frameRange[1]);
}
super.okPressed();
}
public static int[] getSelectedFrameRange(Shell shell,
IRenderableDisplay renderableDispaly) {
DataManager dataManager = DataManagerUIFactory.getCurrentInstance();
ParmOp parmOp = dataManager.getParmOp();
TimeRange selectedRange = parmOp.getSelectionTimeRange();
if (selectedRange == null || !selectedRange.isValid()) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("No Time Range Selected");
mb.setMessage("No Time Range is selected, select a time range in the grid manager.");
mb.open();
return null;
}
IDescriptor descriptor = renderableDispaly.getDescriptor();
FramesInfo fi = descriptor.getFramesInfo();
DataTime[] times = fi.getFrameTimes();
int start = -1;
int end = -1;
for (int i = 0; i < times.length; i += 1) {
if (times[i] == null) {
continue;
}
TimeRange validRange = times[i].getValidPeriod();
if (selectedRange.overlaps(validRange)) {
if (start == -1) {
start = i;
}
end = i;
} else if (start != -1) {
break;
}
}
if (start == -1) {
MessageBox mb = new MessageBox(shell, SWT.ICON_ERROR | SWT.OK);
mb.setText("Invalid Selection");
mb.setMessage("The selected time range does not contain any data, choose a new range.");
mb.open();
return null;
}
return new int[] { start, end + 1 };
}
}

View file

@ -0,0 +1,87 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.viz.gfe.export.kml;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
import com.raytheon.uf.viz.kml.export.KmlExportDialog;
import com.raytheon.uf.viz.kml.export.KmlExportOptions;
import com.raytheon.uf.viz.kml.export.KmlPane;
import com.raytheon.viz.gfe.export.image.GfeImageExportDialog;
/**
* A custom {@link KmlExportDialog} for GFE which adds on option to use the Grid
* Manager Selected Time Range.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Jan 23, 2014 2702 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class GfeKmlExportDialog extends KmlExportDialog {
protected Button selectedFrameRangeButton;
public GfeKmlExportDialog(Shell shell, KmlExportOptions options) {
super(shell, options);
}
@Override
protected void initializeFramesGroup(Group group) {
super.initializeFramesGroup(group);
selectedFrameRangeButton = new Button(group, SWT.RADIO);
selectedFrameRangeButton.setText("Grid Manager Selected Time Range");
GridData gridData = new GridData();
gridData.horizontalSpan = 5;
selectedFrameRangeButton.setLayoutData(gridData);
}
@Override
protected void okPressed() {
if (selectedFrameRangeButton.getSelection()) {
KmlPane pane = options.getSinglPane();
IRenderableDisplay renderableDispaly = pane.getDisplay();
int[] frameRange = GfeImageExportDialog.getSelectedFrameRange(getShell(),
renderableDispaly);
if(frameRange == null){
return;
}
options.setFirstFrameIndex(frameRange[0]);
options.setLastFrameIndex(frameRange[1]);
}
super.okPressed();
}
}

View file

@ -0,0 +1,55 @@
/**
* 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.gfe.export.kml;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.handlers.HandlerUtil;
import com.raytheon.uf.viz.kml.export.KmlExportHandler;
/**
* A custom {@link KmlExportHandler} for GFE which allows adds options to the
* dialog.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Jan 23, 2014 2702 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class GfeKmlExportHandler extends KmlExportHandler {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
new GfeKmlExportDialog(HandlerUtil.getActiveShell(event),
getDefaultOptions()).open();
return null;
}
}

View file

@ -166,6 +166,7 @@ import com.vividsolutions.jts.geom.Envelope;
* Sep 23, 2013 2363 bsteffen Add more vector configuration options.
* Oct 31, 2013 2508 randerso Change to use DiscreteGridSlice.getKeys()
* Dec 11, 2013 2621 randerso Removed conditional from getParm so it never returns null
* Jan 23, 2014 2703 bsteffen Allow construction using a resourceData.
*
* </pre>
*
@ -301,7 +302,27 @@ public class GFEResource extends
* the datamanager responsible for it
*/
public GFEResource(Parm parm, DataManager dataManager) {
super(new GFEResourceData(), new LoadProperties());
this(new GFEResourceData(parm.getParmID()), new LoadProperties(), parm,
dataManager);
}
/**
* Same functionality as {@link #GFEResource(Parm, DataManager)} but uses a
* predefined resourceData.
*
* @param resourceData
* the resourceData
* @param loadProps
* the load properties
* @param parm
* the parm
* @param dataManager
* the datamanager responsible for it
*/
public GFEResource(GFEResourceData resourceData, LoadProperties loadProps,
Parm parm,
DataManager dataManager) {
super(resourceData, loadProps);
this.resourceData.addChangeListener(this);
this.parm = parm;
this.dataManager = dataManager;

View file

@ -21,47 +21,113 @@ package com.raytheon.viz.gfe.rsc;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID;
import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID;
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.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.viz.gfe.core.DataManager;
import com.raytheon.viz.gfe.core.DataManagerUIFactory;
import com.raytheon.viz.gfe.core.IParmManager;
import com.raytheon.viz.gfe.core.parm.Parm;
/**
* TODO Add Description
* Resource data for {@link GFEResource}. Saves information about the parm.
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 19, 2009 chammack Initial creation
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Jan 23, 2014 2703 bsteffen Rewrite to enable JAXB serialization and
* resource construction.
*
* </pre>
*
* @author chammack
* @version 1.0
* @author bsteffen
* @version 2.0
*/
@XmlAccessorType(XmlAccessType.NONE)
public class GFEResourceData extends AbstractResourceData {
@XmlAttribute
private String parmName;
@XmlAttribute
private String parmLevel;
@XmlAttribute
private String dbId;
public GFEResourceData() {
/* Empty constructor for JAXB */
}
public GFEResourceData(ParmID parmId) {
this.parmName = parmId.getParmName();
this.parmLevel = parmId.getParmLevel();
this.dbId = parmId.getDbId().toString();
}
@Override
public AbstractVizResource<?, ?> construct(LoadProperties loadProperties,
public GFEResource construct(LoadProperties loadProperties,
IDescriptor descriptor) throws VizException {
// TODO Auto-generated method stub
return null;
DataManager dataManager = DataManagerUIFactory.getCurrentInstance();
IParmManager parmManager = dataManager.getParmManager();
DatabaseID dbId = new DatabaseID(this.dbId);
ParmID parmId = new ParmID(this.parmName, dbId, this.parmLevel);
Parm parm = parmManager.getParm(parmId);
if (parm == null) {
parm = parmManager.addParm(parmId, false, true);
}
return new GFEResource(this, loadProperties, parm, dataManager);
}
@Override
public void update(Object updateData) {
// TODO Auto-generated method stub
/* Nothing uses updates */
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((dbId == null) ? 0 : dbId.hashCode());
result = prime * result
+ ((parmLevel == null) ? 0 : parmLevel.hashCode());
result = prime * result
+ ((parmName == null) ? 0 : parmName.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
return false;
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
GFEResourceData other = (GFEResourceData) obj;
if (dbId == null) {
if (other.dbId != null)
return false;
} else if (!dbId.equals(other.dbId))
return false;
if (parmLevel == null) {
if (other.parmLevel != null)
return false;
} else if (!parmLevel.equals(other.parmLevel))
return false;
if (parmName == null) {
if (other.parmName != null)
return false;
} else if (!parmName.equals(other.parmName))
return false;
return true;
}
}