The 2D Floor Planner is a desktop-based application that allows users to create and manage room layouts, save their designs, and load them for later use. The application features components for drawing, interacting with rooms, and managing saved layouts.
- Add, remove, and modify room layouts on a 2D grid.
- Save floor plans to a file for future retrieval.
- User-friendly interface with customizable elements.
- A grid-based layout for accurate positioning of rooms.
The project is organized into several packages and files that manage different functionalities:
2DFloorPlanner
│
├── assets # Directory to store additional assets
├── saves # Directory to store save files
│ └── saveFileTest.txt # Example saved file
└── src/com/example # Main source directory
├── canvas # Canvas-related classes (manages grid and room drawing)
│ └── Canvas.java
├── frames # Window frame management
│ └── OuterFrame.java
├── main # Main application entry point
│ └── Main.java
├── menubar # Menu bar implementation
├── models # Data models for rooms and other objects
│ └── Room.java
├── panels # UI panels for commands and other inputs
│ └── CommandPanel.java
└── services # Services for file I/O and constants
├── Constants.java # Contains constant values such as file paths
├── RetrieveFile.java # Loads room data from files
└── SaveFile.java # Saves room data to files
-
Purpose: Manages the drawing and interaction with the 2D grid where rooms are placed. This class listens for user input, processes clicks to place rooms, and handles the rendering of rooms on the grid.
-
Key Responsibilities:
- Draws the grid based on the specified
gridSize
. - Handles mouse events to snap rooms to the grid.
- Dynamically renders rooms and updates the canvas upon user interactions.
- Loads rooms from a saved file using the
RetrieveFile
class.
- Draws the grid based on the specified
-
Key Methods:
paintComponent(Graphics g)
: Draws the grid and any rooms on the canvas.snapToGrid(int value)
: Snaps room positions to the nearest grid point.setSelectedObject(T fixture)
: Allows users to select a type of room (e.g., bedroom, kitchen) for placement.getRoomList()
: Returns the current list of rooms on the canvas.
- Purpose: Manages the main application window frame.
- Key Responsibilities:
- Creates the window frame for the 2D Floor Planner application.
- Sets up the layout and integrates UI components like menus and panels.
- Purpose: Entry point for the application.
- Key Responsibilities:
- Launches the application and initializes key components, such as the
OuterFrame
and theCanvas
. - Ensures that all elements are correctly displayed when the application starts.
- Launches the application and initializes key components, such as the
- Purpose: Manages the user input panel for issuing commands related to room management (e.g., adding or removing rooms).
- Key Responsibilities:
- Provides buttons and input fields for interacting with the floor plan.
- Connects user commands with the canvas, allowing them to modify the room layout.
- Purpose: Represents a room with properties such as dimensions and position.
- Key Properties:
int x, y
: Coordinates of the room on the grid.int width, height
: Dimensions of the room.Color color
: The color representing the room (e.g., bedrooms may be red, bathrooms green).
- Purpose: Stores shared constant values used across the application.
- Key Constants:
ROOM_FILE_PATH
: The path where room layouts are saved and loaded.GRID_SIZE
: Default size of the grid for snapping rooms.
-
Purpose: Manages the loading of saved room layouts from a file.
-
Key Responsibilities:
- Reads room data from a text file (e.g.,
saveFileTest.txt
). - Returns an array of
Room
objects to be displayed on the canvas.
- Reads room data from a text file (e.g.,
-
Key Methods:
getFile()
: Returns a list ofRoom
objects loaded from the file.
- Purpose: Manages the saving of room layouts to a file.
- Key Responsibilities:
- Saves the current list of rooms to a specified file (e.g.,
saveFileTest.txt
). - Converts the
Room
objects to a file format for persistence.
- Saves the current list of rooms to a specified file (e.g.,
- The
SaveFile.java
class is responsible for writing the current list ofRoom
objects to a text file. - The saved file can later be retrieved using
RetrieveFile.java
.
- The
RetrieveFile.java
class reads room data from a file and reconstructs the room objects for display on the canvas.
- The
Constants.java
file stores shared configuration values, such as file paths and grid sizes. This helps in centralizing configurations and ensuring that any changes are reflected across the application without modifying each class individually.
- Java Development Kit (JDK) installed.
- A text editor or IDE (e.g., IntelliJ, Eclipse) for development.
- Open the project in your preferred IDE.
- Navigate to
OuterFrame.java
and run the application. - The main window will open, displaying a grid where users can place rooms.
- Place a Room: Select a room type (e.g., bedroom, bathroom) and click on the grid to place it.
- Save Layout: Use the
SaveFile
functionality to save your current floor plan. - Load Layout: Use the
RetrieveFile
functionality to load a previously saved layout.
- Room Resizing: Allow users to resize rooms dynamically.
- Drag and Drop: Implement drag-and-drop functionality for rooms.
- Undo/Redo: Add undo/redo functionality for better user experience.
-
Issue: Application does not start:
- Ensure you have the correct JDK installed and the project is set up properly.
-
Issue: Saved rooms are not loading correctly:
- Verify the file path in
Constants.java
is correct.
- Verify the file path in
- Java Swing for UI components.
- Open-source libraries for file handling (if any are used).
- Pratyush Nair
- Saket Goyal
- Riddhi Chatterjee
- Aryan Dalmia