Ignore:
Timestamp:
2017-10-09T15:22:45+02:00 (3 years ago)
Author:
bastiK
Message:

see #15273 - more straightforward way to set up the styles for rendering

File:
1 edited

Legend:

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

    r12963 r12964  
    2323import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors;
    2424import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
    25 import org.openstreetmap.josm.data.preferences.sources.SourceEntry;
    26 import org.openstreetmap.josm.data.preferences.sources.SourceType;
    2725import org.openstreetmap.josm.data.projection.Projection;
    2826import org.openstreetmap.josm.gui.NavigatableComponent;
     
    10098    public void render() throws IOException, IllegalDataException {
    10199        // load the styles
     100        ElemStyles elemStyles = new ElemStyles();
    102101        MapCSSStyleSource.STYLE_SOURCE_LOCK.writeLock().lock();
    103102        try {
    104             MapPaintStyles.getStyles().clear();
    105103            for (StyleData sd : styles) {
    106                 SourceEntry se = new SourceEntry(SourceType.MAP_PAINT_STYLE, sd.styleUrl,
    107                             "cliRenderingStyle", "cli rendering style '" + sd.styleUrl + "'", true /* active */);
    108                 StyleSource source = MapPaintStyles.addStyle(se);
     104                MapCSSStyleSource source = new MapCSSStyleSource(sd.styleUrl, "cliRenderingStyle", "cli rendering style '" + sd.styleUrl + "'");
     105                source.loadStyleSource();
     106                elemStyles.add(source);
    109107                if (!source.getErrors().isEmpty()) {
    110108                    throw new IllegalDataException("Failed to load style file. Errors: " + source.getErrors());
     
    156154        g.setColor(PaintColors.getBackgroundColor());
    157155        g.fillRect(0, 0, imgDimPx.width, imgDimPx.height);
    158         new StyledMapRenderer(g, nc, false).render(ds, false, bounds);
     156        StyledMapRenderer smr = new StyledMapRenderer(g, nc, false);
     157        smr.setStyles(elemStyles);
     158        smr.render(ds, false, bounds);
    159159
    160160        // write to file
Note: See TracChangeset for help on using the changeset viewer.