@author Simon Gwerder @version OGV 3.1, May 2015
| 16 | * |
| 17 | */ |
| 18 | public class Floor extends Group implements Selectable { |
| 19 | |
| 20 | private HashSet<Rectangle> tiles = new HashSet<Rectangle>(); |
| 21 | private final double TILE_SIZE = 1000; |
| 22 | private final int TILE_DIMENSION = 10; |
| 23 | public final static Color DEFAULT_COLOR = Color.WHITESMOKE; |
| 24 | |
| 25 | private Color color = DEFAULT_COLOR; |
| 26 | |
| 27 | private volatile boolean selected = false; |
| 28 | |
| 29 | public Floor() { |
| 30 | for (int x = 0; x < TILE_DIMENSION; x++) { |
| 31 | for (int z = 0; z < TILE_DIMENSION; z++) { |
| 32 | buildFloorTile(x, z); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | for (Rectangle tile : this.tiles) { |
| 37 | getChildren().add(tile); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | private void buildFloorTile(int x, int z) { |
| 42 | Rectangle tile = new Rectangle(TILE_SIZE, TILE_SIZE, this.color); |
| 43 | tile.setDepthTest(DepthTest.ENABLE); |
| 44 | tile.getTransforms().add(new Rotate(90, Rotate.X_AXIS)); |
| 45 | tile.setTranslateX(-((TILE_DIMENSION * TILE_SIZE) / 2) + (x * TILE_SIZE)); |
| 46 | tile.setTranslateZ(-((TILE_DIMENSION * TILE_SIZE) / 2) + (z * TILE_SIZE)); |
| 47 | tile.setOpacity(0.6); |
| 48 | this.tiles.add(tile); |
| 49 | } |
| 50 | |
| 51 | public void setSeeable(boolean value) { |
| 52 | for (Rectangle tile : this.tiles) { |
| 53 | if (value) { |
| 54 | tile.setFill(getColor()); |
| 55 | } |
| 56 | else { |
| 57 | tile.setFill(Color.TRANSPARENT); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | } |
| 62 | |
| 63 | public void setColor(Color color) { |
| 64 | for (Rectangle tile : this.tiles) { |
| 65 | tile.setFill(color); |
| 66 | } |
| 67 | this.color = color; |
| 68 | } |
| 69 | |
| 70 | public Color getColor() { |
| 71 | return this.color; |
| 72 | } |
| 73 | |
| 74 | public boolean hasTile(Node node) { |
| 75 | if (node == null || !(node instanceof Rectangle)) |
nothing calls this directly
no outgoing calls
no test coverage detected