package SW9.model_canvas.arrow_heads;

import javafx.scene.paint.Color;
import javafx.scene.shape.LineTo;
import javafx.scene.shape.MoveTo;
import javafx.scene.shape.Path;

public class SimpleArrowHead extends ArrowHead {

    private static final double TRIANGLE_LENGTH = 20d;
    private static final double TRIANGLE_WIDTH = 15d;

    public SimpleArrowHead() {
        super();

        addChild(initializeTriangle());
    }

    private Path initializeTriangle() {
        final Path simpleArrow = new Path();

        MoveTo start = new MoveTo();
        LineTo l1 = new LineTo();
        MoveTo l2 = new MoveTo();
        LineTo l3 = new LineTo();

        start.xProperty().bind(xProperty);
        start.yProperty().bind(yProperty);

        l1.xProperty().bind(start.xProperty().subtract(TRIANGLE_WIDTH / 2));
        l1.yProperty().bind(start.yProperty().subtract(TRIANGLE_LENGTH));

        l2.xProperty().bind(start.xProperty().add(TRIANGLE_WIDTH / 2));
        l2.yProperty().bind(start.yProperty().subtract(TRIANGLE_LENGTH));

        l3.xProperty().bind(start.xProperty());
        l3.yProperty().bind(start.yProperty());

        simpleArrow.setStroke(Color.BLACK);
        simpleArrow.getElements().addAll(start, l1, l2, l3);

        return simpleArrow;
    }

    @Override
    public double getHeadHeight() {
        return TRIANGLE_LENGTH;
    }

    @Override
    public double getHeadWidth() {
        return TRIANGLE_WIDTH;
    }

    @Override
    public boolean shouldBindToTip() {
        return true;
    }

}

@@ -95,80 +95,9 @@
 ape.
-LineTo;%0Aimport javafx.scene.shape.MoveTo;%0Aimport javafx.scene.shape.Path
+*
 ;%0A%0Ap
@@ -320,16 +320,19 @@
 addChild
+ren
 (initial
@@ -334,24 +334,49 @@
 itialize
-Triangle
+LeftArrow(), initializeRightArrow
 ());%0A   
@@ -391,20 +391,20 @@
 private 
-Path
+Line
  initial
@@ -410,103 +410,21 @@
 lize
-Triangle() %7B%0A        final Path simpleArrow = new Path();%0A%0A        MoveTo start = new MoveTo();
+LeftArrow() %7B
 %0A   
@@ -432,85 +432,28 @@
     
-LineTo l1 = new LineTo();%0A        MoveTo l2 = new MoveTo();%0A        LineTo l3
+final Line leftArrow
  = n
@@ -463,23 +463,20 @@
 Line
-To
 ();%0A
-%0A
         
 star
@@ -471,23 +471,32 @@
         
+leftArrow.
 start
-.x
+X
 Property
@@ -523,23 +523,32 @@
         
+leftArrow.
 start
-.y
+Y
 Property
@@ -567,17 +567,16 @@
 perty);%0A
-%0A
         
@@ -580,11 +580,21 @@
    l
-1.x
+eftArrow.endX
 Prop
@@ -597,38 +597,32 @@
 Property().bind(
-start.
 xProperty().subt
@@ -606,34 +606,32 @@
 ).bind(xProperty
-()
 .subtract(TRIANG
@@ -659,11 +659,21 @@
    l
-1.y
+eftArrow.endY
 Prop
@@ -676,38 +676,32 @@
 Property().bind(
-start.
 yProperty().subt
@@ -685,34 +685,32 @@
 ).bind(yProperty
-()
 .subtract(TRIANG
@@ -735,159 +735,144 @@
     
-l2.xProperty().bind(start.xProperty().add(TRIANGLE_WIDTH / 2));%0A        l2.yProperty().bind(start.yProperty().subtract(TRIANGLE_LENGTH));%0A%0A        l3.x
+return leftArrow;%0A    %7D%0A%0A    private Line initializeRightArrow() %7B%0A        final Line rightArrow = new Line();%0A        rightArrow.startX
 Prop
@@ -883,22 +883,16 @@
 ().bind(
-start.
 xPropert
@@ -892,18 +892,16 @@
 Property
-()
 );%0A     
@@ -907,12 +907,25 @@
     
-l3.y
+rightArrow.startY
 Prop
@@ -940,14 +940,8 @@
 ind(
-start.
 yPro
@@ -949,22 +949,19 @@
 erty
-()
 );%0A
-%0A
         
 simp
@@ -960,102 +960,149 @@
     
-simpleArrow.setStroke(Color.BLACK);%0A        simpleArrow.getElements().addAll(start, l1, l2, l3
+rightArrow.endXProperty().bind(xProperty.add(TRIANGLE_WIDTH / 2));%0A        rightArrow.endYProperty().bind(yProperty.subtract(TRIANGLE_LENGTH)
 );%0A%0A
@@ -1120,14 +1120,13 @@
 urn 
-simple
+right
 Arro

Refactor simple arrow head to use two lines instead of path