Add easy way of creating location table

This commit is contained in:
Julius de Jeu 2017-02-28 00:22:49 +01:00
parent 34647418af
commit 25f1c41e39
3 changed files with 133 additions and 5 deletions

View file

@ -1,11 +1,137 @@
package nl.minkema.leendert;
import javafx.scene.Group;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.text.Text;
/**
* @author J0QUE
* @version 1.0
*/
public class Game extends Group {
public class Game extends Pane {
public static int[][] locations = {{290, 163},
{331, 162},
{372, 162},
{412, 161},
{446, 160},
{466, 201},
{429, 202},
{382, 201},
{340, 201},
{313, 201},
{274, 201},
{253, 235},
{293, 242},
{339, 243},
{370, 243},
{419, 242},
{447, 241},
{484, 241},
{517, 277},
{468, 277},
{431, 278},
{402, 280},
{344, 281},
{304, 282},
{277, 282},
{228, 283},
{216, 319},
{256, 319},
{291, 320},
{338, 324},
{367, 324},
{407, 323},
{453, 320},
{486, 320},
{528, 321},
{554, 359},
{506, 362},
{478, 362},
{432, 362},
{395, 361},
{346, 359},
{302, 360},
{272, 360},
{223, 359},
{203, 359},
{179, 359},
{210, 398},
{248, 399},
{292, 400},
{333, 404},
{373, 406},
{404, 396},
{446, 399},
{484, 401},
{523, 402},
{575, 402},
{563, 430},
{520, 438},
{460, 441},
{435, 443},
{394, 442},
{361, 442},
{311, 442},
{275, 439},
{225, 438},
{194, 438},
{203, 473},
{243, 477},
{297, 482},
{335, 482},
{375, 481},
{412, 481},
{450, 481},
{486, 480},
{533, 480},
{520, 517},
{465, 520},
{426, 522},
{389, 523},
{350, 524},
{317, 524},
{276, 524},
{238, 524},
{243, 553},
{276, 555},
{332, 558},
{370, 559},
{415, 560},
{456, 559},
{484, 560},
{479, 594},
{432, 596},
{387, 596},
{347, 597},
{313, 598},
{272, 598},
{287, 635},
{332, 636},
{368, 639},
{417, 642},
{449, 643}};
public Game() {
Image bord = new Image("/svg/Bord.svg");
ImageView view = new ImageView(bord);
view.setPreserveRatio(true);
view.setFitHeight(500);
view.setX(150);
view.setY(135);
this.getChildren().add(view);
for (int i = 0, locationsLength = locations.length; i < locationsLength; i++) {
int[] k = locations[i];
getChildren().add(new Circle(k[0], k[1], 5, Color.RED));
getChildren().add(new Text(k[0], k[1], String.valueOf(i)));
}
System.out.print("{");
this.setOnMouseClicked(event -> System.out.printf("{%d, %d},%n", (int) event.getSceneX(), (int) event.getSceneY()));
}
}

View file

@ -17,11 +17,11 @@ public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
Group root = new Group();
SvgImageLoaderFactory.install();
primaryStage.setTitle("Het spectaculaire tuinavontuur");
scene = new Scene(new Menu(), 1200, 800);
scene = new Scene(new Game(), 1200, 800);
primaryStage.setScene(scene);
primaryStage.setResizable(false);
primaryStage.show();

View file

@ -30,7 +30,7 @@ public class Menu extends Group {
public static ArrayList<Paint> playerColors = new ArrayList<>();
public Menu() throws URISyntaxException, MalformedURLException {
while(playerColors.size()<21) {
while (playerColors.size() < 21) {
Color c = getRandomColor();
if (!playerColors.contains(c)) {
playerColors.add(c);
@ -63,6 +63,8 @@ public class Menu extends Group {
getChildren().addAll(nodes);
playerColors.forEach(System.out::println);
System.out.print("[");
this.setOnMouseClicked(event -> System.out.printf("[%d, %d],%n", (int)event.getSceneX(), (int)event.getSceneY()));
}
public static StackPane createButton(String string, double x, double y, EventHandler<MouseEvent> onClick) {