Commit 42ff324e authored by h2b's avatar h2b

Charts cleaned up.

parent bf0e73f6
......@@ -39,8 +39,6 @@ import de.h2b.scala.lib.simgraf.{ Color, ColorIterator, Point, World }
case class BarChart (val heights: Seq[Double], val colors: Seq[Color])
(implicit val enc: Enclosing) extends Drawable with Fillable {
private val iterator = ColorIterator.over(colors: _*)
def draw (w: World): Unit =
display(w, (p1: Point, p2: Point) Rectangle(p1, p2).draw(w))
......@@ -50,6 +48,7 @@ case class BarChart (val heights: Seq[Double], val colors: Seq[Color])
private def display (w: World, f: (Point, Point) Unit): Unit = {
if (heights.isEmpty) return
val activeColor = w.activeColor
val iterator = ColorIterator.over(colors: _*)
val (wl, wr, wb, wt) = enc.lrbt(w)
val barWidth = (wr-wl)/heights.size
var x = wl
......
......@@ -38,8 +38,6 @@ import de.h2b.scala.lib.simgraf.{ Color, ColorIterator, Point, World }
case class PieChart (val weights: Seq[Double], val colors: Seq[Color])
(implicit val enc: Enclosing) extends Drawable with Fillable {
private val iterator = ColorIterator.over(colors: _*)
def draw (w: World): Unit =
display(w, (alpha1: Double, alpha2: Double)
Arc(Point(0,0), width(w), height(w), alpha1, alpha2).draw(w))
......@@ -61,6 +59,7 @@ case class PieChart (val weights: Seq[Double], val colors: Seq[Color])
private def display (w: World, f: (Double, Double) Unit): Unit = {
if (weights.isEmpty) return
val activeColor = w.activeColor
val iterator = ColorIterator.over(colors: _*)
val sum = weights.sum
val angles = weights map { _*2*Math.PI/sum }
val r1 = width(w)/2
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment