A modular 2D vector graphics editor built with Java 21 and JavaFX 21, designed to demonstrate object-oriented software architecture, GoF design patterns, persistence, and separation of concerns.
MinDrawFX provides an interactive drawing canvas where users can create geometric shapes, apply visual effects, save and load drawings, perform multi-level Undo/Redo operations, and export the canvas as a PNG image.
- Draw Rectangles, Circles, and Lines
- Interactive click-and-drag shape creation
- Select graphical objects on the canvas
- Delete selected shapes
- Multi-level Undo / Redo
- Apply dynamic visual decorators:
- Glow
- Shadow
- Red Border
- Dashed Border
- Thick Border
- Save and load drawings using SQLite
- Alternative text-file persistence
- Export the JavaFX canvas to PNG
- Console and file logging
- Activity history and UI status updates
| Technology | Usage |
|---|---|
| Java 21 | Core application language |
| JavaFX 21 | Desktop UI and Canvas rendering |
| FXML | User interface definition |
| CSS | JavaFX interface styling |
| SQLite | Embedded database |
| JDBC | Database access |
| SQLite JDBC Driver | SQLite connectivity |
| Java ImageIO | PNG image export |
MinDrawFX follows an MVC-oriented architecture complemented by dedicated Service and Repository layers.
View
│
▼
Controller
│
▼
Service Layer
│
├── Domain Model
│
├── Commands
│
├── Factories
│
└── Decorators
│
▼
Repository Layer
│
├── SQLite
└── Text File
- View — JavaFX FXML interface and CSS styling
- Controller — Handles user interactions and coordinates application behavior
- Model — Contains shapes, commands, observers, and strategies
- Service Layer — Provides high-level application operations
- Repository Layer — Abstracts persistence mechanisms
- Factory Layer — Centralizes shape and repository creation
MinDrawFX applies several software design patterns to keep the application modular and extensible.
The Command pattern encapsulates drawing operations into command objects.
Main classes:
Command
DrawShapeCommand
DeleteShapeCommand
CommandManager
CommandManager maintains Undo and Redo stacks, allowing drawing and deletion operations to be reversed or replayed.
Visual effects are dynamically applied to existing shapes without modifying their original implementations.
Implemented decorators include:
GlowDecorator
ShadowDecorator
RedBorderDecorator
DashedDecorator
ThickBorderDecorator
All decorators extend the common ShapeDecorator abstraction.
Shape creation is delegated to dedicated factories:
ShapeFactory
RectangleFactory
CircleFactory
LineFactory
ShapeFactoryProducer
This separates object creation logic from the application controller.
The application uses the Observer pattern to synchronize command execution with interface updates.
Subject
Observer
CommandManager
MainController
CommandManager notifies registered observers whenever commands are executed, undone, or redone.
Logging behavior can be switched dynamically through a common logging abstraction.
LoggerStrategy
ConsoleLogger
FileLogger
LoggingContext
This allows the application to use different logging destinations without changing the calling code.
CanvasExportAdapter bridges JavaFX canvas rendering with Java's image-writing APIs.
JavaFX Canvas
│
▼
CanvasExportAdapter
│
▼
SwingFXUtils
│
▼
ImageIO
│
▼
PNG File
DatabaseConnection manages the application's shared SQLite JDBC connection using a lazy-initialized Singleton.
In addition to GoF design patterns, MinDrawFX uses architectural patterns to organize application responsibilities.
The application separates:
Model → shapes and domain behavior
View → FXML + CSS
Controller → MainController
Persistence is abstracted through:
ShapeRepository
├── SQLiteShapeRepository
└── JsonShapeRepository
Despite its historical class name, JsonShapeRepository currently stores data using a semicolon-separated text format rather than JSON.
The application exposes high-level operations through:
ShapeService
ShapePersistenceService
LoggingService
ExportService
Drawing and deletion operations are implemented as commands.
User Action
│
▼
Command
│
▼
CommandManager
│
├── execute()
├── undo()
└── redo()
The manager maintains separate Undo and Redo stacks.
MinDrawFX supports two persistence approaches.
The primary persistence implementation uses SQLite through JDBC.
Stored shape properties include:
id
type
x
y
width
height
color
The database is created locally at runtime.
A second repository implementation serializes shapes to a simple text format:
type;x;y;width;height;color
This provides an alternative persistence mechanism without requiring database storage.
The current canvas can be exported as a PNG image.
The export workflow is:
JavaFX Canvas
↓
Canvas Snapshot
↓
SwingFXUtils
↓
ImageIO
↓
export.png
The generated image is a runtime artifact and is not committed to the repository.
MinDrawFX/
├── lib/
│ └── sqlite-jdbc-3.53.1.0.jar
│
├── src/
│ ├── adapter/
│ │ └── CanvasExportAdapter.java
│ │
│ ├── app/
│ │ └── MainApp.java
│ │
│ ├── command/
│ │ └── CommandManager.java
│ │
│ ├── controller/
│ │ └── MainController.java
│ │
│ ├── decorator/
│ │ ├── DashedDecorator.java
│ │ ├── GlowDecorator.java
│ │ ├── RedBorderDecorator.java
│ │ ├── ShadowDecorator.java
│ │ ├── ShapeDecorator.java
│ │ └── ThickBorderDecorator.java
│ │
│ ├── factory/
│ │ ├── CircleFactory.java
│ │ ├── LineFactory.java
│ │ ├── RectangleFactory.java
│ │ ├── RepositoryFactory.java
│ │ ├── ShapeFactory.java
│ │ ├── ShapeFactoryProducer.java
│ │ └── ShapeType.java
│ │
│ ├── model/
│ │ ├── commands/
│ │ ├── observers/
│ │ ├── shapes/
│ │ └── strategies/
│ │
│ ├── repository/
│ │ ├── JsonShapeRepository.java
│ │ ├── SQLiteShapeRepository.java
│ │ └── ShapeRepository.java
│ │
│ ├── service/
│ │ ├── ExportService.java
│ │ ├── LoggingService.java
│ │ ├── ShapePersistenceService.java
│ │ └── ShapeService.java
│ │
│ ├── singleton/
│ │ └── DatabaseConnection.java
│ │
│ └── view/
│ ├── main-view.fxml
│ └── style.css
│
├── .gitignore
└── README.md
- JDK 21
- JavaFX SDK 21
- SQLite JDBC driver
The SQLite JDBC driver is included in:
lib/sqlite-jdbc-3.53.1.0.jar
The project requires the following JavaFX modules:
javafx.controls
javafx.fxml
javafx.swing
Configure the JavaFX SDK in your IDE, add the SQLite JDBC driver to the classpath, and run:
app.MainApp
The application may generate the following files locally:
mindraw.db
shapes.txt
export.png
These files are runtime artifacts and are excluded from the Git repository.
The current version focuses primarily on architecture and design-pattern implementation.
The following features are not currently implemented:
- Moving shapes after placement
- Shape resizing
- Custom color picker
- Text tool
- Zoom
- Layers
- Copy / Paste
- Keyboard shortcuts
- Automated JUnit tests
- Maven or Gradle build automation
MinDrawFX was developed primarily as a software architecture project to explore:
- Object-Oriented Programming
- Separation of concerns
- SOLID-oriented design
- GoF Design Patterns
- MVC architecture
- Persistence abstraction
- Reversible commands
- Extensible application structure
Bassem Wali
Software Engineering Student
Full-Stack Development & AI Integration
- GitHub: bassem2002
- LinkedIn: bassem-wali
MinDrawFX is an academic software architecture project and is currently maintained as part of my software engineering portfolio.