Starting from:
$30

$24

Widgets and Event Handling (Java) Jsketch Solution

Synopsis
In this assignment you will implement a vector-drawing program, consisting of a tool palettes and a canvas. Your program will allow a user to select drawing properties, and draw shapes on-screen.

This is a rough mockup that illustrates the features that you will implement, and the basic layout that you must use.


Learning Goals
Construct an interface using toolkit widgets and layouts (Swing/AWT)
Support interaction with a canvas, where users can draw shapes using graphics primitives
Handle hit detection for arbitrary shapes
Requirements
The main area of your drawing program is a canvas that supports drawing shapes. Users can select a shape from the list on the side, specify colour and border thickness, then click and drag the mouse on the canvas to draw that shape. A shape "preview" is shown as the mouse is dragged, and the shape is complete when the mouse button is released (i.e. the first click sets the starting position, and the drag operation sets the width of the circle, or creates a line, depending on the shape being drawn, and the shape is complete when the mouse button is released).

Your drawing program will have the following layout and features:

A menu bar with a File menu containing the following items:

New: create a new drawing. The drawing will always fit the canvas when it is created.
Load: load a drawing from a file (i.e. a file that you previously saved, which replaces the current drawing).
Save: save the current drawing (using a file format that you determine).
A tool palette on the left-hand side, supporting the following tools:

A selection tool: this allows the user to select a shape that has been drawn (there should be some visual indication which shape is selected). To select a shape, the user should click this tool, then click on an existing shape. Pressing ESC on the keyboard will clear shape selection. Selecting a shape will cause the colour palette and line thickness palette to update their state to reflect the shape colour and line thickness of that shape (e.g. if I select a red circle with the largest line thickness, the colour palette should change to red, and the line thickness should change to the largest line to match the selected shape). Changing colour or line thickness when a shape is selected will update the shape colour and thickness to the new values.
An erase tool: click on this tool and then click on a shape to delete it.
A line drawing tool: select this to draw a line using the selected colour and line thickness.
A circle drawing tool: select this to draw a circle at the point indicated using the selected line thickness and colour.
A rectangle tool: select this to draw a rectangle using the selected line thickness and shape colour.
A fill tool: select this tool, and click on a shape to change that shape to the currently selected colour.
A colour palette: a graphical display of at least six colours, which the user can use to select the current colour. The current drawing colour will be used for any new shapes that are drawn. If a shape is already selected when a colour is chosen, the shape will change to that new colour. Also, there should be a Chooser button that lets the user select an arbitrary colour from a colour picker dialog.
A line thickness palette: a graphical display of at least three line widths that the user can select. Selecting a line width will set the border thickness for any new shapes drawn. Selecting a shape will change the border thickness to reflect the line thickness of that shape.
The following functionality should be supported:

The user should be able to move a selected shape around the screen by selecting it, and dragging it with the mouse. You should determine rules for how overlapping shapes are handled (the assumption is that shapes will overlap, but you need to determine exactly how to handle this).
Your interface should clearly indicate which tool, colour and line thickness are selected at any time. It should also be obvious which shape, if any, is selected. You may use thicker borders around the tool (as in the example above), or some other visual indicator that you choose.
Your interface should enable/disable controls if appropriate (e.g. if an option is invalid, you should disable the control).
Your application should run at a fixed size (defined below) and not be resizable. You should actively prevent window resizing.
Additional Features (Mandatory, choose one or more features from the list below, totalling 10%).
Scale shapes: the ability to change the scale/size of any shape by selecting it, then grabbing a corner of the shape, and dragging to increase/decrease it's size (5 marks).
Group shapes: select multiple shapes, then group them together so that they can be dragged/resized as a single entity (10 marks).
Customizable colour palette: you can wholly or partially customize colour buttons in the palette (e.g. right-click a button and choose a new colour for that button from a colour-chooser dialog) (5 marks).
System-level copy/paste: support pasting the entire canvas an an image (using any supported format) to an outside program (e.g. MS Paint, Photoshop, Pixelmator) (10 marks).
Resizing: should support dynamic resizing of the application window, so that the application adapts to different window sizes and resolutions. The tool palettes should expand and contract based upon available space; how the layout changes is a visual design decision left to you. The canvas should not change size, but should display scrollbars if the user resizes the window smaller than the canvas (otherwise the scrollbars should remain hidden). You may set a "reasonable" minimum size for your application window (e.g. 640x480), but there should be no limit to the maximum size (10 marks).
Technical Requirements
The following is a list of technical constraints and guidelines:

The assignment must be programmed in Java using Swing components.
The starting application window should be no larger than 1600x1200.
Appropriate widgets should be selected and used for the interface. Options are appropriately enabled/disabled in the UI.
You may use third-party graphics/images, provided that (a) they are licensed to allow you to use them in this way (e.g. Creative Commons), and (b) you comment their origin and license in your README file.
You may use any sample code provided in-class (including on the class repository). If you do this, you must provide a comment in the code indicating the source of the code. If you use and fail to disclose this information, it could be considered an academic violation. You may not use any other third-party code unless you obtain instructor consent ahead of time.
Submission
Submit the following to your personal Git repository, in a subdirectory named `assignments/a1':

All files required to build and run your project (including source, images).
A gradle.build that will build, then execute, your project by typing only "gradle build" followed by "gradle run" from the command line.
A saved drawing from your application that can be loaded to demonstrate your load and save capabilities.
A readme.md file that documents your application.
Assessment
Late assignments will not be accepted.
TAs will grade on Windows or Mac, using your README as a guideline. If you include more than 10% in additional features, they will only grade the first ones that are submitted.
Your submission will be assessed roughly as follows:

5%
Gradle compiles and runs program.
60%
Functional requirements, described above.
25%
Appropriate use of widgets to meet the requirements above.
10%
Additional features from the list above.

More products