Spec-Zone .ru
спецификации, руководства, описания, API
|
public class DisplacementMap extends Effect
FloatMap
.
For each pixel in the output, the corresponding data from the
mapData
is retrieved, scaled and offset by the scale
and offset
attributes, scaled again by the size of the
source input image and used as an offset from the destination pixel
to retrieve the pixel data from the source input.
dst[x,y] = src[(x,y) + (offset+scale*map[x,y])*(srcw,srch)]A value of
(0.0, 0.0)
would specify no offset for the
pixel data whereas a value of (0.5, 0.5)
would specify
an offset of half of the source image size.
Note that the mapping is the offset from a destination pixel to
the source pixel location from which it is sampled which means that
filling the map with all values of 0.5
would displace the
image by half of its size towards the upper left since each destination
pixel would contain the data that comes from the source pixel below and
to the right of it.
Also 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 DisplacementMap
effect in place.
import javafx.scene.*; import javafx.scene.text.*; import javafx.scene.shape.*; import javafx.scene.paint.*; import javafx.scene.effect.*; int w = 220; int h = 100; FloatMap map = new FloatMap(); map.setWidth(w); map.setHeight(h); for (int i = 0; i < w; i++) { double v = (Math.sin(i/50.0*Math.PI)-0.5)/40.0; for (int j = 0; j < h; j++) { map.setSamples(i, j, 0.0f,(float) v); } } Group g = new Group(); DisplacementMap dm = new DisplacementMap(); dm.setMapData(map); g.setEffect(dm); g.setCache(true); Rectangle r = new Rectangle(); r.setX(20.0); r.setY(20.0); r.setWidth(w); r.setHeight(h); r.setFill(Color.BLUE); g.getChildren().add(r); Text t = new Text(); t.setX(40.0); t.setY(80.0); t.setText("Wavy Text"); t.setFill(Color.YELLOW); t.setFont(Font.font(null, FontWeight.BOLD, 36)); g.getChildren().add(t);
Type | Property and Description |
---|---|
ObjectProperty<Effect> |
input
The input for this
Effect . |
ObjectProperty<FloatMap> |
mapData
The map data for this
Effect . |
DoubleProperty |
offsetX
The offset by which all x coordinate offset values in the
FloatMap are displaced after they are scaled. |
DoubleProperty |
offsetY
The offset by which all y coordinate offset values in the
FloatMap are displaced after they are scaled. |
DoubleProperty |
scaleX
The scale factor by which all x coordinate offset values in the
FloatMap are multiplied. |
DoubleProperty |
scaleY
The scale factor by which all y coordinate offset values in the
FloatMap are multiplied. |
BooleanProperty |
wrap
Defines whether values taken from outside the edges of the map
"wrap around" or not.
|
Constructor and Description |
---|
DisplacementMap()
Creates a new instance of DisplacementMap with default parameters.
|
Modifier and Type | Method and Description |
---|---|
Effect |
getInput()
The input for this
Effect . |
FloatMap |
getMapData()
The map data for this
Effect . |
double |
getOffsetX()
The offset by which all x coordinate offset values in the
FloatMap are displaced after they are scaled. |
double |
getOffsetY()
The offset by which all y coordinate offset values in the
FloatMap are displaced after they are scaled. |
double |
getScaleX()
The scale factor by which all x coordinate offset values in the
FloatMap are multiplied. |
double |
getScaleY()
The scale factor by which all y coordinate offset values in the
FloatMap are multiplied. |
ObjectProperty<Effect> |
inputProperty()
The input for this
Effect . |
boolean |
isWrap()
Defines whether values taken from outside the edges of the map
"wrap around" or not.
|
ObjectProperty<FloatMap> |
mapDataProperty()
The map data for this
Effect . |
DoubleProperty |
offsetXProperty()
The offset by which all x coordinate offset values in the
FloatMap are displaced after they are scaled. |
DoubleProperty |
offsetYProperty()
The offset by which all y coordinate offset values in the
FloatMap are displaced after they are scaled. |
DoubleProperty |
scaleXProperty()
The scale factor by which all x coordinate offset values in the
FloatMap are multiplied. |
DoubleProperty |
scaleYProperty()
The scale factor by which all y coordinate offset values in the
FloatMap are multiplied. |
void |
setInput(Effect value)
The input for this
Effect . |
void |
setMapData(FloatMap value)
The map data for this
Effect . |
void |
setOffsetX(double value)
The offset by which all x coordinate offset values in the
FloatMap are displaced after they are scaled. |
void |
setOffsetY(double value)
The offset by which all y coordinate offset values in the
FloatMap are displaced after they are scaled. |
void |
setScaleX(double value)
The scale factor by which all x coordinate offset values in the
FloatMap are multiplied. |
void |
setScaleY(double value)
The scale factor by which all y coordinate offset values in the
FloatMap are multiplied. |
void |
setWrap(boolean value)
Defines whether values taken from outside the edges of the map
"wrap around" or not.
|
BooleanProperty |
wrapProperty()
Defines whether values taken from outside the edges of the map
"wrap around" or not.
|
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.getInput()
,
setInput(Effect)
Effect
.getMapData()
,
setMapData(FloatMap)
FloatMap
are multiplied.
Min: n/a Max: n/a Default: 1.0 Identity: 1.0
getScaleX()
,
setScaleX(double)
FloatMap
are multiplied.
Min: n/a Max: n/a Default: 1.0 Identity: 1.0
getScaleY()
,
setScaleY(double)
FloatMap
are displaced after they are scaled.
Min: n/a Max: n/a Default: 0.0 Identity: 0.0
getOffsetX()
,
setOffsetX(double)
FloatMap
are displaced after they are scaled.
Min: n/a Max: n/a Default: 0.0 Identity: 0.0
getOffsetY()
,
setOffsetY(double)
Min: n/a Max: n/a Default: false Identity: n/a
isWrap()
,
setWrap(boolean)
public DisplacementMap()
public final void setInput(Effect value)
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.public final Effect getInput()
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.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.getInput()
,
setInput(Effect)
public final void setMapData(FloatMap value)
Effect
.public final FloatMap getMapData()
Effect
.public final ObjectProperty<FloatMap> mapDataProperty()
Effect
.getMapData()
,
setMapData(FloatMap)
public final void setScaleX(double value)
FloatMap
are multiplied.
Min: n/a Max: n/a Default: 1.0 Identity: 1.0
public final double getScaleX()
FloatMap
are multiplied.
Min: n/a Max: n/a Default: 1.0 Identity: 1.0
public final DoubleProperty scaleXProperty()
FloatMap
are multiplied.
Min: n/a Max: n/a Default: 1.0 Identity: 1.0
getScaleX()
,
setScaleX(double)
public final void setScaleY(double value)
FloatMap
are multiplied.
Min: n/a Max: n/a Default: 1.0 Identity: 1.0
public final double getScaleY()
FloatMap
are multiplied.
Min: n/a Max: n/a Default: 1.0 Identity: 1.0
public final DoubleProperty scaleYProperty()
FloatMap
are multiplied.
Min: n/a Max: n/a Default: 1.0 Identity: 1.0
getScaleY()
,
setScaleY(double)
public final void setOffsetX(double value)
FloatMap
are displaced after they are scaled.
Min: n/a Max: n/a Default: 0.0 Identity: 0.0
public final double getOffsetX()
FloatMap
are displaced after they are scaled.
Min: n/a Max: n/a Default: 0.0 Identity: 0.0
public final DoubleProperty offsetXProperty()
FloatMap
are displaced after they are scaled.
Min: n/a Max: n/a Default: 0.0 Identity: 0.0
getOffsetX()
,
setOffsetX(double)
public final void setOffsetY(double value)
FloatMap
are displaced after they are scaled.
Min: n/a Max: n/a Default: 0.0 Identity: 0.0
public final double getOffsetY()
FloatMap
are displaced after they are scaled.
Min: n/a Max: n/a Default: 0.0 Identity: 0.0
public final DoubleProperty offsetYProperty()
FloatMap
are displaced after they are scaled.
Min: n/a Max: n/a Default: 0.0 Identity: 0.0
getOffsetY()
,
setOffsetY(double)
public final void setWrap(boolean value)
Min: n/a Max: n/a Default: false Identity: n/a
public final boolean isWrap()
Min: n/a Max: n/a Default: false Identity: n/a
public final BooleanProperty wrapProperty()
Min: n/a Max: n/a Default: false Identity: n/a
isWrap()
,
setWrap(boolean)
Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. Use is subject to