DrawLayer
Keeps a WWK RenderableLayer in sync with entityRepository's live entity list, so a host app can add one DrawLayer to its WorldWindow and never touch WWK renderables directly.
Builds a WWK renderable only for what is new or changed: on every emission each renderable is looked up by what it was made from (the entity, whether it is selected or being edited, a live drag preview, the handle or highlight style...) and kept when that is unchanged. So selecting a shape, going into edit mode, deleting one or dragging a vertex touches only the shapes (and handles) involved, not every shape on the map — a rebuilt WWK shape costs its tessellation and GPU buffers again, which with hundreds of large polygons ran the heap out. The layer's content is then just the list of those renderables in draw order (polygons, then polylines, then markers, then the draft, then the editing handles), and it is only replaced when that list really differs.
Every renderable is tagged with its originating EntityId via ENTITY_ID_KEY (see Renderable.putUserProperty) — this is how adapter.input.PickInputBridge maps a WWK pick result back to a com.tcsappdev.worldwinddraw.core.geometry.DrawableEntity.
The entity DrawMode.Select/DrawMode.Edit names also gets a selection highlight (see HighlightMapper.kt): a separate, non-pickable outline/halo renderable, so the entity's own fill and style are never modified. These highlight renderables are deliberately NOT tagged with ENTITY_ID_KEY — they are never pick results.
While stateMachine reports DrawMode.Edit for a polygon/polyline, this layer also adds:
one small, individually pickable+Movable "vertex handle" Placemark per existing vertex, tagged with both ENTITY_ID_KEY and VERTEX_ID_KEY — dragging one moves that vertex (
PickInputBridgeresolves exactly which one from WWK's pick result, no geometry heuristic needed).one smaller, dimmer "midpoint handle" per edge, tagged with ENTITY_ID_KEY and EDGE_INDEX_KEY (not VERTEX_ID_KEY — it isn't a real vertex yet). Dragging one grows the shape a new vertex there, the same interaction Mapbox GL Draw/Google My Maps use. While one is actively being dragged (DrawMode.Edit.ActiveDrag.NewVertex), the shape's outline is rendered with that live position spliced in (so it visibly reshapes as you drag) and the midpoint handle for that specific edge is suppressed — the handle WWK is already dragging is standing in for it until
DragEndactually commits the insert.
onContentChanged must be wired to the host WorldWindow's own redraw request (e.g. worldWindow::requestRedraw). WWK's Android surface renders on demand (RENDERMODE_WHEN_DIRTY) and only redraws itself automatically in response to its own gesture pipeline (pan/zoom/an active drag). A change that lands outside of that — e.g. undo/redo, or any other host-triggered repository mutation — updates this layer's renderables correctly but leaves a stale frame on screen until something else happens to ask for a redraw. This was a real bug caught by visual verification, not something WWK documents: dragging a vertex looked correct (the drag gesture itself keeps requesting redraws), but hitting Undo right after silently changed the data with no visible effect until an unrelated touch forced a redraw.
Constructors
Properties
How big and what colour the edit handles are (see HandleStyle). Safe to change at any time — e.g. from a host app's settings screen — the layer rebuilds and redraws right away.
The colours of the selected/edited shape's outline (see HighlightStyle). Live-changeable, like handleStyle.
Functions
Pulses the selection highlight's opacity (see PULSE_DURATION_MS/PULSE_MIN_ALPHA). Register this layer with the host's AnimationController and tick that once per frame. Does nothing — and, importantly, asks for no redraw — while nothing is highlighted, so an idle map isn't redrawn every frame (WWK renders on demand, see onContentChanged).