Skip to content

Commit ea492d3

Browse files
committed
More updates for Scala 2.13. Commented out Polynote until they support 2.13. Fixed most warnings.
1 parent 7e4cdb1 commit ea492d3

File tree

32 files changed

+92
-104
lines changed

32 files changed

+92
-104
lines changed

build.sbt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ lazy val fxrenderer = (project in file("fxrenderer"))
6666
scalaVersion := "2.13.7",
6767
libraryDependencies += "org.scalafx" %% "scalafx" % "17.0.1-R26",
6868
libraryDependencies ++= javaFXModules.map( m =>
69-
"org.openjfx" % s"javafx-$m" % "11" classifier osName
69+
"org.openjfx" % s"javafx-$m" % "17" classifier osName
7070
)
7171
).dependsOn(jvm)
7272

@@ -76,16 +76,18 @@ lazy val swingrenderer = (project in file("swingrenderer"))
7676
name := "SwiftVis2Swing",
7777
scalaVersion := "2.13.7",
7878
libraryDependencies += "org.scala-lang.modules" %% "scala-swing" % "3.0.0",
79-
libraryDependencies += "org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.4"
79+
libraryDependencies += "org.scala-lang.modules" %% "scala-parallel-collections" % "1.0.4",
80+
libraryDependencies += "org.scalactic" %% "scalactic" % "3.2.10",
81+
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.10" % "test"
8082
).dependsOn(jvm)
8183

82-
lazy val polynote = (project in file("polynoteintegration"))
83-
.settings(
84-
commonSettings,
85-
name := "SwiftVis2Polynote",
86-
scalaVersion := "2.12.15",
87-
libraryDependencies += "org.polynote" %% "polynote-runtime" % "0.4.4"
88-
).dependsOn(swingrenderer)
84+
// lazy val polynote = (project in file("polynoteintegration"))
85+
// .settings(
86+
// commonSettings,
87+
// name := "SwiftVis2Polynote",
88+
// scalaVersion := "2.13.7",
89+
// libraryDependencies += "org.polynote" %% "polynote-runtime" % "0.4.4"
90+
// ).dependsOn(swingrenderer)
8991

