1 /*
   2  * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation. Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  */
  24 package test.scenegraph.app;
  25 
  26 import java.util.ArrayList;
  27 import java.util.List;
  28 import javafx.scene.Group;
  29 import javafx.scene.Node;
  30 import javafx.scene.effect.*;
  31 import javafx.scene.effect.Light.Distant;
  32 import javafx.scene.effect.Light.Point;
  33 import javafx.scene.effect.Light.Spot;
  34 import javafx.scene.layout.StackPane;
  35 import javafx.scene.layout.VBox;
  36 import javafx.scene.paint.Color;
  37 import javafx.scene.paint.CycleMethod;
  38 import javafx.scene.paint.LinearGradient;
  39 import javafx.scene.paint.Stop;
  40 import javafx.scene.shape.*;
  41 import javafx.scene.text.Font;
  42 import javafx.scene.text.FontWeight;
  43 import javafx.scene.text.Text;
  44 import test.javaclient.shared.BasicButtonChooserApp;
  45 import test.javaclient.shared.PageWithSlots;
  46 import test.javaclient.shared.TestNode;
  47 import test.javaclient.shared.Utils;
  48 
  49 /**
  50  *
  51  * @author shubov
  52  */
  53 public class Effects2App extends BasicButtonChooserApp {
  54 
  55     public Effects2App() {
  56         super(600, 520, "Effects", false); // "true" stands for "additionalActionButton = "
  57     }
  58 
  59     public Effects2App(int width, int height, String title, boolean showAdditionalActionButton) {
  60         super(width, height, title, showAdditionalActionButton);
  61     }
  62 
  63     public static void main(String args[]) {
  64         Utils.launch(Effects2App.class, args);
  65     }
  66 
  67     public enum Pages {
  68         Blend, Bloom, BoxBlur, Flood, GaussianBlur, Glow, InvertMask,
  69         MotionBlur, SepiaTone, ColorAdjust, Map, DropShadow, InnerShadow,
  70         Lightning, Transform, Reflection, Shadow
  71 
  72     }
  73 
  74     private void setFontViaCss(Text _text, int _size) {
  75             _text.setFont(Font.font("Verdana", _size));
  76 //            _text.setStyle("-fx-font: " + _size+ "pt Verdana;");
  77     }
  78 
  79     @Override
  80     protected void initPredefinedFont() {
  81     }
  82 
  83     private interface Factory {
  84         Node create(final Effect ne);
  85     }
  86 
  87     //private Factory defaultFactory;
  88     //private Factory hugeFontFactory;
  89     private Factory textFactory;
  90 
  91     // Blend page -------------------------------------------------------------
  92     private class slotBlendRectangleCircle extends TestNode {
  93 
  94         Group group;
  95         BlendMode blendMode;
  96 
  97         slotBlendRectangleCircle(BlendMode _blendMode) {
  98             blendMode = _blendMode;
  99         }
 100 
 101         @Override
 102         public Node drawNode() {
 103             group = new Group();
 104             //group.setBlendMode(blendMode);
 105             group.setBlendMode(BlendMode.SRC_OVER);
 106             if (BlendMode.SRC_OVER != group.getBlendMode()) {
 107                 reportGetterFailure("Group.getBlendMode()");
 108             }
 109             Rectangle r = new Rectangle(20, 20, 60, 60);
 110             r.setFill(Color.rgb(0, 50, 255));
 111             Circle c = new Circle(70, 70, 30);
 112             c.setFill(Color.rgb(255, 150, 0, 0.7));
 113             c.setBlendMode(blendMode);
 114 
 115             group.getChildren().add(r);
 116             group.getChildren().add(c);
 117             return group;
 118         }
 119 
 120     }
 121     private class slotBlend2 extends TestNode {
 122         @Override
 123         public Node drawNode() {
 124             Group group = new Group();
 125             Rectangle rect = new Rectangle(0, 0, 90, 60);
 126             LinearGradient lg = new LinearGradient(
 127                 0, 0, 0.25f, 0.25f, true, CycleMethod.REFLECT,
 128                 new Stop[] { new Stop(0, Color.RED), new Stop(1, Color.YELLOW) }
 129             );
 130             rect.setFill(lg);
 131             group.getChildren().add(rect);
 132             Text text = new Text("XYZ");
 133             text.setX(5);
 134             text.setY(50);
 135             text.setFill(Color.BLUE);
 136             setFontViaCss(text, 40);
 137             //text.setFont(Font.font("Arial", FontWeight.BOLD, 40));
 138 //            text.setEffect(new Blend() {{
 139 //                            //setMode(BlendMode.SRC_OUT); see http://javafx-jira.kenai.com/browse/RT-15041
 140 //                            setTopInput(new ColorInput(5, 5, 80, 80, Color.GREEN) {{
 141 //                                    setPaint(Color.GREEN);
 142 //                                    setX(5);
 143 //                                    setY(5);
 144 //                                    setWidth(80); // TODO (SLOTSIZEX - 10);
 145 //                                    setHeight(80); // (SLOTSIZEY - 10);
 146 //                                }
 147 //                            });
 148 //                        }
 149 //                    });
 150             text.setEffect(new Blend(BlendMode.SRC_OVER, null, new ColorInput(5, 5, 80, 80, Color.GREEN)));
 151             group.getChildren().add(text);
 152             return group;
 153         }
 154 
 155     }
 156     private class slotBloom extends TestNode {
 157         final Float threshold;
 158         slotBloom (final Float _threshold) {
 159             threshold = _threshold;
 160         }
 161         @Override
 162         public Node drawNode() {
 163             Group group = new Group();
 164             group.setEffect(new Bloom(threshold));
 165             group.getChildren().add(RectangleBuilder.create().x(0).y(0).width(160).height(80).
 166                     fill(Color.DARKBLUE).build());
 167             Text text = new Text("Bloom!");
 168             group.getChildren().add(text);
 169             text.setX(10);
 170             text.setY(60);
 171             text.setFill(Color.YELLOW);
 172             setFontViaCss(text, 36);
 173 
 174             return group;
 175         }
 176 
 177     }
 178     private class slotBlur extends TestNode {
 179         Node node;
 180         slotBlur(Node _node) {
 181             node = _node;
 182         }
 183         @Override
 184         public Node drawNode() {
 185             return node;
 186         }
 187 
 188     }
 189     private class slotColorAdjust extends TestNode {
 190         Group group;
 191         NamedEffect namedeffect = null;
 192         slotColorAdjust() {
 193         }
 194         slotColorAdjust(final NamedEffect _namedeffect) {
 195             namedeffect = _namedeffect;
 196         }
 197         List<NamedEffect> getNamedEffectList() {
 198             List<NamedEffect> nes = new ArrayList<NamedEffect>();
 199             nes.add(new NamedEffect("defaults", new ColorAdjust()));
 200             nes.add(new NamedEffect("brightness 0.7",  new ColorAdjust(0.0, 0.0, 0.7f, 0.0)));
 201             nes.add(new NamedEffect("brightness -0.7", new ColorAdjust(0.0, 0.0, -0.7f, 0.0)));
 202             nes.add(new NamedEffect("contrast 0.5",    new ColorAdjust(0.0, 0.0, 0.0, -0.75f)));
 203             nes.add(new NamedEffect("contrast 3",      new ColorAdjust(0.0, 0.0, 0.0, 0.75f)));
 204             nes.add(new NamedEffect("hue 0.7",         new ColorAdjust(0.7f, 0.0, 0.0, 0.0)));
 205             nes.add(new NamedEffect("hue -0.7",        new ColorAdjust(-0.7f, 0.0, 0.0, 0.0)));
 206             nes.add(new NamedEffect("saturation 0.7",  new ColorAdjust(0.0, 0.7f, 0.0, 0.0)));
 207             nes.add(new NamedEffect("saturation -0.7", new ColorAdjust(0.0, -0.7f, 0.0, 0.0)));
 208             nes.add(new NamedEffect("B 0.7, C 1.5, H 0.5, S -0.5", new ColorAdjust(0.5f, -0.5f, 0.7f, 1.5f)));
 209             return nes;
 210         }
 211         @Override
 212         public Node drawNode() {
 213             group = new Group();
 214             group.setEffect(namedeffect.effect);
 215             int angle = 0;
 216             for (final Color color : new Color[] {Color.RED, Color.GREEN, Color.BLUE}) {
 217                 Arc arc = new Arc(40,40,40, 40, 120*angle++, 120);
 218                 arc.setType(ArcType.ROUND);
 219                 arc.setFill(color);
 220                 group.getChildren().add(arc);
 221             }
 222             return group;
 223         }
 224 
 225     }
 226     private class slotDisplacementMap extends TestNode {
 227         Group group;
 228         NamedEffect namedeffect = null;
 229         slotDisplacementMap() {
 230         }
 231         slotDisplacementMap(final NamedEffect _namedeffect) {
 232             namedeffect = _namedeffect;
 233         }
 234         List<NamedEffect> getNamedEffectList() {
 235             final FloatMap mapWaves = new FloatMap();
 236             mapWaves.setWidth(100);
 237             mapWaves.setHeight(80);
 238             for (int i = 0; i < mapWaves.getWidth()-1; i++) {
 239                 float v = (float) ((Math.sin(i / 30f * Math.PI) - 0.5f) / 20f);
 240                 for (int j = 0; j < mapWaves.getHeight()-1; j++) {
 241                     mapWaves.setSamples(i, j, 0f, v);
 242                 }
 243             }
 244 
 245             List<NamedEffect> nes = new ArrayList<NamedEffect>();
 246             nes.add(new NamedEffect("defaults", new DisplacementMap(mapWaves)));
 247             nes.add(new NamedEffect("scale",  new DisplacementMap(mapWaves, 0, 0, 1.2f, 2.0f)));
 248             nes.add(new NamedEffect("offset",  new DisplacementMap(mapWaves, 0.2f, 0.1f, 1.0, 1.0)));
 249             nes.add(new NamedEffect("wrap",  DisplacementMapBuilder.create().mapData(mapWaves).
 250                     wrap(true).offsetX(0.5f).offsetY(0.3f).build()));
 251             return nes;
 252         }
 253         @Override
 254         public Node drawNode() {
 255             group = new Group();
 256             group.setEffect(namedeffect.effect);
 257             group.getChildren().add(new Rectangle(10,10, 100, 50));
 258             group.getChildren().add(RectangleBuilder.create().x(0).y(0).width(120).height(120).
 259                     fill(Color.TRANSPARENT).build()); // widener
 260             Text text = new Text("Waves");
 261             text.setX(11);
 262             text.setY(50);
 263             text.setFill(Color.RED);
 264             //text.setFont(Font.font("Verdana", 28));
 265             setFontViaCss(text, 28);
 266 
 267             group.getChildren().add(text);
 268             return group;
 269         }
 270 
 271     }
 272     private class slotWithDefaultDrawNode extends TestNode {
 273         final Effect e;
 274         Group group;
 275         slotWithDefaultDrawNode (final Effect _e) {
 276             e = _e;
 277         }
 278         @Override
 279         public Node drawNode() {
 280             VBox vb = new VBox();
 281             group = new Group();
 282             group.setEffect(e);
 283             group.getChildren().add(RectangleBuilder.create().x(10).y(10).width(100).height(50).
 284                     fill(Color.YELLOW).build());
 285             Text text = new Text("Text");
 286             text.setFill(Color.RED);
 287 //            text.setFont(Font.font("Verdana", 28));
 288             setFontViaCss(text, 28);
 289 
 290             group.getChildren().add(text);
 291             vb.getChildren().add(group);
 292             return vb;
 293         }
 294 
 295     }
 296     private class slotDropShadow extends slotWithDefaultDrawNode {
 297         slotDropShadow() {
 298             super(null);
 299         }
 300         slotDropShadow(final NamedEffect _namedeffect) {
 301             super(_namedeffect.effect);
 302         }
 303         List<NamedEffect> getNamedEffectList() {
 304             List<NamedEffect> nes = new ArrayList<NamedEffect>();
 305             nes.add(new NamedEffect("colored", new DropShadow(10., Color.GREEN)));
 306             nes.add(new NamedEffect("height: 40", new DropShadow() {{ setHeight(40);}})); // Have to use double braces to test constructors
 307             nes.add(new NamedEffect("width: 40", new DropShadow(10., 0., 0., Color.BLACK) {{ setWidth(40);}}));
 308             nes.add(new NamedEffect("spread: 0.7", new DropShadow(BlurType.THREE_PASS_BOX, Color.BLACK, 10., 0.7, 0., 0.)));
 309             for (final BlurType bt : BlurType.values()) {
 310                 nes.add(new NamedEffect("bt:" + bt.name(), DropShadowBuilder.create().blurType(bt).build()));
 311             }
 312             nes.add(new NamedEffect("offset: 10, 20", new DropShadow(10., 10, 20, Color.BLACK)));
 313             return nes;
 314         }
 315 
 316     }
 317 
 318     private class slotFloodSimplePaint extends TestNode {
 319         @Override
 320         public Node drawNode() {
 321             Rectangle rect = new Rectangle(10, 10, 70, 70);
 322             ColorInput effect = new ColorInput();
 323             effect.setPaint(Color.RED);
 324             effect.setX(15);
 325             effect.setY(15);
 326             effect.setWidth(70);
 327             effect.setHeight(70);
 328             rect.setEffect(effect);
 329             return rect;
 330         }
 331     }
 332     private class slotFloodGradPaint extends TestNode {
 333         @Override
 334         public Node drawNode() {
 335             Rectangle rect = new Rectangle(10, 10, 70, 70);
 336             ColorInput effect = new ColorInput();
 337             effect.setPaint(new LinearGradient(0, 0, 0.5f, 0.1f, true, CycleMethod.REPEAT, new Stop[] {
 338                             new Stop(0, Color.RED),
 339                             new Stop(1, Color.GREEN),
 340                         }));
 341             effect.setX(15);
 342             effect.setY(15);
 343             effect.setWidth(70);
 344             effect.setHeight(70);
 345             rect.setEffect(effect);
 346             return rect;
 347         }
 348     }
 349     private class slotFloodAlphaPaint extends TestNode {
 350         @Override
 351         public Node drawNode() {
 352             StackPane st = new StackPane();
 353             Text tmpTxt = new Text("Background");
 354             tmpTxt.setFill(Color.RED);
 355             st.getChildren().add(tmpTxt);
 356             st.getChildren().add(RectangleBuilder.create().x(0).y(0).width(40).height(40).
 357                     effect(new ColorInput(5, 5, 70, 70, Color.rgb(0, 255, 0, 0.5f))).build());
 358             return st;
 359         }
 360 
 361     }
 362 
 363 
 364     private class slotWithTextNode extends TestNode {
 365         final Effect e;
 366         Group group;
 367         slotWithTextNode (final Effect _e) {
 368             e = _e;
 369         }
 370         @Override
 371         public Node drawNode() {
 372             VBox vb = new VBox();
 373             group = new Group();
 374             group.setEffect(e);
 375             Text text = new Text("Text");
 376             text.setX(10);
 377             text.setY(60);
 378 //            text.setFont(Font.font("Verdana", 36));
 379             setFontViaCss(text, 36);
 380 
 381             text.setFill(Color.RED);
 382             group.getChildren().add(text);
 383             vb.getChildren().add(group);
 384             return vb;
 385         }
 386 
 387     }
 388     private class slotWithHugeTextNode extends TestNode {
 389         final Effect e;
 390         Group group;
 391         slotWithHugeTextNode (final Effect _e) {
 392             e = _e;
 393         }
 394         @Override
 395         public Node drawNode() {
 396             VBox vb = new VBox();
 397             group = new Group();
 398             group.setEffect(e);
 399             Text text = new Text("XO");
 400             text.setX(10);
 401 //            text.setFont(Font.font("Verdana", 80));
 402             setFontViaCss(text, 80);
 403 
 404             text.setFill(Color.YELLOW);
 405             group.getChildren().add(text);
 406             group.getChildren().add(RectangleBuilder.create().x(10).y(10).width(100).height(40).
 407                     fill(Color.LIGHTBLUE).build());
 408 
 409             vb.getChildren().add(group);
 410             return vb;
 411         }
 412 
 413     }
 414     private class slotInnerShadow extends slotWithHugeTextNode {
 415         slotInnerShadow() {
 416             super(null);
 417         }
 418         slotInnerShadow(final NamedEffect _namedeffect) {
 419             super(_namedeffect.effect);
 420         }
 421         List<NamedEffect> getNamedEffectList() {
 422             List<NamedEffect> nes = new ArrayList<NamedEffect>();
 423             nes.add(new NamedEffect("colored", InnerShadowBuilder.create().color(Color.GREEN).build()));
 424             nes.add(new NamedEffect("height: 40", InnerShadowBuilder.create().height(40).build()));
 425             nes.add(new NamedEffect("width: 40", InnerShadowBuilder.create().width(40).build()));
 426             nes.add(new NamedEffect("radius: 40", InnerShadowBuilder.create().radius(40).build()));
 427             for (final BlurType bt : BlurType.values()) {
 428                 nes.add(new NamedEffect("bt:" + bt.name(), InnerShadowBuilder.create().blurType(bt).build()));
 429             }
 430             nes.add(new NamedEffect("choke: 0.7", InnerShadowBuilder.create().choke(0.7f).build()));
 431             nes.add(new NamedEffect("offset: 10, 20", InnerShadowBuilder.create().offsetX(10).offsetY(20).build()));
 432             return nes;
 433         }
 434 
 435     }
 436     private class slotLightningShadow extends slotWithHugeTextNode {
 437         slotLightningShadow() {
 438             super(null);
 439         }
 440         slotLightningShadow(final NamedEffect _namedeffect) {
 441             super(_namedeffect.effect);
 442         }
 443         List<NamedEffect> getNamedEffectList() {
 444             List<NamedEffect> nes = new ArrayList<NamedEffect>();
 445             nes.add(new NamedEffect("default", new Lighting()));
 446             nes.add(new NamedEffect("distant light", LightingBuilder.create().light(new Distant()
 447             {{ setAzimuth(90f); setElevation(50);}}).build()));
 448             nes.add(new NamedEffect("point light", LightingBuilder.create().light(new Point(
 449                     70, 120, 10, Color.WHITE)).build()));
 450             nes.add(new NamedEffect("spot light", LightingBuilder.create().light(new Spot() {{
 451                     setX(70);setY(120);setZ(50);
 452                     setPointsAtX(150);setPointsAtY(0);setPointsAtZ(0);
 453                 }}).build()));
 454 
 455             nes.add(new NamedEffect("diffuse: 0.5", LightingBuilder.create().diffuseConstant(0.5f).build()));
 456             nes.add(new NamedEffect("specularC: 1.5", LightingBuilder.create().specularConstant(1.5f).build()));
 457             nes.add(new NamedEffect("specularExp: 35", LightingBuilder.create().specularExponent(35f).build()));
 458             nes.add(new NamedEffect("scale: 7", LightingBuilder.create().surfaceScale(7f).build()));
 459             nes.add(new NamedEffect("bump input", LightingBuilder.create().bumpInput(new DropShadow()).build()));
 460             nes.add(new NamedEffect("content input", LightingBuilder.create().contentInput(new DropShadow()).build()));
 461 
 462             return nes;
 463         }
 464 
 465     }
 466 
 467     private class slotPerspectiveTransform extends slotWithDefaultDrawNode {
 468         slotPerspectiveTransform() {
 469             super(null);
 470         }
 471         slotPerspectiveTransform(final NamedEffect _namedeffect) {
 472             super(_namedeffect.effect);
 473         }
 474         List<NamedEffect> getNamedEffectList() {
 475             List<NamedEffect> nes = new ArrayList<NamedEffect>();
 476             PerspectiveTransform pt = new PerspectiveTransform();
 477             pt.setUlx(10);
 478             pt.setUly(10);
 479             pt.setUrx(150);
 480             pt.setUry(50);
 481             pt.setLrx(150);
 482             pt.setLry(100);
 483             pt.setLlx(10);
 484             pt.setLly(70);
 485             nes.add(new NamedEffect("perspective", pt));
 486 
 487             return nes;
 488         }
 489 
 490     }
 491     private class slotReflection extends slotWithTextNode {
 492         slotReflection() {
 493             super(null);
 494         }
 495         slotReflection(final NamedEffect _namedeffect) {
 496             super(_namedeffect.effect);
 497         }
 498         List<NamedEffect> getNamedEffectList() {
 499             List<NamedEffect> nes = new ArrayList<NamedEffect>();
 500             nes.add(new NamedEffect("default", new Reflection() ));
 501             nes.add(new NamedEffect("bottom opacity 0.7", ReflectionBuilder.create().bottomOpacity(.7f).build()));
 502             nes.add(new NamedEffect("fraction: 0.5", ReflectionBuilder.create().fraction(0.5f).build()));
 503             nes.add(new NamedEffect("top offset: 15", ReflectionBuilder.create().topOffset(15).build()));
 504             nes.add(new NamedEffect("top opacity: 0.9", ReflectionBuilder.create().topOpacity(.9f).build()));
 505 
 506             return nes;
 507         }
 508 
 509     }
 510     private class slotShadow extends slotWithHugeTextNode {
 511         slotShadow() {
 512             super(null);
 513         }
 514         slotShadow(final NamedEffect _namedeffect) {
 515             super(_namedeffect.effect);
 516         }
 517         List<NamedEffect> getNamedEffectList() {
 518             List<NamedEffect> nes = new ArrayList<NamedEffect>();
 519             nes.add(new NamedEffect("colored", ShadowBuilder.create().color(Color.GREEN).build()));
 520             nes.add(new NamedEffect("height: 40", ShadowBuilder.create().height(40).build()));
 521             nes.add(new NamedEffect("width: 40", ShadowBuilder.create().width(40).build()));
 522             nes.add(new NamedEffect("radius: 40", ShadowBuilder.create().radius(40).build()));
 523             for (final BlurType bt : BlurType.values()) {
 524                 nes.add(new NamedEffect("bt:" + bt.name(), ShadowBuilder.create().blurType(bt).build()));
 525             }
 526 
 527             return nes;
 528         }
 529 
 530     }
 531 
 532     public TestNode setup() {
 533         TestNode rootTestNode = new TestNode();
 534 
 535         initFactories();
 536 
 537     // utility classes
 538 
 539 
 540         final int heightPageContentPane = height;
 541         final int widthPageContentPane = width;
 542 
 543         // ======== BLEND =================
 544         final PageWithSlots blendPage = new PageWithSlots(Pages.Blend.name(), heightPageContentPane, widthPageContentPane);
 545         blendPage.setSlotSize(90, 90);
 546         for (final BlendMode blendMode : BlendMode.values()) {
 547             blendPage.add(new slotBlendRectangleCircle(blendMode), blendMode.name());
 548         }
 549         blendPage.add(new slotBlend2(),"Grad_SrcOut");
 550 
 551         // ======== BLOOM =================
 552         final PageWithSlots bloomPage = new PageWithSlots(Pages.Bloom.name(), heightPageContentPane, widthPageContentPane);
 553         bloomPage.setSlotSize(160, 160);
 554         for (final Float threshold : new Float[] {0f, 0.3f, 0.7f, 1f}) {
 555             bloomPage.add(new slotBloom(threshold), "Threshold " + threshold);
 556         }
 557 
 558         // ======== BOX BLUR =================
 559         final PageWithSlots blurPage = new PageWithSlots(Pages.BoxBlur.name(), heightPageContentPane, widthPageContentPane);
 560         blurPage.setSlotSize(110, 110);
 561 
 562         for (final int iterations : new int[]{1, 3}) {
 563             for (final int _width : new int[]{1, 10, 20}) {
 564                 for (final int _height : new int[]{1, 10, 20}) {
 565                     final Node node = textFactory.create(BoxBlurBuilder.create().width(_width).
 566                             height(_height).iterations(iterations).build());
 567                     blurPage.add(new slotBlur(node),"W:" + _width + " H:" + _height + " I:" + iterations);
 568                 }
 569             }
 570         }
 571 
 572         // ======== COLOR ADJUST =================
 573         final PageWithSlots cadjPage = new PageWithSlots(Pages.ColorAdjust.name(), heightPageContentPane, widthPageContentPane);
 574         cadjPage.setSlotSize(110, 110);
 575         for (NamedEffect namedEffect : new slotColorAdjust().getNamedEffectList()) {
 576             cadjPage.add(new slotColorAdjust(namedEffect),namedEffect.name);
 577         }
 578 
 579         // ======== DISPLACEMENT MAP =================
 580         final PageWithSlots mapPage = new PageWithSlots(Pages.Map.name(), heightPageContentPane, widthPageContentPane);
 581         mapPage.setSlotSize(120, 120);
 582         for (NamedEffect namedEffect : new slotDisplacementMap().getNamedEffectList()) {
 583             mapPage.add(new slotDisplacementMap(namedEffect),namedEffect.name);
 584         }
 585         // ======== DROP SHADOW =================
 586         final PageWithSlots dropPage = new PageWithSlots(Pages.DropShadow.name(), heightPageContentPane, widthPageContentPane);
 587         dropPage.setSlotSize(125, 125);
 588         for (NamedEffect namedEffect : new slotDropShadow().getNamedEffectList()) {
 589             dropPage.add(new slotDropShadow(namedEffect),namedEffect.name);
 590         }
 591 
 592         // ======== ColorInput (FLOOD) =================
 593         final PageWithSlots floodPage = new PageWithSlots(Pages.Flood.name(), heightPageContentPane, widthPageContentPane);
 594         floodPage.add(new slotFloodSimplePaint(), "Simple_Paint");
 595         floodPage.add(new slotFloodGradPaint(), "Grad_Paint");
 596         floodPage.add(new slotFloodAlphaPaint(), "Alpha_Paint");
 597 
 598         // ======== GaussianBlur =================
 599         final PageWithSlots gauPage = new PageWithSlots(Pages.GaussianBlur.name(), heightPageContentPane, widthPageContentPane);
 600         gauPage.setSlotSize(180, 180);
 601         for (final Float radius : new Float[]{0f, 10f, 30f, 63f}) {
 602             GaussianBlur gb = new GaussianBlur();
 603             gb.setRadius(radius);
 604             gauPage.add(new slotWithDefaultDrawNode(gb),"Threshold_" + radius);
 605         }
 606 
 607         // ======== Glow =================
 608         final PageWithSlots glowPage = new PageWithSlots(Pages.Glow.name(), heightPageContentPane, widthPageContentPane);
 609         glowPage.setSlotSize(160, 160);
 610         for (final Float level : new Float[] {0f, 0.3f, 0.7f, 1f}) {
 611             Glow gl = GlowBuilder.create().level(level).build();
 612             glowPage.add(new slotWithTextNode(gl),"Level_" + level);
 613         }
 614 
 615         // ======== INNER SHADOW =================
 616         final PageWithSlots innershadowPage = new PageWithSlots(Pages.InnerShadow.name(), heightPageContentPane, widthPageContentPane);
 617         innershadowPage.setSlotSize(140, 140);
 618         for (NamedEffect namedEffect : new slotInnerShadow().getNamedEffectList()) {
 619             innershadowPage.add(new slotInnerShadow(namedEffect),namedEffect.name);
 620         }
 621 
 622         // ======== Lightning SHADOW =================
 623         final PageWithSlots lightningPage = new PageWithSlots(Pages.Lightning.name(), heightPageContentPane, widthPageContentPane);
 624         lightningPage.setSlotSize(140, 140);
 625         for (NamedEffect namedEffect : new slotLightningShadow().getNamedEffectList()) {
 626             lightningPage.add(new slotLightningShadow(namedEffect),namedEffect.name);
 627         }
 628 
 629         // ======== MotionBlur =================
 630         final PageWithSlots motionBlurPage = new PageWithSlots(Pages.MotionBlur.name(), heightPageContentPane, widthPageContentPane);
 631         motionBlurPage.setSlotSize(120, 120);
 632         for (final int radius : new int[] {0, 10, 20}) {
 633             for (final int angle : new int[] {0, 45, 160, 315}) {
 634                 motionBlurPage.add(new slotWithTextNode(MotionBlurBuilder.create().angle(angle).
 635                         radius(radius).build()), "Angle_" + angle + "_Radius_" + radius);
 636             }
 637         }
 638 
 639         // ======== PerspectiveTransform =================
 640         final PageWithSlots perspectiveTransformPage = new PageWithSlots(Pages.Transform.name(), heightPageContentPane, widthPageContentPane);
 641         perspectiveTransformPage.setSlotSize(140, 140);
 642         for (NamedEffect namedEffect : new slotPerspectiveTransform().getNamedEffectList()) {
 643             perspectiveTransformPage.add(new slotPerspectiveTransform(namedEffect),namedEffect.name);
 644         }
 645 
 646         // ======== Reflection =================
 647         final PageWithSlots reflectionPage = new PageWithSlots(Pages.Reflection.name(), heightPageContentPane, widthPageContentPane);
 648         reflectionPage.setSlotSize(140, 140);
 649         for (NamedEffect namedEffect : new slotReflection().getNamedEffectList()) {
 650             reflectionPage.add(new slotReflection(namedEffect),namedEffect.name);
 651         }
 652 
 653         // ============= SepiaTone ==================
 654         final PageWithSlots sepiaTonePage = new PageWithSlots(Pages.SepiaTone.name(), heightPageContentPane, widthPageContentPane);
 655         sepiaTonePage.setSlotSize(180, 180);
 656         for (final Float param : new Float[]{0f, 0.1f, 0.5f, 1f}) {
 657             SepiaTone effect = new SepiaTone();
 658             effect.setLevel(param);
 659             sepiaTonePage.add(new slotWithDefaultDrawNode(effect), "level_" + param);
 660         }
 661 
 662         // ======== Shadow =================
 663         final PageWithSlots shadowPage = new PageWithSlots(Pages.Shadow.name(), heightPageContentPane, widthPageContentPane);
 664         shadowPage.setSlotSize(140, 140);
 665         for (NamedEffect namedEffect : new slotShadow().getNamedEffectList()) {
 666             shadowPage.add(new slotShadow(namedEffect),namedEffect.name);
 667         }
 668 
 669 
 670         // ========= root tests list ==============
 671         rootTestNode.add(blendPage);
 672         rootTestNode.add(bloomPage);
 673         rootTestNode.add(blurPage);
 674         rootTestNode.add(cadjPage);
 675         rootTestNode.add(mapPage);
 676         rootTestNode.add(dropPage);
 677         rootTestNode.add(floodPage);
 678         rootTestNode.add(gauPage);
 679         rootTestNode.add(glowPage);
 680         rootTestNode.add(innershadowPage);
 681         rootTestNode.add(lightningPage);
 682         rootTestNode.add(motionBlurPage);
 683         rootTestNode.add(perspectiveTransformPage);
 684         rootTestNode.add(reflectionPage);
 685         rootTestNode.add(sepiaTonePage);
 686         rootTestNode.add(shadowPage);
 687         return rootTestNode;
 688     }
 689 
 690 
 691     private final static class NamedEffect {
 692         final String name;
 693         final Effect effect;
 694 
 695         public NamedEffect(String name, Effect effect) {
 696             this.name = name;
 697             this.effect = effect;
 698         }
 699     }
 700 /*
 701     private void register(final String pageName, final int slotsize, final List<NamedEffect> effects, final Factory factory)
 702     {
 703         PageWithSlots slotpage = new PageWithSlots(pageName, height, width);
 704         slotpage.setSlotSize(slotsize, slotsize);
 705         for (NamedEffect namedEffect : effects) {
 706             slotpage.add(new slotBlur(factory.create(namedEffect.effect)),namedEffect.name);
 707         }
 708     }
 709 */
 710  private void initFactories() {
 711      /*
 712          defaultFactory = new Factory() {
 713 
 714                 public Node create(final Effect e) {
 715                     return new Group() {{
 716                         setEffect(e);
 717                         getChildren().add(new Rectangle(10,10, 100, 50) {{
 718                             setFill(Color.YELLOW);
 719                         }});
 720 
 721                         Text tmpTxt = new Text("Text");
 722                         tmpTxt.setFill(Color.RED);
 723 //                        tmpTxt.setFont(Font.font("Verdana", 28));
 724                         setFontViaCss(tmpTxt, 28);
 725 
 726                         getChildren().add(tmpTxt);
 727                     }};
 728                 }
 729             };
 730 */
 731          textFactory = new Factory() {
 732 
 733                 public Node create(final Effect e) {
 734                     Group group = new Group();
 735                     group.setEffect(e);
 736 
 737                     Text text = new Text("Text");
 738                     text.setX(10);
 739                     text.setY(60);
 740 //                    text.setFont(Font.font("Verdana", 36));
 741                         setFontViaCss(text, 36);
 742                     text.setFill(Color.RED);
 743                     group.getChildren().add(text);
 744 
 745                     return group;
 746                 }
 747             };
 748 /*
 749             hugeFontFactory = new Factory() {
 750 
 751                     public Node create(final Effect e) {
 752                         return new Group() {{
 753                         setEffect(e);
 754                         Text tmpTxt = new Text("XO");
 755                         tmpTxt.setX(10);
 756                         tmpTxt.setFill(Color.YELLOW);
 757                         tmpTxt.setFont(Font.font("Verdana", 80));
 758                         getChildren().add(tmpTxt);
 759 
 760                         getChildren().add(new Rectangle(10,10, 100, 40) {{
 761                                 setFill(Color.LIGHTBLUE);
 762                             }});
 763                         }};
 764                     }
 765                 };
 766  *
 767  */
 768     }
 769 }