|
@@ -98,7 +98,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
private JFrame frmCyberPhysical;
|
|
|
|
|
|
- private final SimulationMenu simMenu;
|
|
|
+ private final AlgorithmMenu simMenu;
|
|
|
|
|
|
private JTabbedPane tabTemp; // tabbedPane or tabbedPane2
|
|
|
private final JMenuBar menuBar = new JMenuBar();
|
|
@@ -107,12 +107,14 @@ public class GUI<E> implements CategoryListener {
|
|
|
private final JMenu mnNewMenuOptions = new JMenu("Options");
|
|
|
private final JMenu mnNewMenuView = new JMenu("View");
|
|
|
private final JMenu mnHelp = new JMenu("Help");
|
|
|
+ private final JMenu mnAlgorithm = new JMenu("Algorithm");
|
|
|
private final JMenuItem mntmOpen = new JMenuItem("Open");
|
|
|
private final JMenuItem mntmNew = new JMenuItem("New");
|
|
|
private final JMenuItem mntmSave = new JMenuItem("Save");
|
|
|
- private final JMenuItem aboutUs = new JMenuItem("About Us");
|
|
|
- private final JMenuItem canvasSize = new JMenuItem("View Size");
|
|
|
- private final JMenuItem background = new JMenuItem("Background Image");
|
|
|
+ private final JMenuItem mntmAboutUs = new JMenuItem("About Us");
|
|
|
+ private final JMenuItem mntmCanvasSize = new JMenuItem("View Size");
|
|
|
+ private final JMenuItem mntmBackground = new JMenuItem("Background Image");
|
|
|
+ private final JMenuItem mntmSplitView = new JMenuItem("Split View");
|
|
|
private final JSplitPane splitPane = new JSplitPane();
|
|
|
private final JSplitPane splitPane1 = new JSplitPane();
|
|
|
private final JSplitPane splitPaneCanvasConsole = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
|
|
@@ -122,16 +124,12 @@ public class GUI<E> implements CategoryListener {
|
|
|
// private final JScrollPane holonSP = new JScrollPane();
|
|
|
private final JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
|
|
private final JTabbedPane tabbedPane2 = new JTabbedPane(JTabbedPane.TOP);
|
|
|
- private final JButton splitButton = new JButton("Split View Test");
|
|
|
private JSplitPane tempSplit;
|
|
|
private boolean initSplit = true;
|
|
|
|
|
|
- private final JPanel panelTapped_SimMenu = new JPanel();
|
|
|
private JPopupMenu popmenuEdit = new JPopupMenu();
|
|
|
private JMenuItem editItem = new JMenuItem("Edit Object");
|
|
|
private String catOfObjToBeEdited;
|
|
|
- private final JScrollPane statTab = new JScrollPane();
|
|
|
-
|
|
|
private FlexiblePane flexPane;
|
|
|
private StatPanel2 statSplitPane;
|
|
|
private JScrollPane statScrollPane;
|
|
@@ -301,7 +299,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
control.initListener(this);
|
|
|
controller.setCanvas(canvas);
|
|
|
model.setConsole(console);
|
|
|
- simMenu = new SimulationMenu(model, control);
|
|
|
+ simMenu = new AlgorithmMenu(model, control);
|
|
|
initialize();
|
|
|
updateCategories(model.getCategories());
|
|
|
updCon = new UpdateController(model, controller);
|
|
@@ -416,22 +414,41 @@ public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
+ if (tabbedPane.getMousePosition() != null) {
|
|
|
+ tabTemp = tabbedPane;
|
|
|
+ } else {
|
|
|
+ tabTemp = tabbedPane2;
|
|
|
+ }
|
|
|
// Uppernode Canvas?
|
|
|
- if (((JScrollPane) tabbedPane.getSelectedComponent()).getViewport()
|
|
|
+ if (((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
|
|
|
.getComponent(0) instanceof UpperNodeCanvas) {
|
|
|
- UpperNodeCanvas uNC = (UpperNodeCanvas) ((JScrollPane) tabbedPane.getSelectedComponent())
|
|
|
- .getViewport().getComponent(0);
|
|
|
+ UpperNodeCanvas uNC = (UpperNodeCanvas) ((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
|
|
|
+ .getComponent(0);
|
|
|
for (AbstractCpsObject cps : model.getSelectedCpsObjects()) {
|
|
|
if (uNC.upperNode.getNodes().contains(cps)) {
|
|
|
controller.delObjUpperNode(cps, uNC.upperNode);
|
|
|
// Remove UpperNodeTab if UpperNode deleted
|
|
|
if (cps instanceof CpsUpperNode) {
|
|
|
+ boolean splitView = false;
|
|
|
for (int i = 4; i < tabbedPane.getTabCount(); i++) {
|
|
|
- if (((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i)).getViewport()
|
|
|
- .getComponent(0)).upperNode.getId() == cps.getId()) {
|
|
|
- tabbedPane.remove(i);
|
|
|
- i = tabbedPane.getTabCount();
|
|
|
+ if (tabbedPane.getComponentAt(i) == null) {
|
|
|
+ splitView = true;
|
|
|
+ } else if (((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i))
|
|
|
+ .getViewport().getComponent(0)).upperNode.getId() == cps.getId()) {
|
|
|
+ ((ButtonTabComponent) tabbedPane.getTabComponentAt(i)).removeTabs();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // If SplitView is on and the view on
|
|
|
+ // tabbedPane2 is the deleted upperNode
|
|
|
+ try {
|
|
|
+ if (splitView
|
|
|
+ && ((UpperNodeCanvas) ((JScrollPane) tabbedPane2.getSelectedComponent())
|
|
|
+ .getViewport().getComponent(0)).upperNode.getId() == cps.getId()) {
|
|
|
+ ((ButtonTabComponent) tabbedPane
|
|
|
+ .getTabComponentAt(tabbedPane2.getSelectedIndex())).removeTabs();
|
|
|
}
|
|
|
+ } catch (Exception e2) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -439,7 +456,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
uNC.repaint();
|
|
|
|
|
|
// or Canvas?
|
|
|
- } else if (((JScrollPane) tabbedPane.getSelectedComponent()).getViewport()
|
|
|
+ } else if (((JScrollPane) tabTemp.getSelectedComponent()).getViewport()
|
|
|
.getComponent(0) instanceof MyCanvas) {
|
|
|
boolean save = false;
|
|
|
for (int j = 0; j < model.getSelectedCpsObjects().size(); j++) {
|
|
@@ -449,13 +466,26 @@ public class GUI<E> implements CategoryListener {
|
|
|
controller.delCanvasObject(cps, save);
|
|
|
// Remove UpperNodeTab if UpperNode deleted
|
|
|
if (cps instanceof CpsUpperNode) {
|
|
|
+ boolean splitView = false;
|
|
|
for (int i = 4; i < tabbedPane.getTabCount(); i++) {
|
|
|
- if (((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i)).getViewport()
|
|
|
+ if (tabbedPane.getComponentAt(i) == null) {
|
|
|
+ splitView = true;
|
|
|
+ } else if (((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i)).getViewport()
|
|
|
.getComponent(0)).upperNode.getId() == cps.getId()) {
|
|
|
- tabbedPane.remove(i);
|
|
|
- i = tabbedPane.getTabCount();
|
|
|
+ ((ButtonTabComponent) tabbedPane.getTabComponentAt(i)).removeTabs();
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
+ // If SplitView is on and the view on
|
|
|
+ // tabbedPane2 is the deleted upperNode
|
|
|
+ try {
|
|
|
+ if (splitView && ((UpperNodeCanvas) ((JScrollPane) tabbedPane2.getSelectedComponent())
|
|
|
+ .getViewport().getComponent(0)).upperNode.getId() == cps.getId()) {
|
|
|
+ ((ButtonTabComponent) tabbedPane.getTabComponentAt(tabbedPane2.getSelectedIndex()))
|
|
|
+ .removeTabs();
|
|
|
+ }
|
|
|
+ } catch (Exception e2) {
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
canvas.repaint();
|
|
@@ -670,8 +700,8 @@ public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
menuBar.add(mnNewMenuView);
|
|
|
|
|
|
- mnNewMenuView.add(canvasSize);
|
|
|
- canvasSize.addActionListener(new ActionListener() {
|
|
|
+ mnNewMenuView.add(mntmCanvasSize);
|
|
|
+ mntmCanvasSize.addActionListener(new ActionListener() {
|
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
JPanel myPanel = new JPanel();
|
|
@@ -712,10 +742,53 @@ public class GUI<E> implements CategoryListener {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- mnNewMenuView.add(canvasSize);
|
|
|
+ mnNewMenuView.add(mntmCanvasSize);
|
|
|
+ mnNewMenuView.add(mntmSplitView);
|
|
|
+
|
|
|
+ // Split View
|
|
|
+ mntmSplitView.addActionListener(new ActionListener() {
|
|
|
+ @Override
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
+ if (splitPaneCanvasConsole.getLeftComponent() instanceof JSplitPane) {
|
|
|
+ initSplit = true;
|
|
|
+ Component tempC = tabbedPane2.getSelectedComponent();
|
|
|
+ tabbedPane.setComponentAt(tabbedPane2.getSelectedIndex(), tempC);
|
|
|
+ tabbedPane2.removeAll();
|
|
|
+ splitPaneCanvasConsole.setLeftComponent(tabbedPane);
|
|
|
+ } else {
|
|
|
+ for (int i = 0; i < tabbedPane.getTabCount(); i++) {
|
|
|
+ tabbedPane2.addTab(tabbedPane.getTitleAt(i), null);
|
|
|
+ if (i >= 4) {
|
|
|
+ // tabbedPane2.setTabComponentAt(tabbedPane.getTabCount()
|
|
|
+ // - 1,
|
|
|
+ // new ButtonTabComponent(tabbedPane, tabbedPane2));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (tabbedPane.getSelectedComponent() == statScrollPane) {
|
|
|
+ tabbedPane.setComponentAt(0, null);
|
|
|
+ tabbedPane2.setComponentAt(0, canvasSP);
|
|
|
+ tabbedPane2.setSelectedIndex(0);
|
|
|
+ } else {
|
|
|
+ tabbedPane.setComponentAt(1, null);
|
|
|
+ tabbedPane2.setComponentAt(1, statScrollPane);
|
|
|
+ tabbedPane2.setSelectedIndex(1);
|
|
|
+ }
|
|
|
+ tempSplit = new JSplitPane();
|
|
|
+ tempSplit.setBorder(null);
|
|
|
+ tempSplit.setRightComponent(tabbedPane2);
|
|
|
+ tempSplit.setLeftComponent(tabbedPane);
|
|
|
+ tempSplit.setDividerLocation(tabbedPane.getWidth() / 2);
|
|
|
+ tempSplit.setResizeWeight(0.9);
|
|
|
+ splitPaneCanvasConsole.setLeftComponent(tempSplit);
|
|
|
+ initSplit = false;
|
|
|
+ }
|
|
|
+ contentPane.updateUI();
|
|
|
+ }
|
|
|
|
|
|
- mnNewMenuView.add(background);
|
|
|
- background.addActionListener(new ActionListener() {
|
|
|
+ });
|
|
|
+ mnNewMenuView.add(mntmBackground);
|
|
|
+
|
|
|
+ mntmBackground.addActionListener(new ActionListener() {
|
|
|
|
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
@@ -759,57 +832,15 @@ public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
splitPane_1.setLeftComponent(lblHolonBodySize);
|
|
|
|
|
|
- menuBar.add(mnHelp);
|
|
|
+ mnAlgorithm.add(simMenu);
|
|
|
|
|
|
- mnHelp.add(aboutUs);
|
|
|
+ menuBar.add(mnAlgorithm);
|
|
|
|
|
|
- // Testing
|
|
|
- menuBar.add(splitButton);
|
|
|
- // Split View
|
|
|
- splitButton.addActionListener(new ActionListener() {
|
|
|
- @Override
|
|
|
- public void actionPerformed(ActionEvent e) {
|
|
|
- if (panelTapped_SimMenu
|
|
|
- .getComponent(panelTapped_SimMenu.getComponentCount() - 1) instanceof JSplitPane) {
|
|
|
- initSplit = true;
|
|
|
- Component tempC = tabbedPane2.getSelectedComponent();
|
|
|
- tabbedPane.setComponentAt(tabbedPane2.getSelectedIndex(), tempC);
|
|
|
- tabbedPane2.removeAll();
|
|
|
- panelTapped_SimMenu
|
|
|
- .remove(panelTapped_SimMenu.getComponent(panelTapped_SimMenu.getComponentCount() - 1));
|
|
|
- panelTapped_SimMenu.add(tabbedPane);
|
|
|
- } else {
|
|
|
- for (int i = 0; i < tabbedPane.getTabCount(); i++) {
|
|
|
- tabbedPane2.addTab(tabbedPane.getTitleAt(i), null);
|
|
|
- if (i >= 4) {
|
|
|
- // tabbedPane2.setTabComponentAt(tabbedPane.getTabCount()
|
|
|
- // - 1,
|
|
|
- // new ButtonTabComponent(tabbedPane, tabbedPane2));
|
|
|
- }
|
|
|
- }
|
|
|
- if (tabbedPane.getSelectedComponent() == statScrollPane) {
|
|
|
- tabbedPane.setComponentAt(0, null);
|
|
|
- tabbedPane2.setComponentAt(0, canvasSP);
|
|
|
- tabbedPane2.setSelectedIndex(0);
|
|
|
- } else {
|
|
|
- tabbedPane.setComponentAt(1, null);
|
|
|
- tabbedPane2.setComponentAt(1, statScrollPane);
|
|
|
- tabbedPane2.setSelectedIndex(1);
|
|
|
- }
|
|
|
- tempSplit = new JSplitPane();
|
|
|
- tempSplit.setBorder(null);
|
|
|
- tempSplit.setRightComponent(tabbedPane2);
|
|
|
- tempSplit.setLeftComponent(tabbedPane);
|
|
|
- tempSplit.setDividerLocation(tabbedPane.getWidth() / 2);
|
|
|
- tempSplit.setResizeWeight(0.9);
|
|
|
- panelTapped_SimMenu.remove(tabbedPane);
|
|
|
- panelTapped_SimMenu.add(tempSplit);
|
|
|
- initSplit = false;
|
|
|
- }
|
|
|
- contentPane.updateUI();
|
|
|
- }
|
|
|
+ menuBar.add(mnHelp);
|
|
|
|
|
|
- });
|
|
|
+ mnHelp.add(mntmAboutUs);
|
|
|
+
|
|
|
+
|
|
|
|
|
|
tabbedPane.addChangeListener(new ChangeListener() {
|
|
|
|
|
@@ -1502,7 +1533,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
* Pop up - About Us with some important information about the
|
|
|
* developers, source and programming stuff
|
|
|
*/
|
|
|
- aboutUs.addMouseListener(new MouseAdapter() {
|
|
|
+ mntmAboutUs.addMouseListener(new MouseAdapter() {
|
|
|
@Override
|
|
|
public void mousePressed(MouseEvent e) {
|
|
|
aboutUsPopUp = new AboutUsPopUp();
|
|
@@ -1560,6 +1591,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
} else if (model.getSelectedCpsObjects().size() == 1) {
|
|
|
model.getTableHolonElement().setModel(model.getSingleTable());
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -1851,7 +1883,9 @@ public class GUI<E> implements CategoryListener {
|
|
|
controller.runAlgorithm(model, controller);
|
|
|
controller.calculateStateForTimeStep(i);
|
|
|
unitGraph.repaint();
|
|
|
- statSplitPane.repaintGraphs();
|
|
|
+ if (model.getIsSimRunning()) {
|
|
|
+ statSplitPane.repaintGraphs();
|
|
|
+ }
|
|
|
contentPane.updateUI();
|
|
|
}
|
|
|
});
|
|
@@ -1863,7 +1897,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
splitPaneCanvasConsole.setResizeWeight(0.9);
|
|
|
|
|
|
splitPane.setLeftComponent(scrollPane1);
|
|
|
- splitPaneCanvasConsole.setLeftComponent(panelTapped_SimMenu);
|
|
|
+ splitPaneCanvasConsole.setLeftComponent(tabbedPane);
|
|
|
tabbedPane.addTab("View", canvasSP);
|
|
|
tabbedPane.addTab("Statistics", statScrollPane);
|
|
|
tabbedPane.addTab("Holon", holonCanvas);
|
|
@@ -1885,12 +1919,8 @@ public class GUI<E> implements CategoryListener {
|
|
|
splitGraphHolonEl.setBottomComponent(scrollElements);
|
|
|
canvasSP.setViewportView(canvas);
|
|
|
// holonSP.setViewportView(holonCanvas);
|
|
|
- panelTapped_SimMenu.setLayout(new BorderLayout());
|
|
|
- panelTapped_SimMenu.add(simMenu, BorderLayout.NORTH);
|
|
|
- panelTapped_SimMenu.add(tabbedPane);
|
|
|
simMenu.setBackground(new Color(240, 240, 240));
|
|
|
|
|
|
- panelTapped_SimMenu.setBorder(null);
|
|
|
tabbedPane.setBorder(null);
|
|
|
scrollProperties.setBorder(null);
|
|
|
scrollGraph.setBorder(null);
|
|
@@ -2092,9 +2122,9 @@ public class GUI<E> implements CategoryListener {
|
|
|
mnNewMenuOptions.setText(tempArray[9]);
|
|
|
mntmResetCategory.setText(tempArray[10]);
|
|
|
mnNewMenuView.setText(tempArray[11]);
|
|
|
- canvasSize.setText(tempArray[12]);
|
|
|
+ mntmCanvasSize.setText(tempArray[12]);
|
|
|
mnHelp.setText(tempArray[13]);
|
|
|
- aboutUs.setText(tempArray[14]);
|
|
|
+ mntmAboutUs.setText(tempArray[14]);
|
|
|
mntmEditEdges.setText(tempArray[15]);
|
|
|
mnLanguage.setText(tempArray[16]);
|
|
|
canvas.updateLanguages();
|
|
@@ -2221,6 +2251,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
JScrollPane sp = new JScrollPane(unc);
|
|
|
sp.setBorder(null);
|
|
|
+ // Selected tabbed Pane = tabbedPane or tabbedPane2
|
|
|
if (tabTemp == tabbedPane) {
|
|
|
tabbedPane.add(temp.getName(), sp);
|
|
|
tabbedPane.setSelectedComponent(sp);
|