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.io.IOException;
  27 import java.net.URL;
  28 import java.util.ArrayList;
  29 import java.util.Enumeration;
  30 import java.util.List;
  31 import java.util.Timer;
  32 import java.util.TimerTask;
  33 import java.util.logging.Level;
  34 import java.util.logging.Logger;
  35 import javafx.animation.RotateTransition;
  36 import javafx.geometry.Bounds;
  37 import javafx.scene.Group;
  38 import javafx.scene.Node;
  39 import javafx.scene.effect.*;
  40 import javafx.scene.effect.Light.Distant;
  41 import javafx.scene.effect.Light.Point;
  42 import javafx.scene.effect.Light.Spot;
  43 import javafx.scene.image.Image;
  44 import javafx.scene.layout.StackPane;
  45 import javafx.scene.layout.VBox;
  46 import javafx.scene.paint.Color;
  47 import javafx.scene.paint.CycleMethod;
  48 import javafx.scene.paint.LinearGradient;
  49 import javafx.scene.paint.Stop;
  50 import javafx.scene.shape.*;
  51 import javafx.scene.text.Font;
  52 import javafx.scene.text.FontWeight;
  53 import javafx.scene.text.Text;
  54 import javafx.util.Duration;
  55 import test.javaclient.shared.BasicButtonChooserApp;
  56 import test.javaclient.shared.PageWithSlots;
  57 import test.javaclient.shared.TestNode;
  58 import test.javaclient.shared.Utils;
  59 
  60 /**
  61  *
  62  * @author shubov
  63  */
  64 public class Effects2App extends BasicButtonChooserApp {
  65 
  66     public Effects2App() {
  67         super(600, 520, "Effects", false); // "true" stands for "additionalActionButton = "
  68     }
  69 
  70     public Effects2App(int width, int height, String title, boolean showAdditionalActionButton) {
  71         super(width, height, title, showAdditionalActionButton);
  72     }
  73 
  74     public static void main(String args[]) {
  75         Utils.launch(Effects2App.class, args);
  76     }
  77 
  78     public enum Pages {
  79         Blend, Bloom, BoxBlur, Flood, GaussianBlur, Glow, InvertMask,
  80         MotionBlur, SepiaTone, ColorAdjust, Map, DropShadow, InnerShadow,
  81         Lightning, Transform, Reflection, Shadow
  82 
  83     }
  84 
  85     private void setFontViaCss(Text _text, int _size) {
  86             _text.setFont(Font.font("Verdana", _size));
  87 //            _text.setStyle("-fx-font: " + _size+ "pt Verdana;");
  88     }
  89 
  90     @Override
  91     protected void initPredefinedFont() {
  92     }
  93 
  94     private interface Factory {
  95         Node create(final Effect ne);
  96     }
  97 
  98     //private Factory defaultFactory;
  99     //private Factory hugeFontFactory;
 100     private Factory textFactory;
 101 
 102     // Blend page -------------------------------------------------------------
 103     private class slotTexturedBlendRectangle extends TestNode {
 104         private Image image = new Image(
 105                 getClass().getResourceAsStream(ImagesApp.IMAGE_BASE + "blend_texture.png"));
 106 
 107         @Override
 108         public Node drawNode() {
 109             Blend blend = new Blend();
 110             blend.setTopInput(new ImageInput(image));
 111             blend.setMode(BlendMode.SRC_ATOP);
 112 
 113             Polygon p = new Polygon(0, 200, 100, 0, 200, 200);
 114             p.setLayoutX(100);
 115             p.setLayoutY(100);
 116             p.setFill(Color.RED);
 117             p.setStroke(Color.ORANGE);
 118             p.setStrokeWidth(4.0);
 119             p.setStrokeType(StrokeType.OUTSIDE);
 120 
 121 
 122             //Just need to add effect somewhere in the future, when the polygon is already drawn
 123             new Timer().schedule(new TimerTask() {
 124                 @Override
 125                 public void run() {
 126                   p.setEffect(blend);
 127                 }
 128             }, 500);
 129             return p;
 130         }
 131     }
 132 
 133     private class slotBlendRectangleCircle extends TestNode {
 134 
 135         Group group;
 136         BlendMode blendMode;
 137 
 138         slotBlendRectangleCircle(BlendMode _blendMode) {
 139             blendMode = _blendMode;
 140         }
 141 
 142         @Override
 143         public Node drawNode() {
 144             group = new Group();
 145             //group.setBlendMode(blendMode);
 146             group.setBlendMode(BlendMode.SRC_OVER);
 147             if (BlendMode.SRC_OVER != group.getBlendMode()) {
 148                 reportGetterFailure("Group.getBlendMode()");
 149             }
 150             Rectangle r = new Rectangle(20, 20, 60, 60);
 151             r.setFill(Color.rgb(0, 50, 255));
 152             Circle c = new Circle(70, 70, 30);
 153             c.setFill(Color.rgb(255, 150, 0, 0.7));
 154             c.setBlendMode(blendMode);
 155 
 156             group.getChildren().add(r);
 157             group.getChildren().add(c);
 158             return group;
 159         }
 160 
 161     }
 162     private class slotBlend2 extends TestNode {
 163         @Override
 164         public Node drawNode() {
 165             Group group = new Group();
 166             Rectangle rect = new Rectangle(0, 0, 90, 60);
 167             LinearGradient lg = new LinearGradient(
 168                 0, 0, 0.25f, 0.25f, true, CycleMethod.REFLECT,
 169                 new Stop[] { new Stop(0, Color.RED), new Stop(1, Color.YELLOW) }
 170             );
 171             rect.setFill(lg);
 172             group.getChildren().add(rect);
 173             Text text = new Text("XYZ");
 174             text.setX(5);
 175             text.setY(50);
 176             text.setFill(Color.BLUE);
 177             setFontViaCss(text, 40);
 178             //text.setFont(Font.font("Arial", FontWeight.BOLD, 40));
 179 //            text.setEffect(new Blend() {{
 180 //                            //setMode(BlendMode.SRC_OUT); see http://javafx-jira.kenai.com/browse/RT-15041
 181 //                            setTopInput(new ColorInput(5, 5, 80, 80, Color.GREEN) {{
 182 //                                    setPaint(Color.GREEN);
 183 //                                    setX(5);
 184 //                                    setY(5);
 185 //                                    setWidth(80); // TODO (SLOTSIZEX - 10);
 186 //                                    setHeight(80); // (SLOTSIZEY - 10);
 187 //                                }
 188 //                            });
 189 //                        }
 190 //                    });
 191             text.setEffect(new Blend(BlendMode.SRC_OVER, null, new ColorInput(5, 5, 80, 80, Color.GREEN)));
 192             group.getChildren().add(text);
 193             return group;
 194         }
 195 
 196     }
 197     private class slotBloom extends TestNode {
 198         final Float threshold;
 199         slotBloom (final Float _threshold) {
 200             threshold = _threshold;
 201         }
 202         @Override
 203         public Node drawNode() {
 204             Group group = new Group();
 205             group.setEffect(new Bloom(threshold));
 206             Rectangle temp = new Rectangle(0, 0, 160, 80);
 207             temp.setFill(Color.DARKBLUE);
 208             group.getChildren().add(temp);
 209             Text text = new Text("Bloom!");
 210             group.getChildren().add(text);
 211             text.setX(10);
 212             text.setY(60);
 213             text.setFill(Color.YELLOW);
 214             setFontViaCss(text, 36);
 215 
 216             return group;
 217         }
 218 
 219     }
 220     private class slotBlur extends TestNode {
 221         Node node;
 222         slotBlur(Node _node) {
 223             node = _node;
 224         }
 225         @Override
 226         public Node drawNode() {
 227             return node;
 228         }
 229 
 230     }
 231     private class slotColorAdjust extends TestNode {
 232         Group group;
 233         NamedEffect namedeffect = null;
 234         slotColorAdjust() {
 235         }
 236         slotColorAdjust(final NamedEffect _namedeffect) {
 237             namedeffect = _namedeffect;
 238         }
 239         List<NamedEffect> getNamedEffectList() {
 240             List<NamedEffect> nes = new ArrayList<NamedEffect>();
 241             nes.add(new NamedEffect("defaults", new ColorAdjust()));
 242             nes.add(new NamedEffect("brightness 0.7",  new ColorAdjust(0.0, 0.0, 0.7f, 0.0)));
 243             nes.add(new NamedEffect("brightness -0.7", new ColorAdjust(0.0, 0.0, -0.7f, 0.0)));
 244             nes.add(new NamedEffect("contrast 0.5",    new ColorAdjust(0.0, 0.0, 0.0, -0.75f)));
 245             nes.add(new NamedEffect("contrast 3",      new ColorAdjust(0.0, 0.0, 0.0, 0.75f)));
 246             nes.add(new NamedEffect("hue 0.7",         new ColorAdjust(0.7f, 0.0, 0.0, 0.0)));
 247             nes.add(new NamedEffect("hue -0.7",        new ColorAdjust(-0.7f, 0.0, 0.0, 0.0)));
 248             nes.add(new NamedEffect("saturation 0.7",  new ColorAdjust(0.0, 0.7f, 0.0, 0.0)));
 249             nes.add(new NamedEffect("saturation -0.7", new ColorAdjust(0.0, -0.7f, 0.0, 0.0)));
 250             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)));
 251             return nes;
 252         }
 253         @Override
 254         public Node drawNode() {
 255             group = new Group();
 256             group.setEffect(namedeffect.effect);
 257             int angle = 0;
 258             for (final Color color : new Color[] {Color.RED, Color.GREEN, Color.BLUE}) {
 259                 Arc arc = new Arc(40,40,40, 40, 120*angle++, 120);
 260                 arc.setType(ArcType.ROUND);
 261                 arc.setFill(color);
 262                 group.getChildren().add(arc);
 263             }
 264             return group;
 265         }
 266 
 267     }
 268     private class slotDisplacementMap extends TestNode {
 269         Group group;
 270         NamedEffect namedeffect = null;
 271         slotDisplacementMap() {
 272         }
 273         slotDisplacementMap(final NamedEffect _namedeffect) {
 274             namedeffect = _namedeffect;
 275         }
 276         List<NamedEffect> getNamedEffectList() {
 277             final FloatMap mapWaves = new FloatMap();
 278             mapWaves.setWidth(100);
 279             mapWaves.setHeight(80);
 280             for (int i = 0; i < mapWaves.getWidth()-1; i++) {
 281                 float v = (float) ((Math.sin(i / 30f * Math.PI) - 0.5f) / 20f);
 282                 for (int j = 0; j < mapWaves.getHeight()-1; j++) {
 283                     mapWaves.setSamples(i, j, 0f, v);
 284                 }
 285             }
 286 
 287             List<NamedEffect> nes = new ArrayList<NamedEffect>();
 288             nes.add(new NamedEffect("defaults", new DisplacementMap(mapWaves)));
 289             nes.add(new NamedEffect("scale",  new DisplacementMap(mapWaves, 0, 0, 1.2f, 2.0f)));
 290             nes.add(new NamedEffect("offset",  new DisplacementMap(mapWaves, 0.2f, 0.1f, 1.0, 1.0)));
 291             DisplacementMap temp = new DisplacementMap(mapWaves);
 292             temp.setWrap(true);
 293             temp.setOffsetX(0.5f);
 294             temp.setOffsetY(0.3f);
 295             nes.add(new NamedEffect("wrap",  temp));
 296             return nes;
 297         }
 298         @Override
 299         public Node drawNode() {
 300             group = new Group();
 301             group.setEffect(namedeffect.effect);
 302             group.getChildren().add(new Rectangle(10,10, 100, 50));
 303             Rectangle temp = new Rectangle(0, 0, 120, 120);
 304             temp.setFill(Color.TRANSPARENT);
 305             group.getChildren().add(temp); // widener
 306             Text text = new Text("Waves");
 307             text.setX(11);
 308             text.setY(50);
 309             text.setFill(Color.RED);
 310             //text.setFont(Font.font("Verdana", 28));
 311             setFontViaCss(text, 28);
 312 
 313             group.getChildren().add(text);
 314             return group;
 315         }
 316 
 317     }
 318     private class slotWithDefaultDrawNode extends TestNode {
 319         final Effect e;
 320         Group group;
 321         slotWithDefaultDrawNode (final Effect _e) {
 322             e = _e;
 323         }
 324         @Override
 325         public Node drawNode() {
 326             VBox vb = new VBox();
 327             group = new Group();
 328             group.setEffect(e);
 329             Rectangle temp = new Rectangle(10, 10, 100, 50);
 330             temp.setFill(Color.YELLOW);
 331             group.getChildren().add(temp);
 332             Text text = new Text("Text");
 333             text.setFill(Color.RED);
 334 //            text.setFont(Font.font("Verdana", 28));
 335             setFontViaCss(text, 28);
 336 
 337             group.getChildren().add(text);
 338             vb.getChildren().add(group);
 339             return vb;
 340         }
 341 
 342     }
 343     private class slotDropShadow extends slotWithDefaultDrawNode {
 344         slotDropShadow() {
 345             super(null);
 346         }
 347         slotDropShadow(final NamedEffect _namedeffect) {
 348             super(_namedeffect.effect);
 349         }
 350         List<NamedEffect> getNamedEffectList() {
 351             List<NamedEffect> nes = new ArrayList<NamedEffect>();
 352             nes.add(new NamedEffect("colored", new DropShadow(10., Color.GREEN)));
 353             nes.add(new NamedEffect("height: 40", new DropShadow() {{ setHeight(40);}})); // Have to use double braces to test constructors
 354             nes.add(new NamedEffect("width: 40", new DropShadow(10., 0., 0., Color.BLACK) {{ setWidth(40);}}));
 355             nes.add(new NamedEffect("spread: 0.7", new DropShadow(BlurType.THREE_PASS_BOX, Color.BLACK, 10., 0.7, 0., 0.)));
 356             for (final BlurType bt : BlurType.values()) {
 357                 DropShadow temp = new DropShadow();
 358                 temp.setBlurType(bt);
 359                 nes.add(new NamedEffect("bt:" + bt.name(), temp));
 360             }
 361             nes.add(new NamedEffect("offset: 10, 20", new DropShadow(10., 10, 20, Color.BLACK)));
 362             return nes;
 363         }
 364 
 365     }
 366 
 367     private class slotFloodSimplePaint extends TestNode {
 368         @Override
 369         public Node drawNode() {
 370             Rectangle rect = new Rectangle(10, 10, 70, 70);
 371             ColorInput effect = new ColorInput();
 372             effect.setPaint(Color.RED);
 373             effect.setX(15);
 374             effect.setY(15);
 375             effect.setWidth(70);
 376             effect.setHeight(70);
 377             rect.setEffect(effect);
 378             return rect;
 379         }
 380     }
 381     private class slotFloodGradPaint extends TestNode {
 382         @Override
 383         public Node drawNode() {
 384             Rectangle rect = new Rectangle(10, 10, 70, 70);
 385             ColorInput effect = new ColorInput();
 386             effect.setPaint(new LinearGradient(0, 0, 0.5f, 0.1f, true, CycleMethod.REPEAT, new Stop[] {
 387                             new Stop(0, Color.RED),
 388                             new Stop(1, Color.GREEN),
 389                         }));
 390             effect.setX(15);
 391             effect.setY(15);
 392             effect.setWidth(70);
 393             effect.setHeight(70);
 394             rect.setEffect(effect);
 395             return rect;
 396         }
 397     }
 398     private class slotFloodAlphaPaint extends TestNode {
 399         @Override
 400         public Node drawNode() {
 401             StackPane st = new StackPane();
 402             Text tmpTxt = new Text("Background");
 403             tmpTxt.setFill(Color.RED);
 404             st.getChildren().add(tmpTxt);
 405             Rectangle temp = new Rectangle(0, 0, 40, 40);
 406             temp.setEffect(new ColorInput(5, 5, 70, 70, Color.rgb(0, 255, 0, 0.5f)));
 407             st.getChildren().add(temp);
 408             return st;
 409         }
 410 
 411     }
 412 
 413 
 414     private class slotWithTextNode extends TestNode {
 415         final Effect e;
 416         Group group;
 417         slotWithTextNode (final Effect _e) {
 418             e = _e;
 419         }
 420         @Override
 421         public Node drawNode() {
 422             VBox vb = new VBox();
 423             group = new Group();
 424             group.setEffect(e);
 425             Text text = new Text("Text");
 426             text.setX(10);
 427             text.setY(60);
 428 //            text.setFont(Font.font("Verdana", 36));
 429             setFontViaCss(text, 36);
 430 
 431             text.setFill(Color.RED);
 432             group.getChildren().add(text);
 433             vb.getChildren().add(group);
 434             return vb;
 435         }
 436 
 437     }
 438     private class slotWithHugeTextNode extends TestNode {
 439         final Effect e;
 440         Group group;
 441         slotWithHugeTextNode (final Effect _e) {
 442             e = _e;
 443         }
 444         @Override
 445         public Node drawNode() {
 446             VBox vb = new VBox();
 447             group = new Group();
 448             group.setEffect(e);
 449             Text text = new Text("XO");
 450             text.setX(10);
 451 //            text.setFont(Font.font("Verdana", 80));
 452             setFontViaCss(text, 80);
 453 
 454             text.setFill(Color.YELLOW);
 455             group.getChildren().add(text);
 456             Rectangle temp = new Rectangle(10, 10, 100, 40);
 457             temp.setFill(Color.LIGHTBLUE);
 458             group.getChildren().add(temp);
 459 
 460             vb.getChildren().add(group);
 461             return vb;
 462         }
 463 
 464     }
 465     private class slotInnerShadow extends slotWithHugeTextNode {
 466         slotInnerShadow() {
 467             super(null);
 468         }
 469         slotInnerShadow(final NamedEffect _namedeffect) {
 470             super(_namedeffect.effect);
 471         }
 472         List<NamedEffect> getNamedEffectList() {
 473             List<NamedEffect> nes = new ArrayList<NamedEffect>();
 474             InnerShadow temp;
 475             temp = new InnerShadow();
 476             temp.setColor(Color.GREEN);
 477             nes.add(new NamedEffect("colored", temp));
 478             temp = new InnerShadow();
 479             temp.setHeight(40);
 480             nes.add(new NamedEffect("height: 40", temp));
 481             temp = new InnerShadow();
 482             temp.setWidth(40);
 483             nes.add(new NamedEffect("width: 40", temp));
 484             temp = new InnerShadow();
 485             temp.setRadius(40);
 486             nes.add(new NamedEffect("radius: 40", temp));
 487             for (final BlurType bt : BlurType.values()) {
 488                 temp = new InnerShadow();
 489                 temp.setBlurType(bt);
 490                 nes.add(new NamedEffect("bt:" + bt.name(), temp));
 491             }
 492             temp = new InnerShadow();
 493             temp.setChoke(0.7f);
 494             nes.add(new NamedEffect("choke: 0.7", temp));
 495             temp = new InnerShadow();
 496             temp.setOffsetX(10);
 497             temp.setOffsetY(20);
 498             nes.add(new NamedEffect("offset: 10, 20", temp));
 499             return nes;
 500         }
 501 
 502     }
 503     private class slotLightningShadow extends slotWithHugeTextNode {
 504         slotLightningShadow() {
 505             super(null);
 506         }
 507         slotLightningShadow(final NamedEffect _namedeffect) {
 508             super(_namedeffect.effect);
 509         }
 510         List<NamedEffect> getNamedEffectList() {
 511             List<NamedEffect> nes = new ArrayList<NamedEffect>();
 512             Lighting temp = new Lighting();
 513             nes.add(new NamedEffect("default", temp));
 514             temp = new Lighting();
 515             Light.Distant td = new Light.Distant();
 516             td.setAzimuth(90f);
 517             td.setElevation(50);
 518             temp.setLight(td);
 519             nes.add(new NamedEffect("distant light", temp));
 520             temp = new Lighting();
 521             Light.Point tp = new Light.Point(70, 120, 10, Color.WHITE);
 522             temp.setLight(tp);
 523             nes.add(new NamedEffect("point light", temp));
 524             temp = new Lighting();
 525             Light.Spot ts = new Light.Spot();
 526             ts.setX(70);
 527             ts.setY(120);
 528             ts.setZ(50);
 529             ts.setPointsAtX(150);
 530             ts.setPointsAtY(0);
 531             ts.setPointsAtZ(0);
 532             temp.setLight(ts);
 533             nes.add(new NamedEffect("spot light", temp));
 534 
 535             temp = new Lighting();
 536             temp.setDiffuseConstant(0.5f);
 537             nes.add(new NamedEffect("diffuse: 0.5", temp));
 538             temp = new Lighting();
 539             temp.setSpecularConstant(1.5f);
 540             nes.add(new NamedEffect("specularC: 1.5", temp));
 541             temp = new Lighting();
 542             temp.setSpecularExponent(35f);
 543             nes.add(new NamedEffect("specularExp: 35", temp));
 544             temp = new Lighting();
 545             temp.setSurfaceScale(7f);
 546             nes.add(new NamedEffect("scale: 7", temp));
 547             temp = new Lighting();
 548             temp.setBumpInput(new DropShadow());
 549             nes.add(new NamedEffect("bump input", temp));
 550             temp = new Lighting();
 551             temp.setContentInput(new DropShadow());
 552             nes.add(new NamedEffect("content input", temp));
 553 
 554             return nes;
 555         }
 556 
 557     }
 558 
 559     private class slotPerspectiveTransform extends slotWithDefaultDrawNode {
 560         slotPerspectiveTransform() {
 561             super(null);
 562         }
 563         slotPerspectiveTransform(final NamedEffect _namedeffect) {
 564             super(_namedeffect.effect);
 565         }
 566         List<NamedEffect> getNamedEffectList() {
 567             List<NamedEffect> nes = new ArrayList<NamedEffect>();
 568             PerspectiveTransform pt = new PerspectiveTransform();
 569             pt.setUlx(10);
 570             pt.setUly(10);
 571             pt.setUrx(150);
 572             pt.setUry(50);
 573             pt.setLrx(150);
 574             pt.setLry(100);
 575             pt.setLlx(10);
 576             pt.setLly(70);
 577             nes.add(new NamedEffect("perspective", pt));
 578 
 579             return nes;
 580         }
 581 
 582     }
 583     private class slotReflection extends slotWithTextNode {
 584         slotReflection() {
 585             super(null);
 586         }
 587         slotReflection(final NamedEffect _namedeffect) {
 588             super(_namedeffect.effect);
 589         }
 590         List<NamedEffect> getNamedEffectList() {
 591             List<NamedEffect> nes = new ArrayList<NamedEffect>();
 592             Reflection temp = new Reflection();
 593             nes.add(new NamedEffect("default", temp));
 594             temp = new Reflection();
 595             temp.setBottomOpacity(.7f);
 596             nes.add(new NamedEffect("bottom opacity 0.7", temp));
 597             temp = new Reflection();
 598             temp.setFraction(0.5f);
 599             nes.add(new NamedEffect("fraction: 0.5", temp));
 600             temp = new Reflection();
 601             temp.setTopOffset(15);
 602             nes.add(new NamedEffect("top offset: 15", temp));
 603             temp = new Reflection();
 604             temp.setTopOpacity(.9f);
 605             nes.add(new NamedEffect("top opacity: 0.9", temp));
 606 
 607             return nes;
 608         }
 609 
 610     }
 611     private class slotShadow extends slotWithHugeTextNode {
 612         slotShadow() {
 613             super(null);
 614         }
 615         slotShadow(final NamedEffect _namedeffect) {
 616             super(_namedeffect.effect);
 617         }
 618         List<NamedEffect> getNamedEffectList() {
 619             List<NamedEffect> nes = new ArrayList<NamedEffect>();
 620             Shadow temp = new Shadow();
 621             temp.setColor(Color.GREEN);
 622             nes.add(new NamedEffect("colored", temp));
 623             temp = new Shadow();
 624             temp.setHeight(40);
 625             nes.add(new NamedEffect("height: 40", temp));
 626             temp = new Shadow();
 627             temp.setWidth(40);
 628             nes.add(new NamedEffect("width: 40", temp));
 629             temp = new Shadow();
 630             temp.setRadius(40);
 631             nes.add(new NamedEffect("radius: 40", temp));
 632             for (final BlurType bt : BlurType.values()) {
 633                 temp = new Shadow();
 634                 temp.setBlurType(bt);
 635                 nes.add(new NamedEffect("bt:" + bt.name(), temp));
 636             }
 637 
 638             return nes;
 639         }
 640 
 641     }
 642 
 643     public TestNode setup() {
 644         TestNode rootTestNode = new TestNode();
 645 
 646         initFactories();
 647 
 648     // utility classes
 649 
 650 
 651         final int heightPageContentPane = height;
 652         final int widthPageContentPane = width;
 653 
 654         // ======== BLEND =================
 655         final PageWithSlots blendPage = new PageWithSlots(Pages.Blend.name(), heightPageContentPane, widthPageContentPane);
 656         blendPage.setSlotSize(90, 90);
 657         for (final BlendMode blendMode : BlendMode.values()) {
 658             blendPage.add(new slotBlendRectangleCircle(blendMode), blendMode.name());
 659         }
 660         blendPage.add(new slotBlend2(),"Grad_SrcOut");
 661         blendPage.add(new slotTexturedBlendRectangle(), "Textured");
 662         // ======== BLOOM =================
 663         final PageWithSlots bloomPage = new PageWithSlots(Pages.Bloom.name(), heightPageContentPane, widthPageContentPane);
 664         bloomPage.setSlotSize(160, 160);
 665         for (final Float threshold : new Float[] {0f, 0.3f, 0.7f, 1f}) {
 666             bloomPage.add(new slotBloom(threshold), "Threshold " + threshold);
 667         }
 668 
 669         // ======== BOX BLUR =================
 670         final PageWithSlots blurPage = new PageWithSlots(Pages.BoxBlur.name(), heightPageContentPane, widthPageContentPane);
 671         blurPage.setSlotSize(110, 110);
 672 
 673         for (final int iterations : new int[]{1, 3}) {
 674             for (final int _width : new int[]{1, 10, 20}) {
 675                 for (final int _height : new int[]{1, 10, 20}) {
 676                     final Node node = textFactory.create(new BoxBlur(_width, _height, iterations));
 677                     blurPage.add(new slotBlur(node),"W:" + _width + " H:" + _height + " I:" + iterations);
 678                 }
 679             }
 680         }
 681 
 682         // ======== COLOR ADJUST =================
 683         final PageWithSlots cadjPage = new PageWithSlots(Pages.ColorAdjust.name(), heightPageContentPane, widthPageContentPane);
 684         cadjPage.setSlotSize(110, 110);
 685         for (NamedEffect namedEffect : new slotColorAdjust().getNamedEffectList()) {
 686             cadjPage.add(new slotColorAdjust(namedEffect),namedEffect.name);
 687         }
 688 
 689         // ======== DISPLACEMENT MAP =================
 690         final PageWithSlots mapPage = new PageWithSlots(Pages.Map.name(), heightPageContentPane, widthPageContentPane);
 691         mapPage.setSlotSize(120, 120);
 692         for (NamedEffect namedEffect : new slotDisplacementMap().getNamedEffectList()) {
 693             mapPage.add(new slotDisplacementMap(namedEffect),namedEffect.name);
 694         }
 695         // ======== DROP SHADOW =================
 696         final PageWithSlots dropPage = new PageWithSlots(Pages.DropShadow.name(), heightPageContentPane, widthPageContentPane);
 697         dropPage.setSlotSize(125, 125);
 698         for (NamedEffect namedEffect : new slotDropShadow().getNamedEffectList()) {
 699             dropPage.add(new slotDropShadow(namedEffect),namedEffect.name);
 700         }
 701 
 702         // ======== ColorInput (FLOOD) =================
 703         final PageWithSlots floodPage = new PageWithSlots(Pages.Flood.name(), heightPageContentPane, widthPageContentPane);
 704         floodPage.add(new slotFloodSimplePaint(), "Simple_Paint");
 705         floodPage.add(new slotFloodGradPaint(), "Grad_Paint");
 706         floodPage.add(new slotFloodAlphaPaint(), "Alpha_Paint");
 707 
 708         // ======== GaussianBlur =================
 709         final PageWithSlots gauPage = new PageWithSlots(Pages.GaussianBlur.name(), heightPageContentPane, widthPageContentPane);
 710         gauPage.setSlotSize(180, 180);
 711         for (final Float radius : new Float[]{0f, 10f, 30f, 63f}) {
 712             GaussianBlur gb = new GaussianBlur();
 713             gb.setRadius(radius);
 714             gauPage.add(new slotWithDefaultDrawNode(gb),"Threshold_" + radius);
 715         }
 716 
 717         // ======== Glow =================
 718         final PageWithSlots glowPage = new PageWithSlots(Pages.Glow.name(), heightPageContentPane, widthPageContentPane);
 719         glowPage.setSlotSize(160, 160);
 720         for (final Float level : new Float[] {0f, 0.3f, 0.7f, 1f}) {
 721             Glow gl = new Glow(level);
 722             glowPage.add(new slotWithTextNode(gl),"Level_" + level);
 723         }
 724 
 725         // ======== INNER SHADOW =================
 726         final PageWithSlots innershadowPage = new PageWithSlots(Pages.InnerShadow.name(), heightPageContentPane, widthPageContentPane);
 727         innershadowPage.setSlotSize(140, 140);
 728         for (NamedEffect namedEffect : new slotInnerShadow().getNamedEffectList()) {
 729             innershadowPage.add(new slotInnerShadow(namedEffect),namedEffect.name);
 730         }
 731 
 732         // ======== Lightning SHADOW =================
 733         final PageWithSlots lightningPage = new PageWithSlots(Pages.Lightning.name(), heightPageContentPane, widthPageContentPane);
 734         lightningPage.setSlotSize(140, 140);
 735         for (NamedEffect namedEffect : new slotLightningShadow().getNamedEffectList()) {
 736             lightningPage.add(new slotLightningShadow(namedEffect),namedEffect.name);
 737         }
 738 
 739         // ======== MotionBlur =================
 740         final PageWithSlots motionBlurPage = new PageWithSlots(Pages.MotionBlur.name(), heightPageContentPane, widthPageContentPane);
 741         motionBlurPage.setSlotSize(120, 120);
 742         for (final int radius : new int[] {0, 10, 20}) {
 743             for (final int angle : new int[] {0, 45, 160, 315}) {
 744                 motionBlurPage.add(new slotWithTextNode(new MotionBlur(angle, radius)), "Angle_" + angle + "_Radius_" + radius);
 745             }
 746         }
 747 
 748         // ======== PerspectiveTransform =================
 749         final PageWithSlots perspectiveTransformPage = new PageWithSlots(Pages.Transform.name(), heightPageContentPane, widthPageContentPane);
 750         perspectiveTransformPage.setSlotSize(140, 140);
 751         for (NamedEffect namedEffect : new slotPerspectiveTransform().getNamedEffectList()) {
 752             perspectiveTransformPage.add(new slotPerspectiveTransform(namedEffect),namedEffect.name);
 753         }
 754 
 755         // ======== Reflection =================
 756         final PageWithSlots reflectionPage = new PageWithSlots(Pages.Reflection.name(), heightPageContentPane, widthPageContentPane);
 757         reflectionPage.setSlotSize(140, 140);
 758         for (NamedEffect namedEffect : new slotReflection().getNamedEffectList()) {
 759             reflectionPage.add(new slotReflection(namedEffect),namedEffect.name);
 760         }
 761 
 762         // ============= SepiaTone ==================
 763         final PageWithSlots sepiaTonePage = new PageWithSlots(Pages.SepiaTone.name(), heightPageContentPane, widthPageContentPane);
 764         sepiaTonePage.setSlotSize(180, 180);
 765         for (final Float param : new Float[]{0f, 0.1f, 0.5f, 1f}) {
 766             SepiaTone effect = new SepiaTone();
 767             effect.setLevel(param);
 768             sepiaTonePage.add(new slotWithDefaultDrawNode(effect), "level_" + param);
 769         }
 770 
 771         // ======== Shadow =================
 772         final PageWithSlots shadowPage = new PageWithSlots(Pages.Shadow.name(), heightPageContentPane, widthPageContentPane);
 773         shadowPage.setSlotSize(140, 140);
 774         for (NamedEffect namedEffect : new slotShadow().getNamedEffectList()) {
 775             shadowPage.add(new slotShadow(namedEffect),namedEffect.name);
 776         }
 777 
 778 
 779         // ========= root tests list ==============
 780         rootTestNode.add(blendPage);
 781         rootTestNode.add(bloomPage);
 782         rootTestNode.add(blurPage);
 783         rootTestNode.add(cadjPage);
 784         rootTestNode.add(mapPage);
 785         rootTestNode.add(dropPage);
 786         rootTestNode.add(floodPage);
 787         rootTestNode.add(gauPage);
 788         rootTestNode.add(glowPage);
 789         rootTestNode.add(innershadowPage);
 790         rootTestNode.add(lightningPage);
 791         rootTestNode.add(motionBlurPage);
 792         rootTestNode.add(perspectiveTransformPage);
 793         rootTestNode.add(reflectionPage);
 794         rootTestNode.add(sepiaTonePage);
 795         rootTestNode.add(shadowPage);
 796         return rootTestNode;
 797     }
 798 
 799 
 800     private final static class NamedEffect {
 801         final String name;
 802         final Effect effect;
 803 
 804         public NamedEffect(String name, Effect effect) {
 805             this.name = name;
 806             this.effect = effect;
 807         }
 808     }
 809 /*
 810     private void register(final String pageName, final int slotsize, final List<NamedEffect> effects, final Factory factory)
 811     {
 812         PageWithSlots slotpage = new PageWithSlots(pageName, height, width);
 813         slotpage.setSlotSize(slotsize, slotsize);
 814         for (NamedEffect namedEffect : effects) {
 815             slotpage.add(new slotBlur(factory.create(namedEffect.effect)),namedEffect.name);
 816         }
 817     }
 818 */
 819  private void initFactories() {
 820      /*
 821          defaultFactory = new Factory() {
 822 
 823                 public Node create(final Effect e) {
 824                     return new Group() {{
 825                         setEffect(e);
 826                         getChildren().add(new Rectangle(10,10, 100, 50) {{
 827                             setFill(Color.YELLOW);
 828                         }});
 829 
 830                         Text tmpTxt = new Text("Text");
 831                         tmpTxt.setFill(Color.RED);
 832 //                        tmpTxt.setFont(Font.font("Verdana", 28));
 833                         setFontViaCss(tmpTxt, 28);
 834 
 835                         getChildren().add(tmpTxt);
 836                     }};
 837                 }
 838             };
 839 */
 840          textFactory = new Factory() {
 841 
 842                 public Node create(final Effect e) {
 843                     Group group = new Group();
 844                     group.setEffect(e);
 845 
 846                     Text text = new Text("Text");
 847                     text.setX(10);
 848                     text.setY(60);
 849 //                    text.setFont(Font.font("Verdana", 36));
 850                         setFontViaCss(text, 36);
 851                     text.setFill(Color.RED);
 852                     group.getChildren().add(text);
 853 
 854                     return group;
 855                 }
 856             };
 857 /*
 858             hugeFontFactory = new Factory() {
 859 
 860                     public Node create(final Effect e) {
 861                         return new Group() {{
 862                         setEffect(e);
 863                         Text tmpTxt = new Text("XO");
 864                         tmpTxt.setX(10);
 865                         tmpTxt.setFill(Color.YELLOW);
 866                         tmpTxt.setFont(Font.font("Verdana", 80));
 867                         getChildren().add(tmpTxt);
 868 
 869                         getChildren().add(new Rectangle(10,10, 100, 40) {{
 870                                 setFill(Color.LIGHTBLUE);
 871                             }});
 872                         }};
 873                     }
 874                 };
 875  *
 876  */
 877     }
 878 }