A comprehensive JavaFX-based garden simulation application that provides an interactive, real-time virtual garden experience. Built with modular Java architecture and featuring automated systems, environmental events, and visual animations.
- Interactive 5ร5 Garden Grid: Plant, water, and manage crops in real-time
- Multiple Plant Types: Carrot, Cherry, Corn, Pumpkin, and Sunflower varieties
- Real-time Statistics: Track living/dead plants, waterings, temperature, and session time
- Visual Health Indicators: Color-coded health and moisture levels for each plant
- Dynamic Weather Events: Sunny days, rainy days, chilly weather with visual effects
- Temperature Regulation: Automatic insulation cover deployment during cold spells
- Pest Management: Realistic pest infestations with automated spray defense system
- Special Events: Perfect growth conditions and gardener visits
- Background Processing: Multi-threaded updates via JavaFX Timeline and ThreadPoolExecutor
- Smart Automation: Automated watering, pest control, and environmental responses
- Event Scheduling: Random environmental events every 15 seconds during automation
- Batch Logging: Efficient logging system with 10-second batch updates
- Responsive Design: Scalable panels and grid layout
- Visual Animations: Water drops, sunshine, frost, and pest spray effects
- Comprehensive Help: Built-in documentation with gardening tips and controls
- Activity Logging: Real-time log viewer with clear/filter options
- Java 24: Modern Java with advanced features
- JavaFX 24.0.1: Rich UI framework with FXML
- Maven: Dependency management and build automation
- Modular Architecture: Java Platform Module System (JPMS)
- Concurrent Programming: ExecutorService and Timeline for smooth performance
- Java 24 or higher
- Maven 3.6+ (or use included Maven wrapper)
- Operating System: Windows, macOS, or Linux
git clone https://github.com/Anmol-tech/Project_CSEN_275.git
cd Project_CSEN_275Using Maven wrapper (recommended):
# Windows
./mvnw clean javafx:run
# macOS/Linux
./mvnw clean javafx:runUsing system Maven:
mvn clean javafx:run# Compile only
./mvnw clean compile
# Run tests
./mvnw test
# Package application
./mvnw clean package- Left Click: Select a grid cell for planting
- Right Click: Water the plant in the selected cell
- Plant Selection: Choose plant type from dropdown, then click "Plant Selected"
- Water All: Instantly water all living plants in the garden
- Update Garden: Manually trigger a garden state update
- Click "Start Automation" to enable automatic garden management
- The system will:
- Update garden state every 3 seconds
- Randomly water plants every 18 seconds
- Deploy pest spray when infestations occur
- Trigger environmental events every 15 seconds
- Click "Stop Automation" to return to manual control
- Sunny Day: Increases temperature, causes extra plant drying
- Rainy Day: Waters all plants automatically
- Chilly Day: Drops temperature, triggers insulation cover
- Pest Infestation: Adds pests to vulnerable plants
- Perfect Growth: Optimal conditions with extra watering
- Gardener Visit: Removes all pests and waters plants
- Ideal Range: 65-75ยฐF
- Cold Effects: Plants lose health below 65ยฐF
- Hot Effects: Accelerated moisture loss above 75ยฐF
- Insulation Cover: Automatically deployed during cold spells
src/main/java/com/example/project_csen_275/
โโโ GardenApp.java # Application entry point
โโโ GardenControllerFX.java # Main UI controller
โโโ GardenSimulationAPI.java # Core simulation logic
โโโ GardenLogger.java # Logging system
โโโ GardenTimer.java # Game time management
โโโ GardenDocumentation.java # Help system
โโโ PlantSelector.java # Plant type selector
โโโ Models/
โ โโโ Garden.java # Garden state management
โ โโโ Plants/
โ โโโ Plant.java # Base plant class
โ โโโ Carrot.java # Carrot plant implementation
โ โโโ Cherry.java # Cherry plant implementation
โ โโโ Corn.java # Corn plant implementation
โ โโโ Pumpkin.java # Pumpkin plant implementation
โ โโโ Sunflower.java # Sunflower plant implementation
โ โโโ NoPlant.java # Empty soil representation
โโโ animations/
โโโ AnimationFactory.java # Visual effects system
src/main/resources/
โโโ garden-view.fxml # UI layout definition
โโโ garden_config.csv # Plant configuration data
โโโ assests/
โโโ Animation/ # Animation sprites
โโโ Tiles/ # Plant and UI images
Plant characteristics are defined in garden_config.csv:
- Growth rates and health values
- Moisture requirements
- Pest vulnerabilities
- Visual appearance settings
Key constants in GardenControllerFX.java:
AUTO_UPDATE_INTERVAL: Automation cycle time (3 seconds)IDEAL_TEMP_LOWER/UPPER: Temperature comfort zone (65-75ยฐF)SPRAY_INITIAL_DMG/SPRAY_SUBSEQUENT_DMG: Pest spray effectiveness
The application maintains comprehensive logs:
- Garden Events: Plant actions, environmental changes
- System Status: Automation state, errors, warnings
- Performance: Background task execution times
- User Actions: Manual interventions and selections
Logs are stored in the logs/ directory with daily rotation.
- MVC Pattern: Separation of UI, logic, and data
- Factory Pattern: Animation and plant creation
- Observer Pattern: Real-time UI updates
- Command Pattern: Event handling system
- JavaFX Application Thread: UI updates and user interactions
- Background Thread Pool: Garden state calculations
- Timeline Schedulers: Periodic automation tasks
- Platform.runLater(): Thread-safe UI updates
The application uses Java's module system for:
- Clear dependency boundaries
- Improved security and performance
- Better maintainability
- Create new class extending
PlantinModels/Plants/ - Add plant images to
src/main/resources/assests/Tiles/ - Update
PlantSelector.javawith new plant type - Add plant data to
garden_config.csv
- Extend the
triggerRandomEvent()method inGardenControllerFX.java - Add new event type to
eventComboBoxinitialization - Create corresponding animation in
AnimationFactory.java
# Run unit tests
./mvnw test
# Run with debugging
./mvnw clean javafx:run -Djavafx.args="--debug"-
JavaFX Runtime Not Found
- Ensure Java 24+ with JavaFX modules is installed
- Use the provided Maven wrapper which handles JavaFX dependencies
-
Performance Issues
- Reduce automation frequency by increasing
AUTO_UPDATE_INTERVAL - Lower animation quality in resource-constrained environments
- Reduce automation frequency by increasing
-
UI Scaling Problems
- Adjust system DPI settings
- Modify CSS scaling factors in FXML files
- Check the built-in help system (Help button in application)
- Review log files in
logs/directory for error details - Ensure all dependencies are properly installed
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is developed as part of CSEN 275 coursework. Please refer to your institution's academic integrity policies.
- JavaFX community for excellent documentation and examples
- Plant imagery and animations from open-source resources
- Course instructors and peers for feedback and testing
Happy Gardening! ๐ป