Java Reference
In-Depth Information
Figure 3-6 shows the transition partway through with the replacement node visible inside the
circular cutout shape. The node being replaced is still visible around its edges.
In this effect the new node is wrapped in a group and placed over the existing node. The group has
the clip value set to a circle with a radius of 0. As the animation progresses, the radius is increased to
expose the new node. And finally, the usual clean-up code is called to leave the scene in the expected
Listing 3-6. WipeReplace.fx
package org.lj.jfxe.chapter3.example4;
import javafx.scene.Node;
import javafx.animation.*;
import javafx.scene.Group;
import javafx.util.Sequences;
import javafx.animation.Interpolator;
import javafx.scene.shape.*;
import javafx.util.*;
* @author lucasjordan
public function doReplace(nodeToReplace:Node,replacementNode:Node,doAfter:function()):Void{
var parent:Group = (nodeToReplace.parent as Group);
var index = Sequences.indexOf(parent.content, nodeToReplace);
var startingX = nodeToReplace.translateX;
var startingY = nodeToReplace.translateY;
var minX = nodeToReplace.boundsInLocal.minX;
var minY = nodeToReplace.boundsInLocal.minY;
var startWidth = nodeToReplace.boundsInLocal.width;
var startHeight = nodeToReplace.boundsInLocal.height;
replacementNode.translateX = 0;
replacementNode.translateY = 0;
var radius = 0.0;
var maxRadius = Math.sqrt(Math.pow(startWidth/2.0, 2) + Math.pow(startHeight/2.0, 2));
var clip = Circle{
translateX: startWidth/2.0;
translateY: startHeight/2.0;
radius: bind radius;
var holder = Group{
translateX: startingX
Search WWH ::

Custom Search