/* * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ package javafx.scene.effect; import javafx.beans.property.DoubleProperty; import javafx.beans.property.DoublePropertyBase; import javafx.beans.property.ObjectProperty; import javafx.scene.Node; import com.sun.javafx.util.Utils; import com.sun.javafx.effect.EffectDirtyBits; import com.sun.javafx.geom.BaseBounds; import com.sun.javafx.geom.transform.BaseTransform; import com.sun.javafx.scene.BoundsAccessor; /** * A high-level effect that makes brighter portions of the input image * appear to glow, based on a configurable threshold. * *
* Example: *
* Bloom bloom = new Bloom();
* bloom.setThreshold(0.1);
*
* Rectangle rect = new Rectangle();
* rect.setX(10);
* rect.setY(10);
* rect.setWidth(160);
* rect.setHeight(80);
* rect.setFill(Color.DARKSLATEBLUE);
*
* Text text = new Text();
* text.setText("Bloom!");
* text.setFill(Color.ALICEBLUE);
* text.setFont(Font.font(null, FontWeight.BOLD, 40));
* text.setX(25);
* text.setY(65);
* text.setEffect(bloom);
*
*
* The code above produces the following:
*
*
*
* Min: 0.0 * Max: 1.0 * Default: 0.3 * Identity: n/a ** @defaultValue 0.3 */ private DoubleProperty threshold; public final void setThreshold(double value) { thresholdProperty().set(value); } public final double getThreshold() { return threshold == null ? 0.3 : threshold.get(); } public final DoubleProperty thresholdProperty() { if (threshold == null) { threshold = new DoublePropertyBase(0.3) { @Override public void invalidated() { markDirty(EffectDirtyBits.EFFECT_DIRTY); } @Override public Object getBean() { return Bloom.this; } @Override public String getName() { return "threshold"; } }; } return threshold; } @Override void impl_update() { Effect localInput = getInput(); if (localInput != null) { localInput.impl_sync(); } com.sun.scenario.effect.Bloom peer = (com.sun.scenario.effect.Bloom) impl_getImpl(); peer.setInput(localInput == null ? null : localInput.impl_getImpl()); peer.setThreshold((float)Utils.clamp(0, getThreshold(), 1)); } /** * @treatAsPrivate implementation detail * @deprecated This is an internal API that is not intended for use and will be removed in the next version */ @Deprecated @Override public BaseBounds impl_getBounds(BaseBounds bounds, BaseTransform tx, Node node, BoundsAccessor boundsAccessor) { return getInputBounds(bounds, tx,node, boundsAccessor, getInput()); } /** * @treatAsPrivate implementation detail * @deprecated This is an internal API that is not intended for use and will be removed in the next version */ @Deprecated @Override public Effect impl_copy() { Bloom b = new Bloom(this.getThreshold()); b.setInput(this.getInput()); return b; } }