Issue #1976 - Fix race condition in Hydro TS

Peer Review comments

Change-Id: I124176dcc242709f30f19152e7ecb6fda4e7c861

Former-commit-id: 62254c56ac [formerly c27de86f3d] [formerly 62254c56ac [formerly c27de86f3d] [formerly 00d96e88ac [formerly 80c08a73c2bcaf853e63c175334b9f00dd93d696]]]
Former-commit-id: 00d96e88ac
Former-commit-id: 9959645255 [formerly ae1e879aa4]
Former-commit-id: 12722ddbcd
This commit is contained in:
Mike Duff 2013-05-07 11:43:36 -05:00
parent 550a5c04e8
commit 62f8c7e9aa
5 changed files with 1536 additions and 1586 deletions

View file

@ -19,9 +19,6 @@
**/
package com.raytheon.viz.hydro.timeseries;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.QualifiedName;
@ -30,9 +27,8 @@ import org.eclipse.core.runtime.jobs.IJobChangeListener;
import org.eclipse.core.runtime.jobs.Job;
/**
* The TimeSeriesDataJob Manager asynchronously retrieves
* Time Series Graph and Time Series Tabular Data via the
* Eclipse Job capability.
* The TimeSeriesDataJob Manager asynchronously retrieves Time Series Graph and
* Time Series Tabular Data via the Eclipse Job capability.
*
* <pre>
*
@ -40,7 +36,8 @@ import org.eclipse.core.runtime.jobs.Job;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jan 28, 2011 bkowal Initial creation
* Jan 28, 2011 bkowal Initial creation
* May 06, 2013 1976 mpduff Moved c.getDataForGraph() inside .runasync block
*
* </pre>
*
@ -71,11 +68,12 @@ public class TimeSeriesDataJobManager extends Job {
TimeSeriesDisplayCanvas tsDisplayCanvas = (TimeSeriesDisplayCanvas) this
.getProperty(new QualifiedName(null,
"TimeSeriesDisplayCanvas"));
tsDisplayCanvas.getDataForGraph();
final TimeSeriesDisplayCanvas c = tsDisplayCanvas;
tsDisplayCanvas.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if(!c.isDisposed()) {
if (!c.isDisposed()) {
c.getDataForGraph();
c.redraw();
}
}

View file

@ -43,7 +43,6 @@ import org.eclipse.swt.events.MouseMoveListener;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
@ -60,6 +59,9 @@ import org.eclipse.swt.widgets.Shell;
import com.raytheon.uf.common.dataplugin.shef.tables.Fcstheight;
import com.raytheon.uf.common.ohd.AppsDefaults;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.viz.hydro.timeseries.graph.TimeSeriesGraphCanvas;
import com.raytheon.viz.hydro.timeseries.util.GraphData;
@ -133,19 +135,21 @@ import com.raytheon.viz.hydrocommon.util.DbUtils;
* 13 Nov 2012 15416 lbousaidi added a check when the colorname is null and a call to
* getGroupModeColor
* 09 Jan 2012 15493 lbousaidi added code to delete data while zooming when you draw a box
* 16 Jan 2013 15695 wkwock Fix popup menu
* 16 Jan 2013 15695 wkwock Fix popup menu
* 24 Apr 2013 1921 mpduff Fix zoom reset to only reset the "active" graph
* 06 May 2013 1976 mpduff Refactored Hydro time series data access.
* @author lvenable
* @version 1.0
*
*/
public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
IJobChangeListener {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(TimeSeriesDisplayCanvas.class);
/** The maximum number of forecast traces. */
private static final int MAX_FCST_TRACES = 30;
private final String INCH = "in";
private final String FEET = "ft";
private final String CFS = "cfs";
@ -157,16 +161,6 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
*/
private final Composite parentComp;
/**
* Flag indicating that obs data are not available.
*/
private boolean noDataAvailable = true;
/**
* Flag indicating that forecast data are not available.
*/
private boolean noFcstDataAvailable = true;
/**
* No Data Available string.
*/
@ -199,7 +193,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
private Date maxDate = null;
/** List of visible traces */
private ArrayList<TraceData> traceArray = null;
private List<TraceData> traceArray = null;
/** Graph data object */
private GraphData graphData = null;
@ -338,11 +332,6 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
*/
private ArrayList<Boolean> validGraph;
/**
* Is the graph valid
*/
private boolean findGraph = false;
/**
* Show Latest Forecast flag.
*/
@ -352,11 +341,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
* record of the number of forecast traces and type source
*/
private int num_of_fcstTraces = 0;
private int num_of_fcstTs = 0;
private Boolean inDataRetreival = Boolean.FALSE;
private volatile boolean inDataRetreival;
private TimeSeriesDataJobManager tsDataJobManager = null;
@ -367,14 +352,18 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
/**
* Constructor.
*
* @param dialog
* Parent dialog
* @param parent
* Parent composite.
* @param lid
* Location Id
* @param pe
* Physical Element
* @param ts
* Type Source
* parent composite
* @param graphData
* Graph data object
* @param beginDate
* starting date
* @param endDate
* ending date
* @param groupMode
* groupMode
*/
public TimeSeriesDisplayCanvas(final TimeSeriesDisplayDlg dialog,
Composite parent, GraphData graphData, Date beginDate,
@ -388,21 +377,20 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
this.dialog = dialog;
this.tsDataJobManager = new TimeSeriesDataJobManager();
setDialog(dialog);
this.graphData.setBeginDate(beginDate);
this.graphData.setEndDate(endDate);
lineWidth = AppsDefaults.getInstance().getInt(
HydroConstants.TS_LINEWIDTH, 1);
crossHairCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_CROSS);
arrowCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_ARROW);
northSouthCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_SIZENS);
handCursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
crossHairCursor = parent.getDisplay().getSystemCursor(SWT.CURSOR_CROSS);
northSouthCursor = parent.getDisplay().getSystemCursor(
SWT.CURSOR_SIZENS);
handCursor = parent.getDisplay().getSystemCursor(SWT.CURSOR_HAND);
newRequest = true;
parentComp = parent;
tsCanvas = this;
white = parentComp.getDisplay().getSystemColor(SWT.COLOR_WHITE);
black = parentComp.getDisplay().getSystemColor(SWT.COLOR_BLACK);
dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
setRatingCurveExist(false);
@ -413,7 +401,6 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
@Override
public void handleEvent(Event e) {
// Set true so new regions will be created as graph is resized
createRegions = true;
resizeGraph(parentShell.getClientArea());
redraw();
@ -447,7 +434,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
}
private void scheduleDataRetrieval() {
inDataRetreival = Boolean.TRUE;
inDataRetreival = true;
tsDataJobManager.scheduleGetGraphData(this, this);
}
@ -483,7 +470,8 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
drawCanvas(e.gc);
}
} catch (Exception ex) {
ex.printStackTrace();
statusHandler.handle(Priority.WARN,
"Problem Painting Graph", ex);
}
}
});
@ -526,46 +514,25 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
this.resizeGraph(bounds);
}
/**
* Get the data for the lid and pe values passed in. If the graphData object
* is null, get data from IHFS else reuse the data
*/
public void getDataForGraph() {
try {
/*
* Get the data for the lid and pe values passed in. If the
* graphData object is null, get data from IHFS else reuse the data
*/
int start_num = 0;
int end_num = 0;
validGraph = new ArrayList<Boolean>();
for (int d = 0; d < 100; d++)
validGraph.add(false);
ArrayList<TraceData> traceList = graphData.getOriginalTraces();
if (traceList.isEmpty()) {
if (groupMode && latestFcstFlag && (num_of_fcstTraces != 0)) {
for (int g = 0; g < graphData.getNumTraces()
- (num_of_fcstTraces - num_of_fcstTs); g++) {
traceList.add(graphData.getTraceData(g));
}
} else
traceList = graphData.getTraces();
}
graphData.setTraces(traceList);
// Clone the list here because we are adding to it in the
// getFcstData
@SuppressWarnings("unchecked")
ArrayList<TraceData> clonedList = (ArrayList<TraceData>) traceList
.clone();
start_num = clonedList.size();
num_of_fcstTraces = 0;
num_of_fcstTs = 0;
HashSet<String> uniqueList = new HashSet<String>();
List<TraceData> traceList = graphData.getOriginalTraces();
graphData.setTraces(new ArrayList<TraceData>());
for (int i = 0; i < clonedList.size(); i++) {
if (clonedList.get(i).isForecast()) {
TraceData td = clonedList.get(i);
HashSet<String> uniqueList = new HashSet<String>();
// Make a copy of the list so we can add to the original while
// iterating over it
List<TraceData> iterList = new ArrayList<TraceData>();
for (TraceData td : traceList) {
iterList.add(td);
}
for (TraceData td : iterList) {
if (td.isForecast()) {
String traceKey = td.getLid() + td.getPe() + td.getTs()
+ td.getDur() + td.getExtremum();
if (uniqueList.contains(traceKey))
@ -574,37 +541,15 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
uniqueList.add(traceKey);
}
int return_fcst_num = getFcstData(clonedList.get(i));
if (groupMode && !latestFcstFlag && (return_fcst_num > 1)) {
num_of_fcstTraces = num_of_fcstTraces + return_fcst_num;
num_of_fcstTs++;
}
validGraph.set(i, noFcstDataAvailable);
if (return_fcst_num > 1) {
end_num = start_num + (return_fcst_num - 1);
for (int k = start_num; k < end_num; k++) {
validGraph.set(k, noFcstDataAvailable);
}
start_num = end_num;
}
getFcstData(td);
} else {
graphData.addTrace(clonedList.get(i));
getData(clonedList.get(i));
validGraph.set(i, noDataAvailable);
getData(td);
graphData.addTrace(td);
}
}
graphData.setBeginDate(beginDate);
graphData.setEndDate(endDate);
} finally {
inDataRetreival = Boolean.FALSE;
inDataRetreival = false;
}
// newRequest = false;
// getAgain = false;
}
/**
@ -616,7 +561,9 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
protected void drawCanvas(GC gc) {
gc.setFont(canvasFont);
fontHeight = (gc.getFontMetrics().getHeight());
if (fontHeight == -999) {
fontHeight = (gc.getFontMetrics().getHeight());
}
int fontAveWidth = gc.getFontMetrics().getAverageCharWidth();
int swtColor = SWT.COLOR_BLACK;
if (this.dialog.isInverseVideo()) {
@ -683,8 +630,6 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
/* Data Access Manager */
TimeSeriesDataManager dataManager = TimeSeriesDataManager.getInstance();
// TimeSeriesDataManager dataManagerStn = TimeSeriesDataManager
// .getInstance();
try {
String[] sa = dataManager.getStnRiverName(lid);
if ((sa != null) && (sa[0] != null) && (sa[1] != null)) {
@ -704,8 +649,8 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
siteLabel = lid;
}
} catch (VizException e) {
// TODO Auto-generated catch block
e.printStackTrace();
statusHandler.handle(Priority.ERROR,
"Error retrieving river names", e);
}
/* Find the flood stage */
@ -720,15 +665,14 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
}
/* Get the data traces */
traceArray = graphData.getTraces();
traceArray.trimToSize();
/* find valid graph with data or not */
findGraph = false;
for (int j = 0; j < traceArray.size(); j++) {
if ((validGraph != null) && !validGraph.get(j)) {
findGraph = true;
/* Is there data for the graph */
boolean hasData = false;
for (TraceData td : traceArray) {
if (td.getTsData() != null && td.getTsData().length > 0) {
hasData = true;
break;
}
}
@ -736,7 +680,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
/*
* If no data are available then draw no data available information.
*/
if (!findGraph) {
if (!hasData) {
setForegroundColor(gc, SWT.COLOR_WHITE);
// Draws a white border around the graph area
int[] points = { GRAPHBORDER, GRAPHBORDER,
@ -751,7 +695,8 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
int tmpY = canvasHeight / 2;
if (this.dialog.isInverseVideo()) {
gc.setBackground(this.white);
gc.setBackground(parentComp.getDisplay().getSystemColor(
SWT.COLOR_WHITE));
}
gc.drawString(NO_DATA_AVAILABLE, tmpX, tmpY);
gc.drawString(siteLabel + " fs=" + floodStage, GRAPHBORDER - 15,
@ -767,7 +712,6 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
/* Get the data traces */
traceArray = graphData.getTraces();
traceArray.trimToSize();
setForegroundColor(gc, SWT.COLOR_CYAN);
if (pointString != null) {
@ -776,7 +720,8 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
}
if (this.dialog.isInverseVideo()) {
gc.setBackground(this.white);
gc.setBackground(parentComp.getDisplay().getSystemColor(
SWT.COLOR_WHITE));
}
gc.drawString(siteLabel + " fs=" + floodStage,
GRAPHBORDER_LEFT - 10, GRAPHBORDER - fontHeight * 2);
@ -784,22 +729,16 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
int index = GRAPHBORDER_LEFT - 10;
// If labels run off the right of the canvas then need to stack them
boolean stackLabels = false;
// This should start at 2 because the first stack will be above a
// line
int stackCount = 2;
int stackCount = 2; // This should start as 2 because the first
// stack will be above a line
int labelStartX = 0;
int labelStartY = 0;
// store the label to be plotted on the gc legend later
ArrayList noDataLabels = new ArrayList<String>();
List<String> noDataLabels = new ArrayList<String>();
for (int j = 0; j < traceArray.size(); j++) {
TraceData td = traceArray.get(j);
boolean traceValid = true;
if (validGraph.get(j)) {
traceValid = false;
}
if (td.getPe().equalsIgnoreCase(HydroConstants.PP)) {
/*
@ -879,7 +818,8 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
}
}
} catch (Exception ex) {
ex.printStackTrace();
statusHandler.handle(Priority.ERROR,
"Error deriving PP", ex);
}
}
@ -972,8 +912,8 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
try {
labelString = dataManager.getShefPE(pe);
} catch (VizException ve) {
ve.printStackTrace();
// TODO Log error here
statusHandler.handle(Priority.ERROR,
"Error retrieving SHEF PE data", ve);
}
}
@ -1109,7 +1049,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
// draw no data legends
setForegroundColor(gc, SWT.COLOR_WHITE);
for (int i = 0; i < noDataLabels.size(); i++) {
String labelString = (String) noDataLabels.get(i);
String labelString = noDataLabels.get(i);
if (stackLabels
|| ((labelString.length() * fontAveWidth) + 50 + index > canvasWidth)) {
int[] xy = getLabelLocation(index, labelString, stackCount);
@ -1506,14 +1446,13 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
pointsbak.add(pbak);
}
}
noDataAvailable = false;
} else {
noDataAvailable = true;
}
} catch (VizException e) {
e.printStackTrace();
statusHandler.handle(Priority.ERROR, "Error retrieving graph data",
e);
} catch (ClassNotFoundException e) {
e.printStackTrace();
statusHandler.handle(Priority.ERROR, "Error retrieving graph data",
e);
}
td.setTsData(points.toArray(new TimeSeriesPoint[points.size()]));
@ -1595,7 +1534,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
String units = FEET;
boolean isRiverData = true;
boolean isStage = true;
ArrayList<TraceData> traces = graphData.getTraces();
List<TraceData> traces = graphData.getTraces();
for (TraceData trace : traces) {
if (!trace.getPe().toUpperCase().startsWith("H")
&& !trace.getPe().toUpperCase().startsWith("Q")) {
@ -1690,7 +1629,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
break;
} else {
pointSelected = false;
setCursor(arrowCursor);
setCursor(null);
}
}
} else {
@ -1701,7 +1640,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
break;
} else {
pointSelected = false;
setCursor(arrowCursor);
setCursor(null);
}
}
}
@ -1722,7 +1661,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
break;
} else {
pointSelected = false;
setCursor(arrowCursor);
setCursor(null);
}
}
} else {
@ -1733,7 +1672,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
break;
} else {
pointSelected = false;
setCursor(arrowCursor);
setCursor(null);
}
}
}
@ -1755,7 +1694,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
break;
} else {
pointSelected = false;
setCursor(arrowCursor);
setCursor(null);
}
}
} else {
@ -1766,7 +1705,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
break;
} else {
pointSelected = false;
setCursor(arrowCursor);
setCursor(null);
}
}
}
@ -1837,7 +1776,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
selectedTraceId = i;
break;
} else {
setCursor(arrowCursor);
setCursor(null);
selectableTrace = false;
}
}
@ -1848,7 +1787,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
selectableTrace = true;
selectedTraceId = traceId;
} else {
setCursor(arrowCursor);
setCursor(null);
selectableTrace = false;
}
}
@ -1861,15 +1800,15 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
/**
*
* @param x
* location x (of mouse pointer)
* : location x (of mouse pointer)
* @param y
* location y (of mouse pointer)
* : location y (of mouse pointer)
* @return the nearest trace. -999 if x,y is too far away
*/
private int findTracePoint(int x, int y) {
double distance = Double.MAX_VALUE;
int choosingTrace = -999;
ArrayList<TraceData> traceList = graphData.getTraces();
List<TraceData> traceList = graphData.getTraces();
// this loop is to find the closest point/line for every trace that's on
int closePoints[] = new int[traceList.size()];
@ -1889,12 +1828,13 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
y2 = dataPts[i + 3];
}
double curDistance = Double.MAX_VALUE;
if (x1 == x2 && y1 == y2) // distance from a point
// distance from a point
if (x1 == x2 && y1 == y2) {
curDistance = Math.sqrt(Math.pow(x - x1, 2)
+ Math.pow(y - y1, 2));
else {// distance from a line segment
// from
// http://stackoverflow.com/questions/849211/shortest-distance-between-a-point-and-a-line-segment
} else {
// distance from a line segment from
// http://stackoverflow.com/questions/849211/shortest-distance-between-a-point-and-a-line-segment
double p2X = x2 - x1;
double p2Y = y2 - y1;
@ -2170,12 +2110,11 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
/* Get the data traces */
traceArray = graphData.getTraces();
traceArray.trimToSize();
// Set true so new regions will be created
createRegions = true;
setCursor(arrowCursor);
setCursor(null);
redraw();
}
@ -2187,12 +2126,11 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
setZoomed(false);
dialog.setZoomAction(false);
traceArray = graphData.getTraces();
traceArray.trimToSize();
// Set true so new regions will be created
createRegions = true;
setCursor(arrowCursor);
setCursor(null);
redraw();
return;
@ -2235,7 +2173,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
* @param dataPts
* the points that make up the lines
*/
private void makeRegions(ArrayList<TraceData> traceList) {
private void makeRegions(List<TraceData> traceList) {
if (createRegions == true) {
/* Dispose of the previous regions */
for (Region r : regionList) {
@ -2466,7 +2404,8 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
*/
private void setForegroundColor(TraceData td, int traceIndex, GC gc) {
if (dialog.isInverseVideo()) {
gc.setForeground(black);
gc.setForeground(parentComp.getDisplay().getSystemColor(
SWT.COLOR_BLACK));
} else {
if (traceSelected && (selectedTraceId == traceIndex)
&& !dialog.isCancel()) { // if in edit mode
@ -2503,7 +2442,8 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
*/
private void setBackgroundColor(TraceData td, int traceIndex, GC gc) {
if (dialog.isInverseVideo()) {
gc.setBackground(black);
gc.setBackground(parentComp.getDisplay().getSystemColor(
SWT.COLOR_BLACK));
} else {
if (traceSelected && (selectedTraceId == traceIndex)
&& !dialog.isCancel()) { // if in edit mode
@ -2605,34 +2545,41 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
}
if (basisTime.getTime() != prevBasisTime.getTime()) {
if (ntraces < MAX_FCST_TRACES) {
traceData.setXmin(beginDate);
traceData.setXmax(endDate);
n = 0; /* Reset npts in new forecast trace */
traceData.setBasistime(prevBasisTime);
ntraces++;
traceData.setTsData(points
.toArray(new TimeSeriesPoint[points
.size()]));
points = new ArrayList<TimeSeriesPoint>();
if (!this.latestFcstFlag) {
if (ntraces < MAX_FCST_TRACES) {
traceData.setXmin(beginDate);
traceData.setXmax(endDate);
n = 0; /* Reset npts in new forecast trace */
traceData.setBasistime(prevBasisTime);
ntraces++;
traceData.setTsData(points
.toArray(new TimeSeriesPoint[points
.size()]));
points = new ArrayList<TimeSeriesPoint>();
if (ntraces >= 1) {
traceDataList.add(traceData);
if (ntraces >= 1) {
traceDataList.add(traceData);
}
traceData = new TraceData();
traceData.setForecast(true);
traceData.setDur(dur);
traceData.setExtremum(extremum);
traceData.setLid(lid);
traceData.setPe(pe);
traceData.setTs(ts);
traceData.setName(name);
traceData.setBasistime(basisTime);
traceData.setProductTime(productTime);
traceData.setTraceOn(!this.latestFcstFlag);
} else {
/*
* reached max fcst traces, break out of
* loop
*/
break;
}
traceData = new TraceData();
traceData.setForecast(true);
traceData.setDur(dur);
traceData.setExtremum(extremum);
traceData.setLid(lid);
traceData.setPe(pe);
traceData.setTs(ts);
traceData.setName(name);
traceData.setBasistime(basisTime);
traceData.setProductTime(productTime);
traceData.setTraceOn(!this.latestFcstFlag);
} else {
/* reached max fcst traces, break out of loop */
break;
}
}
@ -2687,13 +2634,12 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
traceDataList.add(traceData);
ntraces++;
}
noFcstDataAvailable = false;
} else {
noFcstDataAvailable = true;
traceDataList.add(traceData);// although nothing from DB
}
} catch (VizException e) {
e.printStackTrace();
statusHandler.handle(Priority.ERROR, "Error retrieving graph data",
e);
}
traceData.setTsData(points.toArray(new TimeSeriesPoint[points.size()]));
@ -2780,7 +2726,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
*
* @return The trace list
*/
private ArrayList<TraceData> getTraceList() {
private List<TraceData> getTraceList() {
return traceArray;
}
@ -2826,7 +2772,8 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
try {
redraw();
} catch (Exception e) {
e.printStackTrace();
statusHandler.handle(Priority.ERROR, "Error drawing graph",
e);
}
}
});
@ -2847,7 +2794,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
/**
* @return the traceArray
*/
public ArrayList<TraceData> getTraceArray() {
public List<TraceData> getTraceArray() {
return traceArray;
}
@ -2858,4 +2805,5 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
public void setZoomed(boolean zoomed) {
this.zoomed = zoomed;
}
}

View file

@ -120,6 +120,7 @@ import com.raytheon.viz.hydrocommon.util.StnClassSyncUtil;
* despite start up in CAVE or standalone.
* 30 Jan 2013 15264 wkwock Fix the missing group_definition.cfg file crash
* 05 Feb 2013 1578 rferrel Dialog made non-blocking and a singleton.
* 06 May 2013 1976 mpduff Code cleanup.
* </pre>
*
* @author lvenable
@ -127,7 +128,7 @@ import com.raytheon.viz.hydrocommon.util.StnClassSyncUtil;
*
*/
public class TimeSeriesDlg extends CaveHydroSWTDialog {
private static final transient IUFStatusHandler statusHandler = UFStatus
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(TimeSeriesDlg.class);
/* Constants */
@ -441,27 +442,18 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
private LIDData currLidData = new LIDData();
/** List of GroupInfo objects */
private ArrayList<GroupInfo> groupList = new ArrayList<GroupInfo>();
/** Holds the Group Information */
private GroupInfo groupInfo;
private final ArrayList<GroupInfo> groupList = new ArrayList<GroupInfo>();
/** Holds the last graphed GroupInfo object */
private GroupInfo prevGroupInfo;
/** Holds the page information */
private PageInfo pageInfo = null;
/** Holds the graph information */
private GraphData graphData = null;
private String groupConfigFilePath = null;
private ArrayList<SiteInfo> siteInfoList = new ArrayList<SiteInfo>();
private final ArrayList<SiteInfo> siteInfoList = new ArrayList<SiteInfo>();
private ArrayList<TabInfo> tabInfoList = new ArrayList<TabInfo>();
private final ArrayList<TabInfo> tabInfoList = new ArrayList<TabInfo>();
private HydroDisplayManager displayManager;
private final HydroDisplayManager displayManager;
private boolean openTimeSeriesDisplays = false;
@ -662,7 +654,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
font = new Font(shell.getDisplay(), "Monospace", 11, SWT.NORMAL);
// Initialize all of the controls and layoutsendCal
// Initialize all of the controls
initializeComponents();
setCurrentData();
}
@ -1097,7 +1089,6 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
public void keyReleased(KeyEvent event) {
String search = searchTF.getText();
if (!search.equals("") && !search.equals(" ")) {
/* Iterate over the location Ids in the list */
ListIterator<String> iter = lidList.listIterator();
while (iter.hasNext()) {
@ -1119,10 +1110,8 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
}
}
}
} else {
// topDataList.setSelection(0); // Commented to more closely
// match legacy app
}
if (topDataList.getSelectionIndex() > 0) {
populateBottomList(
lidList.get(topDataList.getSelectionIndex()),
@ -1276,6 +1265,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
bottomDataList.setLayoutData(gd);
bottomDataList.setFont(font);
bottomDataList.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
correctSelections();
}
@ -1532,7 +1522,6 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
si.setTs((String) row[2]);
si.setExt((String) row[3]);
si.setDur((Integer) row[4]);
// siteInfoList.add(si);
if (si.getPe().startsWith("H")) {
if (!si.getPe().equals(prevPE)) {
@ -1617,6 +1606,14 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
} else {
this.populateGroupListForStandalone();
}
for (GroupInfo gi : this.groupList) {
for (PageInfo pi : gi.getPageInfoList()) {
for (GraphData gd : pi.getGraphDataList()) {
gd.saveTraceInfo();
}
}
}
}
/**
@ -1644,7 +1641,6 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
groupDataList.removeAll();
if (this.groupConfigFilePath != null) {
this.readGroupList();
}
}
@ -1653,6 +1649,10 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
* Read the Group List file.
*/
private void readGroupList() {
GroupInfo groupInfo = null;
PageInfo pageInfo = null;
GraphData graphData = null;
try {
BufferedReader in = new BufferedReader(new FileReader(
groupConfigFilePath));
@ -1664,7 +1664,148 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
if (str.trim().equals("")) {
continue;
}
processGroupData(str);
boolean showpp_flag = false;
// Remove any leading whitespace
String line = str.replaceAll("^\\s+", "");
if (line.startsWith(GROUP)) {
groupInfo = new GroupInfo();
groupInfo.setGroupSelected(true);
groupList.add(groupInfo);
}
String[] parts = line.split(":");
if (parts[0].equals(GROUP)) {
String[] pairs = parts[1].split(",");
for (String s : pairs) {
String[] values = s.split("=", 2);
// make sure we have values to go with the key
if (values.length > 1) {
if ((values[0] != null)
&& values[0].equalsIgnoreCase(NAME)) {
if (values[1] != null)
groupInfo.setGroupName(values[1]);
groupDataList.add(groupInfo.getGroupName());
} else if (values[0].equalsIgnoreCase(DESCRIPT)) {
groupInfo.setDescription(values[1]);
} else if (values[0].equalsIgnoreCase(GRID)) {
if (values[1].equalsIgnoreCase("T")) {
groupInfo.setGridLines(true);
} else {
groupInfo.setGridLines(false);
}
} else if (values[0].equalsIgnoreCase(TRACEMODE)) {
groupInfo.setTraceMode(values[1]);
} else if (values[0].equalsIgnoreCase(PASTHOURS)) {
groupInfo.setPastHours(Integer
.parseInt(values[1]));
} else if (values[0].equalsIgnoreCase(FUTUREHOURS)) {
groupInfo.setFutureHours(Integer
.parseInt(values[1]));
} else {
statusHandler.warn("Invalid key/value pair: "
+ s);
}
}
}
} else if (parts[0].equals(PAGE)) {
String[] values = parts[1].split("=", 2);
if (values.length > 1) {
pageInfo = new PageInfo();
pageInfo.setTitle(values[1]);
groupInfo.addPageInfo(pageInfo);
}
} else if (parts[0].equals(GRAPH)) {
graphData = new GraphData();
String[] pairs = parts[1].split(",");
for (String s : pairs) {
String[] values = s.split("=", 2);
if (values.length > 1) {
if (values[0].equalsIgnoreCase(POS)) {
graphData.setGraph_pos(Integer
.parseInt(values[1]));
} else if (values[0].equalsIgnoreCase(XSIZE)) {
graphData.setXsize(Integer.parseInt(values[1]));
} else if (values[0].equalsIgnoreCase(YSIZE)) {
graphData.setYsize(Integer.parseInt(values[1]));
} else if (values[0].equalsIgnoreCase(YLINEAR)) {
graphData.setYlinear(values[1]);
} else if (values[0].equalsIgnoreCase(YSCALE)) {
graphData.setYscale(values[1]);
} else if (values[0].equalsIgnoreCase(SHOWCAT)) {
if (values[1].equalsIgnoreCase("T")) {
graphData.setShowcat(true);
} else {
graphData.setShowcat(false);
}
} else if (values[0].equalsIgnoreCase(DERIVEPP)) {
graphData.setDerivepp(values[1]);
} else if (values[0].equalsIgnoreCase(SHOWPP)) {
if (values[1].equalsIgnoreCase("T")) {
showpp_flag = true;
} else {
showpp_flag = false;
}
} else if (values[0]
.equalsIgnoreCase(LATESTFCSTONLY)) {
if (values[1].equalsIgnoreCase("T")) {
graphData.setLatestfcstonly(true);
} else {
graphData.setLatestfcstonly(false);
}
} else {
statusHandler.warn("Invalid key/value pair: "
+ s);
}
}
}
// handle the case where there isn't a page element when
// there should be
if (pageInfo == null) {
pageInfo = new PageInfo();
groupInfo.addPageInfo(pageInfo);
}
pageInfo.addGraphData(graphData);
} else if (parts[0].equals(TRACE)) {
TraceData td = new TraceData();
String[] pairs = parts[1].split(",");
for (String s : pairs) {
String[] values = s.split("=", 2);
if (values.length > 1) {
if (values[0].equalsIgnoreCase(STN)) {
td.setLid(values[1]);
} else if (values[0]
.equalsIgnoreCase(HydroConstants.PC)) {
td.setPc(values[1]);
if (showpp_flag == true)
graphData.setShowpp(true);
else
graphData.setShowpp(false);
} else if (values[0].equalsIgnoreCase(COLOR)) {
td.setColorName(values[1]);
}
}
}
graphData.addTrace(td);
graphData.setBeginDate(beginDate);
graphData.setEndDate(endDate);
} else {
statusHandler
.warn("Error in Group Definition Config file: "
+ line);
}
// select the first item in the list
if (groupDataList.getItemCount() > 0) {
groupDataList.select(0);
}
}
in.close();
} catch (IOException e) {
@ -1831,7 +1972,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
}
}
// Reset the siteInfoList selections
// Reset the selections
int selectedIndex = bottomDataList.getSelectionIndex();
for (int i = 0; i < siteInfoList.size(); i++) {
@ -1893,144 +2034,6 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
timeSeriesDisplayDlg.getShell().moveAbove(this.shell);
}
/**
* Process the lines in the group config file.
*
* @param line
*/
private void processGroupData(String line) {
Boolean showpp_flag = false;
// Remove any leading whitespace
line = line.replaceAll("^\\s+", "");
if (line.startsWith(GROUP)) {
groupInfo = new GroupInfo();
groupInfo.setGroupSelected(true);
groupList.add(groupInfo);
}
String[] parts = line.split(":");
if (parts[0].equals(GROUP)) {
String[] pairs = parts[1].split(",");
for (String s : pairs) {
String[] values = s.split("=", 2);
// make sure we have values to go with the key
if (values.length > 1) {
if ((values[0] != null) && values[0].equalsIgnoreCase(NAME)) {
if (values[1] != null)
groupInfo.setGroupName(values[1]);
groupDataList.add(groupInfo.getGroupName());
} else if (values[0].equalsIgnoreCase(DESCRIPT)) {
groupInfo.setDescription(values[1]);
} else if (values[0].equalsIgnoreCase(GRID)) {
if (values[1].equalsIgnoreCase("T")) {
groupInfo.setGridLines(true);
} else {
groupInfo.setGridLines(false);
}
} else if (values[0].equalsIgnoreCase(TRACEMODE)) {
groupInfo.setTraceMode(values[1]);
} else if (values[0].equalsIgnoreCase(PASTHOURS)) {
groupInfo.setPastHours(Integer.parseInt(values[1]));
} else if (values[0].equalsIgnoreCase(FUTUREHOURS)) {
groupInfo.setFutureHours(Integer.parseInt(values[1]));
} else {
statusHandler.warn("Invalid key/value pair: " + s);
}
}
}
} else if (parts[0].equals(PAGE)) {
String[] values = parts[1].split("=", 2);
if (values.length > 1) {
pageInfo = new PageInfo();
pageInfo.setTitle(values[1]);
groupInfo.addPageInfo(pageInfo);
}
} else if (parts[0].equals(GRAPH)) {
graphData = new GraphData();
String[] pairs = parts[1].split(",");
for (String s : pairs) {
String[] values = s.split("=", 2);
if (values.length > 1) {
if (values[0].equalsIgnoreCase(POS)) {
graphData.setGraph_pos(Integer.parseInt(values[1]));
} else if (values[0].equalsIgnoreCase(XSIZE)) {
graphData.setXsize(Integer.parseInt(values[1]));
} else if (values[0].equalsIgnoreCase(YSIZE)) {
graphData.setYsize(Integer.parseInt(values[1]));
} else if (values[0].equalsIgnoreCase(YLINEAR)) {
graphData.setYlinear(values[1]);
} else if (values[0].equalsIgnoreCase(YSCALE)) {
graphData.setYscale(values[1]);
} else if (values[0].equalsIgnoreCase(SHOWCAT)) {
if (values[1].equalsIgnoreCase("T")) {
graphData.setShowcat(true);
} else {
graphData.setShowcat(false);
}
} else if (values[0].equalsIgnoreCase(DERIVEPP)) {
graphData.setDerivepp(values[1]);
} else if (values[0].equalsIgnoreCase(SHOWPP)) {
if (values[1].equalsIgnoreCase("T")) {
showpp_flag = true;
} else {
showpp_flag = false;
}
} else if (values[0].equalsIgnoreCase(LATESTFCSTONLY)) {
if (values[1].equalsIgnoreCase("T")) {
graphData.setLatestfcstonly(true);
} else {
graphData.setLatestfcstonly(false);
}
} else {
statusHandler.warn("Invalid key/value pair: " + s);
}
}
}
// handle the case where there isn't a page element when
// there should be
if (pageInfo == null) {
pageInfo = new PageInfo();
}
pageInfo.addGraphData(graphData);
} else if (parts[0].equals(TRACE)) {
TraceData td = new TraceData();
String[] pairs = parts[1].split(",");
for (String s : pairs) {
String[] values = s.split("=", 2);
if (values.length > 1) {
if (values[0].equalsIgnoreCase(STN)) {
td.setLid(values[1]);
} else if (values[0].equalsIgnoreCase(HydroConstants.PC)) {
td.setPc(values[1]);
if (showpp_flag == true)
graphData.setShowpp(true);
else
graphData.setShowpp(false);
} else if (values[0].equalsIgnoreCase(COLOR)) {
td.setColorName(values[1]);
}
}
}
graphData.addTrace(td);
graphData.setBeginDate(beginDate);
graphData.setEndDate(endDate);
} else {
statusHandler
.warn("Error in Group Definition Config file: " + line);
}
// select the first item in the list
if (groupDataList.getItemCount() > 0) {
groupDataList.select(0);
}
}
/**
* Handle Table option when selected on the Time Series Control Dialog
*/
@ -2062,7 +2065,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
/* Set up the GraphData objects */
if (modeCbo.getText().equals(STATION_SELECTION)) {
groupInfo = new GroupInfo();
GroupInfo groupInfo = new GroupInfo();
groupInfo.setCurrentPage(0);
/* Get the data from the station list */
@ -2096,7 +2099,8 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
} else {
/* Set the group info object */
groupInfo = groupList.get(groupDataList.getSelectionIndex());
GroupInfo groupInfo = groupList.get(groupDataList
.getSelectionIndex());
tabularDlg.setGroupInfo(groupInfo);
for (PageInfo pi : groupInfo.getPageInfoList()) {
@ -2151,7 +2155,7 @@ public class TimeSeriesDlg extends CaveHydroSWTDialog {
/* Set up the GraphData objects */
if (modeCbo.getText().equals(STATION_SELECTION)) {
int numberGraphs = 1;
groupInfo = new GroupInfo();
GroupInfo groupInfo = new GroupInfo();
groupInfo.setCurrentPage(0);
/* Get the data from the station list */

View file

@ -21,6 +21,7 @@ package com.raytheon.viz.hydro.timeseries.util;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.raytheon.viz.hydrocommon.HydroConstants;
@ -28,62 +29,68 @@ import com.raytheon.viz.hydrocommon.HydroConstants;
* Object to hold the data and metadata for the time series.
*
* <pre>
*
*
* SOFTWARE HISTORY
*
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 24, 2008 mpduff Initial creation
* Jun 24, 2008 mpduff Initial creation.
* May 06, 2013 1976 mpduff Use List interface.
*
* </pre>
*
*
* @author mpduff
* @version 1.0
* @version 1.0
*/
public class GraphData {
public class GraphData {
private double x;
/**
* yMax - yMin
*/
private double y;
private double y2;
/**
* Graph Area Width
*/
private int w;
/**
* Graph Area Height
*/
private int h;
private boolean displayFlowUnit;
private Date xMin;
private Date xMax;
private double ymin = Integer.MAX_VALUE;
private double ymax = Integer.MIN_VALUE;
private double ymin2;
private double ymax2;
/**
* List of traces for graphing
*/
private ArrayList<TraceData> traces = new ArrayList<TraceData>();
private List<TraceData> traces = new ArrayList<TraceData>();
/**
* List of traces for this graphing object
*/
private ArrayList<TraceData> originalTraces = new ArrayList<TraceData>();
private ArrayList<Boolean> isStage = new ArrayList<Boolean>();
private final List<TraceData> originalTraces = new ArrayList<TraceData>();
private List<Boolean> isStage = new ArrayList<Boolean>();
private Date beginDate = null;
private Date endDate = null;
private String title = null;
@ -119,16 +126,25 @@ public class GraphData {
private String showppc = null;
private String latestfcstonlyc = null;
private double actionStage = -9999;
private double floodStage = -9999;
private double minorStage = -9999;
private double moderateStage = -9999;
private double majorStage = -9999;
private double actionFlow = -9999;
private double floodFlow = -9999;
private double minorFlow = -9999;
private double moderateFlow = -9999;
private double majorFlow = -9999;
/**
@ -139,7 +155,8 @@ public class GraphData {
}
/**
* @param x the x to set
* @param x
* the x to set
*/
public void setX(double x) {
this.x = x;
@ -154,7 +171,9 @@ public class GraphData {
/**
* y = yMax - yMin
* @param y the y to set
*
* @param y
* the y to set
*/
public void setY(double y) {
this.y = y;
@ -168,7 +187,8 @@ public class GraphData {
}
/**
* @param w the w to set
* @param w
* the w to set
*/
public void setW(int w) {
this.w = w;
@ -182,7 +202,8 @@ public class GraphData {
}
/**
* @param h the h to set
* @param h
* the h to set
*/
public void setH(int h) {
this.h = h;
@ -203,7 +224,8 @@ public class GraphData {
}
/**
* @param display_flow_unit the display_flow_unit to set
* @param display_flow_unit
* the display_flow_unit to set
*/
public void setDisplayFlowUnit(boolean displayFlowUnit) {
this.displayFlowUnit = displayFlowUnit;
@ -217,7 +239,8 @@ public class GraphData {
}
/**
* @param min the xMin to set
* @param min
* the xMin to set
*/
public void setXMin(Date min) {
xMin = min;
@ -231,68 +254,13 @@ public class GraphData {
}
/**
* @param max the xMax to set
* @param max
* the xMax to set
*/
public void setXMax(Date max) {
xMax = max;
}
// /**
// * @return the oldXMax
// */
// public Date getOldXMax() {
// return oldXMax;
// }
//
// /**
// * @param oldXMax the oldXMax to set
// */
// public void setOldXMax(Date oldXMax) {
// this.oldXMax = oldXMax;
// }
//
// /**
// * @return the oldXMin
// */
// public Date getOldXMin() {
// return oldXMin;
// }
//
// /**
// * @param oldXMin the oldXMin to set
// */
// public void setOldXMin(Date oldXMin) {
// this.oldXMin = oldXMin;
// }
//
// /**
// * @return the orgXMax
// */
// public Date getOrgXMax() {
// return orgXMax;
// }
//
// /**
// * @param orgXMax the orgXMax to set
// */
// public void setOrgXMax(Date orgXMax) {
// this.orgXMax = orgXMax;
// }
//
// /**
// * @return the orgXMin
// */
// public Date getOrgXMin() {
// return orgXMin;
// }
//
// /**
// * @param orgXMin the orgXMin to set
// */
// public void setOrgXMin(Date orgXMin) {
// this.orgXMin = orgXMin;
// }
/**
* @return the ymin
*/
@ -301,7 +269,8 @@ public class GraphData {
}
/**
* @param ymin the ymin to set
* @param ymin
* the ymin to set
*/
public void setYmin(double ymin) {
this.ymin = ymin;
@ -315,7 +284,8 @@ public class GraphData {
}
/**
* @param ymax the ymax to set
* @param ymax
* the ymax to set
*/
public void setYmax(double ymax) {
this.ymax = ymax;
@ -324,21 +294,22 @@ public class GraphData {
/**
* @return the traces
*/
public ArrayList<TraceData> getTraces() {
public List<TraceData> getTraces() {
return traces;
}
public TraceData getTraceData(int index) {
return traces.get(index);
}
/**
* @param traces the traces to set
* @param traces
* the traces to set
*/
public void setTraces(ArrayList<TraceData> traces) {
public void setTraces(List<TraceData> traces) {
this.traces = traces;
}
public void addTrace(TraceData trace) {
if (traces.size() < HydroConstants.MAX_TRACES) {
if (!traces.contains(trace)) {
@ -350,12 +321,13 @@ public class GraphData {
/**
* @return the isStage
*/
public ArrayList<Boolean> getIsStage() {
public List<Boolean> getIsStage() {
return isStage;
}
/**
* @param isStage the isStage to set
* @param isStage
* the isStage to set
*/
public void setIsStage(ArrayList<Boolean> isStage) {
this.isStage = isStage;
@ -364,7 +336,8 @@ public class GraphData {
/**
* Add the isStage boolean value to the list
*
* @param isStage true if value is stage, false otherwise
* @param isStage
* true if value is stage, false otherwise
*/
public void addIsStage(boolean isStage) {
if (traces.size() < HydroConstants.MAX_TRACES) {
@ -380,7 +353,8 @@ public class GraphData {
}
/**
* @param beginCal the beginCal to set
* @param beginCal
* the beginCal to set
*/
public void setBeginDate(Date beginDate) {
this.beginDate = beginDate;
@ -394,7 +368,8 @@ public class GraphData {
}
/**
* @param endCal the endCal to set
* @param endCal
* the endCal to set
*/
public void setEndDate(Date endDate) {
this.endDate = endDate;
@ -408,7 +383,8 @@ public class GraphData {
}
/**
* @param title the title to set
* @param title
* the title to set
*/
public void setTitle(String title) {
this.title = title;
@ -422,7 +398,8 @@ public class GraphData {
}
/**
* @param num_traces the num_traces to set
* @param num_traces
* the num_traces to set
*/
public void setNum_traces(int num_traces) {
this.num_traces = num_traces;
@ -436,7 +413,8 @@ public class GraphData {
}
/**
* @param graph_pos the graph_pos to set
* @param graph_pos
* the graph_pos to set
*/
public void setGraph_pos(int graph_pos) {
this.graph_pos = graph_pos;
@ -450,7 +428,8 @@ public class GraphData {
}
/**
* @param xsize the xsize to set
* @param xsize
* the xsize to set
*/
public void setXsize(int xsize) {
this.xsize = xsize;
@ -464,7 +443,8 @@ public class GraphData {
}
/**
* @param ysize the ysize to set
* @param ysize
* the ysize to set
*/
public void setYsize(int ysize) {
this.ysize = ysize;
@ -478,7 +458,8 @@ public class GraphData {
}
/**
* @param yscale the yscale to set
* @param yscale
* the yscale to set
*/
public void setYscale(String yscale) {
this.yscale = yscale;
@ -492,7 +473,8 @@ public class GraphData {
}
/**
* @param ylinear the ylinear to set
* @param ylinear
* the ylinear to set
*/
public void setYlinear(String ylinear) {
this.ylinear = ylinear;
@ -506,7 +488,8 @@ public class GraphData {
}
/**
* @param showcat the showcat to set
* @param showcat
* the showcat to set
*/
public void setShowcat(boolean showcat) {
this.showcat = showcat;
@ -520,7 +503,8 @@ public class GraphData {
}
/**
* @param derivepp the derivepp to set
* @param derivepp
* the derivepp to set
*/
public void setDerivepp(String derivepp) {
this.derivepp = derivepp;
@ -534,7 +518,8 @@ public class GraphData {
}
/**
* @param showpp the showpp to set
* @param showpp
* the showpp to set
*/
public void setShowpp(boolean showpp) {
this.showpp = showpp;
@ -548,7 +533,8 @@ public class GraphData {
}
/**
* @param latestfcstonly the latestfcstonly to set
* @param latestfcstonly
* the latestfcstonly to set
*/
public void setLatestfcstonly(boolean latestfcstonly) {
this.latestfcstonly = latestfcstonly;
@ -562,7 +548,8 @@ public class GraphData {
}
/**
* @param ylinearc the ylinearc to set
* @param ylinearc
* the ylinearc to set
*/
public void setYlinearc(String ylinearc) {
this.ylinearc = ylinearc;
@ -576,7 +563,8 @@ public class GraphData {
}
/**
* @param yscalec the yscalec to set
* @param yscalec
* the yscalec to set
*/
public void setYscalec(String yscalec) {
this.yscalec = yscalec;
@ -590,7 +578,8 @@ public class GraphData {
}
/**
* @param showcatc the showcatc to set
* @param showcatc
* the showcatc to set
*/
public void setShowcatc(String showcatc) {
this.showcatc = showcatc;
@ -604,7 +593,8 @@ public class GraphData {
}
/**
* @param deriveppc the deriveppc to set
* @param deriveppc
* the deriveppc to set
*/
public void setDeriveppc(String deriveppc) {
this.deriveppc = deriveppc;
@ -618,7 +608,8 @@ public class GraphData {
}
/**
* @param showppc the showppc to set
* @param showppc
* the showppc to set
*/
public void setShowppc(String showppc) {
this.showppc = showppc;
@ -632,7 +623,8 @@ public class GraphData {
}
/**
* @param latestfcstonlyc the latestfcstonlyc to set
* @param latestfcstonlyc
* the latestfcstonlyc to set
*/
public void setLatestfcstonlyc(String latestfcstonlyc) {
this.latestfcstonlyc = latestfcstonlyc;
@ -651,7 +643,8 @@ public class GraphData {
}
/**
* @param actionStage the actionStage to set
* @param actionStage
* the actionStage to set
*/
public void setActionStage(double actionStage) {
this.actionStage = actionStage;
@ -665,7 +658,8 @@ public class GraphData {
}
/**
* @param minorStage the minorStage to set
* @param minorStage
* the minorStage to set
*/
public void setMinorStage(double minorStage) {
this.minorStage = minorStage;
@ -679,7 +673,8 @@ public class GraphData {
}
/**
* @param moderateStage the moderateStage to set
* @param moderateStage
* the moderateStage to set
*/
public void setModerateStage(double moderateStage) {
this.moderateStage = moderateStage;
@ -693,7 +688,8 @@ public class GraphData {
}
/**
* @param majorStage the majorStage to set
* @param majorStage
* the majorStage to set
*/
public void setMajorStage(double majorStage) {
this.majorStage = majorStage;
@ -707,7 +703,8 @@ public class GraphData {
}
/**
* @param actionFlow the actionFlow to set
* @param actionFlow
* the actionFlow to set
*/
public void setActionFlow(double actionFlow) {
this.actionFlow = actionFlow;
@ -721,7 +718,8 @@ public class GraphData {
}
/**
* @param minorFlow the minorFlow to set
* @param minorFlow
* the minorFlow to set
*/
public void setMinorFlow(double minorFlow) {
this.minorFlow = minorFlow;
@ -735,7 +733,8 @@ public class GraphData {
}
/**
* @param moderateFlow the moderateFlow to set
* @param moderateFlow
* the moderateFlow to set
*/
public void setModerateFlow(double moderateFlow) {
this.moderateFlow = moderateFlow;
@ -749,7 +748,8 @@ public class GraphData {
}
/**
* @param majorFlow the majorFlow to set
* @param majorFlow
* the majorFlow to set
*/
public void setMajorFlow(double majorFlow) {
this.majorFlow = majorFlow;
@ -763,7 +763,8 @@ public class GraphData {
}
/**
* @param floodStage the floodStage to set
* @param floodStage
* the floodStage to set
*/
public void setFloodStage(double floodStage) {
this.floodStage = floodStage;
@ -777,7 +778,8 @@ public class GraphData {
}
/**
* @param floodFlow the floodFlow to set
* @param floodFlow
* the floodFlow to set
*/
public void setFloodFlow(double floodFlow) {
this.floodFlow = floodFlow;
@ -791,7 +793,8 @@ public class GraphData {
}
/**
* @param ymin2 the ymin2 to set
* @param ymin2
* the ymin2 to set
*/
public void setYmin2(double ymin2) {
this.ymin2 = ymin2;
@ -805,7 +808,8 @@ public class GraphData {
}
/**
* @param ymax2 the ymax2 to set
* @param ymax2
* the ymax2 to set
*/
public void setYmax2(double ymax2) {
this.ymax2 = ymax2;
@ -819,7 +823,8 @@ public class GraphData {
}
/**
* @param y2 the y2 to set
* @param y2
* the y2 to set
*/
public void setY2(double y2) {
this.y2 = y2;
@ -828,21 +833,22 @@ public class GraphData {
/**
* @return the originalTraces
*/
public ArrayList<TraceData> getOriginalTraces() {
ArrayList<TraceData> rtnList = new ArrayList<TraceData>(originalTraces.size());
for (TraceData td: originalTraces) {
public List<TraceData> getOriginalTraces() {
List<TraceData> rtnList = new ArrayList<TraceData>(
originalTraces.size());
for (TraceData td : originalTraces) {
TraceData data = new TraceData(td);
rtnList.add(data);
}
return rtnList;
}
/**
* Generate a copy of the original trace data.
*/
public void saveTraceInfo() {
for (TraceData td: traces) {
for (TraceData td : traces) {
TraceData data = new TraceData(td);
originalTraces.add(data);
}