mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-22 20:01:09 -04:00
fixes a sync issue in the data plotter
This commit is contained in:
parent
b84a921f86
commit
f39284c02c
@ -23,11 +23,11 @@ import javax.swing.*;
|
||||
public class DataPlotter implements Drawable {
|
||||
private final ValueTable dataOriginal;
|
||||
private final int textWidth;
|
||||
private final SyncAccess modelSync;
|
||||
private double size = SIZE;
|
||||
private int offset = 0;
|
||||
private int width = 0;
|
||||
private boolean manualScaling = false;
|
||||
private SyncAccess modelSync = SyncAccess.NOSYNC;
|
||||
private JScrollBar scrollBar;
|
||||
private int autoScaleOffset;
|
||||
|
||||
@ -36,8 +36,9 @@ public class DataPlotter implements Drawable {
|
||||
*
|
||||
* @param data the signals used to collect DataSamples
|
||||
*/
|
||||
public DataPlotter(ValueTable data) {
|
||||
public DataPlotter(ValueTable data, SyncAccess modelSync) {
|
||||
this.dataOriginal = data;
|
||||
this.modelSync = modelSync;
|
||||
int tl = 0;
|
||||
for (int i = 0; i < data.getColumns(); i++) {
|
||||
String text = data.getColumnName(i);
|
||||
@ -239,17 +240,6 @@ public class DataPlotter implements Drawable {
|
||||
}).r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets lock to access the data
|
||||
*
|
||||
* @param modelSync the lock
|
||||
* @return this for chained calls
|
||||
*/
|
||||
public DataPlotter setModelSync(SyncAccess modelSync) {
|
||||
this.modelSync = modelSync;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the width of the parents container
|
||||
*
|
||||
|
@ -7,6 +7,7 @@ package de.neemann.digital.draw.shapes;
|
||||
|
||||
import de.neemann.digital.core.Model;
|
||||
import de.neemann.digital.core.Signal;
|
||||
import de.neemann.digital.core.SyncAccess;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.core.element.Keys;
|
||||
import de.neemann.digital.core.element.PinDescriptions;
|
||||
@ -34,6 +35,7 @@ public class DataShape implements Shape {
|
||||
private final int maxSize;
|
||||
private ValueTable logDataModel;
|
||||
private ValueTable logData;
|
||||
private SyncAccess modelSync = SyncAccess.NOSYNC;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
@ -71,11 +73,12 @@ public class DataShape implements Shape {
|
||||
.add(new TestRow(new Value(0), new Value(0), new Value(0)))
|
||||
.add(new TestRow(new Value(0), new Value(1), new Value(0)));
|
||||
}
|
||||
new DataPlotter(logData).drawTo(graphic, null);
|
||||
new DataPlotter(logData, modelSync).drawTo(graphic, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerModel(ModelCreator modelCreator, Model model, ModelEntry element) {
|
||||
modelSync = model;
|
||||
ArrayList<Signal> signals = model.getSignalsCopy();
|
||||
signals.removeIf(signal -> !signal.isShowInGraph());
|
||||
new OrderMerger<String, Signal>(modelCreator.getCircuit().getMeasurementOrdering()) {
|
||||
|
@ -31,7 +31,7 @@ public class GraphComponent extends JComponent {
|
||||
* @param modelSync lock to access the model
|
||||
*/
|
||||
GraphComponent(ValueTable dataSet, SyncAccess modelSync) {
|
||||
plotter = new DataPlotter(dataSet).setModelSync(modelSync);
|
||||
plotter = new DataPlotter(dataSet, modelSync);
|
||||
addMouseWheelListener(e -> {
|
||||
double f = Math.pow(0.9, e.getWheelRotation());
|
||||
scale(f, e.getX());
|
||||
|
Loading…
x
Reference in New Issue
Block a user