9 Creating a Chain of Effects
来源:互联网 发布:淘宝自然排名规则 编辑:程序博客网 时间:2024/04/30 02:18
转自:http://docs.oracle.com/javafx/2/visual_effects/chain.htm#BABGGGHD
Some of the effects have an input property that you can use to create a chain of effects. The chain of effects can be a tree-like structure, because some effects have two inputs and some do not have any.
In Figure 9-1 the reflection effect is used as an input for the drop shadow effect, which means that first the rectangle is reflected by the reflection effect and then the drop shadow effect is applied to the result.
Figure 9-1 Shadow and Reflection
Description of "Figure 9-1 Shadow and Reflection"
Example 9-1 Rectangle with a Shadow and Reflection Sequentially Applied
package visualEffects;import javafx.application.Application;import javafx.collections.ObservableList;import javafx.scene.Group;import javafx.scene.Node;import javafx.scene.Scene;import javafx.scene.effect.DropShadow;import javafx.scene.effect.Reflection;import javafx.scene.paint.Color;import javafx.scene.shape.Rectangle;import javafx.stage.Stage; public class TestChainOfEffects extends Application { Stage stage; Scene scene; @Override public void start(Stage stage) { stage.show(); scene = new Scene(new Group()); ObservableList<Node> content = ((Group)scene.getRoot()).getChildren(); content.add(chainEffects()); stage.setScene(scene); } static Node chainEffects() { Rectangle rect = new Rectangle(); rect.setFill(Color.RED); rect.setWidth(200); rect.setHeight(100); rect.setX(20.0f); rect.setY(20.0f); DropShadow ds = new DropShadow(); ds.setOffsetY(50.0); ds.setOffsetX(50.0); ds.setColor(Color.GRAY); Reflection reflection = new Reflection(); ds.setInput(reflection); rect.setEffect(ds); return rect; } public static void main(String[] args) { Application.launch(args); }}运行结果:
package visualEffects;import javafx.application.Application;import javafx.collections.ObservableList;import javafx.scene.Group;import javafx.scene.Node;import javafx.scene.Scene;import javafx.scene.effect.DropShadow;import javafx.scene.effect.Reflection;import javafx.scene.paint.Color;import javafx.scene.shape.Rectangle;import javafx.stage.Stage; public class TestChainOfEffects extends Application { Stage stage; Scene scene; @Override public void start(Stage stage) { stage.show(); scene = new Scene(new Group()); ObservableList<Node> content = ((Group)scene.getRoot()).getChildren(); content.add(chainEffects()); stage.setScene(scene); } static Node chainEffects() { Rectangle rect = new Rectangle(); rect.setFill(Color.RED); rect.setWidth(200); rect.setHeight(100); rect.setX(20.0f); rect.setY(20.0f); DropShadow ds = new DropShadow(); ds.setOffsetY(50.0); ds.setOffsetX(50.0); ds.setColor(Color.GRAY); Reflection reflection = new Reflection(); reflection.setInput(ds); rect.setEffect(reflection);// ds.setInput(reflection); // rect.setEffect(ds); return rect; } public static void main(String[] args) { Application.launch(args); }}
运行结果:
Note:
If you change the last two lines in the static Node chainEffects()
to reflection.setInput(ds);
and rect.setEffect(reflection);
, first the drop shadow will be applied to the rectangle, and then the result will be reflected by the reflection effect.
For more information about particular classes, methods, or additional features, see the API documentation.
- 9 Creating a Chain of Effects
- Creating Effects
- SQL: A example of creating a procedure
- Effects with the Pixel Bender Toolkit – Part 1: Creating a new filter
- Effects with the Pixel Bender Toolkit – Part 2: Creating a vintage tone filter
- The effects of the TRUNCATE command on a table
- Tomcat Creating a new instance of CacheManager
- How to creating a Component of Joomla
- apache openoffice Creating a table of contents
- Creating a Set of Training Images
- Creating a Customer at the time of creating a Sales Order
- Creating a Customer at the time of creating a Sales Order
- OM:Creating a Customer at the time of creating a Sales Order
- Creating A DLL Of An Application Using wxWidgets
- DPC:Creating a DataBound List of Radio Buttons--PA
- dpc:Creating a DataBound List of Radio Buttons--预览
- Overview of Installing Oracle Database Software and Creating a Database
- The process of creating a socket is as follows
- WINCE 6.0安装顺序说明
- Make the Web Faster
- DLL篇之 dumpbin命令不好使的解决办法.
- WindowsCE目录解析
- windowsCE镜像文件结构
- 9 Creating a Chain of Effects
- 如何搭建软件测试中的W模型?
- WaitForSingleObject()函数,其第一个参数是一个核心对象(如线程)的 handle
- 欲编程 先设计好数据结构
- 串口驱动分析-未完成
- 「田间的精进」的践行者:褚时健——实实在在的人生
- 河南
- 摘录---Windows CE API机制初探
- 最全的JS判断是否为中文的方法