1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-26 20:54:22 +01:00

fixed method name

use also for size command a seperate function
This commit is contained in:
Wilhelm Wiens 2020-04-09 17:41:51 +02:00
parent 450c40d9f2
commit 945f542ed5

View File

@ -261,9 +261,9 @@ public class SerialPlotter extends AbstractMonitor {
messageBuffer = new StringBuffer(); messageBuffer = new StringBuffer();
graphs = new ArrayList<>(); graphs = new ArrayList<>();
graphWidth.addChangeListener(cl -> {setNewBufferCapacity((int)graphWidth.getValue()); } ); graphWidth.addChangeListener(cl -> {commandNewSize((int)graphWidth.getValue()); } );
clearButton.addActionListener(ae -> {CommandClearGraph();}); clearButton.addActionListener(ae -> {commandClearGraph();});
} }
protected void onCreateWindow(Container mainPane) { protected void onCreateWindow(Container mainPane) {
@ -429,12 +429,20 @@ public class SerialPlotter extends AbstractMonitor {
} }
} }
private void CommandClearGraph() private void commandClearGraph()
{ {
graphs.clear(); graphs.clear();
xCount=0; xCount=0;
} }
private void commandNewSize(int newSize)
{
setNewBufferCapacity(newSize);
if((int)graphWidth.getValue() != newSize) {
graphWidth.setValue(newSize);
}
}
public void message(final String s) { public void message(final String s) {
messageBuffer.append(s); messageBuffer.append(s);
while (true) { while (true) {
@ -463,7 +471,7 @@ public class SerialPlotter extends AbstractMonitor {
if(parts[i].startsWith("#") && parts[i].length() > 1) { if(parts[i].startsWith("#") && parts[i].length() > 1) {
String command = parts[i].substring(1, parts[i].length()).trim(); String command = parts[i].substring(1, parts[i].length()).trim();
if("CLEAR".equals(command)) { if("CLEAR".equals(command)) {
CommandClearGraph(); commandClearGraph();
} }
else if(command.startsWith("SIZE:")) { else if(command.startsWith("SIZE:")) {
String[] subString = parts[i].split("[:]+"); String[] subString = parts[i].split("[:]+");
@ -475,9 +483,7 @@ public class SerialPlotter extends AbstractMonitor {
// Ignore // Ignore
} }
} }
if((int)graphWidth.getValue() != newSize) { commandNewSize(newSize);
graphWidth.setValue(newSize);
}
} }
} else { } else {
try { try {