From 3351e36228415c5a36c4efc2d1b2ccd85730fc25 Mon Sep 17 00:00:00 2001 From: Jakob Odersky Date: Tue, 6 Nov 2012 11:48:38 +0100 Subject: add self-type to plotter to allow flexible composition --- src/main/scala/scalam/plotting/Plotter.scala | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/main/scala/scalam/plotting/Plotter.scala b/src/main/scala/scalam/plotting/Plotter.scala index cdc1ef3..199827c 100644 --- a/src/main/scala/scalam/plotting/Plotter.scala +++ b/src/main/scala/scalam/plotting/Plotter.scala @@ -2,32 +2,20 @@ package scalam.plotting import scalam.m._ import scalam.m.ast._ -import scalam.plotting.styles._ import scalam.m.interpretation.MInterpreter -import scalam.m.interpretation.MatlabInterpreter import scalax.file.Path -trait Plotter { +trait Plotter { self: MInterpreter => import Plotter._ - val pwd: scalax.file.Path - - lazy val interpreter: MInterpreter = new MatlabInterpreter(pwd) - def plot(dataSets: Seq[DataSet], title: String, x: String, y: String, grid: Boolean = true, legend: Boolean = true)(implicit styles: Seq[Style[StyleElement]] = defaultStyles, fontSize: FontSize = defaultFontSize) = { val plot = new Plot(dataSets, title, x, y, grid, legend, styles = styles, fontSize = fontSize.fontSize) val path = Path(Identifier.makeValid(title)) scalam.io.save(plot, path) val s = Function(Identifier("run"), StringLiteral((path / Plot.PlotFileName).path)) - println(s.line) - interpreter.evaluate(s) + self.evaluate(s) } - def exit() { - interpreter.write("exit") - interpreter.close() - } - } object Plotter { -- cgit v1.2.3