HexEngine { public HexPosition[] getNeighbourPositions(final HexPosition pos, final int distance) { return this.getNeighbourPositions(null, pos.getColumn(), pos.getRow(), distance); } HexEngine(final float cellWidth, final float cellHeight, final int orientation);  HexEngine(final float cellWidth, final float cellHeight, final float coeff, final int orientation); void changeEnginebaseParameters(final float cellWidth, final float cellHeight, final float coeff, final int orientation); void changeEngineBaseParameters(final float cellWidth, final float cellHeight, final int orientation); float getCellWidth(); float getScaledCellWidth(); float getCellHeight(); float getScaledCellHeight(); void addHexLayerListener(final HexEngineListener listener); void removeHexLayerListener(final HexEngineListener listener); float getHexCoefficient(); @SuppressWarnings("unchecked") void setScale(final float scaleX, final float scaleY); float getScaleX(); float getScaleY(); @SuppressWarnings("unchecked") void setRenderer(final HexEngineRender<G> renderer); HexEngineRender<G> getRenderer(); void setModel(final HexEngineModel<?> model); HexEngineModel<?> getModel(); float calculateX(final int column, final int row); HexPosition pointToHex(final float pointX, final float pointY); int calculateColumn(final float x, final float y); int calculateRow(final float x, final float y); float calculateY(final int column, final int row); boolean isPositionVisible(final HexPosition pos, final HexRect2D rect, final boolean accurately); boolean isPositionVisible(final int col, final int row, final HexRect2D rect, final boolean accurately); void drawHex(final G gfx, final int column, final int row); List<HexPosition> getCoveredHexes(final HexRect2D rect, final boolean accurately); void drawArea(final G gfx, final HexRect2D rect, final boolean accurately); void draw(final G gfx); void drawWithThreadInterruptionCheck(final G gfx); int getOrientation(); HexPoint2D[] getHexPoints(); HexPoint2D[] getHexScaledPoints(); HexPosition getNearestNeighbourPosition(final HexPosition pos, final int neighborPositionIndex); HexPosition getNearestNeighbourPosition(final int col, final int row, final int neighbourIndex); HexPosition[] getNeighbourPositions(final HexPosition pos, final int distance); HexPosition[] getNeighbourPositions(final HexPosition[] array, final HexPosition pos, final int distance); HexPosition[] getNeighbourPositions(final int col, final int row, final int distance); WidthHeightPair calculateHexesForRectangle(final float areaWidth, final float areaHeight); HexRect2D getVisibleSize(); static int packColumnRow(final int col, final int row); static int extractColumn(final int packedValue); static int extractRow(final int packedValue); int[] getPackedNeighbourPositions(final int[] array, final int col, final int row, final int distance); HexPosition[] getNeighbourPositions(final HexPosition[] array, final int col, final int row, final int distance); static final int ORIENTATION_HORIZONTAL; static final int ORIENTATION_VERTICAL; }
@Test public void testGetClockwisePositionsAroundHex_Vertical_1_evenColumn() { final HexEngine<Object> eng = new HexEngine<Object>(20, 20, HexEngine.ORIENTATION_VERTICAL); assertPositions(eng.getNeighbourPositions(10, 11, 1), 11, 10, 11, 11, 11, 12, 10, 12, 9, 11, 10, 10); }
@Test public void testGetClockwisePositionsAroundHex_Horizontal_4() { final HexEngine<Object> eng = new HexEngine<Object>(20, 20, HexEngine.ORIENTATION_HORIZONTAL); assertPositions(eng.getNeighbourPositions(5, 6, 4), 5, 2, 6, 3, 7, 3, 8, 4, 9, 4, 9, 5, 9, 6, 9, 7, 9, 8, 8, 9, 7, 9, 6, 10, 5, 10, 4, 10, 3, 9, 2, 9, 1, 8, 1, 7, 1, 6, 1, 5, 1, 4, 2, 4, 3, 3, 4, 3); }
@Test public void testGetClockwisePositionsAroundHex_Vertical_4() { final HexEngine<Object> eng = new HexEngine<Object>(20, 20, HexEngine.ORIENTATION_VERTICAL); assertPositions(eng.getNeighbourPositions(5, 6, 4), 7, 2, 7, 3, 8, 4, 8, 5, 9, 6, 8, 7, 8, 8, 7, 9, 7, 10, 6, 10, 5, 10, 4, 10, 3, 10, 2, 9, 2, 8, 1, 7, 1, 6, 1, 5, 2, 4, 2, 3, 3, 2, 4, 2, 5, 2, 6, 2); }
@Test public void testGetClockwisePositionsAroundHex_Vertical_3() { final HexEngine<Object> eng = new HexEngine<Object>(20, 20, HexEngine.ORIENTATION_VERTICAL); assertPositions(eng.getNeighbourPositions(5, 6, 3), 6, 3, 7, 4, 7, 5, 8, 6, 7, 7, 7, 8, 6, 9, 5, 9, 4, 9, 3, 9, 3, 8, 2, 7, 2, 6, 2, 5, 3, 4, 3, 3, 4, 3, 5, 3); }
@Test public void testGetClockwisePositionsAroundHex_Horizontal_0() { final HexEngine<Object> eng = new HexEngine<Object>(20, 20, HexEngine.ORIENTATION_HORIZONTAL); assertPositions(eng.getNeighbourPositions(4, 8, 0), 4, 8); }
@Test public void testGetClockwisePositionsAroundHex_Horizontal_1_oddColumn() { final HexEngine<Object> eng = new HexEngine<Object>(20, 20, HexEngine.ORIENTATION_HORIZONTAL); assertPositions(eng.getNeighbourPositions(5, 6, 1), 5, 5, 6, 6, 6, 7, 5, 7, 4, 7, 4, 6); }
@Test public void testGetClockwisePositionsAroundHex_Vertical_1_oddColumn() { final HexEngine<Object> eng = new HexEngine<Object>(20, 20, HexEngine.ORIENTATION_VERTICAL); assertPositions(eng.getNeighbourPositions(5, 6, 1), 5, 5, 6, 6, 5, 7, 4, 7, 4, 6, 4, 5); }
@Test public void testGetClockwisePositionsAroundHex_Horizontal_1_evenColumn() { final HexEngine<Object> eng = new HexEngine<Object>(20, 20, HexEngine.ORIENTATION_HORIZONTAL); assertPositions(eng.getNeighbourPositions(10, 11, 1), 10, 10, 11, 10, 11, 11, 10, 12, 9, 11, 9, 10); }