I have also done som restructuring in the packages which now is:
package me.ironic.scabors.app
package me.ironic.scabors.service
package me.ironic.scabors.model
package me.ironic.scabors.file
even if I have not reworked the messy file-package. I will do that later. however, I finished up with loading the price list, and that code now look like this:
I also broke out the model classes from the file package, and put it in another file called PriceModel.scala, you can also see that I am now using "Price" which is a better name than "Quote" so all references to Quote is now replaced with Price. The content of that file is:
PriceModel.scala
I also made a Service object so that the GUI does not need to know or depend on anything from the file package. So far as I have gotten with the GUI it just contains two methods, one to get all price lists and one to get the data for a chosen stock. Here is the code:
PriceService.scala
GUI programming done in Scala
I decided to leave the idea of using Java FX that I had from the beginning and that I wrote in the beginning post. Instead I decided to use Scala Swing. Not so easy as it turned out, because first of all, it has been a couple of years since I last did any Java Swing programming and second of all, it was not very similar and not easy to transform Java Swing thinking to Scala Swing thinking. Well, it is less code, but surly, at this stage it looks really messy. Maybe it takes a while for my brain to melt Scala Swing programming and the fact that google got warm from all searching and few good examples does not help.
I am to tired to explain most of the code, maybe in a later post, but here is what the purpose if the GUI is so far.
- Provide a text field to filter search for stocks "Instrument"
- Provide a button to perform the search
- Provide a ComboBox to present the filtered result from the search and to select stock to draw
- Provide Panel for drawing a Bar Chart of selected stock
I have implemented and it works as I wand, except that the tedious job to provide the functionality to draw a bar chart is not done. Thea is a later exercise and a future post to describe. I let you see the messy code for this.
ScaBorsApp.scala
Yeah, thats right, I also gave up SBT, I am now using gradle to build. here is the code for that. build.gradle
build.gradle
Until later..... ciao!