Issue #358 Committing NPP core rendering improvements merged with Thin

Client core improvements

Former-commit-id: e2cd95d3f4 [formerly ae47d9683e] [formerly e2cd95d3f4 [formerly ae47d9683e] [formerly 48b6d45f00 [formerly 206bd0450140b6bcdb3ec8f1e1e417c4c37746d6]]]
Former-commit-id: 48b6d45f00
Former-commit-id: 0554abdde0 [formerly 3212cc6ebb]
Former-commit-id: 585e979c76
This commit is contained in:
Max Schenkelberg 2012-03-01 16:59:40 -06:00
parent 3433a1e31c
commit ae389f0b57
228 changed files with 6518 additions and 5259 deletions

View file

@ -20,6 +20,7 @@ Import-Package: com.raytheon.edex.meteoLib,
com.raytheon.uf.common.pointdata,
com.raytheon.uf.common.pointdata.spatial,
com.raytheon.uf.common.serialization,
com.raytheon.uf.common.status,
com.raytheon.uf.common.time,
com.raytheon.uf.viz.core.alerts,
com.raytheon.uf.viz.core.catalog,

View file

@ -39,14 +39,19 @@ import com.raytheon.uf.common.datastorage.records.IntegerDataRecord;
import com.raytheon.uf.common.datastorage.records.LongDataRecord;
import com.raytheon.uf.common.datastorage.records.StringDataRecord;
import com.raytheon.uf.common.pointdata.PointDataContainer;
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.catalog.ScriptCreator;
import com.raytheon.uf.viz.core.comm.Loader;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.derivparam.library.DerivedParameterGenerator;
import com.raytheon.viz.pointdata.util.PointDataCubeAdapter;
import com.raytheon.viz.pointdata.util.AbstractPointDataInventory;
import com.raytheon.viz.pointdata.util.PointDataCubeAdapter;
public class ACARSSoundingDataCubeAdapter extends PointDataCubeAdapter {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(ACARSSoundingDataCubeAdapter.class);
protected static final String REFTIME = AcarsSoundingInventory.REFTIME;
@ -101,11 +106,16 @@ public class ACARSSoundingDataCubeAdapter extends PointDataCubeAdapter {
@Override
public void initInventory() {
derParLibrary = DerivedParameterGenerator.getDerParLibrary();
if (inventory == null) {
AbstractPointDataInventory pointInventory = new AcarsSoundingInventory();
pointInventory.initTree(derParLibrary);
this.inventory = pointInventory;
try {
pointInventory.initTree(DerivedParameterGenerator
.getDerParLibrary());
this.inventory = pointInventory;
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
}
}

View file

@ -82,7 +82,7 @@ public class CoopPrecipDataCubeAdapter implements IDataCubeAdapter {
private static final PointDataDescription rtpDescription = new PointDataDescription();
static {
ffgDescription.parameters = new ParameterDescription[8];
ffgDescription.parameters = new ParameterDescription[9];
ffgDescription.parameters[0] = new ParameterDescription("time",
Type.LONG);
ffgDescription.parameters[1] = new ParameterDescription("latitude",
@ -98,8 +98,9 @@ public class CoopPrecipDataCubeAdapter implements IDataCubeAdapter {
ffgDescription.parameters[6] = new ParameterDescription("stationId",
Type.STRING);
ffgDescription.parameters[7] = new ParameterDescription("id", Type.INT);
ffgDescription.parameters[8] = new ParameterDescription("dataURI", Type.STRING);
rtpDescription.parameters = new ParameterDescription[6];
rtpDescription.parameters = new ParameterDescription[7];
rtpDescription.parameters[0] = new ParameterDescription("time",
Type.LONG);
rtpDescription.parameters[1] = new ParameterDescription("latitude",
@ -111,6 +112,8 @@ public class CoopPrecipDataCubeAdapter implements IDataCubeAdapter {
rtpDescription.parameters[4] = new ParameterDescription("stationId",
Type.STRING);
rtpDescription.parameters[5] = new ParameterDescription("id", Type.INT);
rtpDescription.parameters[6] = new ParameterDescription("dataURI", Type.STRING);
}
@Override
@ -238,6 +241,7 @@ public class CoopPrecipDataCubeAdapter implements IDataCubeAdapter {
pdv.setFloat("3hr", Float.valueOf(parts[1]));
pdv.setFloat("6hr", Float.valueOf(parts[2]));
pdv.setString("stationId", station);
pdv.setString("dataURI", "/textPoints/" + station + "/" + time);
// TODO this id is not really guaranteed to be unique
pdv.setInt("id", ((int) time) + station.hashCode());
}
@ -315,6 +319,7 @@ public class CoopPrecipDataCubeAdapter implements IDataCubeAdapter {
pdv.setFloat("latitude", (float) coord.latlon.y);
pdv.setFloat("precip", precip);
pdv.setString("stationId", station);
pdv.setString("dataURI", "/textPoints/" + station + "/" + time);
// TODO this id is not really guaranteed to be unique
pdv.setInt("id", ((int) time) + station.hashCode());
}
@ -402,12 +407,6 @@ public class CoopPrecipDataCubeAdapter implements IDataCubeAdapter {
return null;
}
@Override
public String recordKeyGenerator(PluginDataObject pdo) {
// TODO Auto-generated method stub
return null;
}
@Override
public void initInventory() {
// TODO Auto-generated method stub

View file

@ -69,7 +69,6 @@ public class CoopPrecipPlotInfoRetriever extends AbstractPlotInfoRetriever {
for (int uriCounter = 0; uriCounter < pdc.getCurrentSz(); uriCounter++) {
PointDataView pdv = pdc.readRandom(uriCounter);
PlotInfo stationInfo = new PlotInfo();
stationInfo.id = pdv.getInt("id");
stationInfo.latitude = pdv.getNumber("latitude").doubleValue();
stationInfo.longitude = pdv.getNumber("longitude")
.doubleValue();
@ -80,6 +79,7 @@ public class CoopPrecipPlotInfoRetriever extends AbstractPlotInfoRetriever {
stationInfo.pdv = new PlotData();
}
stationInfo.pdv.addData(pdv);
stationInfo.dataURI = pdv.getString("dataURI");
info.add(stationInfo);
}
}

View file

@ -133,11 +133,4 @@ public abstract class AbstractGraphicsFactoryAdapter {
public abstract Canvas constrcutCanvas(Composite canvasComp)
throws VizException;
/**
* Dispose of the canvas, it can be assumed the canvas is the same type
* created from constructCanvas
*
* @param canvas
*/
public abstract void disposeCanvas(Canvas canvas);
}

View file

@ -45,11 +45,16 @@ public class DrawableImage {
private PixelCoverage coverage;
private RasterMode mode = RasterMode.SYNCHRONOUS;
private RasterMode mode;
public DrawableImage(IImage image, PixelCoverage coverage) {
this(image, coverage, RasterMode.SYNCHRONOUS);
}
public DrawableImage(IImage image, PixelCoverage coverage, RasterMode mode) {
this.image = image;
this.coverage = coverage;
this.mode = mode;
}
public IImage getImage() {

View file

@ -39,6 +39,8 @@ import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
import com.raytheon.uf.viz.core.drawables.IShadedShape;
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension.IGraphicsExtensionInterface;
import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.geom.PixelCoordinate;
import com.vividsolutions.jts.geom.LinearRing;
@ -64,7 +66,7 @@ import com.vividsolutions.jts.geom.LinearRing;
* @author chammack
* @version 1
*/
public interface IGraphicsTarget {
public interface IGraphicsTarget extends IImagingExtension {
/** Defines alignment characteristics */
public static enum HorizontalAlignment {
@ -189,24 +191,6 @@ public interface IGraphicsTarget {
public abstract boolean drawRaster(IImage image, PixelCoverage extent,
PaintProperties paintProps) throws VizException;
/**
* Draw a raster to a target, given an extent and an alpha (transparency)
* value. Assumes synchronous operation.
*
* This operation will block on unavailable data.
*
* @param image
* the image reference object to draw
* @param extent
* the extent of the drawable area
* @param paintProps
* the paint properties
* @return status whether the raster was able to be drawn
* @throws VizException
*/
public abstract boolean drawRasters(PaintProperties paintProps,
DrawableImage... images) throws VizException;
/**
* Draw a raster to a target, given an extent and an alpha (transparency)
* value
@ -662,15 +646,6 @@ public interface IGraphicsTarget {
*/
public abstract boolean isNeedsRefresh();
/**
* Stage an image
*
* @param image
* the image to stage
* @throws VizException
*/
public abstract void stage(final IImage image) throws VizException;
/**
* Sets the background color of the panes.
*
@ -680,6 +655,10 @@ public interface IGraphicsTarget {
public abstract void setBackgroundColor(RGB backgroundColor);
/**
* DEPRECATED: This method has no effect. IGraphicsTargets are not
* responsible to drawing a colorbar. Use method drawColorRamp to draw a
* color ramp
*
* Sets whether to display a builtin colorbar when displaying colormapped
* images (Defaults to true)
*
@ -687,6 +666,7 @@ public interface IGraphicsTarget {
* boolean flag indicating whether to display the built in
* colorbar
*/
@Deprecated
public abstract void setUseBuiltinColorbar(boolean isColorbarDisplayed);
/**
@ -1044,6 +1024,6 @@ public interface IGraphicsTarget {
* @param extensionClass
* @return
*/
public abstract <T> T getExtension(Class<T> extensionClass)
throws VizException;
public abstract <T extends IGraphicsExtensionInterface> T getExtension(
Class<T> extensionClass) throws VizException;
}

View file

@ -38,8 +38,6 @@ import java.util.Map;
*/
public class AlertMessage {
/** The id of the alert */
public Integer id;
/** The raw string dataURI */
public String dataURI;

View file

@ -77,8 +77,6 @@ public class Colormapper {
boolean log = parameters.isLogarithmic();
double logFactor = parameters.getLogFactor();
boolean mirror = parameters.isMirror();
double naturalMin = parameters.getDataMin();
double naturalMax = parameters.getDataMax();
double cmapMin = parameters.getColorMapMin();
double cmapMax = parameters.getColorMapMax();
int colorMapSz = parameters.getColorMap().getSize();

View file

@ -34,7 +34,6 @@ import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
import com.raytheon.uf.common.dataquery.requests.TimeQueryRequest;
import com.raytheon.uf.common.dataquery.requests.TimeQueryRequestSet;
import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.StorageException;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
@ -42,10 +41,7 @@ import com.raytheon.uf.common.pointdata.PointDataContainer;
import com.raytheon.uf.common.time.BinOffset;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.catalog.LayerProperty;
import com.raytheon.uf.viz.core.catalog.ScriptCreator;
import com.raytheon.uf.viz.core.comm.Loader;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;
/**
* The DataCubeContainer is responsible for handling requests for data times,
@ -101,7 +97,7 @@ public class DataCubeContainer {
if (container.adapter != null) {
synchronized (container.adapter) {
Boolean initialized = initializedMap.get(container.adapter);
if (!initialized) {
if (initialized == null || !initialized) {
container.adapter.initInventory();
initializedMap.put(container.adapter, true);
}
@ -121,21 +117,9 @@ public class DataCubeContainer {
}
}
}
}
private IDataRecord[] getDataRecordInternal(PluginDataObject obj)
throws VizDataCubeException {
if (adapter != null) {
return adapter.getRecord(obj);
} else {
IDataRecord record = null;
try {
record = CubeUtil.retrieveData(obj, pluginName);
} catch (VizException e) {
throw new VizDataCubeException(
"Error retrieving 2D grid record.", e);
}
return new IDataRecord[] { record };
if (adapter == null) {
// Construct default adapter for plugin if none found
adapter = new DefaultDataCubeAdapter(plugin);
}
}
@ -153,23 +137,7 @@ public class DataCubeContainer {
*/
public static IDataRecord[] getDataRecord(PluginDataObject obj)
throws VizDataCubeException {
return getInstance(obj.getPluginName()).getDataRecordInternal(obj);
}
private IDataRecord[] getDataRecordInternal(PluginDataObject obj,
Request req, String dataset) throws VizDataCubeException {
if (adapter != null) {
return adapter.getRecord(obj, req, dataset);
} else {
IDataRecord record = null;
try {
record = CubeUtil.retrieveData(obj, pluginName, req, dataset);
} catch (VizException e) {
throw new VizDataCubeException(
"Error retrieving 2D grid record.", e);
}
return new IDataRecord[] { record };
}
return getInstance(obj.getPluginName()).adapter.getRecord(obj);
}
/**
@ -188,29 +156,10 @@ public class DataCubeContainer {
*/
public static IDataRecord[] getDataRecord(PluginDataObject obj,
Request req, String dataset) throws VizDataCubeException {
return getInstance(obj.getPluginName()).getDataRecordInternal(obj, req,
return getInstance(obj.getPluginName()).adapter.getRecord(obj, req,
dataset);
}
private void getDataRecordsInternal(List<PluginDataObject> objs,
Request req, String dataset) throws VizDataCubeException {
if (adapter != null) {
adapter.getRecords(objs, req, dataset);
} else {
for (PluginDataObject obj : objs) {
IDataRecord record = null;
try {
record = CubeUtil.retrieveData(obj, pluginName, req,
dataset);
} catch (VizException e) {
throw new VizDataCubeException(
"Error retrieving 2D grid record.", e);
}
obj.setMessageData(record);
}
}
}
/**
* For each PluginDataObject requests the DataRecords specified by Request
* and dataSet and stores those DataRecords in the PluginDataObject message
@ -238,41 +187,25 @@ public class DataCubeContainer {
"All PluginDataObjects must be for the same plugin");
}
}
getInstance(pluginName).getDataRecordsInternal(objs, req, dataset);
}
private PointDataContainer getPointDataInternal(String[] params,
Map<String, RequestConstraint> map) throws VizException {
if (adapter != null) {
return adapter.getPoints(pluginName, params, map);
} else {
return null;
}
getInstance(pluginName).adapter.getRecords(objs, req, dataset);
}
public static PointDataContainer getPointData(String plugin,
String[] params, Map<String, RequestConstraint> map)
throws VizException {
return getInstance(plugin).getPointDataInternal(params, map);
}
private PointDataContainer getPointDataInternal(String[] params,
String levelKey, Map<String, RequestConstraint> map)
throws VizException {
if (levelKey == null) {
return getPointData(pluginName, params, map);
}
if (adapter != null) {
return adapter.getPoints(pluginName, params, levelKey, map);
} else {
return null;
}
DataCubeContainer container = getInstance(plugin);
return container.adapter.getPoints(container.pluginName, params, map);
}
public static PointDataContainer getPointData(String plugin,
String[] params, String levelKey, Map<String, RequestConstraint> map)
throws VizException {
return getInstance(plugin).getPointDataInternal(params, levelKey, map);
DataCubeContainer container = getInstance(plugin);
if (levelKey == null) {
return getPointData(container.pluginName, params, map);
}
return container.adapter.getPoints(container.pluginName, params,
levelKey, map);
}
public static DataTime[] performTimeQuery(
@ -308,20 +241,6 @@ public class DataCubeContainer {
new DataTime[0]);
}
public List<List<DataTime>> performTimeQueriesInternal(
List<TimeQueryRequest> requests) throws VizException {
if (adapter == null) {
TimeQueryRequestSet set = new TimeQueryRequestSet();
set.setRequests(requests.toArray(new TimeQueryRequest[0]));
@SuppressWarnings("unchecked")
List<List<DataTime>> result = (List<List<DataTime>>) ThriftClient
.sendRequest(set);
return result;
} else {
return adapter.timeQuery(requests);
}
}
/**
* Perform a bulk time query request when all requests have the same plugin
* type.
@ -334,7 +253,7 @@ public class DataCubeContainer {
if (requests.isEmpty()) {
return Collections.emptyList();
}
return getInstance(pluginName).performTimeQueriesInternal(requests);
return getInstance(pluginName).adapter.timeQuery(requests);
}
/**
@ -346,8 +265,8 @@ public class DataCubeContainer {
*/
public static List<List<DataTime>> performTimeQueries(String pluginName,
TimeQueryRequest... requests) throws VizException {
return getInstance(pluginName).performTimeQueriesInternal(
Arrays.asList(requests));
return getInstance(pluginName).adapter.timeQuery(Arrays
.asList(requests));
}
/**
@ -403,17 +322,6 @@ public class DataCubeContainer {
return result;
}
private synchronized List<Object> getDataInternal(LayerProperty property,
int timeOut) throws VizException {
if (adapter == null) {
String scriptToExecute = ScriptCreator.createScript(property);
return Loader
.loadScripts(new String[] { scriptToExecute }, timeOut);
} else {
return adapter.getData(property, timeOut);
}
}
/**
* Returns a list of responses for the requested layer property. If a
* derived parameter, this will piece together the base parameteters.
@ -432,31 +340,11 @@ public class DataCubeContainer {
.getEntryQueryParameters(false);
String pluginName = originalQuery.get("pluginName")
.getConstraintValue();
return getInstance(pluginName).getDataInternal(property, timeOut);
}
private Object getInventoryInternal() {
if (adapter != null) {
return adapter.getInventory();
} else {
return null;
}
return getInstance(pluginName).adapter.getData(property, timeOut);
}
public static Object getInventory(String plugin) {
return getInstance(plugin).getInventoryInternal();
}
private List<Map<String, RequestConstraint>> getBaseUpdateConstraintsInternal(
Map<String, RequestConstraint> constraints) {
if (adapter != null) {
return adapter.getBaseUpdateConstraints(constraints);
} else {
List<Map<String, RequestConstraint>> result = new ArrayList<Map<String, RequestConstraint>>(
1);
result.add(constraints);
return result;
}
return getInstance(plugin).adapter.getInventory();
}
public static List<Map<String, RequestConstraint>> getBaseUpdateConstraints(
@ -467,8 +355,8 @@ public class DataCubeContainer {
&& pluginRC.getConstraintType() == ConstraintType.EQUALS) {
plugin = pluginRC.getConstraintValue();
}
return getInstance(plugin)
.getBaseUpdateConstraintsInternal(constraints);
return getInstance(plugin).adapter
.getBaseUpdateConstraints(constraints);
}
}

View file

@ -383,7 +383,7 @@ public class DecisionTree<T> {
}
protected List<DataPair> getDataPairs() {
return dataPairs;
return new ArrayList<DecisionTree<T>.DataPair>(dataPairs);
}
private static double calcEntropy(int numExamples, Integer[] values) {

View file

@ -0,0 +1,239 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.core.datastructure;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.dataquery.requests.TimeQueryRequest;
import com.raytheon.uf.common.dataquery.requests.TimeQueryRequestSet;
import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.pointdata.PointDataContainer;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.catalog.LayerProperty;
import com.raytheon.uf.viz.core.catalog.ScriptCreator;
import com.raytheon.uf.viz.core.comm.Loader;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;
/**
* Default implementation of IDataCubeAdapter, function implementations were
* moved from DataCubeContainer into here
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 7, 2011 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class DefaultDataCubeAdapter implements IDataCubeAdapter {
private String pluginName;
public DefaultDataCubeAdapter(String pluginName) {
this.pluginName = pluginName;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getSupportedPlugins
* ()
*/
@Override
public String[] getSupportedPlugins() {
return new String[] { pluginName };
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#timeQuery(java
* .util.List)
*/
@Override
public List<List<DataTime>> timeQuery(List<TimeQueryRequest> requests)
throws VizException {
TimeQueryRequestSet set = new TimeQueryRequestSet();
set.setRequests(requests.toArray(new TimeQueryRequest[0]));
@SuppressWarnings("unchecked")
List<List<DataTime>> result = (List<List<DataTime>>) ThriftClient
.sendRequest(set);
return result;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getPoints(java
* .lang.String, java.lang.String[], java.util.Map)
*/
@Override
public PointDataContainer getPoints(String plugin, String[] parameters,
Map<String, RequestConstraint> queryParams) throws VizException {
return null;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getPoints(java
* .lang.String, java.lang.String[], java.lang.String, java.util.Map)
*/
@Override
public PointDataContainer getPoints(String plugin, String[] parameters,
String levelKey, Map<String, RequestConstraint> queryParams)
throws VizException {
return null;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getRecord(com
* .raytheon.uf.common.dataplugin.PluginDataObject)
*/
@Override
public IDataRecord[] getRecord(PluginDataObject obj)
throws VizDataCubeException {
IDataRecord record = null;
try {
record = CubeUtil.retrieveData(obj, pluginName);
} catch (VizException e) {
throw new VizDataCubeException("Error retrieving 2D data record.",
e);
}
return new IDataRecord[] { record };
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getRecord(com
* .raytheon.uf.common.dataplugin.PluginDataObject,
* com.raytheon.uf.common.datastorage.Request, java.lang.String)
*/
@Override
public IDataRecord[] getRecord(PluginDataObject obj, Request req,
String dataset) throws VizDataCubeException {
IDataRecord record = null;
try {
record = CubeUtil.retrieveData(obj, pluginName, req, dataset);
} catch (VizException e) {
throw new VizDataCubeException("Error retrieving 2D data record.",
e);
}
return new IDataRecord[] { record };
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getRecords(java
* .util.List, com.raytheon.uf.common.datastorage.Request, java.lang.String)
*/
@Override
public void getRecords(List<PluginDataObject> objs, Request req,
String dataset) throws VizDataCubeException {
for (PluginDataObject obj : objs) {
IDataRecord record = null;
try {
record = CubeUtil.retrieveData(obj, pluginName, req, dataset);
} catch (VizException e) {
throw new VizDataCubeException(
"Error retrieving 2D grid record.", e);
}
obj.setMessageData(record);
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getData(com.raytheon
* .uf.viz.core.catalog.LayerProperty, int)
*/
@Override
public List<Object> getData(LayerProperty property, int timeOut)
throws VizException {
String scriptToExecute = ScriptCreator.createScript(property);
return Loader.loadScripts(new String[] { scriptToExecute }, timeOut);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#initInventory()
*/
@Override
public void initInventory() {
// TODO Auto-generated method stub
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getInventory()
*/
@Override
public Object getInventory() {
// TODO Auto-generated method stub
return null;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#
* getBaseUpdateConstraints(java.util.Map)
*/
@Override
public List<Map<String, RequestConstraint>> getBaseUpdateConstraints(
Map<String, RequestConstraint> constraints) {
List<Map<String, RequestConstraint>> result = new ArrayList<Map<String, RequestConstraint>>(
1);
result.add(constraints);
return result;
}
}

View file

@ -145,16 +145,6 @@ public interface IDataCubeAdapter {
public List<Object> getData(LayerProperty property, int timeOut)
throws VizException;
/**
* A simple method that will create a unique string based on the information
* in the PluginDataObject passed in.
*
* @param pdo
* The PDO to generate a unique name from
* @return A string unique to that PDO
*/
public String recordKeyGenerator(PluginDataObject pdo);
/**
* If the inventory for a particular data type is large (for example, Grib),
* a call to this method should get a copy of that data type's inventory

View file

@ -206,8 +206,8 @@ public class ColorMapLoader {
ColorMap cm = (ColorMap) SerializationUtil
.jaxbUnmarshalFromXmlFile(colorMapFile.getFile()
.getAbsolutePath());
cm.setName(name);
cm.setChanged(false);
return cm;
} else {
return null;

View file

@ -22,6 +22,8 @@ package com.raytheon.uf.viz.core.drawables;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import javax.measure.converter.UnitConverter;
import javax.measure.unit.Unit;
@ -116,7 +118,7 @@ public class ColorMapParameters implements Cloneable, ISerializableObject {
}
protected IColorMapParametersListener listener;
protected Set<IColorMapParametersListener> listeners = new HashSet<IColorMapParametersListener>();
/** Units of the colormap parameters (min/max) */
protected Unit<?> displayUnit;
@ -714,13 +716,19 @@ public class ColorMapParameters implements Cloneable, ISerializableObject {
}
private void notifyListener() {
if (listener != null) {
for (IColorMapParametersListener listener : listeners) {
listener.colorMapChanged();
}
}
public void setListener(IColorMapParametersListener listener) {
this.listener = listener;
public void addListener(IColorMapParametersListener listener) {
if (listener != null) {
listeners.add(listener);
}
}
public void removeListener(IColorMapParametersListener listener) {
listeners.remove(listener);
}
public void setAlphaMask(byte[] alphaMask) {
@ -741,8 +749,8 @@ public class ColorMapParameters implements Cloneable, ISerializableObject {
@Override
public int hashCode() {
if (listener != null) {
return listener.hashCode();
if (listeners.size() > 0) {
return listeners.hashCode();
} else if (colorMap != null) {
return colorMap.hashCode();
} else {

View file

@ -20,6 +20,9 @@
package com.raytheon.uf.viz.core.drawables;
import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension;
import com.raytheon.uf.viz.core.exception.VizException;
/**
* Describes a generic Image resource. The IImage resource is an interface
* handle to an image. The image resource manages the lifecycle of the
@ -63,6 +66,11 @@ public interface IImage {
UNLOADED, STAGED, LOADED, LOADING, FAILED, INVALID
};
/**
* Stages any data required for the image to load/draw
*/
public abstract void stage() throws VizException;
/**
* @return the status
*/
@ -106,4 +114,10 @@ public interface IImage {
*/
public abstract void setContrast(float contrast);
/**
* Gets the extension class for this image
*
* @return
*/
public abstract Class<? extends IImagingExtension> getExtensionClass();
}

View file

@ -1,66 +0,0 @@
package com.raytheon.uf.viz.core.drawables;
import org.eclipse.swt.graphics.RGB;
public class SingleColorImage implements IImage {
private IImage image = null;
private RGB color = null;
public IImage getWrappedImage() {
return image;
}
public void setWrappedImage(IImage image) {
this.image = image;
}
public void setColor(RGB color) {
this.color = color;
}
public RGB getColor() {
return color;
}
public SingleColorImage(IImage image) {
this.image = image;
}
@Override
public Status getStatus() {
return image.getStatus();
}
@Override
public void setInterpolated(boolean isInterpolated) {
image.setInterpolated(isInterpolated);
}
@Override
public void dispose() {
image.dispose();
}
@Override
public int getWidth() {
return image.getWidth();
}
@Override
public int getHeight() {
return image.getHeight();
}
@Override
public void setBrightness(float brightness) {
image.setBrightness(brightness);
}
@Override
public void setContrast(float contrast) {
image.setContrast(contrast);
}
}

View file

@ -40,15 +40,22 @@ import com.raytheon.uf.viz.core.IGraphicsTarget;
*/
public abstract class GraphicsExtension<T extends IGraphicsTarget> {
public static enum Compatibilty {
INCOMPATIBLE(-1), GENERIC(0), TARGET_COMPATIBLE(1000), ENHANCED_TARGET_COMPATIBLE(
2000);
/**
* Interface that other interfaces should extend if they want to be used as
* a graphics extension
*/
public static interface IGraphicsExtensionInterface {
public int value;
}
private Compatibilty(int value) {
this.value = value;
}
public static class Compatibilty {
public static final int INCOMPATIBLE = -1;
public static final int GENERIC = 0;
public static final int TARGET_COMPATIBLE = 1000;
public static final int ENHANCED_TARGET_COMPATIBLE = 2000;
}
protected T target;
@ -70,7 +77,7 @@ public abstract class GraphicsExtension<T extends IGraphicsTarget> {
try {
this.target = (T) target;
} catch (ClassCastException e) {
return Compatibilty.INCOMPATIBLE.value;
return Compatibilty.INCOMPATIBLE;
}
return getCompatibilityValue(this.target);
}

View file

@ -15,6 +15,7 @@ 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.IGraphicsTarget;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension.IGraphicsExtensionInterface;
import com.raytheon.uf.viz.core.exception.VizException;
public class GraphicsExtensionManager {
@ -67,8 +68,8 @@ public class GraphicsExtensionManager {
* @return
* @throws VizException
*/
public synchronized <T> T getExtension(Class<T> extensionClass)
throws VizException {
public synchronized <T extends IGraphicsExtensionInterface> T getExtension(
Class<T> extensionClass) throws VizException {
if (cached.containsKey(extensionClass)) {
return extensionClass.cast(cached.get(extensionClass));
}

View file

@ -17,24 +17,23 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.radar.gl.mosaic;
package com.raytheon.uf.viz.core.drawables.ext;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.DrawableImage;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension.IGraphicsExtensionInterface;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.viz.core.gl.IGLTarget;
import com.raytheon.viz.core.gl.glsl.AbstractShaderLoader;
import com.raytheon.viz.core.gl.glsl.GLShaderProgram;
/**
* TODO Add Description
* Interface extensions that return IImage objects should implement
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 20, 2010 mschenke Initial creation
* Dec 15, 2011 mschenke Initial creation
*
* </pre>
*
@ -42,22 +41,17 @@ import com.raytheon.viz.core.gl.glsl.GLShaderProgram;
* @version 1.0
*/
public class CompReflShaderLoader extends AbstractShaderLoader {
public interface IImagingExtension extends IGraphicsExtensionInterface {
/*
* (non-Javadoc)
/**
* Draw the images passed in
*
* @see
* com.raytheon.viz.core.gl.glsl.IShaderLoader#loadData(com.raytheon.viz
* .core.gl.IGLTarget, com.raytheon.viz.core.gl.glsl.GLShaderProgram,
* com.raytheon.uf.viz.core.drawables.IImage,
* com.raytheon.uf.viz.core.drawables.PaintProperties)
* @param paintProps
* @param images
* @return whether all images were drawn or not
* @throws VizException
*/
@Override
public void loadData(IGLTarget target, GLShaderProgram program,
IImage image, PaintProperties paintProps) throws VizException {
// load radar data to GL_TEXTURE0 (bound in drawRaster)
program.setUniform("radarData", 0);
}
public boolean drawRasters(PaintProperties paintProps,
DrawableImage... images) throws VizException;
}

View file

@ -4,9 +4,11 @@ import java.nio.Buffer;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension.IGraphicsExtensionInterface;
import com.raytheon.uf.viz.core.exception.VizException;
public interface IOffscreenRenderingExtension {
public interface IOffscreenRenderingExtension extends
IGraphicsExtensionInterface {
/**
* All drawing between a call to renderOffscreen and the next call to
* renderOnscreen will be drawn to offscreenImage rather than to the screen.

View file

@ -17,52 +17,49 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.core.drawables.ext;
package com.raytheon.viz.core.gl.glsl;
import java.awt.image.RenderedImage;
import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.exception.VizException;
/**
* Define common interface for vertex and fragement shaders.
* Extension for creating images that should be mapped to a single color
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
*
* Dec 15, 2011 mschenke Initial creation
*
* </pre>
*
* @author estrabal
* @author mschenke
* @version 1.0
*/
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.viz.core.gl.IGLTarget;
public interface ISingleColorImageExtension extends IImagingExtension {
public interface IShaderLoader {
public static interface ISingleColorImage extends IImage {
public void setColor(RGB color);
}
/**
* Construct an ISingleColorImage image that maps the image passed into to
* the single color value
*
* @return
*/
public abstract String getName();
/**
*
* @param name
*/
public abstract void setName(String name);
/**
* load shader variables using IImage and PaintProperties
*
* @param target
* @param program
* @param image
* @param paintProps
* @param color
* @return
* @throws VizException
*/
public abstract void loadData(IGLTarget target, GLShaderProgram program,
IImage image, PaintProperties paintProps) throws VizException;
public ISingleColorImage constructImage(RenderedImage image, RGB color);
}

View file

@ -0,0 +1,240 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.core.drawables.ext.colormap;
import java.awt.image.RenderedImage;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback;
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback.ColorMapData;
import com.raytheon.uf.viz.core.data.IRenderedImageCallback;
import com.raytheon.uf.viz.core.data.prep.Colormapper;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.IColorMapParametersListener;
import com.raytheon.uf.viz.core.drawables.IColormappedImage;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension;
import com.raytheon.uf.viz.core.exception.VizException;
/**
* General colormapped image, regenerates image if parameters change
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 16, 2011 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class ColormappedImage implements IColormappedImage,
IRenderedImageCallback, IColorMapParametersListener {
private IImage image;
private IColorMapDataRetrievalCallback callback;
private ColorMapParameters parameters;
public ColormappedImage(IGraphicsTarget target,
IColorMapDataRetrievalCallback callback,
ColorMapParameters parameters) {
this.callback = callback;
setColorMapParameters(parameters);
image = target.initializeRaster(this);
}
/**
* Get the wrapped image for the colormapped image
*
* @return
*/
public IImage getWrappedImage() {
return image;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.drawables.IImage#getStatus()
*/
@Override
public Status getStatus() {
return image.getStatus();
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.drawables.IImage#setInterpolated(boolean)
*/
@Override
public void setInterpolated(boolean isInterpolated) {
image.setInterpolated(isInterpolated);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.drawables.IImage#dispose()
*/
@Override
public void dispose() {
if (image != null) {
image.dispose();
}
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.drawables.IImage#getWidth()
*/
@Override
public int getWidth() {
return image.getWidth();
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.drawables.IImage#getHeight()
*/
@Override
public int getHeight() {
return image.getHeight();
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.drawables.IImage#setBrightness(float)
*/
@Override
public void setBrightness(float brightness) {
image.setBrightness(brightness);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.drawables.IImage#setContrast(float)
*/
@Override
public void setContrast(float contrast) {
image.setContrast(contrast);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.drawables.IImage#getExtensionClass()
*/
@Override
public Class<? extends IImagingExtension> getExtensionClass() {
return GeneralColormappedImageExtension.class;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.drawables.IColormappedImage#getColorMapParameters
* ()
*/
@Override
public ColorMapParameters getColorMapParameters() {
return parameters;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.drawables.IColormappedImage#setColorMapParameters
* (com.raytheon.uf.viz.core.drawables.ColorMapParameters)
*/
@Override
public void setColorMapParameters(ColorMapParameters params) {
if (params != this.parameters) {
if (this.parameters != null) {
this.parameters.removeListener(this);
}
this.parameters = params;
if (this.parameters != null) {
this.parameters.addListener(this);
}
dispose();
}
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.drawables.IColormappedImage#getValue(int,
* int)
*/
@Override
public double getValue(int x, int y) {
return Double.NaN;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.data.IRenderedImageCallback#getImage()
*/
@Override
public RenderedImage getImage() throws VizException {
if (parameters == null || parameters.getColorMap() == null) {
return null;
}
ColorMapData colorMapData = callback.getColorMapData();
return Colormapper.colorMap(colorMapData, parameters);
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.drawables.IColorMapParametersListener#
* colorMapChanged()
*/
@Override
public void colorMapChanged() {
dispose();
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.drawables.IImage#stage()
*/
@Override
public void stage() throws VizException {
image.stage();
}
}

View file

@ -1,81 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.core.drawables.ext.colormap;
import java.awt.image.RenderedImage;
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback;
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback.ColorMapData;
import com.raytheon.uf.viz.core.data.IRenderedImageCallback;
import com.raytheon.uf.viz.core.data.prep.Colormapper;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.exception.VizException;
/**
* General {@link IRenderedImageCallback} that takes a
* {@link IColorMapDataRetrievalCallback} and {@link ColorMapParameters} and
* will colormap the data returned from the callback into a
* {@link RenderedImage}
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Nov 22, 2011 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class ColormappedRenderedImageCallback implements IRenderedImageCallback {
private IColorMapDataRetrievalCallback callback;
private ColorMapParameters parameters;
/**
* Construct a ColormappedRenderedImageCallback for the colormap data
* callback and parameters
*
* @param dataCallback
* @param parameters
*/
public ColormappedRenderedImageCallback(
IColorMapDataRetrievalCallback dataCallback,
ColorMapParameters parameters) {
this.callback = dataCallback;
this.parameters = parameters;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.data.IRenderedImageCallback#getImage()
*/
@Override
public RenderedImage getImage() throws VizException {
ColorMapData colorMapData = callback.getColorMapData();
return Colormapper.colorMap(colorMapData, parameters);
}
}

View file

@ -19,11 +19,17 @@
**/
package com.raytheon.uf.viz.core.drawables.ext.colormap;
import java.util.ArrayList;
import java.util.List;
import com.raytheon.uf.viz.core.DrawableImage;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.IColormappedImage;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension;
import com.raytheon.uf.viz.core.exception.VizException;
/**
* General colormapped image extension. Uses
@ -56,10 +62,10 @@ public class GeneralColormappedImageExtension extends
* com.raytheon.uf.viz.core.drawables.ColorMapParameters)
*/
@Override
public IImage initializeRaster(IColorMapDataRetrievalCallback dataCallback,
public IColormappedImage initializeRaster(
IColorMapDataRetrievalCallback dataCallback,
ColorMapParameters colorMapParameters) {
return target.initializeRaster(new ColormappedRenderedImageCallback(
dataCallback, colorMapParameters));
return new ColormappedImage(target, dataCallback, colorMapParameters);
}
/*
@ -70,7 +76,29 @@ public class GeneralColormappedImageExtension extends
*/
@Override
public int getCompatibilityValue(IGraphicsTarget target) {
return Compatibilty.GENERIC.value;
return Compatibilty.GENERIC;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.drawables.ext.IImagingExtension#drawRasters(
* com.raytheon.uf.viz.core.drawables.PaintProperties,
* com.raytheon.uf.viz.core.DrawableImage[])
*/
@Override
public boolean drawRasters(PaintProperties paintProps,
DrawableImage... images) throws VizException {
List<DrawableImage> renderables = new ArrayList<DrawableImage>();
for (DrawableImage di : images) {
if (di.getImage() instanceof ColormappedImage) {
renderables.add(new DrawableImage(((ColormappedImage) di
.getImage()).getWrappedImage(), di.getCoverage()));
}
}
return target.drawRasters(paintProps,
renderables.toArray(new DrawableImage[renderables.size()]));
}
}

View file

@ -26,6 +26,7 @@ import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.IShadedShape;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension.IGraphicsExtensionInterface;
import com.raytheon.uf.viz.core.exception.VizException;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.LineString;
@ -53,7 +54,8 @@ import com.vividsolutions.jts.geom.LineString;
* @author bsteffen
* @version 1.0
*/
public interface IColormapShadedShapeExtension {
public interface IColormapShadedShapeExtension extends
IGraphicsExtensionInterface {
public interface IColormapShadedShape {

View file

@ -22,7 +22,7 @@ package com.raytheon.uf.viz.core.drawables.ext.colormap;
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.IColormappedImage;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension;
/**
* Extension for creating {@link IColormappedImage} objects
@ -41,7 +41,7 @@ import com.raytheon.uf.viz.core.drawables.IImage;
* @version 1.0
*/
public interface IColormappedImageExtension {
public interface IColormappedImageExtension extends IImagingExtension {
/**
* Initializes an IColormappedImage given the dataCallback and colormap
@ -51,6 +51,7 @@ public interface IColormappedImageExtension {
* @param colorMapParameters
* @return
*/
public IImage initializeRaster(IColorMapDataRetrievalCallback dataCallback,
public IColormappedImage initializeRaster(
IColorMapDataRetrievalCallback dataCallback,
ColorMapParameters colorMapParameters);
}

View file

@ -34,7 +34,7 @@ import org.eclipse.core.runtime.jobs.Job;
* if you have dozens or hundreds of tasks that each take a short time. Creating
* a job for each task can result in more threads than is useful. If you instead
* use a JobPool it reduces the number of threads by limiting the number of
* eclipse jobs that are created. For many tasks a JobPool may perform faster
* eclipse jobs tBhat are created. For many tasks a JobPool may perform faster
* than using eclipse Jobs directly because thread creation and context
* switching are reduced.
*
@ -113,6 +113,18 @@ public class JobPool {
join();
}
/**
* Cancels the specified runnable. Returns true if the provided runnable was
* waiting to be run but now is now. Returns false if the provided runnable
* is already running or if it was not enqueued to begin with.
*
* @param runnable
* @return
*/
public synchronized boolean cancel(Runnable runnable) {
return workQueue.remove(runnable);
}
protected class PooledJob extends Job {
public PooledJob(String name) {

View file

@ -27,13 +27,13 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.LevelFactory;
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.Activator;
import com.raytheon.uf.viz.core.status.StatusConstants;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
/**
* Class defines a database level
@ -55,7 +55,9 @@ import com.raytheon.uf.viz.core.status.StatusConstants;
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement
public class DatabaseLevelMapping {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(DatabaseLevelMapping.class);
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(DatabaseLevelMapping.class);
@XmlAttribute
private String levelName = null;
@ -100,7 +102,7 @@ public class DatabaseLevelMapping {
this.unit = unit;
}
public List<Level> getLevels() {
public List<Level> getLevels() throws VizCommunicationException {
String[] levelOneValues = new String[0];
String[] levelTwoValues = new String[0];
@ -143,12 +145,16 @@ public class DatabaseLevelMapping {
}
// handle any aliasing etc
Level level = LevelFactory.getInstance().getLevel(levelName, lvl1,
lvl2, unit);
if (level != null) {
rval.add(level);
try {
Level level = LevelFactory.getInstance().getLevel(levelName,
lvl1, lvl2, unit);
if (level != null) {
rval.add(level);
}
} catch (CommunicationException e) {
throw new VizCommunicationException(e);
}
}
return rval;

View file

@ -31,6 +31,7 @@ import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
/**
* Class defines a mapping from a display level to one or more database levels.
@ -38,14 +39,14 @@ import com.raytheon.uf.common.serialization.ISerializableObject;
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 11/01/2007 #518 S.Manoj Initial version
* 11/16/2009 #3120 rjpeter Modifed to better integrate with level framework.
* 11/21/2009 #3576 rjpeter Added group
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 11/01/2007 #518 S.Manoj Initial version
* 11/16/2009 #3120 rjpeter Modifed to better integrate with level framework.
* 11/21/2009 #3576 rjpeter Added group
*
* &#064;author smanoj
* @version 1.0
*/
@ -118,12 +119,13 @@ public class LevelMapping implements ISerializableObject {
this.databaseLevels = databaseLevels;
}
public List<Level> getLevels() {
public List<Level> getLevels() throws VizCommunicationException {
if (levelList == null) {
levelList = new ArrayList<Level>();
List<Level> levelList = new ArrayList<Level>();
for (DatabaseLevelMapping mapping : databaseLevels) {
levelList.addAll(mapping.getLevels());
}
this.levelList = levelList;
}
return levelList;

View file

@ -35,6 +35,7 @@ import com.raytheon.uf.common.localization.PathManagerFactory;
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.exception.VizCommunicationException;
/**
* Factory for getting level mappings
@ -56,15 +57,22 @@ public class LevelMappingFactory {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(LevelMappingFactory.class);
private static LevelMappingFactory instance = new LevelMappingFactory();
private static LevelMappingFactory instance = null;
private Map<String, LevelMapping> keyToLevelMappings = new HashMap<String, LevelMapping>();
private boolean levelToLevelMappingsInitialized = false;
private Map<Level, LevelMapping> levelToLevelMappings = new HashMap<Level, LevelMapping>();
private boolean groupToMasterLevelsInitialized = false;
private Map<String, Map<MasterLevel, Set<Level>>> groupToMasterLevels = new HashMap<String, Map<MasterLevel, Set<Level>>>();
public static LevelMappingFactory getInstance() {
public synchronized static LevelMappingFactory getInstance() {
if (instance == null) {
instance = new LevelMappingFactory();
}
return instance;
}
@ -96,47 +104,6 @@ public class LevelMappingFactory {
}
}
for (LevelMapping mapping : keyToLevelMappings.values()) {
String group = mapping.getGroup();
Map<MasterLevel, Set<Level>> masterLevels = null;
if (group != null) {
masterLevels = groupToMasterLevels.get(mapping.getGroup());
if (masterLevels == null) {
masterLevels = new HashMap<MasterLevel, Set<Level>>();
groupToMasterLevels.put(group, masterLevels);
}
}
for (Level l : mapping.getLevels()) {
if (levelToLevelMappings.containsKey(l)) {
LevelMapping oldMapping = levelToLevelMappings.get(l);
// Only replace the old level mapping if we have less
// levels than the old mapping
// This should cause the most specific mapping to be
// used
if (mapping.getLevels().size() < oldMapping.getLevels()
.size()) {
levelToLevelMappings.put(l, mapping);
}
} else {
levelToLevelMappings.put(l, mapping);
}
// populate grouping map
if (masterLevels != null) {
MasterLevel ml = l.getMasterLevel();
Set<Level> levels = masterLevels.get(ml);
if (levels == null) {
levels = new HashSet<Level>();
masterLevels.put(ml, levels);
}
levels.add(l);
}
}
}
}
long finish = System.currentTimeMillis();
System.out.println("LevelMappingFactory initialization took ["
@ -147,7 +114,11 @@ public class LevelMappingFactory {
return keyToLevelMappings.get(key);
}
public LevelMapping getLevelMappingForLevel(Level level) {
public LevelMapping getLevelMappingForLevel(Level level)
throws VizCommunicationException {
if (!levelToLevelMappingsInitialized) {
initializeLevelToLevelMappings();
}
return levelToLevelMappings.get(level);
}
@ -155,11 +126,75 @@ public class LevelMappingFactory {
return keyToLevelMappings.values();
}
public Set<Level> getAllLevels() {
public Set<Level> getAllLevels() throws VizCommunicationException {
if (!levelToLevelMappingsInitialized) {
initializeLevelToLevelMappings();
}
return levelToLevelMappings.keySet();
}
public Map<MasterLevel, Set<Level>> getLevelMapForGroup(String group) {
public Map<MasterLevel, Set<Level>> getLevelMapForGroup(String group)
throws VizCommunicationException {
if (!groupToMasterLevelsInitialized) {
initializeGroupToMasterLevels();
}
return groupToMasterLevels.get(group);
}
private void initializeLevelToLevelMappings()
throws VizCommunicationException {
for (LevelMapping mapping : keyToLevelMappings.values()) {
String group = mapping.getGroup();
for (Level l : mapping.getLevels()) {
if (levelToLevelMappings.containsKey(l)) {
LevelMapping oldMapping = levelToLevelMappings.get(l);
// Only replace the old level mapping if we have less
// levels than the old mapping
// This should cause the most specific mapping to be
// used
if (mapping.getLevels().size() < oldMapping.getLevels()
.size()) {
levelToLevelMappings.put(l, mapping);
}
} else {
levelToLevelMappings.put(l, mapping);
}
}
}
levelToLevelMappingsInitialized = true;
}
private void initializeGroupToMasterLevels()
throws VizCommunicationException {
for (LevelMapping mapping : keyToLevelMappings.values()) {
String group = mapping.getGroup();
Map<MasterLevel, Set<Level>> masterLevels = null;
if (group != null) {
masterLevels = groupToMasterLevels.get(mapping.getGroup());
if (masterLevels == null) {
masterLevels = new HashMap<MasterLevel, Set<Level>>();
groupToMasterLevels.put(group, masterLevels);
}
}
for (Level l : mapping.getLevels()) {
// populate grouping map
if (masterLevels != null) {
MasterLevel ml = l.getMasterLevel();
Set<Level> levels = masterLevels.get(ml);
if (levels == null) {
levels = new HashSet<Level>();
masterLevels.put(ml, levels);
}
levels.add(l);
}
}
}
groupToMasterLevelsInitialized = true;
}
}

View file

@ -22,6 +22,7 @@ package com.raytheon.uf.viz.core.level;
import java.util.HashMap;
import java.util.Map;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.LevelContainer;
import com.raytheon.uf.common.dataplugin.level.MasterLevel;
@ -37,6 +38,7 @@ import com.raytheon.uf.common.dataquery.responses.DbQueryResponse;
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.exception.VizCommunicationException;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;
@ -45,11 +47,14 @@ public class LevelRetrievalAdapter implements ILevelRetrievalAdapter {
.getHandler(LevelRetrievalAdapter.class);
@Override
public Level getLevel(GetLevelRequest request) {
public Level getLevel(GetLevelRequest request)
throws CommunicationException {
Level rval = null;
try {
rval = (Level) ThriftClient.sendRequest(request);
} catch (VizCommunicationException e) {
throw new CommunicationException(e);
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM,
"Error occurred retrieving level information from server.",
@ -60,11 +65,14 @@ public class LevelRetrievalAdapter implements ILevelRetrievalAdapter {
}
@Override
public Level getLevel(GetLevelByIdRequest request) {
public Level getLevel(GetLevelByIdRequest request)
throws CommunicationException {
Level rval = null;
try {
rval = (Level) ThriftClient.sendRequest(request);
} catch (VizCommunicationException e) {
throw new CommunicationException(e);
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM,
"Error occurred retrieving level information from server.",
@ -75,10 +83,13 @@ public class LevelRetrievalAdapter implements ILevelRetrievalAdapter {
}
@Override
public MasterLevel getMasterLevel(GetMasterLevelRequest request) {
public MasterLevel getMasterLevel(GetMasterLevelRequest request)
throws CommunicationException {
MasterLevel rval = null;
try {
rval = (MasterLevel) ThriftClient.sendRequest(request);
} catch (VizCommunicationException e) {
throw new CommunicationException(e);
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM,
"Error occurred retrieving level information from server.",
@ -89,10 +100,13 @@ public class LevelRetrievalAdapter implements ILevelRetrievalAdapter {
@Override
public LevelContainer getAllLevelsForMasterLevel(
GetAllLevelsForMasterLevelRequest request) {
GetAllLevelsForMasterLevelRequest request)
throws CommunicationException {
LevelContainer rval = null;
try {
rval = (LevelContainer) ThriftClient.sendRequest(request);
} catch (VizCommunicationException e) {
throw new CommunicationException(e);
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM,
"Error occurred retrieving level information from server.",
@ -102,7 +116,7 @@ public class LevelRetrievalAdapter implements ILevelRetrievalAdapter {
}
@Override
public LevelContainer getAllLevels() {
public LevelContainer getAllLevels() throws CommunicationException {
LevelContainer rval = null;
DbQueryRequest query = new DbQueryRequest();
query.setConstraints(new HashMap<String, RequestConstraint>());
@ -114,6 +128,8 @@ public class LevelRetrievalAdapter implements ILevelRetrievalAdapter {
for (Map<String, Object> result : resp.getResults()) {
rval.add((Level) result.get(null));
}
} catch (VizCommunicationException e) {
throw new CommunicationException(e);
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM,
"Error occurred retrieving level information from server.",
@ -123,7 +139,8 @@ public class LevelRetrievalAdapter implements ILevelRetrievalAdapter {
}
@Override
public MasterLevelContainer getAllMasterLevels() {
public MasterLevelContainer getAllMasterLevels()
throws CommunicationException {
MasterLevelContainer rval = null;
DbQueryRequest query = new DbQueryRequest();
query.setConstraints(new HashMap<String, RequestConstraint>());
@ -135,6 +152,8 @@ public class LevelRetrievalAdapter implements ILevelRetrievalAdapter {
for (Map<String, Object> result : resp.getResults()) {
rval.add((MasterLevel) result.get(null));
}
} catch (VizCommunicationException e) {
throw new CommunicationException(e);
} catch (VizException e) {
statusHandler
.handle(Priority.PROBLEM,

View file

@ -29,10 +29,12 @@ import java.util.TreeSet;
import javax.measure.unit.Unit;
import javax.measure.unit.UnitFormat;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.level.CompareType;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.LevelFactory;
import com.raytheon.uf.common.dataplugin.level.MasterLevel;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
/**
* Level utilities
@ -62,14 +64,24 @@ public class LevelUtilities {
}
}
public static boolean isPressureLevel(long levelId) {
return isPressureLevel(LevelFactory.getInstance().getLevel(levelId)
.getMasterLevel());
public static boolean isPressureLevel(long levelId)
throws VizCommunicationException {
try {
return isPressureLevel(LevelFactory.getInstance().getLevel(levelId)
.getMasterLevel());
} catch (CommunicationException e) {
throw new VizCommunicationException(e);
}
}
public static boolean isPressureLevel(String masterLevelName) {
return isPressureLevel(LevelFactory.getInstance().getMasterLevel(
masterLevelName));
public static boolean isPressureLevel(String masterLevelName)
throws VizCommunicationException {
try {
return isPressureLevel(LevelFactory.getInstance().getMasterLevel(
masterLevelName));
} catch (CommunicationException e) {
throw new VizCommunicationException(e);
}
}
public static boolean isPressureLevel(Level level) {
@ -89,9 +101,10 @@ public class LevelUtilities {
*
* @param masterLevelName
* @return
* @throws CommunicationException
*/
public synchronized static NavigableSet<Level> getOrderedSetOfStandardLevels(
String masterLevelName) {
String masterLevelName) throws VizCommunicationException {
if (masterLevelToOrderedSet == null) {
Comparator<Level> levelComparator = new Comparator<Level>() {
@ -108,7 +121,7 @@ public class LevelUtilities {
}
};
masterLevelToOrderedSet = new HashMap<String, NavigableSet<Level>>();
Map<String, NavigableSet<Level>> masterLevelToOrderedSet = new HashMap<String, NavigableSet<Level>>();
for (Level level : LevelMappingFactory.getInstance().getAllLevels()) {
NavigableSet<Level> levels = masterLevelToOrderedSet.get(level
.getMasterLevel().getName());
@ -118,12 +131,18 @@ public class LevelUtilities {
.getName(), levels);
}
if (level.isRangeLevel()) {
levels.add(level.getUpperLevel());
levels.add(level.getLowerLevel());
try {
levels.add(level.getUpperLevel());
levels.add(level.getLowerLevel());
} catch (CommunicationException e) {
throw new VizCommunicationException(e);
}
} else {
levels.add(level);
}
}
LevelUtilities.masterLevelToOrderedSet = masterLevelToOrderedSet;
}
return masterLevelToOrderedSet.get(masterLevelName);

View file

@ -20,6 +20,7 @@
package com.raytheon.uf.viz.core.map;
import com.raytheon.uf.viz.core.IMesh;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension.IGraphicsExtensionInterface;
import com.raytheon.uf.viz.core.exception.VizException;
/**
@ -39,7 +40,7 @@ import com.raytheon.uf.viz.core.exception.VizException;
* @version 1.0
*/
public interface IMapMeshExtension {
public interface IMapMeshExtension extends IGraphicsExtensionInterface {
/**
* Create a mesh

View file

@ -193,29 +193,7 @@ public class NotificationManagerJob implements ExceptionListener, IDisposable {
try {
ConnectionFactory connectionFactory = JMSConnection.getInstance()
.getFactory();
if (connection != null) {
try {
connection.stop();
} catch (Exception e) {
if (notifyError) {
statusHandler
.handle(Priority.SIGNIFICANT,
"NotificationManager failed to stop a connection.",
e);
}
}
try {
connection.close();
} catch (Exception e) {
if (notifyError) {
statusHandler
.handle(Priority.SIGNIFICANT,
"NotificationManager failed to close a connection.",
e);
}
}
connection = null;
}
disconnect(notifyError);
// Create a Connection
connection = connectionFactory.createConnection();
@ -250,6 +228,31 @@ public class NotificationManagerJob implements ExceptionListener, IDisposable {
}
}
protected void disconnect(boolean notifyError) {
if (connection != null) {
try {
connection.stop();
} catch (Exception e) {
if (notifyError) {
statusHandler.handle(Priority.SIGNIFICANT,
"NotificationManager failed to stop a connection.",
e);
}
}
try {
connection.close();
} catch (Exception e) {
if (notifyError) {
statusHandler
.handle(Priority.SIGNIFICANT,
"NotificationManager failed to close a connection.",
e);
}
}
connection = null;
}
}
private TimerTask task = null;
@Override

View file

@ -1,5 +1,6 @@
package com.raytheon.uf.viz.core.requests;
import java.io.IOException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
@ -12,6 +13,7 @@ import com.raytheon.uf.common.auth.req.AbstractPrivilegedRequest;
import com.raytheon.uf.common.auth.resp.SuccessfulExecution;
import com.raytheon.uf.common.auth.resp.UserNotAuthenticated;
import com.raytheon.uf.common.auth.resp.UserNotAuthorized;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.comm.HttpClient;
import com.raytheon.uf.common.comm.NetworkStatistics;
import com.raytheon.uf.common.serialization.SerializationException;
@ -23,6 +25,7 @@ import com.raytheon.uf.common.serialization.comm.response.ServerErrorResponse;
import com.raytheon.uf.common.serialization.comm.util.ExceptionWrapper;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.auth.UserController;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.localization.LocalizationManager;
@ -311,6 +314,12 @@ public class ThriftClient {
// Log request stats
stats.log(request.getClass().getSimpleName(), message.length,
responseLen);
} catch (IOException e) {
throw new VizCommunicationException(
"unable to post request to server", e);
} catch (CommunicationException e) {
throw new VizCommunicationException(
"unable to post request to server", e);
} catch (Exception e) {
throw new VizException("unable to post request to server", e);
}

View file

@ -0,0 +1,340 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.core.rsc;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.IRenderable;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.capabilities.AbstractCapability;
/**
* Abstract resource class that manages frames with renderable objects
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 21, 2011 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public abstract class AbstractPluginDataObjectResource<T extends AbstractResourceData, D extends IDescriptor>
extends AbstractVizResource<T, D> {
private static class Frame {
List<PluginDataObject> records = new ArrayList<PluginDataObject>();
IRenderable renderable;
}
private Map<DataTime, Frame> frames = new HashMap<DataTime, Frame>();
private Object lock = new Object();
/**
* @param resourceData
* @param loadProperties
*/
protected AbstractPluginDataObjectResource(T resourceData,
LoadProperties loadProperties) {
super(resourceData, loadProperties);
dataTimes = new ArrayList<DataTime>();
resourceData.addChangeListener(new IResourceDataChanged() {
@Override
public void resourceChanged(ChangeType type, Object object) {
if (type == ChangeType.DATA_UPDATE) {
if (object instanceof PluginDataObject) {
addDataObject((PluginDataObject) object);
} else if (object instanceof PluginDataObject[]) {
for (PluginDataObject pdo : (PluginDataObject[]) object) {
addDataObject((PluginDataObject) pdo);
}
} else if (object instanceof Object[]) {
for (Object obj : (Object[]) object) {
if (obj instanceof PluginDataObject) {
addDataObject((PluginDataObject) obj);
}
}
}
} else if (type == ChangeType.CAPABILITY) {
if (object instanceof AbstractCapability) {
AbstractCapability capability = (AbstractCapability) object;
for (Frame frame : frames.values()) {
if (frame.renderable != null) {
capabilityChanged(frame.renderable, capability);
}
}
}
}
}
});
}
/**
* Adds the pdo to the appropriate time and removes any renderable or data
* cached for that time.
*
* @param pdo
*/
protected final void addDataObject(PluginDataObject pdo) {
synchronized (lock) {
if (frames == null) {
// Check for null in case we were waiting for lock from
// disposeInternal in which case we shouldn't process add
return;
}
DataTime time = getDataObjectTime(pdo);
Frame frame = frames.get(time);
if (frame == null) {
frame = new Frame();
frames.put(time, frame);
}
if (frame.records.contains(pdo)) {
frame.records.remove(pdo);
}
frame.records.add(pdo);
if (frame.renderable != null) {
if (updateRenderable(frame.renderable, pdo) == false) {
dispose(frame.renderable);
}
}
if (!dataTimes.contains(dataTimes)) {
dataTimes.add(time);
}
}
}
/**
* Return the DataTime to be associated with this record. Default returns
* PluginDataObject.getDataTime()
*
* @param pdo
* @return
*/
protected DataTime getDataObjectTime(PluginDataObject pdo) {
return pdo.getDataTime();
}
/**
* Get the records for the given time. Empty list will be returned if no
* frame for time
*
* @param time
* @return
*/
protected List<PluginDataObject> getPluginDataObjects(DataTime time) {
Frame frame = frames.get(time);
if (frame != null) {
return frame.records;
}
return new ArrayList<PluginDataObject>();
}
/**
* Get the current time for the resource, default calls
* descriptor.getTimeForResoruce(this)
*
* @return the current time
*/
protected DataTime getTimeForResource() {
return descriptor.getTimeForResource(this);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.rsc.AbstractVizResource#remove(com.raytheon.
* uf.common.time.DataTime)
*/
@Override
public final void remove(DataTime dataTime) {
synchronized (lock) {
super.remove(dataTime);
Frame frame = frames.remove(dataTime);
if (frame != null && frame.renderable != null) {
IRenderable dispose = frame.renderable;
frame.renderable = null;
dispose(dispose);
}
}
}
/**
* Dispose of a renderable.
*
* @param renderable
*/
private void dispose(final IRenderable renderable) {
VizApp.runAsync(new Runnable() {
@Override
public void run() {
disposeRenderable(renderable);
}
});
}
@Override
public final void project(CoordinateReferenceSystem crs)
throws VizException {
Iterator<Frame> iter = frames.values().iterator();
while (iter.hasNext()) {
Frame frame = iter.next();
IRenderable renderable = frame.renderable;
if (renderable != null) {
if (!projectRenderable(renderable, crs)) {
frame.renderable = null;
dispose(renderable);
}
}
}
}
/*
* (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 final void paintInternal(IGraphicsTarget target,
PaintProperties paintProps) throws VizException {
DataTime time = paintProps.getDataTime();
if (time == null) {
time = getTimeForResource();
}
Frame currFrame = frames.get(time);
if (currFrame != null) {
IRenderable renderable = currFrame.renderable;
if (renderable == null) {
currFrame.renderable = renderable = constructRenderable(currFrame.records);
}
if (renderable != null) {
renderable.paint(target, paintProps);
}
}
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.rsc.AbstractVizResource#disposeInternal()
*/
@Override
protected final void disposeInternal() {
synchronized (lock) {
for (Frame frame : frames.values()) {
if (frame.renderable != null) {
disposeRenderable(frame.renderable);
}
}
frames.clear();
frames = null;
}
disposeResource();
}
/**
* Dispose method for the resource to dispose any data not tied to a
* renderable. Called after all renderables have been disposed. Default impl
* does nothing
*/
protected void disposeResource() {
}
/**
* Notification that a capability has changed and the renderable should be
* updated
*
* @param renderable
* @param capability
*/
protected abstract void capabilityChanged(IRenderable renderable,
AbstractCapability capability);
/**
* Dispose the renderable object
*
* @param renderable
*/
protected abstract void disposeRenderable(IRenderable renderable);
/**
* Attempt to reproject the renderable object into this specified
* projection. If unable to reproject, return false and renderable will be
* recreated next paint
*
* @param renderable
* @param crs
* @return
*/
protected abstract boolean projectRenderable(IRenderable renderable,
CoordinateReferenceSystem crs) throws VizException;
/**
* Construct a renderable object for the given records. This method is
* called from paintInternal. Null can be returned and this method will be
* called next paintInternal. That can be used if requesting data that is
* required for the renderable asynchronously.
*
* NOTE: The size of the pdo list will only grow so it can be used to
* determine if new data has arrived since last call
*
* @param records
* @return
*/
protected abstract IRenderable constructRenderable(
List<PluginDataObject> records) throws VizException;
/**
* Update the renderable with the new pdo, if the renderable is updatable,
* return true. If the renderable needs to be recreated from scratch, return
* false
*
* @param renderable
* @param pdo
* @return
*/
protected abstract boolean updateRenderable(IRenderable renderable,
PluginDataObject pdo);
}

View file

@ -21,6 +21,7 @@ package com.raytheon.uf.viz.core.rsc;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
@ -385,11 +386,6 @@ public abstract class AbstractRequestableResourceData extends
Set<DataTime> currentSet = new HashSet<DataTime>(Arrays.asList(current));
boolean initialLoad = false;
if (currentSet.size() == 0) {
initialLoad = true;
}
Set<DataTime> loadSet = new HashSet<DataTime>();
for (DataTime t : desiredSet) {
boolean found = false;
@ -409,6 +405,21 @@ public abstract class AbstractRequestableResourceData extends
return new PluginDataObject[0];
}
return requestPluginDataObjects(loadSet);
}
/**
* Request plugin data objects for the passed in times. This method is
* called from getLatestPluginDataObjects(DataTime[],DataTime[]) after time
* filter from desired and current has been done. The times passed in is a
* collection of new times needed
*
* @param loadSet
* @return
* @throws VizException
*/
protected PluginDataObject[] requestPluginDataObjects(
Collection<DataTime> loadSet) throws VizException {
LayerProperty property = new LayerProperty();
// TODO fix?
property.setDesiredProduct(ResourceType.PLAN_VIEW);
@ -476,7 +487,7 @@ public abstract class AbstractRequestableResourceData extends
/**
* Comparator for response array.
*/
private static Comparator<PluginDataObject> layerComparator = new Comparator<PluginDataObject>() {
protected static Comparator<PluginDataObject> layerComparator = new Comparator<PluginDataObject>() {
@Override
public int compare(PluginDataObject arg0, PluginDataObject arg1) {

View file

@ -20,10 +20,10 @@
package com.raytheon.uf.viz.core.rsc;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@ -152,11 +152,11 @@ public abstract class AbstractVizResource<T extends AbstractResourceData, D exte
protected AbstractVizResource(T resourceData, LoadProperties loadProperties) {
this.resourceData = resourceData;
this.loadProperties = loadProperties;
refreshListeners = new HashSet<IRefreshListener>();
initListeners = new HashSet<IInitListener>();
paintListeners = new HashSet<IPaintListener>();
paintStatusListeners = new HashSet<IPaintStatusChangedListener>();
disposeListeners = new HashSet<IDisposeListener>();
refreshListeners = new CopyOnWriteArraySet<IRefreshListener>();
initListeners = new CopyOnWriteArraySet<IInitListener>();
paintListeners = new CopyOnWriteArraySet<IPaintListener>();
paintStatusListeners = new CopyOnWriteArraySet<IPaintStatusChangedListener>();
disposeListeners = new CopyOnWriteArraySet<IDisposeListener>();
if (resourceData != null) {
resourceData.addChangeListener(new IResourceDataChanged() {

View file

@ -83,7 +83,12 @@ public class URICatalog extends DecisionTree<List<IURIRefreshCallback>> {
}
protected static synchronized void setCustomInstance(URICatalog catalog) {
// TODO what to do if there already is an isntance.
if (instance != null) {
for (DataPair pair : instance.getDataPairs()) {
catalog.insertCriteria(pair.metadata, pair.data, false);
}
catalog.rebuildTree();
}
instance = catalog;
}

View file

@ -73,6 +73,9 @@ public class ColorMapCapability extends AbstractCapability implements
public void setColorMapParameters(ColorMapParameters colorMapParameters,
boolean notify) {
if (this.colorMapParameters != colorMapParameters) {
if (this.colorMapParameters != null) {
this.colorMapParameters.removeListener(this);
}
this.colorMapParameters = colorMapParameters;
if (notify) {
capabilityChanged();
@ -80,7 +83,7 @@ public class ColorMapCapability extends AbstractCapability implements
}
if (this.colorMapParameters != null) {
this.colorMapParameters.setListener(this);
this.colorMapParameters.addListener(this);
}
}

View file

@ -50,7 +50,17 @@ public class DataUpdateTree extends DecisionTree<AbstractVizResource<?, ?>> {
return instance;
}
public DataUpdateTree() {
protected static synchronized void setCustomInstance(DataUpdateTree tree) {
if (instance != null) {
for (DataPair pair : instance.getDataPairs()) {
tree.insertCriteria(pair.metadata, pair.data, false);
}
tree.rebuildTree();
}
instance = tree;
}
protected DataUpdateTree() {
super();
}

View file

@ -245,19 +245,23 @@ public class PointDataTimeSeriesAdapter extends
// The level mapping for surface has way to much junk in it.
return level;
}
LevelMapping mapping = LevelMappingFactory.getInstance()
.getLevelMappingForKey(resourceData.getLevelKey());
for (Level l : mapping.getLevels()) {
if (LevelUtilities.isPressureLevel(l)) {
try {
level = new SingleLevel(l.getMasterLevel().getName());
level.setValue(l.getLevelonevalue());
break;
} catch (IllegalArgumentException e) {
level = new SingleLevel("SURFACE");
level.setValue(0.0);
try {
LevelMapping mapping = LevelMappingFactory.getInstance()
.getLevelMappingForKey(resourceData.getLevelKey());
for (Level l : mapping.getLevels()) {
if (LevelUtilities.isPressureLevel(l)) {
try {
level = new SingleLevel(l.getMasterLevel().getName());
level.setValue(l.getLevelonevalue());
break;
} catch (IllegalArgumentException e) {
level = new SingleLevel("SURFACE");
level.setValue(0.0);
}
}
}
} catch (VizException e) {
// return the default
}
return level;
}

View file

@ -7,30 +7,26 @@ Bundle-Activator: com.raytheon.uf.viz.derivparam.Activator
Bundle-Vendor: RAYTHEON
Require-Bundle: org.eclipse.core.runtime,
javax.measure,
com.raytheon.uf.common.dataquery
com.raytheon.uf.common.dataquery,
com.raytheon.uf.viz.core;bundle-version="1.12.1174",
com.raytheon.uf.common.datastorage;bundle-version="1.12.1174",
com.raytheon.uf.common.pointdata;bundle-version="1.12.1174"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Eclipse-RegisterBuddy: com.raytheon.uf.common.serialization
Import-Package: com.raytheon.edex.meteoLib,
com.raytheon.edex.util,
com.raytheon.uf.common.comm,
com.raytheon.uf.common.dataplugin,
com.raytheon.uf.common.dataplugin.level,
com.raytheon.uf.common.dataplugin.persist,
com.raytheon.uf.common.datastorage.records,
com.raytheon.uf.common.derivparam.tree,
com.raytheon.uf.common.localization,
com.raytheon.uf.common.message.response,
com.raytheon.uf.common.serialization,
com.raytheon.uf.common.serialization.adapters,
com.raytheon.uf.common.status,
com.raytheon.uf.common.time,
com.raytheon.uf.viz.core,
com.raytheon.uf.viz.core.catalog,
com.raytheon.uf.viz.core.comm,
com.raytheon.uf.viz.core.exception,
com.raytheon.uf.viz.core.level,
com.raytheon.uf.viz.core.localization,
com.raytheon.uf.viz.core.status
com.raytheon.uf.common.time
Export-Package: com.raytheon.uf.viz.derivparam,
com.raytheon.uf.viz.derivparam.data,
com.raytheon.uf.viz.derivparam.inv,

View file

@ -0,0 +1,394 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.derivparam.data;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataquery.requests.DbQueryRequest;
import com.raytheon.uf.common.dataquery.requests.DbQueryRequestSet;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint.ConstraintType;
import com.raytheon.uf.common.dataquery.requests.TimeQueryRequest;
import com.raytheon.uf.common.dataquery.requests.TimeQueryRequestSet;
import com.raytheon.uf.common.dataquery.responses.DbQueryResponse;
import com.raytheon.uf.common.dataquery.responses.DbQueryResponseSet;
import com.raytheon.uf.common.datastorage.Request;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.pointdata.PointDataContainer;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.catalog.LayerProperty;
import com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter;
import com.raytheon.uf.viz.core.datastructure.VizDataCubeException;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.requests.ThriftClient;
import com.raytheon.uf.viz.derivparam.tree.AbstractRequestableLevelNode;
import com.raytheon.uf.viz.derivparam.tree.AbstractRequestableLevelNode.Dependency;
/**
* Abstract data cube adapter for standard data type that uses derived
* parameters
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 30, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public abstract class AbstractDataCubeAdapter implements IDataCubeAdapter {
private String[] supportedPlugins;
protected AbstractDataCubeAdapter(String[] supportedPlugins) {
this.supportedPlugins = supportedPlugins;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getSupportedPlugins
* ()
*/
@Override
public String[] getSupportedPlugins() {
return supportedPlugins;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#timeQuery(java
* .util.List)
*/
@Override
public List<List<DataTime>> timeQuery(List<TimeQueryRequest> requests)
throws VizException {
int mapSize = (int) (requests.size() * 1) + 1;
Map<AbstractRequestableLevelNode, Set<DataTime>> cache = new HashMap<AbstractRequestableLevelNode, Set<DataTime>>(
mapSize);
LinkedHashMap<AbstractRequestableLevelNode, TimeQueryRequest> queries = new LinkedHashMap<AbstractRequestableLevelNode, TimeQueryRequest>(
mapSize);
for (TimeQueryRequest request : requests) {
List<AbstractRequestableLevelNode> requestNodes = evaluateRequestConstraints(request
.getQueryTerms());
// pull out time queries and bulk submit
for (AbstractRequestableLevelNode requestNode : requestNodes) {
getTimeQuery(request, requestNode, false, queries, cache, null);
}
}
// set the results back into the cache's
TimeQueryRequestSet reqSet = new TimeQueryRequestSet();
reqSet.setRequests(queries.values().toArray(
new TimeQueryRequest[queries.size()]));
@SuppressWarnings("unchecked")
List<List<DataTime>> qResponses = (List<List<DataTime>>) ThriftClient
.sendRequest(reqSet);
int index = 0;
for (AbstractRequestableLevelNode node : queries.keySet()) {
// put results into cache
node.setTimeQueryResults(false, qResponses.get(index++), cache,
null);
}
List<List<DataTime>> finalResponse = new ArrayList<List<DataTime>>(
requests.size());
for (TimeQueryRequest request : requests) {
List<AbstractRequestableLevelNode> requestNodes = evaluateRequestConstraints(request
.getQueryTerms());
// pull the actual results from the cache
Set<DataTime> results = new HashSet<DataTime>(64);
for (AbstractRequestableLevelNode requestNode : requestNodes) {
Set<DataTime> times = requestNode.timeQuery(request, false,
cache, null);
if (times == AbstractRequestableLevelNode.TIME_AGNOSTIC) {
// TODO: include time agnostic query in main bulk query as
// each pressure level will cause a separate query
List<DataTime> temp = timeAgnosticQuery(request
.getQueryTerms());
if (temp != null) {
results.addAll(temp);
}
break;
} else {
results.addAll(times);
}
}
if (!request.isMaxQuery() || results.isEmpty()) {
finalResponse.add(new ArrayList<DataTime>(results));
} else {
ArrayList<DataTime> response = new ArrayList<DataTime>(results);
Collections.sort(response);
finalResponse
.add(Arrays.asList(response.get(response.size() - 1)));
}
}
return finalResponse;
}
protected void getTimeQuery(
TimeQueryRequest originalRequest,
AbstractRequestableLevelNode req,
boolean latestOnly,
LinkedHashMap<AbstractRequestableLevelNode, TimeQueryRequest> queries,
Map<AbstractRequestableLevelNode, Set<DataTime>> cache,
Map<AbstractRequestableLevelNode, Set<DataTime>> latestOnlyCache)
throws VizException {
List<Dependency> depends = req.getDependencies();
if (depends.isEmpty()) {
// is source node
TimeQueryRequest myQ = req.getTimeQuery(originalRequest,
latestOnly, cache, latestOnlyCache);
if (myQ != null) {
// no need to merge timeQueries
queries.put(req, myQ);
}
} else {
for (Dependency dep : depends) {
// TODO: Optimize dTime/fTime to use bulk query mechanism,
// small case that is a not easy to get right with a bulk
// query
if (dep.timeOffset == 0 || !latestOnly) {
getTimeQuery(originalRequest, dep.node, latestOnly,
queries, cache, latestOnlyCache);
}
}
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getPoints(java
* .lang.String, java.lang.String[], java.util.Map)
*/
@Override
public PointDataContainer getPoints(String plugin, String[] parameters,
Map<String, RequestConstraint> queryParams) throws VizException {
// TODO Someday we should put objective analysis code
// into this area
return null;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getPoints(java
* .lang.String, java.lang.String[], java.lang.String, java.util.Map)
*/
@Override
public PointDataContainer getPoints(String plugin, String[] parameters,
String levelKey, Map<String, RequestConstraint> queryParams)
throws VizException {
// TODO Someday we should put objective analysis code
// into this area
return null;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getData(com.raytheon
* .uf.viz.core.catalog.LayerProperty, int)
*/
@Override
public List<Object> getData(LayerProperty property, int timeOut)
throws VizException {
List<AbstractRequestableLevelNode> requests = evaluateRequestConstraints(property
.getEntryQueryParameters(false));
int mapSize = (int) (requests.size() * 1.25) + 1;
Map<AbstractRequestableLevelNode, List<AbstractRequestableData>> cache = new HashMap<AbstractRequestableLevelNode, List<AbstractRequestableData>>(
mapSize);
LinkedHashMap<AbstractRequestableLevelNode, DbQueryRequest> queries = new LinkedHashMap<AbstractRequestableLevelNode, DbQueryRequest>(
mapSize);
for (AbstractRequestableLevelNode req : requests) {
getDataQuery(req, property, timeOut, queries, cache);
}
DbQueryRequestSet reqSet = new DbQueryRequestSet();
reqSet.setQueries(queries.values().toArray(
new DbQueryRequest[queries.size()]));
DbQueryResponseSet qSetResponse = (DbQueryResponseSet) ThriftClient
.sendRequest(reqSet);
DbQueryResponse[] qResponses = qSetResponse.getResults();
int index = 0;
for (AbstractRequestableLevelNode node : queries.keySet()) {
// put results into cache
node.setDataQueryResults(qResponses[index++], cache);
}
// pull the actual results from the cache
List<AbstractRequestableData> requesters = new ArrayList<AbstractRequestableData>(
requests.size());
for (AbstractRequestableLevelNode request : requests) {
requesters.addAll(request.getData(property, timeOut, cache));
}
return getData(property, requesters);
}
protected void getDataQuery(
AbstractRequestableLevelNode req,
LayerProperty property,
int timeOut,
LinkedHashMap<AbstractRequestableLevelNode, DbQueryRequest> queries,
Map<AbstractRequestableLevelNode, List<AbstractRequestableData>> cache)
throws VizException {
List<Dependency> depends = req.getDependencies();
if (depends.isEmpty()) {
// is source node
DbQueryRequest myQ = req.getDataQuery(property, timeOut, cache);
if (myQ != null) {
addDataQuery(req, myQ, queries);
}
} else {
for (Dependency dep : depends) {
// TODO: Optimize dTime/fTime to use bulk query mechanism,
// small case that is a not easy to get right with a bulk
// query
if (dep.timeOffset == 0) {
getDataQuery(dep.node, property, timeOut, queries, cache);
}
}
}
}
private void addDataQuery(AbstractRequestableLevelNode req,
DbQueryRequest query,
LinkedHashMap<AbstractRequestableLevelNode, DbQueryRequest> queries) {
DbQueryRequest curQuery = queries.get(req);
if (curQuery == null) {
queries.put(req, query);
} else {
// merge
// assume same DB, fields, etc, should only be different
// time constraints since its the same node
RequestConstraint curDTs = curQuery.getConstraints()
.get("dataTime");
RequestConstraint myDTs = query.getConstraints().get("dataTime");
if (curDTs != null && myDTs != null) {
// only merge if both require dataTimes, otherwise one
// would be constrained when it needs everything, also
// assuming both to be in lists and needing to be merged
curDTs.setConstraintType(ConstraintType.IN);
Pattern split = Pattern.compile(",");
String[] curVals = split.split(curDTs.getConstraintValue());
String[] myVals = split.split(myDTs.getConstraintValue());
HashSet<String> dups = new HashSet<String>(curVals.length
+ myVals.length);
dups.addAll(Arrays.asList(curVals));
dups.addAll(Arrays.asList(myVals));
curDTs.setConstraintValueList(dups.toArray(new String[dups
.size()]));
}
}
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#
* getBaseUpdateConstraints(java.util.Map)
*/
@Override
public List<Map<String, RequestConstraint>> getBaseUpdateConstraints(
Map<String, RequestConstraint> constraints) {
List<Map<String, RequestConstraint>> result = new ArrayList<Map<String, RequestConstraint>>(
1);
result.add(constraints);
return result;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getRecord(com
* .raytheon.uf.common.dataplugin.PluginDataObject)
*/
@Override
public IDataRecord[] getRecord(PluginDataObject obj)
throws VizDataCubeException {
return getRecord(obj, Request.ALL, null);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.datastructure.IDataCubeAdapter#getRecord(com
* .raytheon.uf.common.dataplugin.PluginDataObject,
* com.raytheon.uf.common.datastorage.Request, java.lang.String)
*/
@Override
public IDataRecord[] getRecord(PluginDataObject obj, Request req,
String dataset) throws VizDataCubeException {
getRecords(Arrays.asList(obj), req, dataset);
IDataRecord[] result = (IDataRecord[]) obj.getMessageData();
obj.setMessageData(null);
return result;
}
/**
* Scan the inventory for AbstractRequestableLevelNodes that match the
* request constraints
*
* @param constraints
* @return
*/
protected abstract List<AbstractRequestableLevelNode> evaluateRequestConstraints(
Map<String, RequestConstraint> constraints);
/**
* @param queryTerms
* @return
*/
protected abstract List<DataTime> timeAgnosticQuery(
Map<String, RequestConstraint> queryTerms) throws VizException;
/**
* @param requesters
* @return
*/
protected abstract List<Object> getData(LayerProperty property,
List<AbstractRequestableData> requesters) throws VizException;
}

View file

@ -22,6 +22,7 @@ package com.raytheon.uf.viz.derivparam.inv;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
@ -32,6 +33,7 @@ import java.util.Set;
import java.util.SortedSet;
import java.util.concurrent.BlockingQueue;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.derivparam.tree.AbstractNode;
@ -43,6 +45,7 @@ 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.exception.VizCommunicationException;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.level.LevelMappingFactory;
import com.raytheon.uf.viz.core.level.LevelUtilities;
@ -179,9 +182,12 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
* tree and populates it with available derived parameters based on what is
* available from the base parameters.
*
* @throws VizException
*
*
*/
public synchronized void initTree(Map<String, DerivParamDesc> derParLibrary) {
public synchronized void initTree(Map<String, DerivParamDesc> derParLibrary)
throws VizException {
DerivedParameterGenerator.registerUpdateListener(this);
if (derParLibrary == null) {
this.derParLibrary = new HashMap<String, DerivParamDesc>(0);
@ -189,7 +195,8 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
this.derParLibrary = derParLibrary;
}
long startTime = System.currentTimeMillis();
DataTree newTree = createBaseTree();
DataTree newTree = null;
newTree = createBaseTree();
if (newTree == null) {
return;
}
@ -198,7 +205,13 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
allLevels = null;
dataTree = newTree;
for (SourceNode sourceNode : dataTree.getSourceNodes().values()) {
doSupplement(sourceNode);
try {
doSupplement(sourceNode);
} catch (VizCommunicationException e) {
// TODO need to recover from this
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
}
for (ParameterNode parameterNode : sourceNode.getChildNodes()
.values()) {
String value = parameterNode.getValue();
@ -216,7 +229,11 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
@Override
public void updateDerParLibrary(Map<String, DerivParamDesc> derParLibrary) {
initTree(derParLibrary);
try {
initTree(derParLibrary);
} catch (VizException e) {
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
}
}
public String getParameterUnit(String source, String parameter) {
@ -254,8 +271,10 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
* Resolve any Supplement Derived Parameters.
*
* @param sNode
* @throws VizCommunicationException
*/
private void doSupplement(SourceNode sNode) {
private void doSupplement(SourceNode sNode)
throws VizCommunicationException {
Set<StackEntry> nodata = new HashSet<StackEntry>();
Deque<StackEntry> stack = new ArrayDeque<StackEntry>();
for (DerivParamDesc desc : derParLibrary.values()) {
@ -300,7 +319,7 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
}
}
protected abstract DataTree createBaseTree();
protected abstract DataTree createBaseTree() throws VizException;
/**
* Handle a query for a time agnostic node.
@ -320,7 +339,7 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
protected Collection<String> getAllSources() {
if (allSources == null) {
if (dataTree == null) {
return null;
return Collections.emptyList();
} else {
return new ArrayList<String>(dataTree.getSources());
}
@ -452,10 +471,18 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
* See get allSources, same function but for levels
*
* @return
* @throws VizCommunicationException
*/
protected Collection<Level> getAllLevels() {
if (allLevels == null) {
return LevelMappingFactory.getInstance().getAllLevels();
try {
return LevelMappingFactory.getInstance().getAllLevels();
} catch (VizCommunicationException e) {
// TODO recover from this.
statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
e);
return Collections.emptyList();
}
} else {
return allLevels;
}
@ -552,7 +579,7 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
|| levelsToProcess == null || sourcesToProcess.isEmpty()
|| paramsToProcess.isEmpty() || levelsToProcess.isEmpty()
|| derParLibrary == null) {
return null;
return Collections.emptyList();
}
if (clazz != null) {
// when clazz == null we need to link the aliases to the source
@ -605,8 +632,13 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
Level level = lit.next();
AbstractRequestableLevelNode result = null;
if (derive) {
result = resolveNode(node, param, level, stack,
nodata);
try {
result = resolveNode(node, param, level, stack,
nodata);
} catch (VizCommunicationException e) {
statusHandler.handle(Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
} else {
ParameterNode pNode = node.getChildNode(param);
result = (AbstractRequestableLevelNode) (pNode == null ? null
@ -654,11 +686,17 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
List<AbstractRequestableLevelNode> choices = new ArrayList<AbstractRequestableLevelNode>();
for (String aliasModel : sourceAliases
.get(source)) {
AbstractRequestableLevelNode alias;
AbstractRequestableLevelNode alias = null;
if (derive) {
alias = resolveNode(
dataTree.getSourceNode(aliasModel),
param, level, stack, nodata);
try {
alias = resolveNode(
dataTree.getSourceNode(aliasModel),
param, level, stack, nodata);
} catch (VizCommunicationException e) {
statusHandler.handle(
Priority.PROBLEM,
e.getLocalizedMessage(), e);
}
} else {
ParameterNode pNode = node
.getChildNode(param);
@ -722,10 +760,12 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
* @param stack
* @param nodata
* @return
* @throws VizCommunicationException
*/
protected synchronized AbstractRequestableLevelNode resolveNode(
SourceNode sourceNode, String param, Level level,
Deque<StackEntry> stack, Set<StackEntry> nodata) {
Deque<StackEntry> stack, Set<StackEntry> nodata)
throws VizCommunicationException {
ParameterNode pNode = sourceNode.getChildNode(param);
LevelNode lNode = pNode == null ? null : pNode.getChildNode(Long
.toString(level.getId()));
@ -861,8 +901,14 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
}// method loop
}
if (level.isRangeLevel()) {
Level upperLevel = level.getUpperLevel();
Level lowerLevel = level.getLowerLevel();
Level upperLevel;
Level lowerLevel;
try {
upperLevel = level.getUpperLevel();
lowerLevel = level.getLowerLevel();
} catch (CommunicationException e) {
throw new VizCommunicationException(e);
}
List<AbstractRequestableLevelNode> nodes = new ArrayList<AbstractRequestableLevelNode>();
int endCount = 0;
@ -956,10 +1002,11 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
* @param nodata
* @return Should be Either some IStaticData or an
* AbstractRequestableLevelNode
* @throws VizCommunicationException
*/
private synchronized Object resolveField(SourceNode sourceNode,
Level level, IDerivParamField ifield, Deque<StackEntry> stack,
Set<StackEntry> nodata) {
Set<StackEntry> nodata) throws VizCommunicationException {
// process the next field
if (ifield.getClass() == DerivParamConstantField.class) {
return new FloatRequestableData(
@ -1004,10 +1051,14 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
if (type == null) {
fieldLevel = level;
} else if (level.isRangeLevel()) {
if (type == LevelType.Upper) {
fieldLevel = level.getUpperLevel();
} else {
fieldLevel = level.getLowerLevel();
try {
if (type == LevelType.Upper) {
fieldLevel = level.getUpperLevel();
} else {
fieldLevel = level.getLowerLevel();
}
} catch (CommunicationException e) {
throw new VizCommunicationException(e);
}
} else {
SortedSet<Level> levels = null;
@ -1067,7 +1118,7 @@ public abstract class AbstractInventory implements DerivParamUpdateListener {
protected abstract LevelNode getCubeNode(SourceNode sNode,
DerivParamField field, Deque<StackEntry> stack,
Set<StackEntry> nodata);
Set<StackEntry> nodata) throws VizCommunicationException;
protected abstract AbstractDerivedLevelNode getImportNode(
AbstractRequestableData nodeToImport, SourceNode destSourceNode,

View file

@ -29,6 +29,7 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import com.raytheon.uf.common.serialization.ISerializableObject;
import com.raytheon.uf.common.serialization.adapters.UnitAdapter;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
import com.raytheon.uf.viz.core.level.LevelMapping;
import com.raytheon.uf.viz.core.level.LevelMappingFactory;
@ -82,14 +83,14 @@ public class DerivParamField implements ISerializableObject, IDerivParamField {
this.param = param;
}
public LevelMapping getLevelMapping() {
public LevelMapping getLevelMapping() throws VizCommunicationException {
if (levelType == null && level != null) {
setLevel(level);
}
return levelMapping;
}
public LevelType getLevelType() {
public LevelType getLevelType() throws VizCommunicationException {
if (levelType == null && level != null) {
setLevel(level);
}
@ -125,8 +126,9 @@ public class DerivParamField implements ISerializableObject, IDerivParamField {
* @param level
* @return true upon success, false if the token is not recognized, in which
* case levelType and levelMapping will both be reset to null
* @throws VizCommunicationException
*/
public boolean setLevel(String level) {
public boolean setLevel(String level) throws VizCommunicationException {
levelType = LevelType.parseLevel(level);
if (levelType == LevelType.LevelMapping) {
levelMapping = LevelMappingFactory.getInstance()

View file

@ -38,9 +38,8 @@ import com.raytheon.uf.common.serialization.ISerializableObject;
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.exception.VizCommunicationException;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.status.StatusConstants;
import com.raytheon.uf.viz.derivparam.Activator;
/**
* Metadata about a derived parameter method.
@ -61,7 +60,8 @@ import com.raytheon.uf.viz.derivparam.Activator;
@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement
public class DerivParamMethod implements ISerializableObject {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(DerivParamMethod.class);
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(DerivParamMethod.class);
public enum FrameworkMethod {
ALIAS, MODELRUN, TIMERANGE, OR, UNION, SUPPLEMENT, IMPORT, NODERIVATION;
@ -149,7 +149,7 @@ public class DerivParamMethod implements ISerializableObject {
fields.add(field);
}
public Set<Level> getValidLevels() {
public Set<Level> getValidLevels() throws VizCommunicationException {
if (validLevels == null && levels != null && levels.length() > 0) {
ValidLevelGenerator lvlGen = new ValidLevelGenerator();
validLevels = lvlGen.generateLevels(levels);
@ -253,13 +253,13 @@ public class DerivParamMethod implements ISerializableObject {
tmp.append(pFieldTokens[k]);
}
statusHandler.handle(
Priority.SIGNIFICANT,
"Derived parameter ["
+ "field ["
+ field.getParam()
+ "], contains unknown parameter modifier ["
+ tmp.toString() + "]");
statusHandler
.handle(Priority.SIGNIFICANT,
"Derived parameter ["
+ "field ["
+ field.getParam()
+ "], contains unknown parameter modifier ["
+ tmp.toString() + "]");
}
}
}

View file

@ -28,10 +28,12 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.level.CompareType;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.LevelFactory;
import com.raytheon.uf.common.dataplugin.level.MasterLevel;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
import com.raytheon.uf.viz.core.level.LevelMapping;
import com.raytheon.uf.viz.core.level.LevelMappingFactory;
@ -72,7 +74,7 @@ public class ValidLevelGenerator {
}
public Set<Level> generateLevels(String validLevelsString)
throws IllegalArgumentException {
throws IllegalArgumentException, VizCommunicationException {
masterLevels = new HashMap<MasterLevel, Set<Level>>();
validLevels = new HashSet<Level>();
masterLevelsHandled = new HashSet<MasterLevel>();
@ -121,7 +123,11 @@ public class ValidLevelGenerator {
if (tokensToProcess.size() > 0) {
for (String token : tokensToProcess) {
processLevelToken(token);
try {
processLevelToken(token);
} catch (CommunicationException e) {
throw new VizCommunicationException(e);
}
}
} else {
for (Set<Level> levels : masterLevels.values()) {
@ -133,7 +139,8 @@ public class ValidLevelGenerator {
return validLevels;
}
private void processLevelToken(String token) {
private void processLevelToken(String token)
throws VizCommunicationException, CommunicationException {
boolean negate = token.charAt(0) == '!';
int rangeIndex = token.indexOf('>');
@ -318,7 +325,8 @@ public class ValidLevelGenerator {
}
}
private Type determineType(String token) {
private Type determineType(String token) throws CommunicationException,
VizCommunicationException {
Type rval = null;
LevelMapping mapping = lmf.getLevelMappingForKey(token);

View file

@ -26,6 +26,7 @@ import java.util.Set;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.dataquery.requests.TimeQueryRequest;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.derivparam.library.DerivParamDesc;
@ -67,11 +68,13 @@ public abstract class AbstractAliasLevelNode extends AbstractDerivedLevelNode {
}
@Override
public Set<DataTime> timeQueryInternal(boolean latestOnly,
public Set<DataTime> timeQueryInternal(TimeQueryRequest originalRequest,
boolean latestOnly,
Map<AbstractRequestableLevelNode, Set<DataTime>> cache,
Map<AbstractRequestableLevelNode, Set<DataTime>> latestOnlyCache)
throws VizException {
return sourceNode.timeQuery(latestOnly, cache, latestOnlyCache);
return sourceNode.timeQuery(originalRequest, latestOnly, cache,
latestOnlyCache);
}
@Override

View file

@ -31,6 +31,7 @@ import java.util.Set;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.dataquery.requests.TimeQueryRequest;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.catalog.CatalogQuery;
import com.raytheon.uf.viz.core.catalog.LayerProperty;
@ -270,7 +271,8 @@ public abstract class AbstractCubeLevelNode extends AbstractDerivedLevelNode {
Map<String, RequestConstraint> requestContraintsToFilter);
@Override
public Set<DataTime> timeQueryInternal(boolean latestOnly,
public Set<DataTime> timeQueryInternal(TimeQueryRequest originalRequest,
boolean latestOnly,
Map<AbstractRequestableLevelNode, Set<DataTime>> cache,
Map<AbstractRequestableLevelNode, Set<DataTime>> latestOnlyCache)
throws VizException {
@ -299,8 +301,8 @@ public abstract class AbstractCubeLevelNode extends AbstractDerivedLevelNode {
results.addAll(mergedTimeQuery(merge(requests), latestOnly));
for (AbstractRequestableLevelNode request : requests) {
results.addAll(request
.timeQuery(latestOnly, cache, latestOnlyCache));
results.addAll(request.timeQuery(originalRequest, latestOnly,
cache, latestOnlyCache));
}
return results;
}

View file

@ -243,7 +243,8 @@ public abstract class AbstractDerivedLevelNode extends
}
@Override
protected TimeQueryRequest getTimeQueryInternal(boolean latestOnly,
protected TimeQueryRequest getTimeQueryInternal(
TimeQueryRequest originalRequest, boolean latestOnly,
Map<AbstractRequestableLevelNode, Set<DataTime>> cache)
throws VizException {
throw new UnsupportedOperationException(

View file

@ -205,7 +205,8 @@ public abstract class AbstractRequestableLevelNode extends LevelNode {
protected abstract List<AbstractRequestableData> processDataQueryResults(
DbQueryResponse queryResponse) throws VizException;
public Set<DataTime> timeQuery(boolean latestOnly,
public Set<DataTime> timeQuery(TimeQueryRequest originalRequest,
boolean latestOnly,
Map<AbstractRequestableLevelNode, Set<DataTime>> cache,
Map<AbstractRequestableLevelNode, Set<DataTime>> latestOnlyCache)
throws VizException {
@ -215,15 +216,16 @@ public abstract class AbstractRequestableLevelNode extends LevelNode {
return latestOnlyCache.get(this);
}
Set<DataTime> results = timeQueryInternal(latestOnly, cache,
latestOnlyCache);
Set<DataTime> results = timeQueryInternal(originalRequest, latestOnly,
cache, latestOnlyCache);
if (cache != null && !latestOnly) {
cache.put(this, results);
}
return results;
}
public TimeQueryRequest getTimeQuery(boolean latestOnly,
public TimeQueryRequest getTimeQuery(TimeQueryRequest originalRequest,
boolean latestOnly,
Map<AbstractRequestableLevelNode, Set<DataTime>> cache,
Map<AbstractRequestableLevelNode, Set<DataTime>> latestOnlyCache)
throws VizException {
@ -233,7 +235,7 @@ public abstract class AbstractRequestableLevelNode extends LevelNode {
return null;
}
return getTimeQueryInternal(latestOnly, cache);
return getTimeQueryInternal(originalRequest, latestOnly, cache);
}
public void setTimeQueryResults(boolean latestOnly,
@ -386,13 +388,14 @@ public abstract class AbstractRequestableLevelNode extends LevelNode {
return rval;
}
protected abstract Set<DataTime> timeQueryInternal(boolean latestOnly,
protected abstract Set<DataTime> timeQueryInternal(
TimeQueryRequest originalRequest, boolean latestOnly,
Map<AbstractRequestableLevelNode, Set<DataTime>> cache,
Map<AbstractRequestableLevelNode, Set<DataTime>> latestOnlyCache)
throws VizException;
protected abstract TimeQueryRequest getTimeQueryInternal(
boolean latestOnly,
TimeQueryRequest originalRequest, boolean latestOnly,
Map<AbstractRequestableLevelNode, Set<DataTime>> cache)
throws VizException;
@ -408,8 +411,9 @@ public abstract class AbstractRequestableLevelNode extends LevelNode {
Map<AbstractRequestableLevelNode, List<AbstractRequestableData>> cache)
throws VizException;
protected Set<DataTime> timeQuery(boolean latestOnly) throws VizException {
return timeQuery(latestOnly,
protected Set<DataTime> timeQuery(TimeQueryRequest originalRequest,
boolean latestOnly) throws VizException {
return timeQuery(originalRequest, latestOnly,
new HashMap<AbstractRequestableLevelNode, Set<DataTime>>(),
new HashMap<AbstractRequestableLevelNode, Set<DataTime>>());
}

View file

@ -26,6 +26,7 @@ import java.util.Map;
import java.util.Set;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataquery.requests.TimeQueryRequest;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.catalog.LayerProperty;
import com.raytheon.uf.viz.core.exception.VizException;
@ -102,7 +103,8 @@ public class CompositeAverageLevelNode extends UnionLevelNode {
* boolean, java.util.Map)
*/
@Override
public Set<DataTime> timeQueryInternal(boolean latestOnly,
public Set<DataTime> timeQueryInternal(TimeQueryRequest originalRequest,
boolean latestOnly,
Map<AbstractRequestableLevelNode, Set<DataTime>> cache,
Map<AbstractRequestableLevelNode, Set<DataTime>> latestOnlyCache)
throws VizException {
@ -114,8 +116,8 @@ public class CompositeAverageLevelNode extends UnionLevelNode {
for (AbstractRequestableLevelNode request : requests) {
// Do not request just latest only because if two nodes have
// different latests than this will return no times
Set<DataTime> times = request.timeQuery(false, cache,
latestOnlyCache);
Set<DataTime> times = request.timeQuery(originalRequest, false,
cache, latestOnlyCache);
if (times == TIME_AGNOSTIC) {
continue;
} else if (results == TIME_AGNOSTIC) {

View file

@ -32,6 +32,7 @@ import java.util.Map.Entry;
import java.util.Set;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataquery.requests.TimeQueryRequest;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.DataTime.FLAG;
import com.raytheon.uf.viz.core.catalog.LayerProperty;
@ -65,6 +66,8 @@ import com.raytheon.uf.viz.derivparam.library.IDerivParamField;
public class DerivedLevelNode extends AbstractDerivedLevelNode {
private static final int TIME_QUERY_CACHE_TIME = 30000;
private Map<IDerivParamField, AbstractRequestableData> fieldStaticData = null;
private Map<DerivParamField, AbstractRequestableLevelNode> fields = null;
@ -75,6 +78,8 @@ public class DerivedLevelNode extends AbstractDerivedLevelNode {
*/
private Map<DerivParamField, Set<DataTime>> timeCache = null;
private long lastTimeQuery = 0;
private int dt;
public DerivedLevelNode(Level level, DerivParamDesc desc,
@ -145,10 +150,12 @@ public class DerivedLevelNode extends AbstractDerivedLevelNode {
}
@Override
public Set<DataTime> timeQueryInternal(boolean latestOnly,
public Set<DataTime> timeQueryInternal(TimeQueryRequest originalRequest,
boolean latestOnly,
Map<AbstractRequestableLevelNode, Set<DataTime>> cache,
Map<AbstractRequestableLevelNode, Set<DataTime>> latestOnlyCache)
throws VizException {
this.lastTimeQuery = System.currentTimeMillis();
Map<DerivParamField, Set<DataTime>> timeCache = new HashMap<DerivParamField, Set<DataTime>>();
// We have a derived parameter for the requested grid
Set<DataTime> availableDataTimes = null;
@ -171,8 +178,8 @@ public class DerivedLevelNode extends AbstractDerivedLevelNode {
}
for (DerivParamField field : fieldsKeys) {
AbstractRequestableLevelNode node = fields.get(field);
Set<DataTime> queryDataTimes = node.timeQuery(false, cache,
latestOnlyCache);
Set<DataTime> queryDataTimes = node.timeQuery(originalRequest,
false, cache, latestOnlyCache);
timeCache.put(field, queryDataTimes);
if (queryDataTimes == TIME_AGNOSTIC) {
if (availableDataTimes == null) {
@ -277,8 +284,10 @@ public class DerivedLevelNode extends AbstractDerivedLevelNode {
int timeOut,
Map<AbstractRequestableLevelNode, List<AbstractRequestableData>> cache)
throws VizException {
if (this.timeCache == null) {
this.timeQuery(false);
if (this.timeCache == null
|| this.lastTimeQuery + TIME_QUERY_CACHE_TIME < System
.currentTimeMillis()) {
this.timeQuery(null, false);
}
// keep a reference for scope of method

View file

@ -24,8 +24,8 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import java.util.Set;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.time.DataTime;
@ -70,7 +70,7 @@ public class ModelRunLevelNode extends AbstractAliasLevelNode {
int timeOut,
Map<AbstractRequestableLevelNode, List<AbstractRequestableData>> cache)
throws VizException {
Set<DataTime> allTimes = this.timeQuery(false);
Set<DataTime> allTimes = this.timeQuery(null, false);
Set<DataTime> neededTimes = null;
DataTime[] requestedTimes = property.getSelectedEntryTime();
if (requestedTimes == null) {

View file

@ -28,6 +28,7 @@ import java.util.Set;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.dataquery.requests.TimeQueryRequest;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.catalog.LayerProperty;
import com.raytheon.uf.viz.core.exception.VizException;
@ -116,7 +117,7 @@ public class OrLevelNode extends AbstractDerivedLevelNode {
Set<DataTime> requestedTimes = null;
DataTime[] requestedTimesArr = property.getSelectedEntryTime();
if (requestedTimesArr == null) {
requestedTimes = this.timeQuery(false);
requestedTimes = this.timeQuery(null, false);
} else {
requestedTimes = new HashSet<DataTime>(
Arrays.asList(requestedTimesArr));
@ -144,14 +145,15 @@ public class OrLevelNode extends AbstractDerivedLevelNode {
}
@Override
protected Set<DataTime> timeQueryInternal(boolean latestOnly,
protected Set<DataTime> timeQueryInternal(TimeQueryRequest originalRequest,
boolean latestOnly,
Map<AbstractRequestableLevelNode, Set<DataTime>> cache,
Map<AbstractRequestableLevelNode, Set<DataTime>> latestOnlyCache)
throws VizException {
Set<DataTime> results = new HashSet<DataTime>();
for (AbstractRequestableLevelNode node : nodes) {
Set<DataTime> times = node.timeQuery(latestOnly, cache,
latestOnlyCache);
Set<DataTime> times = node.timeQuery(originalRequest, latestOnly,
cache, latestOnlyCache);
if (times == AbstractRequestableLevelNode.TIME_AGNOSTIC) {
return times;
} else {

View file

@ -99,7 +99,8 @@ public class StaticDataLevelNode extends AbstractDerivedLevelNode {
}
@Override
public Set<DataTime> timeQueryInternal(boolean latestOnly,
public Set<DataTime> timeQueryInternal(TimeQueryRequest originalRequest,
boolean latestOnly,
Map<AbstractRequestableLevelNode, Set<DataTime>> cache,
Map<AbstractRequestableLevelNode, Set<DataTime>> latestOnlyCache)
throws VizException {
@ -107,7 +108,8 @@ public class StaticDataLevelNode extends AbstractDerivedLevelNode {
}
@Override
protected TimeQueryRequest getTimeQueryInternal(boolean latestOnly,
protected TimeQueryRequest getTimeQueryInternal(
TimeQueryRequest originalRequest, boolean latestOnly,
Map<AbstractRequestableLevelNode, Set<DataTime>> cache)
throws VizException {
return null;

View file

@ -28,6 +28,7 @@ import java.util.Map.Entry;
import java.util.Set;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataquery.requests.TimeQueryRequest;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.catalog.LayerProperty;
import com.raytheon.uf.viz.core.exception.VizException;
@ -82,7 +83,7 @@ public class TimeRangeLevelNode extends AbstractAliasLevelNode {
int timeOut,
Map<AbstractRequestableLevelNode, List<AbstractRequestableData>> cache)
throws VizException {
Set<DataTime> allTime = sourceNode.timeQuery(false);
Set<DataTime> allTime = sourceNode.timeQuery(null, false);
Map<DataTime, List<DataTime>> goodTimes = new HashMap<DataTime, List<DataTime>>();
Set<DataTime> timesToRequest = new HashSet<DataTime>();
for (DataTime time : allTime) {
@ -126,12 +127,13 @@ public class TimeRangeLevelNode extends AbstractAliasLevelNode {
}
@Override
public Set<DataTime> timeQueryInternal(boolean latestOnly,
public Set<DataTime> timeQueryInternal(TimeQueryRequest originalRequest,
boolean latestOnly,
Map<AbstractRequestableLevelNode, Set<DataTime>> cache,
Map<AbstractRequestableLevelNode, Set<DataTime>> latestOnlyCache)
throws VizException {
Set<DataTime> allTime = sourceNode.timeQuery(false, cache,
latestOnlyCache);
Set<DataTime> allTime = sourceNode.timeQuery(originalRequest, false,
cache, latestOnlyCache);
Set<DataTime> goodTimes = new HashSet<DataTime>();
for (DataTime time : allTime) {
if (allTime.containsAll(calculateNeededTimes(time))) {

View file

@ -30,6 +30,7 @@ import java.util.Map.Entry;
import java.util.Set;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataquery.requests.TimeQueryRequest;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.catalog.LayerProperty;
import com.raytheon.uf.viz.core.exception.VizException;
@ -142,7 +143,8 @@ public class UnionLevelNode extends AbstractDerivedLevelNode {
}
@Override
public Set<DataTime> timeQueryInternal(boolean latestOnly,
public Set<DataTime> timeQueryInternal(TimeQueryRequest originalRequest,
boolean latestOnly,
Map<AbstractRequestableLevelNode, Set<DataTime>> cache,
Map<AbstractRequestableLevelNode, Set<DataTime>> latestOnlyCache)
throws VizException {
@ -153,8 +155,8 @@ public class UnionLevelNode extends AbstractDerivedLevelNode {
List<AbstractRequestableLevelNode> requests = new ArrayList<AbstractRequestableLevelNode>(
nodes);
for (AbstractRequestableLevelNode request : requests) {
Set<DataTime> times = request.timeQuery(latestOnly, cache,
latestOnlyCache);
Set<DataTime> times = request.timeQuery(originalRequest,
latestOnly, cache, latestOnlyCache);
if (times == TIME_AGNOSTIC) {
continue;
} else if (results == TIME_AGNOSTIC) {

View file

@ -27,8 +27,10 @@ Require-Bundle: org.eclipse.ui,
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package: com.raytheon.uf.viz.objectiveanalysis.rsc
Import-Package: com.raytheon.uf.common.dataplugin.grib.spatial.projections,
Import-Package: com.raytheon.uf.common.comm,
com.raytheon.uf.common.dataplugin.grib.spatial.projections,
com.raytheon.uf.common.dataplugin.level,
com.raytheon.uf.common.dataplugin.radar,
com.raytheon.uf.viz.derivparam.library,
com.raytheon.uf.viz.derivparam.tree,
com.raytheon.viz.ui,

View file

@ -27,18 +27,20 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import com.raytheon.uf.common.comm.CommunicationException;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.level.Level;
import com.raytheon.uf.common.dataplugin.level.LevelFactory;
import com.raytheon.uf.common.dataplugin.level.MasterLevel;
import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.exception.VizCommunicationException;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.level.LevelMappingFactory;
import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.style.level.SingleLevel;
import com.raytheon.uf.viz.core.style.level.Level.LevelType;
import com.raytheon.uf.viz.core.style.level.SingleLevel;
/**
* Resource Data for Objective Analysis
@ -161,8 +163,8 @@ public class OAResourceData extends AbstractRequestableResourceData {
throw new UnsupportedOperationException("Unsupported level for OA "
+ levelKey);
}
level.setValue(Double.parseDouble(levelKey.substring(0, levelKey
.length() - 2)));
level.setValue(Double.parseDouble(levelKey.substring(0,
levelKey.length() - 2)));
return level;
}
@ -194,7 +196,12 @@ public class OAResourceData extends AbstractRequestableResourceData {
DataTime[] times = super.getAvailableTimes();
if (this.levelKey.equals(ALL_TILTS)) {
LevelFactory factory = LevelFactory.getInstance();
MasterLevel ml = factory.getMasterLevel("TILT");
MasterLevel ml;
try {
ml = factory.getMasterLevel("TILT");
} catch (CommunicationException e) {
throw new VizCommunicationException(e);
}
Set<Level> allLevels = LevelMappingFactory.getInstance()
.getAllLevels();
List<Level> levels = new ArrayList<Level>();

View file

@ -10,7 +10,7 @@ void main(void)
{
vec2 xy = gl_FragCoord.xy;
vec4 radarVal = texture2D(radarData,gl_TexCoord[0].st);
vec4 curVal = texture2D(mosaicTexture, vec2((xy.x / width), (xy.y / height)));
vec4 curVal = texture2D(mosaicTexture, vec2((xy.x / float(width)), (xy.y / float(height))));
if ( radarVal.r > curVal.r ) {
gl_FragColor = vec4(radarVal.r,0.0,0.0,1.0);
} else {

View file

@ -1,16 +0,0 @@
// this shader program sets values into a mosaic texture
// which is the same size as the screen (frame buffer)
// Use depth buffer texture
uniform sampler2D radarData;
uniform sampler2D mosaicTexture;
uniform sampler2D depthTexture;
uniform int height;
uniform int width;
void main(void)
{
// TODO: Mimic mosaicMax except use depthTexture to look up current
// depth buffer info (which will actually store the current distance
}

View file

@ -1,10 +0,0 @@
// this shader program sets values into a mosaic texture
// which is the same size as the screen (frame buffer)
uniform sampler2D radarData;
void main(void)
{
vec4 radarVal = texture2D(radarData,gl_TexCoord[0].st);
gl_FragColor = vec4(radarVal.r,0.0,0.0,1.0);
}

View file

@ -1,24 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
<extension
point="com.raytheon.viz.core.gl.shader">
<shader
loaderClass="com.raytheon.uf.viz.radar.gl.mosaic.MosaicShaderLoader"
programName="mosaicMaxVal">
</shader>
<shader
loaderClass="com.raytheon.uf.viz.radar.gl.mosaic.MosaicShaderLoader"
programName="mosaicMinDist">
</shader>
</extension>
<extension
point="com.raytheon.uf.viz.core.graphicsExtension">
<graphicsExtension
class="com.raytheon.uf.viz.radar.gl.GLRadialMeshExtension">
</graphicsExtension>
<graphicsExtension
class="com.raytheon.uf.viz.radar.gl.mosaic.GLRadarMosaicRendererFactory">
class="com.raytheon.uf.viz.radar.gl.mosaic.GLRadarMosaicImageExtension">
</graphicsExtension>
</extension>
</plugin>

View file

@ -74,6 +74,6 @@ public class GLRadialMeshExtension extends GraphicsExtension<IGLTarget>
*/
@Override
public int getCompatibilityValue(IGLTarget target) {
return Compatibilty.TARGET_COMPATIBLE.value;
return Compatibilty.TARGET_COMPATIBLE;
}
}

View file

@ -1,559 +0,0 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.radar.gl;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Collection;
import org.eclipse.swt.graphics.RGB;
import org.geotools.coverage.grid.GeneralGridGeometry;
import com.raytheon.uf.common.colormap.IColorMap;
import com.raytheon.uf.viz.core.DrawableCircle;
import com.raytheon.uf.viz.core.DrawableColorMap;
import com.raytheon.uf.viz.core.DrawableImage;
import com.raytheon.uf.viz.core.DrawableLine;
import com.raytheon.uf.viz.core.DrawableString;
import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.data.IDataPreparer;
import com.raytheon.uf.viz.core.data.IRenderedImageCallback;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.IFont;
import com.raytheon.uf.viz.core.drawables.IFont.Style;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
import com.raytheon.uf.viz.core.drawables.IShadedShape;
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.geom.PixelCoordinate;
import com.raytheon.viz.core.gl.IGLTarget;
import com.vividsolutions.jts.geom.LinearRing;
/**
* IGraphicsTarget for mosaicing radar data, delegates all calls to an IGLTarget
*
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 22, 2010 mschenke Initial creation
* Jul 19, 2010 #5952 bkowal Defined the 'updateExtent' method.
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class MosaicGLTarget implements IGraphicsTarget {
private IGLTarget delegate;
public MosaicGLTarget(IGLTarget delegateTarget) {
this.delegate = delegateTarget;
}
/* Important functions!!! */
public boolean drawRaster(IImage image, PixelCoverage extent,
PaintProperties paintProps, RasterMode mode) throws VizException {
return delegate.drawRaster(image, extent, paintProps, mode,
"mosaicMaxVal");
}
public boolean drawRaster(IImage image, PixelCoverage extent,
PaintProperties paintProps) throws VizException {
return delegate.drawRaster(image, extent, paintProps, "mosaicMaxVal");
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.IGraphicsTarget#drawRasters(com.raytheon.uf.
* viz.core.drawables.PaintProperties,
* com.raytheon.uf.viz.core.DrawableImage[])
*/
@Override
public boolean drawRasters(PaintProperties paintProps,
DrawableImage... images) throws VizException {
return delegate.drawRasters("mosaicMaxVal", paintProps, images);
}
/* Standard delegate functions */
public void beginFrame(IRenderableDisplay display, boolean isClearBackground) {
delegate.beginFrame(display, isClearBackground);
}
public IColorMap buildColorMap(String name) throws VizException {
return delegate.buildColorMap(name);
}
public void clearClippingPlane() {
delegate.clearClippingPlane();
}
public IShadedShape createShadedShape(boolean mutable,
IDescriptor descriptor, boolean tesselate) {
return delegate.createShadedShape(mutable, descriptor, tesselate);
}
public IWireframeShape createWireframeShape(boolean mutable,
GeneralGridGeometry geom, float simplificationLevel,
boolean spatialChopFlag, IExtent extent) {
return delegate.createWireframeShape(mutable, geom,
simplificationLevel, spatialChopFlag, extent);
}
public IWireframeShape createWireframeShape(boolean mutableFlag,
GeneralGridGeometry geom) {
return delegate.createWireframeShape(mutableFlag, geom);
}
public IWireframeShape createWireframeShape(boolean mutable,
IDescriptor descriptor, float simplificationLevel,
boolean spatialChopFlag, IExtent extent) {
return delegate.createWireframeShape(mutable, descriptor,
simplificationLevel, spatialChopFlag, extent);
}
public IWireframeShape createWireframeShape(boolean mutable,
IDescriptor descriptor, float simplificationLevel) {
return delegate.createWireframeShape(mutable, descriptor,
simplificationLevel);
}
public IWireframeShape createWireframeShape(boolean mutable,
IDescriptor descriptor) {
return delegate.createWireframeShape(mutable, descriptor);
}
public void dispose() {
delegate.dispose();
}
public void drawArc(double x1, double y1, double z1, double radius,
RGB color, float width, int startAzimuth, int arcWidth,
LineStyle lineStyle, boolean includeSides) throws VizException {
delegate.drawArc(x1, y1, z1, radius, color, width, startAzimuth,
arcWidth, lineStyle, includeSides);
}
public void drawCircle(double x1, double y1, double z1, double radius,
RGB color, float width) throws VizException {
delegate.drawCircle(x1, y1, z1, radius, color, width);
}
public void drawColorRamp(IColorMap colorMap, IExtent pixelExtent,
float blendAlpha) throws VizException {
delegate.drawColorRamp(colorMap, pixelExtent, blendAlpha);
}
public void drawCylinder(PixelCoordinate coord, RGB color, float alpha,
double height, double baseRadius, double topRadius, int sideCount,
int sliceCount, double rotation, double lean) {
delegate.drawCylinder(coord, color, alpha, height, baseRadius,
topRadius, sideCount, sliceCount, rotation, lean);
}
public void drawFilledCircle(double x, double y, double z, double radius,
RGB color) throws VizException {
delegate.drawFilledCircle(x, y, z, radius, color);
}
public void drawLine(double x1, double y1, double z1, double x2, double y2,
double z2, RGB color, float width, LineStyle lineStyle)
throws VizException {
delegate.drawLine(x1, y1, z1, x2, y2, z2, color, width, lineStyle);
}
public void drawLine(double x1, double y1, double z1, double x2, double y2,
double z2, RGB color, float width) throws VizException {
delegate.drawLine(x1, y1, z1, x2, y2, z2, color, width);
}
public void drawPoint(double x, double y, double z, RGB color,
PointStyle pointStyle) throws VizException {
delegate.drawPoint(x, y, z, color, pointStyle);
}
public void drawRect(IExtent pe, RGB color, float lineWidth, double alpha)
throws VizException {
delegate.drawRect(pe, color, lineWidth, alpha);
}
public void drawShadedPolygon(LinearRing poly, RGB color, double alpha,
byte[] pattern) throws VizException {
delegate.drawShadedPolygon(poly, color, alpha, pattern);
}
public void drawShadedRect(IExtent pe, RGB color, double alpha,
byte[] pattern) throws VizException {
delegate.drawShadedRect(pe, color, alpha, pattern);
}
public void drawShadedShape(IShadedShape shape, float alpha)
throws VizException {
delegate.drawShadedShape(shape, alpha);
}
public void drawString(IFont font, String text, double x, double y,
double z, TextStyle textStyle, RGB color,
HorizontalAlignment horizontalAlignment, Double rotation)
throws VizException {
delegate.drawString(font, text, x, y, z, textStyle, color,
horizontalAlignment, rotation);
}
public void drawString(IFont font, String text, double x, double y,
double z, TextStyle textStyle, RGB color,
HorizontalAlignment horizontalAlignment,
VerticalAlignment verticalAlignment, Double rotation)
throws VizException {
delegate.drawString(font, text, x, y, z, textStyle, color,
horizontalAlignment, verticalAlignment, rotation);
}
public void drawStrings(IFont font, String[] text, double x, double y,
double z, TextStyle textStyle, RGB[] colors,
HorizontalAlignment horizontalAlignment,
VerticalAlignment verticalAlignment) throws VizException {
delegate.drawStrings(font, text, x, y, z, textStyle, colors,
horizontalAlignment, verticalAlignment);
}
public void drawString(IFont font, String string, double xPos, double yPos,
double zPos, TextStyle textStyle, RGB color,
HorizontalAlignment horizontalAlignment,
VerticalAlignment verticalAlignment, Double rotation, float alpha,
double magnification) throws VizException {
// not implemented
}
public void drawWireframeShape(IWireframeShape shape, RGB color,
float lineWidth, LineStyle lineStyle, IFont font)
throws VizException {
delegate.drawWireframeShape(shape, color, lineWidth, lineStyle, font);
}
public void drawWireframeShape(IWireframeShape shape, RGB color,
float lineWidth, LineStyle lineStyle, IFont font, float alpha)
throws VizException {
delegate.drawWireframeShape(shape, color, lineWidth, lineStyle, font,
alpha);
}
public void drawWireframeShape(IWireframeShape shape, RGB color,
float lineWidth, LineStyle lineStyle) throws VizException {
delegate.drawWireframeShape(shape, color, lineWidth, lineStyle);
}
public void drawWireframeShape(IWireframeShape shape, RGB color,
float lineWidth, LineStyle lineStyle, float alpha)
throws VizException {
delegate.drawWireframeShape(shape, color, lineWidth, lineStyle, alpha);
}
public void drawWireframeShape(IWireframeShape shape, RGB color,
float lineWidth) throws VizException {
delegate.drawWireframeShape(shape, color, lineWidth);
}
public void endFrame() {
delegate.endFrame();
}
public IFont getDefaultFont() {
return delegate.getDefaultFont();
}
public double[] getPointOnCircle(double x1, double y1, double z1,
double radius, double angle) throws VizException {
return delegate.getPointOnCircle(x1, y1, z1, radius, angle);
}
public Rectangle2D getStringBounds(IFont font, String text) {
return delegate.getStringBounds(font, text);
}
public String getViewType() {
return delegate.getViewType();
}
public void init() {
delegate.init();
}
public IFont initializeFont(File fontFile, float size, Style[] styles) {
return delegate.initializeFont(fontFile, size, styles);
}
public IFont initializeFont(String fontName, float size, Style[] styles) {
return delegate.initializeFont(fontName, size, styles);
}
public IFont initializeFont(String font) {
return delegate.initializeFont(font);
}
@Deprecated
public IImage initializeRaster(IDataPreparer preparer,
ColorMapParameters optionalParams) {
return delegate.initializeRaster(preparer, optionalParams);
}
public IImage initializeRaster(IRenderedImageCallback imageCallback) {
return delegate.initializeRaster(imageCallback);
}
public boolean isNeedsRefresh() {
return delegate.isNeedsRefresh();
}
public void resize() {
delegate.resize();
}
public BufferedImage screenshot() {
return delegate.screenshot();
}
public void setBackgroundColor(RGB backgroundColor) {
delegate.setBackgroundColor(backgroundColor);
}
public void setNeedsRefresh(boolean needsRefresh) {
delegate.setNeedsRefresh(needsRefresh);
}
public void setupClippingPlane(IExtent extent) {
delegate.setupClippingPlane(extent);
}
public void setUseBuiltinColorbar(boolean isColorbarDisplayed) {
delegate.setUseBuiltinColorbar(isColorbarDisplayed);
}
public void stage(IImage image) throws VizException {
delegate.stage(image);
}
public void updateExtent(IExtent updatedExtent) {
/* Do Nothing */
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.IGraphicsTarget#getStringBounds(com.raytheon
* .uf.viz.core.drawables.IFont, java.lang.String[],
* com.raytheon.uf.viz.core.IGraphicsTarget.TextStyle)
*/
@Override
public Rectangle2D getStringBounds(IFont font, String[] text,
TextStyle style) {
return delegate.getStringBounds(font, text, style);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.IGraphicsTarget#drawColorRamp(com.raytheon.uf
* .common.colormap.IColorMap, com.raytheon.uf.viz.core.IExtent, float,
* float, float)
*/
@Override
public void drawColorRamp(IColorMap colorMap, IExtent pixelExtent,
float blendAlpha, float brightness, float contrast)
throws VizException {
delegate.drawColorRamp(colorMap, pixelExtent, blendAlpha, brightness,
contrast);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.IGraphicsTarget#drawShadedShape(com.raytheon
* .uf.viz.core.drawables.IShadedShape, float, float)
*/
@Override
public void drawShadedShape(IShadedShape shape, float alpha,
float brightness) throws VizException {
delegate.drawShadedShape(shape, alpha, brightness);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.IGraphicsTarget#drawColorRamp(com.raytheon.uf
* .viz.core.drawables.ColorMapParameters, com.raytheon.uf.viz.core.IExtent,
* float)
*/
@Override
public void drawColorRamp(ColorMapParameters colorMapParams,
IExtent pixelExtent, float blendAlpha) throws VizException {
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.IGraphicsTarget#drawColorRamp(com.raytheon.uf
* .viz.core.drawables.ColorMapParameters, com.raytheon.uf.viz.core.IExtent,
* float, float, float)
*/
@Override
public void drawColorRamp(ColorMapParameters colorMapParams,
IExtent pixelExtent, float blendAlpha, float brightness,
float contrast) throws VizException {
}
/*
* (non-Javadoc)
*
* @see com.raytheon.uf.viz.core.IGraphicsTarget#drawPoint(double, double,
* double, org.eclipse.swt.graphics.RGB,
* com.raytheon.uf.viz.core.IGraphicsTarget.PointStyle, float)
*/
@Override
public void drawPoint(double x, double y, double z, RGB color,
PointStyle pointStyle, float magnification) throws VizException {
}
@Override
public void renderOffscreen(IImage offscreenImage) throws VizException {
delegate.renderOffscreen(offscreenImage);
}
@Override
public void renderOnscreen() throws VizException {
delegate.renderOnscreen();
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.IGraphicsTarget#getStringsBounds(com.raytheon
* .uf.viz.core.DrawStringsParameters)
*/
@Override
public Rectangle2D getStringsBounds(DrawableString parameters) {
return null;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.IGraphicsTarget#getStringsBounds(com.raytheon
* .uf.viz.core.DrawStringsParameters, java.lang.String)
*/
@Override
public Rectangle2D getStringsBounds(DrawableString parameters, String string) {
return null;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.IGraphicsTarget#drawStrings(com.raytheon.uf.
* viz.core.DrawStringsParameters)
*/
@Override
public void drawStrings(DrawableString... parameters) throws VizException {
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.IGraphicsTarget#drawColorRamp(com.raytheon.uf
* .viz.core.DrawableColorMap)
*/
@Override
public void drawColorRamp(DrawableColorMap colorMap) throws VizException {
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.IGraphicsTarget#drawCircle(com.raytheon.uf.viz
* .core.DrawableCircle)
*/
@Override
public void drawCircle(DrawableCircle... circle) throws VizException {
}
@Override
public void drawStrings(Collection<DrawableString> parameters)
throws VizException {
}
@Override
public void drawPoints(Collection<double[]> locations, RGB color,
PointStyle pointStyle, float magnification) throws VizException {
}
@Override
public void drawShadedShapes(float alpha, float brightness,
IShadedShape... shapes) throws VizException {
delegate.drawShadedShapes(alpha, brightness, shapes);
}
@Override
public <T> T getExtension(Class<T> extensionClass) throws VizException {
return delegate.getExtension(extensionClass);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.IGraphicsTarget#drawLine(com.raytheon.uf.viz
* .core.DrawableLine[])
*/
@Override
public void drawLine(DrawableLine... lines) throws VizException {
delegate.drawLine(lines);
}
}

View file

@ -71,10 +71,10 @@ public class RadarRadialMesh extends AbstractGLMesh {
throws TransformException {
int horizontalDivisions = key.horizontalDivisions;
int verticalDivisions = key.verticalDivisions;
int verticalDivisions = key.verticalDivisions + 1;
// get dx and dy for texture points
float dX = (1.0f / (horizontalDivisions));
float dX = (1.0f / (key.horizontalDivisions));
vertexCoords = new GLGeometryObject2D(new GLGeometryObjectData(
GL.GL_TRIANGLE_STRIP, GL.GL_VERTEX_ARRAY));
@ -168,7 +168,7 @@ public class RadarRadialMesh extends AbstractGLMesh {
@Override
protected SharedCoordinateKey generateKey(ImageTile tile, MathTransform mt) {
try {
return new SharedCoordinateKey(record.getNumRadials() + 1,
return new SharedCoordinateKey(record.getNumRadials(),
getNumVerticalDivisions(mt, record));
} catch (Exception e) {
statusHandler

View file

@ -0,0 +1,99 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.radar.gl.mosaic;
import com.raytheon.uf.viz.core.DrawableImage;
import com.raytheon.viz.core.gl.images.AbstractGLImage;
import com.raytheon.viz.core.gl.images.GLDelegateImage;
import com.raytheon.viz.radar.rsc.mosaic.ext.IRadarMosaicImageExtension.IMosaicImage;
/**
* GL implementation of IMosaicImage, wraps an offscreen image and contains
* other DrawableImages to mosaic
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 16, 2011 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class GLMosaicImage extends GLDelegateImage<AbstractGLImage> implements
IMosaicImage {
private DrawableImage[] images;
private boolean repaint;
private int[] bounds;
/**
* @param target
* @param image
* @param extensionClass
*/
public GLMosaicImage(AbstractGLImage image, int[] bounds) {
super(image, GLRadarMosaicImageExtension.class);
this.bounds = bounds;
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.core.gl.images.GLDelegateImage#getWidth()
*/
@Override
public int getWidth() {
return bounds[0];
}
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.core.gl.images.GLDelegateImage#getHeight()
*/
@Override
public int getHeight() {
return bounds[1];
}
/**
* @return the repaint
*/
public boolean isRepaint() {
return repaint;
}
public DrawableImage[] getImagesToMosaic() {
return images;
}
public void setImagesToMosaic(DrawableImage... images) {
this.images = images;
repaint = true;
}
}

View file

@ -0,0 +1,157 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.radar.gl.mosaic;
import java.nio.ByteBuffer;
import javax.media.opengl.GL;
import com.raytheon.uf.viz.core.DrawableImage;
import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ext.IOffscreenRenderingExtension;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.viz.core.gl.ext.GLOffscreenRenderingExtension;
import com.raytheon.viz.core.gl.glsl.AbstractGLSLImagingExtension;
import com.raytheon.viz.core.gl.glsl.GLShaderProgram;
import com.raytheon.viz.core.gl.images.AbstractGLImage;
import com.raytheon.viz.radar.rsc.mosaic.ext.IRadarMosaicImageExtension;
/**
* Extension used for rendering radar mosaic images
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 16, 2011 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class GLRadarMosaicImageExtension extends AbstractGLSLImagingExtension
implements IRadarMosaicImageExtension {
private AbstractGLImage writeToImage;
public GLMosaicImage initializeRaster(int[] imageBounds,
ColorMapParameters params) throws VizException {
return new GLMosaicImage(target.getExtension(
GLOffscreenRenderingExtension.class).constructOffscreenImage(
ByteBuffer.class, imageBounds, params), imageBounds);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.core.gl.ext.AbstractGLImagingExtension#getShaderProgramName
* ()
*/
@Override
public String getShaderProgramName() {
return "mosaicMaxVal";
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.core.gl.ext.AbstractGLImagingExtension#preImageRender
* (com.raytheon.uf.viz.core.drawables.PaintProperties,
* com.raytheon.viz.core.gl.images.AbstractGLImage)
*/
@Override
public synchronized Object preImageRender(PaintProperties paintProps,
AbstractGLImage image, PixelCoverage coverage) throws VizException {
if (image instanceof GLMosaicImage) {
GLMosaicImage mosaicImage = (GLMosaicImage) image;
if (mosaicImage.isRepaint()) {
writeToImage = mosaicImage.getWrappedImage();
IOffscreenRenderingExtension extension = target
.getExtension(IOffscreenRenderingExtension.class);
try {
extension.renderOffscreen(mosaicImage);
drawRasters(paintProps, mosaicImage.getImagesToMosaic());
} finally {
extension.renderOnscreen();
}
writeToImage = null;
}
target.drawRasters(paintProps,
new DrawableImage(mosaicImage.getWrappedImage(), coverage));
// Don't actually render this image now since we just did it
return null;
} else {
GL gl = target.getGl();
// activate on texture2 as 0 is radar image and 1 is colormap
gl.glActiveTexture(GL.GL_TEXTURE2);
gl.glBindTexture(writeToImage.getTextureStorageType(),
writeToImage.getTextureid());
return image;
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.core.gl.ext.AbstractGLImagingExtension#postImageRender
* (com.raytheon.uf.viz.core.drawables.PaintProperties,
* com.raytheon.viz.core.gl.images.AbstractGLImage, java.lang.Object)
*/
@Override
public void postImageRender(PaintProperties paintProps,
AbstractGLImage image, Object data) throws VizException {
GL gl = target.getGl();
// activate on texture2 as 0 is radar image and 1 is colormap
gl.glActiveTexture(GL.GL_TEXTURE2);
gl.glBindTexture(writeToImage.getTextureStorageType(), 0);
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.core.gl.ext.AbstractGLImagingExtension#loadShaderData
* (com.raytheon.viz.core.gl.glsl.GLShaderProgram,
* com.raytheon.uf.viz.core.drawables.IImage,
* com.raytheon.uf.viz.core.drawables.PaintProperties)
*/
@Override
public void loadShaderData(GLShaderProgram program, IImage image,
PaintProperties paintProps) throws VizException {
program.setUniform("radarData", 0);
program.setUniform("mosaicTexture", 2);
// pass in width and height
program.setUniform("height", (paintProps.getCanvasBounds().height));
program.setUniform("width", (paintProps.getCanvasBounds().width));
}
}

View file

@ -299,20 +299,16 @@ public class ProductAlertObserver implements INotificationObserver {
if ((payLoad instanceof DataURINotificationMessage)
|| (CAVEMode.getMode().equals(CAVEMode.PRACTICE) && payLoad instanceof PracticeDataURINotificationMessage)) {
String[] dataURIs = null;
int[] ids = null;
if (payLoad instanceof DataURINotificationMessage) {
DataURINotificationMessage uriMsg = (DataURINotificationMessage) payLoad;
dataURIs = uriMsg.getDataURIs();
ids = uriMsg.getIds();
} else {
PracticeDataURINotificationMessage uriMsg = (PracticeDataURINotificationMessage) payLoad;
dataURIs = uriMsg.getDataURIs();
ids = uriMsg.getIds();
}
for (int i = 0; i < dataURIs.length; ++i) {
String str = dataURIs[i];
Integer id = ids[i];
processDataURI(str, id);
processDataURI(str);
}
startWrappers();
@ -338,12 +334,12 @@ public class ProductAlertObserver implements INotificationObserver {
public static void processDerivedAlerts(Collection<String> datauris) {
for (String datauri : datauris) {
getInstance().processDataURI(datauri, 0);
getInstance().processDataURI(datauri);
}
getInstance().startWrappers();
}
private void processDataURI(String datauri, int id) {
private void processDataURI(String datauri) {
if (datauri == null)
return;
try {
@ -363,7 +359,6 @@ public class ProductAlertObserver implements INotificationObserver {
}
AlertMessage am = new AlertMessage();
am.id = id;
am.dataURI = datauri;
am.decodedAlert = Collections.unmodifiableMap(attribs);
List<IAlertObserver> obsList = observers.get(NO_FILTER_CONSTANT);

View file

@ -21,6 +21,7 @@ Require-Bundle: org.eclipse.ui,
Bundle-ActivationPolicy: lazy
Export-Package: com.raytheon.viz.core.gl,
com.raytheon.viz.core.gl.dataformat,
com.raytheon.viz.core.gl.ext,
com.raytheon.viz.core.gl.glsl,
com.raytheon.viz.core.gl.images
Import-Package: com.raytheon.uf.common.status,

View file

@ -1,6 +1,9 @@
// Simple shader program for applying alpha,brightness, and contrast to the
// colormap in the same way they are applied to data
#include <colorUtil>
#include <indexing>
uniform float brightness;
uniform float contrast;
uniform float alphaVal;
@ -15,25 +18,15 @@ uniform sampler2D alphaMask;
uniform int applyMask;
uniform float logFactor;
vec3 AvgLuminance = vec3(0.5, 0.5, 0.5);
// Given an index(0-1) find the color in the colormap
vec4 findColor(float index){
if (logFactor > 0.0){
float minLog = log(logFactor);
float maxLog = log(logFactor + 1.0);
float lg = log(logFactor + index);
index = (lg - minLog) / (maxLog - minLog);
if (index < 0.0){
index = 0.0;
}
else if (index > 1.0){
index = 1.0;
}
void main(void){
// Lookup color in colorMap for index
float index = gl_TexCoord[0].s;
if ( logFactor > 0.0 ) {
index = getLogFactorIndex(index, logFactor);
}
vec4 color = texture1D(colorMap, index).rgba;
vec4 color = texture1D(colorMap, index).rgba;
// Apply alpha mask if set
float alpha = color.a;
if ( applyMask == 1 ) {
if ( texture2D(alphaMask , vec2(index,index) ).r != 0.0 ) {
@ -48,18 +41,6 @@ vec4 findColor(float index){
color.b*color.a + bkgrndBlue*(1.0 - color.a),
alpha);
}
return vec4(color.rgb, alpha);
}
// Apply the preferences for contrast, alpha, and brightness
vec4 applyContrastAlphaBrightness(vec4 color){
vec3 textureColor3 = vec3(color);
vec3 adjustedColor = mix(AvgLuminance, textureColor3, contrast);
float curAlpha = min(color.a, alphaVal);
return vec4(adjustedColor.r * brightness, adjustedColor.g * brightness, adjustedColor.b * brightness, curAlpha);
}
void main(void){
vec4 textureColor = findColor(gl_TexCoord[0].s);
gl_FragColor = applyContrastAlphaBrightness(textureColor);
gl_FragColor = applyContrastAlphaBrightness(color, alphaVal, brightness, contrast);
}

View file

@ -0,0 +1,56 @@
#include <colorUtil>
#include <indexing>
uniform float alpha;
uniform float brightness;
uniform float contrast;
uniform int applyMask;
uniform float naturalMin;
uniform float naturalMax;
uniform float cmapMin;
uniform float cmapMax;
uniform sampler1D colorMap;
uniform sampler2D alphaMask;
uniform sampler2D rawTex;
uniform float colorMapSz;
uniform int isFloat;
uniform int logarithmic;
uniform int mirror;
uniform float logFactor;
void main(void) {
vec4 textureColor = texture2D(rawTex, gl_TexCoord[0].st);
float index = 0.0;
float rawValue = textureColor.r;
if ( isFloat == 1 ) {
if ( logarithmic == 1 ) {
index = findFloatIndexLog(rawValue, cmapMin, cmapMax, mirror);
} else {
index = findFloatIndex(rawValue, cmapMin, cmapMax);
}
// Special float handling, -1.0 is NaN
if (index == -1.0){
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
return;
}
} else {
float naturalValue = ((rawValue * (naturalMax - naturalMin)) + naturalMin);
index = findIndex(naturalValue, cmapMin, cmapMax);
}
// Lookup color in colorMap for index
if ( logFactor > 0.0 ) {
index = getLogFactorIndex(index, logFactor);
}
textureColor = texture1D(colorMap, index).rgba;
// Apply alpha mask
if ( applyMask == 1 ) {
if ( texture2D(alphaMask , vec2(index,index) ).r != 0.0 ) {
textureColor = vec4(textureColor.rgb, 0.0);
}
}
gl_FragColor = applyContrastAlphaBrightness(textureColor, alpha, brightness, contrast);
}

View file

@ -0,0 +1,34 @@
vec3 AvgLuminance = vec3(0.5, 0.5, 0.5);
/**
* This function applies the specified alpha, brightness, and contrast values
* to the color passed in
*/
vec4 applyContrastAlphaBrightness(vec4 color, float alpha, float brightness, float contrast){
vec3 textureColor3 = vec3(color);
vec3 adjustedColor = mix(AvgLuminance, textureColor3, contrast);
float curAlpha = min(color.a, alpha);
return vec4(adjustedColor.r * brightness, adjustedColor.g * brightness, adjustedColor.b * brightness, curAlpha);
}
/**
* This function calculates a new index to use based on the logFactor
*/
float getLogFactorIndex(float index, float logFactor) {
if (logFactor > 0.0){
float minLog = log(logFactor);
float maxLog = log(logFactor + 1.0);
float lg = log(logFactor + index);
index = (lg - minLog) / (maxLog - minLog);
if (index < 0.0){
index = 0.0;
}
else if (index > 1.0){
index = 1.0;
}
}
return index;
}

View file

@ -0,0 +1,104 @@
float HALF_FLOAT_NaN = 65504.0;
/**
* This function takes an index number and caps it to the range 0-1
*/
float capIndex(float index) {
if ( index < 0.0 ) {
index = 0.0;
} else if ( index > 1.0 ) {
index = 1.0;
}
return index;
}
/**
* This function linearly finds the index for the rawValue into cmapMin/cmapMax.
* 65504.0 is treated as NaN for half floats and -1 is returned as special case
*/
float findFloatIndex(float rawValue, float cmapMin, float cmapMax) {
if ( rawValue == HALF_FLOAT_NaN ) {
return -1.0;
}
float index = ((rawValue - cmapMin) / abs(cmapMax-cmapMin));
return capIndex(index);
}
/**
* This function logarithmically finds the index for the rawValue into cmapMin/cmapMax.
* 65504.0 is treated as NaN for half floats and -1 is returned as special case
*/
float findFloatIndexLog(float rawValue, float cmapMin, float cmapMax, int mirror) {
if ( rawValue == HALF_FLOAT_NaN ) {
return -1.0;
}
float index = 0.0;
// is this strictly negative, strictly positive or neg to pos scaling?
if ( cmapMin >= 0.0 && cmapMax >= 0.0 && mirror!=1) {
if(rawValue < cmapMin){
index = 0.0;
}else{
// simple calculation
index = ((log(rawValue) - log(cmapMin)) / abs(log(cmapMax)-log(cmapMin)));
}
} else if (cmapMin <= 0.0 && cmapMax <= 0.0 && mirror!=1) {
index = ((log(rawValue) - log(cmapMax)) / abs(log(cmapMin)-log(cmapMax)));
} else {
// special case, neg to pos:
float colorMapMin = cmapMin;
float colorMapMax = cmapMax;
float zeroVal = max(colorMapMax, abs(colorMapMin)) * 0.0001;
if (mirror==1 && (colorMapMin > 0.0 || colorMapMax < 0.0)) {
if (colorMapMax < 0.0) {
colorMapMax = -cmapMax;
rawValue = -rawValue;
zeroVal = -colorMapMin;
} else {
zeroVal = cmapMin;
}
colorMapMin = -cmapMax;
}
float leftZero = 0.0;
float rightZero = 0.0;
float absLogZeroVal = abs(log(zeroVal));
rightZero = absLogZeroVal + log(colorMapMax);
float cmapMax2 = abs(colorMapMin);
leftZero = absLogZeroVal + log(cmapMax2);
float zeroIndex = leftZero / (leftZero + rightZero);
// figure out index for texture val
float absTextureColor = abs(rawValue);
if (absTextureColor <= zeroVal) {
index = zeroIndex;
} else if (rawValue > 0.0) {
// positive texture color value, find index from 0 to
// cmapMax:
float logTexColor = absLogZeroVal + log(rawValue);
float texIndex = logTexColor / rightZero;
index = (zeroIndex + ((1.0 - zeroIndex) * texIndex));
} else {
// negative texture color value, find index from 0 to
// cmapMax:
float logTexColor = absLogZeroVal + log(absTextureColor);
float texIndex = logTexColor / leftZero;
index = (zeroIndex - (zeroIndex * texIndex));
}
}
return capIndex(index);
}
/**
* Given a raw data value linearly determine the index(0-1) into cmapMin/cmapMax
*/
float findIndex(float rawValue, float cmapMin, float cmapMax) {
float index = ((rawValue - cmapMin) / abs(cmapMax-cmapMin));
return capIndex(index);
}

View file

@ -1,172 +1,11 @@
// NOTE: 65504.0 is the maximum half precision float value
// it is used to do masking of GFE grids since NaNs are not supported
// in NVIDIA cards prior to the 8000 series
// The check for textureColor.r == 65504.0 can be replaced by
// isnan(textureColor.r) if support for cards prior to the 8000 series
// is not required.
// NOTE: there is a corresponding conversion from NaN to 65504.0 in
// FloatDataPreparer that will also need to be changed
#include <colorUtil>
uniform float brightness;
uniform float contrast;
uniform int doColorMap;
uniform int applyMask;
uniform float naturalMin;
uniform float naturalMax;
uniform float cmapMin;
uniform float cmapMax;
uniform sampler1D colorMap;
uniform float alpha;
uniform sampler2D rawTex;
uniform sampler2D alphaMask;
uniform float alphaVal;
uniform float colorMapSz;
uniform int isFloat;
uniform int logarithmic;
uniform int mirror;
uniform float logFactor;
uniform int doSingleColor;
uniform vec3 singleColor;
vec3 AvgLuminance = vec3(0.5, 0.5, 0.5);
// Given a raw data value determine the index(0-1) into the colormap using log scaling
float findIndexLog(float rawValue){
float index = 0.0;
// is this strictly negative, strictly positive or neg to pos scaling?
if ( cmapMin >= 0.0 && cmapMax >= 0.0 && mirror!=1) {
if(rawValue < cmapMin){
index = 0.0;
}else{
// simple calculation
index = ((log(rawValue) - log(cmapMin)) / abs(log(cmapMax)-log(cmapMin)));
}
} else if (cmapMin <= 0.0 && cmapMax <= 0.0 && mirror!=1) {
index = ((log(rawValue) - log(cmapMax)) / abs(log(cmapMin)-log(cmapMax)));
} else {
// special case, neg to pos:
float colorMapMin = cmapMin;
float colorMapMax = cmapMax;
float zeroVal = max(colorMapMax, abs(colorMapMin)) * 0.0001;
if (mirror==1 && (colorMapMin > 0.0 || colorMapMax < 0.0)) {
if (colorMapMax < 0.0) {
colorMapMax = -cmapMax;
rawValue = -rawValue;
zeroVal = -colorMapMin;
} else {
zeroVal = cmapMin;
}
colorMapMin = -cmapMax;
}
float leftZero = 0.0;
float rightZero = 0.0;
float absLogZeroVal = abs(log(zeroVal));
rightZero = absLogZeroVal + log(colorMapMax);
float cmapMax2 = abs(colorMapMin);
leftZero = absLogZeroVal + log(cmapMax2);
float zeroIndex = leftZero / (leftZero + rightZero);
// figure out index for texture val
float absTextureColor = abs(rawValue);
if (absTextureColor <= zeroVal) {
index = zeroIndex;
} else if (rawValue > 0.0) {
// positive texture color value, find index from 0 to
// cmapMax:
float logTexColor = absLogZeroVal + log(rawValue);
float texIndex = logTexColor / rightZero;
index = (zeroIndex + ((1.0 - zeroIndex) * texIndex));
} else {
// negative texture color value, find index from 0 to
// cmapMax:
float logTexColor = absLogZeroVal + log(absTextureColor);
float texIndex = logTexColor / leftZero;
index = (zeroIndex - (zeroIndex * texIndex));
}
}
return index;
}
// Given a raw data value determine the index(0-1) into the colormap
float findIndex(float rawValue)
{
float index = 0.0;
if (isFloat == 1) {
if (rawValue == 65504.0) {
return -1.0;
}
if (logarithmic == 1){
index = findIndexLog(rawValue);
}else{
index = ((rawValue - cmapMin) / abs(cmapMax-cmapMin));
}
} else {
float naturalValue = ((rawValue * (naturalMax - naturalMin)) + naturalMin);
index = ((naturalValue - cmapMin) / abs(cmapMax-cmapMin));
}
if(index < 0.0) {
index = 0.0;
} else if(index > 1.0) {
index = 1.0;
}
return index;
}
// Given an index(0-1) find the color in the colormap
vec4 findColor(float index){
if (logFactor > 0.0){
float minLog = log(logFactor);
float maxLog = log(logFactor + 1.0);
float lg = log(logFactor + index);
index = (lg - minLog) / (maxLog - minLog);
if (index < 0.0){
index = 0.0;
}
else if (index > 1.0){
index = 1.0;
}
}
vec4 color = texture1D(colorMap, index).rgba;
float alpha = color.a;
if ( applyMask == 1 ) {
if ( texture2D(alphaMask , vec2(index,index) ).r != 0.0 ) {
alpha = 0.0;
}
}
return vec4(color.rgb, alpha);
}
// Apply the preferences for contrast, alpha, and brightness
vec4 applyContrastAlphaBrightness(vec4 color){
vec3 textureColor3 = vec3(color);
vec3 adjustedColor = mix(AvgLuminance, textureColor3, contrast);
float curAlpha = min(color.a, alphaVal);
return vec4(adjustedColor.r * brightness, adjustedColor.g * brightness, adjustedColor.b * brightness, curAlpha);
}
void main(void)
{
void main(void) {
vec4 textureColor = texture2D(rawTex, gl_TexCoord[0].st);
float alpha = textureColor.a;
if(doColorMap == 1) {
float index = findIndex(textureColor.r);
if (index == -1.0){
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
return;
}
textureColor = findColor(index);
}
if ( doSingleColor == 1 ) {
textureColor.rgb = singleColor;
}
gl_FragColor = applyContrastAlphaBrightness(textureColor);
gl_FragColor = applyContrastAlphaBrightness(textureColor, alpha, brightness, contrast);
}

View file

@ -0,0 +1,13 @@
#include <colorUtil>
uniform float brightness;
uniform float contrast;
uniform float alpha;
uniform sampler2D rawTex;
uniform vec3 color;
void main(void) {
vec4 textureColor = texture2D(rawTex, gl_TexCoord[0].st);
textureColor.rgb = color;
gl_FragColor = applyContrastAlphaBrightness(textureColor, alpha, brightness, contrast);
}

View file

@ -1,59 +0,0 @@
uniform float brightness;
uniform float contrast;
uniform sampler1D colorMap;
uniform int textureType;
uniform sampler2D cloudTexture2D;
uniform sampler3D cloudTexture3D;
uniform float glaze;
uniform float rime;
uniform float alphaVal;
uniform int clwSize;
uniform float clwRange[8];
uniform float naturalValues[2];
uniform float cmap[];
vec3 AvgLuminance = vec3(0.5, 0.5, 0.5);
float getValue(sampler2D s2D, sampler3D s3D, float max, float min) {
float value;
if(textureType == 3) {
value = texture3D(s3D, vec3(gl_TexCoord[0])).r;
}else {
value = texture2D(s2D, vec2(gl_TexCoord[0])).r;
}
// scale the value
value = (value *(max-min)) + min;
return value;
}
void main(void)
{
gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0 );
float temp = getValue(cloudTexture2D, cloudTexture3D, naturalValues[1], naturalValues[0] );
float index = ((temp - cmap[0]) / (cmap[1]-cmap[0]));
if(index < 0.0) {
index = 0.0;
} else if(index > 1.0) {
index = 1.0;
}
vec4 color = texture1D(colorMap, index).rgba;
float alpha = color.a;
vec4 textureColor = vec4(color.rgb, 1.0);
vec3 adjustedColor = mix(AvgLuminance, color.rgb, contrast);
float curAlpha = min(alpha, alphaVal);
//// if(curAlpha > 0.0) {
gl_FragColor = vec4(adjustedColor.r * brightness, adjustedColor.g * brightness, adjustedColor.b * brightness, curAlpha);
// } else {
// discard;
// }
}

View file

@ -1,37 +0,0 @@
uniform sampler2D tex;
uniform float brightness;
uniform float contrast;
uniform int doColorMap;
uniform float naturalMin;
uniform float naturalMax;
uniform float cmapMin;
uniform float cmapMax;
uniform sampler1D colorMap;
uniform sampler2D rawTex;
uniform float alphaVal;
uniform float colorMapSz;
vec3 AvgLuminance = vec3(0.5, 0.5, 0.5);
void main(void)
{
vec4 textureColor = texture2D(rawTex, gl_TexCoord[0].st);
float alpha = textureColor.a;
if(doColorMap == 1) {
// + " float naturalValue = ((textureColor.r * (20000)) - 10000);
float naturalValue = ((textureColor.r * (naturalMax - naturalMin)) + naturalMin);
float index = ((naturalValue - cmapMin) / abs(cmapMax-cmapMin));
if(index < 0.0) {
index = 0.0;
} else if(index > 1.0) {
index = 1.0;
}
vec4 color = texture1D(colorMap, index).rgba;
alpha = color.a;
textureColor = vec4(color.rgb, 1.0);
}
vec3 textureColor3 = vec3(textureColor);
vec3 adjustedColor = mix(AvgLuminance, textureColor3, contrast);
float curAlpha = min(alpha, alphaVal);
gl_FragColor = vec4(adjustedColor.r * brightness, adjustedColor.g * brightness, adjustedColor.b * brightness, curAlpha);
}

View file

@ -1,98 +0,0 @@
uniform sampler3D tex;
uniform float brightness;
uniform float contrast;
uniform int doColorMap;
uniform float naturalMin;
uniform float naturalMax;
uniform float cmapMin;
uniform float cmapMax;
uniform sampler1D colorMap;
uniform sampler3D rawTex;
uniform float alphaVal;
uniform float colorMapSz;
uniform sampler2D grids[8];
uniform int enabledImpacts[8];
uniform int numberEnabled;
//// actuall pressure levels
//uniform float pressures[20];
//uniform int layers;
//
//
//uniform float texturePres[30];
vec3 AvgLuminance = vec3(0.5, 0.5, 0.5);
//float interp1(float y1, float y3, float x1, float x2, float x3) {
// if(x3 == x1) {
// x1 += 0.01;
// }
//
// return y1+((y3-y1) *((x2-x1)/(x3-x1)));
//
//}
//
//// based on metolib pvalue.f
//float pvalue() {
//
// float z = vec3(gl_TexCoord[0].xyz).z;
// int j = int(z *float(layers-1));
// vec3 lower = gl_TexCoord[0].xyz;
// vec3 upper = gl_TexCoord[0].xyz;
//
//
// float lowerVal = texture3D(rawTex, lower).r;
// float uperVal = texture3D(rawTex, upper).r;
//
// for(int i = 0; i < layers; ++i) {
//
// if(pressures[i] < texturePres[j]) {
//
// // assuming texture coordinates are 0-1
// lower.z += 1/(layers-1);
// upper.z -= 1/(layers-1);
//
// float lowerVal = texture3D(rawTex, lower).r;
// float upperVal = texture3D(rawTex, upper).r;
//
// float p1 = log(pressures[i-1]);
// float p2 = log(texturePres[j]);
// float p3 = log(pressures[i]);
//
// return interp1(lowerVal, upperVal, p1, p2, p3 );
// }
// }
//
//}
void main(void)
{
float textureValue = texture3D(rawTex, gl_TexCoord[0].xyz).r;
float naturalValue = ((textureValue * (naturalMax - naturalMin)) + naturalMin);
float index = ((naturalValue - cmapMin) / (cmapMax-cmapMin));
if(index < 0.0) {
index = 0.0;
} else if(index > 1.0) {
index = 1.0;
}
vec4 color = texture1D(colorMap, index).rgba;
float alpha = color.a;
vec4 textureColor = vec4(color.rgb, 1.0);
vec3 textureColor3 = vec3(textureColor);
vec3 adjustedColor = mix(AvgLuminance, textureColor3, contrast);
//
float curAlpha = min(alpha, alphaVal);
if(curAlpha > 0.0){
gl_FragColor = vec4(adjustedColor.r * brightness, adjustedColor.g * brightness, adjustedColor.b * brightness, curAlpha);
}
else {
discard;
}
}

View file

@ -1,56 +0,0 @@
uniform sampler2D temp2D;
uniform sampler3D temp3D;
uniform sampler2D rh2D;
uniform sampler3D rh3D;
uniform int textureType;
uniform float naturalMin[2];
uniform float naturalMax[2];
uniform float severeThreshold;
uniform float moderateThreshold;
float getValue(sampler2D s2D, sampler3D s3D, float max, float min) {
float value;
if(textureType == 3) {
value = texture3D(s3D, vec3(gl_TexCoord[0])).r;
}else {
value = texture2D(s2D, vec2(gl_TexCoord[0])).r;
}
// scale the value
value = (value *(max-min)) + min;
return value;
}
void main(void)
{
float kelvin = getValue(temp2D, temp3D, naturalMax[0], naturalMin[0]);
float t = (((kelvin - 273.15) * 1.8) + 32.0);
float rh = getValue(rh2D, rh3D, naturalMax[1], naturalMin[1]);
float hi = t;
if(t >= 57.0) {
hi = -42.379 + (2.04901523*t) + (10.14333127*rh) - (0.22475541*t*rh) - (0.00683783*t*t) - (0.05481717*rh*rh) + (0.00122874*t*t*rh)+ (0.00085282*t*rh*rh) - (0.00000199*((t*rh)*(t*rh)));
}
gl_FragColor =vec4(1.0, 0.0, 1.0, 1.0);
// convert threshold values to fahenheit
if(hi > (severeThreshold *9.0/5.0 -459.67)) {
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
} else if(hi > (moderateThreshold *9.0/5.0 -459.67)) {
gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0);
}
else {
discard;
// gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
}
}

View file

@ -1,125 +0,0 @@
uniform float brightness;
uniform float contrast;
uniform sampler1D colorMap;
uniform sampler3D tempTex3D;
uniform sampler3D clwTex3D;
uniform sampler2D tempTex2D;
uniform sampler2D clwTex2D;
uniform sampler2D tempTex;
uniform sampler2D clwTex;
uniform float glaze;
uniform float rime;
uniform float alphaVal;
uniform int clwSize;
uniform float clwRange[4];
uniform float naturalMin[2];
uniform float naturalMax[2];
uniform int textureType;
vec3 AvgLuminance = vec3(0.5, 0.5, 0.5);
// shader based on icing algorithm found at
// http://aoaws.caa.gov.tw/htdocs/projects/aoaws/model/icing/algorithm
//
// get the scaled value from either the 2D or 3D texture
float getValue(sampler2D s2D, sampler3D s3D, float max, float min) {
float value;
if(textureType == 3) {
value = texture3D(s3D, vec3(gl_TexCoord[0])).r;
}else {
value = texture2D(s2D, vec2(gl_TexCoord[0])).r;
}
// scale the value
value = (value *(max-min)) + min;
return value;
}
float getIcing()
{
float value = 0.0;
float temp = getValue(tempTex2D, tempTex3D, naturalMax[0], naturalMin[0]);
// clw - cloud liquid water
float clw = getValue(clwTex2D, clwTex3D, naturalMax[1], naturalMin[1]);
if(temp > glaze || clw < clwRange[0]) {
// no icing
value = 0.0;
}
else {
if(temp < rime){
value = 1.0;
}
else {
value = 2.0;
}
float x = 0.0;
for(int i = 0; i < 4; i++) {
if(clw > clwRange[i] ){
x += 1.0 ;
}
}
value += x;
}
return value;
}
void main(void)
{
gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0 );
// vec4 textureColor = texture2D(tempTex, gl_TexCoord[0].st);
// float alpha = textureColor.a;
float index1 = getIcing();
// if(index1 == 900.0 ) {
// gl_FragColor = vec4(1.0, 0.0, 1.0, 1.0 );
//
// }
// else if(index1 == 10000.0) {
// gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0 );
//
// } else if(index1 == 999.0) {
// gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0 );
//
// }
// else {
float index = (index1 / 5.0);
if(index < 0.0) {
index = 0.0;
} else if(index > 1.0) {
index = 1.0;
}
vec4 color = texture1D(colorMap, index).rgba;
float alpha = color.a;
vec4 textureColor = vec4(color.rgb, 1.0);
vec3 textureColor3 = vec3(textureColor);
vec3 adjustedColor = mix(AvgLuminance, textureColor3, contrast);
float curAlpha = min(alpha, alphaVal);
if(alpha > 0.0) {
gl_FragColor = vec4(adjustedColor.r * brightness, adjustedColor.g * brightness, adjustedColor.b * brightness, alpha);
}
else {
discard;
}
}

View file

@ -1,157 +0,0 @@
uniform sampler2D tex;
uniform float brightness;
uniform float contrast;
uniform int doColorMap;
uniform float naturalMin;
uniform float naturalMax;
uniform float cmapMin;
uniform float cmapMax;
uniform sampler1D colorMap;
uniform sampler2D rawTex;
uniform float alphaVal;
uniform float colorMapSz;
uniform int doImpact;
uniform int upperThreshold;
uniform int numberGrids;
uniform float severeThreshold[8];
uniform float moderateThreshold[8];
uniform float naturalMins[8];
uniform float naturalMaxes[8];
uniform sampler2D grids[8];
uniform int enabledImpacts[8];
uniform int numberEnabled;
vec3 AvgLuminance = vec3(0.5, 0.5, 0.5);
float impactAnd()
{
float impactVal = 3.0;
for(int x=0; x < 8; x++)
{
if(x >= numberGrids)
{
break;
}
if(enabledImpacts[x] == 1)
{
vec4 textureColor = texture2D(grids[x], gl_TexCoord[0].st);
float naturalValue = ((textureColor.r * (naturalMaxes[x] - naturalMins[x])) + naturalMins[x]);
if(upperThreshold == 1)
{
if(naturalValue < moderateThreshold[x])
{
impactVal = 0.0;
}
else if(naturalValue < severeThreshold[x])
{
if(impactVal == 3.0)
{
impactVal = 2.0;
}
}
}
else
{
if(naturalValue > moderateThreshold[x])
{
impactVal = 0.0;
}
else if(naturalValue > severeThreshold[x])
{
if(impactVal == 3.0)
{
impactVal = 2.0;
}
}
}
}
}
return impactVal;
}
float impactOr()
{
float impactVal = 0.0;
for(int x=0; x < 8; x++)
{
if(x >= numberGrids)
{
break;
}
if(enabledImpacts[x] == 1)
{
vec4 textureColor = texture2D(grids[x], gl_TexCoord[0].st);
float naturalValue = ((textureColor.r * (naturalMaxes[x] - naturalMins[x])) + naturalMins[x]);
if(upperThreshold == 1)
{
if(naturalValue > severeThreshold[x])
{
impactVal = 3.0;
}
else if(naturalValue > moderateThreshold[x])
{
impactVal = 2.0;
}
}
else
{
if(naturalValue < severeThreshold[x])
{
impactVal = 3.0;
}
else if(naturalValue < moderateThreshold[x])
{
impactVal = 2.0;
}
}
}
}
return impactVal;
}
void main(void)
{
vec4 textureColor = texture2D(rawTex, gl_TexCoord[0].st);
float alpha = textureColor.a;
if(doImpact == 1)
{
float impactVal = 0.0;
if(numberEnabled > 0)
{
impactVal = impactAnd();
}
else
{
impactVal = 0.0;
}
float index = (impactVal / 3.0);
if(index < 0.0) {
index = 0.0;
} else if(index > 1.0) {
index = 1.0;
}
vec4 color = texture1D(colorMap, index).rgba;
alpha = color.a;
textureColor = vec4(color.rgb, 1.0);
}
else if(doColorMap == 1) {
float naturalValue = ((textureColor.r * (naturalMax - naturalMin)) + naturalMin);
float index = ((naturalValue - cmapMin) / (cmapMax-cmapMin));
if(index < 0.0) {
index = 0.0;
} else if(index > 1.0) {
index = 1.0;
}
vec4 color = texture1D(colorMap, index).rgba;
alpha = color.a;
textureColor = vec4(color.rgb, 1.0);
}
vec3 textureColor3 = vec3(textureColor);
vec3 adjustedColor = mix(AvgLuminance, textureColor3, contrast);
float curAlpha = min(alpha, alphaVal);
gl_FragColor = vec4(adjustedColor.r * brightness, adjustedColor.g * brightness, adjustedColor.b * brightness, curAlpha);
}

View file

@ -1,19 +0,0 @@
uniform sampler2D terrainMap;
uniform float exaggeration;
uniform int layer;
void main(void)
{
vec4 newVertexPos;
float df;
gl_TexCoord[0].xy = gl_MultiTexCoord0.xy;
vec3 normal = normalize(gl_Normal);
df = texture2D( terrainMap, gl_TexCoord[0].xy ).r;
if(layer > 0){
exaggeration *= layer;
}
newVertexPos = vec4(normal *df* exaggeration , 0.0) + gl_Vertex;
gl_Position = gl_ModelViewProjectionMatrix * newVertexPos;
}

View file

@ -20,13 +20,8 @@
-->
<?eclipse version="3.2"?>
<plugin>
<extension-point id ="shader" name="shader" schema="schema/shader.exsd"/>
<extension point="com.raytheon.uf.viz.core.graphicsFactory">
<graphicsFactory id="default" type="2D" factoryClass="com.raytheon.viz.core.gl.GLFactoryAdapter"/>
</extension>
<extension point="com.raytheon.viz.core.gl.shader">
<shader programName="raster" loaderClass="com.raytheon.viz.core.gl.glsl.GLSLRasterProgramLoader"/>
</extension>
<extension
point="com.raytheon.uf.viz.localization.localizationpath">
@ -44,7 +39,7 @@
class="com.raytheon.viz.core.gl.internal.ext.GLColormapShadedShapeExtension">
</graphicsExtension>
<graphicsExtension
class="com.raytheon.viz.core.gl.internal.ext.GLOffscreenRenderingExtension">
class="com.raytheon.viz.core.gl.ext.GLOffscreenRenderingExtension">
</graphicsExtension>
<graphicsExtension
class="com.raytheon.viz.core.gl.internal.ext.GLMapMeshExtension">
@ -52,5 +47,11 @@
<graphicsExtension
class="com.raytheon.viz.core.gl.internal.ext.GLColormappedImageExtension">
</graphicsExtension>
<graphicsExtension
class="com.raytheon.viz.core.gl.internal.ext.GLSingleColorImageExtension">
</graphicsExtension>
<graphicsExtension
class="com.raytheon.viz.core.gl.internal.ext.GLDefaultImagingExtension">
</graphicsExtension>
</extension>
</plugin>

View file

@ -1,85 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="com.raytheon.viz.core.gl" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
<meta.schema plugin="com.raytheon.viz.core.gl" id="shader" name="shader"/>
</appinfo>
<documentation>
This extension point is used to identify shader programs
</documentation>
</annotation>
<element name="extension">
<annotation>
<appinfo>
<meta.element />
</appinfo>
</annotation>
<complexType>
<sequence>
<element ref="shader" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute translatable="true"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="shader">
<complexType>
<attribute name="loaderClass" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute kind="java" basedOn=":com.raytheon.viz.core.gl.glsl.IShaderLoader"/>
</appinfo>
</annotation>
</attribute>
<attribute name="programName" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appinfo>
<meta.section type="since"/>
</appinfo>
<documentation>
0.1
</documentation>
</annotation>
</schema>

View file

@ -106,12 +106,11 @@ public abstract class AbstractGLMesh implements IMesh {
}
if (!compiled) {
vertexCoords.setTarget(glTarget);
vertexCoords.compile();
vertexCoords.compile(glTarget.getGl());
compiled = true;
}
GLGeometryPainter.paintGeometries(glTarget, vertexCoords,
GLGeometryPainter.paintGeometries(glTarget.getGl(), vertexCoords,
sharedTextureCoords.getTextureCoords());
}

View file

@ -19,7 +19,6 @@
**/
package com.raytheon.viz.core.gl;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.preference.IPersistentPreferenceStore;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
@ -62,12 +61,6 @@ public class Activator extends AbstractUIPlugin {
*/
public void start(BundleContext context) throws Exception {
super.start(context);
// Start the texture loader job
TextureLoaderJob textureLoader = TextureLoaderJob.getInstance();
if (textureLoader.getState() != Job.RUNNING) {
textureLoader.setSystem(true);
textureLoader.schedule();
}
}
/*
@ -81,10 +74,7 @@ public class Activator extends AbstractUIPlugin {
plugin = null;
super.stop(context);
// Start the texture loader job
TextureLoaderJob textureLoader = TextureLoaderJob.getInstance();
if (textureLoader.getState() == Job.RUNNING) {
textureLoader.shutdown();
}
TextureLoader.getInstance().shutdown();
}
/**

View file

@ -0,0 +1,203 @@
/**
* 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.core.gl;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLContext;
import javax.media.opengl.GLDrawableFactory;
import javax.media.opengl.GLPbuffer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.opengl.GLCanvas;
import org.eclipse.swt.opengl.GLData;
import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.viz.core.exception.VizException;
/**
*
* Provide a mechanism for keeping JOGL GLContext in sync with the SWT GLCanvas
* context. The JOGL GLContext has most of the logic needed to manage contexts,
* except for when the context is external. Since our context is created by the
* SWT GLCanvas the JOGL GLContext does not actually control the active context
* in GL. This class contains a GLCanvas and a GLContext and keeps the active
* context in sync between the two.
*
* This class also provides static access to the "Master Context" which is a
* context with which all other contexts are sharing data. Ideally we would not
* need to use the master context however there is a bug in some Windows/Intel
* drivers which causes crashes if a texture is created on a context, then the
* context is deleted, then the texture is deleted on a different context. To
* resolve this all textures should be created and deleted on the master
* context. This is done by calling makeMasterContextCurrent before calling
* glGenTexture or glDeleteTexture and then calling releaseMasterContext
* immediately after to restore the previous context.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 17, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class GLContextBridge {
private static GLContextBridge activeContext;
private static GLContextBridge masterContext;
private static GLContextBridge previousContext;
private final GLCanvas canvas;
private final GLContext context;
public GLContextBridge(int width, int height) throws VizException {
GLCapabilities glCap = new GLCapabilities();
if (!GLDrawableFactory.getFactory().canCreateGLPbuffer()) {
throw new VizException(
"Graphics card does not support GLPbuffer and "
+ "therefore does not support offscreen rendering.");
}
GLPbuffer buf = GLDrawableFactory.getFactory().createGLPbuffer(glCap,
null, width, height, null);
this.context = buf.createContext(null);
this.canvas = null;
activeContext = this;
releaseContext();
}
public GLContextBridge(GLCanvas canvas) {
this.canvas = canvas;
this.canvas.setCurrent();
this.context = GLDrawableFactory.getFactory().createExternalGLContext();
activeContext = this;
releaseContext();
}
/**
* Make this context current for any GL Operations and release any
* previously active context.
*
* @return true if this context was not previously active and should
* therefore be released when you are done performing gl operations
*/
public boolean makeContextCurrent() {
if (canvas != null && !canvas.isDisposed()) {
canvas.setCurrent();
} else if (canvas != null) {
throw new RuntimeException(
"Cannot make gl context current, GLCanvas is disposed");
}
GLContext oldContext = GLContext.getCurrent();
if (context != oldContext) {
if (oldContext != null) {
oldContext.release();
}
if (context.makeCurrent() == GLContext.CONTEXT_NOT_CURRENT) {
throw new RuntimeException(
"Cannot make gl context current, Unknown error occured.");
}
}
boolean retVal = (activeContext != this);
activeContext = this;
return retVal;
}
public void releaseContext() {
if (context == GLContext.getCurrent()) {
context.release();
}
if (activeContext == this) {
activeContext = null;
}
}
public void destroyContext() {
releaseContext();
context.destroy();
}
/**
* get the GLData to use when creating a new GLCanvas, data.shareContext
* will contain the canvas for the "Master Context"
*
* @return
*/
public static GLData getGLData() {
return getGLData(true);
}
private static GLData getGLData(boolean setContext) {
GLData data = new GLData();
data.stencilSize = 1;
data.depthSize = 1;
data.doubleBuffer = true;
if (setContext) {
data.shareContext = getMasterContext().canvas;
}
return data;
}
private static GLContextBridge getMasterContext() {
if (masterContext == null) {
GLCanvas canvas = new GLCanvas(new Shell(), SWT.NONE,
getGLData(false));
masterContext = new GLContextBridge(canvas);
}
return masterContext;
}
/**
* This method makes the shared master context the active contexts, it also
* stores the current active context to be restored on release.
*
*/
public static void makeMasterContextCurrent() {
if (masterContext != null) {
if (activeContext != null) {
previousContext = activeContext;
activeContext.releaseContext();
}
masterContext.makeContextCurrent();
}
}
/**
* Releases the master context and restores the context that was active
* before makeMasterContextCurrent was called.
*/
public static void releaseMasterContext() {
if (masterContext != null) {
masterContext.releaseContext();
if (previousContext != null) {
previousContext.makeContextCurrent();
previousContext = null;
}
}
}
}

View file

@ -0,0 +1,127 @@
/**
* 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.core.gl;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.LinkedBlockingQueue;
import javax.media.opengl.GL;
/**
*
* This class provides a convenient way of disposing of GL resources on an
* active GLContext.
*
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 17, 2012 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class GLDisposalManager {
private static ReferenceQueue<Object> refQueue = new ReferenceQueue<Object>();
private static List<GLAutoDisposer> autoDisposers = new LinkedList<GLAutoDisposer>();
private static Queue<GLDisposer> disposeQueue = new LinkedBlockingQueue<GLDisposer>();
/**
* This method should be used to dispose of a GL resource, at the end of a
* frame the target will make the context current and dispose of all
* resources.
*
* @param disposer
* a disposer object that is ready to dispose of a gl resource.
*/
private static void dispose(GLDisposer disposer) {
disposeQueue.add(disposer);
}
/**
* Provide a backup mechanism to dispose. This uses WeakReference objects to
* call the disposer after the object is garbage collected. For this to work
* the disposer must have no references to object. Object should be the only
* thing using these GL resources, this will not work for anything which
* might be shared by multiple objects. This will also result in the dispose
* method of the disposer being called more than once so it should clear any
*
* @param disposer
* - a disposer that will be called when object is garbage
* collected
* @param object
* - an object which uses a gl resource.
*/
public static void autoDispose(GLDisposer disposer, Object object) {
autoDisposers.add(new GLAutoDisposer(object, disposer));
}
/**
* For use by the target only, the target should call this to dispose all
* unneeded resources
*
* @param gl
*/
public static void performDispose(GL gl) {
GLDisposer disposer = disposeQueue.poll();
while (disposer != null) {
disposer.dispose(gl);
disposer = disposeQueue.poll();
}
GLAutoDisposer autoDisposer = (GLAutoDisposer) refQueue.poll();
while (autoDisposer != null) {
autoDisposers.remove(autoDisposer);
autoDisposer.disposer.dispose();
autoDisposer = (GLAutoDisposer) refQueue.poll();
}
}
public static abstract class GLDisposer {
protected abstract void dispose(GL gl);
final public void dispose() {
GLDisposalManager.dispose(this);
}
}
private static class GLAutoDisposer extends WeakReference<Object> {
private final GLDisposer disposer;
public GLAutoDisposer(Object referent, GLDisposer disposer) {
super(referent, refQueue);
this.disposer = disposer;
}
}
}

View file

@ -26,7 +26,6 @@ import org.eclipse.swt.opengl.GLCanvas;
import org.eclipse.swt.opengl.GLData;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.opengis.coverage.grid.GridEnvelope;
import com.raytheon.uf.viz.core.AbstractGraphicsFactoryAdapter;
@ -145,37 +144,11 @@ public class GLFactoryAdapter extends AbstractGraphicsFactoryAdapter {
@Override
public Canvas constrcutCanvas(Composite canvasComp) throws VizException {
GLCanvas canvas;
GLData data = new GLData();
data.stencilSize = 1;
data.depthSize = 1;
data.doubleBuffer = true;
GLCanvas cachedCanvas = GLCanvasCache.getInstance().getCanvas();
if (cachedCanvas == null) {
Shell invisibleShell = new Shell();
cachedCanvas = new GLCanvas(invisibleShell, SWT.NONE, data);
GLCanvasCache.getInstance().setCanvas(cachedCanvas);
cachedCanvas.setCurrent();
}
data.shareContext = cachedCanvas;
GLData data = GLContextBridge.getGLData();
canvas = new GLCanvas(canvasComp, SWT.NONE, data);
canvas.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
return canvas;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.AbstractGraphicsFactoryAdapter#disposeCanvas
* (org.eclipse.swt.widgets.Canvas)
*/
@Override
public void disposeCanvas(Canvas canvas) {
GLCanvas cachedCanvas = GLCanvasCache.getInstance().getCanvas();
if (cachedCanvas != canvas && !canvas.isDisposed()) {
canvas.getParent().dispose();
}
}
}

View file

@ -29,8 +29,8 @@ import java.util.List;
import javax.media.opengl.GL;
import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.viz.core.gl.objects.GLVertexBufferObject;
/**
* GL Geometry object, supports compiling into VBOs. Coordinates passed in will
@ -53,9 +53,6 @@ import com.raytheon.uf.viz.core.exception.VizException;
public class GLGeometryObject2D {
public static class GLGeometryObjectData {
private IGLTarget target;
private GL gl;
public IExtent worldExtent;
@ -72,12 +69,6 @@ public class GLGeometryObject2D {
this.coordType = coordType;
}
public void setTarget(IGLTarget target) {
this.target = target;
if (target != null) {
gl = target.getGl();
}
}
}
protected static enum State {
@ -96,7 +87,7 @@ public class GLGeometryObject2D {
protected int points;
protected int vboId;
protected GLVertexBufferObject vbo;
protected State state;
@ -104,8 +95,6 @@ public class GLGeometryObject2D {
public GLGeometryObject2D(GLGeometryObjectData data) {
this.data = new GLGeometryObjectData(data.geometryType, data.coordType);
this.data.gl = data.gl;
this.data.target = data.target;
this.data.manageIndicies = data.manageIndicies;
this.data.mutable = data.mutable;
this.data.worldExtent = data.worldExtent;
@ -119,16 +108,16 @@ public class GLGeometryObject2D {
}
compiledIndicies = null;
points = 0;
vboId = -1;
vbo = null;
state = State.MUTABLE;
}
public void compile() throws VizException {
public void compile(GL gl) throws VizException {
// We will use glMultiDrawArrays if the cardSupportsHighEndFeatures, so
// we will keep track of a lenghts buffer
state = State.COMPILED;
int add = 1;
if (GLCapabilities.getInstance(data.gl).cardSupportsHighEndFeatures) {
if (GLCapabilities.getInstance(gl).cardSupportsHighEndFeatures) {
state = State.COMPILED_HIGH_END;
add = 0;
}
@ -169,24 +158,21 @@ public class GLGeometryObject2D {
copy.put(data.get());
}
GL gl = this.data.gl;
// clear the error bit.
this.data.target.makeContextCurrent();
gl.glGetError();
// generate vbo
vboId = GLVBOCleaner.allocateVBO(this, this.data.target);
vbo = new GLVertexBufferObject(this);
// verify successful
if (vboId <= 0) {
vboId = -1;
if (!vbo.isValid()) {
vbo = null;
throw new VizException("Error compiling wireframe shape, "
+ "could not generate vertex buffer object");
}
// bind and load
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, vboId);
vbo.bind(gl, GL.GL_ARRAY_BUFFER);
gl.glBufferData(GL.GL_ARRAY_BUFFER, copy.capacity() * 4,
copy.rewind(), GL.GL_STATIC_DRAW);
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
@ -223,16 +209,8 @@ public class GLGeometryObject2D {
compiledLengths = null;
state = State.INVALID;
if (vboId > -1) {
final int vbo = vboId;
vboId = -1;
VizApp.runAsync(new Runnable() {
@Override
public void run() {
GLVBOCleaner.unallocateVBO(GLGeometryObject2D.this, vbo,
data.target);
}
});
if (vbo != null && vbo.isValid()) {
vbo.dispose();
}
}
@ -368,15 +346,8 @@ public class GLGeometryObject2D {
}
}
public synchronized void paint() throws VizException {
GLGeometryPainter.paintGeometries(data.target, this);
}
public void setTarget(IGLTarget target) {
data.target = target;
if (data.target != null) {
data.gl = target.getGl();
}
public synchronized void paint(GL gl) throws VizException {
GLGeometryPainter.paintGeometries(gl, this);
}
// 2D specific functions, override for 3D support

View file

@ -48,11 +48,8 @@ import com.raytheon.viz.core.gl.GLGeometryObject2D.State;
public class GLGeometryPainter {
private static int maxVertices = -1;
public static void paintGeometries(IGLTarget target,
GLGeometryObject2D... geoms) throws VizException {
GL gl = target.getGl();
public static void paintGeometries(GL gl, GLGeometryObject2D... geoms)
throws VizException {
State state = State.INVALID;
Set<State> states = new HashSet<State>();
for (GLGeometryObject2D geom : geoms) {
@ -131,11 +128,11 @@ public class GLGeometryPainter {
case COMPILED:
case COMPILED_HIGH_END: {
for (GLGeometryObject2D geom : geoms) {
if (geom.vboId <= 0) {
if (!geom.vbo.isValid()) {
throw new VizException(
"Could not paint geometry, VBO not set!");
}
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, geom.vboId);
geom.vbo.bind(gl, GL.GL_ARRAY_BUFFER);
switch (geom.data.coordType) {
case GL.GL_VERTEX_ARRAY: {
gl.glVertexPointer(geom.pointsPerCoordinate(), GL.GL_FLOAT,
@ -199,7 +196,7 @@ public class GLGeometryPainter {
*/
private static void drawArrays(GL gl, int mode, int first, int count)
throws VizException {
if (first > -1 && count > 0 && (first + count < getMaxVertices(gl))) {
if (first > -1 && count > 0) {
gl.glDrawArrays(mode, first, count);
} else {
throw new VizException(
@ -220,12 +217,4 @@ public class GLGeometryPainter {
}
}
private static int getMaxVertices(GL gl) {
if (maxVertices < 0) {
IntBuffer ib = IntBuffer.allocate(1);
gl.glGetIntegerv(GL.GL_MAX_ELEMENTS_VERTICES, ib);
maxVertices = ib.get(0);
}
return maxVertices;
}
}

View file

@ -1,138 +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.core.gl;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import javax.media.opengl.GL;
/**
*
* This class uses WeakReference to guarantee that all vbos are deallocated even
* if dispose is never called. It is still better to call dispose to avoid
* having "dead" vbos on the graphics card, which can slow down rendering.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 9, 2011 bsteffen Initial creation
*
* </pre>
*
* @author bsteffen
* @version 1.0
*/
public class GLVBOCleaner extends WeakReference<Object> {
/**
* This is needed so when unallocate is called we can set the vboId to -1
* and stop it from being redeleted
*/
private static List<GLVBOCleaner> cleaners = new LinkedList<GLVBOCleaner>();
/**
* THis queue will contain all garbage collected vbo objects, if everyone
* deallocates all vboIds will be -1.
*/
private static ReferenceQueue<Object> queue = new ReferenceQueue<Object>();
/**
* get a new vboId from gl which will be linked to object, if object is
* garbage collected then the vbo will still be freed. This should only be
* called on the main thread.
*
* @param object
* @param target
* @return
*/
public static int allocateVBO(Object object, IGLTarget target) {
target.makeContextCurrent();
clean(target.getGl());
GLVBOCleaner cleaner = new GLVBOCleaner(object, target.getGl());
target.handleError(target.getGl().glGetError());
// verify successful
if (cleaner.vboId > 0) {
cleaners.add(cleaner);
}
return cleaner.vboId;
}
/**
* Immediately free a vbo which has been allocated, any method that uses
* allocate should also use deallocate. object must be the same as the
* object passed to allocate.
*
* @param object
* @param vboId
* @param target
*/
public static void unallocateVBO(Object object, int vboId, IGLTarget target) {
target.makeContextCurrent();
clean(target.getGl());
if (vboId <= 0) {
return;
}
Iterator<GLVBOCleaner> iter = cleaners.iterator();
while (iter.hasNext()) {
GLVBOCleaner cleaner = iter.next();
if (cleaner.get() == object && cleaner.vboId == vboId) {
cleaner.freeVbo(target.getGl());
iter.remove();
}
}
}
private static void clean(GL gl) {
GLVBOCleaner cleaner = (GLVBOCleaner) queue.poll();
while (cleaner != null) {
if (cleaner.vboId > 0) {
System.err
.println("An object with a gl vertex buffer object has been garbage collected without being disposed. This can cause a delay in freeing vbos which can cause severe performance problems.");
cleaner.freeVbo(gl);
}
cleaners.remove(cleaner);
cleaner = (GLVBOCleaner) queue.poll();
}
}
private int vboId;
private GLVBOCleaner(Object referent, GL gl) {
super(referent, queue);
int[] vbos = new int[1];
gl.glGenBuffers(1, vbos, 0);
this.vboId = vbos[0];
}
private void freeVbo(GL gl) {
gl.glDeleteBuffers(1, new int[] { this.vboId }, 0);
this.vboId = -1;
}
}

View file

@ -20,7 +20,6 @@
package com.raytheon.viz.core.gl;
import com.raytheon.uf.viz.core.drawables.IFont;
import com.raytheon.viz.core.gl.internal.GLTarget;
import com.sun.opengl.util.j2d.TextRenderer;
/**
@ -49,13 +48,6 @@ public interface IGLFont extends IFont {
*/
public TextRenderer getTextRenderer();
/**
* Get the target for the font
*
* @return
*/
public GLTarget getTarget();
/**
* Force a dispose
*/

View file

@ -20,19 +20,13 @@
package com.raytheon.viz.core.gl;
import javax.media.opengl.GL;
import javax.media.opengl.GLContext;
import javax.media.opengl.glu.GLU;
import org.eclipse.swt.graphics.Rectangle;
import com.raytheon.uf.viz.core.DrawableImage;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.viz.core.gl.images.GLColormappedImage;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.viz.core.gl.objects.GLTextureObject;
public interface IGLTarget extends IGraphicsTarget {
@ -40,13 +34,9 @@ public interface IGLTarget extends IGraphicsTarget {
public abstract GLU getGlu();
/**
* Active texture unit and bind a texture
*
* @param textureUnit
* @param GLImage
*/
public abstract void bindTexture(int textureUnit, GLColormappedImage image);
public abstract void pushGLState();
public abstract void popGLState();
/**
*
@ -54,6 +44,12 @@ public interface IGLTarget extends IGraphicsTarget {
*/
public abstract boolean makeContextCurrent();
/**
*
* @return
*/
public abstract void releaseContext();
/**
* Get the modle view matrix settings
*
@ -102,88 +98,17 @@ public interface IGLTarget extends IGraphicsTarget {
public abstract Rectangle getBounds();
/**
* Get the gl context
* Get a colormap texture id for the specified parameters
*
* @param cmapParams
* @return
*/
public abstract GLContext getContext();
/**
* Dispose luminance texture
*
* @param id
* @param pboID
*/
public abstract void disposeLuminanceTexture(int id, int pboID);
/**
* Dispose a vbo
*
* @param id
* the vbo id
*/
public abstract void disposeVBO(int id);
/**
* Dispose the occlusion query
*
* @param id
*/
public abstract void disposeOcclusionQueries(int[] id);
/**
*
* @param display
* @throws VizException
*/
public void beginOcclusionTest(IRenderableDisplay display)
throws VizException;
/**
* End the occlusion test. Commands will update the framebuffer
*
* @throws VizException
*/
public void endOcclusionTest() throws VizException;
/**
* call drawRaster using a specified shader program
*
* @param image
* @param extent
* @param paintProps
* @param shaderProgram
* @return
* @throws VizException
*/
public abstract boolean drawRaster(IImage image, PixelCoverage extent,
PaintProperties paintProps, String shaderProgram)
throws VizException;
/**
* call drawRaster with a specified shader program
*
* @param image
* the image reference object to draw
* @param extent
* the extent of the drawable area
* @param paintProps
* the paint properties
* @param mode
* the drawing mode (synchronous, asynchronous)
* @return status whether the raster was able to be drawn
* @throws VizException
*/
public abstract boolean drawRaster(IImage image, PixelCoverage extent,
PaintProperties paintProps, RasterMode mode, String shaderProgram)
throws VizException;
public abstract boolean drawRasters(String shader,
PaintProperties paintProps, DrawableImage... images)
throws VizException;
public abstract GLTextureObject getColorMapTexture(
ColorMapParameters cmapParams);
/**
* Checks the glError state and does a UFStatus message
*/
public abstract void handleError(int errorid);
}

View file

@ -98,9 +98,8 @@ public class SharedCoordMap {
GL.GL_TRIANGLE_STRIP, GL.GL_TEXTURE_COORD_ARRAY);
data.manageIndicies = false;
textureCoords = new GLGeometryObject2D(data);
textureCoords.setTarget(glTarget);
populateTextureGeom(key, textureCoords);
textureCoords.compile();
textureCoords.compile(glTarget.getGl());
}
private void incRef() {
@ -154,14 +153,13 @@ public class SharedCoordMap {
*/
private static void populateTextureGeom(SharedCoordinateKey key,
GLGeometryObject2D geom) {
geom.allocate(key.verticalDivisions * key.horizontalDivisions * 2);
int height = 2 * key.verticalDivisions;
int height = 2 * (key.verticalDivisions + 1);
int width = key.horizontalDivisions;
geom.allocate(width * height * 2);
// get dx and dy for texture points
float dX = (1.0f / (key.horizontalDivisions));
float dY = (1.0f / (key.verticalDivisions - 1));
float dY = (1.0f / (key.verticalDivisions));
float xLow, xHigh = 0;

View file

@ -0,0 +1,121 @@
/**
* 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.core.gl;
import java.util.ArrayList;
import java.util.List;
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.drawables.IImage.Status;
import com.raytheon.uf.viz.core.jobs.JobPool;
import com.raytheon.viz.core.gl.images.AbstractGLImage;
/**
* Class that loads data for AbstractGLImages asynchronously
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 7/1/06 chammack Initial Creation.
*
* </pre>
*
* @author chammack
*
*/
public class TextureLoader {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(TextureLoader.class);
/** The instance */
private static TextureLoader instance;
private JobPool loaderPool;
private List<AbstractGLImage> texturesToLoad;
/**
* Get the currently running instance of the texture loader
*
* @return
*/
public static synchronized TextureLoader getInstance() {
if (instance == null) {
instance = new TextureLoader();
}
return instance;
}
/**
* Use getInstance() instead of constructor
*
*/
private TextureLoader() {
this.texturesToLoad = new ArrayList<AbstractGLImage>();
this.loaderPool = new JobPool("Texture Loader", Runtime.getRuntime()
.availableProcessors(), true);
}
/**
* Request an image to be loaded
*
* @param img
* the image
*/
public void requestLoad(final AbstractGLImage img) {
if (!texturesToLoad.contains(img)) {
texturesToLoad.add(img);
loaderPool.schedule(new Runnable() {
@Override
public void run() {
try {
try {
img.stage();
} catch (Throwable t) {
img.setStatus(Status.FAILED);
statusHandler.handle(
Priority.PROBLEM,
"Error staging texture: "
+ t.getLocalizedMessage(), t);
}
} finally {
texturesToLoad.remove(img);
}
}
});
}
}
/**
* Request the job to be shut down
*
*/
public void shutdown() {
loaderPool.cancel();
}
}

Some files were not shown because too many files have changed in this diff Show more