Changeset 19549 in josm


Ignore:
Timestamp:
2026-03-19T14:31:13+01:00 (3 days ago)
Author:
stoecker
Message:

fix #24678 - Possibility to specify custom MapPaintSettings for MapCSS rendering - patch by zkir

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPaintSettings.java

    r17874 r19549  
    7272    }
    7373
     74    /**
     75     * Creates MapPaintSettings with most neutral settings, that do not override MapCSS.
     76     * Useful for MapCSS CLI/Plugin rendering, via {@link org.openstreetmap.josm.gui.mappaint.RenderingHelper}
     77     * @return a new MapPaintSettings instance with neutral values.
     78     * @since 19549
     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);
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java

    r19050 r19549  
    384384
    385385    /**
     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     * @since 19549
     397     */
     398    public StyledMapRenderer(Graphics2D g, NavigatableComponent nc, boolean isInactiveMode, MapPaintSettings paintSettings) {
     399        this(g, nc, isInactiveMode);
     400        this.paintSettings = paintSettings;
     401    }
     402
     403    /**
    386404     * Set the {@link ElemStyles} instance to use for this renderer.
    387405     * @param styles the {@code ElemStyles} instance to use
     
    14111429    public void getSettings(boolean virtual) {
    14121430        super.getSettings(virtual);
    1413         paintSettings = MapPaintSettings.INSTANCE;
     1431        if (paintSettings == null) {
     1432            paintSettings = MapPaintSettings.INSTANCE;
     1433        }
    14141434
    14151435        circum = nc.getDist100Pixel();
  • trunk/src/org/openstreetmap/josm/gui/mappaint/RenderingHelper.java

    r19519 r19549  
    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;
     
    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);
Note: See TracChangeset for help on using the changeset viewer.