@@ -5,6 +5,16 @@ import scala.language.implicitConversions // TODO: remove the need for this
5
5
// TODO: This is copied from old Scala 2 code in reqT v3; it should be migrated and improved
6
6
object quper {
7
7
8
+ extension (m : Model )
9
+ def toQuperSpec : QuperSpec =
10
+ def mapOf (et : EntType ): Map [String ,Estimate ] =
11
+ m.atoms.collect{ case Rel (e,l,t) if e.t == et && (t/ Value ).nonEmpty => (e.id,Estimate ((t/ Value ).head)) }.toMap
12
+ val nonRefs = Set [EntType ](Target ,Barrier ,Breakpoint )
13
+ val refMap = m.atoms.collect{
14
+ case Rel (e,l,t) if ! nonRefs.contains(e.t) && (t/ Value ).nonEmpty =>
15
+ (e.id,Estimate ((t/ Value ).head)) }.toMap
16
+ QuperSpec (mapOf(Breakpoint ), mapOf(Barrier ), mapOf(Target ), refMap)
17
+
8
18
trait Estimate {
9
19
def min : Int
10
20
def max : Int
@@ -31,8 +41,7 @@ object quper {
31
41
case _ => TriangleEstimate (min, value, max)
32
42
}
33
43
}
34
- implicit def intToEstimate (i : Int ): Estimate = Estimate (i)
35
-
44
+ implicit def intToEstimate (i : Int ): Estimate = Estimate (i) // TODO: remove this
36
45
37
46
case class QuperSpec (
38
47
breakpoints : Map [String , Estimate ],
@@ -45,7 +54,7 @@ object quper {
45
54
lazy val minValue = values.map(_.value).min
46
55
47
56
def toSvgElem (dx : Int , dy : Int ): scala.xml.Elem = {
48
- val (axisLength, imageHeight) = (600.0 , 600 )
57
+ val (axisLength, imageHeight) = (600.0 , 800 )
49
58
def normalize (value : Int ): Double = axisLength* (value- minValue)/ (maxValue- minValue)
50
59
<svg width ={s " ${axisLength+ 500 }" } height ={s " $imageHeight" } font-family =" sans-serif" >
51
60
{ svg.axis(" " , axisLength, dx, dy) }
@@ -54,9 +63,9 @@ object quper {
54
63
{ barriers.map{case (b, e) =>
55
64
svg.barrier(b, e.value, normalize, svg.color(" barr" ), dx, dy)}}
56
65
{ targets.map{case (t, e) =>
57
- svg.marker(" Target" ,t, e.value, normalize, - 25 , svg.color(" targ" ), dx, dy)}}
66
+ svg.marker(" Target" ,t, e.value, normalize, - 30 , svg.color(" targ" ), dx, dy)}}
58
67
{ references.map{case (t, e) =>
59
- svg.marker(" Ref" ,t, e.value, normalize, - 25 , svg.color(" refe" ), dx, dy)}}
68
+ svg.marker(" Ref" ,t, e.value, normalize, - 20 , svg.color(" refe" ), dx, dy)}}
60
69
</svg >
61
70
}
62
71
0 commit comments