changeset 20159:81a34c9d6e17

IGV: Improve text contrast.
author Roland Schatz <roland.schatz@oracle.com>
date Thu, 02 Apr 2015 18:55:27 +0200
parents ad1ef31ba0c1
children 90b5605032bc
files src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/FigureWidget.java
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/FigureWidget.java	Thu Apr 02 14:55:51 2015 +0200
+++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/FigureWidget.java	Thu Apr 02 18:55:27 2015 +0200
@@ -32,8 +32,10 @@
 import com.sun.hotspot.igv.util.PropertiesSheet;
 import com.sun.hotspot.igv.view.DiagramScene;
 import java.awt.*;
+import java.awt.color.ColorSpace;
 import java.awt.event.ActionEvent;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Set;
 import javax.swing.AbstractAction;
@@ -130,7 +132,15 @@
             middleWidget.addChild(lw);
             lw.setLabel(displayString);
             lw.setFont(figure.getDiagram().getFont());
-            lw.setForeground(Color.BLACK);
+            
+            Color bg = f.getColor();
+            double brightness = bg.getRed() * 0.21 + bg.getGreen() * 0.72 + bg.getBlue() * 0.07;
+            if (brightness < 150) {
+                lw.setForeground(Color.WHITE);
+            } else {
+                lw.setForeground(Color.BLACK);
+            }
+            
             lw.setAlignment(LabelWidget.Alignment.CENTER);
             lw.setVerticalAlignment(LabelWidget.VerticalAlignment.CENTER);
             lw.setBorder(BorderFactory.createEmptyBorder());