Skip to content

Commit 09a58ac

Browse files
committed
Add PNG export to JFGraphPlotter
1 parent e6a53f0 commit 09a58ac

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/scala/org/sameersingh/scalaplot/jfreegraph/JFGraphPlotter.scala

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package org.sameersingh.scalaplot.jfreegraph
22

33
import org.sameersingh.scalaplot._
44
import javax.swing.JFrame
5-
import org.jfree.chart.{JFreeChart => JChart, ChartPanel, ChartFactory}
5+
import org.jfree.chart.{JFreeChart => JChart, ChartPanel, ChartFactory, ChartUtilities}
66
import org.jfree.data.xy.{XYSeries => XYS}
77
import org.jfree.data.xy.XYSeriesCollection
88
import com.itextpdf.text.pdf.DefaultFontMapper
@@ -94,6 +94,11 @@ class JFGraphPlotter(chart: Chart) extends Plotter(chart) {
9494
out.close
9595
}
9696

97+
override def png(directory: String, filenamePrefix: String) {
98+
val filename = directory + filenamePrefix + ".png"
99+
ChartUtilities.saveChartAsPNG(new java.io.File(filename), jchart, 1280, 720)
100+
}
101+
97102
override def gui() { JFGraphPlotter.gui(jchart) }
98103
}
99104

@@ -135,4 +140,4 @@ object JFGraphPlotter {
135140
plotter.gui()
136141
}
137142

138-
}
143+
}

0 commit comments

Comments
 (0)