anti aliasing

This commit is contained in:
Konstantin Bulenkov
2012-03-14 16:13:25 +01:00
parent c8d5ccc8c4
commit 68e293f16e
5 changed files with 25 additions and 33 deletions
@@ -300,29 +300,7 @@ public class UISettings implements PersistentStateComponent<UISettings>, Exporta
UISettings uiSettings=getInstance();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_OFF);
if (uiSettings == null || uiSettings.ANTIALIASING_IN_EDITOR) {
Toolkit tk = Toolkit.getDefaultToolkit();
//noinspection HardCodedStringLiteral
Map map = (Map)tk.getDesktopProperty("awt.font.desktophints");
if (map != null) {
if (isRemoteDesktopConnected()) {
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT);
}
else {
g2d.addRenderingHints(map);
}
}
else {
if (SystemInfo.isUnix) {
GraphicsUtil.installAntialiasing(g2d);
} else {
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
}
}
}
else {
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
}
GraphicsUtil.setupAntialiasing(g2d, uiSettings == null || uiSettings.ANTIALIASING_IN_EDITOR);
}
/**
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@ import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.ui.ColorUtil;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.util.ui.GraphicsUtil;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -295,7 +296,9 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent
}
@Override
protected void paintComponent(Graphics g) {
public void paint(Graphics g) {
GraphicsUtil.setupAntialiasing(g);
final boolean isEmpty = getIcon() == null && StringUtil.isEmpty(getText());
final Dimension size = getSize();
if (isSmallVariant()) {
@@ -311,8 +314,7 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent
new GradientPaint(0, 0, ColorUtil.shift(UIUtil.getControlColor(), 1.1), 0, h, ColorUtil.shift(UIUtil.getControlColor(), 0.9)));
}
g2.fillRect(2, 0, w - 2, h);
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
GraphicsUtil.setupAntialiasing(g2);
if (!myMouseInside) {
g2.setPaint(new GradientPaint(0, 0, UIUtil.getBorderColor(), 0, h, UIUtil.getBorderColor().darker()));
//g2.setColor(UIUtil.getBorderColor());
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -743,7 +743,7 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl
@Override
public void paint(Graphics g, JComponent c) {
GraphicsUtil.installAntialiasing(g);
GraphicsUtil.setupAntialiasing(g);
super.paint(g, c);
}
}
@@ -787,8 +787,6 @@ public class BalloonImpl implements Balloon, IdeTooltip.Ui {
void paintComponent(BalloonImpl balloon, final Rectangle bounds, final Graphics2D g, Point pointTarget, JComponent component) {
final GraphicsConfig cfg = new GraphicsConfig(g);
GraphicsUtil.installAntialiasing(g);
Shape shape;
if (balloon.myShowPointer) {
@@ -18,15 +18,29 @@ package com.intellij.util.ui;
import org.jetbrains.annotations.NotNull;
import java.awt.*;
import java.util.Map;
/**
* @author Konstantin Bulenkov
*/
public class GraphicsUtil {
public static void installAntialiasing(@NotNull Graphics g2) {
public static void setupAntialiasing(@NotNull Graphics g2) {
setupAntialiasing(g2, true);
}
public static void setupAntialiasing(Graphics g2, boolean enable) {
if (g2 instanceof Graphics2D) {
Graphics2D g = (Graphics2D)g2;
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
Toolkit tk = Toolkit.getDefaultToolkit();
//noinspection HardCodedStringLiteral
Map map = (Map)tk.getDesktopProperty("awt.font.desktophints");
if (map != null) {
g.addRenderingHints(map);
} else {
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
enable ? RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF);
}
}
}
}