This project is a farm dashboard application built using JavaFX. It allows users to visualize and manage farm items and item containers. The application provides functionality to add, rename, change the location, dimensions, price, and delete farm items and containers. Additionally, it includes the ability to visualize the farm layout and control drone movements.
-
FarmItem
- Description: The base class for all farm items. It stores basic information about an item such as name, location, dimensions, price, and associated shapes for visualization.
- Key Methods:
getName()
,getLocationX()
,setLocationX()
,setAssociatedShapes()
, etc.
-
Item (extends FarmItem)
- Description: A subclass of
FarmItem
representing a specific item on the farm, which may be a drone. - Key Methods:
checkDrone()
(to check if the item is a drone).
- Description: A subclass of
-
ItemContainer (extends FarmItem)
- Description: Represents a container for farm items. It holds a list of farm items.
- Key Methods:
getItemList()
,setItemList()
.
-
Add
- Description: Responsible for adding new items or item containers to the dashboard.
- Key Methods:
addItem()
,addItemContainer()
.
-
ChangeDimensions
- Description: Allows the user to change the dimensions of a selected farm item or container.
- Key Methods:
changeItemDimensions()
,changeItemContainerDimensions()
.
-
ChangeLocation
- Description: Allows the user to change the location of a selected farm item or container.
- Key Methods:
changeItemLocation()
,changeItemContainerLocation()
.
-
ChangePrice
- Description: Allows the user to change the price of a selected farm item or container.
- Key Methods:
changeItemPrice()
,changeItemContainerPrice()
.
-
Delete
- Description: Handles the deletion of a selected farm item or container.
- Key Methods:
deleteItem()
,deleteItemContainer()
.
-
Rename
- Description: Allows the user to rename a selected farm item or container.
- Key Methods:
renameItem()
,renameItemContainer()
.
-
Draw
- Description: Responsible for drawing farm items and containers in the visualization area. It visualizes items as rectangles with diagonal lines and handles the display of drones.
- Key Methods:
drawFarmItem()
,redraw()
,drawDrone()
.
- DashboardController
- Description: Manages the interactions between the view and the underlying data. It responds to user actions such as visiting items or scanning the farm.
- Key Methods:
handleVisitItem()
,handleScanFarm()
.
- DashboardView
- Description: Contains the main user interface for the farm dashboard, including the tree view of farm items, controls for interacting with the items, and the visualization area where items are displayed.
- Key Methods:
createScene()
,drawFarmItem()
,redraw()
.
- FarmDashboardApp
- Description: The entry point for the JavaFX application. It initializes the primary stage and sets up the dashboard view.
- Key Methods:
start()
.
The Singleton design pattern is used to ensure that only one instance of a particular class is created throughout the application. In our implementation, the DashboardView
class is designed as a Singleton to ensure that there is only one instance of the dashboard throughout the application’s lifecycle. Instead of creating multiple instances of the DashboardView
, we instantiate it only once. This ensures that all user interactions, visualization, and item management happen in a single, consistent environment.
By using the Singleton pattern for the DashboardView
, we avoid the creation of redundant UI elements and ensure that all operations like adding, renaming, and changing items are managed in one unified instance, preventing potential conflicts or inconsistencies across multiple dashboard instances.
The Composite design pattern is used to treat individual farm items and item containers uniformly. An ItemContainer
can hold multiple FarmItem
objects, including other containers or individual items. This pattern allows us to treat both Item
and ItemContainer
as FarmItem
objects, which simplifies the management of these objects in the UI and operations like adding, deleting, or changing their properties. By using this pattern, we can create complex hierarchical structures of farm items (individual items and containers) while maintaining simplicity in the way we manipulate and display them.
- Clone this repository or download the source code.
- Ensure that you have Java and JavaFX set up on your system.
- Run
FarmDashboardApp.java
as a JavaFX application.
- JavaFX