Object Oriented Paint Program using Java Swing
Object-oriented paint program which allows the user to unleash their inner Da Vinci!. GUI was designed mainly using javax.swing.
This app helps the user unleash their inner Da Vinci! The user can:
- Free paint using a brush with variable stroke/thickness ( Antialiasing got you covered ;) )
- Erase using eraser tool
- Draw geometric shapes (Line Segment, Circle, Square, Rectangle, Triangle)
- Change drawing color and stroke
- Fill shapes with any color
- Undo and redo any action ( I actually designed a custom algorithm for that :D )
- Move shapes around
- Resize shapes
- Copy and paste shapes as many times as you like!
- Clear the screen
- Automatic screenshot of your masterpiece with every change! Manual screenshot button is also present.
- IntelliJ IDEA (IDE)
- Java
- Javax.swing
- Graphic libraries like java.awt and javax.imageio
- Creately for UMLs diagrams
- LaTeX for writing documentation
- Maintained S.O.L.I.D principles
- Implemented 6 design patterns
To run the program, you have to run the class named "FinalProjectPaint_V1" as your main class with Java SDK 16
1. Factory Design Pattern We have used Factory design pattern to create new objects without the need of constructors and to avoid coupling and dependency between classes. So we constructed new instances of classes through this factory and returned in needed methods or classes.
2. Prototype Design Pattern We have used Prototype design pattern by implementing “Cloneable” interface and implementing “clone()” method in each and every Shape class and also Cloning instances of “Point” class. It helped us make copies of our Objects using values instead of references which helped in the copy method.
3. Singleton Design Pattern We have used Singleton design pattern to ensure the creation of only one instance of “ScreenShotter” class whose main aim is to screenshot the paint board and it is the only instance that is allowed to do such task.
4. Façade Design Pattern We have used the Façade design pattern as it offers a simple interface to more complex underlying objects. So we could use draw methods using objects of “ShapeMakerFacade” class instead of accessing the shapes classes themselves.
5. Iterator Design Pattern Iterator design Pattern facilitates looping across the array list of Geometric shapes needed to be drawn by only using 2 basic methods which are : “hasNext()” and “next()” avoiding looping with varying conditions which helped enhance the readability of the code.
6. Observer Design Pattern Observer design pattern helped us with automatic screenshotting(update method) while drawing (auto-documentation) as it takes screenshot each and every time we release the mouse by only changing the state in the PaintBoard class.
1. Single-Responsibility Principle A class should have one and only one reason to change, meaning that a class should have only one job, that's why we made classes like ShapeCopier, ShapeFiller, ShapeMover and ShapeResizer. Those classes are only responsiple for one job as shown from their names.
2. Open-Closed Principle Objects or entities should be open for extension but closed for modification, so if anyone wants to contribute to project and add another shape, he can do so effortlessly by adding a class and extending it from "GeometricShape" class.
3. Interface Segregation Principle Each method in each class is there for a reason, there is no unused method, so if you are adding extra shape, you probably won't be forced to implement a method you won't use.
Excuse my evidently limited drawing skills :)
The following is a report of the whole program : paint_Final.pdf