{"id":2555,"date":"2013-12-02T18:35:37","date_gmt":"2013-12-02T16:35:37","guid":{"rendered":"http:\/\/www.tutego.de\/blog\/javainsel\/?p=2555"},"modified":"2013-12-04T23:24:31","modified_gmt":"2013-12-04T21:24:31","slug":"example-for-javafx-cubiccurve-with-animation","status":"publish","type":"post","link":"https:\/\/www.tutego.de\/blog\/javainsel\/2013\/12\/example-for-javafx-cubiccurve-with-animation\/","title":{"rendered":"Example for JavaFX CubicCurve with animation"},"content":{"rendered":"<pre>import javafx.animation.KeyFrame;\nimport javafx.animation.KeyValue;\nimport javafx.animation.Timeline;\nimport javafx.application.Application;\nimport javafx.beans.property.DoubleProperty;\nimport javafx.beans.property.SimpleDoubleProperty;\nimport javafx.scene.Group;\nimport javafx.scene.Scene;\nimport javafx.scene.paint.Color;\nimport javafx.scene.shape.CubicCurve;\nimport javafx.scene.shape.Line;\nimport javafx.stage.Stage;\nimport javafx.util.Duration;\n\npublic class CubicCurveDemo extends Application\n{\n  @Override\n  public void start( Stage stage )\n  {\n    double startX = 200, startY = 200;\n    DoubleProperty controlX1 = new SimpleDoubleProperty( 20 );\n    DoubleProperty controlY1 = new SimpleDoubleProperty( 20 );\n    DoubleProperty controlX2 = new SimpleDoubleProperty( 400 );\n    DoubleProperty controlY2 = new SimpleDoubleProperty( 20 );\n    double endX = 300, endY = 200;\n\n    \/\/ Linie von [controlX1, controlY1] nach [startX, startY]\n    Line line1 = new Line( 0, 0, startX, startY );\n    line1.startXProperty().bind( controlX1 );\n    line1.startYProperty().bind( controlY1 );\n    line1.setStrokeWidth( 2 );\n\n    \/\/ Linie von [controlX2, controlY2] nach [endX, endY]\n    Line line2 = new Line( 0, 0, endX, endY );\n    line2.startXProperty().bind( controlX2 );\n    line2.startYProperty().bind( controlY2 );\n    line2.setStrokeWidth( 2 );\n\n    \/\/ Animierte Kontrollpunkte\n    Timeline timeline = new Timeline( new KeyFrame( Duration.millis( 1000 ),\n                                        new KeyValue( controlX1, 300 ),\n                                        new KeyValue( controlY2, 300 ) ) );\n    timeline.setCycleCount( Timeline.INDEFINITE );\n    timeline.setAutoReverse( true );\n    timeline.play();\n\n    CubicCurve curve = new CubicCurve( startX, startY, 0, 0, 0, 0, endX, endY );\n    curve.controlX1Property().bind( controlX1 );\n    curve.controlY1Property().bind( controlY1 );\n    curve.controlX2Property().bind( controlX2 );\n    curve.controlY2Property().bind( controlY2 );\n    curve.setFill( null );\n    curve.setStroke( Color.BLUEVIOLET );\n    curve.setStrokeWidth( 3 );\n\n    stage.setScene( new Scene( new Group( line1, line2, curve ), 450, 300 ) );\n    stage.show();\n  }\n\n  public static void main( String[] args )\n  {\n    launch( args );\n  }\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>import javafx.animation.KeyFrame; import javafx.animation.KeyValue; import javafx.animation.Timeline; import javafx.application.Application; import javafx.beans.property.DoubleProperty; import javafx.beans.property.SimpleDoubleProperty; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.scene.shape.CubicCurve; import javafx.scene.shape.Line; import javafx.stage.Stage; import javafx.util.Duration; public class CubicCurveDemo extends Application { @Override public void start( Stage stage ) { double startX = 200, startY = 200; DoubleProperty controlX1 = new SimpleDoubleProperty( 20 ); DoubleProperty [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","_links_to":"","_links_to_target":""},"categories":[1],"tags":[],"class_list":["post-2555","post","type-post","status-publish","format-standard","hentry","category-allgemein"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/posts\/2555","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/comments?post=2555"}],"version-history":[{"count":2,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/posts\/2555\/revisions"}],"predecessor-version":[{"id":2561,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/posts\/2555\/revisions\/2561"}],"wp:attachment":[{"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/media?parent=2555"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/categories?post=2555"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tutego.de\/blog\/javainsel\/wp-json\/wp\/v2\/tags?post=2555"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}