Erika Savell 9 years ago
commit 2811a09784

@ -1,5 +1,6 @@
package seng302.Controllers; package seng302.Controllers;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.canvas.Canvas; import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext; import javafx.scene.canvas.GraphicsContext;
@ -47,14 +48,15 @@ public class RaceController extends Controller{
gc.fillOval(graphCoordinate.getX(), graphCoordinate.getY(), 10, 10); gc.fillOval(graphCoordinate.getX(), graphCoordinate.getY(), 10, 10);
} }
public void displayArrow(GraphCoordinate coordinate, Paint paint){ public void displayArrow(GraphCoordinate coordinate, int angle){
rotate(10, 30,30); rotate(angle, coordinate.getX(),coordinate.getY());
gc.fillPolygon(new double[]{0, 6, 12, 8, 8, 4, 4}, 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[]{15, 0, 15, 15, 40, 40, 15}, new double[]{coordinate.getY()-5, coordinate.getY()-20, coordinate.getY()-5, coordinate.getY()-5, coordinate.getY()+20, coordinate.getY()+20, coordinate.getY()-5},
7); 7);
gc.restore(); gc.restore();
} }
private void rotate(double angle, double px, double py) { private void rotate(double angle, double px, double py) {
Rotate r = new Rotate(angle, px, py); Rotate r = new Rotate(angle, px, py);
gc.setTransform(r.getMxx(), r.getMyx(), r.getMxy(), r.getMyy(), r.getTx(), r.getTy()); gc.setTransform(r.getMxx(), r.getMyx(), r.getMxy(), r.getMyy(), r.getTx(), r.getTy());
@ -65,6 +67,7 @@ public class RaceController extends Controller{
raceMap.widthProperty().bind(canvasBase.widthProperty()); raceMap.widthProperty().bind(canvasBase.widthProperty());
raceMap.heightProperty().bind(canvasBase.heightProperty());*/ raceMap.heightProperty().bind(canvasBase.heightProperty());*/
this.gc = raceMap.getGraphicsContext2D(); this.gc = raceMap.getGraphicsContext2D();
this.map = new RaceMap(32.321989, -64.8553, 32.246, -64.831, (int)raceMap.getWidth(), (int)raceMap.getHeight()); this.map = new RaceMap(32.321989, -64.8553, 32.246, -64.831, (int)raceMap.getWidth(), (int)raceMap.getHeight());
//boat //boat
GraphCoordinate boat1coord = this.map.convertGPS(32.296577, -64.854304); GraphCoordinate boat1coord = this.map.convertGPS(32.296577, -64.854304);
@ -89,7 +92,13 @@ public class RaceController extends Controller{
GraphCoordinate startline2 = this.map.convertGPS(32.293771, -64.855242); GraphCoordinate startline2 = this.map.convertGPS(32.293771, -64.855242);
displayLine(startline1, startline2, Color.GREEN); displayLine(startline1, startline2, Color.GREEN);
//display wind direction arrow - specify origin point and angle
displayPoint(this.map.convertGPS(32.293771, -64.855242), Color.BLACK); displayPoint(this.map.convertGPS(32.293771, -64.855242), Color.BLACK);
displayArrow(new GraphCoordinate(100, 100), Color.BLUEVIOLET); displayArrow(new GraphCoordinate(500, 20), 100);
} }
} }

@ -11,7 +11,7 @@
<items> <items>
<AnchorPane fx:id="canvasBase" minHeight="0.0" minWidth="0.0"> <AnchorPane fx:id="canvasBase" minHeight="0.0" minWidth="0.0">
<children> <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> </children>
</AnchorPane> </AnchorPane>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0"> <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0">

Loading…
Cancel
Save