aboutsummaryrefslogtreecommitdiff
path: root/mavigator-dashboard/src/main/scala/mavigator/dashboard/ui/instruments/Distribution.scala
diff options
context:
space:
mode:
authorJakob Odersky <jodersky@gmail.com>2015-12-28 11:54:00 +0100
committerJakob Odersky <jakob@odersky.com>2016-01-29 13:50:37 -0800
commit4f4c799a6d9ccf333a3e609a2464e2f317875af7 (patch)
tree599232dd8c97fa9eb8f3426ea4375216ecadb386 /mavigator-dashboard/src/main/scala/mavigator/dashboard/ui/instruments/Distribution.scala
parentc77bf21e7f4c197d34d23b2aebe5953a75d099e2 (diff)
downloadmavigator-4f4c799a6d9ccf333a3e609a2464e2f317875af7.tar.gz
mavigator-4f4c799a6d9ccf333a3e609a2464e2f317875af7.tar.bz2
mavigator-4f4c799a6d9ccf333a3e609a2464e2f317875af7.zip
Rename project and update dependencies
Diffstat (limited to 'mavigator-dashboard/src/main/scala/mavigator/dashboard/ui/instruments/Distribution.scala')
-rw-r--r--mavigator-dashboard/src/main/scala/mavigator/dashboard/ui/instruments/Distribution.scala25
1 files changed, 25 insertions, 0 deletions
diff --git a/mavigator-dashboard/src/main/scala/mavigator/dashboard/ui/instruments/Distribution.scala b/mavigator-dashboard/src/main/scala/mavigator/dashboard/ui/instruments/Distribution.scala
new file mode 100644
index 0000000..f750bab
--- /dev/null
+++ b/mavigator-dashboard/src/main/scala/mavigator/dashboard/ui/instruments/Distribution.scala
@@ -0,0 +1,25 @@
+package vfd.dashboard.ui.instruments
+
+import org.scalajs.dom.html
+import rx._
+import vfd.dashboard.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)
+ }
+
+} \ No newline at end of file