Commit 78adbc32 authored by h2b's avatar h2b

Deprecated method replaced.

parent b4af14ab
......@@ -50,7 +50,7 @@ case class BarChart (val heights: Double*)
private def display (w: World, f: (Point, Point) Unit): Unit = {
if (heights.isEmpty) return
val activeColor = w.activeColor
val colorIterator = ColorIterator(activeColor)
val colorIterator = ColorIterator.excluding(activeColor)
val (wl, wr, wb, wt) = enc.lrbt(w)
val barWidth = (wr-wl)/heights.size
var x = wl
......
......@@ -61,7 +61,7 @@ case class PieChart (val weights: Double*)
private def display (w: World, f: (Double, Double) Unit): Unit = {
if (weights.isEmpty) return
val activeColor = w.activeColor
val colorIterator = ColorIterator(activeColor)
val colorIterator = ColorIterator.excluding(activeColor)
val sum = weights.sum
val angles = weights map { _*2*Math.PI/sum }
val r1 = width(w)/2
......
......@@ -30,29 +30,29 @@ class ColorIteratorTest extends FunSuite {
private val n = fullSeq.length
test("iteration over full seq") {
val it = ColorIterator()
val it = ColorIterator.excluding()
for (i 0 until n) assertResult(fullSeq(i))(it.next())
for (i 0 until n) assertResult(fullSeq(i))(it.next())
}
test("iteration over full seq excluding black") {
val exclude = Black
val it = ColorIterator(exclude)
val it = ColorIterator.excluding(exclude)
for (i 0 until n if fullSeq(i)!=exclude) assertResult(fullSeq(i))(it.next())
for (i 0 until n if fullSeq(i)!=exclude) assertResult(fullSeq(i))(it.next())
}
test("iteration over full seq excluding black and gray") {
val excludes = Set(Black, Gray)
val it = ColorIterator(excludes.toSeq: _*)
val it = ColorIterator.excluding(excludes.toSeq: _*)
for (i 0 until n if !excludes.contains(fullSeq(i))) assertResult(fullSeq(i))(it.next())
for (i 0 until n if !excludes.contains(fullSeq(i))) assertResult(fullSeq(i))(it.next())
}
test("toSeq") {
assertResult(fullSeq)(ColorIterator().toSeq)
assertResult(fullSeq.diff(Seq(Red)))(ColorIterator(Red).toSeq)
assertResult(fullSeq.diff(Seq(Cyan, Magenta, Yellow)))(ColorIterator(Cyan, Magenta, Yellow).toSeq)
assertResult(fullSeq)(ColorIterator.excluding().toSeq)
assertResult(fullSeq.diff(Seq(Red)))(ColorIterator.excluding(Red).toSeq)
assertResult(fullSeq.diff(Seq(Cyan, Magenta, Yellow)))(ColorIterator.excluding(Cyan, Magenta, Yellow).toSeq)
}
}
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