如何使用JavaFx滚动广泛的内容smoooth? [英] How to make scrolling of wide content smoooth with JavaFx?

查看:148
本文介绍了如何使用JavaFx滚动广泛的内容smoooth?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JavaFx开发gant图表。我的主要内容放在ScrollPane中。
我有缩放选项,它正在改变内容宽度。

I'm developing gant chart with JavaFx. My main content is placed inside of ScrollPane. I have zoom option which is changing content width.

这是与内容大小相关的表现:

This is performance related to content size:

zoom:
x1 - 2880px    // smooth scrolling 
x2 - 5760px    // smooth scrolling 
x3 - 8640px    // smooth scrolling 
x4 - 11520px   // bad/jumps
x5 - 14410px   // very bad/ not smooth at all
x6 - ...       // :-/

是否有可能解决这个问题?走哪条路......我不知道如何开始,甚至可以修复它: - /

Is it possible to fix it some how? Which way to go ... I don't have any idea how to start or even is it possible to fix it :-/

请帮忙。

解决方案

我发现了什么问题。希望能帮到你们一些人。问题出在CSS的ScrollPane内容上。我正在开发gant图表。在ScrollPane里面我有行(HBox'es),这是类行的CSS类:

I found out what was the problem. Hope that will help some of You. Problem was with CSS of content of ScrollPane. I'm developing gant chart. Inside of ScrollPane I has rows ( HBox'es ) and this is CSS class for class row:

.opertationRow{
-fx-background-color: #171717;
-fx-border-color: #323232;
-fx-border-width: 0 0 1 0;
/*-fx-border-style: dashed;*/  
-fx-padding: 1 0 1 0;        
}

-fx-border-style:dashed; < -----在我发表评论后,一切顺利!我没有回答这个问题,因为我的网站没有添加足够的输入

-fx-border-style: dashed; <----- after I've commented this everything is working smooth! I'm not answering this question as not enough input from my site was added

推荐答案

对于标准节点(可能是JavaFX构建的)在图表中,您可以在节点上将'cache'设置为true。这会导致节点的内容被缓存为图像。由于图像和简单的形状是通过图形硬件加速来处理的,因此可以加快速度(如果遇到性能问题,这是首先尝试的事情之一)。

For standard Nodes (and probably JavaFX built-in charts as well), you can set 'cache' to true on the Node. This causes the Node's contents to be cached as an image. Since images and simple shapes are handled by graphics hardware acceleration, it can speed things up a lot (and is one of the first things to try if you're having performance problems).

使用它的缺点是缓存的图像使用了一些内存,但我没有看到这是我的应用程序的问题。如果节点经常动画/更改,您可能需要谨慎使用此方法。

The downside of using this is that the cached image uses some memory, but I haven't seen this to be an issue for my app. If the Node is animating / changing often, you may want to use caution with this approach.

'缓存'的API文档:
http://docs.oracle.com/javafx/2/api/javafx/ scene / Node.html #cacheProperty

API docs for 'cache': http://docs.oracle.com/javafx/2/api/javafx/scene/Node.html#cacheProperty

这篇关于如何使用JavaFx滚动广泛的内容smoooth?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