Class HexagonMap
- java.lang.Object
-
- de.gsi.chart.renderer.spi.hexagon.HexagonMap
-
public class HexagonMap extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classHexagonMap.Direction
-
Field Summary
Fields Modifier and Type Field Description intgraphicsXpaddingintgraphicsYpaddinginthexagonSizejava.util.List<HexagonCallback>onHexClickedCallbackjava.util.List<HexagonCallback>onHexEnteredCallbackjava.util.List<HexagonCallback>onHexExitCallbackbooleanrenderCoordinates
-
Constructor Summary
Constructors Constructor Description HexagonMap(int hexagonSize)Creates an empty HexagonMapHexagonMap(int hexagonSize, javafx.scene.image.Image image, int mapWidthInHexes)Generates a HexagonMap from an ImageHexagonMap(int hexagonSize, javafx.scene.image.Image image, int mapWidthInHexes, IHexagonCreator hexagonCreator)Generates a HexagonMap from an Image
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HexagonaddHexagon(Hexagon hexagon)Add a Hexagon to the HexagonMapjava.util.Collection<Hexagon>getAllHexagons()intgetGraphicsHexagonHeight()doublegetGraphicsHorizontalDistanceBetweenHexagons()doublegetGraphicsverticalDistanceBetweenHexagons()HexagongetHexagon(int q, int r)Retrieves the Hexagon at the specified position (axial coordinates)HexagongetHexagon(GridPosition position)HexagongetHexagonByCube(int x, int y, int z)HexagongetHexagonContainingPixel(int x, int y)java.util.Optional<java.lang.Double>getImageMapHorizontalRelation()If the map was created from an Image, this will return the horizontal pixel relation between the image and the generated mapjava.util.Optional<java.lang.Double>getImageMapVerticalRelation()If the map was created from an Image, this will return the vertical pixel relation between the image and the generated mapdoublegetPaddingX()doublegetPaddingY()voidregisterCanvasMouseLiner(javafx.scene.canvas.Canvas canvas)voidremoveHexagon(Hexagon hexagon)Removes a Hexagon from the HexagonMapvoidrender(javafx.scene.canvas.Canvas canvas)Renders the HexagonMapvoidrender(javafx.scene.Group group)Renders the HexagonMapvoidrenderContour(javafx.scene.canvas.Canvas canvas)Renders the contours of the HexagonMapvoidsetOnHexagonClickedCallback(HexagonCallback callback)A callback when the user clicks on a HexagonvoidsetOnHexagonEnteredCallback(HexagonCallback callback)A callback when the user moves into a HexagonvoidsetOnHexagonExitCallback(HexagonCallback callback)A callback when the user moves out of a HexagonvoidsetPadding(int left, int top)Tells the renderer that you want some space before the HexagonMap is renderedvoidsetRenderCoordinates(boolean b)If you want the coordinates rendered on the screenvoidsetRenderFont(javafx.scene.text.Font font)Sets the font used to draw the hexagon positions
-
-
-
Field Detail
-
hexagonSize
public final int hexagonSize
-
graphicsXpadding
public int graphicsXpadding
-
graphicsYpadding
public int graphicsYpadding
-
renderCoordinates
public boolean renderCoordinates
-
onHexClickedCallback
public java.util.List<HexagonCallback> onHexClickedCallback
-
onHexEnteredCallback
public java.util.List<HexagonCallback> onHexEnteredCallback
-
onHexExitCallback
public java.util.List<HexagonCallback> onHexExitCallback
-
-
Constructor Detail
-
HexagonMap
public HexagonMap(int hexagonSize)
Creates an empty HexagonMap- Parameters:
hexagonSize- the distance between the center and one corner
-
HexagonMap
public HexagonMap(int hexagonSize, javafx.scene.image.Image image, int mapWidthInHexes)Generates a HexagonMap from an Image- Parameters:
hexagonSize- the distance between the center and one cornerimage- an Image which will be used to generate a HexagonMapmapWidthInHexes- the number of hexagons on the x-axis
-
HexagonMap
public HexagonMap(int hexagonSize, javafx.scene.image.Image image, int mapWidthInHexes, IHexagonCreator hexagonCreator)Generates a HexagonMap from an Image- Parameters:
hexagonSize- the distance between the center and one cornerimage- an Image which will be used to generate a HexagonMapmapWidthInHexes- the number of hexagons on the x-axishexagonCreator- a class implementing IHexagonCreator. This is how you decide HOW the HexagonMap should be generated from the Image. In it's most basic form:public void createHexagon(int q, int r, Color imagePixelColor, HexagonMap map) { Hexagon h = new Hexagon(q, r); h.setBackgroundColor(imagePixelColor); map.addHexagon(h); }
-
-
Method Detail
-
addHexagon
public Hexagon addHexagon(Hexagon hexagon)
Add a Hexagon to the HexagonMap- Parameters:
hexagon- new hexagon- Returns:
- the same hexagon
-
getAllHexagons
public java.util.Collection<Hexagon> getAllHexagons()
- Returns:
- all Hexagons that has been added to the map
-
getGraphicsHexagonHeight
public int getGraphicsHexagonHeight()
-
getGraphicsHorizontalDistanceBetweenHexagons
public double getGraphicsHorizontalDistanceBetweenHexagons()
-
getGraphicsverticalDistanceBetweenHexagons
public double getGraphicsverticalDistanceBetweenHexagons()
-
getHexagon
public Hexagon getHexagon(GridPosition position)
-
getHexagon
public Hexagon getHexagon(int q, int r)
Retrieves the Hexagon at the specified position (axial coordinates)- Parameters:
q- the Q coordinater- the R coordinate- Returns:
- the Hexagon if there is no Hexagon at the specified position
-
getHexagonByCube
public Hexagon getHexagonByCube(int x, int y, int z)
-
getHexagonContainingPixel
public Hexagon getHexagonContainingPixel(int x, int y)
- Parameters:
x- carthesian x coordinatey- carthesian y coordinate- Returns:
- the hexagon that is rendered on a specific position on the screen if there is no Hexagon at the specified position
-
getImageMapHorizontalRelation
public java.util.Optional<java.lang.Double> getImageMapHorizontalRelation()
If the map was created from an Image, this will return the horizontal pixel relation between the image and the generated map- Returns:
- scaling factor between pixel and grid
-
getImageMapVerticalRelation
public java.util.Optional<java.lang.Double> getImageMapVerticalRelation()
If the map was created from an Image, this will return the vertical pixel relation between the image and the generated map- Returns:
- scaling factor between pixel and grid
-
getPaddingX
public double getPaddingX()
-
getPaddingY
public double getPaddingY()
-
registerCanvasMouseLiner
public void registerCanvasMouseLiner(javafx.scene.canvas.Canvas canvas)
-
removeHexagon
public void removeHexagon(Hexagon hexagon)
Removes a Hexagon from the HexagonMap- Parameters:
hexagon- to be removed
-
render
public void render(javafx.scene.canvas.Canvas canvas)
Renders the HexagonMap- Parameters:
canvas- the JaxaFX Group where all the hexagons should be rendered
-
render
public void render(javafx.scene.Group group)
Renders the HexagonMap- Parameters:
group- the JaxaFX Group where all the hexagons should be rendered
-
renderContour
public void renderContour(javafx.scene.canvas.Canvas canvas)
Renders the contours of the HexagonMap- Parameters:
canvas- the JaxaFX Group where all the hexagons should be rendered
-
setOnHexagonClickedCallback
public void setOnHexagonClickedCallback(HexagonCallback callback)
A callback when the user clicks on a Hexagon- Parameters:
callback- call-back function handler
-
setOnHexagonEnteredCallback
public void setOnHexagonEnteredCallback(HexagonCallback callback)
A callback when the user moves into a Hexagon- Parameters:
callback- call-back function handler
-
setOnHexagonExitCallback
public void setOnHexagonExitCallback(HexagonCallback callback)
A callback when the user moves out of a Hexagon- Parameters:
callback- call-back function handler
-
setPadding
public void setPadding(int left, int top)Tells the renderer that you want some space before the HexagonMap is rendered- Parameters:
left- padding margin lefttop- padding margin right
-
setRenderCoordinates
public void setRenderCoordinates(boolean b)
If you want the coordinates rendered on the screen- Parameters:
b- true: render coordinates
-
setRenderFont
public void setRenderFont(javafx.scene.text.Font font)
Sets the font used to draw the hexagon positions- Parameters:
font- for rendering the hex positions
-
-