From 7c34074e52e8c3afabdf9ece72a818e9ca7a11ce Mon Sep 17 00:00:00 2001 From: Slav Korolev Date: Wed, 18 Nov 2015 13:04:23 -0500 Subject: [PATCH] Omaha #5073 - Fixed issue with Time Series Display. Former-commit-id: ef723c22c0cb54c0a6448696455349d8b4195bca --- .../timeseries/TimeSeriesDisplayCanvas.java | 27 ++++++++++--------- .../graph/TimeSeriesGraphCanvas.java | 8 ++++-- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDisplayCanvas.java b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDisplayCanvas.java index db009a60c5..5d08c52da1 100644 --- a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDisplayCanvas.java +++ b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/TimeSeriesDisplayCanvas.java @@ -140,7 +140,9 @@ import com.raytheon.viz.hydrocommon.util.DbUtils; * 06 May 2013 1976 mpduff Refactored Hydro time series data access. * 29 May 2013 2016 mpduff Fix TS Toggle Traces. * 05 Sep 2013 #2332 lvenable Fixed memory leaks. - * 24 Jan 2013 15959 lbousaidi Swap the corner points of the bounding box when zooming. + * 24 Jan 2013 15959 lbousaidi Swap the corner points of the bounding box when zooming. + * Nov 18 2015 5073 skorolev Fixed drawing PP time series. + * * @author lvenable * @version 1.0 * @@ -841,7 +843,8 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements } /* Precipitation physical element */ - if (td.getPe().equalsIgnoreCase(HydroConstants.PP)) { + if (td.getPe().equalsIgnoreCase(HydroConstants.PP) + && td.isTraceOn()) { precipPE = true; setBackgroundColor(td, j, gc); int[] ia = new int[8]; @@ -1242,12 +1245,12 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements } Date xMin = pixel2x(gd, rubberBandX1 - GRAPHBORDER_LEFT); Date xMax = pixel2x(gd, rubberBandX2 - GRAPHBORDER_LEFT); - //Swap the corner points of the bounding box when zooming + // Swap the corner points of the bounding box when zooming if (xMin.after(xMax)) { - Date xtmp; - xtmp= xMin; - xMin=xMax; - xMax=xtmp; + Date xtmp; + xtmp = xMin; + xMin = xMax; + xMax = xtmp; } gd.setXMin(xMin); gd.setXMax(xMax); @@ -1263,12 +1266,12 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements if (ymin < gd.getYmin()) { ymin = gd.getYmin(); } - //Swap the corner points of the bounding box when zooming + // Swap the corner points of the bounding box when zooming if (ymin > ymax) { - double ytmp; - ytmp= ymin; - ymin=ymax; - ymax=ytmp; + double ytmp; + ytmp = ymin; + ymin = ymax; + ymax = ytmp; } gd.setYmin(ymin); gd.setYmax(ymax); diff --git a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/graph/TimeSeriesGraphCanvas.java b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/graph/TimeSeriesGraphCanvas.java index 860f762da3..0ccaba3663 100644 --- a/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/graph/TimeSeriesGraphCanvas.java +++ b/cave/com.raytheon.viz.hydro/src/com/raytheon/viz/hydro/timeseries/graph/TimeSeriesGraphCanvas.java @@ -70,6 +70,7 @@ import com.raytheon.viz.hydrocommon.HydroConstants; * 06 Nov 2012 15399 wkwock Fix refine the plot algorithm and sampling algorithm * May 06, 2013 1976 mpduff Code cleanup * 05Sep2013 #2332 lvenable Fixed memory leaks. + * Nov 18, 2015 5073 skorolev Fixed y2pixel. * * * @author mpduff @@ -624,8 +625,11 @@ public class TimeSeriesGraphCanvas extends Canvas { } double yDiff = gd.getYmax() - gd.getYmin(); double yValue = (graphAreaHeight / yDiff) * (y - gd.getYmin()); - - return (int) (graphAreaHeight - Math.round(yValue)); + if (yValue < 0) { + return graphAreaHeight; + } else { + return (int) (graphAreaHeight - Math.round(yValue)); + } } /**