Merge "Issue #2256 - Memory leak fixes and some code clean up fixes." into development

Former-commit-id: 2a296b5890 [formerly 44eddc910a51059ed527c41ca8aafe7ade2410fe]
Former-commit-id: b005f48faa
This commit is contained in:
Lee Venable 2013-08-19 11:13:57 -05:00 committed by Gerrit Code Review
commit a77bacccdb
18 changed files with 272 additions and 298 deletions

View file

@ -102,6 +102,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
* 10/09/2012 1229 rferrel Changes for non-blocking TafMonitorDlg.
* 04/10/2013 1735 rferrel Changes for taf monitor speed up.
* 08/09/2013 2033 mschenke Switched File.separator to IPathManager.SEPARATOR
* 12 Aug 2013 #2256 lvenable Removed unnecessary font code and other code clean up.
*
* </pre>
*
@ -116,11 +117,6 @@ public class AviationDialog extends CaveSWTDialog implements IBackupRestart {
+ IPathManager.SEPARATOR + "avnwatch" + IPathManager.SEPARATOR
+ "aviationForecasterConfig.xml";
/**
* Label font.
*/
private Font font;
/**
* Font list to dispose of.
*/
@ -211,7 +207,6 @@ public class AviationDialog extends CaveSWTDialog implements IBackupRestart {
*/
@Override
protected void disposed() {
font.dispose();
for (Font f : fontList) {
f.dispose();
}
@ -242,9 +237,6 @@ public class AviationDialog extends CaveSWTDialog implements IBackupRestart {
fontList = new ArrayList<Font>();
font = new Font(getDisplay(), "Monospace", 8, SWT.NORMAL);
fontList.add(font);
String path = loadGifPath("avn");
if (path != null) {
avnImage = new Image(getDisplay(), path);
@ -506,13 +498,8 @@ public class AviationDialog extends CaveSWTDialog implements IBackupRestart {
return;
}
try {
for (ForecasterConfig forecaster : forecasterArray) {
forecasterList.add(forecaster.getName());
}
} catch (Exception e1) {
// do nothing
for (ForecasterConfig forecaster : forecasterArray) {
forecasterList.add(forecaster.getName());
}
forecasterList.setSelection(0);

View file

@ -25,7 +25,6 @@ import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Transform;
import org.eclipse.swt.widgets.Composite;
@ -37,6 +36,7 @@ import org.eclipse.swt.widgets.Composite;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 28 FEB 2008 938 lvenable Initial creation
* 12 Aug 2013 #2256 lvenable Moved getCigVisDistImage() to parent class.
*
* </pre>
*
@ -178,10 +178,8 @@ public class CigVisByHourCanvasComp extends CigVisCanvasComp {
private int fontAveWidthLrg;
/**
* A copy of the image CigVisDist image to save to file.
* By Hour tab composite.
*/
private Image image;
private CigVisByHourTabComp tabComp;
/**
@ -290,9 +288,9 @@ public class CigVisByHourCanvasComp extends CigVisCanvasComp {
.getSelectedElement();
int startMonth = tabComp.getStartMonth();
int endMonth = tabComp.getEndMonth();
mainLabel = String
.format("%s %s %s (%d-%d)", site, elements[element.ordinal()],
monthStr(startMonth, endMonth), startYear, endYear);
mainLabel = String.format("%s %s %s (%d-%d)", site,
elements[element.ordinal()], monthStr(startMonth, endMonth),
startYear, endYear);
pixelPerInc = (double) graphHeight / (double) maxPercent;
@ -575,13 +573,13 @@ public class CigVisByHourCanvasComp extends CigVisCanvasComp {
}
gc.fillRectangle(cellWidth * x + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(vlifrArray[x]
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(vlifrArray[x] * pixelPerInc)
- barLengthOffset);
gc.drawRectangle(cellWidth * x + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(vlifrArray[x]
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(vlifrArray[x] * pixelPerInc)
- barLengthOffset);
if (yStartPos == graphYCoord) {
@ -612,13 +610,13 @@ public class CigVisByHourCanvasComp extends CigVisCanvasComp {
}
gc.fillRectangle(cellWidth * x + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(lifrArray[x]
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(lifrArray[x] * pixelPerInc)
- barLengthOffset);
gc.drawRectangle(cellWidth * x + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(lifrArray[x]
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(lifrArray[x] * pixelPerInc)
- barLengthOffset);
if (yStartPos == graphYCoord) {
@ -650,13 +648,13 @@ public class CigVisByHourCanvasComp extends CigVisCanvasComp {
}
gc.fillRectangle(cellWidth * x + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(ifrArray[x]
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(ifrArray[x] * pixelPerInc)
- barLengthOffset);
gc.drawRectangle(cellWidth * x + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(ifrArray[x]
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(ifrArray[x] * pixelPerInc)
- barLengthOffset);
if (yStartPos == graphYCoord) {
@ -687,13 +685,13 @@ public class CigVisByHourCanvasComp extends CigVisCanvasComp {
}
gc.fillRectangle(cellWidth * x + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(mvfrArray[x]
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(mvfrArray[x] * pixelPerInc)
- barLengthOffset);
gc.drawRectangle(cellWidth * x + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(mvfrArray[x]
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(mvfrArray[x] * pixelPerInc)
- barLengthOffset);
if (yStartPos == graphYCoord) {
@ -708,21 +706,6 @@ public class CigVisByHourCanvasComp extends CigVisCanvasComp {
}
}
public Image getCigVisDistImage() {
if (image != null) {
image.dispose();
}
image = new Image(parent.getDisplay(), CANVAS_WIDTH, CANVAS_HEIGHT);
GC gc = new GC(image);
drawCanvas(gc);
gc.dispose();
return image;
}
@Override
public float getMaxPercentInData() {
return maxPercentInData;

View file

@ -25,7 +25,6 @@ import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Transform;
import org.eclipse.swt.widgets.Composite;
@ -37,6 +36,7 @@ import org.eclipse.swt.widgets.Composite;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 28 FEB 2008 938 lvenable Initial creation
* 12 Aug 2013 #2256 lvenable Moved getCigVisDistImage() to parent class.
*
* </pre>
*
@ -184,10 +184,8 @@ public class CigVisByMonthCanvasComp extends CigVisCanvasComp {
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
/**
* A copy of the image CigVisDist image to save to file.
* By Month tab composite.
*/
private Image image;
private CigVisByMonthTabComp tabComp;
/**
@ -294,8 +292,9 @@ public class CigVisByMonthCanvasComp extends CigVisCanvasComp {
.getSelectedElement();
int startHour = tabComp.getStartHour();
int endHour = tabComp.getEndHour();
mainLabel = String.format("%s %s %sZ (%d-%d)", site, elements[element
.ordinal()], hourStr(startHour, endHour), startYear, endYear);
mainLabel = String.format("%s %s %sZ (%d-%d)", site,
elements[element.ordinal()], hourStr(startHour, endHour),
startYear, endYear);
pixelPerInc = (double) graphHeight / (double) maxPercent;
@ -588,13 +587,13 @@ public class CigVisByMonthCanvasComp extends CigVisCanvasComp {
}
gc.fillRectangle(cellWidth * x + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(vlifrArray[x]
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(vlifrArray[x] * pixelPerInc)
- barLengthOffset);
gc.drawRectangle(cellWidth * x + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(vlifrArray[x]
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(vlifrArray[x] * pixelPerInc)
- barLengthOffset);
if (yStartPos == graphYCoord) {
@ -625,13 +624,13 @@ public class CigVisByMonthCanvasComp extends CigVisCanvasComp {
}
gc.fillRectangle(cellWidth * x + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(lifrArray[x]
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(lifrArray[x] * pixelPerInc)
- barLengthOffset);
gc.drawRectangle(cellWidth * x + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(lifrArray[x]
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(lifrArray[x] * pixelPerInc)
- barLengthOffset);
if (yStartPos == graphYCoord) {
@ -663,13 +662,13 @@ public class CigVisByMonthCanvasComp extends CigVisCanvasComp {
}
gc.fillRectangle(cellWidth * x + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(ifrArray[x]
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(ifrArray[x] * pixelPerInc)
- barLengthOffset);
gc.drawRectangle(cellWidth * x + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(ifrArray[x]
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(ifrArray[x] * pixelPerInc)
- barLengthOffset);
if (yStartPos == graphYCoord) {
@ -700,13 +699,13 @@ public class CigVisByMonthCanvasComp extends CigVisCanvasComp {
}
gc.fillRectangle(cellWidth * x + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(mvfrArray[x]
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(mvfrArray[x] * pixelPerInc)
- barLengthOffset);
gc.drawRectangle(cellWidth * x + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(mvfrArray[x]
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(mvfrArray[x] * pixelPerInc)
- barLengthOffset);
if (yStartPos == graphYCoord) {
@ -752,13 +751,13 @@ public class CigVisByMonthCanvasComp extends CigVisCanvasComp {
}
gc.fillRectangle(cellWidth * arrayLength + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(vlifrAnnual
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(vlifrAnnual * pixelPerInc)
- barLengthOffset);
gc.drawRectangle(cellWidth * arrayLength + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(vlifrAnnual
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(vlifrAnnual * pixelPerInc)
- barLengthOffset);
if (yStartPos == graphYCoord) {
@ -788,13 +787,13 @@ public class CigVisByMonthCanvasComp extends CigVisCanvasComp {
}
gc.fillRectangle(cellWidth * arrayLength + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(lifrAnnual
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(lifrAnnual * pixelPerInc)
- barLengthOffset);
gc.drawRectangle(cellWidth * arrayLength + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(lifrAnnual
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(lifrAnnual * pixelPerInc)
- barLengthOffset);
if (yStartPos == graphYCoord) {
@ -824,14 +823,12 @@ public class CigVisByMonthCanvasComp extends CigVisCanvasComp {
}
gc.fillRectangle(cellWidth * arrayLength + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(ifrAnnual
* pixelPerInc)
- barLengthOffset);
yStartPos, barWidth,
(int) Math.round(ifrAnnual * pixelPerInc) - barLengthOffset);
gc.drawRectangle(cellWidth * arrayLength + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(ifrAnnual
* pixelPerInc)
- barLengthOffset);
yStartPos, barWidth,
(int) Math.round(ifrAnnual * pixelPerInc) - barLengthOffset);
if (yStartPos == graphYCoord) {
yStartPos = graphYCoord + graphHeight;
@ -860,13 +857,13 @@ public class CigVisByMonthCanvasComp extends CigVisCanvasComp {
}
gc.fillRectangle(cellWidth * arrayLength + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(mvfrAnnual
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(mvfrAnnual * pixelPerInc)
- barLengthOffset);
gc.drawRectangle(cellWidth * arrayLength + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(mvfrAnnual
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(mvfrAnnual * pixelPerInc)
- barLengthOffset);
if (yStartPos == graphYCoord) {
@ -880,21 +877,6 @@ public class CigVisByMonthCanvasComp extends CigVisCanvasComp {
yStartPos = graphYCoord + graphHeight;
}
public Image getCigVisDistImage() {
if (image != null) {
image.dispose();
}
image = new Image(parent.getDisplay(), CANVAS_WIDTH, CANVAS_HEIGHT);
GC gc = new GC(image);
drawCanvas(gc);
gc.dispose();
return image;
}
@Override
public float getMaxPercentInData() {
return maxPercentInData;

View file

@ -25,7 +25,6 @@ import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Transform;
import org.eclipse.swt.widgets.Composite;
@ -37,6 +36,7 @@ import org.eclipse.swt.widgets.Composite;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 28 FEB 2008 938 lvenable Initial creation
* 12 Aug 2013 #2256 lvenable Moved getCigVisDistImage() to parent class.
*
* </pre>
*
@ -185,10 +185,8 @@ public class CigVisByWindDirCanvasComp extends CigVisCanvasComp {
"VRB", "C " };
/**
* A copy of the image CigVisDist image to save to file.
* By Wing tab composite.
*/
private Image image;
private CigVisByWindDirTabComp tabComp;
/**
@ -645,13 +643,13 @@ public class CigVisByWindDirCanvasComp extends CigVisCanvasComp {
}
gc.fillRectangle(cellWidth * x + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(vlifrArray[x]
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(vlifrArray[x] * pixelPerInc)
- barLengthOffset);
gc.drawRectangle(cellWidth * x + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(vlifrArray[x]
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(vlifrArray[x] * pixelPerInc)
- barLengthOffset);
if (yStartPos == graphYCoord) {
@ -682,13 +680,13 @@ public class CigVisByWindDirCanvasComp extends CigVisCanvasComp {
}
gc.fillRectangle(cellWidth * x + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(lifrArray[x]
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(lifrArray[x] * pixelPerInc)
- barLengthOffset);
gc.drawRectangle(cellWidth * x + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(lifrArray[x]
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(lifrArray[x] * pixelPerInc)
- barLengthOffset);
if (yStartPos == graphYCoord) {
@ -720,13 +718,13 @@ public class CigVisByWindDirCanvasComp extends CigVisCanvasComp {
}
gc.fillRectangle(cellWidth * x + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(ifrArray[x]
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(ifrArray[x] * pixelPerInc)
- barLengthOffset);
gc.drawRectangle(cellWidth * x + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(ifrArray[x]
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(ifrArray[x] * pixelPerInc)
- barLengthOffset);
if (yStartPos == graphYCoord) {
@ -757,13 +755,13 @@ public class CigVisByWindDirCanvasComp extends CigVisCanvasComp {
}
gc.fillRectangle(cellWidth * x + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(mvfrArray[x]
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(mvfrArray[x] * pixelPerInc)
- barLengthOffset);
gc.drawRectangle(cellWidth * x + graphXCoord + barOffset,
yStartPos, barWidth, (int) Math.round(mvfrArray[x]
* pixelPerInc)
yStartPos, barWidth,
(int) Math.round(mvfrArray[x] * pixelPerInc)
- barLengthOffset);
if (yStartPos == graphYCoord) {
@ -778,21 +776,6 @@ public class CigVisByWindDirCanvasComp extends CigVisCanvasComp {
}
}
public Image getCigVisDistImage() {
if (image != null) {
image.dispose();
}
image = new Image(parent.getDisplay(), CANVAS_WIDTH, CANVAS_HEIGHT);
GC gc = new GC(image);
drawCanvas(gc);
gc.dispose();
return image;
}
@Override
public float getMaxPercentInData() {
return maxPercentInData;

View file

@ -27,6 +27,7 @@ import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@ -41,6 +42,7 @@ import org.eclipse.swt.widgets.Composite;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 28 FEB 2008 938 lvenable Initial creation
* 12 Aug 2013 #2256 lvenable Disposed of image when composite is disposed.
*
* </pre>
*
@ -90,6 +92,11 @@ abstract public class CigVisCanvasComp extends Composite {
*/
private Canvas cigVisCanvas;
/**
* A copy of the image to save to file.
*/
private Image image;
/**
* Constructor.
*
@ -125,6 +132,9 @@ abstract public class CigVisCanvasComp extends Composite {
largeFont.dispose();
mediumFont.dispose();
smallFont.dispose();
if (image != null) {
image.dispose();
}
}
});
}
@ -317,6 +327,21 @@ abstract public class CigVisCanvasComp extends Composite {
+ legendBarHeight * 3, true);
}
public Image getCigVisDistImage() {
if (image != null) {
image.dispose();
}
image = new Image(parent.getDisplay(), CANVAS_WIDTH, CANVAS_HEIGHT);
GC gc = new GC(image);
drawCanvas(gc);
gc.dispose();
return image;
}
/**
* This method is implemented by the class extending this abstract class and
* is used to draw information on the canvas.

View file

@ -31,7 +31,6 @@ import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
@ -88,6 +87,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* 4/14/2011 8861 rferrel Use SaveImageDlg class
* 04/08/2012 1229 rferrel Made dialog non-blocking.
* 10/15/2012 1229 rferrel Changes for non-blocking HelpUsageDlg.
* 16 Aug 2013 #2256 lvenable Fixed image and cursor memory leaks.
*
* </pre>
*
@ -192,10 +192,6 @@ public class CigVisDistributionDlg extends CaveSWTDialog implements
*/
private RGB statusCompRGB;
private Cursor waitCursor;
private Cursor defaultCursor;
private Button drawBtn;
private boolean firstReceived;
@ -248,9 +244,6 @@ public class CigVisDistributionDlg extends CaveSWTDialog implements
pythonScript.killProcess();
}
canvasFont.dispose();
if (waitCursor != null) {
waitCursor.dispose();
}
super.disposed();
}
@ -606,9 +599,6 @@ public class CigVisDistributionDlg extends CaveSWTDialog implements
*/
public void closeDisplay() {
shell.dispose();
if (waitCursor != null) {
waitCursor.dispose();
}
}
/**
@ -703,6 +693,8 @@ public class CigVisDistributionDlg extends CaveSWTDialog implements
private void printImage() {
PrintDialog dialog = new PrintDialog(shell, SWT.NULL);
PrinterData printerData = dialog.open();
Image tmpImage = null;
Image rotatedImage = null;
if (printerData != null) {
// set the orientation to landscape
printerData.orientation = PrinterData.PORTRAIT;
@ -724,19 +716,27 @@ public class CigVisDistributionDlg extends CaveSWTDialog implements
}
Image image = comp.getCigVisDistImage();
image = new Image(gc.getDevice(), image.getImageData()
tmpImage = new Image(gc.getDevice(), image.getImageData()
.scaledTo(printer.getBounds().height,
printer.getBounds().width));
// rotate the image
image = ImageUtil.rotateImage(image);
rotatedImage = ImageUtil.rotateImage(tmpImage);
gc.drawImage(image, 0, 0);
gc.drawImage(rotatedImage, 0, 0);
printer.endPage();
}
gc.dispose();
printer.endJob();
printer.dispose();
if (tmpImage != null) {
tmpImage.dispose();
}
if (rotatedImage != null) {
rotatedImage.dispose();
}
}
}
@ -789,10 +789,7 @@ public class CigVisDistributionDlg extends CaveSWTDialog implements
private void retrieveData(final String site) {
final int timeout = ClimateTimeoutManager.getInstance()
.getCigVisDistTimeout();
if (waitCursor == null) {
waitCursor = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
defaultCursor = shell.getCursor();
}
setBusyCursor(true);
data = new CigVisDistDataManager();
data.setSite(site);
@ -854,12 +851,12 @@ public class CigVisDistributionDlg extends CaveSWTDialog implements
if (state == true) {
++busyCount;
drawBtn.setEnabled(false);
shell.setCursor(waitCursor);
shell.setCursor(getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
} else {
--busyCount;
if (busyCount == 0) {
drawBtn.setEnabled(true);
shell.setCursor(defaultCursor);
shell.setCursor(null);
}
}
}

View file

@ -29,7 +29,6 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
@ -73,6 +72,8 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
* 4/14/2011 8861 rferrel Use SaveImageDlg class
* 10/09/2912 1229 rferrel Made non-blocking
* 10/15/2012 1229 rferrel Changes for non-blocking HelpUsageDlg.
* 12 Aug 2013 #2256 lvenable Disposed of images after printing and removed
* cursor memory leak.
*
* </pre>
*
@ -127,10 +128,6 @@ public class CigVisTrendDlg extends CaveSWTDialog {
*/
private Button drawBtn;
private Cursor waitCursor;
private Cursor defaultCursor;
/**
* Font used in text controls.
*/
@ -942,11 +939,7 @@ public class CigVisTrendDlg extends CaveSWTDialog {
}
selectionMap.put("cur_hour", hour);
if (waitCursor == null) {
waitCursor = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
defaultCursor = shell.getCursor();
}
shell.setCursor(waitCursor);
shell.setCursor(shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
drawBtn.setEnabled(false);
// Always get 12 hours worth
dataMgr.getData(siteList.getItem(siteList.getSelectionIndex()),
@ -956,7 +949,7 @@ public class CigVisTrendDlg extends CaveSWTDialog {
public void resetCursor() {
drawBtn.setEnabled(true);
shell.setCursor(defaultCursor);
shell.setCursor(null);
}
public void dataReceived() {
@ -1018,6 +1011,9 @@ public class CigVisTrendDlg extends CaveSWTDialog {
PrintDialog dialog = new PrintDialog(shell, SWT.NULL);
PrinterData printerData = dialog.open();
Image tmpImage = null;
Image rotatedImage = null;
if (printerData != null) {
// Create the printer object
Printer printer = new Printer(printerData);
@ -1026,18 +1022,26 @@ public class CigVisTrendDlg extends CaveSWTDialog {
if (printer.startPage()) {
Image image = trendCigVisCanvas.getCigVisTrendImage();
image = new Image(gc.getDevice(), image.getImageData()
tmpImage = new Image(gc.getDevice(), image.getImageData()
.scaledTo(printer.getBounds().height,
printer.getBounds().width));
// rotate the image
image = ImageUtil.rotateImage(image);
gc.drawImage(image, 0, 0);
rotatedImage = ImageUtil.rotateImage(tmpImage);
gc.drawImage(rotatedImage, 0, 0);
printer.endPage();
}
gc.dispose();
printer.endJob();
printer.dispose();
if (tmpImage != null) {
tmpImage.dispose();
}
if (rotatedImage != null) {
rotatedImage.dispose();
}
}
}
}

View file

@ -36,6 +36,7 @@ import org.eclipse.swt.widgets.Composite;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 28 FEB 2008 938 lvenable Initial creation
* 12 Aug 2013 #2256 lvenable Moved calcArrow() to parent abstract class
*
* </pre>
*
@ -263,21 +264,6 @@ public class TrendCeilingCanvasComp extends TrendSliderComp implements
gc.drawRectangle(barRect);
}
/**
* Calculate the arrow position.
*/
private void calcArrow() {
if (region.isEmpty() == false) {
region.subtract(arrowPoints);
}
arrowPoints = new int[] { arrowCenterXCoord, arrowBottomYCoord,
arrowCenterXCoord + 5, arrowTopYCoord, arrowCenterXCoord - 5,
arrowTopYCoord, arrowCenterXCoord, arrowBottomYCoord };
region.add(arrowPoints);
}
/**
* Not Implemented...
*/

View file

@ -44,6 +44,7 @@ import org.eclipse.swt.widgets.Composite;
* ------------ ---------- ----------- --------------------------
* 28 FEB 2008 938 lvenable Initial creation
* 14 JUN 2008 1119 lvenable Updated to draw graph data.
* 12 Aug 2013 #2256 lvenable Disposed of image when the composite is disposed of.
*
* </pre>
*
@ -238,6 +239,10 @@ public class TrendCigVisCanvasComp extends Composite {
ifrColor.dispose();
lifrColor.dispose();
vlifrColor.dispose();
if (image != null) {
image.dispose();
}
}
});
}
@ -500,15 +505,17 @@ public class TrendCigVisCanvasComp extends Composite {
gc.setBackground(mvfrColor);
gc.fillRectangle(graphXCoord + graphDataCellWidth * x
+ barOffset, Math.round(graphHeight + graphYCoord
- total * pixelPerInc), graphDataCellWidth - barOffset
* 2, Math.round(total * pixelPerInc));
gc.fillRectangle(
graphXCoord + graphDataCellWidth * x + barOffset,
Math.round(graphHeight + graphYCoord - total
* pixelPerInc), graphDataCellWidth - barOffset
* 2, Math.round(total * pixelPerInc));
gc.drawRectangle(graphXCoord + graphDataCellWidth * x
+ barOffset, Math.round(graphHeight + graphYCoord
- total * pixelPerInc), graphDataCellWidth - barOffset
* 2, Math.round(total * pixelPerInc));
gc.drawRectangle(
graphXCoord + graphDataCellWidth * x + barOffset,
Math.round(graphHeight + graphYCoord - total
* pixelPerInc), graphDataCellWidth - barOffset
* 2, Math.round(total * pixelPerInc));
}
// Draw the MVFR label
@ -526,15 +533,17 @@ public class TrendCigVisCanvasComp extends Composite {
gc.setBackground(ifrColor);
gc.fillRectangle(graphXCoord + graphDataCellWidth * x
+ barOffset, Math.round(graphHeight + graphYCoord
- total * pixelPerInc), graphDataCellWidth - barOffset
* 2, Math.round(total * pixelPerInc));
gc.fillRectangle(
graphXCoord + graphDataCellWidth * x + barOffset,
Math.round(graphHeight + graphYCoord - total
* pixelPerInc), graphDataCellWidth - barOffset
* 2, Math.round(total * pixelPerInc));
gc.drawRectangle(graphXCoord + graphDataCellWidth * x
+ barOffset, Math.round(graphHeight + graphYCoord
- total * pixelPerInc), graphDataCellWidth - barOffset
* 2, Math.round(total * pixelPerInc));
gc.drawRectangle(
graphXCoord + graphDataCellWidth * x + barOffset,
Math.round(graphHeight + graphYCoord - total
* pixelPerInc), graphDataCellWidth - barOffset
* 2, Math.round(total * pixelPerInc));
}
// Draw the IFR label
@ -552,15 +561,17 @@ public class TrendCigVisCanvasComp extends Composite {
gc.setBackground(lifrColor);
gc.fillRectangle(graphXCoord + graphDataCellWidth * x
+ barOffset, Math.round(graphHeight + graphYCoord
- total * pixelPerInc), graphDataCellWidth - barOffset
* 2, Math.round(total * pixelPerInc));
gc.fillRectangle(
graphXCoord + graphDataCellWidth * x + barOffset,
Math.round(graphHeight + graphYCoord - total
* pixelPerInc), graphDataCellWidth - barOffset
* 2, Math.round(total * pixelPerInc));
gc.drawRectangle(graphXCoord + graphDataCellWidth * x
+ barOffset, Math.round(graphHeight + graphYCoord
- total * pixelPerInc), graphDataCellWidth - barOffset
* 2, Math.round(total * pixelPerInc));
gc.drawRectangle(
graphXCoord + graphDataCellWidth * x + barOffset,
Math.round(graphHeight + graphYCoord - total
* pixelPerInc), graphDataCellWidth - barOffset
* 2, Math.round(total * pixelPerInc));
}
// Draw the LIFR data
@ -578,15 +589,17 @@ public class TrendCigVisCanvasComp extends Composite {
gc.setBackground(vlifrColor);
gc.fillRectangle(graphXCoord + graphDataCellWidth * x
+ barOffset, Math.round(graphHeight + graphYCoord
- total * pixelPerInc), graphDataCellWidth - barOffset
* 2, Math.round(total * pixelPerInc));
gc.fillRectangle(
graphXCoord + graphDataCellWidth * x + barOffset,
Math.round(graphHeight + graphYCoord - total
* pixelPerInc), graphDataCellWidth - barOffset
* 2, Math.round(total * pixelPerInc));
gc.drawRectangle(graphXCoord + graphDataCellWidth * x
+ barOffset, Math.round(graphHeight + graphYCoord
- total * pixelPerInc), graphDataCellWidth - barOffset
* 2, Math.round(total * pixelPerInc));
gc.drawRectangle(
graphXCoord + graphDataCellWidth * x + barOffset,
Math.round(graphHeight + graphYCoord - total
* pixelPerInc), graphDataCellWidth - barOffset
* 2, Math.round(total * pixelPerInc));
}
// Draw the VLIFR data

View file

@ -51,6 +51,7 @@ import org.eclipse.swt.widgets.Text;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 28 FEB 2008 938 lvenable Initial creation.
* 12 Aug 2013 #2256 lvenable Added calcArrow() method and code to dispose of the region.
*
* </pre>
*
@ -217,6 +218,7 @@ public abstract class TrendSliderComp extends Composite {
this.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
canvasFont.dispose();
region.dispose();
}
});
}
@ -334,6 +336,21 @@ public abstract class TrendSliderComp extends Composite {
mb.open();
}
/**
* Calculate the arrow position.
*/
protected void calcArrow() {
if (region.isEmpty() == false) {
region.subtract(arrowPoints);
}
arrowPoints = new int[] { arrowCenterXCoord, arrowBottomYCoord,
arrowCenterXCoord + 5, arrowTopYCoord, arrowCenterXCoord - 5,
arrowTopYCoord, arrowCenterXCoord, arrowBottomYCoord };
region.add(arrowPoints);
}
/**
* This method is implemented by the class extending this abstract class and
* is used to draw information on the canvas.

View file

@ -36,6 +36,7 @@ import org.eclipse.swt.widgets.Composite;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 28 FEB 2008 938 lvenable Initial creation.
* 12 Aug 2013 #2256 lvenable Moved calcArrow() to parent abstract class
*
* </pre>
*
@ -261,21 +262,6 @@ public class TrendVisCanvasComp extends TrendSliderComp implements
gc.drawRectangle(barRect);
}
/**
* Calculate the arrow position.
*/
private void calcArrow() {
if (region.isEmpty() == false) {
region.subtract(arrowPoints);
}
arrowPoints = new int[] { arrowCenterXCoord, arrowBottomYCoord,
arrowCenterXCoord + 5, arrowTopYCoord, arrowCenterXCoord - 5,
arrowTopYCoord, arrowCenterXCoord, arrowBottomYCoord };
region.add(arrowPoints);
}
/**
* Not Implemented...
*/

View file

@ -36,6 +36,7 @@ import org.eclipse.swt.widgets.Composite;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 28 FEB 2008 938 lvenable Initial creation.
* 12 Aug 2013 #2256 lvenable Moved calcArrow() to parent abstract class
*
* </pre>
*
@ -222,21 +223,6 @@ public class TrendWindSpdCanvasComp extends TrendSliderComp implements
gc.drawRectangle(barRect);
}
/**
* Calculate the arrow position.
*/
private void calcArrow() {
if (region.isEmpty() == false) {
region.subtract(arrowPoints);
}
arrowPoints = new int[] { arrowCenterXCoord, arrowBottomYCoord,
arrowCenterXCoord + 5, arrowTopYCoord, arrowCenterXCoord - 5,
arrowTopYCoord, arrowCenterXCoord, arrowBottomYCoord };
region.add(arrowPoints);
}
/**
* Not Implemented...
*/
@ -635,7 +621,6 @@ public class TrendWindSpdCanvasComp extends TrendSliderComp implements
}
String[] ranges = rangeTF.getText().split("-");
String startStr = ranges[0];
String endStr = ranges[1];
int newXCoord = calcValueToXCoord(startVal);
barRect.x = newXCoord;
@ -677,8 +662,8 @@ public class TrendWindSpdCanvasComp extends TrendSliderComp implements
windSpdRange[1] = str[1];
if (windSpdRange[1].endsWith("+")) {
windSpdRange[1] = windSpdRange[1].substring(0, (windSpdRange[1]
.length() - 1));
windSpdRange[1] = windSpdRange[1].substring(0,
(windSpdRange[1].length() - 1));
}
return windSpdRange;

View file

@ -49,6 +49,7 @@ import com.raytheon.viz.aviation.xml.WxPlotCfg;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 25 JUN 2008 1119 lvenable Initial creation
* 12 Aug 2013 #2256 lvenable Disposed of image when composite is disposed.
*
* </pre>
*
@ -227,6 +228,10 @@ abstract class WeatherCanvasComp extends Composite {
this.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
smallFont.dispose();
if (image != null) {
image.dispose();
}
}
});
}

