public class HexagonMap extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
HexagonMap.Direction |
| Modifier and Type | Field and Description |
|---|---|
int |
graphicsXpadding |
int |
graphicsYpadding |
int |
hexagonSize |
List<HexagonCallback> |
onHexClickedCallback |
List<HexagonCallback> |
onHexEnteredCallback |
List<HexagonCallback> |
onHexExitCallback |
boolean |
renderCoordinates |
| Constructor and Description |
|---|
HexagonMap(int hexagonSize)
Creates an empty HexagonMap
|
HexagonMap(int hexagonSize,
Image image,
int mapWidthInHexes)
Generates a HexagonMap from an Image
|
HexagonMap(int hexagonSize,
Image image,
int mapWidthInHexes,
IHexagonCreator hexagonCreator)
Generates a HexagonMap from an Image
|
| Modifier and Type | Method and Description |
|---|---|
Hexagon |
addHexagon(Hexagon hexagon)
Add a Hexagon to the HexagonMap
|
Collection<Hexagon> |
getAllHexagons() |
int |
getGraphicsHexagonHeight() |
double |
getGraphicsHorizontalDistanceBetweenHexagons() |
double |
getGraphicsverticalDistanceBetweenHexagons() |
Hexagon |
getHexagon(GridPosition position) |
Hexagon |
getHexagon(int q,
int r)
Retrieves the Hexagon at the specified position (axial coordinates)
|
Hexagon |
getHexagonByCube(int x,
int y,
int z) |
Hexagon |
getHexagonContainingPixel(int x,
int y) |
Optional<Double> |
getImageMapHorizontalRelation()
If the map was created from an Image, this will return the horizontal pixel relation between the image and the
generated map
|
Optional<Double> |
getImageMapVerticalRelation()
If the map was created from an Image, this will return the vertical pixel relation between the image and the
generated map
|
double |
getPaddingX() |
double |
getPaddingY() |
void |
registerCanvasMouseLiner(Canvas canvas) |
void |
removeHexagon(Hexagon hexagon)
Removes a Hexagon from the HexagonMap
|
void |
render(Canvas canvas)
Renders the HexagonMap
|
void |
render(Group group)
Renders the HexagonMap
|
void |
renderContour(Canvas canvas)
Renders the contours of the HexagonMap
|
void |
setOnHexagonClickedCallback(HexagonCallback callback)
A callback when the user clicks on a Hexagon
|
void |
setOnHexagonEnteredCallback(HexagonCallback callback)
A callback when the user moves into a Hexagon
|
void |
setOnHexagonExitCallback(HexagonCallback callback)
A callback when the user moves out of a Hexagon
|
void |
setPadding(int left,
int top)
Tells the renderer that you want some space before the HexagonMap is rendered
|
void |
setRenderCoordinates(boolean b)
If you want the coordinates rendered on the screen
|
void |
setRenderFont(Font font)
Sets the font used to draw the hexagon positions
|
public final int hexagonSize
public int graphicsXpadding
public int graphicsYpadding
public boolean renderCoordinates
public List<HexagonCallback> onHexClickedCallback
public List<HexagonCallback> onHexEnteredCallback
public List<HexagonCallback> onHexExitCallback
public HexagonMap(int hexagonSize)
hexagonSize - the distance between the center and one cornerpublic HexagonMap(int hexagonSize,
Image image,
int mapWidthInHexes)
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-axispublic HexagonMap(int hexagonSize,
Image image,
int mapWidthInHexes,
IHexagonCreator hexagonCreator)
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); }
public Hexagon addHexagon(Hexagon hexagon)
hexagon - new hexagonpublic Collection<Hexagon> getAllHexagons()
public int getGraphicsHexagonHeight()
public double getGraphicsHorizontalDistanceBetweenHexagons()
public double getGraphicsverticalDistanceBetweenHexagons()
public Hexagon getHexagon(GridPosition position)
public Hexagon getHexagon(int q, int r)
q - the Q coordinater - the R coordinatepublic Hexagon getHexagonByCube(int x, int y, int z)
public Hexagon getHexagonContainingPixel(int x, int y)
x - carthesian x coordinatey - carthesian y coordinatepublic Optional<Double> getImageMapHorizontalRelation()
public Optional<Double> getImageMapVerticalRelation()
public double getPaddingX()
public double getPaddingY()
public void registerCanvasMouseLiner(Canvas canvas)
public void removeHexagon(Hexagon hexagon)
hexagon - to be removedpublic void render(Canvas canvas)
canvas - the JaxaFX Group where all the hexagons should be renderedpublic void render(Group group)
group - the JaxaFX Group where all the hexagons should be renderedpublic void renderContour(Canvas canvas)
canvas - the JaxaFX Group where all the hexagons should be renderedpublic void setOnHexagonClickedCallback(HexagonCallback callback)
callback - call-back function handlerpublic void setOnHexagonEnteredCallback(HexagonCallback callback)
callback - call-back function handlerpublic void setOnHexagonExitCallback(HexagonCallback callback)
callback - call-back function handlerpublic void setPadding(int left,
int top)
left - padding margin lefttop - padding margin rightpublic void setRenderCoordinates(boolean b)
b - true: render coordinatespublic void setRenderFont(Font font)
font - for rendering the hex positionsCopyright © 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH. All rights reserved.