Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/java/org/frcteam2910/pathviewer/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class Application {
private BorderPane root;
@FXML
private FieldDisplay fieldDisplay;
@FXML
private PointEditorController pointEditorController;

/**
* The path file that is currently being edited.
Expand All @@ -33,6 +35,7 @@ public class Application {

@FXML
private void initialize() {
pointEditorController.fieldPointProperty().bind(fieldDisplay.selectedPointProperty());
}

@CheckForNull
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/frcteam2910/pathviewer/FieldDisplay.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public FieldDisplay() {

@FXML
private void initialize() {
field = new Field(new Image("org/frcteam2910/pathviewer/2020-field.png"), new Vector2(54.0 * 12.0, 27.0 * 12.0), new Vector2(76, 64), new Vector2(2696 - 76, 1688 - 64));
field = new Field(new Image("org/frcteam2910/pathviewer/2020-field.png"), new Vector2(54.0 * 12.0, 27.0 * 12.0), new Vector2(76, 64), new Vector2(2696 - 76, 1386 - 64));
Image image = field.getImage();
backgroundImage.setImage(image);
Scale scale = new Scale();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package org.frcteam2910.pathviewer;


import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.control.TextFormatter;
import javafx.util.converter.DoubleStringConverter;

public class PointEditorController {
@FXML
private TextField txtX;
@FXML
private TextField txtY;
@FXML
private TextField txtRotationField;
@FXML
private Button btnUpdate;

@FXML
private void initialize() {
txtX.setTextFormatter(new TextFormatter<>(new DoubleStringConverter()));
txtY.setTextFormatter(new TextFormatter<>(new DoubleStringConverter()));
txtRotationField.setTextFormatter(new TextFormatter<>(new DoubleStringConverter()));

fieldPointProperty().addListener((observable, oldValue, newValue) -> {
if(newValue != null) {
txtX.setText(String.valueOf(newValue.getCenterX()));
txtY.setText(String.valueOf(newValue.getCenterY()));
txtRotationField.setText(String.valueOf(newValue.getRotate()));
}
});
}

@FXML
private void updateValues(ActionEvent actionEvent) {
if(getFieldPoint() == null) {
return;
}

getFieldPoint().setCenter(Double.parseDouble(txtX.getText()), Double.parseDouble(txtY.getText()));
getFieldPoint().setRotate(Double.parseDouble(txtRotationField.getText()));
}

private final SimpleObjectProperty<FieldPoint> fieldPoint = new SimpleObjectProperty<>();

public ObjectProperty<FieldPoint> fieldPointProperty() {
return fieldPoint;
}

public FieldPoint getFieldPoint() {
return fieldPoint.get();
}

public void setFieldPoint(FieldPoint fieldPoint) {
fieldPointProperty().set(fieldPoint);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,7 @@
<center>
<FieldDisplay fx:id="fieldDisplay"/>
</center>
<bottom>
<fx:include source="PointEditor.fxml" fx:id="pointEditor"/>
</bottom>
</BorderPane>
33 changes: 33 additions & 0 deletions src/main/resources/org/frcteam2910/pathviewer/PointEditor.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<GridPane xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.frcteam2910.pathviewer.PointEditorController">
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" />
<RowConstraints minHeight="10.0" prefHeight="30.0" />
<RowConstraints minHeight="10.0" prefHeight="30.0" />
<RowConstraints minHeight="10.0" prefHeight="30.0" />
</rowConstraints>
<columnConstraints>
<ColumnConstraints minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints minWidth="10.0" />
</columnConstraints>
<children>
<Label text="Point X:">
<GridPane.margin>
<Insets />
</GridPane.margin></Label>
<Label text="Point Y:" GridPane.rowIndex="1" />
<Label text="Point Rotation:" GridPane.rowIndex="2" />
<TextField fx:id="txtX" GridPane.columnIndex="1" />
<TextField fx:id="txtY" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<TextField fx:id="txtRotationField" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<Button fx:id="btnUpdate" mnemonicParsing="false" text="Update" GridPane.rowIndex="3" onAction="#updateValues"/>
</children>
<padding>
<Insets bottom="4.0" left="4.0" right="4.0" top="4.0" />
</padding>
</GridPane>