public class GuiHelper extends Object
Constructor and Description |
---|
GuiHelper() |
Modifier and Type | Method and Description |
---|---|
void |
addIcon(javafx.stage.Stage stage)
adds an icon to a stage
|
TileImageView |
addTile(int position,
int tileId,
Rotation rotation,
TileGridPane tileGridPane)
adds a TileImageView to a position on a given pane.
|
TileImageView |
addTile(int position,
Tile tile,
TileGridPane tileGridPane)
adds a TileImageView to a position on a given pane.
|
TileImageView |
addTile(Position position,
int tileId,
Rotation rotation,
TileGridPane tileGridPane)
adds a TileImageView to a position on a given pane.
|
TileImageView |
addTile(Position position,
Tile tile,
TileGridPane tileGridPane)
adds a tile to a position on a given pane.
|
void |
bindTileScaleToPane(TileImageView tileImageView,
TileGridPane tileGridPane)
binds the height and width properties of a
TileImageView so they fit the cell size |
void |
calculateAbsoluteLayout(TileGridPane... tileGridPanes)
Calculates and sets the absolute sizes of the padding, gaps, and cells for a given amount of TileGridPanes
|
void |
calculateRowCountAndColCountFromSize(TileGridPane tileGridPane)
When only the amount of elements that need to fit into a
TileGridPane is known,
this method calculates the amount of rows and columns the TileGridPane needs to have to maximize the area of each cell,
based on the height and width the TileGridPane can utilize |
javafx.scene.shape.Rectangle[][] |
fillGridWithEmptyWaypoints(TileGridPane tileGridPane)
fills a given
TileGridPane with rectangles. |
ArrayList<Gate> |
getBorderGatesFromPosition(TileGridPane tileGridPane,
Position position) |
double[] |
getPadding(javafx.scene.layout.GridPane pane)
returns the vertical (TOP + BOTTOM) and horizontal (LEFT + RIGHT) padding of a given
GridPane |
String |
getResourcePath(String path) |
void |
initGridPaneConstraints(TileGridPane tileGridPane)
Sets up the correct height and width of the rows and columns according to their amount for a given TileGridPane
|
void |
removeRectanglesFromTileGridPane(TileGridPane tileGridPane)
removes all
Rectangle s from a given TileGridPane |
void |
removeRowsAndColumnsFromGridPane(javafx.scene.layout.GridPane pane)
removes all rows and columns for a given
GridPane . |
void |
replaceStyles(javafx.scene.Node node,
String[] oldStyles,
String[] newStyles)
replaces an array of styles with another one
|
void |
rotateTileImageViewClockWise(TileImageView tileImageView)
rotates a given
TileImageView by 90 degrees |
void |
setCssToScene(javafx.scene.Scene scene) |
void |
setPosOnCell(javafx.scene.Node node,
TileGridPane tileGridPane,
Position position,
Gate gate,
double offsetParallel,
double offsetOrthogonal)
places a node in a certain alignment to a gate in a cell of a given
TileGridPane |
void |
setRotationOfTileImageView(javafx.scene.image.ImageView tileImageView,
Rotation rotation)
sets the rotation of an ImageView
|
public void calculateRowCountAndColCountFromSize(TileGridPane tileGridPane)
TileGridPane
is known,
this method calculates the amount of rows and columns the TileGridPane
needs to have to maximize the area of each cell,
based on the height and width the TileGridPane can utilizetileGridPane
- method calculates for this TileGridPane
public void initGridPaneConstraints(TileGridPane tileGridPane) throws Exception
tileGridPane
- the TileGridPane that is to be adjustedException
- if the pane has a width or height of '0'public void calculateAbsoluteLayout(TileGridPane... tileGridPanes)
tileGridPanes
- any number of TileGridPanes to use in the calculationpublic javafx.scene.shape.Rectangle[][] fillGridWithEmptyWaypoints(TileGridPane tileGridPane)
TileGridPane
with rectangles. Each rectangle will be placed in an own cell and has the same size as one.tileGridPane
- the TileGridPane to be filledpublic TileImageView addTile(Position position, int tileId, Rotation rotation, TileGridPane tileGridPane) throws Exception
position
- the position where the tile will be placed.tileId
- the tile's IDrotation
- the Rotation
of the placed tiletileGridPane
- the TileGridPane
on which the tile will be placedException
- if position doesn't exist one the panepublic TileImageView addTile(int position, int tileId, Rotation rotation, TileGridPane tileGridPane) throws Exception
position
- the position where the tile will be placed.tileId
- the tile's IDrotation
- the Rotation
of the placed tiletileGridPane
- the TileGridPane
on which the tile will be placedException
- if position doesn't exist one the panepublic TileImageView addTile(int position, Tile tile, TileGridPane tileGridPane) throws Exception
position
- the position where the tile will be placed.
This is not of the type Position
, but rather an index that is applied by moving through the rows downwardstile
- that should be added to a positiontileGridPane
- the TileGridPane
on which the tile will be placedException
- if position doesn't exist one the panepublic TileImageView addTile(Position position, Tile tile, TileGridPane tileGridPane) throws Exception
position
- the Position
where the tile will be placedtile
- that should be addedtileGridPane
- the TileGridPane
where the tile will be placedException
- if position doesn't exist one the panepublic void bindTileScaleToPane(TileImageView tileImageView, TileGridPane tileGridPane)
TileImageView
so they fit the cell sizetileImageView
- the TileImageView
whose size will be boundtileGridPane
- the TileGridPane
where tileImageView is locatedpublic void removeRowsAndColumnsFromGridPane(javafx.scene.layout.GridPane pane)
GridPane
. This needs to be done for every GridPane that is supposed to be dynamically filledpane
- the GridPane
whose rows and columns will be removedpublic void removeRectanglesFromTileGridPane(TileGridPane tileGridPane)
Rectangle
s from a given TileGridPane
tileGridPane
- the TileGridPane
whose Rectangle
s will be removedpublic void rotateTileImageViewClockWise(TileImageView tileImageView)
TileImageView
by 90 degreestileImageView
- the TileImageView
to be rotatedpublic void setRotationOfTileImageView(javafx.scene.image.ImageView tileImageView, Rotation rotation)
tileImageView
- the ImageView to rotate correctlyrotation
- the Rotation to rotate bypublic double[] getPadding(javafx.scene.layout.GridPane pane)
GridPane
pane
- the GridPane
to checkGridPane
as a double[]public void setPosOnCell(javafx.scene.Node node, TileGridPane tileGridPane, Position position, Gate gate, double offsetParallel, double offsetOrthogonal)
TileGridPane
node
- the Node
that will be placedtileGridPane
- the TileGridPane
where the node will be placedposition
- the Position
on the TileGridPane
where the node will be placedgate
- the Gate
to which the node will be alignedoffsetParallel
- the amount of space that the node will be placed alongside the rectangle sideoffsetOrthogonal
- the amount of space that the node will overlap the cellpublic ArrayList<Gate> getBorderGatesFromPosition(TileGridPane tileGridPane, Position position)
public void replaceStyles(javafx.scene.Node node, String[] oldStyles, String[] newStyles)
node
- the Node
that is going to be changedoldStyles
- styles to be removednewStyles
- styles to be addedpublic void setCssToScene(javafx.scene.Scene scene) throws IOException
IOException
public String getResourcePath(String path) throws IOException
path
- the path inside the graphical folderIOException
- if the file name can't be foundpublic void addIcon(javafx.stage.Stage stage)
stage
- the given Stage
Copyright © 2017 smarTen. All rights reserved.