9092
lazy val spark = (project in file("spark"))
9193
.settings(

core/src/main/scala/swiftvis2/plotting/Axes.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ case class NumericAxis(
330330
case Axis.ScaleStyle.Linear =>
331331
val majorSep = tickSpacing.getOrElse {
332332
val str = "%e".format((amax - amin) / 6)
333-
(str.take(str.indexOf('.') + 2).toDouble.round + str.drop(str.indexOf('e'))).toDouble // TODO - consider BigDecimal here if display gets unhappy
333+
(str.take(str.indexOf('.') + 2).toDouble.round.toString + str.drop(str.indexOf('e'))).toDouble // TODO - consider BigDecimal here if display gets unhappy
334334
}
335335
val firstTickApprox = (amin / majorSep).toInt * majorSep
336336
val firstTick = firstTickApprox + (if ((amax - amin).abs < (amax - firstTickApprox).abs) majorSep else 0)

core/src/main/scala/swiftvis2/plotting/PlotGrid.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ case class PlotGrid(
7777
// Draw grid of plots
7878
r.setColor(0xff000000)
7979
val sizesAndAxisRenderers = (for {
80-
((row, i), yStart, yEnd) <- (plots.zipWithIndex, yStarts, yStarts.tail).zipped
81-
((p2ds, j), xStart, xEnd) <- (row.zipWithIndex, xStarts, xStarts.tail).zipped
80+
((row, i), yStart, yEnd) <- plots.zipWithIndex.lazyZip(yStarts).lazyZip(yStarts.tail)
81+
((p2ds, j), xStart, xEnd) <- row.zipWithIndex.lazyZip(xStarts).lazyZip(xStarts.tail)
8282
} yield {
8383
val axisBounds = Seq(
8484
minXAxisBounds.subX(xStart, xEnd),
@@ -210,7 +210,7 @@ case class PlotGrid(
210210
private def collectXAxes(pred: Axis => Boolean): Seq[Seq[String]] = {
211211
plots.foldLeft(Seq.fill(plots(0).size)(Seq.empty[String])) { (names, row) =>
212212
val toAdd = row.map(_.flatMap(p2d => axisNameAsListWithCondition(p2d.xAxisName, pred)))
213-
(names, toAdd).zipped.map((a, b) => (b ++: a))
213+
names.lazyZip(toAdd).map((a, b) => (b ++: a))
214214
}
215215
}
216216

core/src/main/scala/swiftvis2/plotting/renderer/SVGRenderer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package swiftvis2.plotting.renderer
22

33
import swiftvis2.plotting.Bounds
4-
import scala.collection.mutable.ArrayStack
4+
import scala.collection.mutable.Stack
55

66
class SVGRenderer(width: Double, height: Double) {
77
import SVGRenderer.Options
88

99
private var copt = Options("#000000", Renderer.StrokeData(1.0, Nil), Renderer.FontData("Ariel", Renderer.FontStyle.Plain), 10.0, None)
10-
private val stack = ArrayStack[Options]()
10+
private val stack = Stack[Options]()
1111
private var clipCnt = 0
1212

1313
def drawEllipse(cx: Double, cy: Double, width: Double, height: Double): String = {

core/src/main/scala/swiftvis2/plotting/styles/ColoredSurfaceStyle.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package swiftvis2.plotting.styles
22

33
import swiftvis2.plotting._
44
import swiftvis2.plotting.renderer.Renderer
5+
import scala.collection.immutable.ArraySeq
56

67
case class XYC(x: Double, y: Double, c: Int)
78

@@ -52,8 +53,8 @@ case class ColoredSurfaceStyle(
5253
def drawGroup(): Unit = {
5354
for (i <- 0 until pData(0).length - 1; if i < pData(1).length - 1) {
5455
r.setColor(pData(0)(i).c)
55-
val xs = Array(pData(0)(i).x, pData(1)(i).x, pData(1)(i + 1).x, pData(0)(i + 1).x)
56-
val ys = Array(pData(0)(i).y, pData(1)(i).y, pData(1)(i + 1).y, pData(0)(i + 1).y)
56+
val xs = ArraySeq(pData(0)(i).x, pData(1)(i).x, pData(1)(i + 1).x, pData(0)(i + 1).x)
57+
val ys = ArraySeq(pData(0)(i).y, pData(1)(i).y, pData(1)(i + 1).y, pData(0)(i + 1).y)
5758
r.fillPolygon(xs, ys)
5859
r.drawPolygon(xs, ys)
5960
}

core/src/main/scala/swiftvis2/plotting/styles/ScatterStyle.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ final case class ScatterStyle(
7373
r.setColor(BlackARGB)
7474
r.drawLine(px, yConv(y - error), px, yConv(y + error))
7575
}
76-
(lines, connectMap).zipped.foreach {
76+
lines.lazyZip(connectMap).foreach {
7777
case (ScatterStyle.LineData(groupFunc, stroke), cm) =>
7878
val group = groupFunc(i)
7979
cm.get(group) match {
@@ -93,7 +93,7 @@ final case class ScatterStyle(
9393
}
9494
symbol.drawSymbol(px, py, pwidth, pheight, r)
9595
}
96-
(lines, connectMap).zipped.foreach {
96+
lines.lazyZip(connectMap).foreach {
9797
case (LineData(groupFunc, stroke), cm) =>
9898
for ((group, lst @ ((_, _, c) :: _)) <- cm) {
9999
r.setColor(c)

fxrenderer/src/main/scala/swiftvis2/plotting/renderer/FXRenderer.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ class FXRenderer(gc: GraphicsContext, maxQueue: Int = 1000) extends Renderer {
190190

191191
def drawText(s: String, x: Double, y: Double, align: Renderer.HorizontalAlign.Value, angle: Double): Unit = {
192192
enqueue(() => {
193-
gc.save
193+
gc.save()
194194
text.text = s
195195
text.font = gc.font
196196
gc.textBaseline = VPos.Center
@@ -202,13 +202,13 @@ class FXRenderer(gc: GraphicsContext, maxQueue: Int = 1000) extends Renderer {
202202
case Renderer.HorizontalAlign.Right => TextAlignment.Right
203203
}
204204
gc.fillText(s, 0, 0)
205-
gc.restore
205+
gc.restore()
206206
})
207207
}
208208

209-
def save(): Unit = enqueue(() => gc.save)
209+
def save(): Unit = enqueue(() => gc.save())
210210

211-
def restore(): Unit = enqueue(() => gc.restore)
211+
def restore(): Unit = enqueue(() => gc.restore())
212212

213213
def setColor(argb: Int): Unit = {
214214
enqueue(() => {

jsrenderer/src/main/scala/swiftvis2/plotting/renderer/JSRenderer.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package swiftvis2.plotting.renderer
22

33
import swiftvis2.plotting._
44
import org.scalajs.dom.html.Canvas
5-
import org.scalajs.dom.raw.CanvasRenderingContext2D
5+
import org.scalajs.dom.CanvasRenderingContext2D
66
import swiftvis2.plotting.renderer.Renderer.FontStyle
77

88
import scala.scalajs.js
@@ -83,7 +83,7 @@ class JSRenderer(canvas: Canvas) extends Renderer {
8383
}
8484

8585
def drawText(s: String, x: Double, y: Double, align: Renderer.HorizontalAlign.Value, angle: Double): Unit = {
86-
ctx2D.save
86+
ctx2D.save()
8787
ctx2D.textBaseline = "middle"
8888
ctx2D.translate(x, y)
8989
ctx2D.rotate(angle * (math.Pi / 180))
@@ -93,7 +93,7 @@ class JSRenderer(canvas: Canvas) extends Renderer {
9393
case Renderer.HorizontalAlign.Right => "right"
9494
}
9595
ctx2D.fillText(s, 0, 0)
96-
ctx2D.restore
96+
ctx2D.restore()
9797
}
9898

9999
def setColor(argb: Int): Unit = {

jvm/src/main/scala/swiftvis2/CompilerParsing.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ object CompilerParsing {
4949
println(className+"\n"+classString)
5050
val inputFile = new BatchSourceFile(className+".scala", classString)
5151
val fParser = new global.syntaxAnalyzer.SourceFileParser(inputFile)
52-
val fTree = fParser.parse
52+
val fTree = fParser.parse()
5353
val bounds = findIndices(fTree)
5454

5555
run.compileSources(List(inputFile))

jvm/src/main/scala/swiftvis2/DataElement.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package swiftvis2
22

3+
import scala.collection.immutable.ArraySeq
4+
35
class DataElement(
46
private val _x: Array[Double],
57
private val _s: Array[String],
@@ -10,9 +12,9 @@ class DataElement(
1012
}
1113

1214
object DataElement {
13-
val noNums = Array[Double]()
14-
val noStrings = Array[String]()
15-
val noInts = Array[Int]()
15+
val noNums = ArraySeq[Double]()
16+
val noStrings = ArraySeq[String]()
17+
val noInts = ArraySeq[Int]()
1618

1719
def apply(nums: Seq[Double] = noNums, strings: Seq[String] = noStrings, ints: Seq[Int] = noInts): DataElement =
1820
new DataElement(nums.toArray, strings.toArray, ints.toArray)

0 commit comments

Comments
 (0)