View file

@ -35,7 +35,6 @@ import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
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.Image;
@ -89,7 +88,7 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback;
* 10/10/2012 1229 rferrel Changes for non-blocking TimeSelectorDlg.
* 10/15/2012 1229 rferrel Changes for non-blocking HelpUsageDlg.
* 11/26/2012 1298 rferrel Non-blocking dialog code cleanup.
*
* 12 Aug 2013 #2256 lvenable Disposed of masterImage.
*
* </pre>
*
@ -189,8 +188,6 @@ public class WeatherPlotDialog extends CaveSWTDialog {
*/
private Composite graphComp;
private Cursor waitCursor = null;
/**
* Status message type.
*/
@ -262,7 +259,6 @@ public class WeatherPlotDialog extends CaveSWTDialog {
protected void disposed() {
busyCnt = 0;
font.dispose();
waitCursor.dispose();
}
@Override
@ -276,7 +272,6 @@ public class WeatherPlotDialog extends CaveSWTDialog {
mainComp.setLayoutData(gd);
font = new Font(shell.getDisplay(), "Monospace", 10, SWT.NORMAL);
waitCursor = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
// Initialize the data and all of the controls and layouts
initData();
@ -533,6 +528,7 @@ public class WeatherPlotDialog extends CaveSWTDialog {
ImageLoader loader = new ImageLoader();
loader.data = new ImageData[] { masterImage.getImageData() };
loader.save(filename, style);
masterImage.dispose();
}
/**
@ -792,7 +788,7 @@ public class WeatherPlotDialog extends CaveSWTDialog {
}
if (state) {
++busyCnt;
shell.setCursor(waitCursor);
shell.setCursor(getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
} else {
--busyCnt;
if (busyCnt == 0) {

View file

@ -21,6 +21,8 @@ package com.raytheon.viz.aviation.editor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseTrackAdapter;
@ -57,6 +59,7 @@ import com.raytheon.viz.aviation.resource.ResourceConfigMgr.ResourceTag;
* display tool tip in dataStTxt.
* 12/09/2010 7380 rferrel Remove no longer needed constructor and now
* adjust both hight and width of text filed.
* 12 Aug 2013 #2256 lvenable Added code to dispose of the cursor.
*
* </pre>
*
@ -136,6 +139,15 @@ public class HeaderTextComp extends Composite {
initializeComponents(configMgr);
this.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
if (textCursor != null) {
textCursor.dispose();
}
}
});
this.pack();
}

View file

@ -54,6 +54,8 @@ import com.raytheon.viz.aviation.resource.ResourceConfigMgr.ResourceTag;
* Feb 7, 1011 7783 rferrel setTextEditorFontAndReverseColors no
* longer reverses highlighted text's
* foreground color
* 16 Aug 2013 #2256 lvenable Fixed font array out of bounds issue that may
* occasionally occur.
*
* </pre>
*
@ -315,8 +317,20 @@ public class ResourceDataManager {
*/
String fontStr = resourceCB.getResourceAsString(ResourceTag.Font);
String[] stringArray = fontStr.split("-");
defaultFont = new Font(display, new FontData(stringArray[0],
Integer.valueOf(stringArray[1]), getStyleInt(stringArray[2])));
/*
* If the font back from the resource is null or doesn't have the
* correct font data then create the default font with a system font.
*/
if (stringArray == null || stringArray.length < 3) {
FontData fd = display.getSystemFont().getFontData()[0];
defaultFont = new Font(display, new FontData(fd.name,
(int) fd.height, fd.style));
} else {
defaultFont = new Font(display, new FontData(stringArray[0],
Integer.valueOf(stringArray[1]),
getStyleInt(stringArray[2])));
}
RGB colorRGB = RGBColors.getRGBColor(resourceCB
.getResourceAsString(ResourceTag.Foreground));

View file

@ -22,6 +22,8 @@ package com.raytheon.viz.aviation.resource;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.swt.SWT;
@ -64,6 +66,7 @@ import com.raytheon.viz.aviation.resource.ResourceConfigMgr.ResourceType;
* ------------ ---------- ----------- --------------------------
* Jul 17, 2009 lvenable Initial creation
* Feb 18, 2011 rferrel Selecting audio file now works.
* 12 Aug 2013 #2256 lvenable Reworked the code to dispose of the font after it has been used.
*
* </pre>
*
@ -84,17 +87,23 @@ public class ResourceItemComp extends Composite {
/**
* Map containing the resource tag (key) and the String value.
*/
private HashMap<ResourceTag, String> resTagValMap;
private Map<ResourceTag, String> resTagValMap;
/**
* Array of all the Reset buttons.
*/
private ArrayList<Button> resetButtons;
private List<Button> resetButtons;
/**
* Array of all the Font buttons. The Font buttons will always contain Fonts
* that have been create so the Font will need to be disposed of.
*/
private List<Button> fontButtons = new ArrayList<Button>();
/**
* Temporary font.
*/
private Font tmpFont;
// private Font tmpFont;
/**
* Constructor.
@ -138,7 +147,11 @@ public class ResourceItemComp extends Composite {
this.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
tmpFont.dispose();
// Dispose of the fonts that were create for the buttons. Since
// the buttons were using them they will be disposed of here.
for (Button b : fontButtons) {
b.getFont().dispose();
}
}
});
}
@ -224,6 +237,7 @@ public class ResourceItemComp extends Composite {
});
resTagValMap.put(tag, configMgr.getResourceAsString(tag));
fontButtons.add(fontBtn);
return fontBtn;
} else if (resType == ResourceType.COLOR) {
@ -394,7 +408,8 @@ public class ResourceItemComp extends Composite {
sourceBtn.getFont().dispose();
// Create the new font and set it into the label
tmpFont = new Font(this.getShell().getDisplay(), dlg.getFontList());
Font tmpFont = new Font(this.getShell().getDisplay(),
dlg.getFontList());
FontData fd = tmpFont.getFontData()[0];
@ -474,8 +489,9 @@ public class ResourceItemComp extends Composite {
String[] string = fontStr.split("-");
tmpFont = new Font(getParent().getDisplay(), new FontData(string[0],
Integer.valueOf(string[1]), configMgr.getStyleInt(string[2])));
Font tmpFont = new Font(getParent().getDisplay(), new FontData(
string[0], Integer.valueOf(string[1]),
configMgr.getStyleInt(string[2])));
fontBtn.setFont(tmpFont);
fontBtn.setText(fontStr);
@ -550,7 +566,9 @@ public class ResourceItemComp extends Composite {
break;
case FONT:
updateFontButton(configMgr, (Button) c, tag);
Button btn = (Button) c;
btn.getFont().dispose();
updateFontButton(configMgr, btn, tag);
break;
case SPINNER:

View file

@ -70,6 +70,7 @@ import com.raytheon.viz.avncommon.AvnMessageMgr.StatusMessageType;
* non-blocking dialogs.
* 10/12/2012 1229 rferrel Changes for non-blocking MessageViewerDlg.
* 08/09/2013 2033 mschenke Switched File.separator to IPathManager.SEPARATOR
* 12 Aug 2013 #2256 lvenable Cleanup to remove deprecated code.
*
* </pre>
*
@ -108,13 +109,6 @@ public class MessageStatusComp extends Composite implements IStatusSettable {
*/
private MessageViewerDlg msgViewerDlg;
/**
* Background RGB color. Only used at construction time to create
* newBgColor. No need to keep it around in a class variable.
*/
@Deprecated
private RGB bgRGB;
/**
* New background color for the msgViewerBtn.
*/
@ -150,13 +144,6 @@ public class MessageStatusComp extends Composite implements IStatusSettable {
*/
private boolean timerDone = true;
/**
* Message background RGB color. Only used at construction time to create
* messageBgColor. No need to keep it around in a class variable.
*/
@Deprecated
private RGB messageBgRGB;
/**
* The normal back ground color for the text field.
*/
@ -181,9 +168,7 @@ public class MessageStatusComp extends Composite implements IStatusSettable {
msgType = null;
this.messageBgRGB = messageBgRGB;
init();
init(null, messageBgRGB);
}
/**
@ -205,19 +190,15 @@ public class MessageStatusComp extends Composite implements IStatusSettable {
this.parent = parent;
this.bgRGB = bgRGB;
this.msgType = msgType;
this.messageBgRGB = messageBgRGB;
init();
init(bgRGB, messageBgRGB);
}
/**
* Initialize method.
*/
private void init() {
private void init(RGB bgRGB, RGB messageBgRGB) {
msgLogImg = new Image(parent.getDisplay(), loadMessageGif());