Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2013-01-31 16:04:29 +0000
committercletavernie2013-01-31 16:04:29 +0000
commit739d2845c17042705a78896de779f7829b2260c8 (patch)
tree1e44da1ed6ec561480d7bb98d023654968b9e10f /incoming
parentab5a926eb16a5192b06a6495499871897687da0b (diff)
downloadorg.eclipse.papyrus-739d2845c17042705a78896de779f7829b2260c8.tar.gz
org.eclipse.papyrus-739d2845c17042705a78896de779f7829b2260c8.tar.xz
org.eclipse.papyrus-739d2845c17042705a78896de779f7829b2260c8.zip
399616: [CSS] Papyrus shall provide a view to help debugging CSS
https://bugs.eclipse.org/bugs/show_bug.cgi?id=399616 Improve contrast between the cell's Background color and the font, for color values
Diffstat (limited to 'incoming')
-rw-r--r--incoming/org.eclipse.papyrus.infra.gmfdiag.css.debug/src/org/eclipse/papyrus/infra/gmfdiag/css/debug/views/CSSDebugView.java20
1 files changed, 14 insertions, 6 deletions
diff --git a/incoming/org.eclipse.papyrus.infra.gmfdiag.css.debug/src/org/eclipse/papyrus/infra/gmfdiag/css/debug/views/CSSDebugView.java b/incoming/org.eclipse.papyrus.infra.gmfdiag.css.debug/src/org/eclipse/papyrus/infra/gmfdiag/css/debug/views/CSSDebugView.java
index 93ab1e8c70d..49e3a82e224 100644
--- a/incoming/org.eclipse.papyrus.infra.gmfdiag.css.debug/src/org/eclipse/papyrus/infra/gmfdiag/css/debug/views/CSSDebugView.java
+++ b/incoming/org.eclipse.papyrus.infra.gmfdiag.css.debug/src/org/eclipse/papyrus/infra/gmfdiag/css/debug/views/CSSDebugView.java
@@ -222,7 +222,6 @@ public class CSSDebugView extends ViewPart implements ISelectionListener, ISelec
private void debug(List<Object> supportedElements) {
if(supportedElements.isEmpty()) {
- System.out.println("Ignored");
return; //Do not change the state of the debug view if the selection isn't interesting
}
@@ -466,13 +465,21 @@ public class CSSDebugView extends ViewPart implements ISelectionListener, ISelec
if(feature.getName().endsWith("Color") && value instanceof Integer) {
Color color = FigureUtilities.integerToColor((Integer)value);
cell.setBackground(color);
- if(((Integer)value) == 0) {
- //Use a white font when the color is black. TODO: Do the same for all dark colors...
- cell.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
- }
+ int lightness = getLightness(color);
+ //Use a white font when the color is dark
+ int systemColor = lightness < 130 ? systemColor = SWT.COLOR_WHITE : SWT.COLOR_BLACK;
+ cell.setForeground(Display.getDefault().getSystemColor(systemColor));
}
}
+ private int getLightness(Color color) {
+ //Computes the lightness of the color
+ int M = Math.max(color.getGreen(), Math.max(color.getRed(), color.getBlue()));
+ int m = Math.min(color.getGreen(), Math.min(color.getRed(), color.getBlue()));
+ int L = (M + m) / 2;
+ return L;
+ }
+
private String getValueAsText(EStructuralFeature feature, Object value) {
if(value instanceof GradientData) {
GradientData gradient = (GradientData)value;
@@ -573,7 +580,8 @@ public class CSSDebugView extends ViewPart implements ISelectionListener, ISelec
}
private void updateValue(ViewerCell cell, EStructuralFeature feature) {
- cell.setText(cssElement.getSemanticElement().eGet(feature).toString());
+ Object value = cssElement.getSemanticElement().eGet(feature);
+ cell.setText(value == null ? "" : value.toString());
}
}

Back to the top