Ticket #20706: antialias.patch

File antialias.patch, 3.0 KB (added by nvarner, 5 years ago)
  • src/org/openstreetmap/josm/gui/MainApplication.java

     
    10301030        }
    10311031        // Disable automatic POST retry after 5 minutes, see #17882 / https://bugs.openjdk.java.net/browse/JDK-6382788
    10321032        Utils.updateSystemProperty("sun.net.http.retryPost", "false");
     1033        // Force text antialiasing, not including mappaint text
     1034        if (Config.getPref().getBoolean("gui.forceAntialiasing", true)) {
     1035            Utils.updateSystemProperty("awt.useSystemAAFontSettings", "on");
     1036        }
    10331037    }
    10341038
    10351039    /**
  • src/org/openstreetmap/josm/gui/widgets/JosmEditorPane.java

     
    33
    44import java.awt.Color;
    55import java.awt.Font;
     6import java.awt.Graphics;
     7import java.awt.Graphics2D;
     8import java.awt.RenderingHints;
    69import java.io.IOException;
    710import java.io.InputStream;
    811import java.net.URL;
     
    1518import javax.swing.text.html.StyleSheet;
    1619
    1720import org.openstreetmap.josm.gui.util.GuiHelper;
     21import org.openstreetmap.josm.spi.preferences.Config;
    1822import org.openstreetmap.josm.tools.ColorHelper;
    1923import org.openstreetmap.josm.tools.Destroyable;
    2024import org.openstreetmap.josm.tools.HttpClient;
     
    2125import org.openstreetmap.josm.tools.LanguageInfo;
    2226
    2327/**
    24  * Subclass of {@link JEditorPane} that adds a "native" context menu (cut/copy/paste/select all)
    25  * and effectively uses JOSM user agent when performing HTTP request in {@link #setPage(URL)} method.
     28 * Subclass of {@link JEditorPane} that adds a "native" context menu (cut/copy/paste/select all), forces text and bullet
     29 * point antialiasing based on user preferences, and effectively uses JOSM user agent when performing HTTP request in
     30 * {@link #setPage(URL)} method.
    2631 * @since 5886
    2732 */
    2833public class JosmEditorPane extends JEditorPane implements Destroyable {
     
    8691        return conn.getContent();
    8792    }
    8893
     94    @Override
     95    public void paintComponent(Graphics g) {
     96        // Force antialiasing within the JosmEditorPane for antialiased bullet points
     97        if (Config.getPref().getBoolean("gui.forceAntialiasing", true)) {
     98            Graphics2D g2d = (Graphics2D) g.create();
     99            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
     100            g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
     101            super.paintComponent(g2d);
     102            g2d.dispose();
     103        } else {
     104            super.paintComponent(g);
     105        }
     106    }
     107
    89108    /**
    90109     * Adapts a {@link JEditorPane} to be used as a powerful replacement of {@link javax.swing.JLabel}.
    91110     * @param pane The editor pane to adapt