Class DialogUtil


  • public class DialogUtil
    extends java.lang.Object
    Author:
    Andi Hotz, (c) Sahits GmbH, 2013 Created on Dec 20, 2013
    • Constructor Summary

      Constructors 
      Constructor Description
      DialogUtil()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      javafx.scene.layout.Pane center​(javafx.scene.control.Control childNode)
      Create an element that will layout the childNode horizontally centered within a Dialog.
      javafx.scene.layout.Pane center​(javafx.scene.image.ImageView childNode)
      Create an element that will layout the childNode horizontally centered within a Dialog.
      javafx.scene.Group center​(javafx.scene.layout.Pane childNode)
      Create an element that will layout the childNode horizontally centered within a Dialog.
      javafx.scene.layout.GridPane createGridPaneFromModel​(Table model)
      Create a grid pane based on a model.
      javafx.event.EventHandler<javafx.scene.input.MouseEvent> createNextActionForShips​(javafx.collections.ObservableList<IShip> ships, javafx.beans.property.ObjectProperty<IShip> currentShip)
      Navigate to the next ship in the catalogue.
      javafx.event.EventHandler<javafx.scene.input.MouseEvent> createPreviousActionForShips​(javafx.collections.ObservableList<IShip> ships, javafx.beans.property.ObjectProperty<IShip> currentShip)
      Navigate to the previous ship in the catalogue.
      javafx.scene.layout.GridPane createShipInfoOnThreeLines​(javafx.beans.property.ObjectProperty<IShip> currentShip, boolean withShipName, int maxWidth)
      Create the grid pane for the ship information on three lines.
      javafx.scene.layout.GridPane createShipSelection3LinesForShips​(javafx.collections.ObservableList<IShip> ships, javafx.beans.property.ObjectProperty<IShip> currentShip)
      Create the grid pane for the ship selection on three lines.
      javafx.scene.layout.Pane createShipWeaponDisplay​(IShip ship)
      Create the weapon display with all weapons and place holders.
      javafx.scene.Node createVerticalSpacer​(int heigth)
      Create a Node that forces vertical spacing.
      private javafx.beans.property.ObjectProperty<DecoratedText> createWeaponStrength​(IShip currentShip)  
      javafx.beans.binding.BooleanBinding enableShipCatalogueForShips​(javafx.collections.ObservableList<IShip> ships)
      Boolean binding for the navigation enabling of the ships cataloque.
      private javafx.scene.image.ImageView getShipDeck​(EShipType shipType)  
      private javafx.scene.image.ImageView getShipWeapon​(IWeaponSlot weaponSlot)  
      private ch.sahits.game.openpatrician.data.xmlmodel.weapon.BasicSlot getSlotModel​(int id)  
      private javax.xml.transform.Source getSourceFromFile​(java.lang.String fileName)  
      javafx.scene.image.Image getStatusIcon​(EShipTravelState travelState)
      Retrieve the appropriate icon for the traveling state.
      private javafx.scene.image.ImageView getWeaponPlaceHolder​(ESide side)  
      private void initialize()  
      int removeById​(javafx.scene.layout.Pane parent, java.lang.String id)
      Remove a node identified by id from the parent and return the index.
      javafx.scene.layout.Pane right​(javafx.scene.control.Control childNode)
      Create an element that will layout the childNode at the right dialog content border.
      javafx.scene.Group right​(javafx.scene.layout.Pane childNode)
      Create an element that will layout the childNode at the right dialog content border.
      • Methods inherited from class java.lang.Object

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

      • shipService

        @Autowired
        private ShipService shipService
      • locale

        @Autowired
        private Locale locale
      • messageSource

        @Autowired
        private org.springframework.context.MessageSource messageSource
      • unmarshaller

        @Autowired
        @Qualifier("jaxb2XmlModelMarshallerWeapon")
        private org.springframework.oxm.Unmarshaller unmarshaller
      • weaponLocations

        private ch.sahits.game.openpatrician.data.xmlmodel.weapon.WeaponLocations weaponLocations
      • anchor

        private javafx.scene.image.Image anchor
      • sail

        private javafx.scene.image.Image sail
      • repair

        private javafx.scene.image.Image repair
    • Constructor Detail

      • DialogUtil

        public DialogUtil()
    • Method Detail

      • initialize

        @PostConstruct
        private void initialize()
      • getSourceFromFile

        private javax.xml.transform.Source getSourceFromFile​(java.lang.String fileName)
      • enableShipCatalogueForShips

        public javafx.beans.binding.BooleanBinding enableShipCatalogueForShips​(javafx.collections.ObservableList<IShip> ships)
        Boolean binding for the navigation enabling of the ships cataloque. Only the ships are considered (convoys are excluded)
        Parameters:
        ships - to be observed.
        Returns:
        binding.
      • createNextActionForShips

        public javafx.event.EventHandler<javafx.scene.input.MouseEvent> createNextActionForShips​(javafx.collections.ObservableList<IShip> ships,
                                                                                                 javafx.beans.property.ObjectProperty<IShip> currentShip)
        Navigate to the next ship in the catalogue. Only the ships are considered (convoys are excluded)
        Parameters:
        ships - in the selection
        currentShip - current ship
        Returns:
        Event handler for the navigation.
      • createPreviousActionForShips

        public javafx.event.EventHandler<javafx.scene.input.MouseEvent> createPreviousActionForShips​(javafx.collections.ObservableList<IShip> ships,
                                                                                                     javafx.beans.property.ObjectProperty<IShip> currentShip)
        Navigate to the previous ship in the catalogue. Only the ships are considered (convoys are excluded)
        Parameters:
        ships - in the selection
        currentShip - current ship
        Returns:
        Event handler for the navigation.
      • createGridPaneFromModel

        public javafx.scene.layout.GridPane createGridPaneFromModel​(Table model)
        Create a grid pane based on a model.
        Parameters:
        model - base model
        Returns:
        grid pane
      • createShipSelection3LinesForShips

        public javafx.scene.layout.GridPane createShipSelection3LinesForShips​(javafx.collections.ObservableList<IShip> ships,
                                                                              javafx.beans.property.ObjectProperty<IShip> currentShip)
        Create the grid pane for the ship selection on three lines. The currently selected ship is the first in ships.
             +----------+-------------+-------------+-------------+-----------+
             |                      ship type and name                        |
             |prevShip  | weapon icon | health icon | sailor icon |   nextShip|
             |          |weapon amount|   health    | no. sailors |           |
             +----------+-------------+-------------+-------------+-----------+
         
        Parameters:
        ships - observable list of ships through which is to be navigated.
        currentShip - container to store the currently selected ship. The value will be set as par of the execution.
        Returns:
        GridPane displaying ship details like weapon strength, health and crew compliment as well as navigation capabilities through the list of ships.
      • createShipInfoOnThreeLines

        public javafx.scene.layout.GridPane createShipInfoOnThreeLines​(javafx.beans.property.ObjectProperty<IShip> currentShip,
                                                                       boolean withShipName,
                                                                       int maxWidth)
        Create the grid pane for the ship information on three lines.
             +------------+-------------+-------------+-------------+
             | ship type and name                                   | optional, triggered by withShipName
             | knot icon  | weapon icon | health icon | sailor icon |
             |            |weapon amount|   health    | no. sailors |
             +------------+-------------+-------------+-------------+
         
        Parameters:
        currentShip - container to store the currently selected ship. The value will be set as par of the execution.
        withShipName - flag indicating if the first row should be included.
        maxWidth - maximum width of the table
        Returns:
        GridPane displaying ship details like speed, weapon strength, health and crew compliment.
      • createWeaponStrength

        private javafx.beans.property.ObjectProperty<DecoratedText> createWeaponStrength​(IShip currentShip)
      • center

        public javafx.scene.layout.Pane center​(javafx.scene.control.Control childNode)
        Create an element that will layout the childNode horizontally centered within a Dialog.
        Parameters:
        childNode - that should be centered
        Returns:
        wrapping Pane
      • center

        public javafx.scene.layout.Pane center​(javafx.scene.image.ImageView childNode)
        Create an element that will layout the childNode horizontally centered within a Dialog.
        Parameters:
        childNode - that should be centered
        Returns:
        wrapping Pane
      • center

        public javafx.scene.Group center​(javafx.scene.layout.Pane childNode)
        Create an element that will layout the childNode horizontally centered within a Dialog.
        Parameters:
        childNode - that should be centered
        Returns:
        wrapping Pane
      • right

        public javafx.scene.Group right​(javafx.scene.layout.Pane childNode)
        Create an element that will layout the childNode at the right dialog content border.
        Parameters:
        childNode - that should be right aligned.
        Returns:
        wrapping Pane
      • right

        public javafx.scene.layout.Pane right​(javafx.scene.control.Control childNode)
        Create an element that will layout the childNode at the right dialog content border.
        Parameters:
        childNode - that should be right aligned.
        Returns:
        wrapping Pane
      • createVerticalSpacer

        public javafx.scene.Node createVerticalSpacer​(int heigth)
        Create a Node that forces vertical spacing.
        Parameters:
        heigth - of the spacing node.
        Returns:
        Node with specified heigth.
      • removeById

        public int removeById​(javafx.scene.layout.Pane parent,
                              java.lang.String id)
        Remove a node identified by id from the parent and return the index.
        Parameters:
        parent - containing the node
        id - of the id
        Returns:
        index in the children of the removed node within id. If the node cannot be found -1 will be returned.
      • createShipWeaponDisplay

        public javafx.scene.layout.Pane createShipWeaponDisplay​(IShip ship)
        Create the weapon display with all weapons and place holders.
        Parameters:
        ship - for which to create the weapon display
        Returns:
        pane for the weapon display
      • getShipDeck

        private javafx.scene.image.ImageView getShipDeck​(EShipType shipType)
      • getWeaponPlaceHolder

        private javafx.scene.image.ImageView getWeaponPlaceHolder​(ESide side)
      • getShipWeapon

        private javafx.scene.image.ImageView getShipWeapon​(IWeaponSlot weaponSlot)
      • getSlotModel

        private ch.sahits.game.openpatrician.data.xmlmodel.weapon.BasicSlot getSlotModel​(int id)
      • getStatusIcon

        public javafx.scene.image.Image getStatusIcon​(EShipTravelState travelState)
        Retrieve the appropriate icon for the traveling state.
        Parameters:
        travelState - for which to retrieve the icon
        Returns:
        icon.