Merge "Issue #2406 - fixed color memory leaks." into development

Former-commit-id: e8f02f7d04 [formerly 1dfcc6bee0] [formerly 11c42579a0] [formerly d1fa75d519 [formerly 11c42579a0 [formerly 3ffd3b878f4a553d3102f325cd3c8a296e5ec6c9]]]
Former-commit-id: d1fa75d519
Former-commit-id: 03ed0ddfe1f03ab94763dad4621fbc37267289c8 [formerly 73b701043c]
Former-commit-id: 87028c8f4e
This commit is contained in:
Lee Venable 2013-09-26 14:25:40 -05:00 committed by Gerrit Code Review
commit 368926fd43

View file

@ -84,6 +84,7 @@ import com.raytheon.uf.viz.stats.display.ScaleManager;
* Jan 17, 2013 1357 mpduff Added mouse listeners. * Jan 17, 2013 1357 mpduff Added mouse listeners.
* Jan 29, 2013 1523 mpduff Fix for count units. * Jan 29, 2013 1523 mpduff Fix for count units.
* Mar 12, 2013 1760 mpduff Fix for 3 hour graph x axis labels. * Mar 12, 2013 1760 mpduff Fix for 3 hour graph x axis labels.
* Sep 25, 2013 2406 lvenable Fixed color memory leaks.
* *
* </pre> * </pre>
* *
@ -218,6 +219,9 @@ public class StatsDisplayCanvas extends Canvas {
/** Hide dataset dialog */ /** Hide dataset dialog */
private HideDlg hideDlg; private HideDlg hideDlg;
/** Background color */
private Color backgroundColor = null;
/** /**
* Constructor * Constructor
* *
@ -249,6 +253,10 @@ public class StatsDisplayCanvas extends Canvas {
* Initialize the canvas. * Initialize the canvas.
*/ */
private void setupCanvas() { private void setupCanvas() {
RGB rgbColor = RGBColors.getRGBColor("gray85");
backgroundColor = new Color(parentComp.getDisplay(), rgbColor);
canvasFont = new Font(parentComp.getDisplay(), "Monospace", 9, canvasFont = new Font(parentComp.getDisplay(), "Monospace", 9,
SWT.NORMAL); SWT.NORMAL);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
@ -317,9 +325,7 @@ public class StatsDisplayCanvas extends Canvas {
.getSystemColor(SWT.COLOR_WHITE)); .getSystemColor(SWT.COLOR_WHITE));
gc.fillRectangle(0, 0, canvasWidth, canvasHeight + 2); gc.fillRectangle(0, 0, canvasWidth, canvasHeight + 2);
RGB color = RGBColors.getRGBColor("gray85"); gc.setBackground(backgroundColor);
gc.setBackground(new Color(parentComp.getDisplay(), color.red,
color.green, color.blue));
Rectangle graphArea = new Rectangle(GRAPH_BORDER, GRAPH_BORDER, Rectangle graphArea = new Rectangle(GRAPH_BORDER, GRAPH_BORDER,
GRAPH_WIDTH, GRAPH_HEIGHT); GRAPH_WIDTH, GRAPH_HEIGHT);
gc.fillRectangle(graphArea); gc.fillRectangle(graphArea);
@ -718,9 +724,11 @@ public class StatsDisplayCanvas extends Canvas {
UnitUtils uu = callback.getUnitUtils(); UnitUtils uu = callback.getUnitUtils();
GraphData graphData = callback.getGraphData(); GraphData graphData = callback.getGraphData();
Color color = null;
for (String key : graphData.getKeysWithData()) { for (String key : graphData.getKeysWithData()) {
if (groupSettings.containsKey(key)) { if (groupSettings.containsKey(key)) {
Color color = new Color(getDisplay(), groupSettings.get(key)); color = new Color(getDisplay(), groupSettings.get(key));
gc.setForeground(color); gc.setForeground(color);
gc.setBackground(color); gc.setBackground(color);
if (groupSettings.containsKey(key)) { if (groupSettings.containsKey(key)) {
@ -789,6 +797,8 @@ public class StatsDisplayCanvas extends Canvas {
} }
} }
} }
color.dispose();
} }
} }
} }
@ -1012,6 +1022,9 @@ public class StatsDisplayCanvas extends Canvas {
if (this.canvasFont != null && !canvasFont.isDisposed()) { if (this.canvasFont != null && !canvasFont.isDisposed()) {
this.canvasFont.dispose(); this.canvasFont.dispose();
} }
backgroundColor.dispose();
super.dispose(); super.dispose();
} }