diff --git a/src/main/java/edu/wpi/first/pathweaver/EditWaypointController.java b/src/main/java/edu/wpi/first/pathweaver/EditWaypointController.java index e83b17d0..375809c5 100644 --- a/src/main/java/edu/wpi/first/pathweaver/EditWaypointController.java +++ b/src/main/java/edu/wpi/first/pathweaver/EditWaypointController.java @@ -6,15 +6,18 @@ import javafx.beans.property.DoubleProperty; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; +import javafx.collections.ObservableList; import javafx.fxml.FXML; -import javafx.scene.control.CheckBox; -import javafx.scene.control.Control; -import javafx.scene.control.TextField; +import javafx.scene.control.*; +import javafx.scene.input.Clipboard; +import javafx.scene.input.ClipboardContent; import javafx.scene.input.KeyEvent; import javafx.util.converter.NumberStringConverter; @SuppressWarnings("PMD.UnusedPrivateMethod") public class EditWaypointController { + @FXML + private ListView listView; @FXML private TextField xPosition; @FXML @@ -29,13 +32,20 @@ public class EditWaypointController { private CheckBox reverseSpline; @FXML private TextField pointName; + @FXML + private Button javaExport; + @FXML + private Button cExport; private List controls; private ChangeListener nameListener; + final Clipboard clipboard = Clipboard.getSystemClipboard(); + final ClipboardContent content = new ClipboardContent(); + @FXML private void initialize() { - controls = List.of(xPosition, yPosition, tangentX, tangentY, lockedTangent, pointName, reverseSpline); + controls = List.of(listView, xPosition, yPosition, tangentX, tangentY, lockedTangent, pointName, reverseSpline, javaExport, cExport); controls.forEach(control -> control.setDisable(true)); List textFields = List.of(xPosition, yPosition, tangentX, tangentY); textFields.forEach(textField -> textField.setTextFormatter(FxUtils.onlyDoubleText())); @@ -163,4 +173,22 @@ private void lockTangentOnEdit() { tangentY.setOnKeyTyped((KeyEvent event) -> lockedTangent.setSelected(true)); tangentX.setOnKeyTyped((KeyEvent event) -> lockedTangent.setSelected(true)); } + + @FXML + private void handleJavaExport() { + String baseString = "var %s = new ControlVector(new double[] {%f, %f}, new double[] {%f, %f});"; + var wp = CurrentSelections.getCurWaypoint(); + String clipStr = String.format(baseString, wp.getName(), wp.getX(), wp.getTangentX(), wp.getY(), wp.getTangentY()); + content.putString(clipStr); + clipboard.setContent(content); + } + + @FXML + private void handleCExport() { + String baseString = "ControlVector %s{{%f, %f}, {%f, %f}};"; + var wp = CurrentSelections.getCurWaypoint(); + String clipStr = String.format(baseString, wp.getName(), wp.getX(), wp.getTangentX(), wp.getY(), wp.getTangentY()); + content.putString(clipStr); + clipboard.setContent(content); + } } diff --git a/src/main/resources/edu/wpi/first/pathweaver/editWaypoint.fxml b/src/main/resources/edu/wpi/first/pathweaver/editWaypoint.fxml index 3630d947..fc9a8bab 100644 --- a/src/main/resources/edu/wpi/first/pathweaver/editWaypoint.fxml +++ b/src/main/resources/edu/wpi/first/pathweaver/editWaypoint.fxml @@ -9,13 +9,16 @@ + + - - - + + + + @@ -25,18 +28,27 @@ -