Changeset 16100 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2020-03-09T00:35:05+01:00 (5 years ago)
Author:
simon04
Message:

see #18468 - MapCSSRendererTest: generate style debugging output

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/RenderingHelper.java

    r15731 r16100  
    1111import java.awt.image.BufferedImage;
    1212import java.io.IOException;
     13import java.io.PrintStream;
    1314import java.util.Collection;
    1415import java.util.HashMap;
     
    1920import org.openstreetmap.josm.data.ProjectionBounds;
    2021import org.openstreetmap.josm.data.osm.DataSet;
     22import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2123import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
    2224import org.openstreetmap.josm.data.projection.Projection;
     
    2426import org.openstreetmap.josm.gui.NavigatableComponent;
    2527import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
     28import org.openstreetmap.josm.gui.mappaint.styleelement.StyleElement;
    2629import org.openstreetmap.josm.io.IllegalDataException;
    2730import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    4144    private Color backgroundColor;
    4245    private boolean fillBackground = true;
     46    private PrintStream debugStream;
    4347
    4448    /**
     
    183187        smr.setStyles(elemStyles);
    184188        smr.render(ds, false, bounds);
     189
     190        // For debugging, write computed StyleElement to debugStream for primitives marked with debug=yes
     191        if (debugStream != null) {
     192            for (OsmPrimitive primitive : ds.allPrimitives()) {
     193                if (!primitive.isKeyTrue("debug")) {
     194                    continue;
     195                }
     196                debugStream.println(primitive);
     197                for (StyleElement styleElement : elemStyles.get(primitive, scale, nc)) {
     198                    debugStream.append(" * ").println(styleElement);
     199                }
     200            }
     201        }
     202
    185203        return image;
    186204    }
    187205
     206    void setDebugStream(PrintStream debugStream) {
     207        this.debugStream = debugStream;
     208    }
    188209}
Note: See TracChangeset for help on using the changeset viewer.