Skip to content

Commit

Permalink
Added UI to change max data points displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
ajayyy committed Nov 7, 2020
1 parent c33e552 commit 734aee5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/uorocketry/basestation/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ public void setupUI() {

window.addChartButton.addActionListener(this);

window.setMaxDataPointsButton.addActionListener(this);

window.restoreDeletedData.addActionListener(this);

window.saveLayout.addActionListener(this);
Expand Down Expand Up @@ -805,6 +807,11 @@ public void actionPerformed(ActionEvent e) {
}
} else if (e.getSource() == window.onlyShowLatestDataCheckBox) {
onlyShowLatestData = window.onlyShowLatestDataCheckBox.isSelected();
} else if (e.getSource() == window.setMaxDataPointsButton) {
try {
int maxDataPoints = Integer.parseInt(window.maxDataPointsTextField.getText());
maxDataPointsDisplayed = maxDataPoints;
} catch (NumberFormatException err) {}
} else if (e.getSource() == window.dataDeletionModeCheckBox) {
dataDeletionMode = window.dataDeletionModeCheckBox.isSelected();
} else if (e.getSource() == window.restoreDeletedData) {
Expand Down
18 changes: 18 additions & 0 deletions src/uorocketry/basestation/Window.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import javax.swing.JScrollPane;
import javax.swing.JSlider;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
Expand All @@ -47,6 +48,9 @@ public class Window extends JFrame {

private JPanel chartDataPointsOptions;
JCheckBox onlyShowLatestDataCheckBox;
JPanel maxDataPoints;
JButton setMaxDataPointsButton;
JTextField maxDataPointsTextField;

private JPanel dataTools;
JButton restoreDeletedData;
Expand Down Expand Up @@ -133,6 +137,20 @@ public Window(Main main) {
onlyShowLatestDataCheckBox = new JCheckBox("Only Show Latest Data");
chartDataPointsOptions.add(onlyShowLatestDataCheckBox);

maxDataPoints = new JPanel();
maxDataPoints.setAlignmentY(Component.TOP_ALIGNMENT);
maxDataPoints.setAlignmentX(Component.LEFT_ALIGNMENT);
maxDataPoints.setLayout(new BoxLayout(maxDataPoints, BoxLayout.X_AXIS));
chartDataPointsOptions.add(maxDataPoints);

maxDataPointsTextField = new JTextField(6);
maxDataPointsTextField.setMaximumSize(maxDataPointsTextField.getPreferredSize());
maxDataPointsTextField.setText(Main.maxDataPointsDisplayed + "");
maxDataPoints.add(maxDataPointsTextField);

setMaxDataPointsButton = new JButton("Set");
maxDataPoints.add(setMaxDataPointsButton);

dataTools = new JPanel();
dataTools.setBorder(new TitledBorder(null, "Data", TitledBorder.LEADING, TitledBorder.TOP, null, null));
leftPanel.add(dataTools);
Expand Down

0 comments on commit 734aee5

Please sign in to comment.