转自: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相关推荐

  1. iOS/iPhoneOS Equalizer with libsox - doing some effects

    原文地址:http://uberblo.gs/2011/04/iosiphoneos-equalizer-with-libsox-doing-effects Today i will show you ...

  2. react动画库_React 2020动画库

    react动画库 Animations are important in instances like page transitions, scroll events, entering and ex ...

  3. audacity_如何在Audacity中快速编辑多个文件

    audacity Got a bunch of files that need to be edited the same way? You can automate the process to s ...

  4. serlvert jsp mysql_JAVA基础:Java多语言编码问题解析(2)

    这里是一个具体的例子: 现在因为浏览器对UTF-8的支持,我们可以通过在源文件.请求.响应中都使用unicode编码方式,来轻松达到处理国际化和字符编码问题的目标. 以我们使用的tomcat4.1.2 ...

  5. Kendo UI开发教程(8): Kendo UI 特效概述

    Kendo UI Fx 提供了一个丰富,可扩展,性能经过优化的工具集合用来完成HTML元素的过渡显示.每种特效近可能的使用CSS Transition ,对于一些老版本浏览器使用修改属性的方法作为补充 ...

  6. Struts原理与实践(5)

    Struts原理与实践(5) 作者:罗会波 发文时间:2004.09.24 一个支持i18n的应用程序应该有如下一些特征: 1增加支持的语言时要求不更改程序代码 2字符元素.消息.和图象保存在原代码之 ...

  7. 设置utf8编码问题

    注意:乱码和request的具体实现类有关,现在已经查到的是RequestDispatcher.forward调用前使用的是org.apache.catalina.connector.RequestF ...

  8. Cool!15个超炫的 CSS3 文本特效【上篇】

    每一个网页设计师都希望创建出让用户能够赏识的网站.当然,这是不可能满足每个人的口味的.幸运的是,我们有最强大的工具和资源.实际上,我们非常多的网站模板,框架,内容管理系统,先进的工具和其他的资源可以使 ...

  9. 2017年Spring发布了30个新的Android库,值得您关注

    by Michal Bialas 由Michal Bialas 2017年Spring推出的30个最酷的Android库 (The 30 Coolest Android Libraries from ...

  10. struts中文问题,struts国际化问题的终极解决方案

    Java本身就支持多国语言编码,不需要写任何程序,可以很简单的 实现. 秘诀就是两点: 1.所有HTML/JSP页面全部采用UTF-8编码 2.客户端浏览器完全支持UTF-8编码 步骤: 1.首先把所 ...

最新文章

  1. python解压到指定文件夹_Python:将文件解压缩到当前工作目录,但不保存zip中的目录结构...
  2. 微信小程序学习笔记(4)--------框架之逻辑层
  3. Asp.Net中几种相似数据绑定标记符号的解释及用法
  4. oracle中如何插入
  5. [转]常用数字处理算法的Verilog实现
  6. N-甲基-N-亚硝基脲(MNU)与眼睛健康(思考中)
  7. UVA - 572 Oil Deposits
  8. Spring 的 IOC原理
  9. 驳文不看文,实在可怕
  10. S3C2440PWM 定时器
  11. 7 位 CEO 创业自述:你熬过人生中最黑暗时刻的经历,是你成为强者的必然选择...
  12. 若依框架登录去除验证码
  13. html图片做成菱形,CSS秘密花园:菱形图片
  14. codeforces 1526B I Hate 1111
  15. 零基础搭建基于知识图谱的电影问答系统
  16. html手机qq登陆验证码,为什么qq登陆需要验证码?qq登陆需要验证码怎么取消?...
  17. C#实现PDF转PNG图片
  18. psm进销存管理系统、供应商管理、进货管理、销售管理、仓库管理、采购记录、库存盘点、调拨单、出库单、借入单、进货报表、采购记录、销售往来账、采购往来账、图表分析、人事管理、销售报表、财务报表、rp原型
  19. python——正则表达式(re模块)详解
  20. 文本深度表示模型——word2vecdoc2vec词向量模型(转)

热门文章

  1. springcloud -netflix学习总结
  2. 华三模拟器(防火墙)实现IPSEC穿越NAT实验
  3. ARM-LINUX平台下的文本文件打印机打印
  4. 【年终总结】我的2016,阅读本文大约需要一整年
  5. python + selenium + chrome 如何清理浏览器缓存
  6. 怪兽星座欲并购,运动饮料成为新战场?
  7. windows server 2016 活动目录部署系列(三)加入域且创建域用户
  8. 产品经理的自我修养—认知模式
  9. mongodb mongoose 的使用
  10. iconfont 多色图标使用介绍