The Scribble App was a coursework project, as part of Further OOP, which explored dynamic ways of layering abstractions to build new concepts. While HireSnatch explored branching logic and object hierarchies, Scribble App focused on direct interaction: capturing mouse input and translating it into drawn shapes on a canvas.
Core Functionality
- The app provided a freehand drawing surface built with Java Swing and AWT.
- Mouse listeners tracked pressed, dragged, and released events, mapping them into line segments that persisted on the panel.
- A 2D vector structure (
java.awt.geom) stored points and paths, ensuring drawn strokes could be repainted whenever the window refreshed. - Colour and stroke size were adjustable through a simple toolbar, implemented as Swing buttons and sliders bound to drawing parameters.
Event Handling
- MousePressed: began a new path at the clicked coordinates.
- MouseDragged: appended line segments to the current path as the pointer moved.
- MouseReleased: finalized the path and committed it to the list of stored shapes.
- Repaint cycles: overridden
paintComponent(Graphics g)ensured all stored paths were redrawn whenever the window refreshed or resized.
Additional Features
- Clear canvas button: reset the vector store and triggered a full repaint.
- Save/load functionality: optional export of the current drawing as an image file, using
BufferedImageandImageIO.write. - Undo: basic stack-based undo/redo for paths, implemented through a list structure.
Architecture at a Glance
- Model: Vector data structure storing paths, colors, and stroke sizes.
- Controller: Mouse event listeners interpreting user input into vector updates.
- View: Swing panels and paint methods rendering paths to screen.
