commonMain.org.jetbrains.letsPlot.livemap.config.LiveMapCanvasFigure.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of livemap-jvm Show documentation
Show all versions of livemap-jvm Show documentation
A part of the Lets-Plot library.
The newest version!
/*
* Copyright (c) 2020. JetBrains s.r.o.
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
*/
package org.jetbrains.letsPlot.livemap.config
import org.jetbrains.letsPlot.commons.intern.async.Async
import org.jetbrains.letsPlot.commons.geometry.Rectangle
import org.jetbrains.letsPlot.commons.intern.observable.property.ReadableProperty
import org.jetbrains.letsPlot.commons.intern.observable.property.ValueProperty
import org.jetbrains.letsPlot.commons.registration.Registration
import org.jetbrains.letsPlot.core.canvas.CanvasControl
import org.jetbrains.letsPlot.core.canvasFigure.CanvasFigure
import org.jetbrains.letsPlot.livemap.LiveMap
import org.jetbrains.letsPlot.livemap.canvascontrols.LiveMapPresenter
class LiveMapCanvasFigure (private val liveMap: Async) : CanvasFigure {
private val myBounds = ValueProperty(Rectangle(0, 0, 0, 0))
private val myLiveMapPresenter = LiveMapPresenter()
val isLoading: ReadableProperty
get() = myLiveMapPresenter.isLoading
fun setBounds(bounds: Rectangle) {
myBounds.set(bounds)
}
override fun bounds(): ReadableProperty {
return myBounds
}
override fun mapToCanvas(canvasControl: CanvasControl): Registration {
myLiveMapPresenter.render(canvasControl, liveMap)
return Registration.from(myLiveMapPresenter)
}
}