< prev index next >

functional/SceneGraphTests/src/test/scenegraph/app/Effects2App.java

Print this page

        

@@ -21,28 +21,39 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  */
 package test.scenegraph.app;
 
+import java.io.IOException;
+import java.net.URL;
 import java.util.ArrayList;
+import java.util.Enumeration;
 import java.util.List;
+import java.util.Timer;
+import java.util.TimerTask;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javafx.animation.RotateTransition;
+import javafx.geometry.Bounds;
 import javafx.scene.Group;
 import javafx.scene.Node;
 import javafx.scene.effect.*;
 import javafx.scene.effect.Light.Distant;
 import javafx.scene.effect.Light.Point;
 import javafx.scene.effect.Light.Spot;
+import javafx.scene.image.Image;
 import javafx.scene.layout.StackPane;
 import javafx.scene.layout.VBox;
 import javafx.scene.paint.Color;
 import javafx.scene.paint.CycleMethod;
 import javafx.scene.paint.LinearGradient;
 import javafx.scene.paint.Stop;
 import javafx.scene.shape.*;
 import javafx.scene.text.Font;
 import javafx.scene.text.FontWeight;
 import javafx.scene.text.Text;
+import javafx.util.Duration;
 import test.javaclient.shared.BasicButtonChooserApp;
 import test.javaclient.shared.PageWithSlots;
 import test.javaclient.shared.TestNode;
 import test.javaclient.shared.Utils;
 

@@ -87,10 +98,40 @@
     //private Factory defaultFactory;
     //private Factory hugeFontFactory;
     private Factory textFactory;
 
     // Blend page -------------------------------------------------------------
+    private class slotTexturedBlendRectangle extends TestNode {
+        private Image image = new Image(
+                getClass().getResourceAsStream(ImagesApp.IMAGE_BASE + "blend_texture.png"));
+
+        @Override
+        public Node drawNode() {
+            Blend blend = new Blend();
+            blend.setTopInput(new ImageInput(image));
+            blend.setMode(BlendMode.SRC_ATOP);
+
+            Polygon p = new Polygon(0, 200, 100, 0, 200, 200);
+            p.setLayoutX(100);
+            p.setLayoutY(100);
+            p.setFill(Color.RED);
+            p.setStroke(Color.ORANGE);
+            p.setStrokeWidth(4.0);
+            p.setStrokeType(StrokeType.OUTSIDE);
+
+
+            //Just need to add effect somewhere in the future, when the polygon is already drawn
+            new Timer().schedule(new TimerTask() {
+                @Override
+                public void run() {
+                  p.setEffect(blend);
+                }
+            }, 500);
+            return p;
+        }
+    }
+
     private class slotBlendRectangleCircle extends TestNode {
 
         Group group;
         BlendMode blendMode;
 

@@ -160,12 +201,13 @@
         }
         @Override
         public Node drawNode() {
             Group group = new Group();
             group.setEffect(new Bloom(threshold));
-            group.getChildren().add(RectangleBuilder.create().x(0).y(0).width(160).height(80).
-                    fill(Color.DARKBLUE).build());
+            Rectangle temp = new Rectangle(0, 0, 160, 80);
+            temp.setFill(Color.DARKBLUE);
+            group.getChildren().add(temp);
             Text text = new Text("Bloom!");
             group.getChildren().add(text);
             text.setX(10);
             text.setY(60);
             text.setFill(Color.YELLOW);

@@ -244,21 +286,25 @@
 
             List<NamedEffect> nes = new ArrayList<NamedEffect>();
             nes.add(new NamedEffect("defaults", new DisplacementMap(mapWaves)));
             nes.add(new NamedEffect("scale",  new DisplacementMap(mapWaves, 0, 0, 1.2f, 2.0f)));
             nes.add(new NamedEffect("offset",  new DisplacementMap(mapWaves, 0.2f, 0.1f, 1.0, 1.0)));
-            nes.add(new NamedEffect("wrap",  DisplacementMapBuilder.create().mapData(mapWaves).
-                    wrap(true).offsetX(0.5f).offsetY(0.3f).build()));
+            DisplacementMap temp = new DisplacementMap(mapWaves);
+            temp.setWrap(true);
+            temp.setOffsetX(0.5f);
+            temp.setOffsetY(0.3f);
+            nes.add(new NamedEffect("wrap",  temp));
             return nes;
         }
         @Override
         public Node drawNode() {
             group = new Group();
             group.setEffect(namedeffect.effect);
             group.getChildren().add(new Rectangle(10,10, 100, 50));
-            group.getChildren().add(RectangleBuilder.create().x(0).y(0).width(120).height(120).
-                    fill(Color.TRANSPARENT).build()); // widener
+            Rectangle temp = new Rectangle(0, 0, 120, 120);
+            temp.setFill(Color.TRANSPARENT);
+            group.getChildren().add(temp); // widener
             Text text = new Text("Waves");
             text.setX(11);
             text.setY(50);
             text.setFill(Color.RED);
             //text.setFont(Font.font("Verdana", 28));

@@ -278,12 +324,13 @@
         @Override
         public Node drawNode() {
             VBox vb = new VBox();
             group = new Group();
             group.setEffect(e);
-            group.getChildren().add(RectangleBuilder.create().x(10).y(10).width(100).height(50).
-                    fill(Color.YELLOW).build());
+            Rectangle temp = new Rectangle(10, 10, 100, 50);
+            temp.setFill(Color.YELLOW);
+            group.getChildren().add(temp);
             Text text = new Text("Text");
             text.setFill(Color.RED);
 //            text.setFont(Font.font("Verdana", 28));
             setFontViaCss(text, 28);
 

@@ -305,11 +352,13 @@
             nes.add(new NamedEffect("colored", new DropShadow(10., Color.GREEN)));
             nes.add(new NamedEffect("height: 40", new DropShadow() {{ setHeight(40);}})); // Have to use double braces to test constructors
             nes.add(new NamedEffect("width: 40", new DropShadow(10., 0., 0., Color.BLACK) {{ setWidth(40);}}));
             nes.add(new NamedEffect("spread: 0.7", new DropShadow(BlurType.THREE_PASS_BOX, Color.BLACK, 10., 0.7, 0., 0.)));
             for (final BlurType bt : BlurType.values()) {
-                nes.add(new NamedEffect("bt:" + bt.name(), DropShadowBuilder.create().blurType(bt).build()));
+                DropShadow temp = new DropShadow();
+                temp.setBlurType(bt);
+                nes.add(new NamedEffect("bt:" + bt.name(), temp));
             }
             nes.add(new NamedEffect("offset: 10, 20", new DropShadow(10., 10, 20, Color.BLACK)));
             return nes;
         }
 

@@ -351,12 +400,13 @@
         public Node drawNode() {
             StackPane st = new StackPane();
             Text tmpTxt = new Text("Background");
             tmpTxt.setFill(Color.RED);
             st.getChildren().add(tmpTxt);
-            st.getChildren().add(RectangleBuilder.create().x(0).y(0).width(40).height(40).
-                    effect(new ColorInput(5, 5, 70, 70, Color.rgb(0, 255, 0, 0.5f))).build());
+            Rectangle temp = new Rectangle(0, 0, 40, 40);
+            temp.setEffect(new ColorInput(5, 5, 70, 70, Color.rgb(0, 255, 0, 0.5f)));
+            st.getChildren().add(temp);
             return st;
         }
 
     }
 

@@ -401,12 +451,13 @@
 //            text.setFont(Font.font("Verdana", 80));
             setFontViaCss(text, 80);
 
             text.setFill(Color.YELLOW);
             group.getChildren().add(text);
-            group.getChildren().add(RectangleBuilder.create().x(10).y(10).width(100).height(40).
-                    fill(Color.LIGHTBLUE).build());
+            Rectangle temp = new Rectangle(10, 10, 100, 40);
+            temp.setFill(Color.LIGHTBLUE);
+            group.getChildren().add(temp);
 
             vb.getChildren().add(group);
             return vb;
         }
 

