javafx.scene.effect.Effect Java Examples

The following examples show how to use javafx.scene.effect.Effect. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Builders.java    From PDF4Teachers with Apache License 2.0 6 votes vote down vote up
public static ImageView buildImage(String imgPath, int width, int height, Effect effect) {
    ImageView imageView = new ImageView(new Image(imgPath));

    if(effect != null) imageView.setEffect(effect);

    if(width == 0 && height == 0) return imageView;

    if(width == 0){
        imageView.setFitHeight(height);
        imageView.setPreserveRatio(true);
    }else if(height == 0){
        imageView.setFitWidth(width);
        imageView.setPreserveRatio(true);
    }else{
        imageView.setFitWidth(width);
        imageView.setFitHeight(height);
    }
    return imageView;
}
 
Example #2
Source File: OtherEffects.java    From Learn-Java-12-Programming with MIT License 6 votes vote down vote up
@Override
public void run(){
    try {
        for(String effect: effects){
            for(int i = 0; i < 11; i++){
                double d = Math.round(i * 0.1 * 10.0) / 10.0;
                Effect e = createEffect(effect, i, txt);
                ivM.setEffect(e);
                ivP.setEffect(e);
                TimeUnit.SECONDS.sleep(1);
                if(pause){
                    while(true){
                        TimeUnit.SECONDS.sleep(1);
                        if(!pause){
                            break;
                        }
                    }
                }
            }
        }
        Platform.exit();
    } catch (Exception ex){
        ex.printStackTrace();
    }
}
 
Example #3
Source File: GameToken.java    From metastone with GNU General Public License v2.0 6 votes vote down vote up
private void createTargetButton() {
	target = (StackPane) lookup("#targetAnchor");
	Image image = IconFactory.getTargetIcon();
	ImageView targetIcon = new ImageView(image);
	targetIcon.setClip(new ImageView(image));
	ColorAdjust monochrome = new ColorAdjust();
	monochrome.setSaturation(-1.0);

	Blend red = new Blend(BlendMode.MULTIPLY, monochrome,
			new ColorInput(0, 0, targetIcon.getImage().getWidth(), targetIcon.getImage().getHeight(), Color.RED));

	Blend green = new Blend(BlendMode.MULTIPLY, monochrome,
			new ColorInput(0, 0, targetIcon.getImage().getWidth(), targetIcon.getImage().getHeight(), new Color(0, 1, 0, 0.5)));

	targetButton = targetIcon;

	targetIcon.effectProperty().bind(Bindings.when(targetButton.hoverProperty()).then((Effect) green).otherwise((Effect) red));
	targetButton.setId("target_button");
	hideTargetMarker();
	target.getChildren().add(targetButton);
}
 
Example #4
Source File: FxIconBuilder.java    From FxDock with Apache License 2.0 6 votes vote down vote up
protected Effect setInputEffect(Effect a, Effect b)
{
	// I don't know a better way to chain effects, it's missing in FX
	// https://bugs.openjdk.java.net/browse/JDK-8091895
	// perhaps try Blend:
	// https://community.oracle.com/thread/2337194?tstart=0
	if(b instanceof GaussianBlur)
	{
		((GaussianBlur)b).setInput(a);
	}
	else if(b instanceof ColorAdjust)
	{
		((ColorAdjust)b).setInput(a);
	}
	else
	{
		throw new Error("todo: does " + b + " have setInput()?"); 
	}
	return b;
}
 
Example #5
Source File: MvcLogoExample.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
private static Effect createShadowEffect() {
	DropShadow outerShadow = new DropShadow();
	outerShadow.setRadius(3);
	outerShadow.setSpread(0.2);
	outerShadow.setOffsetX(3);
	outerShadow.setOffsetY(3);
	outerShadow.setColor(new Color(0.3, 0.3, 0.3, 1));

	Distant light = new Distant();
	light.setAzimuth(-135.0f);

	Lighting l = new Lighting();
	l.setLight(light);
	l.setSurfaceScale(3.0f);

	Blend effects = new Blend(BlendMode.MULTIPLY);
	effects.setTopInput(l);
	effects.setBottomInput(outerShadow);

	return effects;
}
 
Example #6
Source File: GeometryNodeSnippet.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
protected static Effect createShadowEffect() {
	final DropShadow outerShadow = new DropShadow();
	outerShadow.setRadius(3);
	outerShadow.setSpread(0.2);
	outerShadow.setOffsetX(3);
	outerShadow.setOffsetY(3);
	outerShadow.setColor(new Color(0.3, 0.3, 0.3, 1));

	final Distant light = new Distant();
	light.setAzimuth(-135.0f);

	final Lighting l = new Lighting();
	l.setLight(light);
	l.setSurfaceScale(3.0f);

	final Blend effects = new Blend(BlendMode.MULTIPLY);
	effects.setTopInput(l);
	effects.setBottomInput(outerShadow);

	return effects;
}
 
Example #7
Source File: NameField.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
public NameField(final String name, final String prompt, final Effect errorEffect)
{
	this.nameField = new TextField("");
	this.nameField.setPromptText(prompt);
	this.errorEffect = errorEffect;
	this.noErrorEffect = this.nameField.getEffect();
	this.errorString = name + " not specified!";
	this.errorMessage = new SimpleObjectProperty<>(errorString);
	this.nameField.textProperty().addListener((obs, oldv, newv) -> {
		final boolean isError = Optional.ofNullable(newv).orElse("").length() > 0;
		this.errorMessage.set(!isError ? errorString : "");
		this.effectProperty.set(!isError ? this.errorEffect : noErrorEffect);
	});

	this.effectProperty.addListener((obs, oldv, newv) -> {
		if (!nameField.isFocused())
			nameField.setEffect(newv);
	});

	nameField.setEffect(this.effectProperty.get());

	nameField.focusedProperty().addListener((obs, oldv, newv) -> {
		if (newv)
			nameField.setEffect(this.noErrorEffect);
		else
			nameField.setEffect(effectProperty.get());
	});

	this.nameField.setText(null);

}
 
Example #8
Source File: ThingView.java    From narjillos with MIT License 5 votes vote down vote up
private Effect getHaloEffect(double zoomLevel) {
	double minZoomLevel = 0.2;
	if (zoomLevel <= minZoomLevel)
		return null;
	double alpha = (zoomLevel - minZoomLevel) * 2.5;
	double limitedAlpha = Math.max(0, Math.min(1, alpha));
	Color color = new Color(0.9, 0.9, 0.9, limitedAlpha);
	return new DropShadow(20, 7, 7, color);
}
 
Example #9
Source File: DigitFactory.java    From metastone with GNU General Public License v2.0 5 votes vote down vote up
private static void applyFontColor(ImageView image, Color color) {
	ColorAdjust monochrome = new ColorAdjust();
	monochrome.setSaturation(-1.0);
	Effect colorInput = new ColorInput(0, 0, image.getImage().getWidth(), image.getImage().getHeight(), color);
	Blend blend = new Blend(BlendMode.MULTIPLY, new ImageInput(image.getImage()), colorInput);
	image.setClip(new ImageView(image.getImage()));
	image.setEffect(blend);
	image.setCache(true);
}
 
Example #10
Source File: FxIconBuilder.java    From FxDock with Apache License 2.0 5 votes vote down vote up
public void addEffect(Effect x)
{
	if(effect == null)
	{
		effect = x;
	}
	else
	{
		effect = setInputEffect(effect, x);
	}
}
 
Example #11
Source File: GeometricCurve.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
public GeometricCurve(Point[] waypoints, Paint stroke, double strokeWidth, Double[] dashes, Effect effect) {
	super(constructCurveFromWayPoints(waypoints), stroke, strokeWidth, effect);
	if (waypoints.length < 2) {
		throw new IllegalArgumentException("At least start and end point need to be specified,");
	}
	wayPointsProperty.addAll(Arrays.asList(waypoints));
	dashesProperty.addAll(dashes);
}
 
Example #12
Source File: AbstractGeometricElement.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
public AbstractGeometricElement(G geometry, Paint stroke,
		double strokeWidth, Effect effect) {
	setGeometry(geometry);
	setEffect(effect);
	setStroke(stroke);
	setStrokeWidth(strokeWidth);
}
 
Example #13
Source File: AbstractGeometricElement.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
public AbstractGeometricElement(G geometry, AffineTransform transform,
		Paint stroke, double strokeWidth, Effect effect) {
	this(geometry);
	setTransform(transform);
	setEffect(effect);
	setStroke(stroke);
	setStrokeWidth(strokeWidth);
}
 
Example #14
Source File: DigitalClock.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Digit(Color onColor, Color offColor, Effect onEffect, Effect offEffect) {
    this.onColor = onColor;
    this.offColor = offColor;
    this.onEffect = onEffect;
    this.offEffect = offEffect;
    getChildren().addAll(polygons);
    getTransforms().add(new Shear(-0.1,0));
    showNumber(0);
}
 
Example #15
Source File: DigitalClock.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public Digit(Color onColor, Color offColor, Effect onEffect, Effect offEffect) {
    this.onColor = onColor;
    this.offColor = offColor;
    this.onEffect = onEffect;
    this.offEffect = offEffect;
    getChildren().addAll(polygons);
    getTransforms().add(new Shear(-0.1,0));
    showNumber(0);
}
 
Example #16
Source File: DigitalClock.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public Digit(Color onColor, Color offColor, Effect onEffect, Effect offEffect) {
    this.onColor = onColor;
    this.offColor = offColor;
    this.onEffect = onEffect;
    this.offEffect = offEffect;
    getChildren().addAll(polygons);
    getTransforms().add(new Shear(-0.1,0));
    showNumber(0);
}
 
Example #17
Source File: AbstractGeometricElement.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
public Effect getEffect() {
	return effect;
}
 
Example #18
Source File: AbstractGeometricElement.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
public void setEffect(Effect effect) {
	this.effect = effect;
}
 
Example #19
Source File: GeometricShape.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
public GeometricShape(IShape shape, AffineTransform transform, Color stroke, double strokeWidth, Paint fill,
		Effect effect) {
	super(shape, transform, stroke, strokeWidth, effect);
	setFill(fill);
}
 
Example #20
Source File: GeometricShape.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
public GeometricShape(IShape shape, AffineTransform transform, Paint fill, Effect effect) {
	this(shape, transform, new Color(0, 0, 0, 1), 1.0, fill, effect);
}
 
Example #21
Source File: Sprite.java    From DeskChan with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void applyEffect(Effect effect){
    this.effect = effect;
    sprite.setEffect(null);
    sprite.setEffect(effect);
}
 
Example #22
Source File: FxIconBuilder.java    From FxDock with Apache License 2.0 4 votes vote down vote up
public void setEffect(Effect x)
{
	effect = x;
}
 
Example #23
Source File: BaseModel.java    From CrazyAlpha with GNU General Public License v2.0 4 votes vote down vote up
public void setEffect(Effect effect) {
    this.effect = effect;
}
 
Example #24
Source File: EnvironmentView.java    From narjillos with MIT License 4 votes vote down vote up
private Effect getBlurEffect(double zoomLevel) {
	int blurAmount = Math.min((int) (15 * (zoomLevel - 0.7)), 10);
	return new BoxBlur(blurAmount, blurAmount, 1);
}
 
Example #25
Source File: ThingView.java    From narjillos with MIT License 4 votes vote down vote up
Effect getEffects(double zoomLevel, boolean infraredOn) {
	if (infraredOn)
		return getHaloEffect(zoomLevel * 1.5);

	return getHaloEffect(zoomLevel);
}
 
Example #26
Source File: BaseModel.java    From CrazyAlpha with GNU General Public License v2.0 4 votes vote down vote up
public Effect getEffect() {
    return effect;
}
 
Example #27
Source File: HoverFeedbackPart.java    From gef with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Returns the {@link Effect} that is provided by the
 * <code>Provider&lt;Effect&gt;</code> of this part's first anchorage.
 *
 * @return The {@link Effect} that is provided by the
 *         <code>Provider&lt;Effect&gt;</code> of this part's first
 *         anchorage.
 */
public Effect getHoverFeedbackEffect() {
	DropShadow effect = new DropShadow();
	effect.setRadius(3);
	return effect;
}
 
Example #28
Source File: HoverBehavior.java    From gef with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Returns the {@link Effect} that is applied to {@link IHandlePart}s as a
 * replacement for {@link IFeedbackPart}s which are created for normal
 * parts.
 *
 * @param contextMap
 *            A map with context information that might be needed to
 *            identify the concrete creation context.
 * @return The {@link Effect} that is applied to {@link IHandlePart}s as a
 *         replacement for {@link IFeedbackPart}s which are created for
 *         normal parts.
 */
public Effect getHandleHoverFeedbackEffect(Map<Object, Object> contextMap) {
	DropShadow effect = new DropShadow();
	effect.setRadius(5);
	return effect;
}