问题
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 :-/
Please help.
SOLUTION
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; <----- after I've commented this everything is working smooth! I'm not answering this question as not enough input from my site was added
回答1:
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 docs for 'cache': http://docs.oracle.com/javafx/2/api/javafx/scene/Node.html#cacheProperty
来源:https://stackoverflow.com/questions/18493412/how-to-make-scrolling-of-wide-content-smoooth-with-javafx