# Class SelectedTileController

java.lang.Object
it.polimi.ingsw.is25am31.view.gui.SelectedTileController

public class SelectedTileController extends Object
Controller for managing the selected component tile during the ship assembly phase. Handles component display, rotation, placement confirmation, removal, and reservation. Provides visual feedback and validation for component placement operations.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `javafx.scene.control.Button`
  `okButton`
  `javafx.scene.control.Button`
  `rotateButton`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SelectedTileController()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `activateAll()`
  Enables all interactive buttons in the view.
  `void`
  `clearComponent()`
  Clears the current component selection and resets the view.
  `void`
  `clearPendingComponent()`
  Clears the pending component and resets the image view.
  `void`
  `enableRotateButton()`
  Enables the rotate button using Platform.runLater for thread safety.
  `void`
  `finishComponentError(String message)`
  Displays an error message when component placement fails.
  `javafx.scene.control.Label`
  `getComponentLabel()`
  Gets the component label for displaying messages.
  `Component`
  `getCurrentComponent()`
  Gets the current component being displayed.
  `Component`
  `getPendingComponent()`
  Gets the pending component that hasn't been confirmed yet.
  `static javafx.stage.Stage`
  `getStage()`
  Gets the static stage for this controller.
  `boolean`
  `hasPendingComponent()`
  Checks if there is a pending component that hasn't been confirmed.
  `void`
  `initialize()`
  Initializes the controller by loading all component images.
  `boolean`
  `isConfirmed()`
  Checks if the current component has been confirmed for placement.
  `void`
  `resetImage()`
  Resets the component image rotation to 0 degrees.
  `void`
  `setDisableAll()`
  Disables all interactive buttons in the view.
  `void`
  `setGui(Gui gui)`
  Sets the GUI instance for this controller.
  `static void`
  `setStage(javafx.stage.Stage s)`
  Sets the static stage for this controller.
  `void`
  `setStage2Controller(Stage2Controller controller)`
  Sets the Stage2Controller instance for this controller.
  `void`
  `showComponentImage(int id, Component component)`
  Displays the component image and enables interaction buttons.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### okButton

    public javafx.scene.control.Button okButton

  - ### rotateButton

    public javafx.scene.control.Button rotateButton

- ## Constructor Details

  - ### SelectedTileController

    public SelectedTileController()

- ## Method Details

  - ### initialize

    public void initialize()
    Initializes the controller by loading all component images. This method is automatically called after the FXML file has been loaded.

  - ### showComponentImage

    public void showComponentImage(int id, Component component)
    Displays the component image and enables interaction buttons.
    Parameters:
      `id` - the component ID used to load the image
      `component` - the component to display

  - ### getCurrentComponent

    public Component getCurrentComponent()
    Gets the current component being displayed.
    Returns:
      the current component, or null if no component is selected

  - ### isConfirmed

    public boolean isConfirmed()
    Checks if the current component has been confirmed for placement.
    Returns:
      true if confirmed, false otherwise

  - ### clearComponent

    public void clearComponent()
    Clears the current component selection and resets the view.

  - ### getComponentLabel

    public javafx.scene.control.Label getComponentLabel()
    Gets the component label for displaying messages.
    Returns:
      the reserve message label

  - ### setGui

    public void setGui(Gui gui)
    Sets the GUI instance for this controller.
    Parameters:
      `gui` - the GUI instance to set

  - ### setStage2Controller

    public void setStage2Controller(Stage2Controller controller)
    Sets the Stage2Controller instance for this controller.
    Parameters:
      `controller` - the Stage2Controller to set

  - ### enableRotateButton

    public void enableRotateButton()
    Enables the rotate button using Platform.runLater for thread safety.

  - ### hasPendingComponent

    public boolean hasPendingComponent()
    Checks if there is a pending component that hasn't been confirmed.
    Returns:
      true if there's an unconfirmed component, false otherwise

  - ### getPendingComponent

    public Component getPendingComponent()
    Gets the pending component that hasn't been confirmed yet.
    Returns:
      the pending component, or null if none exists

  - ### clearPendingComponent

    public void clearPendingComponent()
    Clears the pending component and resets the image view.

  - ### setStage

    public static void setStage(javafx.stage.Stage s)
    Sets the static stage for this controller.
    Parameters:
      `s` - the stage to set

  - ### getStage

    public static javafx.stage.Stage getStage()
    Gets the static stage for this controller.
    Returns:
      the current stage

  - ### setDisableAll

    public void setDisableAll()
    Disables all interactive buttons in the view.

  - ### activateAll

    public void activateAll()
    Enables all interactive buttons in the view.

  - ### resetImage

    public void resetImage()
    Resets the component image rotation to 0 degrees.

  - ### finishComponentError

    public void finishComponentError(String message)
    Displays an error message when component placement fails.
    Parameters:
      `message` - the error message to display