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:
And a not so nice outcome!
I have written several articles on converting our Java3D usage into JavaFX and you can read the other articles here.
Latest posts by Leon Atherton (see all)
- How to fill shapes on HTML5 Canvas using EvenOdd winding rule - September 4, 2013
- Measure content performance with Analytics – Why convert PDF magazines to HTML5? Part 7 - July 9, 2013
- Images in SVG: Beware of Aspect Ratio! - June 27, 2013
- What is the optimum number of lines of code written per day? - June 13, 2013
- Improving the way settings get passed in ExtractPagesAsHTML - May 30, 2013