Merge "Issue #704 add INCOMPLETE PaintStatus to indicate a frame will require more painting later" into development

Former-commit-id: c7de1d7896 [formerly 121d68b8c4] [formerly c7de1d7896 [formerly 121d68b8c4] [formerly 133cd9994e [formerly 5e8d1cbc132dbd69b86342234631f3d11e3bdb3d]]]
Former-commit-id: 133cd9994e
Former-commit-id: 8c38ed612e [formerly f4db55cd46]
Former-commit-id: 082fbf8f1a
This commit is contained in:
Nate Jensen 2012-06-20 17:56:50 -05:00 committed by Gerrit Code Review
commit 9e69498620
12 changed files with 116 additions and 10 deletions

View file

@ -26,6 +26,7 @@ import org.opengis.referencing.crs.CoordinateReferenceSystem;
import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.drawables.PaintProperties; import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.PaintStatus;
import com.raytheon.uf.viz.core.drawables.ResourcePair; import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.MapDescriptor; import com.raytheon.uf.viz.core.map.MapDescriptor;
@ -164,7 +165,10 @@ public class MapResourceGroup extends
paintProps.setAlpha(resource.getCapability( paintProps.setAlpha(resource.getCapability(
ImagingCapability.class).getAlpha()); ImagingCapability.class).getAlpha());
} }
resource.paint(target, newProps); PaintStatus paintStatus = resource.paint(target, newProps);
if (paintStatus != PaintStatus.PAINTED) {
updatePaintStatus(paintStatus);
}
} }
} }
} }

View file

@ -37,5 +37,31 @@ package com.raytheon.uf.viz.core.drawables;
*/ */
public enum PaintStatus { public enum PaintStatus {
PAINTED, REPAINT, ERROR; /**
* indicates that a resource or renderable has successfully painted all
* available data.
*/
PAINTED,
/**
* indicates that a resource is currently in the act of painting
*/
PAINTING,
/**
* indicates that less than all the data has painted and more data will be
* arriving asynchronously, when that data arrives the PaintStatus will
* become REPAINT.
*/
INCOMPLETE,
/**
* indicates a resource has new data that needs to be painted
*/
REPAINT,
/**
* an uncaught error occured during the last paint event.
*/
ERROR;
} }

View file

