0
我正在使用JavaFX,我正在創建一個可以接收「字符串」或「數字」數據類型到Axis的泛型LineChart,但是我使用的數據類型是X,Y在向圖表添加數據的方法中,我有兩個通用參數X和Y,並且我需要將「Y」轉換爲「double」,因爲當我使用此方法時,Y參數是「double」值,但我不能再次將「Y」值轉換爲「double」。如何將X,Y數據類型轉換爲JavaFX中的double值?
添加數據的方法是:
public void addData(final String idSeries, final X x, final Y y, String kindOfSymbol) {
//valido que exista la serie
boolean seriesExist = seriesMap.containsKey(idSeries);
//obtengo el index de la serie, como fue almacenada en la grafica
Integer indexSerie = seriesMap.get(idSeries);
if (seriesExist) {
Platform.runLater(() - > {
XYChart.Series < X, Y > currentSeries = null;
currentSeries = chart.getData().get(indexSerie.intValue());
int lastNodePosition = currentSeries.getData().size() - 1;
XYChart.Data < X, Y > point = new XYChart.Data < > (x, y);
//The problem is here when I try to convert "Y" to "double" because the object JFXStackPaneSymbol require the double and Dimension parameters
point.setNode(new JFXStackPaneSymbol(y, new Dimension(15, 15)));
currentSeries.getData().add(point);
currentSeries.getData().get(lastNodePosition).getNode().setStyle(kindOfSymbol);
});
}
}
方法調用是:
lineChart.addData(Constants.ID_LINE_SERIE, xAxisUnit++, value, tempSymbol);
//Constants.ID_LINE_SERIE = String
//xAxisUnit++ = double
//value = double
//tempSymbol = String
非常感謝您的幫助。
你能證明與聲明? –
聲明? – Raul
編輯:類聲明,類型X,Y等 –