Omaha #3242 fix errors that can occur if a user zooms or pans while the

time series is still loading

Change-Id: Ibcdc9681c651731f7da554c8cca40e260303aebb

Former-commit-id: 7999e026e8ff02ccb0f155af8770b0d8aac43339
This commit is contained in:
Nate Jensen 2014-06-18 16:02:55 -05:00
parent bc9e7f1cb3
commit 3ba4931eee
2 changed files with 24 additions and 5 deletions

View file

@ -28,7 +28,7 @@ import com.raytheon.viz.ui.input.PanHandler;
import com.vividsolutions.jts.geom.Coordinate;
/**
* TODO Add Description
* A pan handler for time series.
*
* <pre>
*
@ -36,6 +36,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 16, 2009 mschenke Initial creation
* Jun 14, 2014 3242 njensen Null safety checks
*
* </pre>
*
@ -94,6 +95,7 @@ public class TimeSeriesPanHandler extends AbstractGraphInputHandler {
IGraph graphToUse = desc.getGraphResource().getClosestGraph(grid);
if (graphToUse != null
&& graphToUse.getExtent() != null
&& graphToUse.getExtent().contains(
new double[] { grid.x, grid.y, grid.z })) {
this.graph = graphToUse;
@ -150,6 +152,7 @@ public class TimeSeriesPanHandler extends AbstractGraphInputHandler {
*
* @see com.raytheon.viz.ui.input.IInputHandler#handleMouseUp(int, int, int)
*/
@Override
public boolean handleMouseUp(int x, int y, int button) {
IDisplayPaneContainer editor = display.getContainer();
if (button != 1) {

View file

@ -38,7 +38,9 @@ import com.raytheon.viz.ui.input.preferences.MousePreferenceManager;
import com.vividsolutions.jts.geom.Coordinate;
/**
* TODO Add Description
* A zoom handler for time series. Time series needs a special zoom handler
* since the axes will redraw as the user zooms in and out.
*
*
* <pre>
*
@ -47,6 +49,7 @@ import com.vividsolutions.jts.geom.Coordinate;
* ------------ ---------- ----------- --------------------------
* Oct 16, 2009 mschenke Initial creation
* Dec 11, 2013 DR 16795 D. Friedman Transform pixel coordinate for zoom
* Jun 18, 2014 3242 njensen Null safety checks
*
* </pre>
*
@ -126,7 +129,7 @@ public class TimeSeriesZoomHandler extends AbstractGraphInputHandler {
hiddenGraphs.push(graphToHide);
} else {
IGraph graph = desc.getGraphResource().getClosestGraph(grid);
if (graph.getExtent().contains(new double[] { grid.x, grid.y })) {
if (graphContainsCoordinate(graph, grid)) {
graph.zoom((int) Math.pow(2, zoomIndex - totalGraphs + 1), grid);
} else {
zoomIndex--;
@ -148,7 +151,7 @@ public class TimeSeriesZoomHandler extends AbstractGraphInputHandler {
if (zoomIndex > 0) {
if (zoomIndex >= totalGraphs) {
IGraph graph = desc.getGraphResource().getClosestGraph(grid);
if (graph.getExtent().contains(new double[] { grid.x, grid.y })) {
if (graphContainsCoordinate(graph, grid)) {
graph.zoom((int) Math.pow(2, zoomIndex - totalGraphs), grid);
} else {
zoomIndex++;
@ -169,7 +172,8 @@ public class TimeSeriesZoomHandler extends AbstractGraphInputHandler {
if (grid == null) {
return null;
}
/* Convert from the overall display coordinate space to the coordinate
/*
* Convert from the overall display coordinate space to the coordinate
* space for our resource.
*/
DirectPosition2D dp = new DirectPosition2D(grid.x, grid.y);
@ -185,4 +189,16 @@ public class TimeSeriesZoomHandler extends AbstractGraphInputHandler {
return grid;
}
/**
* Checks whether or not the coordinate is in the extent of a graph
*
* @param graph
* @param coord
* @return
*/
private boolean graphContainsCoordinate(IGraph graph, Coordinate coord) {
return (graph != null && graph.getExtent() != null && graph.getExtent()
.contains(new double[] { coord.x, coord.y }));
}
}