diff options
author | Jakob Odersky <jakob@odersky.com> | 2016-02-24 20:33:51 -0800 |
---|---|---|
committer | Jakob Odersky <jakob@odersky.com> | 2016-02-24 20:33:51 -0800 |
commit | 8186b3622ce1c9d2b50df3d264ab526dc1e61d77 (patch) | |
tree | b4446408291c9f179e1c270a561523023ac6a105 /mavigator-cockpit/src/main/scala/mavigator/dashboard/ui/instruments/Distribution.scala | |
parent | 6c4e8849d753734b3e50523dcdb372fbdbccc2c1 (diff) | |
parent | a41de68066007852d7d3dbf019d75b4caf7463ad (diff) | |
download | mavigator-8186b3622ce1c9d2b50df3d264ab526dc1e61d77.tar.gz mavigator-8186b3622ce1c9d2b50df3d264ab526dc1e61d77.tar.bz2 mavigator-8186b3622ce1c9d2b50df3d264ab526dc1e61d77.zip |
Merge branch 'akka-streams'
Diffstat (limited to 'mavigator-cockpit/src/main/scala/mavigator/dashboard/ui/instruments/Distribution.scala')
-rw-r--r-- | mavigator-cockpit/src/main/scala/mavigator/dashboard/ui/instruments/Distribution.scala | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/mavigator-cockpit/src/main/scala/mavigator/dashboard/ui/instruments/Distribution.scala b/mavigator-cockpit/src/main/scala/mavigator/dashboard/ui/instruments/Distribution.scala new file mode 100644 index 0000000..aadafe0 --- /dev/null +++ b/mavigator-cockpit/src/main/scala/mavigator/dashboard/ui/instruments/Distribution.scala @@ -0,0 +1,25 @@ +package mavigator.dashboard.ui.instruments + +import org.scalajs.dom.html +import rx._ +import mavigator.util.Environment + +class Distribution(val value: Rx[(Double, Double, Double, Double)])(implicit env: Environment) extends SvgInstrument[(Double, Double, Double, Double)] { + import SvgInstrument._ + + lazy val element = svgObject("distribution") + lazy val position = part("position") + lazy val moveable = Seq(position) + + private final val Radius = 50 //px + + protected def update(value: (Double, Double, Double, Double)) = { + val sum = value._1 + value._2 + value._3 + value._4 + val i = (value._1 - value._3) / sum + val j = (value._2 - value._4) / sum + val x = math.sqrt(2) / 2 * (i - j) + val y = math.sqrt(2) / 2 * (-i - j) + translate(position, (x * Radius).toInt, (y * Radius).toInt) + } + +} |