@@ -418,19 +469,35 @@
         slotInnerShadow(final NamedEffect _namedeffect) {
             super(_namedeffect.effect);
         }
         List<NamedEffect> getNamedEffectList() {
             List<NamedEffect> nes = new ArrayList<NamedEffect>();
-            nes.add(new NamedEffect("colored", InnerShadowBuilder.create().color(Color.GREEN).build()));
-            nes.add(new NamedEffect("height: 40", InnerShadowBuilder.create().height(40).build()));
-            nes.add(new NamedEffect("width: 40", InnerShadowBuilder.create().width(40).build()));
-            nes.add(new NamedEffect("radius: 40", InnerShadowBuilder.create().radius(40).build()));
+            InnerShadow temp;
+            temp = new InnerShadow();
+            temp.setColor(Color.GREEN);
+            nes.add(new NamedEffect("colored", temp));
+            temp = new InnerShadow();
+            temp.setHeight(40);
+            nes.add(new NamedEffect("height: 40", temp));
+            temp = new InnerShadow();
+            temp.setWidth(40);
+            nes.add(new NamedEffect("width: 40", temp));
+            temp = new InnerShadow();
+            temp.setRadius(40);
+            nes.add(new NamedEffect("radius: 40", temp));
             for (final BlurType bt : BlurType.values()) {
-                nes.add(new NamedEffect("bt:" + bt.name(), InnerShadowBuilder.create().blurType(bt).build()));
-            }
-            nes.add(new NamedEffect("choke: 0.7", InnerShadowBuilder.create().choke(0.7f).build()));
-            nes.add(new NamedEffect("offset: 10, 20", InnerShadowBuilder.create().offsetX(10).offsetY(20).build()));
+                temp = new InnerShadow();
+                temp.setBlurType(bt);
+                nes.add(new NamedEffect("bt:" + bt.name(), temp));
+            }
+            temp = new InnerShadow();
+            temp.setChoke(0.7f);
+            nes.add(new NamedEffect("choke: 0.7", temp));
+            temp = new InnerShadow();
+            temp.setOffsetX(10);
+            temp.setOffsetY(20);
+            nes.add(new NamedEffect("offset: 10, 20", temp));
             return nes;
         }
 
     }
     private class slotLightningShadow extends slotWithHugeTextNode {

@@ -440,26 +507,51 @@
         slotLightningShadow(final NamedEffect _namedeffect) {
             super(_namedeffect.effect);
         }
         List<NamedEffect> getNamedEffectList() {
             List<NamedEffect> nes = new ArrayList<NamedEffect>();
-            nes.add(new NamedEffect("default", new Lighting()));
-            nes.add(new NamedEffect("distant light", LightingBuilder.create().light(new Distant()
-            {{ setAzimuth(90f); setElevation(50);}}).build()));
-            nes.add(new NamedEffect("point light", LightingBuilder.create().light(new Point(
-                    70, 120, 10, Color.WHITE)).build()));
-            nes.add(new NamedEffect("spot light", LightingBuilder.create().light(new Spot() {{
-                    setX(70);setY(120);setZ(50);
-                    setPointsAtX(150);setPointsAtY(0);setPointsAtZ(0);
-                }}).build()));
-
-            nes.add(new NamedEffect("diffuse: 0.5", LightingBuilder.create().diffuseConstant(0.5f).build()));
-            nes.add(new NamedEffect("specularC: 1.5", LightingBuilder.create().specularConstant(1.5f).build()));
-            nes.add(new NamedEffect("specularExp: 35", LightingBuilder.create().specularExponent(35f).build()));
-            nes.add(new NamedEffect("scale: 7", LightingBuilder.create().surfaceScale(7f).build()));
-            nes.add(new NamedEffect("bump input", LightingBuilder.create().bumpInput(new DropShadow()).build()));
-            nes.add(new NamedEffect("content input", LightingBuilder.create().contentInput(new DropShadow()).build()));
+            Lighting temp = new Lighting();
+            nes.add(new NamedEffect("default", temp));
+            temp = new Lighting();
+            Light.Distant td = new Light.Distant();
+            td.setAzimuth(90f);
+            td.setElevation(50);
+            temp.setLight(td);
+            nes.add(new NamedEffect("distant light", temp));
+            temp = new Lighting();
+            Light.Point tp = new Light.Point(70, 120, 10, Color.WHITE);
+            temp.setLight(tp);
+            nes.add(new NamedEffect("point light", temp));
+            temp = new Lighting();
+            Light.Spot ts = new Light.Spot();
+            ts.setX(70);
+            ts.setY(120);
+            ts.setZ(50);
+            ts.setPointsAtX(150);
+            ts.setPointsAtY(0);
+            ts.setPointsAtZ(0);
+            temp.setLight(ts);
+            nes.add(new NamedEffect("spot light", temp));
+
+            temp = new Lighting();
+            temp.setDiffuseConstant(0.5f);
+            nes.add(new NamedEffect("diffuse: 0.5", temp));
+            temp = new Lighting();
+            temp.setSpecularConstant(1.5f);
+            nes.add(new NamedEffect("specularC: 1.5", temp));
+            temp = new Lighting();
+            temp.setSpecularExponent(35f);
+            nes.add(new NamedEffect("specularExp: 35", temp));
+            temp = new Lighting();
+            temp.setSurfaceScale(7f);
+            nes.add(new NamedEffect("scale: 7", temp));
+            temp = new Lighting();
+            temp.setBumpInput(new DropShadow());
+            nes.add(new NamedEffect("bump input", temp));
+            temp = new Lighting();
+            temp.setContentInput(new DropShadow());
+            nes.add(new NamedEffect("content input", temp));
 
             return nes;
         }
 
     }

