资源简介
利用javafx绘制动画风扇图,提供pause、reverse、resume按钮
代码片段和文件信息
package experiment8;
import javafx.animation.PathTransition;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;//最后注释掉改成画弧线
import javafx.scene.shape.Circle;
import javafx.stage.Stage;
import javafx.util.Duration;
import javafx.scene.text.Text;
import javafx.scene.shape.Arc;
import javafx.scene.shape.ArcType;
public class experiment8 extends Application{
public void start(Stage primaryStage) {
// TODO Auto-generated method stub
//画风扇
Pane pane = new Pane();
Arc arc1=new Arc(15010080803035);
arc1.setFill(Color.ORANGE);
arc1.setType(ArcType.ROUND);
pane.getChildren().add(arc1);
Arc arc2=new Arc(150100808012035);
arc2.setFill(Color.ORANGE);
arc2.setType(ArcType.ROUND);
pane.getChildren().add(arc2);
Arc arc3=new Arc(150100808021035);
arc3.setFill(Color.ORANGE);
arc3.setType(ArcType.ROUND);
pane.getChildren().add(arc3);
Arc arc4=new Arc(150100808030035);
arc4.setFill(Color.ORANGE);
arc4.setType(ArcType.ROUND);
pane.getChildren().add(arc4);
Circle circle=new Circle(15010090);
circle.setFill(Color.hsb(0 0 1 0));
circle.setStroke(Color.BLACK);
pane.getChildren().add(circle);
Circle circle2=new Circle(1501001);
circle2.setFill(Color.hsb(0 0 1 0));
circle2.setStroke(Color.hsb(0 0 1 0));
pane.getChildren().add(circle2);
//create path transition
PathTransition pt=new PathTransition();
pt.setDuration(Duration.millis(4000));
pt.setPath(circle2);
pt.setNode(pane);
// pt.setNode(arc2);
// pt.setNode(arc3);
// pt.setNode(arc4);
pt.setOrientation(PathTransition.OrientationType.NONE);//设置方向垂直于切线
pt.setCycleCount(Timeline.INDEFINITE);
pt.setAutoReverse(false);
pt.play();
PathTransition pt2=new PathTransition();
pt2.setDuration(Duration.millis(4000));
pt2.setPath(circle2);
pt2.setNode(pane);
// pt.setNode(arc2);
// pt.setNode(arc3);
// pt.setNode(arc4);
pt2.setOrientation(PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT);//设置方向垂直于切线
pt2.setCycleCount(Timeline.INDEFINITE);
pt2.setAutoReverse(false);
pt2.play();
Scene scene =new Scene(pane300200);
primaryStage.settitle(“风扇“);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Application.launch(args);
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 395 2018-04-25 13:03 experiment8\.classpath
文件 387 2018-04-25 13:03 experiment8\.project
文件 592 2018-04-25 13:03 experiment8\.settings\org.eclipse.jdt.core.prefs
文件 3133 2018-05-09 15:08 experiment8\bin\experiment8\experiment8.class
文件 5601 2018-05-09 15:08 experiment8\bin\experiment8\experiment8true.class
文件 2676 2018-04-25 14:09 experiment8\src\experiment8\experiment8.java
文件 3100 2018-04-25 14:49 experiment8\src\experiment8\experiment8true.java
目录 0 2018-05-09 15:08 experiment8\bin\experiment8
目录 0 2018-04-25 14:16 experiment8\src\experiment8
目录 0 2018-04-25 13:03 experiment8\.settings
目录 0 2018-05-09 15:08 experiment8\bin
目录 0 2018-04-25 13:03 experiment8\src
目录 0 2018-04-25 13:03 experiment8
----------- --------- ---------- ----- ----
15884 13
评论
共有 条评论