Changeset 16100 in josm


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

see #18468 - MapCSSRendererTest: generate style debugging output

Location:
trunk
Files:
4 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}
  • trunk/test/data/renderer/node-text2/data.osm

    r12978 r16100  
    55    <tag k='name' v='Hgmpf' />
    66    <tag k='test' v='text-placement' />
     7    <tag k='debug' v='yes' />
    78  </node>
    89</osm>
  • trunk/test/data/renderer/way-text/data.osm

    r12476 r16100  
    4444    <tag k='name' v='An der Actien-Zuckerfabrik' />
    4545    <tag k='test' v='w1' />
     46    <tag k='debug' v='yes' />
    4647  </way>
    4748  <way id='-41280' action='modify'>
  • trunk/test/functional/org/openstreetmap/josm/gui/mappaint/MapCSSRendererTest.java

    r16094 r16100  
    192192        RenderingHelper rh = new RenderingHelper(dataSet, testConfig.getTestArea(), scale, Collections.singleton(sd));
    193193        rh.setFillBackground(false);
     194        rh.setDebugStream(System.out);
     195        System.out.println("Running " + getClass() + "[" + testConfig.testDirectory + "]");
    194196        BufferedImage image = rh.render();
    195197
Note: See TracChangeset for help on using the changeset viewer.