# Conflicts:
#	src/main/java/seng302/Controllers/RaceController.java
This commit is contained in:
cbt24
2017-03-17 11:43:30 +13:00
5 changed files with 30 additions and 18 deletions
@@ -1,5 +1,6 @@
package seng302.Controllers;
import javafx.beans.property.ReadOnlyObjectWrapper;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
@@ -14,6 +15,7 @@ import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
import javafx.util.Callback;
import seng302.GPSCoordinate;
import javafx.scene.transform.Rotate;
import seng302.GraphCoordinate;
import seng302.Model.*;
import seng302.RaceMap;
@@ -63,6 +65,20 @@ public class RaceController extends Controller{
gc.fillOval(graphCoordinate.getX(), graphCoordinate.getY(), 10, 10);
}
public void displayArrow(GraphCoordinate coordinate, int angle){
rotate(angle, coordinate.getX(),coordinate.getY());
gc.fillPolygon(new double[]{coordinate.getX()-12, coordinate.getX()-6, coordinate.getX(), coordinate.getX()-4, coordinate.getX()-4, coordinate.getX()-8, coordinate.getX()-8},
new double[]{coordinate.getY()-5, coordinate.getY()-20, coordinate.getY()-5, coordinate.getY()-5, coordinate.getY()+20, coordinate.getY()+20, coordinate.getY()-5},
7);
gc.restore();
}
private void rotate(double angle, double px, double py) {
Rotate r = new Rotate(angle, px, py);
gc.setTransform(r.getMxx(), r.getMyx(), r.getMxy(), r.getMyy(), r.getTx(), r.getTy());
}
public void updateInfoTable(Race race) {
boatInfoTable.setItems(FXCollections.observableArrayList(race.getFinishingBoats()));
@@ -90,6 +106,8 @@ public class RaceController extends Controller{
(new Thread(race)).start();
this.gc = raceMap.getGraphicsContext2D();
this.map = new RaceMap(32.321989, -64.8553, 32.246, -64.831, (int)raceMap.getWidth(), (int)raceMap.getHeight());
this.gc = raceMap.getGraphicsContext2D();
@@ -116,6 +134,13 @@ public class RaceController extends Controller{
GraphCoordinate startline2 = this.map.convertGPS(32.293771, -64.855242);
displayLine(startline1, startline2, Color.GREEN);
//display wind direction arrow - specify origin point and angle
displayPoint(this.map.convertGPS(32.293771, -64.855242), Color.BLACK);
displayArrow(new GraphCoordinate(500, 20), 100);
}
}
+1 -1
View File
@@ -11,7 +11,7 @@
<items>
<AnchorPane fx:id="canvasBase" minHeight="0.0" minWidth="0.0">
<children>
<Canvas fx:id="raceMap" height="600.0" width="600.0" />
<Canvas fx:id="raceMap" height="600.0" width="600.0" AnchorPane.bottomAnchor="-202.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="-155.0" AnchorPane.topAnchor="0.0" />
</children>
</AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">