简体   繁体   English

JavaFX Chart动画完成

[英]JavaFX Chart animation finished

I need to grab the chart plot background for its bounds, but I can't do that until the chart is laid out. 我需要获取图表图背景的界限,但是直到图表布置好之后,我才能这样做。

If I set the chart data, then try to get those bounds, it will return values of 0 . 如果我设置了图表数据,则尝试获取这些界限,它将返回值0

As a workaround, I delay those calculations with the help of a thread. 解决方法是,我借助线程延迟了这些计算。 For now it'll do, but the UI is kinda flickering due to my manual delay in the thread. 现在就可以了,但是由于我在线程中的手动延迟,UI有点闪烁。

Does the JavaFX Node(s) have onAnimationFinished APIs or something like that? JavaFX节点是否具有onAnimationFinished API或类似的东西?

My solution to this sort of problem was to create the charting elements in a new window, and then to do all of the actual calculations and laying out of the elements BEFORE I show the window, then I attach a 'WINDOW_SHOWN' listener to it, and run whatever analysis I need after that. 我针对此类问题的解决方案是在一个新窗口中创建图表元素,然后在显示该窗口之前进行所有实际计算并布局这些元素,然后在其上附加一个“ WINDOW_SHOWN”侦听器,然后执行我需要的任何分析。 For example: 例如:

 wellDiagram.setLabel(current_position_label);
        wellDiagram.setScaleLabels(zero_scale_labels_bottom, full_scale_labels_bottom);
        wellDiagram.setProperties();
        GraphWindow.get_stage().addEventHandler(WindowEvent.WINDOW_SHOWN, new EventHandler<WindowEvent>() {
            @Override
            public void handle(WindowEvent event) {
                    //DO some stuff to get the bounds of your chart, etc. etc. 
                    //I use it to automatically save an image of the graph with one
                    //One kind of css, and then switch it back to a nice looking one. 
                }
            }
        });
        wellDiagram.setError(lbl_error_label, GraphWindow.graphWindowReturner().getErrorMessage());

If you can't do it with a new window... I'm not totally sure. 如果您不能在新窗口中执行此操作...我不确定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM