Using ScalaFX to build a plotting lib

35 views
Skip to first unread message

Jin Tao

unread,
Jun 3, 2020, 9:18:01 PM6/3/20
to ScalaFX Users
Hi all,


So my question is as follows:

I want to build a programmatic charting library. Basically the user will do something as follows. in Driver.scala, which extends App:

import myChartingLib
// run some simulation code here.... returns Results
myChartinLib.plotLineChart(Results)

// run some more simulation code here... returns Results2
myChartinLib.plotBarChart(Results)


Running this code will create a line chart and a bar chart. Now an issue I see is that ScalaFX has only one entry point; JFXApp which is essentially the main class. The problem is I only want ScalaFX to render some charts, since my Driver class extends App. I do not want to have JFXApp as my main. If this is unclear please let me know.

Is this possible? I would love to use ScalaFX to build a library, but I don't know if I should resort to something else for my needs. Any guidance is much appreciated. I cannot use a pre-made charting lib like jfreecharts due to restrictions.






Jarek

unread,
Jun 3, 2020, 9:28:24 PM6/3/20
to ScalaFX Users

Looks that in the meantime James_D provided very extensive answer: https://stackoverflow.com/a/62183916/2100641
Is that answer sufficient?

Mark Lewis

unread,
Jun 11, 2020, 8:01:25 AM6/11/20
to ScalaFX Users
I'll just give a word of warning here. Depending on what you are doing with it, JavaFX might not be the best platform for plotting. I have a plotting library, SwiftVis2, that is written in Scala and has the ability to render with JavaFX, Swing, SVF, HTML Canvas (through Scala.js), and natively (limited and ugly at the current time). JavaFX is by far the slowest of these and it the output isn't great for a lot of things either, mainly because their anti-aliasing seems to be poor. It might not matter much for your purposes, but I thought I'd let you know. You can see some timing results and an example of where the output is bad at.

https://dynamicsofprogramming.blogspot.com/2018/08/swiftvis2-and-speed-problems-with.html

Note that the problem we have with the anti-aliasing seems to be mostly caused by an inability to handle features that are sub-pixel in size. The pixel that shape is centered on seems to be turned on completely even though the geometry only covers a tiny fraction of it.

Daniel Roberts

unread,
Jun 12, 2020, 12:18:45 PM6/12/20
to ScalaFX Users
I am trying to follow the link to dynamicsofprogramming.blogspot.com but it is hanging redirecting to alexgorbatchev.com.
Thanks!

Mark Lewis

unread,
Jun 12, 2020, 1:03:17 PM6/12/20
to ScalaFX Users
I was having the same problem. I can't remember where I put that into Blogger. It comes up eventually, but it is definitely something I'm going to have to find and fix. I should probably move my code samples into other tools so that it doesn't rely on something small like that.

Mark Lewis

unread,
Jun 13, 2020, 1:28:37 PM6/13/20
to ScalaFX Users
I found where to go on blogger to remove that code from my theme. I probably broke some of my old posts, but I'm not too worried about the older ones. It also makes the one in question here load quickly.


On Friday, June 12, 2020 at 11:18:45 AM UTC-5, Daniel Roberts wrote:

Jin Tao

unread,
Jun 14, 2020, 3:05:56 PM6/14/20
to ScalaFX Users
Thanks yes it does!

Jin Tao

unread,
Jun 14, 2020, 3:06:28 PM6/14/20
to ScalaFX Users
Thanks for the comprehensive reply Mark - this is a very interesting read. I will be sure to take this into account for my project!
Reply all
Reply to author
Forward
0 new messages