﻿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)

**Memory impact:** Additional **48 bytes** are consumed by the newly added HashMap per OsmPrimitive. In comparison,  existing StyleCache field consumes 24 bytes.

    size of HashMap: java.util.HashMap object internals:
    OFF  SZ                       TYPE DESCRIPTION               VALUE
      0   8                            (object header: mark)     0x0000000000000009 (non-biasable; age: 1)
      8   4                            (object header: class)    0x002013d8
     12   4              java.util.Set AbstractMap.keySet        null
     16   4       java.util.Collection AbstractMap.values        null
     20   4   java.util.HashMap.Node[] HashMap.table             [(object), null, null, null, null, null, null, null, null, null, null, null, null, null, null, null]
     24   4              java.util.Set HashMap.entrySet          null
     28   4                        int HashMap.size              1
     32   4                        int HashMap.modCount          7
     36   4                        int HashMap.threshold         12
     40   4                      float HashMap.loadFactor        0.75
     44   4                            (object alignment gap)
    Instance size: 48 bytes

== 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	new	normal	26.03	Core mappaint			MapCSS, ElemStyles, style cache, UrbanEye3D	