@ -125,6 +125,36 @@ public class JobPool {
return workQueue.remove(runnable); return workQueue.remove(runnable);
} }
/**
* A JobPool is considered active if any of the jobs it contains are running
* or waiting to be run. When all scheduled work is run
*
* @return
*/
public boolean isActive() {
if (!workQueue.isEmpty()) {
return true;
}
for (Job job : jobList) {
int state = job.getState();
if (state == Job.RUNNING || state == Job.WAITING) {
return true;
}
}
return false;
}
/**
* get the number of tasks(Runnables) that are waiting to be run. This does
* not include tasks that are currently running so even if there are no
* waiting tasks the pool may still be active.
*
* @return
*/
public int getWorkRemaining() {
return workQueue.size();
}
protected class PooledJob extends Job { protected class PooledJob extends Job {
public PooledJob(String name) { public PooledJob(String name) {

View file

@ -337,6 +337,7 @@ public abstract class AbstractVizResource<T extends AbstractResourceData, D exte
for (IInitListener listener : initListeners) { for (IInitListener listener : initListeners) {
listener.inited(this); listener.inited(this);
} }
issueRefresh();
} }
/** /**
@ -441,7 +442,7 @@ public abstract class AbstractVizResource<T extends AbstractResourceData, D exte
initJob = new InitJob(target); initJob = new InitJob(target);
initJob.schedule(); initJob.schedule();
} }
issueRefresh(); updatePaintStatus(PaintStatus.INCOMPLETE);
break; break;
} }
case LOADING: { case LOADING: {
@ -453,19 +454,21 @@ public abstract class AbstractVizResource<T extends AbstractResourceData, D exte
initJob = null; initJob = null;
throw e; throw e;
} }
issueRefresh(); updatePaintStatus(PaintStatus.INCOMPLETE);
break; break;
} }
case INITIALIZED: { case INITIALIZED: {
// We have initialized successfully, now time to paint // We have initialized successfully, now time to paint
try { try {
paintStatus = PaintStatus.PAINTED; updatePaintStatus(PaintStatus.PAINTING);
paintInternal(target, paintProps); paintInternal(target, paintProps);
} catch (VizException e) { } catch (VizException e) {
paintStatus = PaintStatus.ERROR; updatePaintStatus(PaintStatus.ERROR);
throw e; throw e;
} }
if (paintStatus == PaintStatus.PAINTING) {
updatePaintStatus(PaintStatus.PAINTED);
}
for (IPaintListener listener : paintListeners) { for (IPaintListener listener : paintListeners) {
listener.painted(this); listener.painted(this);
} }
@ -712,6 +715,10 @@ public abstract class AbstractVizResource<T extends AbstractResourceData, D exte
} }
} }
public PaintStatus getPaintStatus() {
return paintStatus;
}
/** /**
* Recycle a resource to be used again, will call dispose on the resource if * Recycle a resource to be used again, will call dispose on the resource if
* it is in the INITIALIZED state, otherwise sets status to NEW which will * it is in the INITIALIZED state, otherwise sets status to NEW which will

View file

@ -69,6 +69,7 @@ import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle; import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle;
import com.raytheon.uf.viz.core.datastructure.DataCubeContainer; import com.raytheon.uf.viz.core.datastructure.DataCubeContainer;
import com.raytheon.uf.viz.core.drawables.PaintProperties; import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.PaintStatus;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.IMapDescriptor; import com.raytheon.uf.viz.core.map.IMapDescriptor;
import com.raytheon.uf.viz.core.map.MapDescriptor; import com.raytheon.uf.viz.core.map.MapDescriptor;
@ -934,6 +935,8 @@ public abstract class AbstractMapVectorResource extends
if (combineOperation != CombineOperation.NONE) { if (combineOperation != CombineOperation.NONE) {
contourGroup.paint(target, paintProps); contourGroup.paint(target, paintProps);
} }
} else {
updatePaintStatus(PaintStatus.INCOMPLETE);
} }
} else { } else {
AbstractGriddedDisplay<?> display = this.gdManagerJob AbstractGriddedDisplay<?> display = this.gdManagerJob

View file

@ -54,6 +54,7 @@ import com.raytheon.uf.viz.core.drawables.ColorMapLoader;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters; import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.IRenderable; import com.raytheon.uf.viz.core.drawables.IRenderable;
import com.raytheon.uf.viz.core.drawables.PaintProperties; import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.PaintStatus;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.IMapDescriptor; import com.raytheon.uf.viz.core.map.IMapDescriptor;
import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData; import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData;
@ -413,6 +414,7 @@ public abstract class AbstractGridResource<T extends AbstractResourceData>
GeneralGridData data = requestData(time); GeneralGridData data = requestData(time);
if (data == null) { if (data == null) {
updatePaintStatus(PaintStatus.INCOMPLETE);
return; return;
} }
@ -421,6 +423,8 @@ public abstract class AbstractGridResource<T extends AbstractResourceData>
if (renderable != null) { if (renderable != null) {
renderables.put(time, renderable); renderables.put(time, renderable);
renderable.paint(target, paintProps); renderable.paint(target, paintProps);
} else {
updatePaintStatus(PaintStatus.INCOMPLETE);
} }
} }

View file

@ -174,6 +174,15 @@ public class PlotDataThreadPool {
} }
} }
public boolean isDone() {
for (PlotModelDataRequestJob job : jobList) {
if (!job.isDone()) {
return false;
}
}
return true;
}
public void shutdown() { public void shutdown() {
stationQueue.clear(); stationQueue.clear();
for (PlotModelDataRequestJob job : jobList) { for (PlotModelDataRequestJob job : jobList) {

View file

@ -186,8 +186,8 @@ public class PlotModelDataRequestJob extends Job {
} }
} }
} }
if(!params.contains("dataURI")){ if (!params.contains("dataURI")) {
params.add("dataURI"); params.add("dataURI");
} }
@ -334,6 +334,11 @@ public class PlotModelDataRequestJob extends Job {
this.plotCreator.setPlotMissingData(b); this.plotCreator.setPlotMissingData(b);
} }
public boolean isDone() {
return getState() != Job.RUNNING && getState() != Job.WAITING
&& generatorJob.isDone();
}
public void shutdown() { public void shutdown() {
this.cancel(); this.cancel();
this.generatorJob.shutdown(); this.generatorJob.shutdown();

View file

@ -145,6 +145,10 @@ public class PlotModelGeneratorJob extends Job {
imageCache.clear(); imageCache.clear();
} }
public boolean isDone() {
return getState() != Job.RUNNING && getState() != Job.WAITING;
}
protected void shutdown() { protected void shutdown() {
cancel(); cancel();
taskQueue.clear(); taskQueue.clear();

View file

@ -48,6 +48,7 @@ import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.PixelExtent; import com.raytheon.uf.viz.core.PixelExtent;
import com.raytheon.uf.viz.core.drawables.IImage; import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.PaintProperties; import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.PaintStatus;
import com.raytheon.uf.viz.core.drawables.ext.ISingleColorImageExtension.ISingleColorImage; import com.raytheon.uf.viz.core.drawables.ext.ISingleColorImageExtension.ISingleColorImage;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.jobs.JobPool; import com.raytheon.uf.viz.core.jobs.JobPool;
@ -208,6 +209,11 @@ public class PlotResource2 extends
descriptor.getCRS()), descriptor.getCRS()); descriptor.getCRS()), descriptor.getCRS());
} }
if (!progressiveDisclosure.isDone() || !generator.isDone()
|| frameRetrievalPool.isActive()) {
updatePaintStatus(PaintStatus.INCOMPLETE);
}
this.updateRecords(); this.updateRecords();
List<Station> stationList = curFrame.lastComputed; List<Station> stationList = curFrame.lastComputed;

View file

@ -188,6 +188,10 @@ public abstract class AbstractProgDisclosure extends Job {
return nextTask.canvasWidth / nextTask.extent.getWidth(); return nextTask.canvasWidth / nextTask.extent.getWidth();
} }
public boolean isDone() {
return getState() != Job.RUNNING && getState() != Job.WAITING;
}
public void shutdown() { public void shutdown() {
this.cancel(); this.cancel();
nextTask = new Task(); nextTask = new Task();

View file

@ -33,6 +33,7 @@ import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.PixelCoverage; import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.drawables.IImage; import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.PaintProperties; import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.PaintStatus;
import com.raytheon.uf.viz.core.drawables.ResourcePair; import com.raytheon.uf.viz.core.drawables.ResourcePair;
import com.raytheon.uf.viz.core.drawables.ext.IOffscreenRenderingExtension; import com.raytheon.uf.viz.core.drawables.ext.IOffscreenRenderingExtension;
import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.exception.VizException;
@ -190,7 +191,10 @@ public class SatBlendedResource extends
paintProps); paintProps);
rscProps.setDataTime(timeForRsc); rscProps.setDataTime(timeForRsc);
rscProps.setAlpha(1.0f); rscProps.setAlpha(1.0f);
rsc.paint(target, rscProps); PaintStatus paintStatus = rsc.paint(target, rscProps);
if (paintStatus != PaintStatus.PAINTED) {
updatePaintStatus(paintStatus);
}
} }
} }
} }