Hello,
I am trying to recode the examples of the Hansolo’s char library using JDK 21. I have coded quite a few examples, but cannot solve an issue in an example. The code can be found here. To try and run the example we execute:
./mill -i hansolo.bar.runMain hansolo.charts.PanelBarChartTest
The relevant code snippet is:
override def init() = {
val categories: List[DayOfWeekCategory] = List.of(Categories.MONDAY, Categories.TUESDAY, Categories.WEDNESDAY, Categories.THURSDAY, Categories.FRIDAY, Categories.SATURDAY, Categories.SUNDAY)
val listOfSeries: List[ChartItemSeries[ChartItem]] = new ArrayList[ChartItemSeries[ChartItem]]()
val ss = 0 until 3
for (s <- ss) {
val serverNo: Int = s
val series: ChartItemSeries[? <: ChartItem] = ChartItemSeriesBuilder.create().name("This week " + serverNo).build()
categories.forEach(category => {
val item: ChartItem = ChartItemBuilder.create().name(series.getName() + " " + category.getName(TextStyle.SHORT, Locale.US)).category(category).value(RND.nextDouble() * 100).fill(Color.ORANGE).build()
series.getItems().add(item)
})
listOfSeries.add(series)
}
...
The relevant errors are:
[error] 69 | series.getItems().add(item)
[error] | ^^^^
[error] | Found: (item : eu.hansolo.fx.charts.data.ChartItem)
[error] | Required: series.T
[error] |
[error] | longer explanation available when compiling with `-explain`
[error] -- [E007] Type Mismatch Error: /home/hmf/VSCodeProjects/javaFXClientMill/hansolo/bar/src/PanelBarChartTest.scala:71:29
[error] 71 | listOfSeries.add(series)
[error] | ^^^^^^
[error] |Found: (series :
[error] | eu.hansolo.fx.charts.series².ChartItemSeries[?
[error] | <: eu.hansolo.fx.charts.data.ChartItem]
[error] |)
[error] |Required: eu.hansolo.fx.charts.series².ChartItemSeries[eu.hansolo.fx.charts.data.ChartItem
[error] | ]
[error] |
[error] |where: series is a value in an anonymous function in method init
[error] | series² is a package in package eu.hansolo.fx.charts
[error] |
[error] | longer explanation available when compiling with `-explain`
The library code is here.
I have made several attempts at explicitly setting the types but have not succeeded. Can anyone tell me how to set these types?
TIA