Skip to content
Snippets Groups Projects
Verified Commit cae7f9fb authored by Théo Pirkl's avatar Théo Pirkl :nail_care:
Browse files

Enhances your ui

parent e1974a2f
No related branches found
No related tags found
1 merge request!21*poof* final version
......@@ -11,6 +11,7 @@ import javafx.fxml.Initializable;
import javafx.scene.canvas.Canvas;
import javafx.scene.control.*;
import javafx.scene.input.KeyCode;
import javafx.scene.paint.Color;
import org.json.JSONArray;
import java.io.IOException;
......@@ -93,9 +94,13 @@ public class MainWindowController implements Initializable {
private void drawConnection(Connection connection, int x, int y){
List<Section> sections = connection.getSections();
for (int i = 0; i < sections.size(); i++){
connectionCanvas.getGraphicsContext2D().setFill(Color.RED);
connectionCanvas.getGraphicsContext2D().strokeLine(
x + (800 / sections.size()) * i, y, 800 / sections.size(), y);
x + (652 / sections.size()) * i, y, 652 / sections.size(), y);
connectionCanvas.getGraphicsContext2D().fillOval(x + (652 / sections.size()) * i - 5, y - 5,
10, 10);
}
connectionCanvas.getGraphicsContext2D().fillOval(x + 620 - 5, y - 5, 10, 10);
}
/**
......@@ -122,13 +127,16 @@ public class MainWindowController implements Initializable {
launchItinaryButton.setOnAction(event -> {
try {
connectionCanvas.getGraphicsContext2D()
.clearRect(0, 0, connectionCanvas.getWidth(), connectionCanvas.getHeight());
JSONArray connections = transportApi.getConnections(
originComboBox.getValue(), destinationComboBox.getValue());
startStopLabel.setText(originComboBox.getValue() + " - " + destinationComboBox.getValue());
for (int i = 0; i < connections.length(); i++){
// Now iterating over connections
Connection c = new Connection.ConnectionBuilder(connections.getJSONObject(i)).build();
drawConnection(c, 30, 100 + 30 * i);
drawConnection(c, 30, 100 + 100 * i);
}
} catch (IOException | ParseException e) {
......@@ -137,7 +145,7 @@ public class MainWindowController implements Initializable {
});
sendMessageButton.setOnAction(event -> {
if (app.getUser().isPresent()){
if (app.getUser().isPresent() && !messageTextBox.getText().isEmpty()){
app.getMessageManager().sendChatMessage(new ChatMessage(app.getUser().get(), messageTextBox.getText()));
messageTextBox.clear();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment