import javafx.application.Application; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.control.ChoiceBox; import javafx.scene.effect.Blend; import javafx.scene.effect.BlendMode; import javafx.scene.effect.Bloom; import javafx.scene.effect.BoxBlur; import javafx.scene.effect.ColorAdjust; import javafx.scene.effect.ColorInput; import javafx.scene.effect.DropShadow; import javafx.scene.effect.Effect; import javafx.scene.effect.GaussianBlur; import javafx.scene.effect.Glow; import javafx.scene.effect.InnerShadow; import javafx.scene.effect.MotionBlur; import javafx.scene.effect.PerspectiveTransform; import javafx.scene.effect.Reflection; import javafx.scene.effect.SepiaTone; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; import javafx.scene.text.Text; import javafx.stage.Stage; import javafx.util.StringConverter; public class TestEffectDPI extends Application { public static void main(String argv[]) { launch(argv); } Group noeffecttest; Group scalednoeffecttest; Group basictest; Group rotatedtest; Group scaledtest; @Override public void start(Stage stage) { noeffecttest = makeTest(0, 0, 0.0, 1.0); scalednoeffecttest = makeTest(100, 275, 0.0, 3.0); basictest = makeTest(200, 0, 0.0, 1.0); rotatedtest = makeTest(400, 0, 30.0, 1.0); scaledtest = makeTest(450, 275, 0.0, 3.0); final ChoiceBox box = new ChoiceBox(); box.getItems().addAll( new Blend(BlendMode.ADD, null, new ColorInput(20, 20, 120, 120, Color.RED)), new Bloom(0.1), new BoxBlur(0.0, 0.0, 1), new ColorAdjust(0.5, 0.0, 0.0, 0.0), new DropShadow(20, Color.PURPLE), new GaussianBlur(0.0), new Glow(1.0), new InnerShadow(20, Color.PURPLE), new MotionBlur(45, 0.0), new PerspectiveTransform(30, 30, 120, 40, 130, 135, 20, 140), new Reflection(), new SepiaTone()); box.setConverter(new StringConverter() { @Override public String toString(Effect object) { return object.getClass().getSimpleName(); } @Override public Effect fromString(String string) { for (Effect e : box.getItems()) { if (e.getClass().getSimpleName().equals(string)) { return e; } } return null; } }); box.valueProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observable, Effect oldValue, Effect newValue) { setEffect(newValue); } }); box.getSelectionModel().selectFirst(); Group root = new Group(noeffecttest, scalednoeffecttest, basictest, rotatedtest, scaledtest, box); Scene scene = new Scene(root, 800, 600); stage.setScene(scene); stage.setTitle("Effect transform/DPI quality test"); stage.show(); } public void setEffect(Effect e) { basictest.setEffect(e); rotatedtest.setEffect(e); scaledtest.setEffect(e); } public static Group makeTest(double x, double y, double rotate, double scale) { Rectangle r = new Rectangle(30, 30, 100, 100); r.setFill(Color.DARKBLUE); r.setStroke(Color.LIGHTGREEN); Text t = new Text(30, 120, "Effect Test"); t.setFill(Color.WHITE); Group g = new Group(r, t); g.setTranslateX(x); g.setTranslateY(y); g.setScaleX(scale); g.setScaleY(scale); g.setRotate(rotate); return g; } }