Skip to content

Commit d6dee34

Browse files
committed
8252547: Correct transformations docs in Node
Reviewed-by: kcr, arapte
1 parent 0514116 commit d6dee34

File tree

1 file changed

+33
-30
lines changed
  • modules/javafx.graphics/src/main/java/javafx/scene

1 file changed

+33
-30
lines changed

modules/javafx.graphics/src/main/java/javafx/scene/Node.java

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@
225225
* an UnsupportedOperationException being thrown.
226226
* </p>
227227
*
228-
* <h2>String ID</h2>
228+
* <h2><a id="StringID">String ID</a></h2>
229229
* <p>
230230
* Each node in the scene graph can be given a unique {@link #idProperty id}. This id is
231231
* much like the "id" attribute of an HTML tag in that it is up to the designer
@@ -235,7 +235,7 @@
235235
* scene graph. The id can also be used identify nodes for applying styles; see
236236
* the CSS section below.
237237
*
238-
* <h2>Coordinate System</h2>
238+
* <h2><a id="CoordinateSystem">Coordinate System</a></h2>
239239
* <p>
240240
* The {@code Node} class defines a traditional computer graphics "local"
241241
* coordinate system in which the {@code x} axis increases to the right and the
@@ -268,7 +268,7 @@
268268
* important context-specific information about coordinate mapping and how
269269
* it can affect rendering.
270270
*
271-
* <h2>Transformations</h2>
271+
* <h2><a id="Transformations">Transformations</a></h2>
272272
* <p>
273273
* Any {@code Node} can have transformations applied to it. These include
274274
* translation, rotation, scaling, or shearing.
@@ -321,11 +321,22 @@
321321
* A <b>shearing</b> transformation, sometimes called a skew, effectively
322322
* rotates one axis so that the x and y axes are no longer perpendicular.
323323
* <p>
324-
* Multiple transformations may be applied to a node by specifying an ordered
325-
* chain of transforms. The order in which the transforms are applied is
326-
* defined by the ObservableList specified in the {@link #getTransforms transforms} variable.
324+
* Multiple transformations may be applied to a node. Custom transforms are applied using the
325+
* {@link #getTransforms transforms} list. Predefined transforms are applied using the properties specified below.
326+
* The matrices that represent the transforms are multiplied in this order:
327+
* <ol>
328+
* <li> Layout ({@link #layoutXProperty layoutX}, {@link #layoutYProperty layoutY}) and translate
329+
* ({@link #translateXProperty translateX}, {@link #translateYProperty translateY}, {@link #translateZProperty translateZ})</li>
330+
* <li> Rotate ({@link #rotateProperty rotate})</li>
331+
* <li> Scale ({@link #scaleXProperty scaleX}, {@link #scaleYProperty scaleY}, {@link #scaleZProperty scaleZ})</li>
332+
* <li> Transforms list ({@link #getTransforms transforms}) starting from element 0</li>
333+
* </ol>
334+
* The transforms are applied in the reverse order of the matrix multiplication outlined above: last element of the transforms list
335+
* to 0th element, scale, rotate, and layout and translate. By applying the transforms in this order, the bounds in the local
336+
* coordinates of the node are transformed to the bounds in the parent coordinate of the node (see the
337+
* <a href="#BoundingRectangles">Bounding Rectangles</a> section).
327338
*
328-
* <h2>Bounding Rectangles</h2>
339+
* <h2><a id="BoundingRectangles">Bounding Rectangles</a></h2>
329340
* <p>
330341
* Since every {@code Node} has transformations, every Node's geometric
331342
* bounding rectangle can be described differently depending on whether
@@ -340,9 +351,7 @@
340351
* <p>
341352
* Each {@code Node} also has a read-only {@link #boundsInParentProperty boundsInParent} variable which
342353
* specifies the bounding rectangle of the {@code Node} after all transformations
343-
* have been applied, including those set in {@link #getTransforms transforms},
344-
* {@link #scaleXProperty scaleX}/{@link #scaleYProperty scaleY}, {@link #rotateProperty rotate},
345-
* {@link #translateXProperty translateX}/{@link #translateYProperty translateY}, and {@link #layoutXProperty layoutX}/{@link #layoutYProperty layoutY}.
354+
* have been applied as specified in the <a href="#Transformations">Transformations</a> section.
346355
* It is called "boundsInParent" because the rectangle will be relative to the
347356
* parent's coordinate system. This is the 'visual' bounds of the node.
348357
* <p>
@@ -380,8 +389,7 @@
380389
* <p> <img src="doc-files/bounds.png" alt="The rectangles are enclosed by their
381390
* respective bounds"> </p>
382391
*
383-
*
384-
* <h2>CSS</h2>
392+
* <h2><a id="CSS">CSS</a></h2>
385393
* <p>
386394
* The {@code Node} class contains {@code id}, {@code styleClass}, and
387395
* {@code style} variables that are used in styling this node from
@@ -393,6 +401,7 @@
393401
* For further information about CSS and how to apply CSS styles
394402
* to nodes, see the <a href="doc-files/cssref.html">CSS Reference
395403
* Guide</a>.
404+
*
396405
* @since JavaFX 2.0
397406
*/
398407
@IDProperty("id")
@@ -3388,21 +3397,12 @@ public final Bounds getBoundsInParent() {
33883397
}
33893398

33903399
/**
3391-
* The rectangular bounds of this {@code Node} which include its transforms.
3392-
* {@code boundsInParent} is calculated by
3393-
* taking the local bounds (defined by {@link #boundsInLocalProperty boundsInLocal}) and applying
3394-
* the transform created by setting the following additional variables
3395-
* <ol>
3396-
* <li>{@link #getTransforms transforms} ObservableList</li>
3397-
* <li>{@link #scaleXProperty scaleX}, {@link #scaleYProperty scaleY}, {@link #scaleZProperty scaleZ}</li>
3398-
* <li>{@link #rotateProperty rotate}</li>
3399-
* <li>{@link #layoutXProperty layoutX}, {@link #layoutYProperty layoutY}</li>
3400-
* <li>{@link #translateXProperty translateX}, {@link #translateYProperty translateY},
3401-
* {@link #translateZProperty translateZ}</li>
3402-
* </ol>
3400+
* The rectangular bounds of this {@code Node} in the parent coordinate system.
3401+
* {@code boundsInParent} is calculated by taking the {@linkplain #boundsInLocalProperty local bounds} and applying
3402+
* the node transforms as specified in the <a href="#Transformations">Transformations</a> section of the class doc.
34033403
* <p>
34043404
* The resulting bounds will be conceptually in the coordinate space of the
3405-
* {@code Node}'s parent, however the node need not have a parent to calculate
3405+
* {@code Node}'s parent, however, the node need not have a parent to calculate
34063406
* these bounds.
34073407
* <p>
34083408
* Note that this method does not take the node's visibility into account;
@@ -3418,7 +3418,10 @@ public final Bounds getBoundsInParent() {
34183418
* this variable. For example, the x or y variables of a shape, or
34193419
* {@code translateX}, {@code translateY} should never be bound to
34203420
* {@code boundsInParent} for the purpose of positioning the node.
3421-
* @return the boundsInParent for this {@code Node}
3421+
* <p>
3422+
* See also the <a href="#BoundingRectangles">Bounding Rectangles</a> section.
3423+
*
3424+
* @return the {@code boundsInParent} property for this {@code Node}
34223425
*/
34233426
public final ReadOnlyObjectProperty<Bounds> boundsInParentProperty() {
34243427
return getMiscProperties().boundsInParentProperty();
@@ -5519,10 +5522,10 @@ public final double getViewOrder() {
55195522
* *
55205523
**************************************************************************/
55215524
/**
5522-
* Defines the ObservableList of {@link javafx.scene.transform.Transform} objects
5523-
* to be applied to this {@code Node}. This ObservableList of transforms is applied
5524-
* before {@link #translateXProperty translateX}, {@link #translateYProperty translateY}, {@link #scaleXProperty scaleX}, and
5525-
* {@link #scaleYProperty scaleY}, {@link #rotateProperty rotate} transforms.
5525+
* The {@code ObservableList} of custom {@link javafx.scene.transform.Transform}s
5526+
* to be applied to this {@code Node}. These transforms are applied before the predefined transforms.
5527+
* <p>
5528+
* See also the <a href="#Transformations">Transformations</a> section.
55265529
*
55275530
* @return the transforms for this {@code Node}
55285531
* @defaultValue empty

0 commit comments

Comments
 (0)