1 / 13

Control Circle Project Revisited

Control Circle Project Revisited. Refer to CircleControlWithMouseAndKey Eclipse Project that Adds more control to the CircleControl example Allowing end user to Increase/decrease the circle radius by clicking left/right buttons

loyd
Télécharger la présentation

Control Circle Project Revisited

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Control Circle Project Revisited • Refer to CircleControlWithMouseAndKey • Eclipse Project that • Adds more control to the CircleControl example • Allowing end user to • Increase/decrease the circle radius by clicking left/right buttons • Increase/decrease the circle radius by pressing the U and D keys • getButton() • Detects which mouse button is pressed • MouseButton.PRIMARY, MouseButton.SECONDARY, …

  2. Listeners for Observable Objects • A listener can be added • To process a value change in an observable object • An instance of Observable class • Is known as an observable object that contains the • addListener(InvalidationListener) for adding a listener • The listener must implement • the InvalidationListenerinterface • To override the invalidated(Observable o) method • To handle value change • Once the value in Observable changes • The listener is notified through the invalidated method

  3. Animation Class • JavaFX provides the Animation class • With the core functionality for all animations

  4. Animation Class (Continued) • TheCycleCountproperty • Indicates the number of cycles for the animation • The constant Timeline.INDEFINITEindicates an infinite number • The rate property • Defines the speed of the animation • The status property • Indicates the status of the animation: • Animation.Status.PAUSED • Animation.Status.RUNNING • Animation.Status.STOPPED

  5. PathTransition Class • This class • Animates the moves of a node along a path • From one end to the other over a given time

  6. PathTransition Class (Cont’d) • The Duration class • Defines a duration of time • Constants INDEFINITE, ONE, ZERO are defined • Offers • add, subtract, multiply, and divide methods • To perform arithmetic operations • toHours(), toMinutes(), toSeconds(), and toMillis() • To return number of hours, minutes, seconds, and ms in duration • Defines • PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT

  7. PathTransition Class (Cont’d) • Refer to PathTransitionDemo Eclipse project • It moves a rectangle along the outline of a circle • An animation can be • Started by invoking the play() method • Paused by invoking the pause() method

  8. PathTransition Class (Cont’d) • Refer to FlagRisingApp Eclipse project • It animates a flag rising • ImageView moves along a line • That may or may not be placed in the scene

  9. FadeTransition Class • This class • Animates the changes of the opacity in a node • over a given time

  10. FadeTransition Class (Cont’d) • Refer to FadeTransitionDemo Eclipse project • It applies a fade transition to the filled color in an ellipse • The ellipse’s • centerX, centerY, radiusX, and radiusY properties • Are bound to the pane’s size

  11. Timeline Class • Timeline class • Can be used to program any animation using • One or more KeyFrames • Each KeyFrame • Is executed sequentially at a specified time interval • Can be constructed as follows: • The onFinished handler • Is called when the duration of the key frame is elapsed.

  12. Timeline Class (Continued) • Refer to TimeLineDemo Eclipse project • Displays a flashing text. • The text is on and off alternating to animate flashing • A handler is used • To change the text to empty if it is not empty or • To “programming is fun” if the text is empty • The animation is set to run indefinitely

  13. Timeline Class (Continued) • Refer to BouncingBallApp Eclipse project • Animates a bouncing ball • The mouse-pressed and mouse-released handlers • Are implemented to pause and resume the animation • When the UP arrow key is pressed • The ball’s movement is increased

More Related