Class GUI

java.lang.Object
javafx.application.Application
it.polimi.ingsw.Client.GUI

public class GUI extends javafx.application.Application
This class define game's GUI
  • Nested Class Summary

    Nested classes/interfaces inherited from class javafx.application.Application

    javafx.application.Application.Parameters
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Menu's lock
    Identifier's lock
    Login's lock
    Move's lock
    Scoreboard's lock
    private final int
    Board cells' dimension
    private final double
    Board's dimension
    private final ArrayList<javafx.scene.layout.HBox>
    Board rows' pointers
    private static final ArrayList<ArrayList<CellDataModel>>
    Board cells' pointers
    private final double
    Border's dimension value
    private final javafx.scene.layout.BorderWidths
    Border's dimension
    private final double
    CGC points card's resolution
    private final double
    Common goal card's width resolution
    private final double
    Common goal card's height resolution
    private static javafx.scene.Scene
    Credits' scene
    private static final double
    End game card's resolution
    private static javafx.scene.image.ImageView
    First common goal card available points' ImageView attribute
    private static javafx.scene.image.ImageView
    First common goal card's ImageView attribute
    private static javafx.scene.image.ImageView
    First common goal card points' ImageView attribute
    private static String
    Game'ID
    private final int
    Game's width resolution
    private final int
    Game's height resolution
    private static javafx.scene.Scene
    Game's scene
    private static boolean
    Attribute that allow or not shelf's columns selection
    private static javafx.scene.Scene
    Loading's scene
    private static final int
    Game's login width resolution
    private static final int
    Game's login height resolution
    private static javafx.scene.Scene
    Login's scene
    private final int
    Game's menu' width resolution
    private final int
    Game's menu' height resolution
    private static javafx.scene.Scene
    Main menu's scene
    private static javafx.stage.Stage
    Game's main stage
    private static boolean
    Valued to true if the client is joining a new match
    private static String
    Player's nickname
    private static javafx.scene.text.Text
    Player's nickname Text attribute
    private static String
    Game's number of players
    private static javafx.scene.text.Text
    Attribute that indicate the textArea to insert player's number
    private static javafx.scene.control.TextArea
    TextArea used to insert number of players
    private static javafx.scene.image.ImageView
    Personal goal card ImageView attribute
    private final double
    Personal goal card's resolution
    private static final ArrayList<ArrayList<Integer>>
    Support array with board cell's position
    private static javafx.scene.layout.AnchorPane
    Game rootPane's attribute
    private static javafx.scene.layout.AnchorPane
    ScoreBoard rootPane's attribute
    private static javafx.scene.Scene
    Scoreboard's scene
    private final double
    Score card's resolution
    private static javafx.scene.image.ImageView
    Second common goal card available points' ImageView attribute
    private static javafx.scene.image.ImageView
    Second common goal card's ImageView attribute
    private static javafx.scene.image.ImageView
    Second common goal card points' ImageView attribute
    private static ArrayList<CellDataModel>
    Selected cells' pointers attribute
    private static int
    Selected column's number
    private final int
    Shelf cells' dimension
    private final ArrayList<javafx.scene.layout.VBox>
    Shelf columns' pointers
    private static final ArrayList<ArrayList<javafx.scene.image.ImageView>>
    Shelf cells' pointers
    private final double
    Shelf's dimension
    private static List<Integer>
    Selected cells' x positions
    private static List<Integer>
    Selected cells' y positions
    private static final javafx.scene.text.Text
    Attribute that indicate if is player's turn

    Fields inherited from class javafx.application.Application

    STYLESHEET_CASPIAN, STYLESHEET_MODENA
  • Constructor Summary

    Constructors
    Constructor
    Description
    GUI()
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
    This method defines board cell's events
    private void
    This method builds the board's GUI
    private void
    This method builds board grid's GUI
    private void
    This method instantiates board cells' positions
    private void
    This method builds shelf's cells
    private void
    This method builds common goal cards' GUI
    private void
    This method builds cgc points cards' GUI
    private void
    buildCredits(javafx.scene.layout.AnchorPane rootPane)
    This method builds credits' GUI
    static void
    This method builds end game card's GUI
    private void
    This method builds first CGC available points' GUI
    private void
    This method builds game button's GUI
    private static void
    buildLoading(javafx.scene.layout.AnchorPane rootPane)
    This method builds loading scene's GUI
    private void
    buildLogin(javafx.scene.layout.AnchorPane rootPane)
    This method builds login's GUI
    private void
    buildMenu(javafx.scene.layout.AnchorPane rootPane)
    This method builds game menu's GUI
    private void
    This method builds nickname's GUI
    private void
    This method builds personal goal card's GUI
    private void
    This method builds board's cells
    static void
    This method build score board's GUI
    private void
    This method builds second CGC available points' GUI
    private void
    This method builds the shelf's GUI
    private void
    This method builds shelf grid's GUI
    private boolean
    This method makes identifier input's checks
    private boolean
    checkLoginInputs(String nickname, String numOfPlayers)
    This method makes login input's checks
    private void
    creditsButtonEvent(javafx.scene.control.Button creditsButton)
     
    static void
    errorMessage(String errorText)
    This method builds error messages
    static void
    This method builds error messages waiting for user confirmation
    private void
    gameButtonsEvents(javafx.scene.control.Button exitButton)
    This method defines game buttons' events
    static String
    Getter method for the game's ID
    static String
    Getter method for player's nickname
    static String
    Getter method for game's number of players
    static int
    Getter method for selected column
    static List<Integer>
    Getter method for x selected cells coordinates
    static List<Integer>
    Getter method for x selected cells coordinates
    static void
    This method builds information messages
    private void
    loginButtonEvent(javafx.scene.control.Button connectOrStartButton, javafx.scene.control.Button gobackButton, javafx.scene.control.Button confirmIDButton, javafx.scene.control.TextArea gameIDTextArea, javafx.scene.control.TextArea playerNickTextArea)
    This method defines login buttons' events
    static void
    main(String[] args)
    Launch GUI
    private void
    mainMenuButtonsEvents(javafx.scene.control.Button startGameButton, javafx.scene.control.Button creditsButton, javafx.scene.control.Button closeGameButton)
    This method defines main menu buttons' events
    static void
    This method cleans the insertion's attributes
    private static void
    scoreboardButtonEvent(javafx.scene.control.Button gobackButton)
    This method defines score board button's events
    static void
    setMyTurn(boolean myTurn)
    Setter method for boolean attribute "myTurn"
    static void
    setNewMatch(boolean isVisible)
    Sets visibility of nickname/number of players text areas
    static void
    Setter method for nickname's TextArea attribute
    static void
    This method changes game's current scene
    private void
    shelfGridEvents(javafx.scene.layout.VBox shelfColumn0, javafx.scene.layout.VBox shelfColumn1, javafx.scene.layout.VBox shelfColumn2, javafx.scene.layout.VBox shelfColumn3, javafx.scene.layout.VBox shelfColumn4)
    This method defines shelf columns' events
    void
    start(javafx.stage.Stage stage)
    This method instantiates game's GUI component
    static void
    This method is used to update game's board
    static void
    This method updates common goal cards score's cards
    static void
    This method is used to update common goal cards
    static void
    This method is used to update personal goal cards
    static void
    This method is used to update game's shelf

    Methods inherited from class javafx.application.Application

    getHostServices, getParameters, getUserAgentStylesheet, init, launch, launch, notifyPreloader, setUserAgentStylesheet, stop

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • loginRESX

      private static final int loginRESX
      Game's login width resolution
      See Also:
    • loginRESY

      private static final int loginRESY
      Game's login height resolution
      See Also:
    • egcRES

      private static final double egcRES
      End game card's resolution
      See Also:
    • shelfColumnsCells

      private static final ArrayList<ArrayList<javafx.scene.image.ImageView>> shelfColumnsCells
      Shelf cells' pointers
    • boardRowsCells

      private static final ArrayList<ArrayList<CellDataModel>> boardRowsCells
      Board cells' pointers
    • positions

      private static final ArrayList<ArrayList<Integer>> positions
      Support array with board cell's position
    • yourTurnText

      private static final javafx.scene.text.Text yourTurnText
      Attribute that indicate if is player's turn
    • allowExitMenu

      public static ClassicLock allowExitMenu
      Menu's lock
    • allowLogin

      public static ClassicLock allowLogin
      Login's lock
    • allowMove

      public static ClassicLock allowMove
      Move's lock
    • allowScoreboard

      public static ClassicLock allowScoreboard
      Scoreboard's lock
    • allowIdentifier

      public static ClassicLock allowIdentifier
      Identifier's lock
    • mainStage

      private static javafx.stage.Stage mainStage
      Game's main stage
    • loginScene

      private static javafx.scene.Scene loginScene
      Login's scene
    • creditsScene

      private static javafx.scene.Scene creditsScene
      Credits' scene
    • gameScene

      private static javafx.scene.Scene gameScene
      Game's scene
    • scoreboardScene

      private static javafx.scene.Scene scoreboardScene
      Scoreboard's scene
    • loadingScene

      private static javafx.scene.Scene loadingScene
      Loading's scene
    • secondCGCAvailablePointsImageView

      private static javafx.scene.image.ImageView secondCGCAvailablePointsImageView
      Second common goal card available points' ImageView attribute
    • firstCGCAvailablePointsImageView

      private static javafx.scene.image.ImageView firstCGCAvailablePointsImageView
      First common goal card available points' ImageView attribute
    • firstCGCPImageView

      private static javafx.scene.image.ImageView firstCGCPImageView
      First common goal card points' ImageView attribute
    • secondCGCPImageView

      private static javafx.scene.image.ImageView secondCGCPImageView
      Second common goal card points' ImageView attribute
    • pgcImageView

      private static javafx.scene.image.ImageView pgcImageView
      Personal goal card ImageView attribute
    • firstCGCImageView

      private static javafx.scene.image.ImageView firstCGCImageView
      First common goal card's ImageView attribute
    • secondCGCImageView

      private static javafx.scene.image.ImageView secondCGCImageView
      Second common goal card's ImageView attribute
    • sbRootPane

      private static javafx.scene.layout.AnchorPane sbRootPane
      ScoreBoard rootPane's attribute
    • rootPane

      private static javafx.scene.layout.AnchorPane rootPane
      Game rootPane's attribute
    • nicknameText

      private static javafx.scene.text.Text nicknameText
      Player's nickname Text attribute
    • numPlayer

      private static javafx.scene.text.Text numPlayer
      Attribute that indicate the textArea to insert player's number
    • numPlayerTextArea

      private static javafx.scene.control.TextArea numPlayerTextArea
      TextArea used to insert number of players
    • selectedCells

      private static ArrayList<CellDataModel> selectedCells
      Selected cells' pointers attribute
    • isMyTurn

      private static boolean isMyTurn
      Attribute that allow or not shelf's columns selection
    • selectedColumn

      private static int selectedColumn
      Selected column's number
    • x

      private static List<Integer> x
      Selected cells' x positions
    • y

      private static List<Integer> y
      Selected cells' y positions
    • gameID

      private static String gameID
      Game'ID
    • numOfPlayers

      private static String numOfPlayers
      Game's number of players
    • nickname

      private static String nickname
      Player's nickname
    • newMatch

      private static boolean newMatch
      Valued to true if the client is joining a new match
    • GameRESX

      private final int GameRESX
      Game's width resolution
      See Also:
    • GameRESY

      private final int GameRESY
      Game's height resolution
      See Also:
    • borderDimension

      private final double borderDimension
      Border's dimension value
      See Also:
    • borderWidths

      private final javafx.scene.layout.BorderWidths borderWidths
      Border's dimension
    • boardRES

      private final double boardRES
      Board's dimension
    • shelfRES

      private final double shelfRES
      Shelf's dimension
    • cgcRESX

      private final double cgcRESX
      Common goal card's width resolution
    • cgcRESY

      private final double cgcRESY
      Common goal card's height resolution
    • pgcRES

      private final double pgcRES
      Personal goal card's resolution
    • cgcPointsRES

      private final double cgcPointsRES
      CGC points card's resolution
    • scRES

      private final double scRES
      Score card's resolution
      See Also:
    • shelfColumns

      private final ArrayList<javafx.scene.layout.VBox> shelfColumns
      Shelf columns' pointers
    • shelfCellDim

      private final int shelfCellDim
      Shelf cells' dimension
      See Also:
    • boardRows

      private final ArrayList<javafx.scene.layout.HBox> boardRows
      Board rows' pointers
    • boardCellDim

      private final int boardCellDim
      Board cells' dimension
      See Also:
  • Constructor Details

    • GUI

      public GUI()
  • Method Details

    • buildEndGameCard

      public static void buildEndGameCard()
      This method builds end game card's GUI
    • resetSelection

      public static void resetSelection()
      This method cleans the insertion's attributes
    • setNewMatch

      public static void setNewMatch(boolean isVisible)
      Sets visibility of nickname/number of players text areas
      Parameters:
      isVisible - to turn visibility on
    • buildScoreBoard

      public static void buildScoreBoard(Map<String,Integer> scoreboard)
      This method build score board's GUI
      Parameters:
      scoreboard - map received from the server
    • scoreboardButtonEvent

      private static void scoreboardButtonEvent(javafx.scene.control.Button gobackButton)
      This method defines score board button's events
      Parameters:
      gobackButton - button
    • buildLoading

      private static void buildLoading(javafx.scene.layout.AnchorPane rootPane)
      This method builds loading scene's GUI
      Parameters:
      rootPane - root AnchorPane
    • errorMessage

      public static void errorMessage(String errorText)
      This method builds error messages
      Parameters:
      errorText - text to visualize
    • errorMessageConfirm

      public static void errorMessageConfirm(String errorText)
      This method builds error messages waiting for user confirmation
      Parameters:
      errorText - text to visualize
    • infoMessage

      public static void infoMessage(String mexText)
      This method builds information messages
      Parameters:
      mexText - text to visualize
    • updateBoard

      public static void updateBoard(BoardInterface board) throws Exception
      This method is used to update game's board
      Parameters:
      board - game's board
      Throws:
      Exception - related to Model management
    • updateShelf

      public static void updateShelf(ShelfInterface shelf)
      This method is used to update game's shelf
      Parameters:
      shelf - game's shelf
    • updatePersonalGoalCard

      public static void updatePersonalGoalCard(PersonalGoalCardInterface pgCard) throws RemoteException
      This method is used to update personal goal cards
      Parameters:
      pgCard - game's personal goal card
      Throws:
      RemoteException - related to server
    • updateCommonGoalCards

      public static void updateCommonGoalCards(CommonGoalCardInterface firstCGC, CommonGoalCardInterface secondCGC) throws RemoteException
      This method is used to update common goal cards
      Parameters:
      firstCGC - game's first common goal card
      secondCGC - game's second common goal card
      Throws:
      RemoteException - related to server
    • updateCGCScoredPoints

      public static void updateCGCScoredPoints(ArrayList<Integer> scoreCards) throws RemoteException
      This method updates common goal cards score's cards
      Parameters:
      scoreCards - List with gained points
      Throws:
      RemoteException - related to server
    • setScene

      public static void setScene(Scenes scene)
      This method changes game's current scene
      Parameters:
      scene - scene to set
    • getGameID

      public static String getGameID()
      Getter method for the game's ID
      Returns:
      game's ID
    • getNumOfPlayers

      public static String getNumOfPlayers()
      Getter method for game's number of players
      Returns:
      game's number of players
    • getNickname

      public static String getNickname()
      Getter method for player's nickname
      Returns:
      player's nickname
    • getSelectedColumn

      public static int getSelectedColumn()
      Getter method for selected column
      Returns:
      selected column
    • getX

      public static List<Integer> getX()
      Getter method for x selected cells coordinates
      Returns:
      x coordinates
    • getY

      public static List<Integer> getY()
      Getter method for x selected cells coordinates
      Returns:
      y coordinates
    • setMyTurn

      public static void setMyTurn(boolean myTurn)
      Setter method for boolean attribute "myTurn"
      Parameters:
      myTurn - value to set
    • setNicknameText

      public static void setNicknameText(String text)
      Setter method for nickname's TextArea attribute
      Parameters:
      text - text to set
    • main

      public static void main(String[] args)
      Launch GUI
      Parameters:
      args - arguments
    • start

      public void start(javafx.stage.Stage stage)
      This method instantiates game's GUI component
      Specified by:
      start in class javafx.application.Application
      Parameters:
      stage - game's stage
    • buildBoard

      private void buildBoard()
      This method builds the board's GUI
    • buildShelf

      private void buildShelf()
      This method builds the shelf's GUI
    • buildCommonGoalCards

      private void buildCommonGoalCards()
      This method builds common goal cards' GUI
    • buildPersonalGoalCard

      private void buildPersonalGoalCard()
      This method builds personal goal card's GUI
    • buildCommonGoalCardsPointCards

      private void buildCommonGoalCardsPointCards()
      This method builds cgc points cards' GUI
    • buildFirstCGCAvailablePoints

      private void buildFirstCGCAvailablePoints()
      This method builds first CGC available points' GUI
    • buildSecondCGCAvailablePoints

      private void buildSecondCGCAvailablePoints()
      This method builds second CGC available points' GUI
    • buildGameButtons

      private void buildGameButtons()
      This method builds game button's GUI
    • buildNickname

      private void buildNickname()
      This method builds nickname's GUI
    • buildShelfGrid

      private void buildShelfGrid()
      This method builds shelf grid's GUI
    • buildBoardGrid

      private void buildBoardGrid()
      This method builds board grid's GUI
    • buildBoardPositions

      private void buildBoardPositions()
      This method instantiates board cells' positions
    • buildRowsCells

      private void buildRowsCells()
      This method builds board's cells
    • buildColumCells

      private void buildColumCells()
      This method builds shelf's cells
    • boardCellEvents

      private void boardCellEvents(CellDataModel cell)
      This method defines board cell's events
      Parameters:
      cell - for which to define effects
    • shelfGridEvents

      private void shelfGridEvents(javafx.scene.layout.VBox shelfColumn0, javafx.scene.layout.VBox shelfColumn1, javafx.scene.layout.VBox shelfColumn2, javafx.scene.layout.VBox shelfColumn3, javafx.scene.layout.VBox shelfColumn4)
      This method defines shelf columns' events
      Parameters:
      shelfColumn0 - first column
      shelfColumn1 - second column
      shelfColumn2 - third column
      shelfColumn3 - fourth column
      shelfColumn4 - fifth column
    • gameButtonsEvents

      private void gameButtonsEvents(javafx.scene.control.Button exitButton)
      This method defines game buttons' events
      Parameters:
      exitButton - button
    • buildMenu

      private void buildMenu(javafx.scene.layout.AnchorPane rootPane)
      This method builds game menu's GUI
      Parameters:
      rootPane - root AnchorPane
    • buildLogin

      private void buildLogin(javafx.scene.layout.AnchorPane rootPane)
      This method builds login's GUI
      Parameters:
      rootPane - root AnchorPane
    • buildCredits

      private void buildCredits(javafx.scene.layout.AnchorPane rootPane)
      This method builds credits' GUI
      Parameters:
      rootPane - root AnchorPane
    • creditsButtonEvent

      private void creditsButtonEvent(javafx.scene.control.Button creditsButton)
    • loginButtonEvent

      private void loginButtonEvent(javafx.scene.control.Button connectOrStartButton, javafx.scene.control.Button gobackButton, javafx.scene.control.Button confirmIDButton, javafx.scene.control.TextArea gameIDTextArea, javafx.scene.control.TextArea playerNickTextArea)
      This method defines login buttons' events
      Parameters:
      connectOrStartButton - button
      gobackButton - button
      gameIDTextArea - button
      playerNickTextArea - button
    • checkLoginInputs

      private boolean checkLoginInputs(String nickname, String numOfPlayers)
      This method makes login input's checks
      Parameters:
      nickname - player's nickname
      numOfPlayers - game's number of players
      Returns:
      true if OK, false if KO
    • checkLoginID

      private boolean checkLoginID(String gameID)
      This method makes identifier input's checks
      Parameters:
      gameID - game's identifier
      Returns:
      true if OK, false if KO