java.lang.Object
com.example.cab302project.CrimesController
Controller for the public crime reports screen (crimes-view.fxml).
Manages the List and Map tab views, the sliding detail panel,
crime report submission, address autocomplete and the hamburger menu.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs the CrimesController and initialises the database access object (DAO). -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetRelativeTime(LocalDateTime timestamp) Returns a human-readable relative time string from a LocalDateTime.voidThis method runs automatically after the FXML has loadedvoidAdd a new crime to the database after entering details.voidReturn to the previous menu (dashboard)voidClose the detail panel - slides back down off screen.voidCloses the crime map filter drawer when the user clicks outside it.voidClears the suburb search on the crime map, removes the boundary polygon, and resets the map to show all crimes.voidCalled when any crime map filter dropdown changes value.voidonCrimeFilterDrawerClicked(javafx.scene.input.MouseEvent event) Consumes mouse clicks on the filter drawer itself so they do not propagate to the backdrop and accidentally close the panel.voidResets all crime map filter dropdowns to their defaults and refreshes the map.voidHandles suburb search on the crime map when the user presses enter or Search.voidToggles the crime map filter drawer open and closed.voidHandles changes from any filter menu option.voidShows the list pane and marks the List tab as active.voidShows the map pane and marks the Map tab as active.voidHandles a tap on the Opened Report banner above the list.voidonSave()Handles saving a crime report based on form input.
-
Constructor Details
-
CrimesController
public CrimesController()Constructs the CrimesController and initialises the database access object (DAO). This allows the controller to interact with the shared application database for managing and retrieving crime records.
-
-
Method Details
-
initialize
public void initialize()This method runs automatically after the FXML has loaded -
onListTabClick
public void onListTabClick()Shows the list pane and marks the List tab as active. -
onMapTabClick
public void onMapTabClick()Shows the map pane and marks the Map tab as active. Loads the crime map on first open only. -
onCrimeSearch
public void onCrimeSearch()Handles suburb search on the crime map when the user presses enter or Search. Runs Nominatim on a background thread to keep the UI responsive, then draws the suburb boundary polygon on the map and refilters markers to that area. -
onCrimeClearSearch
public void onCrimeClearSearch()Clears the suburb search on the crime map, removes the boundary polygon, and resets the map to show all crimes. -
onCrimeToggleFilter
public void onCrimeToggleFilter()Toggles the crime map filter drawer open and closed. Also shows or hides the transparent backdrop that catches outside clicks. -
onCrimeBackdropClicked
public void onCrimeBackdropClicked()Closes the crime map filter drawer when the user clicks outside it. -
onCrimeFilterDrawerClicked
public void onCrimeFilterDrawerClicked(javafx.scene.input.MouseEvent event) Consumes mouse clicks on the filter drawer itself so they do not propagate to the backdrop and accidentally close the panel.- Parameters:
event- the mouse event to consume
-
onCrimeFilterChanged
public void onCrimeFilterChanged()Called when any crime map filter dropdown changes value. Immediately reapplies all filters and refreshes the map markers. -
onCrimeResetFilters
public void onCrimeResetFilters()Resets all crime map filter dropdowns to their defaults and refreshes the map. -
onSave
public void onSave()Handles saving a crime report based on form input. If the selected record is new (id == 0), it is added to the database. Existing records are treated as read-only and cannot be modified. -
onAddNewCrime
public void onAddNewCrime()Add a new crime to the database after entering details. The new blank record is stored in pendingRecord and shown in the Opened Report banner above the list. The list scrolls to the top so the user sees the banner immediately. -
onOpenedBannerClicked
public void onOpenedBannerClicked()Handles a tap on the Opened Report banner above the list. Re-opens the detail panel so the user can continue editing and submit the pending report. -
onBackButtonClick
public void onBackButtonClick()Return to the previous menu (dashboard) -
onCloseDetail
public void onCloseDetail()Close the detail panel - slides back down off screen. If a pending report is open, its current form values are saved back into pendingRecord before closing so they are restored when the user reopens it. -
onFilterChanged
public void onFilterChanged()Handles changes from any filter menu option. -
getRelativeTime
Returns a human-readable relative time string from a LocalDateTime.- Parameters:
timestamp- the timestamp to describe- Returns:
- a string such as "Today", "1 day ago", or "3 days ago"
-