Changeset 12964 in josm for trunk/src/org
- Timestamp:
- 2017-10-09T15:22:45+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/ComputeStyleListWorker.java
r12846 r12964 36 36 private final transient List<StyleRecord> output; 37 37 38 private final transient ElemStyles styles = MapPaintStyles.getStyles();38 private final transient ElemStyles styles; 39 39 private final int directExecutionTaskSize; 40 40 private final double circum; … … 55 55 ComputeStyleListWorker(double circum, NavigatableComponent nc, 56 56 final List<? extends OsmPrimitive> input, List<StyleRecord> output, int directExecutionTaskSize) { 57 this(circum, nc, input, output, directExecutionTaskSize, MapPaintStyles.getStyles()); 58 } 59 60 /** 61 * Constructs a new {@code ComputeStyleListWorker}. 62 * @param circum distance on the map in meters that 100 screen pixels represent 63 * @param nc navigatable component 64 * @param input the primitives to process 65 * @param output the list of styles to which styles will be added 66 * @param directExecutionTaskSize the threshold deciding whether to subdivide the tasks 67 * @param styles the {@link ElemStyles} instance used to generate primitive {@link StyleElement}s. 68 * @since 12964 69 */ 70 ComputeStyleListWorker(double circum, NavigatableComponent nc, 71 final List<? extends OsmPrimitive> input, List<StyleRecord> output, int directExecutionTaskSize, 72 ElemStyles styles) { 57 73 this.circum = circum; 58 74 this.nc = nc; … … 60 76 this.output = output; 61 77 this.directExecutionTaskSize = directExecutionTaskSize; 78 this.styles = styles; 62 79 this.drawArea = circum <= Config.getPref().getInt("mappaint.fillareas", 10_000_000); 63 80 this.drawMultipolygon = drawArea && Config.getPref().getBoolean("mappaint.multipolygon", true); … … 75 92 final int toIndex = Math.min(fromIndex + directExecutionTaskSize, input.size()); 76 93 tasks.add(new ComputeStyleListWorker(circum, nc, input.subList(fromIndex, toIndex), 77 new ArrayList<>(directExecutionTaskSize), directExecutionTaskSize ).fork());94 new ArrayList<>(directExecutionTaskSize), directExecutionTaskSize, styles).fork()); 78 95 } 79 96 for (ForkJoinTask<List<StyleRecord>> task : tasks) { -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
r12876 r12964 65 65 import org.openstreetmap.josm.gui.draw.MapViewPath; 66 66 import org.openstreetmap.josm.gui.draw.MapViewPositionAndRotation; 67 import org.openstreetmap.josm.gui.mappaint.ElemStyles; 68 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles; 67 69 import org.openstreetmap.josm.gui.mappaint.styleelement.BoxTextElement; 68 70 import org.openstreetmap.josm.gui.mappaint.styleelement.BoxTextElement.HorizontalTextAlignment; … … 261 263 262 264 private MapPaintSettings paintSettings; 265 private ElemStyles styles; 263 266 264 267 private Color highlightColorTransparent; … … 345 348 Component focusOwner = FocusManager.getCurrentManager().getFocusOwner(); 346 349 useWiderHighlight = !(focusOwner instanceof AbstractButton || focusOwner == nc); 350 this.styles = MapPaintStyles.getStyles(); 351 } 352 353 /** 354 * Set the {@link ElemStyles} instance to use for this renderer. 355 * @param styles the {@code ElemStyles} instance to use 356 */ 357 public void setStyles(ElemStyles styles) { 358 this.styles = styles; 347 359 } 348 360 … … 1626 1638 // (Could be synchronized, but try to avoid this for performance reasons.) 1627 1639 THREAD_POOL.invoke(new ComputeStyleListWorker(circum, nc, relations, allStyleElems, 1628 Math.max(20, relations.size() / THREAD_POOL.getParallelism() / 3) ));1640 Math.max(20, relations.size() / THREAD_POOL.getParallelism() / 3), styles)); 1629 1641 THREAD_POOL.invoke(new ComputeStyleListWorker(circum, nc, new CompositeList<>(nodes, ways), allStyleElems, 1630 Math.max(100, (nodes.size() + ways.size()) / THREAD_POOL.getParallelism() / 3) ));1642 Math.max(100, (nodes.size() + ways.size()) / THREAD_POOL.getParallelism() / 3), styles)); 1631 1643 1632 1644 if (!benchmark.renderSort()) { -
trunk/src/org/openstreetmap/josm/gui/mappaint/RenderingHelper.java
r12963 r12964 23 23 import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors; 24 24 import 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;27 25 import org.openstreetmap.josm.data.projection.Projection; 28 26 import org.openstreetmap.josm.gui.NavigatableComponent; … … 100 98 public void render() throws IOException, IllegalDataException { 101 99 // load the styles 100 ElemStyles elemStyles = new ElemStyles(); 102 101 MapCSSStyleSource.STYLE_SOURCE_LOCK.writeLock().lock(); 103 102 try { 104 MapPaintStyles.getStyles().clear();105 103 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); 109 107 if (!source.getErrors().isEmpty()) { 110 108 throw new IllegalDataException("Failed to load style file. Errors: " + source.getErrors()); … … 156 154 g.setColor(PaintColors.getBackgroundColor()); 157 155 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); 159 159 160 160 // write to file
Note:
See TracChangeset
for help on using the changeset viewer.