-
Notifications
You must be signed in to change notification settings - Fork 47
/
LiveMapContent.kt
32 lines (26 loc) · 994 Bytes
/
LiveMapContent.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package jetbrains.livemap.canvascontrols
import jetbrains.datalore.base.observable.event.EventHandler
import jetbrains.datalore.base.observable.event.EventSource
import jetbrains.datalore.base.registration.Registration
import jetbrains.datalore.visualization.base.canvas.CanvasControl
import jetbrains.livemap.BaseLiveMap
class LiveMapContent(private val liveMap: BaseLiveMap) : CanvasContent, EventSource<Throwable> {
override fun show(parentControl: CanvasControl) {
liveMap.draw(parentControl)
}
override fun hide() {
liveMap.dispose()
}
override fun addHandler(handler: EventHandler<Throwable>): Registration {
return liveMap.addHandler(handler)
}
fun addHandler(handler: (Throwable) -> Unit): Registration {
return liveMap.addHandler(
object : EventHandler<Throwable> {
override fun onEvent(event: Throwable) {
handler(event)
}
}
)
}
}