A JavaFX-based image processing application that provides various image manipulation features, color analysis, and special effects including Game of Life simulation and image-to-music conversion. The application demonstrates advanced Java concepts while maintaining a user-friendly interface.
- Inheritance: Main application extends
Application
class (TheImaniPulator.java
) - Encapsulation: Private fields and methods throughout classes
- Polymorphism: Method overriding (
ColorCount.compareTo()
) - Inner Classes:
ColorCount
class insideTheImaniPulator
- Scene Graph Architecture: Hierarchical layout using
VBox
,HBox
,GridPane
- Event Handling: Button actions and mouse events
- Property Binding: Image and effect bindings
- UI Controls:
Button
,Label
,ImageView
, etc. - Custom Styling: CSS-like styling through Java
- Animation:
FadeTransition
,Timeline
for Game of Life
- Concurrency:
ExecutorService
,ConcurrentHashMap
in color analysis - Lambda Expressions: Event handlers and thread operations
- Stream API: Collection processing
- Thread Management:
Platform.runLater()
for UI updates - Atomic Operations:
AtomicReference
in Game of Life - Resource Management: Image loading/saving operations
-
Generics
- Parameterized collections (
LinkedList<String>
,PriorityQueue<ColorCount>
) - Type-safe operations in collections
- Parameterized collections (
-
Collections Framework
PriorityQueue
for color sortingConcurrentHashMap
for thread-safe color countingLinkedList
for storing analysis results
-
I/O Operations
ImageIO
for image reading/writingFile
handling with exception management- Buffered operations for efficient I/O
-
Exception Handling
- Custom error dialogs using
Alert
- Try-catch blocks with specific handling
- Resource management with try-with-resources
- Custom error dialogs using
-
Image Loading and Display
- File chooser dialog for image selection
- Responsive image display with preservation ratio
-
Image Filters
- Blur:
GaussianBlur
with bloom effects - Grayscale:
ColorAdjust
with saturation manipulation - Sepia:
SepiaTone
with custom parameters - Vignette: Custom shadow effects
- Blur:
-
Color Analysis
- Parallel processing of image pixels
- Frequency analysis of colors
- Top 10 colors display with pixel counts
-
Game of Life
- Image conversion to binary state
- Cellular automaton implementation
- Chunked processing for performance
- Animated transitions between states
-
Image to Music
- Pixel data conversion to audio signals
- Real-time playback capabilities
// Efficient image scaling
int width = 640;
int height = (int) (source.getHeight() * (640.0 / source.getWidth()));
- Dynamic memory allocation based on image size
- Automatic garbage collection consideration
- Resource cleanup in image processing
ExecutorService executor = Executors.newFixedThreadPool(numThreads);
int rowsPerThread = height / numThreads;
- Thread pool management
- Work distribution strategies
- Synchronization mechanisms
Platform.runLater(() -> {
Alert alert = new Alert(AlertType.INFORMATION);
// UI updates
});
- JavaFX Application Thread management
- Event queue handling
- UI thread safety
- Main UI thread for interface responsiveness
- Background threads for heavy processing
- Thread synchronization for shared resources
- Thread pool management for parallel operations
// Example of data pipeline
Image -> PixelReader -> Processing -> WritableImage -> ImageView
- Efficient data transformation
- Minimal copying of large data structures
- Stream-based processing where applicable
private Button activeButton = null;
private Image originalImage;
- Clear state tracking
- Atomic operations for thread safety
- Consistent state management
-
Lazy Loading
- Deferred initialization of heavy resources
- On-demand processing
- Cached results where appropriate
-
Memory Usage
- Image scaling before processing
- Efficient data structures
- Resource cleanup and management
-
Processing Pipeline
- Chunked processing for large images
- Parallel processing where beneficial
- Cancelable operations
- MVC-like Structure: Separation of UI and processing logic
- Factory Pattern: Scene creation methods
- Observer Pattern: Event handling implementation
TheImaniPulator.java
: Main application classWelcomeScreen.java
: Initial welcome interfaceImageProcessor.java
: Core image processing functionalityGameOfLifeProcessor.java
: Game of Life implementation- Supporting classes for specific features
resetButton.setOnAction(e -> {
if (originalImage != null) {
GameOfLifeProcessor.stopGameOfLife();
setActiveButton(null);
imageView.setImage(originalImage);
imageView.setEffect(null);
updateStatus("Image Processor");
}
});
The reset button implements a comprehensive state restoration mechanism. When triggered, it first checks if there's an original image to revert to. It then stops any running Game of Life simulation to prevent resource conflicts, clears the active button state for UI consistency, restores the original image to the ImageView, removes any applied effects (filters, animations, etc.), and updates the status label. This implementation ensures a clean slate by properly releasing resources and resetting all visual modifications while maintaining the original image data. The reset functionality is crucial for user experience, allowing users to undo all modifications without reloading the image.
The project utilizes a well-structured package hierarchy to maintain code organization and separation of concerns. The root package jfxlabproj
contains the main application classes, while specialized features are organized into sub-packages. For instance, jfxlabproj.gameoflife
encapsulates the Game of Life functionality, and jfxlabproj.musicplayer
contains music conversion and playback logic. This package structure not only improves code maintainability but also provides clear boundaries between different components of the application. Import statements are organized to clearly show dependencies between JavaFX components (javafx.*
), utility classes (java.util.*
), and project-specific implementations, making the codebase more navigable and reducing potential naming conflicts.
This project demonstrates advanced Java and JavaFX concepts while maintaining clean code architecture and efficient processing methods. The modular design allows for easy extension and modification while ensuring robust performance and resource management.
[Note: The implementation emphasizes both functionality and performance, utilizing modern Java features and best practices in software design.]
Compile: javac -d bin --module-path lib --add-modules javafx.controls,javafx.graphics,javafx.base src/jfxlabproj/*.java
Run: java --module-path lib --add-modules javafx.controls,javafx.graphics,javafx.base -cp bin jfxlabproj.TheImaniPulator