Ticket #24678: patch-24678-v2.diff

File patch-24678-v2.diff, 9.8 KB (added by zkir, 4 days ago)

Patch, version 2, much shorter.

  • src/org/openstreetmap/josm/data/osm/visitor/paint/MapPaintSettings.java

    diff --git a/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPaintSettings.java b/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPaintSettings.java
    index a5111b2b24..955695ccf1 100644
    a b public final class MapPaintSettings implements PreferenceChangedListener {  
    7171        Config.getPref().addPreferenceChangeListener(this);
    7272    }
    7373
     74
     75    /**
     76     * Creates MapPaintSettings with most neutral settings, that do not override MapCSS.
     77     * Useful for MapCSS CLI/Plugin rendering, via {@link org.openstreetmap.josm.gui.mappaint.RenderingHelper}
     78     * @return a new MapPaintSettings instance with neutral values.
     79     */
     80    public static MapPaintSettings createNeutralSettings() {
     81        MapPaintSettings neutralSettings = new MapPaintSettings();
     82        neutralSettings.useRealWidth = false; // Real width is not used (at least currently)
     83        neutralSettings.showDirectionArrow = false; // Direction arrows are turned off
     84        neutralSettings.showOnewayArrow = false; // One way arrows are disabled
     85        neutralSettings.showNamesDistance = 0; // Forced labels are turned off
     86        neutralSettings.showOrderNumber = false;
     87        neutralSettings.showOrderNumberOnSelectedWay = false;
     88        neutralSettings.outlineOnly = false;
     89        return neutralSettings;
     90    }
     91
    7492    private void load() {
    7593        showDirectionArrow = Config.getPref().getBoolean("draw.segment.direction", false);
    7694        showOnewayArrow = Config.getPref().getBoolean("draw.oneway", true);
  • 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 f49eb1e332..47909742c1 100644
    a b public class StyledMapRenderer extends AbstractMapRenderer {  
    382382        this.styles = MapPaintStyles.getStyles();
    383383    }
    384384
     385    /**
     386     * Constructs a new {@code StyledMapRenderer} with custom map paint settings.
     387     *
     388     * @param g the graphics context. Must not be null.
     389     * @param nc the map viewport. Must not be null.
     390     * @param isInactiveMode if true, the paint visitor shall render OSM objects such that they
     391     * look inactive. Example: rendering of data in an inactive layer using light gray as color only.
     392     * @param paintSettings the map paint settings to use. Must not be null.
     393     * @throws IllegalArgumentException if {@code g} is null
     394     * @throws IllegalArgumentException if {@code nc} is null
     395     * @throws IllegalArgumentException if {@code paintSettings} is null
     396     */
     397    public StyledMapRenderer(Graphics2D g, NavigatableComponent nc, boolean isInactiveMode, MapPaintSettings paintSettings) {
     398        this(g, nc, isInactiveMode);
     399        this.paintSettings = paintSettings;
     400    }
     401
    385402    /**
    386403     * Set the {@link ElemStyles} instance to use for this renderer.
    387404     * @param styles the {@code ElemStyles} instance to use
    public class StyledMapRenderer extends AbstractMapRenderer {  
    14101427    @Override
    14111428    public void getSettings(boolean virtual) {
    14121429        super.getSettings(virtual);
    1413         paintSettings = MapPaintSettings.INSTANCE;
     1430        if (paintSettings == null) {
     1431            paintSettings = MapPaintSettings.INSTANCE;
     1432        }
    14141433
    14151434        circum = nc.getDist100Pixel();
    14161435        scale = nc.getScale();
  • src/org/openstreetmap/josm/gui/mappaint/RenderingHelper.java

    diff --git a/src/org/openstreetmap/josm/gui/mappaint/RenderingHelper.java b/src/org/openstreetmap/josm/gui/mappaint/RenderingHelper.java
    index 93f524a944..c8fab26cae 100644
    a b import org.openstreetmap.josm.data.projection.ProjectionRegistry;  
    2626import org.openstreetmap.josm.gui.NavigatableComponent;
    2727import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
    2828import org.openstreetmap.josm.gui.mappaint.styleelement.StyleElement;
     29import org.openstreetmap.josm.data.osm.visitor.paint.MapPaintSettings;
    2930import org.openstreetmap.josm.io.IllegalDataException;
    3031import org.openstreetmap.josm.tools.CheckParameterUtil;
    3132import org.openstreetmap.josm.tools.Logging;
    public class RenderingHelper {  
    183184            g.setColor(Optional.ofNullable(backgroundColor).orElse(elemStyles.getBackgroundColor()));
    184185            g.fillRect(0, 0, imgDimPx.width, imgDimPx.height);
    185186        }
    186         StyledMapRenderer smr = new StyledMapRenderer(g, nc, false);
     187        StyledMapRenderer smr = new StyledMapRenderer(g, nc, false, MapPaintSettings.createNeutralSettings());
    187188        smr.setStyles(elemStyles);
    188189        smr.render(ds, false, bounds);
    189190