Files
SENG302/racevisionGame/src/main/java/visualiser/model/RaceConnection.java
T
Jessica Syder 7c5670f8c2 Sails are displayed on first boat in a race. Optimised imports.
- Implemented drawSails method
- Sail position is displayed and updated using a boat's heading
- Sails conform to 'Points of sail'
- Javadoc'd new method and tidied up existing
- Sped up track point frequency (visualiserBoat class)
- Optimised imports (any other classes changed)
- A lot of canvas drawing and sail rotating issues were discovered and eventually overcome along the way. Using a sail image to draw and rotate on the existing canvas rather than a JavaFX shape on a new canvas was the final decision.

#story[1098]
2017-08-07 12:20:52 +12:00

58 lines
1.4 KiB
Java

package visualiser.model;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
/**
* Connection for Races
*/
public class RaceConnection {
private final StringProperty hostname;
private final int port;
private final StringProperty status;
private final StringProperty gamename;
/**
* Constructor for remote host connections.
* @param hostname URL for remote host
* @param port port for game feed
* @param gamename Name of the game
*/
public RaceConnection(String hostname, int port, String gamename) {
this.hostname = new SimpleStringProperty(hostname);
this.port = port;
this.status = new SimpleStringProperty("");
check();
this.gamename = new SimpleStringProperty(gamename);
}
/**
* Tries to create a socket to hostname and port, indicates status after test.
* @return true if socket can connect
*/
public boolean check() {
Ping ping = new Ping(hostname.get(), port, this);
new Thread(ping).start();
return true;
}
public String getHostname() {
return hostname.get();
}
public StringProperty hostnameProperty() {
return hostname;
}
public int getPort() {
return port;
}
public StringProperty statusProperty() {
return status;
}
public StringProperty gamenameProperty() { return gamename;}
}