Opened 10 years ago
Last modified 10 years ago
#11838 closed enhancement
[Patch] Clean up MapView, put layer management to new class. — at Initial Version
| Reported by: | michael2402 | Owned by: | team |
|---|---|---|---|
| Priority: | normal | Milestone: | 16.06 |
| Component: | Core | Version: | |
| Keywords: | layers, gsoc-core | Cc: | Don-vip, bastiK, stoecker |
Description
During my GSoC, I had to fight a lot with the mess that MapView has become.
It's task should be to display the map. It does not really need to expose any public API for that. But searching for "Main.map.mapView" yields around 350 results, most of which are:
- Layer accesses
- Registering layer listeners
- playHeadMarker (should be converted to temporary layer and moved out of there)
- viewportFollowing (not even used anywhere in the MapView class, just a global flag)
- data query (getNearestWaySegment, ...)
- zoom/move calls
- repaint calls (they should also be reduced and repainting should e.g. be per-layer to allow for optimisation there. e.g. node moving simpy calls repaint() but does not trigger any event. Stuff like this requires active polling on every frame for the OpenGL code)
- coordinate conversion
The current layer listeners are relatively primitive and missing a move layer event.
Move the layers to a new class.
This patch attempts to improve that by:
- Move all layer code to a new LayerManager
- Move the active layer code to LayerManagerWithActive
- Define a new listener interface. Events are now wrapped in objects for easy extensibility.
- Synchronizing that LayerManager
- Get rid of that if/else code in addLayer(...). Use strategy pattern instead. This also allows plugins to define their preffered insertion position.
- Provide deprecated layer methods in MapView to not break plugins.
This patch is still not finished, since we should replace all layer access in JOSM with this new manager. But JOSM already works using the compatibility methods.
Since this is mostly a rewrite of the layer code, I cannot provide smaller patches.
Migration
Simply replace Main.map.mapView.getActiveLayer() with Main.layerManager.getActiveLayer() and so on. Most accesses to this are static.


