Class PerspectiveTransform
public class PerspectiveTransform extends Effect
PerspectiveTransform is used to provide a "faux" three-dimensional effect for otherwise two-dimensional content. A perspective transformation is capable of mapping an arbitrary quadrilateral into another arbitrary quadrilateral, while preserving the straightness of lines. Unlike an affine transformation, the parallelism of lines in the source is not necessarily preserved in the output.
Note that this effect does not adjust the coordinates of input events or any methods that measure containment on a Node. The results of mouse picking and the containment methods are undefined when a Node has a PerspectiveTransform effect in place.
Example:
PerspectiveTransform perspectiveTrasform = new PerspectiveTransform();
perspectiveTrasform.setUlx(10.0);
perspectiveTrasform.setUly(10.0);
perspectiveTrasform.setUrx(310.0);
perspectiveTrasform.setUry(40.0);
perspectiveTrasform.setLrx(310.0);
perspectiveTrasform.setLry(60.0);
perspectiveTrasform.setLlx(10.0);
perspectiveTrasform.setLly(90.0);
Group g = new Group();
g.setEffect(perspectiveTrasform);
g.setCache(true);
Rectangle rect = new Rectangle();
rect.setX(10.0);
rect.setY(10.0);
rect.setWidth(280.0);
rect.setHeight(80.0);
rect.setFill(Color.web("0x3b596d"));
Text text = new Text();
text.setX(20.0);
text.setY(65.0);
text.setText("Perspective");
text.setFill(Color.ALICEBLUE);
text.setFont(Font.font(null, FontWeight.BOLD, 36));
g.getChildren().addAll(rect, text);
The code above produces the following:
- Since:
- JavaFX 2.0
Property Summary
| Type | Property | Description |
|---|---|---|
final ObjectProperty |
input |
The input for this Effect. |
final DoubleProperty |
llx |
The x coordinate of the output location onto which the lower left corner of the source is mapped. |
final DoubleProperty |
lly |
The y coordinate of the output location onto which the lower left corner of the source is mapped. |
final DoubleProperty |
lrx |
The x coordinate of the output location onto which the lower right corner of the source is mapped. |
final DoubleProperty |
lry |
The y coordinate of the output location onto which the lower right corner of the source is mapped. |
final DoubleProperty |
ulx |
The x coordinate of the output location onto which the upper left corner of the source is mapped. |
final DoubleProperty |
uly |
The y coordinate of the output location onto which the upper left corner of the source is mapped. |
final DoubleProperty |
urx |
The x coordinate of the output location onto which the upper right corner of the source is mapped. |
final DoubleProperty |
ury |
The y coordinate of the output location onto which the upper right corner of the source is mapped. |
Constructor Summary
| Constructor | Description |
|---|---|
PerspectiveTransform() |
Creates a new instance of PerspectiveTransform with default parameters. |
PerspectiveTransform |
Creates a new instance of PerspectiveTransform with the specified ulx, uly, urx, ury, lrx, lry, llx, and lly. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
final Effect |
getInput() |
Gets the value of the input property. |
final double |
getLlx() |
Gets the value of the llx property. |
final double |
getLly() |
Gets the value of the lly property. |
final double |
getLrx() |
Gets the value of the lrx property. |
final double |
getLry() |
Gets the value of the lry property. |
final double |
getUlx() |
Gets the value of the ulx property. |
final double |
getUly() |
Gets the value of the uly property. |
final double |
getUrx() |
Gets the value of the urx property. |
final double |
getUry() |
Gets the value of the ury property. |
final ObjectProperty |
inputProperty() |
The input for this Effect. |
final DoubleProperty |
llxProperty() |
The x coordinate of the output location onto which the lower left corner of the source is mapped. |
final DoubleProperty |
llyProperty() |
The y coordinate of the output location onto which the lower left corner of the source is mapped. |
final DoubleProperty |
lrxProperty() |
The x coordinate of the output location onto which the lower right corner of the source is mapped. |
final DoubleProperty |
lryProperty() |
The y coordinate of the output location onto which the lower right corner of the source is mapped. |
final void |
setInput |
Sets the value of the input property. |
final void |
setLlx |
Sets the value of the llx property. |
final void |
setLly |
Sets the value of the lly property. |
final void |
setLrx |
Sets the value of the lrx property. |
final void |
setLry |
Sets the value of the lry property. |
final void |
setUlx |
Sets the value of the ulx property. |
final void |
setUly |
Sets the value of the uly property. |
final void |
setUrx |
Sets the value of the urx property. |
final void |
setUry |
Sets the value of the ury property. |
final DoubleProperty |
ulxProperty() |
The x coordinate of the output location onto which the upper left corner of the source is mapped. |
final DoubleProperty |
ulyProperty() |
The y coordinate of the output location onto which the upper left corner of the source is mapped. |
final DoubleProperty |
urxProperty() |
The x coordinate of the output location onto which the upper right corner of the source is mapped. |
final DoubleProperty |
uryProperty() |
The y coordinate of the output location onto which the upper right corner of the source is mapped. |
Property Details
input
public final ObjectProperty<Effect> inputProperty
Effect. If set to null, or left unspecified, a graphical image of the Node to which the Effect is attached will be used as the input.- Default value:
- null
- See Also:
ulx
public final DoubleProperty ulxProperty
- Default value:
- 0.0
- See Also:
uly
public final DoubleProperty ulyProperty
- Default value:
- 0.0
- See Also:
urx
public final DoubleProperty urxProperty
- Default value:
- 0.0
- See Also:
ury
public final DoubleProperty uryProperty
- Default value:
- 0.0
- See Also:
lrx
public final DoubleProperty lrxProperty
- Default value:
- 0.0
- See Also:
lry
public final DoubleProperty lryProperty
- Default value:
- 0.0
- See Also:
llx
public final DoubleProperty llxProperty
- Default value:
- 0.0
- See Also:
lly
public final DoubleProperty llyProperty
- Default value:
- 0.0
- See Also:
Constructor Details
PerspectiveTransform
public PerspectiveTransform()
PerspectiveTransform
public PerspectiveTransform(double ulx, double uly, double urx, double ury, double lrx, double lry, double llx, double lly)
- Parameters:
-
ulx- the x coordinate of upper left corner -
uly- the y coordinate of upper left corner -
urx- the x coordinate of upper right corner -
ury- the y coordinate of upper right corner -
lrx- the x coordinate of lower right corner -
lry- the y coordinate of lower right corner -
llx- the x coordinate of lower left corner -
lly- the y coordinate of lower left corner - Since:
- JavaFX 2.1
Method Details
setInput
public final void setInput(Effect value)
input property.- Property description:
- The input for this
Effect. If set tonull, or left unspecified, a graphical image of theNodeto which theEffectis attached will be used as the input. - Default value:
- null
- Parameters:
-
value- the value for theinputproperty - See Also:
getInput
public final Effect getInput()
input property.- Property description:
- The input for this
Effect. If set tonull, or left unspecified, a graphical image of theNodeto which theEffectis attached will be used as the input. - Default value:
- null
- Returns:
- the value of the
inputproperty - See Also:
inputProperty
public final ObjectProperty<Effect> inputProperty()
Effect. If set to null, or left unspecified, a graphical image of the Node to which the Effect is attached will be used as the input.- Default value:
- null
- Returns:
- the
inputproperty - See Also:
setUlx
public final void setUlx(double value)
ulx property.- Property description:
- The x coordinate of the output location onto which the upper left corner of the source is mapped.
- Default value:
- 0.0
- Parameters:
-
value- the value for theulxproperty - See Also:
getUlx
public final double getUlx()
ulx property.- Property description:
- The x coordinate of the output location onto which the upper left corner of the source is mapped.
- Default value:
- 0.0
- Returns:
- the value of the
ulxproperty - See Also:
ulxProperty
public final DoubleProperty ulxProperty()
- Default value:
- 0.0
- Returns:
- the
ulxproperty - See Also:
setUly
public final void setUly(double value)
uly property.- Property description:
- The y coordinate of the output location onto which the upper left corner of the source is mapped.
- Default value:
- 0.0
- Parameters:
-
value- the value for theulyproperty - See Also:
getUly
public final double getUly()
uly property.- Property description:
- The y coordinate of the output location onto which the upper left corner of the source is mapped.
- Default value:
- 0.0
- Returns:
- the value of the
ulyproperty - See Also:
ulyProperty
public final DoubleProperty ulyProperty()
- Default value:
- 0.0
- Returns:
- the
ulyproperty - See Also:
setUrx
public final void setUrx(double value)
urx property.- Property description:
- The x coordinate of the output location onto which the upper right corner of the source is mapped.
- Default value:
- 0.0
- Parameters:
-
value- the value for theurxproperty - See Also:
getUrx
public final double getUrx()
urx property.- Property description:
- The x coordinate of the output location onto which the upper right corner of the source is mapped.
- Default value:
- 0.0
- Returns:
- the value of the
urxproperty - See Also:
urxProperty
public final DoubleProperty urxProperty()
- Default value:
- 0.0
- Returns:
- the
urxproperty - See Also:
setUry
public final void setUry(double value)
ury property.- Property description:
- The y coordinate of the output location onto which the upper right corner of the source is mapped.
- Default value:
- 0.0
- Parameters:
-
value- the value for theuryproperty - See Also:
getUry
public final double getUry()
ury property.- Property description:
- The y coordinate of the output location onto which the upper right corner of the source is mapped.
- Default value:
- 0.0
- Returns:
- the value of the
uryproperty - See Also:
uryProperty
public final DoubleProperty uryProperty()
- Default value:
- 0.0
- Returns:
- the
uryproperty - See Also:
setLrx
public final void setLrx(double value)
lrx property.- Property description:
- The x coordinate of the output location onto which the lower right corner of the source is mapped.
- Default value:
- 0.0
- Parameters:
-
value- the value for thelrxproperty - See Also:
getLrx
public final double getLrx()
lrx property.- Property description:
- The x coordinate of the output location onto which the lower right corner of the source is mapped.
- Default value:
- 0.0
- Returns:
- the value of the
lrxproperty - See Also:
lrxProperty
public final DoubleProperty lrxProperty()
- Default value:
- 0.0
- Returns:
- the
lrxproperty - See Also:
setLry
public final void setLry(double value)
lry property.- Property description:
- The y coordinate of the output location onto which the lower right corner of the source is mapped.
- Default value:
- 0.0
- Parameters:
-
value- the value for thelryproperty - See Also:
getLry
public final double getLry()
lry property.- Property description:
- The y coordinate of the output location onto which the lower right corner of the source is mapped.
- Default value:
- 0.0
- Returns:
- the value of the
lryproperty - See Also:
lryProperty
public final DoubleProperty lryProperty()
- Default value:
- 0.0
- Returns:
- the
lryproperty - See Also:
setLlx
public final void setLlx(double value)
llx property.- Property description:
- The x coordinate of the output location onto which the lower left corner of the source is mapped.
- Default value:
- 0.0
- Parameters:
-
value- the value for thellxproperty - See Also:
getLlx
public final double getLlx()
llx property.- Property description:
- The x coordinate of the output location onto which the lower left corner of the source is mapped.
- Default value:
- 0.0
- Returns:
- the value of the
llxproperty - See Also:
llxProperty
public final DoubleProperty llxProperty()
- Default value:
- 0.0
- Returns:
- the
llxproperty - See Also:
setLly
public final void setLly(double value)
lly property.- Property description:
- The y coordinate of the output location onto which the lower left corner of the source is mapped.
- Default value:
- 0.0
- Parameters:
-
value- the value for thellyproperty - See Also:
getLly
public final double getLly()
lly property.- Property description:
- The y coordinate of the output location onto which the lower left corner of the source is mapped.
- Default value:
- 0.0
- Returns:
- the value of the
llyproperty - See Also:
llyProperty
public final DoubleProperty llyProperty()
- Default value:
- 0.0
- Returns:
- the
llyproperty - See Also:
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.