Skip to content

Commit

Permalink
GH-102 Improved VisualVM appearance on dark themes (release142)
Browse files Browse the repository at this point in the history
 - "ugly" fix - additional hardcoded colors
  • Loading branch information
jisedlac committed Aug 23, 2018
1 parent 2f3dc69 commit 6010c00
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
public interface Constants {

static final String COLOR_SCREEN_BACKGROUND = "ScreenBackgroundColor"; //NOI18N
static final String COLOR_SCREEN_BACKGROUND_DARK = "ScreenBackgroundColorDark"; //NOI18N
static final String COLOR_CONTENT_BACKGROUND = "ContentBackgroundColor"; //NOI18N
static final String BORDER_COLOR = "BorderColor"; //NOI18N

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

package com.sun.tools.visualvm.modules.appui.welcome;

import com.sun.tools.visualvm.uisupport.UISupport;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
Expand All @@ -43,7 +44,9 @@ public class StartPageContent extends JPanel implements Constants {
public StartPageContent() {
super( new GridBagLayout() );

setBackground( Utils.getColor( COLOR_SCREEN_BACKGROUND ) );
setBackground( !UISupport.isDarkResultsBackground() ?
Utils.getColor( COLOR_SCREEN_BACKGROUND ) :
Utils.getColor( COLOR_SCREEN_BACKGROUND_DARK ) );
setMinimumSize( new Dimension(START_PAGE_MIN_WIDTH,100) );

add( new JLabel(), new GridBagConstraints(0,0,1,1,0.0,1.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ URL_OracleLogo=http://www.oracle.com
# Colors
#
ScreenBackgroundColor=0xa9c7de
ScreenBackgroundColorDark=0x325067
ContentBackgroundColor=0xeff7fb
MouseOverLinkColor=0xe76f00
BorderColor=0x5B83A9
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

package com.sun.tools.visualvm.charts;

import com.sun.tools.visualvm.uisupport.UISupport;
import java.awt.Color;

/**
Expand All @@ -41,11 +42,18 @@ final class ColorFactory {
new Color(158, 156, 0)
};

private static final Color[][] PREDEFINED_GRADIENTS = new Color[][] {
private static final Color[][] PREDEFINED_GRADIENTS = !UISupport.isDarkResultsBackground() ?
new Color[][] {
new Color[] { new Color(245, 204, 152), new Color(255, 243, 226) },
new Color[] { new Color(151, 223, 246), new Color(227, 248, 255) },
new Color[] { new Color(200, 163, 248), new Color(242, 232, 255) },
new Color[] { new Color(212, 211, 131), new Color(244, 243, 217) }
} :
new Color[][] {
new Color[] { new Color(145, 104, 052), new Color(155, 143, 126) },
new Color[] { new Color(051, 123, 146), new Color(127, 148, 155) },
new Color[] { new Color(100, 063, 148), new Color(142, 132, 155) },
new Color[] { new Color(112, 111, 031), new Color(144, 143, 117) }
};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public class SimpleXYChartUtils {

DEFAULT_BUFFER_STEP = 50;

AXIS_FONT_COLOR = new Color(90, 90, 90);
AXIS_FONT_COLOR = !UISupport.isDarkResultsBackground() ? new Color(90, 90, 90) : new Color(165, 165, 165);
BACKGROUND_COLOR = UISupport.getDefaultBackground();

VALUES_SPACING = Math.max(new TimeMarksPainter().getFont().getSize(), 15) + 10;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

package com.sun.tools.visualvm.charts.xy;

import com.sun.tools.visualvm.uisupport.UISupport;
import org.netbeans.lib.profiler.charts.ChartContext;
import org.netbeans.lib.profiler.charts.ChartDecorator;
import java.awt.Color;
Expand All @@ -40,8 +41,10 @@
*/
public class XYBackground implements ChartDecorator {

private static final Color GRADIENT_TOP = new Color(240, 240, 240);
private static final Color GRADIENT_BOTTOM = new Color(250, 250, 250);
private static final Color GRADIENT_TOP = !UISupport.isDarkResultsBackground() ?
new Color(240, 240, 240) : new Color(60, 60, 60);
private static final Color GRADIENT_BOTTOM = !UISupport.isDarkResultsBackground() ?
new Color(250, 250, 250) : new Color(75, 75, 75);

public void paint(Graphics2D g, Rectangle dirtyArea, ChartContext context) {
if (Utils.forceSpeed()) g.setPaint(GRADIENT_BOTTOM);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

package com.sun.tools.visualvm.core.ui.components;

import com.sun.tools.visualvm.uisupport.UISupport;
import java.awt.BasicStroke;
import java.awt.BorderLayout;
import java.awt.Color;
Expand Down Expand Up @@ -64,10 +65,10 @@
*/
class DisplayAreaSupport {

static final Color BORDER_COLOR_NORMAL = new Color(192, 192, 192);
static final Color BORDER_COLOR_HIGHLIGHT = new Color(128, 128, 128);
static final Color BACKGROUND_COLOR_NORMAL = new Color(245, 245, 245);
static final Color BACKGROUND_COLOR_HIGHLIGHT = new Color(235, 235, 235);
static final Color BORDER_COLOR_NORMAL = !UISupport.isDarkResultsBackground() ? new Color(192, 192, 192) : new Color(64, 64, 64);
static final Color BORDER_COLOR_HIGHLIGHT = !UISupport.isDarkResultsBackground() ? new Color(128, 128, 128) : new Color(90, 90, 90);
static final Color BACKGROUND_COLOR_NORMAL = !UISupport.isDarkResultsBackground() ? new Color(245, 245, 245) : new Color(50, 50, 50);
static final Color BACKGROUND_COLOR_HIGHLIGHT = !UISupport.isDarkResultsBackground() ? new Color(235, 235, 235) : new Color(55, 55, 55);

static final Color COLOR_NONE = new Color(0, 0, 0);
static final Color TABS_SEPARATOR = new Color(UIManager.getColor("Label.foreground").getRGB()); // NOI18N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

package com.sun.tools.visualvm.heapviewer.oql;

import com.sun.tools.visualvm.uisupport.UISupport;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
Expand Down Expand Up @@ -261,7 +262,7 @@ public Dimension getPreferredSize() {
return dim;
}
public void setBackground(Color c) {
super.setBackground(new Color(245, 245, 245));
super.setBackground(!UISupport.isDarkResultsBackground() ? new Color(245, 245, 245) : new Color(55, 55, 55));
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.sun.tools.visualvm.core.ui.components.DataViewComponent;
import com.sun.tools.visualvm.core.ui.components.ScrollableContainer;
import com.sun.tools.visualvm.uisupport.HTMLTextArea;
import com.sun.tools.visualvm.uisupport.UISupport;
import java.awt.BorderLayout;
import java.awt.Color;
import java.io.File;
Expand Down Expand Up @@ -140,12 +141,13 @@ private static String htmlize(String value) {
}

private static String transform(String value) {
String alternateColor = !UISupport.isDarkResultsBackground() ? "#0033CC" : "#FFCC33"; // NOI18N
StringBuilder sb = new StringBuilder();
String[] result = value.split("\\n"); // NOI18N
for (int i = 0; i < result.length; i++) {
String line = result[i];
if (!line.isEmpty() && !Character.isWhitespace(line.charAt(0))) {
sb.append("<span style=\"color: #0033CC\">"); // NOI18N
sb.append("<span style=\"color: ").append(alternateColor).append("\">"); // NOI18N
sb.append(line);
sb.append("</span><br>"); // NOI18N
} else {
Expand All @@ -171,7 +173,7 @@ public void run() {
try {
HTMLTextArea area = new HTMLTextArea();
area.setEditorKit(new CustomHtmlEditorKit());
area.setForeground(new Color(0xcc, 0x33, 0));
area.setForeground(!UISupport.isDarkResultsBackground() ? new Color(0xcc, 0x33, 0) : new Color(0x33, 0xcc, 0xff));
area.setText("<pre>" + transform(htmlize(new String(data, "UTF-8"))) + "</pre>"); // NOI18N
area.setCaretPosition(0);
area.setBorder(BorderFactory.createEmptyBorder(14, 8, 14, 8));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,9 @@ public static void runInEventDispatchThread(final Runnable r) {
public static void runInEventDispatchThreadAndWait(final Runnable r) {
UIUtils.runInEventDispatchThreadAndWait(r);
}

public static boolean isDarkResultsBackground() {
return UIUtils.isDarkResultsBackground();
}

}

0 comments on commit 6010c00

Please sign in to comment.