Changes between Initial Version and Version 6 of Ticket #11838


Ignore:
Timestamp:
2016-04-29T15:39:29+02:00 (10 years ago)
Author:
michael2402
Comment:

For this years GSoC, I will have time to dig this out again and work on this for one of the first things I am doing.

I adjusted the ticket to reflect my current design goals.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #11838

    • Property Owner changed from team to michael2402
    • Property Keywords gsoc-core added
    • Property Summary [Patch] Clean up MapView, put layer management to new class.Clean up MapView, put layer management to new class.
  • Ticket #11838 – Description

    initial v6  
    1 During my GSoC, I had to fight a lot with the mess that MapView has become.
     1== Move the layer core to a new class. ==
    22
    3 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:
    4 - Layer accesses
    5 - Registering layer listeners
    6 - playHeadMarker (should be converted to temporary layer and moved out of there)
    7 - viewportFollowing (not even used anywhere in the MapView class, just a global flag)
    8 - data query (getNearestWaySegment, ...)
    9 - zoom/move calls
    10 - 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)
    11 - coordinate conversion
    12 
    13 The current layer listeners are relatively primitive and missing a move layer event.
    14 
    15 == Move the layers to a new class. ==
    16 
    17 This patch attempts to improve that by:
    183- Move all layer code to a new ''LayerManager''
    194- Move the active layer code to ''LayerManagerWithActive''
    20 - Define a new listener interface. Events are now wrapped in objects for easy extensibility.
    21 - Synchronizing that LayerManager
    22 - Get rid of that if/else code in addLayer(...). Use strategy pattern instead. This also allows plugins to define their preffered insertion position.
    23 - Provide deprecated layer methods in MapView to not break plugins.
     5- Define a new listener interface. Events are now wrapped in objects for easy extensibility and all run in the UI thread
     6  - LayerAddEvent
     7  - LayerRemoveEvent
     8  - LayerOrderChangeEvent
     9  - ActiveLayerChangeEvent
     10- The LayerManager is completely synchronized
     11- Provide adapter layer methods in MapView to not break plugins.
     12- Make the layer list accessible using Main.getLayers() and Main.getTemporarayLayers()
    2413
    2514This 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.
     
    2716Since this is mostly a rewrite of the layer code, I cannot provide smaller patches.
    2817
     18Implementing this will require several steps, yielding at least one patch each:
     19
     20== Add the LayerManager ==
     21The main change. We replace the mapView layer code with the new code and add compatibility methods.
     22I'll be doing this between May 23 and May 27.
     23
     24== Add temporary layers ==
     25We can use the LayerManager to manage temporary layers as well.
     26I'll be doing this between May 23 and May 27.
     27
    2928== Migration ==
     29Simply replace ''Main.map.mapView.getActiveLayer()'' with ''Main.getLayers().getActiveLayer()'' and so on. Most accesses to this are static, so they should be easy to find.
    3030
    31 Simply replace ''Main.map.mapView.getActiveLayer()'' with ''Main.layerManager.getActiveLayer()'' and so on. Most accesses to this are static.
     31For some modules, it might be possible to add the LayerManager as private field. That way, we get rid of the dependency on a static Main access and make testing easier.
     32I'll be doing this between May 30 and June 3.