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.
Example:
int width = 220;
int height = 100;
FloatMap floatMap = new FloatMap();
floatMap.setWidth(width);
floatMap.setHeight(height);
for (int i = 0; i < width; i++) {
double v = (Math.sin(i / 20.0 * Math.PI) - 0.5) / 40.0;
for (int j = 0; j < height; j++) {
floatMap.setSamples(i, j, 0.0f, (float) v);
}
}
DisplacementMap displacementMap = new DisplacementMap();
displacementMap.setMapData(floatMap);
Text text = new Text();
text.setX(40.0);
text.setY(80.0);
text.setText("Wavy Text");
text.setFill(Color.web("0x3b596d"));
text.setFont(Font.font(null, FontWeight.BOLD, 50));
text.setEffect(displacementMap);
The code above produces the following:
| Modifier and Type | Class and Description |
|---|---|
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private final FloatMap | |
| private ObjectProperty | input
The input for this |
| private ObjectProperty | mapData
The map data for this |
| private final DisplacementMap. | |
| private DoubleProperty | offsetX
The offset by which all x coordinate offset values in the
|
| private DoubleProperty | offsetY
The offset by which all y coordinate offset values in the
|
| private DoubleProperty | scaleX
The scale factor by which all x coordinate offset values in the
|
| private DoubleProperty | scaleY
The scale factor by which all y coordinate offset values in the
|
| private BooleanProperty | wrap
Defines whether values taken from outside the edges of the map "wrap around" or not. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | DisplacementMap(FloatMap
the map data for this displacement map effect mapData)Creates a new instance of DisplacementMap with the specified mapData. |
| public | DisplacementMap(FloatMap
the map data for this displacement map effect mapData, double the offset by which all x coordinate offset values in the
offsetX, double FloatMap are displaced after they are scaledthe offset by which all y coordinate offset values in the
offsetY, double FloatMap are displaced after they are scaledthe scale factor by which all x coordinate offset values in the
scaleX, double FloatMap are multipliedthe scale factor by which all y coordinate offset values in the
scaleY)FloatMap are multipliedCreates a new instance of DisplacementMap with the specified mapData, offsetX, offsetY, scaleX, and scaleY. |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv boolean | |
| pack-priv Effect | |
| pack-priv DisplacementMap | |
| pack-priv BaseBounds | getBounds(BaseBounds bounds, BaseTransform tx, Node node, BoundsAccessor boundsAccessor)
Implements abstract javafx. Returns bounds of given node with applied effect. |
| public final Effect | |
| public final FloatMap | |
| public final double | |
| public final double | |
| public final double | |
| public final double | |
| public final ObjectProperty | |
| public final boolean | |
| public final ObjectProperty | |
| public final DoubleProperty | |
| public final DoubleProperty | |
| public final DoubleProperty | |
| public final DoubleProperty | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| pack-priv void | |
| public final BooleanProperty |
| defaultMap | back to summary |
|---|---|
| private final FloatMap defaultMap | |
| input | back to summary |
|---|---|
| private ObjectProperty<Effect> input The input for this
| |
| mapData | back to summary |
|---|---|
| private ObjectProperty<FloatMap> mapData The map data for this
| |
| mapDataChangeListener | back to summary |
|---|---|
| private final DisplacementMap. | |
| offsetX | back to summary |
|---|---|
| private DoubleProperty offsetX The offset by which all x coordinate offset values in the
Min: n/a
Max: n/a
Default: 0.0
Identity: 0.0
| |
| offsetY | back to summary |
|---|---|
| private DoubleProperty offsetY The offset by which all y coordinate offset values in the
Min: n/a
Max: n/a
Default: 0.0
Identity: 0.0
| |
| scaleX | back to summary |
|---|---|
| private DoubleProperty scaleX The scale factor by which all x coordinate offset values in the
Min: n/a
Max: n/a
Default: 1.0
Identity: 1.0
| |
| scaleY | back to summary |
|---|---|
| private DoubleProperty scaleY The scale factor by which all y coordinate offset values in the
Min: n/a
Max: n/a
Default: 1.0
Identity: 1.0
| |
| wrap | back to summary |
|---|---|
| private BooleanProperty wrap Defines whether values taken from outside the edges of the map "wrap around" or not.
Min: n/a
Max: n/a
Default: false
Identity: n/a
| |
| DisplacementMap | back to summary |
|---|---|
| public DisplacementMap() Creates a new instance of DisplacementMap with default parameters. | |
| DisplacementMap | back to summary |
|---|---|
| public DisplacementMap(FloatMap mapData) Creates a new instance of DisplacementMap with the specified mapData.
| |
| DisplacementMap | back to summary |
|---|---|
| public DisplacementMap(FloatMap mapData, double offsetX, double offsetY, double scaleX, double scaleY) Creates a new instance of DisplacementMap with the specified mapData, offsetX, offsetY, scaleX, and scaleY.
| |
| checkChainContains | back to summary |
|---|---|
| pack-priv boolean checkChainContains(Effect e) Implements abstract javafx.
| |
| copy | back to summary |
|---|---|
| pack-priv Effect copy() Implements abstract javafx.
| |
| createPeer | back to summary |
|---|---|
| pack-priv DisplacementMap createPeer() Implements abstract javafx.
| |
| getBounds | back to summary |
|---|---|
| pack-priv BaseBounds getBounds(BaseBounds bounds, BaseTransform tx, Node node, BoundsAccessor boundsAccessor) Implements abstract javafx. Doc from javafx. Returns bounds of given node with applied effect. We *never* pass null in as a bounds. This method will NOT take a null bounds object. The returned value may be the same bounds object passed in, or it may be a new object.
| |
| getInput | back to summary |
|---|---|
| public final Effect getInput() | |
| getMapData | back to summary |
|---|---|
| public final FloatMap getMapData() | |
| getOffsetX | back to summary |
|---|---|
| public final double getOffsetX() | |
| getOffsetY | back to summary |
|---|---|
| public final double getOffsetY() | |
| getScaleX | back to summary |
|---|---|
| public final double getScaleX() | |
| getScaleY | back to summary |
|---|---|
| public final double getScaleY() | |
| inputProperty | back to summary |
|---|---|
| public final ObjectProperty | |
| isWrap | back to summary |
|---|---|
| public final boolean isWrap() | |
| mapDataProperty | back to summary |
|---|---|
| public final ObjectProperty | |
| offsetXProperty | back to summary |
|---|---|
| public final DoubleProperty offsetXProperty() | |
| offsetYProperty | back to summary |
|---|---|
| public final DoubleProperty offsetYProperty() | |
| scaleXProperty | back to summary |
|---|---|
| public final DoubleProperty scaleXProperty() | |
| scaleYProperty | back to summary |
|---|---|
| public final DoubleProperty scaleYProperty() | |
| setInput | back to summary |
|---|---|
| public final void setInput(Effect value) | |
| setMapData | back to summary |
|---|---|
| public final void setMapData(FloatMap value) | |
| setOffsetX | back to summary |
|---|---|
| public final void setOffsetX(double value) | |
| setOffsetY | back to summary |
|---|---|
| public final void setOffsetY(double value) | |
| setScaleX | back to summary |
|---|---|
| public final void setScaleX(double value) | |
| setScaleY | back to summary |
|---|---|
| public final void setScaleY(double value) | |
| setWrap | back to summary |
|---|---|
| public final void setWrap(boolean value) | |
| update | back to summary |
|---|---|
| pack-priv void update() Implements abstract javafx.
| |
| wrapProperty | back to summary |
|---|---|
| public final BooleanProperty wrapProperty() | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv FloatMap |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | invalidated(Observable
The valueModel)Observable that became invalidImplements javafx. This method needs to be provided by an implementation of
|
| public void |
| mapData | back to summary |
|---|---|
| pack-priv FloatMap mapData | |
| MapDataChangeListener | back to summary |
|---|---|
| private MapDataChangeListener() | |
| invalidated | back to summary |
|---|---|
| public void invalidated(Observable valueModel) Implements javafx. Doc from javafx. This method needs to be provided by an implementation of
In general, it is considered bad practice to modify the observed value in this method.
| |
| register | back to summary |
|---|---|
| public void register(FloatMap value) | |