Leon Atherton

Leon is a developer at IDRsolutions and product manager for BuildVu. He is responsible for managing the BuildVu product strategy and roadmap, and also spends a lot of his time writing code to build new features, improve functionality, fix bugs, and improve the testing for BuildVu.

JavaFX: How to apply multiple Effects to a Node

37 sec read

While I was converting the PageFlow mode from Java3D into JavaFX for our Java PDF Viewer, one of the fun issues that I came across is how to apply multiple effects to a Node.

There is only one method to set effects on a node, and using the method more than once will overwrite the previous effect each time. The key is that you need to chain effects together. This is done by setting the input of the effects like so:

        ImageView imView = new ImageView();
        PerspectiveTransform pTrans = new PerspectiveTransform(100, 110, 400, 160, 400, 940, 100, 1060);
        Reflection ref = new Reflection();
        pTrans.setInput(ref);
        imView.setEffect(pTrans);

What this does is set the input of the PerspectiveTransform to be the result of applying the Reflection to the ImageView.

Be careful of the order in which you chain your effects because the order in which the effects are applied matters. It’s the difference between a nice outcome:

perspectiveRight

And a not so nice outcome!

perspectiveWrong

I have written several articles on converting our Java3D usage into JavaFX and you can read the other articles here.

Leon Atherton

Leon is a developer at IDRsolutions and product manager for BuildVu. He is responsible for managing the BuildVu product strategy and roadmap, and also spends a lot of his time writing code to build new features, improve functionality, fix bugs, and improve the testing for BuildVu.

Updates on Java PDF Viewer roadmap from IDRsolutions

My previous blog post (5 changes we are considering in 2016 for IDRsolutions), generated lots of feedback for us (for which we would like...
Mark Stephens
1 min read

My key takeaways from NetBeans Day 2015

NetBeans Day 2015 had to be rescheduled to bigger rooms because of attendee demand. It was a very busy schedule. Here are my notes...
Mark Stephens
2 min read

An Introduction to JavaFX Panes with Code Examples

As a developer at IDR Solutions I spend a lot of my time working with JavaFX and Panes in our JavaFX PDF Viewer. I...
Sylwia Dorota Kedzia
1 min read

One Reply to “JavaFX: How to apply multiple Effects to a Node”

Leave a Reply

Your email address will not be published. Required fields are marked *