Lab
1
Get started now
0.1, 0.1 0.1,0.9 0.9,0.9 0.9, 0.1Here are a few sample .dot files: [circle.dot](circle.dot), [balloon100.dot](balloon100.dot), and [magician.dot](magician.dot). If you'd like to make your own graphic files, you can use the [GraphicFileGenerator.jar](GraphicFileGenerator.jar). The program begins with a file chooser dialog that can be used to select a background image (which you can then trace). Hit cancel if you'd rather just have a black background. To draw, press and hold the mouse down. When you're done, release the mouse. You'll then need to save the points to a file (use the menu). ### Drawing Dots A dot can be drawn on a `Canvas` by first obtaining the `GraphicsContext` and then calling the `fillOval()` method. Be sure to set an appropriate fill color and center the dot over its coordinate location. ### Drawing Lines Lines should be drawn between all neighboring dots, including a line from the last dot back to the first dot. The lines can be drawn on a `Canvas` by first obtaining the `GraphicsContext` and then creating a path. To do this: 1. Call `beginPath()` 1. Move to the location of the first dot by calling `moveTo()` 1. Draw a line to the next dot by calling `lineTo()` 1. Repeat the previous step for all dots 1. Call `closePath()` 1. Call `stroke()` to draw the path ### Exception Handling There are a number of situations that could cause your program to throw an exception. For example, if the file is not found, cannot be opened, or contains incorrectly formatted data, it is likely that an exception will be thrown. In these cases, the program should display an useful message in an `Alert`. ## Just For Fun Ambitious students may wish to: * Try replacing `lineTo()` with `quadraticCurveTo()` or `bezierCurveTo()`. * Add number annotations next to each dot. * Create a print to PDF option. ## Lab Deliverables > See your professor's instructions for details on submission guidelines and due dates. > * Dr. Taylor's students: See below > * All other students should refer to Blackboard > >If you have any questions, consult your instructor. ## Acknowledgment This laboratory assignment was developed by [Dr. Chris Taylor](/taylor/).