ITI0011:Kimp homework

Allikas: Kursused
Mine navigeerimisribale Mine otsikasti

Back to course web page

This is English version of second homework. Estonian version is here: ITI0011:Kimp.

General

Deadline:

  • HW3 folder pushed to git before 16. November 23:59
  • 18. or 20. November (depending on your practice time)

Defending your homework one week before (or earlier) will give you +1 point. The code must be in git before defending.

The goal of the homework is to develop a JavaFX program which enables to draw and manipulate shapes.

Main (4p)

  • The program presents a GUI (a window) and enables drawing free hand line inside the window using the mouse.
  • The line starts with mouse press.
  • While the mouse is dragged (mouse is down and mouse is moving), the the trajectory should be shown as drawing a line.
  • The line is finished if the mouse is released.
  • There can be unlimited number of different lines.
  • Point can also be drawn (if the user just clicks the mouse - the starting point and the ending point of the line are the same)
  • Pressing <escape> exits the program.

Additional part: rectangle (1p)

  • In addition to free hand line, the program allows to draw a rectangle using the mouse.
  • If the mouse is pressed, one corner of the rectangle is fixed in that location.
  • While dragging, the opposite corner of the rectangle is moved.
  • During the dragging, the rectangle should be visible (one corner is fixed, another moves along with the mouse).
  • How exactly the user can select which shape to draw (free hand line or rectangle) is up to the student (you can use buttons, keyboard somehow etc).

Additional part: moving and deleting shapes (2-3p)

A shape can be moved:

  • When the user holds <control> key, shapes can be moved:
    • while moving (just holding ctrl, no mouse button is clicked) around, the closest shape will be highlighted by adding shadow effect to it
    • when left mouse button is pressed, the moving starts
    • while the left mouse button is down and the mouse is dragged, the shape moves along with the mouse cursor
    • the shape should be visible during the move (and it follows the cursor movement)
    • if the mouse button is released, the shape is moved
    • if ctrl is still down, the user can go on with moving the next shape.

A shape can be deleted:

  • When the user holds <control> key, shapes can be deleted:
    • as with moving the shape, moving around the mouse will highlight the closest shape to the cursor
    • when right mouse button is clicked, the shape is deleted.

This additional part gives 2 points if drawing rectangle additional part is not implemented.

This additional part gives 3 points if both drawing the rectangle and free hand line are implemented.

Additional part: undo/redo (2p)

  • The program stores all the actions done by the user.
  • All the actions can be taken back (undo):
    • drawing a shape
    • moving a shape
    • removing a shape
  • Undo works with <escape> key.
  • <escape> takes back one action.
  • If there is no more actions to take back, exiting program with esc key will continue.
  • In addition to undo, actions can be repeated (redo).
  • Program can redo only actions which have been undone.
  • <space> key is used for redo.

To get 2 points, moving and removing the shape should be implemented.

If only drawing is implemented (the main part), then redo and undo together will give only 1 point.

Additional part: GUI improvements (2p)

This part requires other additional parts to be implemented.

The task is to improve the GUI:

  • When pressing <escape> (to exit the program after all is undone), a confirmation dialog should be presented to the user (e.g. "Are you sure you want to exit?") with options like "yes", "no" or "cancel".
  • The user can pick the color for the next shape he/she draws. It's not required to change the color for existing shape (although you can still try to implement this). The program should contain ColorPicker element.
  • Undo and redo have buttons (or are in menu). In addition to <escape> and <space>, buttons can be used.
  • Shape selection (free hand line or rectangle) is done with buttons or other GUI element.