@@ -495,15 +587,24 @@
         slotReflection(final NamedEffect _namedeffect) {
             super(_namedeffect.effect);
         }
         List<NamedEffect> getNamedEffectList() {
             List<NamedEffect> nes = new ArrayList<NamedEffect>();
-            nes.add(new NamedEffect("default", new Reflection() ));
-            nes.add(new NamedEffect("bottom opacity 0.7", ReflectionBuilder.create().bottomOpacity(.7f).build()));
-            nes.add(new NamedEffect("fraction: 0.5", ReflectionBuilder.create().fraction(0.5f).build()));
-            nes.add(new NamedEffect("top offset: 15", ReflectionBuilder.create().topOffset(15).build()));
-            nes.add(new NamedEffect("top opacity: 0.9", ReflectionBuilder.create().topOpacity(.9f).build()));
+            Reflection temp = new Reflection();
+            nes.add(new NamedEffect("default", temp));
+            temp = new Reflection();
+            temp.setBottomOpacity(.7f);
+            nes.add(new NamedEffect("bottom opacity 0.7", temp));
+            temp = new Reflection();
+            temp.setFraction(0.5f);
+            nes.add(new NamedEffect("fraction: 0.5", temp));
+            temp = new Reflection();
+            temp.setTopOffset(15);
+            nes.add(new NamedEffect("top offset: 15", temp));
+            temp = new Reflection();
+            temp.setTopOpacity(.9f);
+            nes.add(new NamedEffect("top opacity: 0.9", temp));
 
             return nes;
         }
 
     }

