Ticket #12415: TemporaryLayerUseAntialiasing.patch

File TemporaryLayerUseAntialiasing.patch, 5.1 KB (added by kolesar, 10 years ago)
  • src/org/openstreetmap/josm/data/osm/visitor/paint/AbstractMapRenderer.java

    diff --git a/src/org/openstreetmap/josm/data/osm/visitor/paint/AbstractMapRenderer.java b/src/org/openstreetmap/josm/data/osm/visitor/paint/AbstractMapRenderer.java
    index 205323e..b496391 100644
    a b package org.openstreetmap.josm.data.osm.visitor.paint;  
    44import java.awt.Color;
    55import java.awt.Graphics2D;
    66import java.awt.Point;
     7import java.awt.RenderingHints;
    78import java.awt.geom.GeneralPath;
    89import java.awt.geom.Point2D;
    910import java.util.Iterator;
    public abstract class AbstractMapRenderer implements Rendering {  
    5152
    5253    /** Preference: minimum space (displayed way length) to display segment numbers */
    5354    protected int segmentNumberSpace;
     55    /** Preference: use smooth graphics */
     56    protected Object antialiasing;
    5457
    5558    /**
    5659     * <p>Creates an abstract paint visitor</p>
    public abstract class AbstractMapRenderer implements Rendering {  
    229232            }
    230233        }
    231234    }
     235
     236    public void setAntialiasing(boolean antialiasing) {
     237        setAntialiasing(antialiasing ? RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF);
     238    }
     239
     240    public void setAntialiasing(Object antialiasing) {
     241        this.antialiasing = antialiasing;
     242        applyAntialiasing();
     243    }
     244
     245    public void applyAntialiasing() {
     246        if (antialiasing == null) getSettings(false);
     247        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, antialiasing);
     248    }
    232249}
  • src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java

    diff --git a/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java b/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
    index 3a61bf7..d35c529 100644
    a b public class StyledMapRenderer extends AbstractMapRenderer {  
    337337    private Font orderFont;
    338338
    339339    private boolean leftHandTraffic;
    340     private Object antialiasing;
    341340
    342341    /**
    343342     * Constructs a new {@code StyledMapRenderer}.
    public class StyledMapRenderer extends AbstractMapRenderer {  
    15321531        isOutlineOnly = paintSettings.isOutlineOnly();
    15331532        orderFont = new Font(Main.pref.get("mappaint.font", "Droid Sans"), Font.PLAIN, Main.pref.getInteger("mappaint.fontsize", 8));
    15341533
    1535         antialiasing = Main.pref.getBoolean("mappaint.use-antialiasing", true) ?
    1536                         RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF;
    1537         g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, antialiasing);
     1534        setAntialiasing(Main.pref.getBoolean("mappaint.use-antialiasing", true) ?
     1535                        RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF);
    15381536
    15391537        Object textAntialiasing;
    15401538        switch (Main.pref.get("mappaint.text-antialiasing", "default")) {
  • src/org/openstreetmap/josm/data/osm/visitor/paint/WireframeMapRenderer.java

    diff --git a/src/org/openstreetmap/josm/data/osm/visitor/paint/WireframeMapRenderer.java b/src/org/openstreetmap/josm/data/osm/visitor/paint/WireframeMapRenderer.java
    index aad01af..740c55b 100644
    a b public class WireframeMapRenderer extends AbstractMapRenderer implements Visitor  
    140140        fillConnectionNode = settings.isFillConnectionNode();
    141141        fillTaggedNode = settings.isFillTaggedNode();
    142142
    143         g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
    144                 Main.pref.getBoolean("mappaint.wireframe.use-antialiasing", false) ?
    145                         RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF);
     143        setAntialiasing(Main.pref.getBoolean("mappaint.wireframe.use-antialiasing", false) ?
     144            RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF);
    146145    }
    147146
    148147    /**
  • src/org/openstreetmap/josm/gui/MapView.java

    diff --git a/src/org/openstreetmap/josm/gui/MapView.java b/src/org/openstreetmap/josm/gui/MapView.java
    index b2e4b35..5ac7fa6 100644
    a b import org.openstreetmap.josm.data.coor.LatLon;  
    5151import org.openstreetmap.josm.data.imagery.ImageryInfo;
    5252import org.openstreetmap.josm.data.osm.DataSet;
    5353import org.openstreetmap.josm.data.osm.OsmPrimitive;
     54import org.openstreetmap.josm.data.osm.visitor.paint.MapRendererFactory;
    5455import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;
    5556import org.openstreetmap.josm.data.osm.visitor.paint.Rendering;
    5657import org.openstreetmap.josm.data.osm.visitor.paint.relations.MultipolygonCache;
    implements PropertyChangeListener, PreferenceChangedListener, OsmDataLayer.Layer  
    681682        }
    682683
    683684        Graphics2D tempG = offscreenBuffer.createGraphics();
     685        MapRendererFactory.getInstance().createActiveRenderer(tempG, (NavigatableComponent) this, false).applyAntialiasing();
    684686        tempG.setClip(g.getClip());
    685687        Bounds box = getLatLonBounds(g.getClipBounds());
    686688