Full Screen Sketching
Full Screen Sketch is an application for free form drawing. User can draw on the canvas by dragging the mouse. Color and stroke width can be selected. The strokes of user is recorded. It can be played back using "Replay" option. User can toggle the application between normal and full screen mode.
Understanding the Code
A new javafx.scene.shape.Path instance is created when user press the mouse. As the user drags the mouse over the canvas, new instance of javafx.scene.shape.LineTo with x and y coordinates of mouse is created and inserted into javafx.scene.shape.Path.elements. When mouse is released the new instance of javafx.scene.shape.MoveTo is added to path and the final path is saved permanently.
Stage can be set to full screen by setting stage.fullScreen to true. For toggle effect we can just assign stage.fullScreen = not stage.fullScreen;
For replay a new empty Path instance is created. In a Timeline a path element from existing path is inserted into this new path every 5ms. Thus user will view the playback of path creation.
Jasper PottsStaff Engineer,
Sun Microsystems