Skip to content
Snippets Groups Projects
Commit 25f0d159 authored by apvrille's avatar apvrille
Browse files

Adding SVG sage to diplodocus simulation trace

parent 2ca20f49
No related branches found
No related tags found
No related merge requests found
Source diff could not be displayed: it is too large. Options to address this: view the blob.
...@@ -105,7 +105,12 @@ public class InteractiveSimulationActions extends AbstractAction { ...@@ -105,7 +105,12 @@ public class InteractiveSimulationActions extends AbstractAction {
public static final int ACT_ANALYSIS_RG = 30; public static final int ACT_ANALYSIS_RG = 30;
public static final int ACT_VIEW_RG = 31; public static final int ACT_VIEW_RG = 31;
public static final int ACT_SHOW_TRACE = 36; public static final int ACT_SHOW_TRACE = 36;
public static final int NB_ACTION = 37;
public static final int ACT_QUIT_SD_WINDOW = 37;
public static final int ACT_SAVE_SD_SVG = 38;
public static final int NB_ACTION = 39;
private static final TAction [] actions = new TAction[NB_ACTION]; private static final TAction [] actions = new TAction[NB_ACTION];
...@@ -191,6 +196,8 @@ public class InteractiveSimulationActions extends AbstractAction { ...@@ -191,6 +196,8 @@ public class InteractiveSimulationActions extends AbstractAction {
actions[ACT_ADD_LATENCY] = new TAction("add-latency", "Measure Latency", null, null, "Measure Latency", "Measure Latency", '0'); actions[ACT_ADD_LATENCY] = new TAction("add-latency", "Measure Latency", null, null, "Measure Latency", "Measure Latency", '0');
actions[ACT_SHOW_TRACE] = new TAction("show-trace", "Show Simulation Traces", IconManager.imgic7007, IconManager.imgic7007, "Show Simulation Traces", "Show Simulation Traces", '0'); actions[ACT_SHOW_TRACE] = new TAction("show-trace", "Show Simulation Traces", IconManager.imgic7007, IconManager.imgic7007, "Show Simulation Traces", "Show Simulation Traces", '0');
actions[ACT_QUIT_SD_WINDOW] = new TAction("close-sdpanel", "Close Window", IconManager.imgic27, IconManager.imgic27, "Close window", "Close this window", 'Q');
actions[ACT_SAVE_SD_SVG] = new TAction("svg-sdpanel", "Save in SVG Format", IconManager.imgic1310, IconManager.imgic1310, "Save in SVG Format", "Save as SVG file", 'S');
} }
......
...@@ -104,7 +104,7 @@ public class JFrameSimulationSDPanel extends JFrame implements ActionListener { ...@@ -104,7 +104,7 @@ public class JFrameSimulationSDPanel extends JFrame implements ActionListener {
// Top panel // Top panel
JPanel topPanel = new JPanel(); JPanel topPanel = new JPanel();
JButton buttonClose = new JButton(actions[InteractiveSimulationActions.ACT_STOP_ALL]); JButton buttonClose = new JButton(actions[InteractiveSimulationActions.ACT_QUIT_SD_WINDOW]);
topPanel.add(buttonClose); topPanel.add(buttonClose);
topPanel.add(new JLabel(" time unit:")); topPanel.add(new JLabel(" time unit:"));
units = new JComboBox<>(unitTab); units = new JComboBox<>(unitTab);
...@@ -164,7 +164,7 @@ public class JFrameSimulationSDPanel extends JFrame implements ActionListener { ...@@ -164,7 +164,7 @@ public class JFrameSimulationSDPanel extends JFrame implements ActionListener {
String command = evt.getActionCommand(); String command = evt.getActionCommand();
//TraceManager.addDev("Command:" + command); //TraceManager.addDev("Command:" + command);
if (command.equals(actions[InteractiveSimulationActions.ACT_STOP_ALL].getActionCommand())) { if (command.equals(actions[InteractiveSimulationActions.ACT_QUIT_SD_WINDOW].getActionCommand())) {
close(); close();
} else if (command.equals(actions[InteractiveSimulationActions.ACT_REFRESH].getActionCommand())) { } else if (command.equals(actions[InteractiveSimulationActions.ACT_REFRESH].getActionCommand())) {
refresh(); refresh();
......
...@@ -41,6 +41,9 @@ ...@@ -41,6 +41,9 @@
package ui.interactivesimulation; package ui.interactivesimulation;
import common.ConfigurationTTool;
import myutil.FileUtils;
import myutil.SVGGeneration;
import myutil.TraceManager; import myutil.TraceManager;
import ui.ColorManager; import ui.ColorManager;
import ui.MainGUI; import ui.MainGUI;
...@@ -52,12 +55,13 @@ import java.awt.event.ActionListener; ...@@ -52,12 +55,13 @@ import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter; import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent; import java.awt.event.ComponentEvent;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File;
/** /**
* Class JFrameSimulationSDPanel * Class JFrameSimulationSDPanel
* Creation: 26/05/2011 * Creation: 26/05/2011
* version 1.0 26/05/2011 * version 1.0 20/06/2018
* @author Ludovic APVRILLE * @author Ludovic APVRILLE
*/ */
public class JFrameTMLSimulationPanel extends JFrame implements ActionListener { public class JFrameTMLSimulationPanel extends JFrame implements ActionListener {
...@@ -73,10 +77,12 @@ public class JFrameTMLSimulationPanel extends JFrame implements ActionListener { ...@@ -73,10 +77,12 @@ public class JFrameTMLSimulationPanel extends JFrame implements ActionListener {
//, buttonStart, buttonStopAndClose; //, buttonStart, buttonStopAndClose;
//protected JTextArea jta; //protected JTextArea jta;
//protected JScrollPane jsp; //protected JScrollPane jsp;
private MainGUI mgui;
public JFrameTMLSimulationPanel(Frame _f, MainGUI _mgui, String _title) { public JFrameTMLSimulationPanel(Frame _f, MainGUI _mgui, String _title) {
super(_title); super(_title);
mgui = _mgui;
initActions(); initActions();
makeComponents(); makeComponents();
//setComponents(); //setComponents();
...@@ -104,8 +110,10 @@ public class JFrameTMLSimulationPanel extends JFrame implements ActionListener { ...@@ -104,8 +110,10 @@ public class JFrameTMLSimulationPanel extends JFrame implements ActionListener {
// Top panel // Top panel
JPanel topPanel = new JPanel(); JPanel topPanel = new JPanel();
JButton buttonClose = new JButton(actions[InteractiveSimulationActions.ACT_STOP_ALL]); JButton buttonClose = new JButton(actions[InteractiveSimulationActions.ACT_QUIT_SD_WINDOW]);
topPanel.add(buttonClose); topPanel.add(buttonClose);
JButton buttonSVG = new JButton(actions[InteractiveSimulationActions.ACT_SAVE_SD_SVG]);
topPanel.add(buttonSVG);
/*topPanel.add(new JLabel(" time unit:")); /*topPanel.add(new JLabel(" time unit:"));
units = new JComboBox<>(unitTab); units = new JComboBox<>(unitTab);
units.setSelectedIndex(1); units.setSelectedIndex(1);
...@@ -148,57 +156,56 @@ public class JFrameTMLSimulationPanel extends JFrame implements ActionListener { ...@@ -148,57 +156,56 @@ public class JFrameTMLSimulationPanel extends JFrame implements ActionListener {
//actions[i].addKeyListener(this); //actions[i].addKeyListener(this);
} }
} }
public void close() { public void close() {
dispose(); dispose();
setVisible(false); setVisible(false);
} }
private void refresh() { private void saveSVG() {
if (sdpanel != null ){ TraceManager.addDev("Saving in svg format");
sdpanel.refresh(); File file = mgui.selectSVGFileForCapture(true);
}
}
boolean ok = true;
try {
ok = FileUtils.checkFileForSave(file);
} catch (Exception e) {
ok = false;
}
if (!ok) {
JOptionPane.showMessageDialog(this,
"The capture could not be performed: the specified file is not valid",
"Error",
JOptionPane.INFORMATION_MESSAGE);
return;
}
SVGGeneration gen = new SVGGeneration();
gen.saveInSVG(sdpanel, file.getAbsolutePath());
//newSVGSave(fileName);
}
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
String command = evt.getActionCommand(); String command = evt.getActionCommand();
//TraceManager.addDev("Command:" + command); //TraceManager.addDev("Command:" + command);
if (command.equals(actions[InteractiveSimulationActions.ACT_STOP_ALL].getActionCommand())) { if (command.equals(actions[InteractiveSimulationActions.ACT_QUIT_SD_WINDOW].getActionCommand())) {
close(); close();
} else if (command.equals(actions[InteractiveSimulationActions.ACT_REFRESH].getActionCommand())) { } else if (command.equals(actions[InteractiveSimulationActions.ACT_SAVE_SD_SVG].getActionCommand())) {
refresh(); saveSVG();
} else if (evt.getSource() == units) {
if (sdpanel != null) {
switch(units.getSelectedIndex()) {
case 0:
}
sdpanel.setClockDiviser(clockDivisers[units.getSelectedIndex()]);
}
} }
} }
public void setFileReference(String _fileReference) {
if (sdpanel != null) {
TraceManager.addDev("Resetting file");
sdpanel.setFileReference(_fileReference);
}
}
public void setFileReference(BufferedReader inputStream) { public void setFileReference(BufferedReader inputStream) {
if (sdpanel != null) { if (sdpanel != null) {
sdpanel.setFileReference(inputStream); sdpanel.setFileReference(inputStream);
} }
} }
public void setCurrentTime(long timeValue) {
status.setText("time = " + timeValue);
}
public void setStatus(String _status) { public void setStatus(String _status) {
status.setText(_status); status.setText(_status);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment