Skip to content
Snippets Groups Projects
Commit 1a44be5c authored by Simon Barner's avatar Simon Barner
Browse files

- Avoid leaking SWT colors

refs 2709
parent 7b12dd7e
No related branches found
No related tags found
No related merge requests found
...@@ -28,7 +28,7 @@ import static de.cau.cs.kieler.klay.layered.properties.Properties.INTERACTIVE_RE ...@@ -28,7 +28,7 @@ import static de.cau.cs.kieler.klay.layered.properties.Properties.INTERACTIVE_RE
import static java.lang.Math.max; import static java.lang.Math.max;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE; import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_GRID_SIZE; import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_GRID_SIZE;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_HEIGHT; import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_WIDTH;
import static org.fortiss.tooling.base.ui.annotation.view.AnnotationViewPartBase.isUpdateEnabled; import static org.fortiss.tooling.base.ui.annotation.view.AnnotationViewPartBase.isUpdateEnabled;
import static org.fortiss.tooling.base.ui.annotation.view.AnnotationViewPartBase.setUpdateEnabled; import static org.fortiss.tooling.base.ui.annotation.view.AnnotationViewPartBase.setUpdateEnabled;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.addBendPointToConnection; import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.addBendPointToConnection;
...@@ -329,7 +329,7 @@ public class KielerAutoLayouter implements IAutoLayouter { ...@@ -329,7 +329,7 @@ public class KielerAutoLayouter implements IAutoLayouter {
int numConnectors = max(inputConnectors.size(), outputConnectors.size()); int numConnectors = max(inputConnectors.size(), outputConnectors.size());
kNodeLayout.setHeight(max((1 + 2 * numConnectors) * DEFAULT_CONNECTOR_SIZE, kNodeLayout.setHeight(max((1 + 2 * numConnectors) * DEFAULT_CONNECTOR_SIZE,
truncateSnap2Grid(dimension.getHeight(), true))); truncateSnap2Grid(dimension.getHeight(), true)));
kNodeLayout.setWidth(max(DEFAULT_SHAPE_MINIMUM_HEIGHT, kNodeLayout.setWidth(max(DEFAULT_SHAPE_MINIMUM_WIDTH,
truncateSnap2Grid(dimension.getWidth(), true))); truncateSnap2Grid(dimension.getWidth(), true)));
kNode.setParent(rootNode); kNode.setParent(rootNode);
......
...@@ -4,7 +4,7 @@ ConstraintsBaseUIUtils.java d52255cb76e1152e233dba67b9d764b443157054 GREEN ...@@ -4,7 +4,7 @@ ConstraintsBaseUIUtils.java d52255cb76e1152e233dba67b9d764b443157054 GREEN
DecorationIconUtils.java 77c435bc970b7ca2774a9eab9fc102f0f46698b3 GREEN DecorationIconUtils.java 77c435bc970b7ca2774a9eab9fc102f0f46698b3 GREEN
DragAndDropBaseUtils.java c88f397ca7aa034247b3508ca0f70c24cde53a47 GREEN DragAndDropBaseUtils.java c88f397ca7aa034247b3508ca0f70c24cde53a47 GREEN
EllipseLayoutUIUtils.java d007669f0f284392345d94d3b17009bebd53e2ee GREEN EllipseLayoutUIUtils.java d007669f0f284392345d94d3b17009bebd53e2ee GREEN
GCStateManager.java 58303cf3c9bb0f9178659c8baabad81c6d96e9a7 YELLOW GCStateManager.java 414e62052a64a9b4514ebda23d64a17a370ea360 YELLOW
LayoutDataUIUtils.java 0b2d3d1f47eef070c11b56fb7b332e0e49fa5a52 GREEN LayoutDataUIUtils.java 0b2d3d1f47eef070c11b56fb7b332e0e49fa5a52 GREEN
PropertiesViewUtils.java 009d390b8aa41bb79b45b1e09a3375d0374fa139 GREEN PropertiesViewUtils.java 009d390b8aa41bb79b45b1e09a3375d0374fa139 GREEN
RectangleLayoutUIUtils.java b64f2f86b8254363689bf0809f681fc59a87a04a GREEN RectangleLayoutUIUtils.java b64f2f86b8254363689bf0809f681fc59a87a04a GREEN
......
...@@ -15,6 +15,8 @@ ...@@ -15,6 +15,8 @@
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.utils; package org.fortiss.tooling.base.ui.utils;
import static org.eclipse.wb.swt.SWTResourceManager.getColor;
import java.util.Deque; import java.util.Deque;
import java.util.LinkedList; import java.util.LinkedList;
...@@ -66,7 +68,7 @@ public final class GCStateManager { ...@@ -66,7 +68,7 @@ public final class GCStateManager {
/** Stores the current foreground color and creates and activates the given color. */ /** Stores the current foreground color and creates and activates the given color. */
public GCStateManager foregroundStoreAndCreate(RGB rgb) { public GCStateManager foregroundStoreAndCreate(RGB rgb) {
state.push(gc.getForeground()); state.push(gc.getForeground());
gc.setForeground(new Color(Display.getCurrent(), rgb)); gc.setForeground(getColor(rgb));
return this; return this;
} }
...@@ -80,7 +82,7 @@ public final class GCStateManager { ...@@ -80,7 +82,7 @@ public final class GCStateManager {
/** Stores the current background color and creates and activates the given color. */ /** Stores the current background color and creates and activates the given color. */
public GCStateManager backgroundStoreAndCreate(RGB rgb) { public GCStateManager backgroundStoreAndCreate(RGB rgb) {
state.push(gc.getBackground()); state.push(gc.getBackground());
gc.setBackground(new Color(Display.getCurrent(), rgb)); gc.setBackground(getColor(rgb));
return this; return this;
} }
......
AxisStyle.java 08afd475d82f08acc926512637d136f7dc53da01 GREEN AxisStyle.java 08afd475d82f08acc926512637d136f7dc53da01 GREEN
ChartStyle.java f5eb717f58603f62a6c65aee52d25168882ba77b GREEN ChartStyle.java f5eb717f58603f62a6c65aee52d25168882ba77b GREEN
ColorStyleBase.java 3091975acd2e88e1c7e1faaf733c2d79ed11eaee GREEN ColorStyleBase.java 5b7b6067b70bb2f740696c59d17127a3d2f18f7a YELLOW
DataSeriesStyle.java facb27bc839a83057499b1ee982fd18ae1939ece GREEN DataSeriesStyle.java facb27bc839a83057499b1ee982fd18ae1939ece GREEN
FillStyle.java b3951ca3b29aa8c67ff01eccbaaa138e434c9382 GREEN FillStyle.java b3951ca3b29aa8c67ff01eccbaaa138e434c9382 GREEN
FontStyle.java 24c20e5f4038855eb419d6f690e3c25f18b208bc GREEN FontStyle.java 24c20e5f4038855eb419d6f690e3c25f18b208bc GREEN
......
...@@ -15,9 +15,7 @@ ...@@ -15,9 +15,7 @@
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.tooling.spiderchart.style; package org.fortiss.tooling.spiderchart.style;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.RGB;
import org.fortiss.tooling.spiderchart.util.RGBColorUtils;
/** /**
* Base class for styles with a single {@link RGB} color. * Base class for styles with a single {@link RGB} color.
...@@ -37,9 +35,4 @@ public abstract class ColorStyleBase { ...@@ -37,9 +35,4 @@ public abstract class ColorStyleBase {
public final RGB getRGBColor() { public final RGB getRGBColor() {
return rgbColor; return rgbColor;
} }
/** Creates the Color instance, which MUST be disposed after use. */
public final Color createSWTColor() {
return RGBColorUtils.createSWTColor(rgbColor);
}
} }
AxisUtils.java 6bda56a8f065c0f61da3219fed969ec81550e0d5 GREEN AxisUtils.java 6bda56a8f065c0f61da3219fed969ec81550e0d5 GREEN
FontUtils.java 45708694de3276761a926819d61d6b002fa21840 GREEN FontUtils.java 45708694de3276761a926819d61d6b002fa21840 GREEN
RGBColorUtils.java 6aa3b43a72303eb61eac223f1b9634647ccba1d5 GREEN RGBColorUtils.java 710fb18fbf1d7023ebe4330a43abc429e0c05e49 YELLOW
...@@ -18,9 +18,7 @@ package org.fortiss.tooling.spiderchart.util; ...@@ -18,9 +18,7 @@ package org.fortiss.tooling.spiderchart.util;
import static java.lang.Math.max; import static java.lang.Math.max;
import static java.lang.Math.min; import static java.lang.Math.min;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
/** /**
* Utility class for handling colors with a set of commonly used colors. * Utility class for handling colors with a set of commonly used colors.
...@@ -60,14 +58,6 @@ public final class RGBColorUtils { ...@@ -60,14 +58,6 @@ public final class RGBColorUtils {
/** The RGB color navy. */ /** The RGB color navy. */
public static final RGB NAVY = new RGB(0, 0, 128); public static final RGB NAVY = new RGB(0, 0, 128);
/**
* Creates a {@link Color} from the given {@link RGB}, which MUST be disposed after finished
* using it.
*/
public static Color createSWTColor(RGB rgb) {
return new Color(Display.getCurrent(), rgb);
}
/** Returns the color, which is 10% brighter than the given color. */ /** Returns the color, which is 10% brighter than the given color. */
public static RGB getBrighterColor(RGB color) { public static RGB getBrighterColor(RGB color) {
int percent = 10; int percent = 10;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment