mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-27 06:51:37 -04:00
minor refactorings
This commit is contained in:
parent
748634bcea
commit
89c2c4679d
@ -36,7 +36,6 @@ public class GraphDialog extends JDialog implements Observer {
|
|||||||
private static final Icon ICON_ZOOM_IN = IconCreator.create("View-zoom-in.png");
|
private static final Icon ICON_ZOOM_IN = IconCreator.create("View-zoom-in.png");
|
||||||
private static final Icon ICON_ZOOM_OUT = IconCreator.create("View-zoom-out.png");
|
private static final Icon ICON_ZOOM_OUT = IconCreator.create("View-zoom-out.png");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a instance prepared for "live logging"
|
* Creates a instance prepared for "live logging"
|
||||||
*
|
*
|
||||||
@ -63,9 +62,22 @@ public class GraphDialog extends JDialog implements Observer {
|
|||||||
}.order(signals);
|
}.order(signals);
|
||||||
|
|
||||||
ValueTableObserver valueTableObserver = new ValueTableObserver(microStep, signals, MAX_SAMPLE_SIZE);
|
ValueTableObserver valueTableObserver = new ValueTableObserver(microStep, signals, MAX_SAMPLE_SIZE);
|
||||||
ValueTable logData = valueTableObserver.getLogData();
|
|
||||||
|
|
||||||
return new GraphDialog(owner, title, model, logData, valueTableObserver, modelSync);
|
GraphDialog graphDialog = new GraphDialog(owner, title, valueTableObserver.getLogData(), modelSync);
|
||||||
|
|
||||||
|
graphDialog.addWindowListener(new WindowAdapter() {
|
||||||
|
@Override
|
||||||
|
public void windowOpened(WindowEvent e) {
|
||||||
|
modelSync.access(() -> model.addObserver(valueTableObserver));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void windowClosed(WindowEvent e) {
|
||||||
|
modelSync.access(() -> model.removeObserver(valueTableObserver));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return graphDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,7 +88,7 @@ public class GraphDialog extends JDialog implements Observer {
|
|||||||
* @param logData the data to visualize
|
* @param logData the data to visualize
|
||||||
*/
|
*/
|
||||||
public GraphDialog(JFrame owner, String title, ValueTable logData) {
|
public GraphDialog(JFrame owner, String title, ValueTable logData) {
|
||||||
this(owner, title, null, logData, null, NoSync.INST);
|
this(owner, title, logData, NoSync.INST);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -84,11 +96,10 @@ public class GraphDialog extends JDialog implements Observer {
|
|||||||
*
|
*
|
||||||
* @param owner the parent frame
|
* @param owner the parent frame
|
||||||
* @param title the frame title
|
* @param title the frame title
|
||||||
* @param model the model used to collect the data
|
|
||||||
* @param logData the data to visualize
|
* @param logData the data to visualize
|
||||||
* @param modelSync used to access the running model
|
* @param modelSync used to access the running model
|
||||||
*/
|
*/
|
||||||
private GraphDialog(JFrame owner, String title, Model model, ValueTable logData, ValueTableObserver valueTableObserver, Sync modelSync) {
|
private GraphDialog(JFrame owner, String title, ValueTable logData, Sync modelSync) {
|
||||||
super(owner, title, false);
|
super(owner, title, false);
|
||||||
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||||
setAlwaysOnTop(true);
|
setAlwaysOnTop(true);
|
||||||
@ -125,7 +136,7 @@ public class GraphDialog extends JDialog implements Observer {
|
|||||||
showTable = new ToolTipAction(Lang.get("menu_showDataAsTable")) {
|
showTable = new ToolTipAction(Lang.get("menu_showDataAsTable")) {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
new ValueTableDialog(owner, title)
|
new ValueTableDialog(owner, title) // ToDo pass modelSync to ValueTableDialog
|
||||||
.addValueTable(Lang.get("win_data"), logData).disableGraph()
|
.addValueTable(Lang.get("win_data"), logData).disableGraph()
|
||||||
.setVisible(true);
|
.setVisible(true);
|
||||||
}
|
}
|
||||||
@ -138,19 +149,6 @@ public class GraphDialog extends JDialog implements Observer {
|
|||||||
getContentPane().add(toolBar, BorderLayout.NORTH);
|
getContentPane().add(toolBar, BorderLayout.NORTH);
|
||||||
pack();
|
pack();
|
||||||
|
|
||||||
if (model != null)
|
|
||||||
addWindowListener(new WindowAdapter() {
|
|
||||||
@Override
|
|
||||||
public void windowOpened(WindowEvent e) {
|
|
||||||
modelSync.access(() -> model.addObserver(valueTableObserver));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void windowClosed(WindowEvent e) {
|
|
||||||
modelSync.access(() -> model.removeObserver(valueTableObserver));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
scrollPane.getViewport().setPreferredSize(dsc.getPreferredSize());
|
scrollPane.getViewport().setPreferredSize(dsc.getPreferredSize());
|
||||||
|
|
||||||
JMenuBar bar = new JMenuBar();
|
JMenuBar bar = new JMenuBar();
|
||||||
|
@ -35,14 +35,10 @@ public class ValueTableObserver implements ModelStateObserver {
|
|||||||
else
|
else
|
||||||
this.type = ModelEvent.STEP;
|
this.type = ModelEvent.STEP;
|
||||||
|
|
||||||
this.logData = new ValueTable(createNames(signals)).setMaxSize(maxSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String[] createNames(ArrayList<Signal> signals) {
|
|
||||||
String[] names = new String[signals.size()];
|
String[] names = new String[signals.size()];
|
||||||
for (int i = 0; i < signals.size(); i++)
|
for (int i = 0; i < signals.size(); i++)
|
||||||
names[i] = signals.get(i).getName();
|
names[i] = signals.get(i).getName();
|
||||||
return names;
|
this.logData = new ValueTable(names).setMaxSize(maxSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,6 +26,7 @@ import java.util.Collections;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Dialog to show the testing results.
|
* Dialog to show the testing results.
|
||||||
|
* ToDo: Sync of data access is missing!
|
||||||
*
|
*
|
||||||
* @author hneemann
|
* @author hneemann
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user