From 126d8ea8706ab4ecca12eb92f20efb3b629dc890 Mon Sep 17 00:00:00 2001 From: Calum Date: Wed, 9 Aug 2017 15:24:32 +1200 Subject: [PATCH] Added factory class for producing mark arrows. #story[1118] --- .../fxObjects/MarkArrowFactory.java | 56 +++++++++++++++++++ .../seng302/visualiser/fxObjects/Marker.java | 20 ++++++- 2 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 src/main/java/seng302/visualiser/fxObjects/MarkArrowFactory.java diff --git a/src/main/java/seng302/visualiser/fxObjects/MarkArrowFactory.java b/src/main/java/seng302/visualiser/fxObjects/MarkArrowFactory.java new file mode 100644 index 00000000..9ab67b2b --- /dev/null +++ b/src/main/java/seng302/visualiser/fxObjects/MarkArrowFactory.java @@ -0,0 +1,56 @@ +package seng302.visualiser.fxObjects; + +import javafx.scene.Group; +import javafx.scene.paint.Paint; +import javafx.scene.shape.Line; +import javafx.scene.shape.Polyline; + +/** + * Created by cir27 on 9/08/17. + */ +public class MarkArrowFactory { + + public enum RoundingType { + PORT, + STARBOARD, + } + + public static Group constructEntryArrow (RoundingType roundingSide, double angleOfEntry, + double angleOfExit, Paint colour) { + Group arrow = new Group(); + return arrow; + } + + public static Group constructExitArrow (RoundingType roundingSide, double angleOfEntry, Paint colour) { + Group arrow = new Group(); + Line arrowBody; + Polyline arrowHead = constructArrowHead(); + if (roundingSide == RoundingType.PORT) { + arrowBody = new Line( + -10, -10, + -10, -30 + ); + arrowHead.setLayoutX(-10); + arrowHead.setLayoutY(-10); + } else { + arrowBody = new Line( + 10, -10, + 10, -30 + ); + arrowHead.setLayoutX(10); + arrowHead.setLayoutY(-10); + } + arrowBody.setFill(colour); + arrowHead.setFill(colour); + arrow.getChildren().addAll(arrowBody, arrowHead); + return arrow; + } + + private static Polyline constructArrowHead () { + return new Polyline( + -5, -5, + 0, 0, + 5, -5 + ); + } +} diff --git a/src/main/java/seng302/visualiser/fxObjects/Marker.java b/src/main/java/seng302/visualiser/fxObjects/Marker.java index 5697f5ef..22942a2b 100644 --- a/src/main/java/seng302/visualiser/fxObjects/Marker.java +++ b/src/main/java/seng302/visualiser/fxObjects/Marker.java @@ -1,19 +1,33 @@ package seng302.visualiser.fxObjects; +import javafx.application.Platform; +import javafx.scene.Group; import javafx.scene.paint.Paint; import javafx.scene.shape.Circle; /** * Visual object for a mark. */ -public class Marker extends Circle { +public class Marker extends Group { + + Circle mark = new Circle(); + Group enterArrow; + Group exitArrow; public Marker() { - super.setRadius(5); + mark.setRadius(5); } public Marker(Paint colour) { this(); - super.setFill(colour); + mark.setFill(colour); + } + + public void showEnterArrow () { + Platform.runLater(() -> this.getChildren().setAll(enterArrow)); + } + + public void showExitArrow () { + Platform.runLater(() -> this.getChildren().setAll(exitArrow)); } } \ No newline at end of file