Java Reference
In-Depth Information
Nodes may also have a set of transforms applied, including translate , scale ,
rotate , and shear . Transforms may be provided as one sequence of transforms ,
each being applied in the order they are presented in the transforms sequence.
Alternatively, the instance variables, translateX , translateY , scaleX , scaleY ,
and rotate may be used. When using these instance variables, there is certain
default behavior. For example, scaleX / scaleY and rotate use the center point
as the anchor. If you need finer control over these kinds of transforms, use the
transforms sequence.
The geometry of nodes is contained in four instance variables: boundsInLocal ,
boundsInParent , boundsInScene , and layoutBounds . boundsInLocal is the
rectangular area defined for the node without considering any transformations.
boundsInParent is the rectangular area defined for the node after all the trans-
formations have been applied and is in the coordinate space of the node's parent.
boundsInScene is the rectangular area defined for the node after all the transfor-
mations have been applied and is in the coordinate space of the node's scene or
root node if the node is not connected to a scene. layoutBounds is the geometry
that should be used in all calculations for node layout and includes all the trans-
formations defined in the nodes transforms sequence.
There are several indicators available with a node: hover , pressed , and focused .
The indicator hover indicates that the mouse is over the node. pressed indicates
that the mouse is over the node and the mouse button is pressed, focused indi-
cates that the node has the input focus. To programmatically gain the input focus,
call the node function requestFocus() .
To control the appearance of a node, there are instance variables for opacity and
visible . Also, there are functions to move the node forward (in front of other
nodes), toFront() , or backward (behind other nodes), toBack() . You can assign a
special effect using the effect variable. This will be discussed in depth in Chap-
ter 6, Apply Special Effects . We have already discussed the style and styleClass
variables when we discussed style sheets, earlier in this chapter.
Lastly, you can use another node to define a clip region for this node, using the
clip attribute. When doing this, only the portion of the node that is contained
within the region of the other node is visible.
Custom Nodes
To create a custom node, just extend javafx.scene.CustomNode and implement
the abstract function, create() , which returns a node. The following Title
class is a CustomNode .
 
Search WWH ::




Custom Search