();;
+
+ /**
+ * Find the DataManager associated with a discriminator
+ *
+ * If it does not exist, return null.
+ *
+ * @param discriminator
+ * the discriminator
+ * @return the DataManager associated with the specified discriminator
+ */
+ static DataManager findInstance(Object discriminator) {
+ return instanceMap.get(new DataManagerKey(discriminator));
+ }
+
+ /**
+ * Gets an instance of the DataManager for the given discriminator, factory
+ * will be used to create display manager
+ *
+ * @param factory
+ * @param discriminator
+ * @return
+ */
+ public static DataManager getInstance(DataManagerFactory factory,
+ Object discriminator) {
+ synchronized (DataManagerKey.class) {
+ DataManagerKey key = new DataManagerKey(discriminator);
+ DataManager dm = instanceMap.get(key);
+ if (dm == null) {
+ try {
+ dm = new DataManager(factory, discriminator);
+ instanceMap.put(key, dm);
+ waitForJobs(dm);
+ } catch (GFEServerException e) {
+ statusHandler.handle(Priority.PROBLEM,
+ e.getLocalizedMessage(), e);
+ }
+ }
+ return dm;
+ }
+ }
+
+ /**
+ * @param dataManager
+ */
+ private static void waitForJobs(DataManager dataManager) {
+ // wait to ensure init jobs are done
+ long waitForJobs = 0;
+ while (!dataManager.getInitStatus().isDone()) {
+ try {
+ waitForJobs += 10;
+ Thread.sleep(10);
+ } catch (InterruptedException e) {
+ statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(),
+ e);
+ }
+ }
+ System.out.println("Waiting on Jobs: " + waitForJobs);
+ }
+
+ /**
+ * Dispose an instance of the DataManager associated with a particular
+ * discriminator
+ *
+ * @param window
+ */
+ public static void dispose(Object discriminator) {
+ synchronized (DataManagerKey.class) {
+ DataManager dm = instanceMap.remove(new DataManagerKey(
+ discriminator));
+
+ if (dm != null) {
+ dm.dispose();
+ }
+ }
+ }
+
+ /**
+ * Create an {@link ISpatialDisplayManager} for the {@link DataManager} and
+ * discriminator
+ *
+ * @param dm
+ * @param discriminator
+ * @return
+ */
+ protected abstract ISpatialDisplayManager createSpatialDisplayManager(
+ DataManager dm, Object discriminator);
+}
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/DataManagerOffscreenFactory.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/DataManagerOffscreenFactory.java
new file mode 100644
index 0000000000..29ef586f4b
--- /dev/null
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/DataManagerOffscreenFactory.java
@@ -0,0 +1,73 @@
+/**
+ * This software was developed and / or modified by Raytheon Company,
+ * pursuant to Contract DG133W-05-CQ-1067 with the US Government.
+ *
+ * U.S. EXPORT CONTROLLED TECHNICAL DATA
+ * This software product contains export-restricted data whose
+ * export/transfer/disclosure is restricted by U.S. law. Dissemination
+ * to non-U.S. persons whether in the United States or abroad requires
+ * an export license or other authorization.
+ *
+ * Contractor Name: Raytheon Company
+ * Contractor Address: 6825 Pine Street, Suite 340
+ * Mail Stop B8
+ * Omaha, NE 68106
+ * 402.291.0100
+ *
+ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
+ * further licensing information.
+ **/
+package com.raytheon.viz.gfe.core;
+
+import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
+import com.raytheon.viz.gfe.core.internal.OffscreenSpatialDisplayManager;
+
+/**
+ * Manages windowless DataManagers for {@link IRenderableDisplay}s. Mostly used
+ * for offscreen rendering applications
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * Nov 27, 2012 mschenke Initial creation
+ *
+ *
+ *
+ * @author mschenke
+ * @version 1.0
+ */
+
+public class DataManagerOffscreenFactory extends DataManagerFactory {
+
+ private static DataManagerOffscreenFactory instance = new DataManagerOffscreenFactory();
+
+ /**
+ * Gets (will create if none) the DataManager for the given display
+ *
+ * @param display
+ * @return
+ */
+ public static DataManager getInstance(GFEMapRenderableDisplay display) {
+ DataManager dm = DataManagerFactory.getInstance(instance, display);
+ display.setDataManager(dm);
+ return dm;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.raytheon.viz.gfe.core.DataManagerFactory#createSpatialDisplayManager
+ * (com.raytheon.viz.gfe.core.DataManager, java.lang.Object)
+ */
+ @Override
+ protected ISpatialDisplayManager createSpatialDisplayManager(
+ DataManager dm, Object discriminator) {
+ return new OffscreenSpatialDisplayManager(
+ (GFEMapRenderableDisplay) discriminator, dm);
+ }
+
+}
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/DataManagerUIFactory.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/DataManagerUIFactory.java
new file mode 100644
index 0000000000..b5714e61b3
--- /dev/null
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/DataManagerUIFactory.java
@@ -0,0 +1,140 @@
+/**
+ * This software was developed and / or modified by Raytheon Company,
+ * pursuant to Contract DG133W-05-CQ-1067 with the US Government.
+ *
+ * U.S. EXPORT CONTROLLED TECHNICAL DATA
+ * This software product contains export-restricted data whose
+ * export/transfer/disclosure is restricted by U.S. law. Dissemination
+ * to non-U.S. persons whether in the United States or abroad requires
+ * an export license or other authorization.
+ *
+ * Contractor Name: Raytheon Company
+ * Contractor Address: 6825 Pine Street, Suite 340
+ * Mail Stop B8
+ * Omaha, NE 68106
+ * 402.291.0100
+ *
+ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
+ * further licensing information.
+ **/
+package com.raytheon.viz.gfe.core;
+
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID;
+import com.raytheon.uf.viz.core.VizApp;
+import com.raytheon.viz.gfe.core.internal.GFESpatialDisplayManager;
+import com.raytheon.viz.ui.VizWorkbenchManager;
+
+/**
+ * UI based {@link DataManager} factory. Uses {@link IWorkbenchWindow} objects
+ * as the discriminator for keeping track of instances
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * Nov 27, 2012 mschenke Initial creation
+ *
+ *
+ *
+ * @author mschenke
+ *
+ *
+ * @version 1.0
+ */
+
+public class DataManagerUIFactory extends DataManagerFactory {
+
+ private static DataManagerUIFactory instance = new DataManagerUIFactory();
+
+ /**
+ * Find the DataManager associated with a specific workbench window
+ *
+ * If it does not exist, return null.
+ *
+ * @param window
+ * the workbench window
+ * @return the DataManager associated with the specified window
+ */
+ public static DataManager findInstance(IWorkbenchWindow window) {
+ return DataManagerFactory.findInstance(window);
+ }
+
+ /**
+ * Get the DataManager associated with the currently active workbench
+ * window.
+ *
+ * If no workbench window is active, or the GFE perspective has not been
+ * activated in the active window, this method will return null.
+ *
+ * @return the active DataManager
+ */
+ public static DataManager getCurrentInstance() {
+ final IWorkbenchWindow[] window = new IWorkbenchWindow[1];
+
+ window[0] = VizWorkbenchManager.getInstance().getCurrentWindow();
+
+ if (window[0] == null && PlatformUI.isWorkbenchRunning()) {
+ VizApp.runSync(new Runnable() {
+
+ @Override
+ public void run() {
+ window[0] = PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow();
+ }
+
+ });
+ }
+
+ return findInstance(window[0]);
+ }
+
+ /**
+ * Get the DataManager associated with a specific workbench window
+ *
+ * If it does not exist, create one.
+ *
+ * @param window
+ * the window the DataManager is associated with
+ * @return a DataManager associated to a specific window
+ */
+ public static DataManager getInstance(IWorkbenchWindow window) {
+ DataManager dm = DataManagerFactory.getInstance(instance, window);
+ if (window != null) {
+ postInitialize(dm);
+ }
+ return dm;
+ }
+
+ /**
+ * Tell ParmManager which parms to load initially
+ *
+ * @param dataManager
+ */
+ private static void postInitialize(DataManager dataManager) {
+ IParmManager parmMgr = dataManager.getParmManager();
+ ParmID[] parmIDs = dataManager.getWEGroupManager().getParmIDs(
+ dataManager.getWEGroupManager().getDefaultGroup(),
+ parmMgr.getAllAvailableParms());
+
+ parmMgr.setDisplayedParms(parmIDs);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.raytheon.viz.gfe.core.DataManagerFactory#createSpatialDisplayManager
+ * (com.raytheon.viz.gfe.core.DataManager, java.lang.Object)
+ */
+ @Override
+ protected ISpatialDisplayManager createSpatialDisplayManager(
+ DataManager dm, Object discriminator) {
+ return new GFESpatialDisplayManager(dm);
+ }
+
+}
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/GFEIntervalTimeMatcher.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/GFEIntervalTimeMatcher.java
new file mode 100644
index 0000000000..d08fe6fa47
--- /dev/null
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/GFEIntervalTimeMatcher.java
@@ -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.viz.gfe.core;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+
+import com.raytheon.uf.common.time.DataTime;
+import com.raytheon.uf.common.time.TimeRange;
+import com.raytheon.uf.viz.core.drawables.IDescriptor;
+import com.raytheon.uf.viz.core.drawables.IDescriptor.FramesInfo;
+import com.raytheon.viz.gfe.rsc.GFEResource;
+
+/**
+ * Time matcher that uses a set interval/offset and start/end time to calculate
+ * DataTimes for a descriptor
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * Nov 28, 2012 mschenke Initial creation
+ *
+ *
+ *
+ * @author mschenke
+ * @version 1.0
+ */
+
+public class GFEIntervalTimeMatcher extends GFETimeMatcher {
+
+ private static final long HRS_TO_MILLIS = 3600 * 1000;
+
+ private DataTime[] dataTimes = new DataTime[0];
+
+ /**
+ * Set the time matching interval data used to calculate the data times
+ *
+ * @param intervalInHrs
+ * @param intervalOffsetInHrs
+ * @param timeRange
+ */
+ public void setTimeMatchingInterval(int intervalInHrs,
+ int intervalOffsetInHrs, TimeRange timeRange) {
+ long intervalInMillis = intervalInHrs * HRS_TO_MILLIS;
+ long intervalOffsetInMillis = intervalOffsetInHrs * HRS_TO_MILLIS;
+
+ List times = new ArrayList();
+ long firstTime = timeRange.getStart().getTime();
+ long lastTime = timeRange.getEnd().getTime();
+
+ long time = ((firstTime / intervalInMillis) * intervalInMillis)
+ + intervalOffsetInMillis;
+ while (time <= lastTime) {
+ if (time >= firstTime) {
+ times.add(new DataTime(new Date(time)));
+ }
+ time += intervalInMillis;
+ }
+ dataTimes = times.toArray(new DataTime[0]);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.raytheon.viz.gfe.core.GFETimeMatcher#calculateDescriptorTimes(com
+ * .raytheon.uf.viz.core.drawables.IDescriptor,
+ * com.raytheon.uf.viz.core.drawables.IDescriptor.FramesInfo, java.util.Set)
+ */
+ @Override
+ protected DataTime[] calculateDescriptorTimes(IDescriptor descriptor,
+ FramesInfo currInfo, Set tmbResources) {
+ return Arrays.copyOf(dataTimes, dataTimes.length);
+ }
+
+}
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/GFEMapRenderableDisplay.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/GFEMapRenderableDisplay.java
index 79ee3d329a..7c33c268f7 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/GFEMapRenderableDisplay.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/GFEMapRenderableDisplay.java
@@ -26,6 +26,7 @@ import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import com.raytheon.uf.common.time.DataTime;
+import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.map.MapDescriptor;
@@ -75,6 +76,21 @@ public class GFEMapRenderableDisplay extends PlainMapRenderableDisplay
super(desc);
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.raytheon.uf.viz.core.drawables.AbstractRenderableDisplay#setDescriptor
+ * (com.raytheon.uf.viz.core.drawables.IDescriptor)
+ */
+ @Override
+ public void setDescriptor(IDescriptor desc) {
+ super.setDescriptor(desc);
+ if (desc.getTimeMatcher() == null) {
+ desc.setTimeMatcher(new GFETimeMatcher());
+ }
+ }
+
@SuppressWarnings("unchecked")
public void setDataManager(DataManager dataManager) {
if (this.dataMgr != null) {
@@ -102,9 +118,9 @@ public class GFEMapRenderableDisplay extends PlainMapRenderableDisplay
protected PaintProperties calcPaintDataTime(PaintProperties paintProps,
AbstractVizResource, ?> rsc) {
if (dataMgr != null) {
- Date date = dataMgr.getSpatialDisplayManager()
- .getSpatialEditorTime();
- paintProps.setDataTime(new DataTime(date));
+ // Get time for resource from FramesInfo
+ paintProps.setDataTime(paintProps.getFramesInfo()
+ .getTimeForResource(rsc));
}
GFEPaintProperties gfeProps = new GFEPaintProperties(paintProps);
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/GFETimeMatcher.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/GFETimeMatcher.java
new file mode 100644
index 0000000000..b7d28e0176
--- /dev/null
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/GFETimeMatcher.java
@@ -0,0 +1,270 @@
+/**
+ * This software was developed and / or modified by Raytheon Company,
+ * pursuant to Contract DG133W-05-CQ-1067 with the US Government.
+ *
+ * U.S. EXPORT CONTROLLED TECHNICAL DATA
+ * This software product contains export-restricted data whose
+ * export/transfer/disclosure is restricted by U.S. law. Dissemination
+ * to non-U.S. persons whether in the United States or abroad requires
+ * an export license or other authorization.
+ *
+ * Contractor Name: Raytheon Company
+ * Contractor Address: 6825 Pine Street, Suite 340
+ * Mail Stop B8
+ * Omaha, NE 68106
+ * 402.291.0100
+ *
+ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
+ * further licensing information.
+ **/
+package com.raytheon.viz.gfe.core;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+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.common.time.TimeRange;
+import com.raytheon.uf.viz.core.AbstractTimeMatcher;
+import com.raytheon.uf.viz.core.drawables.IDescriptor;
+import com.raytheon.uf.viz.core.drawables.IDescriptor.FramesInfo;
+import com.raytheon.uf.viz.core.drawables.ResourcePair;
+import com.raytheon.uf.viz.core.exception.VizException;
+import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
+import com.raytheon.uf.viz.core.rsc.LoadProperties;
+import com.raytheon.viz.gfe.core.griddata.IGridData;
+import com.raytheon.viz.gfe.core.parm.Parm;
+import com.raytheon.viz.gfe.rsc.GFEResource;
+
+/**
+ * GFE Time matcher, uses the union of visible resources available times to
+ * create set of descriptor times. Has notion of a selected time which is added
+ * to set of descriptor times
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * Nov 14, 2012 mschenke Initial creation
+ *
+ *
+ *
+ * @author mschenke
+ * @version 1.0
+ */
+
+public class GFETimeMatcher extends AbstractTimeMatcher {
+
+ /** The selected date, added as a extra frame if not null */
+ private Date selectedDate;
+
+ /** Set of resources used in calculating the descriptor times */
+ private Set tmbResources = new HashSet();
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.raytheon.uf.viz.core.AbstractTimeMatcher#redoTimeMatching(com.raytheon
+ * .uf.viz.core.rsc.AbstractVizResource)
+ */
+ @Override
+ public void redoTimeMatching(AbstractVizResource, ?> resource) {
+ // Noop
+ }
+
+ /**
+ * Time matches a single resource against the set of descriptorTimes and
+ * adds times into the timeMap
+ *
+ * @param descriptorTimes
+ * @param timeMap
+ * @param resource
+ */
+ private void redoTimeMatching(DataTime[] descriptorTimes,
+ Map, DataTime[]> timeMap,
+ AbstractVizResource, ?> resource) {
+ if (resource instanceof GFEResource) {
+ GFEResource rsc = (GFEResource) resource;
+ Parm parm = rsc.getParm();
+ DataTime[] rscTimes = new DataTime[descriptorTimes.length];
+ for (int i = 0; i < descriptorTimes.length; ++i) {
+ IGridData overlapping = parm.overlappingGrid(descriptorTimes[i]
+ .getRefTime());
+ if (overlapping != null) {
+ TimeRange tr = overlapping.getGridTime();
+ rscTimes[i] = new DataTime(tr.getStart().getTime(),
+ new TimeRange(tr.getStart(), tr.getEnd()));
+ }
+ }
+ if (timeMap != null) {
+ timeMap.put(rsc, rscTimes);
+ }
+ }
+ }
+
+ protected DataTime[] calculateDescriptorTimes(IDescriptor descriptor,
+ FramesInfo currInfo, Set tmbResources) {
+ DataTime currTime = currInfo.getCurrentFrame();
+ List rscs = descriptor.getResourceList()
+ .getResourcesByTypeAsType(GFEResource.class);
+
+ // Figure list of parms from visible GFEResources
+ List parms = new ArrayList(rscs.size());
+ for (GFEResource rsc : rscs) {
+ if (rsc.getProperties().isVisible()) {
+ parms.add(rsc.getParm());
+ tmbResources.add(rsc);
+ }
+ }
+
+ // calculate time steps from parms
+ SortedSet dateSet = new TreeSet();
+ for (Date stepTime : calcTimeSteps(parms)) {
+ dateSet.add(new DataTime(stepTime));
+ }
+
+ if (currTime != null && selectedDate == null
+ && dateSet.contains(currTime) == false) {
+ selectedDate = currTime.getRefTime();
+ }
+
+ // Add special selected time
+ if (selectedDate != null) {
+ currTime = new DataTime(selectedDate);
+ dateSet.add(currTime);
+ }
+ return dateSet.toArray(new DataTime[0]);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.raytheon.uf.viz.core.AbstractTimeMatcher#redoTimeMatching(com.raytheon
+ * .uf.viz.core.drawables.IDescriptor)
+ */
+ @Override
+ public synchronized void redoTimeMatching(IDescriptor descriptor)
+ throws VizException {
+ Set tmbResources = new HashSet();
+ FramesInfo currInfo = descriptor.getFramesInfo();
+ int currIdx = currInfo.getFrameIndex();
+ DataTime currTime = currInfo.getCurrentFrame();
+
+ // Create descriptor times, for each resource, time match against them
+ DataTime[] descriptorTimes = calculateDescriptorTimes(descriptor,
+ currInfo, tmbResources);
+ Map, DataTime[]> rscTimeMap = new HashMap, DataTime[]>();
+ for (ResourcePair rp : descriptor.getResourceList()) {
+ redoTimeMatching(descriptorTimes, rscTimeMap, rp.getResource());
+ }
+
+ // Update current displayed index
+ if (descriptorTimes.length == 0) {
+ currIdx = -1;
+ } else if (currTime != null) {
+ currIdx = Arrays.binarySearch(descriptorTimes, currTime);
+ if (currIdx < 0) {
+ // Fix Arrays.binarySearch returning -insertionIndex-1
+ currIdx = -currIdx - 1;
+ }
+ } else {
+ currIdx = 0;
+ }
+
+ FramesInfo newInfo = new FramesInfo(descriptorTimes, currIdx,
+ rscTimeMap);
+ descriptor.setFramesInfo(newInfo);
+
+ this.tmbResources = tmbResources;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.raytheon.uf.viz.core.AbstractTimeMatcher#handleRemove(com.raytheon
+ * .uf.viz.core.rsc.AbstractVizResource,
+ * com.raytheon.uf.viz.core.drawables.IDescriptor)
+ */
+ @Override
+ public void handleRemove(AbstractVizResource, ?> resource,
+ IDescriptor descriptor) {
+ if (tmbResources.contains(resource)) {
+ // This was a time match basis resource, need to redo time matching
+ try {
+ redoTimeMatching(resource.getDescriptor());
+ } catch (VizException e) {
+ // Do not like this handle, should throw exception?
+ UFStatus.getHandler().handle(Priority.PROBLEM,
+ e.getLocalizedMessage(), e);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.raytheon.uf.viz.core.AbstractTimeMatcher#initialLoad(com.raytheon
+ * .uf.viz.core.rsc.LoadProperties, com.raytheon.uf.common.time.DataTime[],
+ * com.raytheon.uf.viz.core.drawables.IDescriptor)
+ */
+ @Override
+ public DataTime[] initialLoad(LoadProperties loadProps,
+ DataTime[] availableTimes, IDescriptor descriptor)
+ throws VizException {
+ // Should we support this? Would need to figure out a simple time
+ // matching method (would be same as how non GFEResources are handled in
+ // redoTimeMatching)
+ return new DataTime[0];
+ }
+
+ /**
+ * @param selectedDate
+ * the selectedDate to set
+ */
+ public void setSelectedDate(Date selectedDate) {
+ this.selectedDate = selectedDate;
+ }
+
+ /**
+ * Given a list of parms, calculate the time steps between them
+ *
+ * @param parms
+ * @return
+ */
+ public static List calcTimeSteps(List parms) {
+ SortedSet dateSet = new TreeSet();
+ for (Parm pi : parms) {
+ IGridData[] inv = pi.getGridInventory();
+ for (IGridData grid : inv) {
+ dateSet.add(grid.getGridTime().getStart());
+
+ if (!dateSet.contains(grid.getGridTime().getEnd())) {
+ for (Parm pk : parms) {
+ if (pi != pk
+ && pk.overlappingGrid(grid.getGridTime()
+ .getEnd()) != null) {
+ dateSet.add(grid.getGridTime().getEnd());
+ break;
+ }
+ }
+ }
+ }
+ }
+ return new ArrayList(dateSet);
+ }
+}
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/IParmManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/IParmManager.java
index cd428ddc14..0465a0b832 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/IParmManager.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/IParmManager.java
@@ -19,7 +19,6 @@
**/
package com.raytheon.viz.gfe.core;
-import java.util.Date;
import java.util.List;
import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID;
@@ -551,6 +550,4 @@ public interface IParmManager extends IParmInventoryChangedListener,
public JobPool getNotificationPool();
public VCModuleJobPool getVCModulePool();
-
- public abstract List calcStepTimes(List parms, TimeRange dspTR);
}
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/ISpatialDisplayManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/ISpatialDisplayManager.java
index a7c0a76841..215c1783ce 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/ISpatialDisplayManager.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/ISpatialDisplayManager.java
@@ -22,7 +22,6 @@ package com.raytheon.viz.gfe.core;
import java.util.Date;
import com.raytheon.uf.common.time.TimeRange;
-import com.raytheon.uf.viz.core.PixelExtent;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
@@ -71,8 +70,7 @@ public interface ISpatialDisplayManager {
public void setSpatialEditorTime(Date date);
/**
- * Activate a certain parm on the spatial editor. This will also disable all
- * other parms
+ * Activate the specified parm for the display manager.
*
* @param parmToActivate
* the parm to activate
@@ -246,14 +244,6 @@ public interface ISpatialDisplayManager {
*/
public Parm[] getCurrentlyEnabledParms();
- /**
- * Return the area of the screen (if any) that the colorbar is currently
- * occupying.
- *
- * @return the colorbar coverage, or null if no colorbar displayed.
- */
- public PixelExtent getColorbarExtent();
-
/**
* Return the GFE System Resource
*
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/AbstractParmManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/AbstractParmManager.java
index cf20e10bc4..821357e690 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/AbstractParmManager.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/AbstractParmManager.java
@@ -2103,31 +2103,4 @@ public abstract class AbstractParmManager implements IParmManager {
return vcModulePool;
}
- // Now construct the step times.
- // All startTimes are included.
- // EndTimes which are contained in another TR are included.
- @Override
- public List calcStepTimes(List parms, TimeRange dspTR) {
- SortedSet dateSet = new TreeSet();
-
- for (Parm pi : parms) {
- IGridData[] inv = pi.getGridInventory();
- for (IGridData grid : inv) {
- dateSet.add(grid.getGridTime().getStart());
-
- if (!dateSet.contains(grid.getGridTime().getEnd())) {
- for (Parm pk : parms) {
- if (pi != pk
- && pi.overlappingGrid(grid.getGridTime()
- .getEnd()) != null) {
- dateSet.add(grid.getGridTime().getEnd());
- break;
- }
- }
- }
- }
- }
-
- return new ArrayList(dateSet);
- }
}
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/AbstractSpatialDisplayManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/AbstractSpatialDisplayManager.java
index 5cf8744df7..26aa80b964 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/AbstractSpatialDisplayManager.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/AbstractSpatialDisplayManager.java
@@ -22,7 +22,6 @@ package com.raytheon.viz.gfe.core.internal;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -30,10 +29,14 @@ import org.apache.commons.lang.Validate;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
-import com.raytheon.uf.common.time.SimulatedTime;
-import com.raytheon.uf.viz.core.PixelExtent;
+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.common.time.TimeRange;
+import com.raytheon.uf.viz.core.AbstractTimeMatcher;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
+import com.raytheon.uf.viz.core.drawables.IDescriptor.FramesInfo;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
@@ -44,6 +47,7 @@ import com.raytheon.viz.gfe.Activator;
import com.raytheon.viz.gfe.GFEOperationFailedException;
import com.raytheon.viz.gfe.actions.ShowISCMarkersAction;
import com.raytheon.viz.gfe.core.DataManager;
+import com.raytheon.viz.gfe.core.GFETimeMatcher;
import com.raytheon.viz.gfe.core.ISpatialDisplayManager;
import com.raytheon.viz.gfe.core.msgs.IActivatedParmChangedListener;
import com.raytheon.viz.gfe.core.msgs.IDisplayModeChangedListener;
@@ -58,7 +62,6 @@ import com.raytheon.viz.gfe.core.parm.ParmDisplayAttributes.VisMode;
import com.raytheon.viz.gfe.edittool.AbstractGFEEditTool;
import com.raytheon.viz.gfe.rsc.GFEResource;
import com.raytheon.viz.gfe.rsc.GFESystemResource;
-import com.raytheon.viz.gfe.rsc.colorbar.GFEColorbarResource;
/**
* Abstract Spatial Display Manager for GFE. Most of the implemented methods
@@ -83,6 +86,8 @@ public abstract class AbstractSpatialDisplayManager implements
protected final DataManager dataManager;
+ private TimeRange globalTimeRange;
+
protected Date seTime;
protected Parm activeParm;
@@ -117,7 +122,7 @@ public abstract class AbstractSpatialDisplayManager implements
protected AbstractSpatialDisplayManager(DataManager dataMgr) {
this.dataManager = dataMgr;
- this.seTime = SimulatedTime.getSystemTime().getTime();
+ this.globalTimeRange = new TimeRange(0, 0);
this.activatedParmChangedListeners = new HashSet();
this.gridVisibilityChangedListeners = new HashSet();
this.globalSelectionTRChangedListeners = new HashSet();
@@ -146,6 +151,12 @@ public abstract class AbstractSpatialDisplayManager implements
.getBoolean("ShowISCOfficialSymbol"));
}
+ /**
+ * Gets any descriptors to be kept in sync with the display manager (can be
+ * empty)
+ *
+ * @return
+ */
protected abstract IDescriptor[] getDescriptors();
/*
@@ -311,13 +322,10 @@ public abstract class AbstractSpatialDisplayManager implements
IDescriptor[] descriptors = getDescriptors();
for (IDescriptor desc : descriptors) {
ResourceList rl = desc.getResourceList();
- synchronized (rl) {
- for (ResourcePair rp : rl) {
- AbstractVizResource, ?> rsc = rp.getResource();
- if (rsc instanceof GFESystemResource) {
- ((GFESystemResource) rsc).addEditTool(editTool);
- }
- }
+ List rscs = rl
+ .getResourcesByTypeAsType(GFESystemResource.class);
+ for (GFESystemResource rsc : rscs) {
+ rsc.addEditTool(editTool);
}
}
}
@@ -332,16 +340,11 @@ public abstract class AbstractSpatialDisplayManager implements
@Override
public void removeEditTool(AbstractGFEEditTool editTool)
throws VizException {
- IDescriptor[] descriptors = getDescriptors();
- for (IDescriptor desc : descriptors) {
- ResourceList rl = desc.getResourceList();
- synchronized (rl) {
- for (ResourcePair rp : rl) {
- AbstractVizResource, ?> rsc = rp.getResource();
- if (rsc instanceof GFESystemResource) {
- ((GFESystemResource) rsc).removeEditTool(editTool);
- }
- }
+ for (IDescriptor desc : getDescriptors()) {
+ List rscs = desc.getResourceList()
+ .getResourcesByTypeAsType(GFESystemResource.class);
+ for (GFESystemResource rsc : rscs) {
+ rsc.removeEditTool(editTool);
}
}
}
@@ -356,14 +359,13 @@ public abstract class AbstractSpatialDisplayManager implements
@Override
public ColorMapParameters getColorMapParameters(Parm p)
throws GFEOperationFailedException {
- IDescriptor[] descriptors = getDescriptors();
- if (descriptors.length == 0) {
- throw new GFEOperationFailedException(
- "Unable to get colormap from parm because spatial editor is not active");
+ for (IDescriptor descriptor : getDescriptors()) {
+ ColorMapParameters cmap = getColorMapParameters(p, descriptor);
+ if (cmap != null) {
+ return cmap;
+ }
}
-
- IDescriptor descriptor = descriptors[0];
- return getColorMapParameters(p, descriptor);
+ return null;
}
/*
@@ -389,32 +391,6 @@ public abstract class AbstractSpatialDisplayManager implements
return null;
}
- /*
- * (non-Javadoc)
- *
- * @see com.raytheon.viz.gfe.core.ISpatialDisplayManager#getColorbarExtent()
- */
- @Override
- public PixelExtent getColorbarExtent() {
- IDescriptor[] descriptors = getDescriptors();
- if (descriptors.length == 0) {
- return null;
- }
-
- IDescriptor descriptor = descriptors[0];
- ResourceList rscList = descriptor.getResourceList();
- synchronized (rscList) {
- for (ResourcePair rp : rscList) {
- AbstractVizResource, ?> rsc = rp.getResource();
- if (rsc instanceof GFEColorbarResource) {
- return ((GFEColorbarResource) rsc).getExtent();
- }
- }
- }
-
- return null;
- }
-
/*
* (non-Javadoc)
*
@@ -425,30 +401,17 @@ public abstract class AbstractSpatialDisplayManager implements
*/
@Override
public void setDisplayMode(Parm parm, VisMode mode) {
- IDescriptor[] descriptors = getDescriptors();
- if (descriptors.length == 0) {
- return;
- }
-
- for (IDescriptor descriptor : descriptors) {
- ResourceList resourceList = descriptor.getResourceList();
- synchronized (resourceList) {
- Iterator iterator = resourceList.iterator();
-
- while (iterator.hasNext()) {
- ResourcePair resourcePair = iterator.next();
- AbstractVizResource, ?> rsc = resourcePair.getResource();
- if (rsc instanceof GFEResource) {
- Parm p = ((GFEResource) rsc).getParm();
- if (p.equals(parm)) {
- p.getDisplayAttributes().setVisMode(mode);
- ((GFEResource) rsc).reset();
- } else if (mode.equals(VisMode.IMAGE)) {
- p.getDisplayAttributes()
- .setVisMode(VisMode.GRAPHIC);
- ((GFEResource) rsc).reset();
- }
- }
+ for (IDescriptor descriptor : getDescriptors()) {
+ List rscs = descriptor.getResourceList()
+ .getResourcesByTypeAsType(GFEResource.class);
+ for (GFEResource rsc : rscs) {
+ Parm p = rsc.getParm();
+ if (p.equals(parm)) {
+ p.getDisplayAttributes().setVisMode(mode);
+ rsc.reset();
+ } else if (mode.equals(VisMode.IMAGE)) {
+ p.getDisplayAttributes().setVisMode(VisMode.GRAPHIC);
+ rsc.reset();
}
}
}
@@ -465,16 +428,11 @@ public abstract class AbstractSpatialDisplayManager implements
*/
@Override
public GFESystemResource getSystemResource() throws VizException {
- IDescriptor[] descriptors = getDescriptors();
- if (descriptors.length == 0) {
- return null;
- }
-
- ResourceList rl = descriptors[0].getResourceList();
-
- for (ResourcePair rp : rl) {
- if (rp.getResource() instanceof GFESystemResource) {
- return (GFESystemResource) rp.getResource();
+ for (IDescriptor descriptor : getDescriptors()) {
+ List rscs = descriptor.getResourceList()
+ .getResourcesByTypeAsType(GFESystemResource.class);
+ for (GFESystemResource rsc : rscs) {
+ return rsc;
}
}
@@ -492,21 +450,16 @@ public abstract class AbstractSpatialDisplayManager implements
*/
@Override
public ResourcePair getResourcePair(Parm parm) {
- IDescriptor[] descriptors = getDescriptors();
- if (descriptors.length == 0 || descriptors[0] == null) {
- return null;
- }
+ for (IDescriptor descriptor : getDescriptors()) {
+ ResourceList resourceList = descriptor.getResourceList();
- IDescriptor descriptor = descriptors[0];
-
- ResourceList resourceList = descriptor.getResourceList();
-
- for (ResourcePair resourcePair : resourceList) {
- AbstractVizResource, ?> rsc = resourcePair.getResource();
- if (rsc instanceof GFEResource) {
- GFEResource grsc = (GFEResource) rsc;
- if (grsc.getParm().equals(parm)) {
- return resourcePair;
+ for (ResourcePair resourcePair : resourceList) {
+ AbstractVizResource, ?> rsc = resourcePair.getResource();
+ if (rsc instanceof GFEResource) {
+ GFEResource grsc = (GFEResource) rsc;
+ if (grsc.getParm().equals(parm)) {
+ return resourcePair;
+ }
}
}
}
@@ -522,60 +475,57 @@ public abstract class AbstractSpatialDisplayManager implements
*/
@Override
public Parm[] getCurrentlyEnabledParms() {
- IDescriptor[] descriptors = getDescriptors();
- if (descriptors.length == 0) {
- return new Parm[0];
- }
-
- IDescriptor descriptor = descriptors[0];
- List parmList = new ArrayList();
- ResourceList rscList = descriptor.getResourceList();
- synchronized (rscList) {
- for (ResourcePair rp : rscList) {
- AbstractVizResource, ?> rsc = rp.getResource();
- ResourceProperties props = rp.getProperties();
- if (rsc instanceof GFEResource && props.isVisible()) {
- GFEResource grsc = (GFEResource) rsc;
- parmList.add(grsc.getParm());
+ for (IDescriptor descriptor : getDescriptors()) {
+ List parmList = new ArrayList();
+ List rscs = descriptor.getResourceList()
+ .getResourcesByTypeAsType(GFEResource.class);
+ for (GFEResource rsc : rscs) {
+ if (rsc.getProperties().isVisible()) {
+ parmList.add(rsc.getParm());
}
}
+ if (parmList.size() > 0) {
+ return parmList.toArray(new Parm[parmList.size()]);
+ }
}
- return parmList.toArray(new Parm[parmList.size()]);
+ return new Parm[0];
}
@Override
public void makeVisible(Parm parm, boolean visible, boolean makeOnlyVisible) {
- IDescriptor[] descriptors = getDescriptors();
- if (descriptors.length == 0) {
- return;
+ for (IDescriptor descriptor : getDescriptors()) {
+ makeVisible(descriptor, parm, visible, makeOnlyVisible);
}
- for (IDescriptor descriptor : descriptors) {
- ResourceList resourceList = descriptor.getResourceList();
- synchronized (resourceList) {
- Iterator iterator = resourceList.iterator();
-
- while (iterator.hasNext()) {
- ResourcePair resourcePair = iterator.next();
- AbstractVizResource, ?> rsc = resourcePair.getResource();
- if (rsc instanceof GFEResource) {
- ResourceProperties props = resourcePair.getProperties();
- Parm p = ((GFEResource) rsc).getParm();
- if (p.equals(parm)) {
- props.setVisible(visible);
- } else if (makeOnlyVisible) {
- props.setVisible(false);
- }
- }
- }
- }
- }
for (IGridVisibilityChangedListener listener : this.gridVisibilityChangedListeners) {
listener.gridVisibilityChanged(parm, visible, makeOnlyVisible);
}
}
+ private void makeVisible(IDescriptor descriptor, Parm parm,
+ boolean visible, boolean makeOnlyVisible) {
+ List rscs = descriptor.getResourceList()
+ .getResourcesByTypeAsType(GFEResource.class);
+ for (GFEResource rsc : rscs) {
+ ResourceProperties props = rsc.getProperties();
+ Parm p = rsc.getParm();
+ if (p.equals(parm)) {
+ props.setVisible(visible);
+ } else if (makeOnlyVisible) {
+ props.setVisible(false);
+ }
+ }
+
+ try {
+ // Parm visibility affects GFE time matching
+ descriptor.redoTimeMatching();
+ } catch (VizException e) {
+ UFStatus.getHandler().handle(Priority.PROBLEM,
+ e.getLocalizedMessage(), e);
+ }
+ }
+
/*
* (non-Javadoc)
*
@@ -585,47 +535,36 @@ public abstract class AbstractSpatialDisplayManager implements
*/
public void activateParm(Parm parmToActivate)
throws GFEOperationFailedException {
- IDescriptor[] descriptors = getDescriptors();
- if (descriptors.length == 0) {
- throw new GFEOperationFailedException(
- "Unable to activate parm because spatial editor is not active");
+ // Keep any resources on descriptors in sync
+ for (IDescriptor descriptor : getDescriptors()) {
+ ResourceList resourceList = descriptor.getResourceList();
+ List rscs = resourceList
+ .getResourcesByTypeAsType(GFEResource.class);
+ for (GFEResource rsc : rscs) {
+ ResourceProperties props = rsc.getProperties();
+ // skip the quick view resource
+ if (props.isSystemResource()) {
+ continue;
+ }
+ Parm parm = ((GFEResource) rsc).getParm();
+ if (parm.equals(parmToActivate)) {
+ props.setVisible(true);
+ }
+ ((GFEResource) rsc).reset();
+ }
}
- for (IDescriptor descriptor : descriptors) {
- ResourceList resourceList = descriptor.getResourceList();
- synchronized (resourceList) {
- Iterator iterator = resourceList.iterator();
-
- while (iterator.hasNext()) {
- ResourcePair resourcePair = iterator.next();
- AbstractVizResource, ?> rsc = resourcePair.getResource();
- if (rsc instanceof GFEResource) {
- ResourceProperties props = resourcePair.getProperties();
- // skip the quick view resource
- if (props.isSystemResource()) {
- continue;
- }
- Parm parm = ((GFEResource) rsc).getParm();
- if (parm.equals(parmToActivate)) {
- props.setVisible(true);
- }
- ((GFEResource) rsc).reset();
- }
- }
-
- this.activeParm = parmToActivate;
- if (activeParm != null) {
- if (Message.inquireLastMessage(
- SetImageOnActiveChangedMsg.class).isEnabled()) {
- setDisplayMode(parmToActivate, VisMode.IMAGE);
- }
- this.lastActiveParm = parmToActivate;
- }
-
- for (IActivatedParmChangedListener listener : this.activatedParmChangedListeners) {
- listener.activatedParmChanged(parmToActivate);
- }
+ this.activeParm = parmToActivate;
+ if (activeParm != null) {
+ if (Message.inquireLastMessage(SetImageOnActiveChangedMsg.class)
+ .isEnabled()) {
+ setDisplayMode(parmToActivate, VisMode.IMAGE);
}
+ this.lastActiveParm = parmToActivate;
+ }
+
+ for (IActivatedParmChangedListener listener : this.activatedParmChangedListeners) {
+ listener.activatedParmChanged(parmToActivate);
}
}
@@ -712,13 +651,51 @@ public abstract class AbstractSpatialDisplayManager implements
}
@Override
- public void setSpatialEditorTime(Date date) {
- seTime = date;
+ public Date getSpatialEditorTime() {
+ // Check descriptors first for current time
+ IDescriptor[] descs = getDescriptors();
+ for (IDescriptor desc : descs) {
+ FramesInfo fi = desc.getFramesInfo();
+ DataTime dt = fi.getCurrentFrame();
+ if (dt != null) {
+ return dt.getRefTime();
+ }
+ }
+ // No descriptors or no set time, use seTime
+ return seTime;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.raytheon.viz.gfe.core.ISpatialDisplayManager#setSpatialEditorTime
+ * (java.util.Date)
+ */
@Override
- public Date getSpatialEditorTime() {
- return seTime;
+ public void setSpatialEditorTime(Date date) {
+ this.seTime = date;
+ // Keep descriptors in sync
+ for (IDescriptor desc : getDescriptors()) {
+ setSpatialEditorTime(desc, date);
+ }
+ }
+
+ protected void setSpatialEditorTime(IDescriptor descriptor, Date date) {
+ AbstractTimeMatcher matcher = descriptor.getTimeMatcher();
+ if (matcher instanceof GFETimeMatcher) {
+ ((GFETimeMatcher) matcher).setSelectedDate(date);
+ try {
+ // Selected spatial editor time affects GFE time matching
+ matcher.redoTimeMatching(descriptor);
+ } catch (VizException e) {
+ UFStatus.getHandler().handle(Priority.PROBLEM,
+ "Error redoing time matching", e);
+ }
+ }
+ if (date != null) {
+ descriptor.getFrameCoordinator().changeFrame(date);
+ }
}
private void updateElement(String commandId, boolean state) {
@@ -729,4 +706,65 @@ public abstract class AbstractSpatialDisplayManager implements
service.refreshElements(commandId, null);
}
}
+
+ @Override
+ public void toggleVisibility(Parm parm) {
+ Boolean visible = null;
+ // Check for parm on any descriptor, use visiblity of first found
+ for (IDescriptor descriptor : getDescriptors()) {
+ ResourceList resourceList = descriptor.getResourceList();
+ List rscs = resourceList
+ .getResourcesByTypeAsType(GFEResource.class);
+ for (GFEResource rsc : rscs) {
+ Parm p = rsc.getParm();
+ if (p.equals(parm)) {
+ visible = rsc.getProperties().isVisible();
+ break;
+ }
+ }
+ if (visible != null) {
+ break;
+ }
+ }
+
+ if (visible != null) {
+ // Only if resource visibilty was found do we toggle and notify
+ visible = !visible;
+ for (IDescriptor descriptor : getDescriptors()) {
+ makeVisible(descriptor, parm, visible, false);
+ }
+
+ for (IGridVisibilityChangedListener listener : this.gridVisibilityChangedListeners) {
+ listener.gridVisibilityChanged(parm, visible, false);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.raytheon.viz.gfe.core.ISpatialDisplayManager#setGlobalTimeRange(com
+ * .raytheon.edex.plugin.time.TimeRange)
+ */
+ @Override
+ public void setGlobalTimeRange(TimeRange timeRange) {
+ this.globalTimeRange = timeRange;
+
+ for (IGlobalSelectionTRChangedListener listener : this.globalSelectionTRChangedListeners) {
+ listener.globalSelectionTRChanged(timeRange);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.raytheon.viz.gfe.core.ISpatialDisplayManager#getGlobalTimeRange()
+ */
+ @Override
+ public TimeRange getGlobalTimeRange() {
+ return this.globalTimeRange;
+ }
+
}
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/GFESpatialDisplayManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/GFESpatialDisplayManager.java
index 1fab7da2db..8f725b3865 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/GFESpatialDisplayManager.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/GFESpatialDisplayManager.java
@@ -19,24 +19,23 @@
**/
package com.raytheon.viz.gfe.core.internal;
+import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Date;
import java.util.HashSet;
-import java.util.Iterator;
+import java.util.List;
import java.util.Set;
import org.eclipse.swt.graphics.RGB;
-import org.eclipse.ui.IWorkbenchWindow;
import org.geotools.coverage.grid.GridGeometry2D;
import org.geotools.geometry.GeneralEnvelope;
import org.opengis.geometry.Envelope;
import com.raytheon.uf.common.dataplugin.gfe.db.objects.GridLocation;
import com.raytheon.uf.common.geospatial.MapUtil;
-import com.raytheon.uf.common.time.TimeRange;
+import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
-import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
+import com.raytheon.uf.viz.core.drawables.IDescriptor.IFrameChangedListener;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.MapDescriptor;
@@ -51,17 +50,13 @@ import com.raytheon.viz.gfe.core.DataManager;
import com.raytheon.viz.gfe.core.IParmManager;
import com.raytheon.viz.gfe.core.ISampleSetManager;
import com.raytheon.viz.gfe.core.msgs.IDisplayedParmListChangedListener;
-import com.raytheon.viz.gfe.core.msgs.IGlobalSelectionTRChangedListener;
-import com.raytheon.viz.gfe.core.msgs.IGridVisibilityChangedListener;
import com.raytheon.viz.gfe.core.msgs.ISampleSetChangedListener;
import com.raytheon.viz.gfe.core.msgs.ISpatialEditorTimeChangedListener;
import com.raytheon.viz.gfe.core.parm.Parm;
-import com.raytheon.viz.gfe.perspective.GFEPerspective;
import com.raytheon.viz.gfe.rsc.GFEReferenceSetResource;
import com.raytheon.viz.gfe.rsc.GFEResource;
import com.raytheon.viz.gfe.rsc.GFESystemResource;
import com.raytheon.viz.gfe.rsc.colorbar.GFEColorbarResource;
-import com.raytheon.viz.ui.UiUtil;
import com.raytheon.viz.ui.editor.AbstractEditor;
/**
@@ -85,31 +80,29 @@ import com.raytheon.viz.ui.editor.AbstractEditor;
*/
public class GFESpatialDisplayManager extends AbstractSpatialDisplayManager
- implements IDisplayedParmListChangedListener {
-
- private final IWorkbenchWindow window;
-
- private TimeRange globalTimeRange;
-
- private static final String GFE_PERSPECTIVE = GFEPerspective.ID_PERSPECTIVE;
+ implements IDisplayedParmListChangedListener, IFrameChangedListener {
private final ISampleSetChangedListener sampleSetListener = new ISampleSetChangedListener() {
- @Override
+ @Override
public void sampleSetChanged(ISampleSetManager sampleSetMgr) {
GFESpatialDisplayManager.this.refresh();
}
};
- private boolean isPopulated;
+ private boolean isRegistered;
public final static String GFE_STATUS_GROUP = "GFE_STATUS_GROUP";
private static final String WXD_SETTING = "WxDiscrete_Description";
- public GFESpatialDisplayManager(IWorkbenchWindow window, DataManager mgr) {
+ /**
+ * Editors managed by this display manager, use
+ * {@link #populate(AbstractEditor)} to add editor
+ */
+ private List managedEditors = new ArrayList();
+
+ public GFESpatialDisplayManager(DataManager mgr) {
super(mgr);
- this.window = window;
- this.globalTimeRange = new TimeRange(0, 0);
PythonPreferenceStore prefs = Activator.getDefault()
.getPreferenceStore();
boolean wxd_val = true;
@@ -132,12 +125,13 @@ public class GFESpatialDisplayManager extends AbstractSpatialDisplayManager
@Override
protected IDescriptor[] getDescriptors() {
- AbstractEditor[] editors = UiUtil.getEditors(window, GFE_PERSPECTIVE);
- IDescriptor[] descriptors = new IDescriptor[editors.length];
- for (int i = 0; i < editors.length; i++) {
- descriptors[i] = editors[i].getActiveDisplayPane().getDescriptor();
+ List descriptors = new ArrayList();
+ for (AbstractEditor editor : managedEditors) {
+ for (IDisplayPane pane : editor.getDisplayPanes()) {
+ descriptors.add(pane.getDescriptor());
+ }
}
- return descriptors;
+ return descriptors.toArray(new IDescriptor[descriptors.size()]);
}
/**
@@ -149,98 +143,107 @@ public class GFESpatialDisplayManager extends AbstractSpatialDisplayManager
*/
public void populate(AbstractEditor editor) throws VizException {
synchronized (this) {
- if (isPopulated) {
+ if (isRegistered == false) {
+ // First time called, register listeners
+ this.dataManager.getParmManager()
+ .addDisplayedParmListChangedListener(this);
+ this.dataManager.getSampleSetManager()
+ .addSampleSetChangedListener(sampleSetListener);
+ isRegistered = true;
+ }
+
+ if (managedEditors.contains(editor)) {
+ // Editor already managed
return;
}
IParmManager parmManager = this.dataManager.getParmManager();
- parmManager.addDisplayedParmListChangedListener(this);
-
Parm[] parms = parmManager.getDisplayedParms();
-
- IDisplayPane pane = editor.getActiveDisplayPane();
- MapDescriptor descriptor = (MapDescriptor) pane.getDescriptor();
-
- GridLocation gloc = parmManager.compositeGridLocation();
- GridGeometry2D gridGeometry = MapUtil.getGridGeometry(gloc);
- Envelope envelope = gridGeometry.getEnvelope();
- double colorBarHeight = GFEColorbarResource.HEIGHT
- * envelope.getSpan(1) / pane.getBounds().height;
-
- PythonPreferenceStore prefs = Activator.getDefault()
- .getPreferenceStore();
-
- double expandLeft = 10;
- if (prefs.contains("OfficeDomain_expandLeft")) {
- expandLeft = prefs.getDouble("OfficeDomain_expandLeft");
- }
- double expandRight = 0.1;
- if (prefs.contains("OfficeDomain_expandRight")) {
- expandRight = prefs.getDouble("OfficeDomain_expandRight");
- }
- double expandTop = 0.1;
- if (prefs.contains("OfficeDomain_expandTop")) {
- expandTop = prefs.getDouble("OfficeDomain_expandTop");
- }
- double expandBottom = 0.1;
- if (prefs.contains("OfficeDomain_expandBottom")) {
- expandBottom = prefs.getDouble("OfficeDomain_expandBottom");
- }
-
- double dxLeft = (envelope.getSpan(0) * expandLeft / 100.0);
- double dxRight = (envelope.getSpan(0) * expandRight / 100.0);
- double dyTop = (envelope.getSpan(1) * expandTop / 100.0);
- double dyBottom = (envelope.getSpan(1) * expandBottom / 100.0);
-
- GeneralEnvelope newEnvelope = new GeneralEnvelope(
- envelope.getCoordinateReferenceSystem());
- newEnvelope.setRange(0, envelope.getMinimum(0) - dxLeft,
- envelope.getMaximum(0) + dxRight);
- newEnvelope.setRange(1, envelope.getMinimum(1) - dyBottom,
- envelope.getMaximum(1) + colorBarHeight + dyTop);
- GridGeometry2D newGridGeometry = new GridGeometry2D(
- gridGeometry.getGridRange(), newEnvelope);
- descriptor.setGridGeometry(newGridGeometry);
- pane.getRenderableDisplay().scaleToClientArea(pane.getBounds());
-
- // Stop any looping
- editor.getLoopProperties().setLooping(false);
-
- // Construct a new gfe time match resource which is used to help
- // establish gfe time matching
- GFESystemResource basis = new GFESystemResource(this.dataManager);
- basis.setDescriptor(descriptor);
- descriptor.getResourceList().add(basis);
- descriptor.getResourceList().getProperties(basis)
- .setSystemResource(true);
- descriptor.setNumberOfFrames(Integer.MAX_VALUE);
-
- // create the gfe color bar
- GFEColorbarResource colorBar = new GFEColorbarResource(
- this.dataManager);
- colorBar.setDescriptor(descriptor);
- descriptor.getResourceList().add(colorBar);
- descriptor.getResourceList().getProperties(colorBar)
- .setSystemResource(true);
-
- // create the gfe reference set
- GFEReferenceSetResource refSetRsc = new GFEReferenceSetResource(
- this.dataManager.getRefManager());
- refSetRsc.setDescriptor(descriptor);
- descriptor.getResourceList().add(refSetRsc);
- descriptor.getResourceList().getProperties(refSetRsc)
- .setSystemResource(true);
-
Arrays.sort(parms);
- for (int i = parms.length - 1; i >= 0; i--) {
- createResourceFromParm(descriptor, parms[i], false);
+ for (IDisplayPane pane : editor.getDisplayPanes()) {
+ MapDescriptor descriptor = (MapDescriptor) pane.getDescriptor();
+ descriptor.addFrameChangedListener(this);
+
+ GridLocation gloc = parmManager.compositeGridLocation();
+ GridGeometry2D gridGeometry = MapUtil.getGridGeometry(gloc);
+ Envelope envelope = gridGeometry.getEnvelope();
+ double colorBarHeight = GFEColorbarResource.HEIGHT
+ * envelope.getSpan(1) / pane.getBounds().height;
+
+ PythonPreferenceStore prefs = Activator.getDefault()
+ .getPreferenceStore();
+
+ double expandLeft = 10;
+ if (prefs.contains("OfficeDomain_expandLeft")) {
+ expandLeft = prefs.getDouble("OfficeDomain_expandLeft");
+ }
+ double expandRight = 0.1;
+ if (prefs.contains("OfficeDomain_expandRight")) {
+ expandRight = prefs.getDouble("OfficeDomain_expandRight");
+ }
+ double expandTop = 0.1;
+ if (prefs.contains("OfficeDomain_expandTop")) {
+ expandTop = prefs.getDouble("OfficeDomain_expandTop");
+ }
+ double expandBottom = 0.1;
+ if (prefs.contains("OfficeDomain_expandBottom")) {
+ expandBottom = prefs.getDouble("OfficeDomain_expandBottom");
+ }
+
+ double dxLeft = (envelope.getSpan(0) * expandLeft / 100.0);
+ double dxRight = (envelope.getSpan(0) * expandRight / 100.0);
+ double dyTop = (envelope.getSpan(1) * expandTop / 100.0);
+ double dyBottom = (envelope.getSpan(1) * expandBottom / 100.0);
+
+ GeneralEnvelope newEnvelope = new GeneralEnvelope(
+ envelope.getCoordinateReferenceSystem());
+ newEnvelope.setRange(0, envelope.getMinimum(0) - dxLeft,
+ envelope.getMaximum(0) + dxRight);
+ newEnvelope.setRange(1, envelope.getMinimum(1) - dyBottom,
+ envelope.getMaximum(1) + colorBarHeight + dyTop);
+ GridGeometry2D newGridGeometry = new GridGeometry2D(
+ gridGeometry.getGridRange(), newEnvelope);
+ descriptor.setGridGeometry(newGridGeometry);
+ pane.getRenderableDisplay().scaleToClientArea(pane.getBounds());
+
+ // Stop any looping
+ editor.getLoopProperties().setLooping(false);
+
+ // Construct a new gfe time match resource which is used to help
+ // establish gfe time matching
+ GFESystemResource basis = new GFESystemResource(
+ this.dataManager);
+ basis.setDescriptor(descriptor);
+ descriptor.getResourceList().add(basis);
+ descriptor.getResourceList().getProperties(basis)
+ .setSystemResource(true);
+ descriptor.setNumberOfFrames(Integer.MAX_VALUE);
+
+ // create the gfe color bar
+ GFEColorbarResource colorBar = new GFEColorbarResource(
+ this.dataManager);
+ colorBar.setDescriptor(descriptor);
+ descriptor.getResourceList().add(colorBar);
+ descriptor.getResourceList().getProperties(colorBar)
+ .setSystemResource(true);
+
+ // create the gfe reference set
+ GFEReferenceSetResource refSetRsc = new GFEReferenceSetResource(
+ this.dataManager.getRefManager());
+ refSetRsc.setDescriptor(descriptor);
+ descriptor.getResourceList().add(refSetRsc);
+ descriptor.getResourceList().getProperties(refSetRsc)
+ .setSystemResource(true);
+
+ for (int i = parms.length - 1; i >= 0; i--) {
+ createResourceFromParm(descriptor, parms[i], false);
+ }
+
+ setSpatialEditorTime(descriptor, getSpatialEditorTime());
}
- this.dataManager.getSampleSetManager().addSampleSetChangedListener(
- sampleSetListener);
-
- this.isPopulated = true;
+ managedEditors.add(editor);
}
}
@@ -315,59 +318,16 @@ public class GFESpatialDisplayManager extends AbstractSpatialDisplayManager
*
* @throws VizException
*/
- public void depopulate() throws VizException {
+ public void dispose() throws VizException {
synchronized (this) {
- this.dataManager.getSampleSetManager()
- .removeSampleSetChangedListener(sampleSetListener);
- this.dataManager.getParmManager()
- .removeDisplayedParmListChangedListener(this);
- this.isPopulated = false;
+ if (isRegistered) {
+ this.dataManager.getSampleSetManager()
+ .removeSampleSetChangedListener(sampleSetListener);
+ this.dataManager.getParmManager()
+ .removeDisplayedParmListChangedListener(this);
+ isRegistered = false;
+ }
}
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.raytheon.viz.gfe.core.ISpatialDisplayManager#setSpatialEditorTime
- * (java.util.Date)
- */
- @Override
- public void setSpatialEditorTime(Date date) {
- super.setSpatialEditorTime(date);
-
- for (ISpatialEditorTimeChangedListener listener : spatialEditorTimeChangedListeners) {
- listener.spatialEditorTimeChanged(date);
- }
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.raytheon.viz.gfe.core.ISpatialDisplayManager#setGlobalTimeRange(com
- * .raytheon.edex.plugin.time.TimeRange)
- */
- @Override
- public void setGlobalTimeRange(TimeRange timeRange) {
- this.globalTimeRange = timeRange;
-
- for (IGlobalSelectionTRChangedListener listener : this.globalSelectionTRChangedListeners) {
- listener.globalSelectionTRChanged(timeRange);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.raytheon.viz.gfe.core.ISpatialDisplayManager#getGlobalTimeRange()
- */
- @Override
- public TimeRange getGlobalTimeRange() {
- return this.globalTimeRange;
}
/*
@@ -376,84 +336,53 @@ public class GFESpatialDisplayManager extends AbstractSpatialDisplayManager
* @see com.raytheon.viz.gfe.core.ISpatialDisplayManager#refresh()
*/
private void refresh() {
- for (AbstractEditor editor : UiUtil.getEditors(window, GFE_PERSPECTIVE)) {
- editor.refresh();
+ for (IDescriptor desc : getDescriptors()) {
+ if (desc.getRenderableDisplay() != null) {
+ desc.getRenderableDisplay().refresh();
+ }
}
}
@Override
public void displayedParmListChanged(Parm[] parms, Parm[] deletions,
Parm[] additions) {
-
- AbstractEditor[] editors = UiUtil.getEditors(window, GFE_PERSPECTIVE);
- for (AbstractEditor e : editors) {
- IRenderableDisplay disp = e.getActiveDisplayPane()
- .getRenderableDisplay();
- IDescriptor descriptor = disp.getDescriptor();
-
- // put parms to delete in set for easy look up
- Set parmsToDelete = new HashSet();
- for (Parm p : deletions) {
- parmsToDelete.add(p);
- }
-
- for (ResourcePair rp : descriptor.getResourceList()) {
- AbstractVizResource, ?> rsc = rp.getResource();
- if (rsc instanceof GFEResource) {
- GFEResource gfeRsc = (GFEResource) rsc;
-
- if (parmsToDelete.contains(gfeRsc.getParm())) {
- descriptor.getResourceList().remove(rp);
- }
+ Set toDelete = new HashSet(Arrays.asList(deletions));
+ for (IDescriptor desc : getDescriptors()) {
+ ResourceList list = desc.getResourceList();
+ List rscs = list
+ .getResourcesByTypeAsType(GFEResource.class);
+ for (GFEResource rsc : rscs) {
+ if (toDelete.contains(rsc.getParm())) {
+ list.removeRsc(rsc);
}
}
for (Parm addParm : additions) {
- createResourceFromParm(descriptor, addParm, false);
+ createResourceFromParm(desc, addParm, false);
}
}
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * com.raytheon.uf.viz.core.drawables.IDescriptor.IFrameChangedListener#
+ * frameChanged(com.raytheon.uf.viz.core.drawables.IDescriptor,
+ * com.raytheon.uf.common.time.DataTime,
+ * com.raytheon.uf.common.time.DataTime)
+ */
@Override
- public void toggleVisibility(Parm parm) {
- AbstractEditor[] editors = UiUtil.getEditors(window, GFE_PERSPECTIVE);
- if (editors.length == 0) {
- return;
+ public void frameChanged(IDescriptor descriptor, DataTime oldTime,
+ DataTime newTime) {
+ if (newTime != null && oldTime != null && seTime != null
+ && oldTime.getRefTime().equals(seTime)) {
+ // time was set to seTime, frame changed, set seTime to null
+ setSpatialEditorTime(null);
}
-
- for (AbstractEditor editor : editors) {
- IDescriptor descriptor = editor.getActiveDisplayPane()
- .getDescriptor();
- boolean needRefresh = false;
-
- ResourceList resourceList = descriptor.getResourceList();
- synchronized (resourceList) {
- Iterator iterator = resourceList.iterator();
-
- while (iterator.hasNext()) {
- ResourcePair resourcePair = iterator.next();
- AbstractVizResource, ?> rsc = resourcePair.getResource();
- if (rsc instanceof GFEResource) {
- Parm p = ((GFEResource) rsc).getParm();
- if (p.equals(parm)) {
- ResourceProperties props = resourcePair
- .getProperties();
- boolean visible = !props.isVisible();
- props.setVisible(visible);
- needRefresh = true;
-
- for (IGridVisibilityChangedListener listener : gridVisibilityChangedListeners) {
- listener.gridVisibilityChanged(p, visible,
- false);
- }
- }
- }
- }
- }
-
- if (needRefresh) {
- editor.refresh();
- }
+ for (ISpatialEditorTimeChangedListener subListener : spatialEditorTimeChangedListeners) {
+ subListener.spatialEditorTimeChanged(newTime != null ? newTime
+ .getRefTime() : null);
}
}
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/OffscreenSpatialDisplayManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/OffscreenSpatialDisplayManager.java
index 16137c49ff..3fb03eefd6 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/OffscreenSpatialDisplayManager.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/internal/OffscreenSpatialDisplayManager.java
@@ -19,12 +19,9 @@
**/
package com.raytheon.viz.gfe.core.internal;
-import org.eclipse.ui.IWorkbenchWindow;
-
-import com.raytheon.uf.common.time.TimeRange;
-import com.raytheon.uf.viz.core.map.MapDescriptor;
+import com.raytheon.uf.viz.core.drawables.IDescriptor;
+import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
import com.raytheon.viz.gfe.core.DataManager;
-import com.raytheon.viz.gfe.core.parm.Parm;
/**
* Spatial display manager for working offscreen without a display, i.e. with
@@ -46,58 +43,17 @@ import com.raytheon.viz.gfe.core.parm.Parm;
public class OffscreenSpatialDisplayManager extends
AbstractSpatialDisplayManager {
- private MapDescriptor descriptor;
+ private IRenderableDisplay display;
- public OffscreenSpatialDisplayManager(IWorkbenchWindow window,
+ public OffscreenSpatialDisplayManager(IRenderableDisplay display,
DataManager mgr) {
super(mgr);
+ this.display = display;
}
@Override
- protected MapDescriptor[] getDescriptors() {
- return new MapDescriptor[] { descriptor };
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.raytheon.viz.gfe.core.ISpatialDisplayManager#getGlobalTimeRange()
- */
- @Override
- public TimeRange getGlobalTimeRange() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.raytheon.viz.gfe.core.ISpatialDisplayManager#toggleVisibility(com
- * .raytheon .viz.gfe.core.parm.Parm)
- */
- @Override
- public void toggleVisibility(Parm parm) {
- // TODO Auto-generated method stub
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.raytheon.viz.gfe.core.ISpatialDisplayManager#setGlobalTimeRange(com
- * .raytheon.uf.common.time.TimeRange)
- */
- @Override
- public void setGlobalTimeRange(TimeRange timeRange) {
- // TODO Auto-generated method stub
-
- }
-
- public void setDescriptor(MapDescriptor desc) {
- descriptor = desc;
+ protected IDescriptor[] getDescriptors() {
+ return new IDescriptor[] { display.getDescriptor() };
}
}
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/msgs/ICurrentDataManagerChangedListener.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/msgs/ICurrentDataManagerChangedListener.java
deleted file mode 100644
index bb110ce333..0000000000
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/core/msgs/ICurrentDataManagerChangedListener.java
+++ /dev/null
@@ -1,42 +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.gfe.core.msgs;
-
-/**
- *
- * Defines a listener that is called when the current datamanager changes
- *
- *
- * SOFTWARE HISTORY
- * Date Ticket# Engineer Description
- * ------------ ---------- ----------- --------------------------
- * 03/12/2008 chammack Initial Creation.
- *
- *
- *
- * @author chammack
- * @version 1.0
- */
-
-public interface ICurrentDataManagerChangedListener {
-
- public void currentDataManagerChanged(
- com.raytheon.viz.gfe.core.DataManager newDataManager);
-}
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/gridmanager/GridBar.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/gridmanager/GridBar.java
index 558e5f1cbb..f738e338d8 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/gridmanager/GridBar.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/gridmanager/GridBar.java
@@ -1469,7 +1469,6 @@ public class GridBar implements IMessageClient, IParmInventoryChangedListener,
@Override
public void parmInventoryChanged(Parm parm, TimeRange timeRange) {
// System.out.println("parmInventoryChanged for " + this);
- canvas.calcStepTimes();
if (this.parm.equals(parm)
&& this.gridManager.checkVisibility(timeRange)) {
redraw();
@@ -1510,7 +1509,6 @@ public class GridBar implements IMessageClient, IParmInventoryChangedListener,
if (desiredVisiblity != parmVisible) {
parmVisible = desiredVisiblity;
// System.out.println("gridVisibilityChanged for " + this);
- canvas.calcStepTimes();
redraw();
}
}
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/gridmanager/GridCanvas.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/gridmanager/GridCanvas.java
index 9aa7856b45..fb3813d64f 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/gridmanager/GridCanvas.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/gridmanager/GridCanvas.java
@@ -272,8 +272,6 @@ public class GridCanvas extends Canvas implements IMessageClient {
private int separatorPosition = 0;
- private List stepTimes;
-
private boolean quickviewMode;
private GridID quickviewGrid;
@@ -736,8 +734,6 @@ public class GridCanvas extends Canvas implements IMessageClient {
}
}
- calcStepTimes();
-
resize();
}
@@ -908,96 +904,6 @@ public class GridCanvas extends Canvas implements IMessageClient {
}
}
- public void nextSelectedGrid() {
- Date seTime = gridManager.getSelectedTime();
- Date time = null;
- for (Date stepTime : stepTimes) {
- if (seTime.before(stepTime)) {
- time = stepTime;
- break;
- }
- }
-
- if (time == null && stepTimes.size() > 0) {
- time = stepTimes.get(0);
- }
-
- if (time != null) {
- gridManager.setSelectedTime(time);
- gridManager.syncSelectTR(time);
- }
- }
-
- public void previousSelectedGrid() {
-
- Date seTime = gridManager.getSelectedTime();
- Date time = null;
- for (int i = stepTimes.size() - 1; i >= 0; i--) {
- Date stepTime = stepTimes.get(i);
- if (seTime.after(stepTime)) {
- time = stepTime;
- break;
- }
- }
-
- if (time == null && stepTimes.size() > 0) {
- time = stepTimes.get(stepTimes.size() - 1);
- }
-
- if (time != null) {
- gridManager.setSelectedTime(time);
- gridManager.syncSelectTR(time);
- }
-
- return;
- }
-
- public void firstSelectedGrid() {
- Date time = null;
-
- if (time == null && stepTimes.size() > 0) {
- time = stepTimes.get(0);
- }
-
- if (time != null) {
- gridManager.setSelectedTime(time);
- gridManager.syncSelectTR(time);
- }
- }
-
- public void lastSelectedGrid() {
- Date time = null;
-
- if (time == null && stepTimes.size() > 0) {
- time = stepTimes.get(stepTimes.size() - 1);
- }
-
- if (time != null) {
- gridManager.setSelectedTime(time);
- gridManager.syncSelectTR(time);
- }
- }
-
- public void calcStepTimes() {
- ArrayList parms = new ArrayList();
- for (GridBar gridBar : gridBarList) {
- if (gridBar.isParmVisible()) {
- Parm p = gridBar.getParm();
- if (!parms.contains(p)) {
- parms.add(p);
- }
-
- // TODO ISC?
- // p = view.iscGridID().parm();
- // if (!parms.contains(p)) {
- // parms.add(p);
- // }
- }
- }
- stepTimes = dataMgr.getParmManager().calcStepTimes(parms,
- new TimeRange());
- }
-
/**
* @param e
*/
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/gridmanager/GridManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/gridmanager/GridManager.java
index 1daf497a0d..efd3ea9c45 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/gridmanager/GridManager.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/gridmanager/GridManager.java
@@ -52,6 +52,7 @@ import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.viz.gfe.Activator;
import com.raytheon.viz.gfe.core.DataManager;
import com.raytheon.viz.gfe.core.griddata.IGridData;
+import com.raytheon.viz.gfe.core.msgs.ISpatialEditorTimeChangedListener;
import com.raytheon.viz.gfe.core.msgs.ISystemTimeRangeChangedListener;
import com.raytheon.viz.gfe.core.parm.Parm;
import com.raytheon.viz.gfe.edittool.GridID;
@@ -73,7 +74,8 @@ import com.raytheon.viz.gfe.temporaleditor.TemporalEditor;
* @version 1.0
*/
-public class GridManager implements IGridManager {
+public class GridManager implements IGridManager,
+ ISpatialEditorTimeChangedListener {
/**
* Job to scroll the grid manager horizontally
*/
@@ -234,15 +236,6 @@ public class GridManager implements IGridManager {
private ScrolledComposite teScrolledComp;
- private Date selectedTime;
-
- /**
- * @return the selectedTime
- */
- public Date getSelectedTime() {
- return selectedTime;
- }
-
private DataManager dataManager;
private int widthIncrement;
@@ -554,6 +547,9 @@ public class GridManager implements IGridManager {
if (updateJob.getState() == Job.NONE) {
updateJob.schedule();
}
+
+ dataManager.getSpatialDisplayManager()
+ .addSpatialEditorTimeChangedListener(this);
}
public TimeRange getVisibleTimeRange() {
@@ -652,26 +648,6 @@ public class GridManager implements IGridManager {
}
}
- @Override
- public void nextSelectedGrid() {
- gridCanvas.nextSelectedGrid();
- }
-
- @Override
- public void previousSelectedGrid() {
- gridCanvas.previousSelectedGrid();
- }
-
- @Override
- public void firstSelectedGrid() {
- gridCanvas.firstSelectedGrid();
- }
-
- @Override
- public void lastSelectedGrid() {
- gridCanvas.lastSelectedGrid();
- }
-
protected void startScrolling(int i) {
scrollJob.setIncrement(i);
scrollJob.schedule();
@@ -751,12 +727,18 @@ public class GridManager implements IGridManager {
@Override
public void setSelectedTime(Date selectedTime) {
- this.selectedTime = selectedTime;
dataManager.getSpatialDisplayManager().setSpatialEditorTime(
selectedTime);
redraw();
}
+ /**
+ * @return the selectedTime
+ */
+ public Date getSelectedTime() {
+ return dataManager.getSpatialDisplayManager().getSpatialEditorTime();
+ }
+
protected void syncSelectTR(Date t) {
// Use a selection tr of 1 hour duration if no active parm,
// if active parm and no grid, use the parm's time constraint,
@@ -809,4 +791,16 @@ public class GridManager implements IGridManager {
service.refreshElements(
"com.raytheon.viz.gfe.actions.SelectGridsWhenStepping", null);
}
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.raytheon.viz.gfe.core.msgs.ISpatialEditorTimeChangedListener#
+ * spatialEditorTimeChanged(java.util.Date)
+ */
+ @Override
+ public void spatialEditorTimeChanged(Date date) {
+ syncSelectTR(date);
+ redraw();
+ }
}
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/gridmanager/IGridManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/gridmanager/IGridManager.java
index 81fdc4969f..2e8c77fa47 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/gridmanager/IGridManager.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/gridmanager/IGridManager.java
@@ -59,32 +59,6 @@ public interface IGridManager {
*/
public void contractTimeScale();
- /**
- * Moves the selected grid to the next selected grid or if at the end of the
- * list selects the first grid in the list.
- *
- */
- public void nextSelectedGrid();
-
- /**
- * Moves the selected grid to the previous selected grid or if at the
- * beginning of the list selects the last grid in the list.
- *
- */
- public void previousSelectedGrid();
-
- /**
- * Moves the selected grid to the first selected grid.
- *
- */
- public void firstSelectedGrid();
-
- /**
- * Moves the selected grid to the last selected grid.
- *
- */
- public void lastSelectedGrid();
-
/**
* Paints the TimeScale and all of the GridBars.
*/
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/gridmanager/action/GFEFrameTool.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/gridmanager/action/GFEFrameTool.java
deleted file mode 100644
index da1b8157a8..0000000000
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/gridmanager/action/GFEFrameTool.java
+++ /dev/null
@@ -1,86 +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.gfe.gridmanager.action;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-
-import com.raytheon.uf.viz.core.drawables.IFrameCoordinator.FrameChangeOperation;
-import com.raytheon.viz.gfe.core.DataManager;
-import com.raytheon.viz.gfe.gridmanager.IGridManager;
-import com.raytheon.viz.ui.tools.AbstractTool;
-
-/**
- * Implements the frame tool events for GFE
- *
- * GFE only defines single step frame operations in forward and reverse, the
- * rest of the operations are no-op.
- *
- *
- * SOFTWARE HISTORY
- * Date Ticket# Engineer Description
- * ------------ ---------- ----------- --------------------------
- * 03/26/2008 chammack Initial Creation.
- *
- *
- *
- * @author chammack
- * @version 1.0
- */
-
-public class GFEFrameTool extends AbstractTool {
- /*
- * (non-Javadoc)
- *
- * @see
- * com.raytheon.viz.ui.tools.AbstractTool#execute(org.eclipse.core.commands
- * .ExecutionEvent)
- */
- @Override
- public Object execute(ExecutionEvent arg0) throws ExecutionException {
-
- String operationStr = arg0.getParameter("operation");
- FrameChangeOperation operation = FrameChangeOperation
- .valueOf(operationStr);
-
- IGridManager gm = DataManager.getCurrentInstance().getGridManager();
-
- switch (operation) {
- case PREVIOUS:
- gm.previousSelectedGrid();
- break;
- case NEXT:
- gm.nextSelectedGrid();
- break;
- case FIRST:
- gm.firstSelectedGrid();
- break;
- case LAST:
- gm.lastSelectedGrid();
- break;
- }
-
- gm.redraw();
-
- return null;
-
- }
-
-}
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ifpimage/ImageLegendResource.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ifpimage/ImageLegendResource.java
index b6d756aeae..9ef5676f0c 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ifpimage/ImageLegendResource.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/ifpimage/ImageLegendResource.java
@@ -21,7 +21,7 @@ package com.raytheon.viz.gfe.ifpimage;
import java.util.ArrayList;
import java.util.Calendar;
-import java.util.Date;
+import java.util.Collection;
import java.util.Formatter;
import java.util.HashMap;
import java.util.List;
@@ -35,6 +35,7 @@ import com.raytheon.uf.common.time.DataTime;
import com.raytheon.uf.common.time.TimeRange;
import com.raytheon.uf.viz.core.RGBColors;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
+import com.raytheon.uf.viz.core.drawables.IDescriptor.FramesInfo;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.rsc.ResourceProperties;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability;
@@ -99,13 +100,9 @@ public class ImageLegendResource extends GFELegendResource {
@Override
public LegendEntry[] getLegendData(IDescriptor descriptor) {
- Date date = this.dataManager.getSpatialDisplayManager()
- .getSpatialEditorTime();
- DataTime dt = new DataTime(date);
-
- Parm[] parms = orderParms(descriptor);
-
- LegendData[] data = makeLegend(parms, dt);
+ Map parmRscMap = new HashMap();
+ Collection parms = getLegendOrderedParms(descriptor, parmRscMap);
+ LegendData[] data = makeLegend(parms, parmRscMap);
LegendEntry[] entries = new LegendEntry[data.length];
for (int i = 0; i < entries.length; ++i) {
@@ -116,18 +113,23 @@ public class ImageLegendResource extends GFELegendResource {
return entries;
}
- private LegendData[] makeLegend(Parm[] parms, DataTime curTime) {
+ private LegendData[] makeLegend(Collection parms,
+ Map parmRscMap) {
+ FramesInfo currInfo = descriptor.getFramesInfo();
+ DataTime curTime = currInfo.getCurrentFrame();
+
// loop through the grids
List legendData = new ArrayList();
- for (int i = parms.length - 1; i >= 0; i--) {
- Parm parm = parms[i];
- String parmName = parm.getParmID().getParmName();
- ResourcePair rp = this.parmToRscMap.get(parm);
+ for (Parm parm : parms) {
+ ResourcePair rp = parmRscMap.get(parm);
GFEResource rsc = (GFEResource) rp.getResource();
+ String parmName = parm.getParmID().getParmName();
ResourceProperties props = rp.getProperties();
LegendData data = new LegendData();
data.resource = rp;
+ DataTime curRscTime = currInfo.getTimeForResource(rsc);
+
// color for the text
if ((props.isVisible())
&& (parm.getDisplayAttributes().getVisMode() == VisMode.IMAGE)) {
@@ -175,36 +177,32 @@ public class ImageLegendResource extends GFELegendResource {
snap.setTimeZone(TimeZone.getTimeZone(tz));
formatter.format(snapshotFormat.replaceAll("\\%", "%1\\$t"),
snap);
- } else {
- // get the valid time for the grid, get the time format
- gd = rsc.getParm().getGridInventory(curTime.getValidPeriod());
- if (gd.length > 0) {
- TimeRange tr = gd[0].getGridTime();
- if (durationFormat != null) {
- timeString += durationString(tr);
- }
- if (startFormat != null) {
- Calendar start = Calendar.getInstance();
- start.setTimeZone(TimeZone.getTimeZone(tz));
- start.setTime(tr.getStart());
- formatter.format(
- startFormat.replaceAll("\\%", "%1\\$t"), start);
- }
- if (endFormat != null) {
- Calendar end = Calendar.getInstance();
- end.setTimeZone(TimeZone.getTimeZone(tz));
- end.setTime(tr.getEnd());
- formatter.format(endFormat.replaceAll("\\%", "%1\\$t"),
- end);
- }
-
+ } else if (curRscTime != null) {
+ TimeRange tr = curRscTime.getValidPeriod();
+ if (durationFormat != null) {
+ timeString += durationString(tr);
}
+ if (startFormat != null) {
+ Calendar start = Calendar.getInstance();
+ start.setTimeZone(TimeZone.getTimeZone(tz));
+ start.setTime(tr.getStart());
+ formatter.format(startFormat.replaceAll("\\%", "%1\\$t"),
+ start);
+ }
+ if (endFormat != null) {
+ Calendar end = Calendar.getInstance();
+ end.setTimeZone(TimeZone.getTimeZone(tz));
+ end.setTime(tr.getEnd());
+ formatter
+ .format(endFormat.replaceAll("\\%", "%1\\$t"), end);
+ }
+
}
timeString += formatter.toString();
timeString = timeString.replaceAll("\\[UNITS\\]", units);
- if (snapshotTime || gd.length > 0) {
+ if (snapshotTime || curRscTime != null) {
// now prefix the parameter name
String name = null;
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/perspective/GFEPerspectiveManager.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/perspective/GFEPerspectiveManager.java
index 712f93f141..9902f4f472 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/perspective/GFEPerspectiveManager.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/perspective/GFEPerspectiveManager.java
@@ -46,8 +46,6 @@ import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.IDisplayPane;
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
-import com.raytheon.uf.viz.core.IExtent;
-import com.raytheon.uf.viz.core.PixelExtent;
import com.raytheon.uf.viz.core.RGBColors;
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
@@ -58,6 +56,7 @@ import com.raytheon.viz.gfe.Activator;
import com.raytheon.viz.gfe.PythonPreferenceStore;
import com.raytheon.viz.gfe.actions.FormatterlauncherAction;
import com.raytheon.viz.gfe.core.DataManager;
+import com.raytheon.viz.gfe.core.DataManagerUIFactory;
import com.raytheon.viz.gfe.core.GFEMapRenderableDisplay;
import com.raytheon.viz.gfe.core.ISpatialDisplayManager;
import com.raytheon.viz.gfe.core.internal.GFESpatialDisplayManager;
@@ -144,7 +143,7 @@ public class GFEPerspectiveManager extends AbstractCAVEPerspectiveManager {
keybindingsCreated = true;
}
- DataManager dm = DataManager.getInstance(perspectiveWindow);
+ DataManager dm = DataManagerUIFactory.getInstance(perspectiveWindow);
IRenderableDisplay display = pane.getRenderableDisplay();
if (display instanceof GFEMapRenderableDisplay) {
((GFEMapRenderableDisplay) display).setDataManager(dm);
@@ -176,16 +175,12 @@ public class GFEPerspectiveManager extends AbstractCAVEPerspectiveManager {
+ GFESpatialDisplayManager.class.getName());
}
}
-
- DataManager.fireChangeListener();
}
@Override
public void activate() {
super.activate();
- DataManager.fireChangeListener();
-
// Hack to disable editor closing
IWorkbenchPage activePage = perspectiveWindow.getActivePage();
if (activePage != null) {
@@ -220,11 +215,12 @@ public class GFEPerspectiveManager extends AbstractCAVEPerspectiveManager {
super.close();
try {
- DataManager dm = DataManager.findInstance(perspectiveWindow);
+ DataManager dm = DataManagerUIFactory
+ .findInstance(perspectiveWindow);
if (dm != null) {
ISpatialDisplayManager mgr = dm.getSpatialDisplayManager();
if (mgr instanceof GFESpatialDisplayManager) {
- ((GFESpatialDisplayManager) mgr).depopulate();
+ ((GFESpatialDisplayManager) mgr).dispose();
} else {
throw new IllegalStateException(this.getClass().getName()
+ " must be used with "
@@ -237,7 +233,7 @@ public class GFEPerspectiveManager extends AbstractCAVEPerspectiveManager {
e);
}
- DataManager.dispose(perspectiveWindow);
+ DataManagerUIFactory.dispose(perspectiveWindow);
// Put on own thread so close is not slowed down.
new Thread(new Runnable() {
@@ -408,30 +404,6 @@ public class GFEPerspectiveManager extends AbstractCAVEPerspectiveManager {
public void addContextMenuItems(IMenuManager menuManager,
IDisplayPaneContainer container, IDisplayPane pane) {
super.addContextMenuItems(menuManager, container, pane);
-
- DataManager dataManager = DataManager.getCurrentInstance();
- if (dataManager != null) {
- // Don't add menu items for the resource if mouse is in the colorbar
-
- // code for corrected mouse X and Y copied from
- // GFEColorbarResource
- IDisplayPane displayPane = container.getActiveDisplayPane();
- int x = displayPane.getLastClickX();
- int y = displayPane.getLastClickY();
- org.eclipse.swt.graphics.Rectangle bounds = displayPane.getBounds();
- IExtent extent = displayPane.getRenderableDisplay().getExtent();
- double correctedX = x * (extent.getMaxX() - extent.getMinX())
- / bounds.width + extent.getMinX();
- double correctedY = y * (extent.getMaxY() - extent.getMinY())
- / bounds.height + extent.getMinY();
-
- PixelExtent colorBarExtent = dataManager.getSpatialDisplayManager()
- .getColorbarExtent();
- if (colorBarExtent != null
- && colorBarExtent.contains(correctedX, correctedY)) {
- return;
- }
- }
menuManager.add(new ZoomMenuAction(container));
}
}
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFELegendResource.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFELegendResource.java
index 8a6fd10cb1..ce10249422 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFELegendResource.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFELegendResource.java
@@ -21,24 +21,22 @@ package com.raytheon.viz.gfe.rsc;
import static com.raytheon.viz.gfe.core.parm.ParmDisplayAttributes.VisMode.IMAGE;
-import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
import java.util.Date;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
-import java.util.WeakHashMap;
import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.common.dataplugin.gfe.db.objects.DatabaseID;
import com.raytheon.uf.common.dataplugin.gfe.db.objects.ParmID;
-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;
@@ -48,6 +46,7 @@ import com.raytheon.uf.viz.core.IDisplayPaneContainer;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.RGBColors;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
+import com.raytheon.uf.viz.core.drawables.IDescriptor.FramesInfo;
import com.raytheon.uf.viz.core.drawables.IFont;
import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.exception.VizException;
@@ -74,9 +73,9 @@ import com.raytheon.viz.gfe.edittool.GridID;
import com.raytheon.viz.ui.input.InputAdapter;
/**
- *
+ *
* Port of SELegendVisual from AWIPS I GFE
- *
+ *
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
@@ -85,7 +84,7 @@ import com.raytheon.viz.ui.input.InputAdapter;
* 08/19/2009 2547 rjpeter Implement Test/Prac database display.
* 07/10/2012 15186 ryu Clean up initInternal per Ron
*
- *
+ *
* @author chammack
* @version 1.0
*/
@@ -107,7 +106,7 @@ public class GFELegendResource extends
/*
* (non-Javadoc)
- *
+ *
* @see java.lang.Enum#toString()
*/
@Override
@@ -222,8 +221,6 @@ public class GFELegendResource extends
protected IGraphicsTarget lastTarget;
- protected Map parmToRscMap;
-
private GridID qvGrid;
private IInputHandler handler = new GFELegendInputHandler();
@@ -252,7 +249,6 @@ public class GFELegendResource extends
resourceDateFormat = new SimpleDateFormat("E HH'Z' dd-MMM-yy");
resourceDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
this.dataManager = dataManager;
- parmToRscMap = new WeakHashMap();
String s = Activator.getDefault().getPreferenceStore()
.getString("LegendMode");
@@ -273,7 +269,7 @@ public class GFELegendResource extends
/*
* (non-Javadoc)
- *
+ *
* @see java.lang.Object#finalize()
*/
@SuppressWarnings("unchecked")
@@ -290,7 +286,7 @@ public class GFELegendResource extends
/*
* (non-Javadoc)
- *
+ *
* @see
* com.raytheon.viz.core.legend.ILegendDecorator#getLegendData(com.raytheon
* .viz.core.drawables.IDescriptor)
@@ -322,27 +318,55 @@ public class GFELegendResource extends
}
+ /**
+ * Gets an ordered collection of Parms to display for the legend.
+ *
+ * @param descriptor
+ * @param parmRscMap
+ * optional map to create Parm->ResourcePair mapping for parms
+ * returned
+ * @return
+ */
+ protected Collection getLegendOrderedParms(IDescriptor descriptor,
+ Map parmRscMap) {
+ List parms = new ArrayList();
+ for (ResourcePair rp : descriptor.getResourceList()) {
+ if (rp.getResource() instanceof GFEResource) {
+ Parm parm = ((GFEResource) rp.getResource()).getParm();
+ if (qvGrid == null
+ || (qvGrid != null && qvGrid.getParm() == parm)) {
+ parms.add(parm);
+ if (parmRscMap != null) {
+ parmRscMap.put(parm, rp);
+ }
+ if (qvGrid != null) {
+ break;
+ }
+ }
+ }
+ }
+
+ Collections.sort(parms);
+ Collections.reverse(parms);
+ return parms;
+ }
+
private LegendData[] getLegendDataGrids(IDescriptor descriptor) {
int lengthOfTime = "144h Tue 19Z 12-Sep-06".length();
List legendDataList = new ArrayList();
- Date date = this.dataManager.getSpatialDisplayManager()
- .getSpatialEditorTime();
- DataTime dt = new DataTime(date);
+ FramesInfo currInfo = descriptor.getFramesInfo();
Parm activeParm = dataManager.getSpatialDisplayManager()
.getActivatedParm();
StringBuilder labelBuilder = new StringBuilder();
- Parm[] parms;
+ Map parmRscMap = new HashMap();
+ Collection parms = getLegendOrderedParms(descriptor, parmRscMap);
Parm qvParm = null;
- if (qvGrid == null) {
- parms = orderParms(descriptor);
- } else {
+ if (qvGrid != null) {
qvParm = qvGrid.getParm();
- parms = new Parm[] { qvParm };
- dt = new DataTime(qvGrid.getDate());
}
int[] lengths = getLongestFields(parms);
@@ -350,12 +374,11 @@ public class GFELegendResource extends
ParmID topoID = dataManager.getTopoManager().getCompositeParmID();
// Topmost resources: GFE Parms
- for (int i = parms.length - 1; i >= 0; i--) {
- Parm parm = parms[i];
+ for (Parm parm : parms) {
ParmID parmId = parm.getParmID();
DatabaseID dbId = parmId.getDbId();
StringBuilder sb = new StringBuilder();
- ResourcePair rp = parmToRscMap.get(parm);
+ ResourcePair rp = parmRscMap.get(parm);
GFEResource rsc = (GFEResource) rp.getResource();
LegendData ld = new LegendData();
ResourceProperties props = rp.getProperties();
@@ -450,25 +473,19 @@ public class GFELegendResource extends
addSpaces(sb, diff + 3);
labelBuilder.setLength(0);
- if (dt != null) {
- IGridData[] gd = parm.getGridInventory(dt.getValidPeriod());
- if ((gd == null) || (gd.length == 0)) {
- labelBuilder.append(" ");
- } else if (!parm.getGridInfo().isTimeIndependentParm()) {
- TimeRange tr = gd[0].getGridTime();
+ if (parm.getGridInfo().isTimeIndependentParm()) {
+ labelBuilder.append(" Persistent");
+ } else {
+ DataTime currRscTime = currInfo.getTimeForResource(rsc);
+ if (currRscTime != null) {
+ TimeRange tr = currRscTime.getValidPeriod();
labelBuilder.append(String.format("%3d",
tr.getDuration() / 3600000));
labelBuilder.append("h ");
labelBuilder.append(resourceDateFormat.format(tr
.getStart()));
} else {
- labelBuilder.append(" Persistent");
- }
-
- }
- if (labelBuilder.length() == 0) {
- if (parm.getGridInfo().isTimeIndependentParm()) {
- labelBuilder.append(" Persistent");
+ labelBuilder.append(" ");
}
}
@@ -528,7 +545,7 @@ public class GFELegendResource extends
/**
* Get the legend mode
- *
+ *
* @return the legend mode
*/
public LegendMode getLegendMode() {
@@ -538,14 +555,14 @@ public class GFELegendResource extends
/**
* Works in a single pass to perform the operations performed in AWIPS I
* getLargestLevelName, etc.
- *
+ *
* The fields in order: FieldName LevelName Units ModelName
- *
- *
+ *
+ *
* @param descriptor
* @return
*/
- private int[] getLongestFields(Parm[] parms) {
+ private int[] getLongestFields(Collection parms) {
// Iterator rl = descriptor.getResourceList().iterator();
int[] sz = new int[4];
StringBuilder labelBuilder = new StringBuilder();
@@ -604,34 +621,6 @@ public class GFELegendResource extends
return sz;
}
- /**
- * Create a map between parms and gfe resources. This will avoid expensive
- * searching
- *
- * @param descriptor
- * @return
- */
- protected Parm[] orderParms(IDescriptor descriptor) {
- Iterator rl = descriptor.getResourceList().iterator();
-
- parmToRscMap.clear();
- while (rl.hasNext()) {
- ResourcePair rp = rl.next();
- if (rp.getResource() instanceof GFEResource) {
- GFEResource gfeRsc = (GFEResource) rp.getResource();
- parmToRscMap.put(gfeRsc.getParm(), rp);
- }
- }
-
- // Now sort the parms in the proper order
- // This will put them in the desired order, even if the actual order has
- // been changed to facilitate proper rendering order
- Parm[] parms = parmToRscMap.keySet().toArray(
- new Parm[parmToRscMap.size()]);
- Arrays.sort(parms);
- return parms;
- }
-
@Override
protected void disposeInternal() {
super.disposeInternal();
@@ -677,7 +666,7 @@ public class GFELegendResource extends
/**
* Set the legend mode
- *
+ *
* @param mode
* the legend mode
*/
@@ -688,7 +677,7 @@ public class GFELegendResource extends
/*
* (non-Javadoc)
- *
+ *
* @see
* com.raytheon.viz.gfe.core.msgs.Message.IMessageClient#receiveMessage(
* com.raytheon.viz.gfe.core.msgs.Message)
diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFEResource.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFEResource.java
index 2dd9895521..2cd4701aec 100644
--- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFEResource.java
+++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFEResource.java
@@ -105,6 +105,7 @@ import com.raytheon.uf.viz.core.rsc.capabilities.ImagingCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.MagnificationCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.OutlineCapability;
import com.raytheon.uf.viz.core.style.LabelingPreferences;
+import com.raytheon.uf.viz.core.time.TimeMatchingJob;
import com.raytheon.viz.core.contours.rsc.displays.GriddedContourDisplay;
import com.raytheon.viz.core.contours.rsc.displays.GriddedVectorDisplay;
import com.raytheon.viz.core.rsc.displays.GriddedImageDisplay;
@@ -253,6 +254,7 @@ public class GFEResource extends
@Override
public void parmInventoryChanged(Parm parm, TimeRange timeRange) {
resetFrame(timeRange);
+ TimeMatchingJob.scheduleTimeMatch(getDescriptor());
}
};
@@ -309,7 +311,6 @@ public class GFEResource extends
lastIscMode = dataManager.getParmManager().iscMode();
updateRightClickMenu();
-
}
public void reset() {
diff --git a/cave/com.raytheon.viz.gfe/tests/com/raytheon/viz/gfe/core/FakeDataManager.java b/cave/com.raytheon.viz.gfe/tests/com/raytheon/viz/gfe/core/FakeDataManager.java
index c2da335e94..4ae16f25fa 100644
--- a/cave/com.raytheon.viz.gfe/tests/com/raytheon/viz/gfe/core/FakeDataManager.java
+++ b/cave/com.raytheon.viz.gfe/tests/com/raytheon/viz/gfe/core/FakeDataManager.java
@@ -72,7 +72,7 @@ public class FakeDataManager extends DataManager {
private AutoSaveJob autoSaveJob;
public FakeDataManager() throws GFEServerException {
- super();
+ super(new DataManagerOffscreenFactory(), null);
parmManager = super.getParmManager();
spatialDisplayManager = super.getSpatialDisplayManager();
parmOp = super.getParmOp();