Issue #2332 - fixed graph memory leaks
Change-Id: I298df2996d5a5c12ca3216659691741fe97277f5 Former-commit-id:4cb05eca7c
[formerlyd29663ddb8
] [formerlyfa972943ce
] [formerly4cb05eca7c
[formerlyd29663ddb8
] [formerlyfa972943ce
] [formerlyc7c8efe65f
[formerlyfa972943ce
[formerly ab943585c58005575f6497575a882e9a4054d38c]]]] Former-commit-id:c7c8efe65f
Former-commit-id:56a010b487
[formerlye86a5d8620
] [formerly 95bce9603270a38ab5e87c55f922e548ed28a396 [formerly1bc4fd1099
]] Former-commit-id: c62048007bbe1d904c5bac67e0412ef030b6a6a9 [formerly9071f715fc
] Former-commit-id:5facc63c17
This commit is contained in:
parent
6f5f98f2ab
commit
3714ab9b50
2 changed files with 83 additions and 61 deletions
|
@ -138,7 +138,8 @@ import com.raytheon.viz.hydrocommon.util.DbUtils;
|
|||
* 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.
|
||||
* 29 May 2013 2016 mpduff Fix TS Toggle Traces.
|
||||
* 29 May 2013 2016 mpduff Fix TS Toggle Traces.
|
||||
* 05 Sep 2013 #2332 lvenable Fixed memory leaks.
|
||||
* @author lvenable
|
||||
* @version 1.0
|
||||
*
|
||||
|
@ -165,7 +166,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
|
|||
/**
|
||||
* No Data Available string.
|
||||
*/
|
||||
private static final String NO_DATA_AVAILABLE = "NO DATA AVAILABLE";
|
||||
private final String NO_DATA_AVAILABLE = "NO DATA AVAILABLE";
|
||||
|
||||
/** Location ID */
|
||||
private String lid = null;
|
||||
|
@ -234,17 +235,17 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
|
|||
/**
|
||||
* List of regions for a single trace
|
||||
*/
|
||||
private final ArrayList<Region> regionList = new ArrayList<Region>();
|
||||
private final List<Region> regionList = new ArrayList<Region>();
|
||||
|
||||
/**
|
||||
* List of Region Lists
|
||||
*/
|
||||
private final ArrayList<ArrayList<Region>> listRegionList = new ArrayList<ArrayList<Region>>();
|
||||
private final List<List<Region>> listRegionList = new ArrayList<List<Region>>();
|
||||
|
||||
/**
|
||||
* List of regions for points for each trace
|
||||
*/
|
||||
private final ArrayList<ArrayList<Region>> pointList = new ArrayList<ArrayList<Region>>();
|
||||
private final List<List<Region>> pointList = new ArrayList<List<Region>>();
|
||||
|
||||
/**
|
||||
* Is a point selected?
|
||||
|
@ -328,11 +329,6 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
|
|||
/** Graph display Date Format MM/dd/yy HH 'z' */
|
||||
public SimpleDateFormat graphFormat;
|
||||
|
||||
/**
|
||||
* List of graph traces that are available.
|
||||
*/
|
||||
private ArrayList<Boolean> validGraph;
|
||||
|
||||
/**
|
||||
* Show Latest Forecast flag.
|
||||
*/
|
||||
|
@ -483,6 +479,8 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
|
|||
if ((canvasFont != null) && (canvasFont.isDisposed() == false)) {
|
||||
canvasFont.dispose();
|
||||
}
|
||||
|
||||
disposeRegions();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1143,7 +1141,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
|
|||
}
|
||||
|
||||
if (points != null) {
|
||||
ArrayList<TimeSeriesPoint> pointList = new ArrayList<TimeSeriesPoint>();
|
||||
List<TimeSeriesPoint> pointList = new ArrayList<TimeSeriesPoint>();
|
||||
/* Delete the specified point */
|
||||
if ((deleteList.size() > 0) && (i == selectedTraceId)) {
|
||||
for (int j = 0; j < points.length; j++) {
|
||||
|
@ -1623,7 +1621,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
|
|||
} else if (dialog.isSelectMove() && traceSelected && !pointSelected) {
|
||||
// This catches the move event before point is selected
|
||||
if (!precipPE) {
|
||||
ArrayList<Region> prl = pointList.get(selectedTraceId);
|
||||
List<Region> prl = pointList.get(selectedTraceId);
|
||||
for (int i = 0; i < prl.size(); i++) {
|
||||
if (prl.get(i).contains(e.x, e.y)) {
|
||||
setCursor(northSouthCursor);
|
||||
|
@ -1634,7 +1632,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
|
|||
}
|
||||
}
|
||||
} else {
|
||||
ArrayList<Region> ppl = precipPointList.get(selectedTraceId);
|
||||
List<Region> ppl = precipPointList.get(selectedTraceId);
|
||||
for (int i = 0; i < ppl.size(); i++) {
|
||||
if (ppl.get(i).contains(e.x, e.y)) {
|
||||
setCursor(northSouthCursor);
|
||||
|
@ -1654,8 +1652,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
|
|||
redraw();
|
||||
} else {
|
||||
if (precipPE) {
|
||||
ArrayList<Region> ppl = precipPointList
|
||||
.get(selectedTraceId);
|
||||
List<Region> ppl = precipPointList.get(selectedTraceId);
|
||||
for (int i = 0; i < ppl.size(); i++) {
|
||||
if (ppl.get(i).contains(e.x, e.y)) {
|
||||
setCursor(northSouthCursor);
|
||||
|
@ -1666,7 +1663,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
|
|||
}
|
||||
}
|
||||
} else {
|
||||
ArrayList<Region> prl = pointList.get(selectedTraceId);
|
||||
List<Region> prl = pointList.get(selectedTraceId);
|
||||
for (int i = 0; i < prl.size(); i++) {
|
||||
if (prl.get(i).contains(e.x, e.y)) {
|
||||
setCursor(handCursor);
|
||||
|
@ -1687,8 +1684,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
|
|||
redraw();
|
||||
} else {
|
||||
if (precipPE) {
|
||||
ArrayList<Region> ppl = precipPointList
|
||||
.get(selectedTraceId);
|
||||
List<Region> ppl = precipPointList.get(selectedTraceId);
|
||||
for (int i = 0; i < ppl.size(); i++) {
|
||||
if (ppl.get(i).contains(e.x, e.y)) {
|
||||
setCursor(handCursor);
|
||||
|
@ -1699,7 +1695,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
|
|||
}
|
||||
}
|
||||
} else {
|
||||
ArrayList<Region> prl = pointList.get(selectedTraceId);
|
||||
List<Region> prl = pointList.get(selectedTraceId);
|
||||
for (int i = 0; i < prl.size(); i++) {
|
||||
if (prl.get(i).contains(e.x, e.y)) {
|
||||
setCursor(handCursor);
|
||||
|
@ -1898,7 +1894,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
|
|||
} else if (traceSelected && dialog.isSelectMove()) {
|
||||
// loop to see if a dot is selected
|
||||
if (precipPE) {
|
||||
ArrayList<Region> prl = precipPointList.get(selectedTraceId);
|
||||
List<Region> prl = precipPointList.get(selectedTraceId);
|
||||
for (int i = 0; i < prl.size(); i++) {
|
||||
if (prl.get(i).contains(e.x, e.y)) {
|
||||
setCursor(northSouthCursor);
|
||||
|
@ -1910,7 +1906,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
|
|||
}
|
||||
}
|
||||
} else {
|
||||
ArrayList<Region> prl = pointList.get(selectedTraceId);
|
||||
List<Region> prl = pointList.get(selectedTraceId);
|
||||
for (int i = 0; i < prl.size(); i++) {
|
||||
if (prl.get(i).contains(e.x, e.y)) {
|
||||
setCursor(northSouthCursor);
|
||||
|
@ -1924,7 +1920,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
|
|||
}
|
||||
} else if (traceSelected && dialog.isDelete()) {
|
||||
if (precipPE) {
|
||||
ArrayList<Region> ppl = precipPointList.get(selectedTraceId);
|
||||
List<Region> ppl = precipPointList.get(selectedTraceId);
|
||||
for (int i = 0; i < ppl.size(); i++) {
|
||||
if (ppl.get(i).contains(e.x, e.y)) {
|
||||
deleteIndex = i;
|
||||
|
@ -1933,7 +1929,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
|
|||
}
|
||||
}
|
||||
} else {
|
||||
ArrayList<Region> prl = pointList.get(selectedTraceId);
|
||||
List<Region> prl = pointList.get(selectedTraceId);
|
||||
for (int i = 0; i < prl.size(); i++) {
|
||||
if (prl.get(i).contains(e.x, e.y)) {
|
||||
deleteIndex = i;
|
||||
|
@ -1956,7 +1952,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
|
|||
}
|
||||
} else if (traceSelected && dialog.isSetMissing()) {
|
||||
if (precipPE) {
|
||||
ArrayList<Region> ppl = precipPointList.get(selectedTraceId);
|
||||
List<Region> ppl = precipPointList.get(selectedTraceId);
|
||||
for (int i = 0; i < ppl.size(); i++) {
|
||||
if (ppl.get(i).contains(e.x, e.y)) {
|
||||
setMissingIndex = i;
|
||||
|
@ -1965,7 +1961,7 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
|
|||
}
|
||||
}
|
||||
} else {
|
||||
ArrayList<Region> prl = pointList.get(selectedTraceId);
|
||||
List<Region> prl = pointList.get(selectedTraceId);
|
||||
for (int i = 0; i < prl.size(); i++) {
|
||||
if (prl.get(i).contains(e.x, e.y)) {
|
||||
setMissingIndex = i;
|
||||
|
@ -2176,29 +2172,9 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
|
|||
*/
|
||||
private void makeRegions(List<TraceData> traceList) {
|
||||
if (createRegions == true) {
|
||||
|
||||
/* Dispose of the previous regions */
|
||||
for (Region r : regionList) {
|
||||
if (r.isDisposed() == false) {
|
||||
r.dispose();
|
||||
}
|
||||
}
|
||||
for (ArrayList<Region> al : pointList) {
|
||||
for (Region r : al) {
|
||||
if (r.isDisposed() == false) {
|
||||
r.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
for (ArrayList<Region> al : listRegionList) {
|
||||
for (Region r : al) {
|
||||
if (r.isDisposed() == false) {
|
||||
r.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
regionList.clear();
|
||||
pointList.clear();
|
||||
listRegionList.clear();
|
||||
disposeRegions();
|
||||
|
||||
int dy = 15;
|
||||
|
||||
|
@ -2278,6 +2254,31 @@ public class TimeSeriesDisplayCanvas extends TimeSeriesGraphCanvas implements
|
|||
}
|
||||
}
|
||||
|
||||
private void disposeRegions() {
|
||||
for (Region r : regionList) {
|
||||
if (r.isDisposed() == false) {
|
||||
r.dispose();
|
||||
}
|
||||
}
|
||||
for (List<Region> al : pointList) {
|
||||
for (Region r : al) {
|
||||
if (r.isDisposed() == false) {
|
||||
r.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
for (List<Region> al : listRegionList) {
|
||||
for (Region r : al) {
|
||||
if (r.isDisposed() == false) {
|
||||
r.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
regionList.clear();
|
||||
pointList.clear();
|
||||
listRegionList.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the point array to be drawn.
|
||||
*
|
||||
|
|
|
@ -24,9 +24,12 @@ import java.text.NumberFormat;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.DisposeEvent;
|
||||
import org.eclipse.swt.events.DisposeListener;
|
||||
import org.eclipse.swt.graphics.Color;
|
||||
import org.eclipse.swt.graphics.Cursor;
|
||||
import org.eclipse.swt.graphics.Font;
|
||||
|
@ -54,18 +57,19 @@ import com.raytheon.viz.hydrocommon.HydroConstants;
|
|||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 12, 2008 1519 mpduff Initial creation
|
||||
* Jan 26, 2011 5557 bkowal Finished the implementation of
|
||||
* "Reverse Video" printing.
|
||||
* Feb 03, 2011 8085 mpduff Modified the trace line to circle
|
||||
* around the point.
|
||||
* Apr 18, 2011 8963 jpiatt Removed Left Scale call to scale manager.
|
||||
* July 12 2011 9709 djingtao draw right Y axis for showPP is true. add new
|
||||
* function adjust_pcymax()
|
||||
* Aug. 10, 2011 10457 djingtao allow the red rubberband box to be drawn for setMissing in Edit
|
||||
* Jul. 24, 2012 15195 mpduff Fix x axis scales.
|
||||
* 06 Nov 2012 15399 wkwock Fix refine the plot algorithm and sampling algorithm
|
||||
* May 06, 2013 1976 mpduff Code cleanup
|
||||
* Sep 12, 2008 1519 mpduff Initial creation
|
||||
* Jan 26, 2011 5557 bkowal Finished the implementation of
|
||||
* "Reverse Video" printing.
|
||||
* Feb 03, 2011 8085 mpduff Modified the trace line to circle
|
||||
* around the point.
|
||||
* Apr 18, 2011 8963 jpiatt Removed Left Scale call to scale manager.
|
||||
* July 12 2011 9709 djingtao draw right Y axis for showPP is true. add new
|
||||
* function adjust_pcymax()
|
||||
* Aug 10, 2011 10457 djingtao allow the red rubberband box to be drawn for setMissing in Edit
|
||||
* Jul 24, 2012 15195 mpduff Fix x axis scales.
|
||||
* 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.
|
||||
* </pre>
|
||||
*
|
||||
* @author mpduff
|
||||
|
@ -173,9 +177,9 @@ public class TimeSeriesGraphCanvas extends Canvas {
|
|||
/* Flag for selection of 1hr PC as PP */
|
||||
protected boolean showPP = false;
|
||||
|
||||
protected ArrayList<Region> precipRegions = new ArrayList<Region>();
|
||||
protected final List<Region> precipRegions = new ArrayList<Region>();
|
||||
|
||||
protected ArrayList<ArrayList<Region>> precipPointList = new ArrayList<ArrayList<Region>>();
|
||||
protected final List<List<Region>> precipPointList = new ArrayList<List<Region>>();
|
||||
|
||||
protected int currentX;
|
||||
|
||||
|
@ -222,6 +226,23 @@ public class TimeSeriesGraphCanvas extends Canvas {
|
|||
public TimeSeriesGraphCanvas(Composite parent, int style) {
|
||||
super(parent, style);
|
||||
parentComp = parent;
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize method.
|
||||
*/
|
||||
private void init() {
|
||||
this.addDisposeListener(new DisposeListener() {
|
||||
|
||||
@Override
|
||||
public void widgetDisposed(DisposeEvent e) {
|
||||
if (currentTraceColor != null
|
||||
&& currentTraceColor.isDisposed() == false) {
|
||||
currentTraceColor.dispose();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue