Square or Hexagon Cell

- allows to select between square and hexagon representation
 - remark : this is still a square model
This commit is contained in:
philippe lhardy
2020-12-28 15:09:54 +01:00
parent 0bab1d51b1
commit 0c886f0cd1
5 changed files with 89 additions and 43 deletions

View File

@@ -1,6 +1,7 @@
package org.artisanlogiciel.games.maze.gui;
import org.artisanlogiciel.games.maze.Brick;
import org.artisanlogiciel.games.maze.model.WidthHeightProvider;
import java.awt.*;
@@ -13,15 +14,16 @@ public class HexagonCellRenderer
extends MazeCellRenderer
{
public final static int SUBCELL = 4;
public final static int SUBCELLY = 3;
public HexagonCellRenderer(int mapw, int maph, int W, int H, int x, int y) {
super(mapw, maph, W, H, x, y);
public HexagonCellRenderer(WidthHeightProvider model, WidthHeightProvider frame, int x, int y) {
super(model, frame, x, y);
}
void drawLine(Graphics g, int refx, int refy, int x, int y, int a, int b) {
g.drawLine(
(int) ((refx + x) * getWidth() / SUBCELL), (int) ((refy + y) * getHeight() / SUBCELL),
(int) ((refx + a) * getWidth() / SUBCELL),(int) ((refy + b) * getHeight() / SUBCELL));
(int) ((refx + x) * width / SUBCELL), (int) ((refy + y) * height / SUBCELL),
(int) ((refx + a) * width / SUBCELL),(int) ((refy + b) * height / SUBCELL));
}
@Override
@@ -87,4 +89,8 @@ extends MazeCellRenderer
// E : (4,3) - (4,1)
}
@Override
public double getHeight() {
return height * SUBCELLY / SUBCELL;
}
}