Skip to content

Add clear button to SerialPlotter #7452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions app/src/processing/app/SerialPlotter.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class SerialPlotter extends AbstractMonitor {

private final StringBuffer messageBuffer;
private JComboBox<String> serialRates;
private JButton clearButton;
private Serial serial;
private int serialRate, xCount;

Expand Down Expand Up @@ -255,6 +256,8 @@ public SerialPlotter(BoardPort port) {

messageBuffer = new StringBuffer();
graphs = new ArrayList<>();

clearButton.addActionListener(ae -> {graphs.clear();});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can argue to also reset xCount to 0 here as well.

}

protected void onCreateWindow(Container mainPane) {
Expand All @@ -273,9 +276,12 @@ protected void onCreateWindow(Container mainPane) {

serialRates.setMaximumSize(serialRates.getMinimumSize());

clearButton = new JButton(tr("Clear output"));

pane.add(Box.createHorizontalGlue());
pane.add(Box.createRigidArea(new Dimension(8, 0)));
pane.add(serialRates);
pane.add(clearButton);

mainPane.add(pane, BorderLayout.SOUTH);

Expand Down Expand Up @@ -383,6 +389,8 @@ public void appyPreferences() {
protected void onEnableWindow(boolean enable) {
textField.setEnabled(enable);
sendButton.setEnabled(enable);
serialRates.setEnabled(enable);
clearButton.setEnabled(enable);
}

private void onSerialRateChange(ActionListener listener) {
Expand Down