From b6ba8c0a3da72095a4e60a67ecd0781cb213e682 Mon Sep 17 00:00:00 2001 From: Nate Jensen Date: Wed, 18 Jun 2014 16:02:55 -0500 Subject: [PATCH] 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: 3ba4931eeedba24ab6ea286046edaaa0c28eda2b [formerly 7999e026e8ff02ccb0f155af8770b0d8aac43339] Former-commit-id: a18fa3f0262c9892656db51123c819685d100ec3 --- .../timeseries/util/TimeSeriesPanHandler.java | 5 +++- .../util/TimeSeriesZoomHandler.java | 24 +++++++++++++++---- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/cave/com.raytheon.uf.viz.xy.timeseries/src/com/raytheon/uf/viz/xy/timeseries/util/TimeSeriesPanHandler.java b/cave/com.raytheon.uf.viz.xy.timeseries/src/com/raytheon/uf/viz/xy/timeseries/util/TimeSeriesPanHandler.java index 065479c77b..36d4534a24 100644 --- a/cave/com.raytheon.uf.viz.xy.timeseries/src/com/raytheon/uf/viz/xy/timeseries/util/TimeSeriesPanHandler.java +++ b/cave/com.raytheon.uf.viz.xy.timeseries/src/com/raytheon/uf/viz/xy/timeseries/util/TimeSeriesPanHandler.java @@ -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. * *
  * 
@@ -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
  * 
  * 
* @@ -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) { diff --git a/cave/com.raytheon.uf.viz.xy.timeseries/src/com/raytheon/uf/viz/xy/timeseries/util/TimeSeriesZoomHandler.java b/cave/com.raytheon.uf.viz.xy.timeseries/src/com/raytheon/uf/viz/xy/timeseries/util/TimeSeriesZoomHandler.java index 02dba0e768..d6edbad6f3 100644 --- a/cave/com.raytheon.uf.viz.xy.timeseries/src/com/raytheon/uf/viz/xy/timeseries/util/TimeSeriesZoomHandler.java +++ b/cave/com.raytheon.uf.viz.xy.timeseries/src/com/raytheon/uf/viz/xy/timeseries/util/TimeSeriesZoomHandler.java @@ -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. + * * *
  * 
@@ -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
  * 
  * 
* @@ -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 })); + } + }