TA的每日心情 | 开心 2021-3-12 23:18 |
---|
签到天数: 2 天 [LV.1]初来乍到
|
Main.fx
- package org.jqueen.fx.scene.control;
- import javafx.scene.Scene;
- import javafx.stage.Stage;
- /**
- * @author Leon Chen
- */
- var waitingPaneFX = WaitingPaneFX{
- width : 300
- height : 300
- };
- Stage {
- title: "WaitingPaneFX Sample"
- width: 300
- height: 300
- scene: Scene {
- content: [
- waitingPaneFX
- ]
- }
- }
- waitingPaneFX.play();
- WaitingPaneFX.fx
- package org.jqueen.fx.scene.control;
- import javafx.scene.paint.Color;
- import javafx.scene.shape.Circle;
- import javafx.scene.transform.Rotate;
- import javafx.animation.Timeline;
- import javafx.animation.KeyFrame;
- import javafx.scene.transform.Translate;
- import javafx.scene.shape.Rectangle;
- import javafx.scene.CustomNode;
- import javafx.scene.Group;
- import javafx.scene.Node;
- /**
- * @author Leon Chen
- */
- public class WaitingPaneFX extends CustomNode{
- public-init var width : Number;
- public-init var height : Number;
- public var radius : Number = 15;
- public var leafRadius : Number = 5;
- var group : Group;
- var waitingTimeline = Timeline{
- repeatCount: Timeline.INDEFINITE
- keyFrames : [
- KeyFrame {
- time: 100ms
- action: function() {
- var tmp : Number;
- for(i in [1..8]){
- if(i == 1){
- tmp = group.content[i].opacity
- }
- if(i == 8){
- group.content[i].opacity = tmp
- }else{
- group.content[i].opacity = group.content[i+1].opacity
- }
- }
- }
- }
- ]
- };
- init{
- blocksMouse = true;
- }
- public override function create() : Node{
- group = Group{
- content : [
- Rectangle{
- x: bind layoutX y: bind layoutY
- width: bind width height: bind height
- opacity : 0.0
- },
- for (i in [0..7])
- Circle {
- transforms:[Translate { x : width / 2, y : height / 2 }, Rotate { angle: - 45 * i }]
- centerX: bind radius
- radius: bind leafRadius
- fill: Color.BLACK
- opacity: 1.0 / i
- }
- ]
- }
- return group;
- }
- public function pause(){
- waitingTimeline.pause();
- }
- public function play(){
- waitingTimeline.play();
- }
- public function playFromStart(){
- waitingTimeline.playFromStart();
- }
- public function stop(){
- waitingTimeline.stop();
- }
- }
复制代码
源码下载:http://file.javaxxz.com/2014/10/12/234956906.rar |
|