【发布时间】:2016-08-12 13:16:10
【问题描述】:
我正在尝试将我在 Matlab 中的 GUI 转换为 JavaFX 8 小程序。我想要一个散点图,其中的图位于图像上,如下所示。
如上图所示,CIE 图与散点图集成在一起。我尝试使用堆栈窗格,但由于图像在其上方,所以绘图不可见。
编辑-
试图覆盖 layoutplotchildren():
class SuperScatterChart extends ScatterChart{
public SuperScatterChart(Axis arg0, Axis arg1) {
super(arg0, arg1 );
// TODO Auto-generated constructor stub
}
@Override
protected void layoutPlotChildren(){
ImageView iv1 = new ImageView(new Image("file:///C:/Desktop/cie.png",450,450,true,true));
// How do I add iv1 to plot children?
super.layoutPlotChildren();
}
}
【问题讨论】:
-
我想到了两种方法。 1.使用CSS:
.chart-plot-backgroundnode是Region,所以你可以在CSS上设置一个-fx-background-image。 2. 继承ScatterChart并覆盖layoutPlotChildren()将图像添加到绘图区域,然后调用super.layoutPlotChildren()添加散点。请参阅stackoverflow.com/questions/38871202 了解一些类似的内容。 -
另外:“我尝试使用堆栈窗格,但由于图像在它上面,所以绘图不可见。” - 如果您将图像添加到堆栈窗格在图表之前,则不应该发生这种情况。
-
我尝试了第一种方法,但是图像位于散点图后面。至于第二种方法,将图像更改为覆盖 layoutPlotChildren() 中的绘图区域的代码语法是什么?谢谢@James_D
-
在调用
super.layoutPlotChildren()之前,只需将包含所需图像的ImageView添加到情节儿童中即可 -
edit 你的问题,不要在 cmets 中发布代码。会发生什么?
标签: java user-interface javafx-8 scatter-plot