﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc
24637	[PATCH] MapCSS style cache should be dependent on ElemStyles instance	zkir	team	"== Use Case
The UbanEye3D plugin displays the active dataset in its own window with MapCSS style which can be different from the MapCSS style used in the main JOSM map view window.

(picture: see attachments).


== The issue in JOSM with MapCSS styles.

In JOSM, MapCSS style (style set) is represented as an instance of `ElemStyles` class. There can be several such instances.  However, currently there is **only one** cache for all instances of ElemStyles, which leads to the problem that only one style can be applied to all windows, and sometime crashes are produced, if different styles are specified.

== Suggested solution
Make the style cache dependent on ElemStyles instance:

* `StyleCache mappaintStyle` in OsmPrimitive and VectorPrimitive becomes `HashMap<ElemStyles,StyleCache>  mappaintStyle`. 
* Parameters of methods of Stylable interface are adjusted accordingly.  `Stylable.getCachedStyle()` becomes `Stylable.getCachedStyle(ElemStyles styles)`, e.t.c.

== Performance and memory impact

**Performance impact:** Performance tests via CLI **DO NOT** reveal any performance degradation (See detailed tests result in the comments below), which is expected, HashMap with just several items work quite fast.

**Memory impact:** Additional **48 bytes** are consumed by the newly added HashMap per OsmPrimitive. For comparison,  existing StyleCache field consumes 24 bytes (per OsmPrimitive).

== References
* UrbanEye3D branch with the feature in question can be found here:  https://github.com/Zkir/UrbanEye3D/tree/mapcss-layer
(Obviously it cannot be released until this issue in JOSM is fixed)"	defect	closed	normal	26.03	Core mappaint		fixed	MapCSS, ElemStyles, style cache, UrbanEye3D	
