Animation_Intro1.htm
 
Reference : http://www.developer.com/java/data/doing-animation-in-javafx.html

Animation Classes:

  • Animation: Is accomplished with "javafx.animation package" and "Duration in  javafx.util package" .
  • Duration Class
  • Animation Class
    • TimeLine
    • Transition
      • ParallelTransition
      • SequentialTransition
      • FadeTransition
      • PauseTransition
      • RotateTransition
      • StrokeTransition
      • PathTransition
      • ScaleTransition
      • TranslateTransition
      • FadeTransition

 

 
  • Path
    • Path : Methods
      • beginPath()
      • lineTo(double x1, double y1)
      • moveTo(double x0, double y0)
      • quadraticCurveTo(double xc, double yc, double x1, double y1)
      • appendSVGPath(String svgpath)
        arc(double centerX, double centerY, double radiusX, double radiusY,
        double startAngle, double length)
      • arcTo(double x1, double y1, double x2, double y2, double radius)
      • bezierCurveTo(double xc1, double yc1, double xc2, double yc2, double x1, double y1)
      • closePath()
      • stroke()
      • fill()
    • Uses
      Path path = new Path();
      path.getElements().add (new MoveTo (0f, 50f));
      path.setStroke(Color.WHITE);
      path.setStrokeWidth(4);
  • Shapes: javafx.scene.shape :: Path
    • Arc
    • Polygon
    • Line : (startX, startY, endX, endY)

      path.getElements().add(new LineTo(100.0f, 100.0f));
       
    • SVGPath
    • CubicCurve
      path.getElements().add (new CubicCurveTo (40f, 10f, 390f, 240f, 400, 50f));
    • Path
    • Circle
    • Ellipse
    • QuadCurve
    • Rectangle
    • Polyline
    • Text
  • Animation :page 917  Learn JavaFx
    • TimeLine
    • KeyFrame
    • KeyValue
    • Interpolator

 

  • SubClasses:
    • FadeTransition,
    • FillTransition,
    •  ParallelTransition,
    • PathTransition,
    • PauseTransition,
    • RotateTransition,
    • ScaleTransition,
    •  SequentialTransition,
    •  StrokeTransition,
    •  TranslateTransition
Controlling animation:
  • play() : plays an animation from its current position, or resumed position. This method is asynchronous, may have delay in starting or resuming aply.
  • playFrom(Duration time)
     playFrom(String cuePoint)
    playFromStart()
  • Looping Animation:
    • timelineobjectTimeline1.setCycleCount(Timeline.INDEFINITE); // Run the animation forever
       
    • RotateTransition : duration, node, axix, fromAngle, toAngle, byAngle
      RotateTransition spin = new RotateTransition();
      spin.setNode(cubic1);
      spin.setFromAngle(0);
      spin.setToAngle(-360);// anti-clock spin
      spin.setInterpolator(Interpolator.LINEAR);
      spin.setCycleCount(Timeline.INDEFINITE);
      spin.setDuration(new Duration(5000));
      //
      RotateTransition anim = new RotateTransition();
      anim.setNode(cubic2);
      anim.setFromAngle(0);
      anim.setToAngle(360);// clock spin
      anim.setInterpolator(Interpolator.LINEAR);
      anim.setCycleCount(Timeline.INDEFINITE);
      anim.setDuration(new Duration(5000));
       
    • Compare PathTransition with RotateTransition
      RotateTransition spin = new RotateTransition();
      spin.setNode(cubic1);
      spin.setFromAngle(0);
      spin.setToAngle(-360);// anti-clock spin
      spin.setRate(2.0);
      spin.setInterpolator(Interpolator.LINEAR);
      spin.setCycleCount(Timeline.INDEFINITE);
      spin.setDuration(new Duration(5000));
      spin.setAutoReverse(true);
      //
      PathTransition anim = new PathTransition();
      anim.setNode(circle1);
      //anim.setFromAngle(0);
      //anim.setToAngle(360);// clock spin
      anim.setPath(track);
      anim.setInterpolator(Interpolator.LINEAR);
      anim.setCycleCount(Timeline.INDEFINITE);
      anim.setDuration(new Duration(5000));
      anim.setAutoReverse(false);
  • Stopping animation: timelineobject.stop();
  • Pausing animation: timelineobject.pause();
  • State Of Animation:
    • Running
    • Paused
    • Stopped

    use : Animation.Status status = timeline.getStatus();

Path Class using Shapes:

MoveTo
LineTo
HLineTo
VLineTo
ArcTo
QuadCurveTo
CubicCurveTo

 

ArcTo
  • new ArcTo(20, 10, 0, 0,0,false,false),
  • new ArcTo(20, 5, 0, 0,0,false,false)
  • new ArcTo(20,100, 0, 0,0,false,false),
  • new ArcTo(20,100, 10, 0,0,false,false), top-bulge
  • new ArcTo(20,10, 50, 0,0,false,false),

     
  • new ArcTo(20,10, 50, 50,0,false,false

  • Letter P
    new VLineTo(-50), new HLineTo(100), new VLineTo(50),new HLineTo(10),
     
  • VLineTo HLIneTo
    • U shaped Track/path
      new MoveTo(0, 0), //
      new HLineTo(150),new VLineTo(0),
    • With ClosePath ::/NO ClosePath(),
    • Rectangular Track/path
    • Square Track/Path