@@ -514,16 +615,26 @@
         slotShadow(final NamedEffect _namedeffect) {
             super(_namedeffect.effect);
         }
         List<NamedEffect> getNamedEffectList() {
             List<NamedEffect> nes = new ArrayList<NamedEffect>();
-            nes.add(new NamedEffect("colored", ShadowBuilder.create().color(Color.GREEN).build()));
-            nes.add(new NamedEffect("height: 40", ShadowBuilder.create().height(40).build()));
-            nes.add(new NamedEffect("width: 40", ShadowBuilder.create().width(40).build()));
-            nes.add(new NamedEffect("radius: 40", ShadowBuilder.create().radius(40).build()));
+            Shadow temp = new Shadow();
+            temp.setColor(Color.GREEN);
+            nes.add(new NamedEffect("colored", temp));
+            temp = new Shadow();
+            temp.setHeight(40);
+            nes.add(new NamedEffect("height: 40", temp));
+            temp = new Shadow();
+            temp.setWidth(40);
+            nes.add(new NamedEffect("width: 40", temp));
+            temp = new Shadow();
+            temp.setRadius(40);
+            nes.add(new NamedEffect("radius: 40", temp));
             for (final BlurType bt : BlurType.values()) {
-                nes.add(new NamedEffect("bt:" + bt.name(), ShadowBuilder.create().blurType(bt).build()));
+                temp = new Shadow();
+                temp.setBlurType(bt);
+                nes.add(new NamedEffect("bt:" + bt.name(), temp));
             }
 
             return nes;
         }
 

@@ -545,11 +656,11 @@
         blendPage.setSlotSize(90, 90);
         for (final BlendMode blendMode : BlendMode.values()) {
             blendPage.add(new slotBlendRectangleCircle(blendMode), blendMode.name());
         }
         blendPage.add(new slotBlend2(),"Grad_SrcOut");
-
+        blendPage.add(new slotTexturedBlendRectangle(), "Textured");
         // ======== BLOOM =================
         final PageWithSlots bloomPage = new PageWithSlots(Pages.Bloom.name(), heightPageContentPane, widthPageContentPane);
         bloomPage.setSlotSize(160, 160);
         for (final Float threshold : new Float[] {0f, 0.3f, 0.7f, 1f}) {
             bloomPage.add(new slotBloom(threshold), "Threshold " + threshold);

@@ -560,12 +671,11 @@
         blurPage.setSlotSize(110, 110);
 
         for (final int iterations : new int[]{1, 3}) {
             for (final int _width : new int[]{1, 10, 20}) {
                 for (final int _height : new int[]{1, 10, 20}) {
-                    final Node node = textFactory.create(BoxBlurBuilder.create().width(_width).
-                            height(_height).iterations(iterations).build());
+                    final Node node = textFactory.create(new BoxBlur(_width, _height, iterations));
                     blurPage.add(new slotBlur(node),"W:" + _width + " H:" + _height + " I:" + iterations);
                 }
             }
         }
 

@@ -606,11 +716,11 @@
 
         // ======== Glow =================
         final PageWithSlots glowPage = new PageWithSlots(Pages.Glow.name(), heightPageContentPane, widthPageContentPane);
         glowPage.setSlotSize(160, 160);
         for (final Float level : new Float[] {0f, 0.3f, 0.7f, 1f}) {
-            Glow gl = GlowBuilder.create().level(level).build();
+            Glow gl = new Glow(level);
             glowPage.add(new slotWithTextNode(gl),"Level_" + level);
         }
 
         // ======== INNER SHADOW =================
         final PageWithSlots innershadowPage = new PageWithSlots(Pages.InnerShadow.name(), heightPageContentPane, widthPageContentPane);

@@ -629,12 +739,11 @@
         // ======== MotionBlur =================
         final PageWithSlots motionBlurPage = new PageWithSlots(Pages.MotionBlur.name(), heightPageContentPane, widthPageContentPane);
         motionBlurPage.setSlotSize(120, 120);
         for (final int radius : new int[] {0, 10, 20}) {
             for (final int angle : new int[] {0, 45, 160, 315}) {
-                motionBlurPage.add(new slotWithTextNode(MotionBlurBuilder.create().angle(angle).
-                        radius(radius).build()), "Angle_" + angle + "_Radius_" + radius);
+                motionBlurPage.add(new slotWithTextNode(new MotionBlur(angle, radius)), "Angle_" + angle + "_Radius_" + radius);
             }
         }
 
         // ======== PerspectiveTransform =================
         final PageWithSlots perspectiveTransformPage = new PageWithSlots(Pages.Transform.name(), heightPageContentPane, widthPageContentPane);
< prev index next >