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:
Effect.EffectInputChangeListener, Effect.EffectInputProperty
Modifier and Type | Field and Description |
---|---|
private float[] |
devcoords |
private ObjectProperty<Effect> |
input
The input for this
Effect . |
private DoubleProperty |
llx
The x coordinate of the output location onto which the lower left
corner of the source is mapped.
|
private DoubleProperty |
lly
The y coordinate of the output location onto which the lower left
corner of the source is mapped.
|
private DoubleProperty |
lrx
The x coordinate of the output location onto which the lower right
corner of the source is mapped.
|
private DoubleProperty |
lry
The y coordinate of the output location onto which the lower right
corner of the source is mapped.
|
private DoubleProperty |
ulx
The x coordinate of the output location onto which the upper left
corner of the source is mapped.
|
private DoubleProperty |
uly
The y coordinate of the output location onto which the upper left
corner of the source is mapped.
|
private DoubleProperty |
urx
The x coordinate of the output location onto which the upper right
corner of the source is mapped.
|
private DoubleProperty |
ury
The y coordinate of the output location onto which the upper right
corner of the source is mapped.
|
Constructor and Description |
---|
PerspectiveTransform()
Creates a new instance of PerspectiveTransform with default parameters.
|
PerspectiveTransform(double ulx,
double uly,
double urx,
double ury,
double lrx,
double lry,
double llx,
double lly)
Creates a new instance of PerspectiveTransform with the specified ulx,
uly, urx, ury, lrx, lry, llx, and lly.
|
Modifier and Type | Method and Description |
---|---|
Effect |
getInput() |
double |
getLlx() |
double |
getLly() |
double |
getLrx() |
double |
getLry() |
double |
getUlx() |
double |
getUly() |
double |
getUrx() |
double |
getUry() |
(package private) boolean |
impl_checkChainContains(Effect e) |
Effect |
impl_copy()
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
(package private) PerspectiveTransform |
impl_createImpl() |
BaseBounds |
impl_getBounds(BaseBounds bounds,
BaseTransform tx,
Node node,
BoundsAccessor boundsAccessor)
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
(package private) void |
impl_update() |
ObjectProperty<Effect> |
inputProperty() |
DoubleProperty |
llxProperty() |
DoubleProperty |
llyProperty() |
DoubleProperty |
lrxProperty() |
DoubleProperty |
lryProperty() |
void |
setInput(Effect value) |
void |
setLlx(double value) |
void |
setLly(double value) |
void |
setLrx(double value) |
void |
setLry(double value) |
void |
setUlx(double value) |
void |
setUly(double value) |
private void |
setupDevCoords(BaseTransform transform) |
void |
setUrx(double value) |
void |
setUry(double value) |
DoubleProperty |
ulxProperty() |
DoubleProperty |
ulyProperty() |
private void |
updateXform() |
DoubleProperty |
urxProperty() |
DoubleProperty |
uryProperty() |
effectBoundsChanged, getInputBounds, getKernelSize, getShadowBounds, impl_containsCycles, impl_effectDirtyProperty, impl_getImpl, impl_isEffectDirty, impl_sync, markDirty, transformBounds
private ObjectProperty<Effect> input
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.private DoubleProperty ulx
private DoubleProperty uly
private DoubleProperty urx
private DoubleProperty ury
private DoubleProperty lrx
private DoubleProperty lry
private DoubleProperty llx
private DoubleProperty lly
private float[] devcoords
public PerspectiveTransform()
public PerspectiveTransform(double ulx, double uly, double urx, double ury, double lrx, double lry, double llx, double lly)
ulx
- the x coordinate of upper left corneruly
- the y coordinate of upper left cornerurx
- the x coordinate of upper right cornerury
- the y coordinate of upper right cornerlrx
- the x coordinate of lower right cornerlry
- the y coordinate of lower right cornerllx
- the x coordinate of lower left cornerlly
- the y coordinate of lower left cornerprivate void updateXform()
PerspectiveTransform impl_createImpl()
impl_createImpl
in class Effect
public final void setInput(Effect value)
public final Effect getInput()
public final ObjectProperty<Effect> inputProperty()
boolean impl_checkChainContains(Effect e)
impl_checkChainContains
in class Effect
public final void setUlx(double value)
public final double getUlx()
public final DoubleProperty ulxProperty()
public final void setUly(double value)
public final double getUly()
public final DoubleProperty ulyProperty()
public final void setUrx(double value)
public final double getUrx()
public final DoubleProperty urxProperty()
public final void setUry(double value)
public final double getUry()
public final DoubleProperty uryProperty()
public final void setLrx(double value)
public final double getLrx()
public final DoubleProperty lrxProperty()
public final void setLry(double value)
public final double getLry()
public final DoubleProperty lryProperty()
public final void setLlx(double value)
public final double getLlx()
public final DoubleProperty llxProperty()
public final void setLly(double value)
public final double getLly()
public final DoubleProperty llyProperty()
void impl_update()
impl_update
in class Effect
@Deprecated public BaseBounds impl_getBounds(BaseBounds bounds, BaseTransform tx, Node node, BoundsAccessor boundsAccessor)
Effect
impl_getBounds
in class Effect
private void setupDevCoords(BaseTransform transform)