Class DialogUtil
- java.lang.Object
-
- ch.sahits.game.openpatrician.display.dialog.service.DialogUtil
-
public class DialogUtil extends java.lang.Object
- Author:
- Andi Hotz, (c) Sahits GmbH, 2013 Created on Dec 20, 2013
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
DialogUtil.SailorOnShipBinding
Sailors on ship binding with min and max.private class
DialogUtil.SimpleSailorOnShipBinding
Sailors on ship binding.
-
Field Summary
Fields Modifier and Type Field Description private javafx.scene.image.Image
anchor
private JavaFXUtils
fxUtils
private SelectiveCachableXMLImageLoader
imageLoader
private Locale
locale
private org.springframework.context.MessageSource
messageSource
private javafx.scene.image.Image
repair
private javafx.scene.image.Image
sail
private ShipService
shipService
private DecoratedTextFactory
textFactory
private ModelTranslations
translations
private org.springframework.oxm.Unmarshaller
unmarshaller
private ch.sahits.game.openpatrician.data.xmlmodel.weapon.WeaponLocations
weaponLocations
-
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 thechildNode
horizontally centered within a Dialog.javafx.scene.layout.Pane
center(javafx.scene.image.ImageView childNode)
Create an element that will layout thechildNode
horizontally centered within a Dialog.javafx.scene.Group
center(javafx.scene.layout.Pane childNode)
Create an element that will layout thechildNode
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 byid
from the parent and return the index.javafx.scene.layout.Pane
right(javafx.scene.control.Control childNode)
Create an element that will layout thechildNode
at the right dialog content border.javafx.scene.Group
right(javafx.scene.layout.Pane childNode)
Create an element that will layout thechildNode
at the right dialog content border.
-
-
-
Field Detail
-
fxUtils
@Autowired private JavaFXUtils fxUtils
-
shipService
@Autowired private ShipService shipService
-
locale
@Autowired private Locale locale
-
messageSource
@Autowired private org.springframework.context.MessageSource messageSource
-
textFactory
@Autowired private DecoratedTextFactory textFactory
-
translations
@Autowired private ModelTranslations translations
-
imageLoader
@Autowired @Qualifier("xmlImageLoader") private SelectiveCachableXMLImageLoader imageLoader
-
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
-
-
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 selectioncurrentShip
- 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 selectioncurrentShip
- 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 inships
.
+----------+-------------+-------------+-------------+-----------+ | 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 thechildNode
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 thechildNode
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 thechildNode
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 thechildNode
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 thechildNode
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 byid
from the parent and return the index.- Parameters:
parent
- containing the nodeid
- 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.
-
-