Browse Source

Log choice of antialiasing settings.

pull/187/head
weisj 4 years ago
parent
commit
f7355b467e
  1. 34
      core/src/main/java/com/github/weisj/darklaf/graphics/StringPainter.java
  2. 5
      core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java
  3. 2
      core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java

34
core/src/main/java/com/github/weisj/darklaf/graphics/StringPainter.java

@ -35,11 +35,11 @@ import javax.swing.*;
import javax.swing.plaf.basic.BasicHTML;
import javax.swing.text.View;
import sun.swing.SwingUtilities2;
import com.github.weisj.darklaf.ui.OpacityBufferedUI;
import com.github.weisj.darklaf.util.*;
import sun.swing.SwingUtilities2;
public class StringPainter {
private static final Logger LOGGER = LogUtil.getLogger(StringPainter.class);
@ -264,23 +264,27 @@ public class StringPainter {
return g;
}
public static void paintOpacityBuffered(final Graphics g, final JComponent c, final OpacityBufferedUI ui) {
public static void paintOpacityBufferedUI(final Graphics g, final JComponent c, final OpacityBufferedUI ui) {
boolean opaqueBuffered = translucentAAPaintingEnabled && GraphicsUtil.isOpaqueBuffered(c);
if (opaqueBuffered) {
double scaleX = Scale.getScaleX((Graphics2D) g);
double scaleY = Scale.getScaleX((Graphics2D) g);
BufferedImage img = ImageUtil.createCompatibleImage((int) Math.round(scaleX * c.getWidth()),
(int) Math.round(scaleY * c.getHeight()));
Graphics imgGraphics = img.getGraphics();
imgGraphics.setColor(c.getBackground());
imgGraphics.fillRect(0, 0, c.getWidth(), c.getHeight());
imgGraphics.setClip(0, 0, img.getWidth(), img.getHeight());
((Graphics2D) imgGraphics).scale(scaleX, scaleY);
ui.updateUI(imgGraphics, c);
imgGraphics.dispose();
g.drawImage(img, 0, 0, c.getWidth(), c.getHeight(), null);
paintOpacityBuffered(g, c, ui);
} else {
ui.updateUI(g, c);
}
}
public static void paintOpacityBuffered(final Graphics g, final JComponent c, final OpacityBufferedUI ui) {
double scaleX = Scale.getScaleX((Graphics2D) g);
double scaleY = Scale.getScaleX((Graphics2D) g);
BufferedImage img = ImageUtil.createCompatibleImage((int) Math.round(scaleX * c.getWidth()),
(int) Math.round(scaleY * c.getHeight()));
Graphics imgGraphics = img.getGraphics();
imgGraphics.setColor(c.getBackground());
imgGraphics.fillRect(0, 0, c.getWidth(), c.getHeight());
imgGraphics.setClip(0, 0, img.getWidth(), img.getHeight());
((Graphics2D) imgGraphics).scale(scaleX, scaleY);
ui.updateUI(imgGraphics, c);
imgGraphics.dispose();
g.drawImage(img, 0, 0, c.getWidth(), c.getHeight(), null);
}
}

5
core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java

@ -114,6 +114,11 @@ public class FontDefaultsInitTask implements DefaultsInitTask {
if (aaHint != null
&& aaHint != RenderingHints.VALUE_TEXT_ANTIALIAS_OFF
&& aaHint != RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT) {
LOGGER.fine(String.format("Setting '%s' = '%s'",
RenderingHints.KEY_TEXT_ANTIALIASING, aaHint));
LOGGER.fine(String.format("Setting '%s' = '%s'",
RenderingHints.KEY_TEXT_LCD_CONTRAST,
RenderingHints.KEY_TEXT_LCD_CONTRAST));
defaults.put(RenderingHints.KEY_TEXT_ANTIALIASING, aaHint);
defaults.put(RenderingHints.KEY_TEXT_LCD_CONTRAST,
desktopHints.get(RenderingHints.KEY_TEXT_LCD_CONTRAST));

2
core/src/main/java/com/github/weisj/darklaf/ui/text/DarkTextUI.java

@ -307,7 +307,7 @@ public abstract class DarkTextUI extends BasicTextUI implements PropertyChangeLi
@Override
public void update(final Graphics g, final JComponent c) {
StringPainter.paintOpacityBuffered(g, c, this);
StringPainter.paintOpacityBufferedUI(g, c, this);
}
@Override

Loading…
Cancel
Save