|
@@ -92,7 +92,8 @@ import ui.model.DecoratedState;
|
|
import ui.model.Model;
|
|
import ui.model.Model;
|
|
import ui.model.Model.FairnessModel;
|
|
import ui.model.Model.FairnessModel;
|
|
import ui.view.CreateNewDialog.Option;
|
|
import ui.view.CreateNewDialog.Option;
|
|
-import utility.ImageImport;
|
|
|
|
|
|
+import util.Event;
|
|
|
|
+import util.ImageImport;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Graphical User Interface.
|
|
* Graphical User Interface.
|
|
@@ -103,6 +104,10 @@ public class GUI{
|
|
|
|
|
|
static final Color PALE_RED=new Color(255, 192, 192);
|
|
static final Color PALE_RED=new Color(255, 192, 192);
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Menu on the Top containing File, Edit View Help etc
|
|
* Menu on the Top containing File, Edit View Help etc
|
|
*/
|
|
*/
|
|
@@ -113,6 +118,9 @@ public class GUI{
|
|
private final JMenu mnNewMenuView = new JMenu("View");
|
|
private final JMenu mnNewMenuView = new JMenu("View");
|
|
private final JMenu menuWindow = new JMenu("Window");
|
|
private final JMenu menuWindow = new JMenu("Window");
|
|
|
|
|
|
|
|
+
|
|
|
|
+ private final HolonInformationPanel informationPanel;
|
|
|
|
+
|
|
/** Help Menu containing helpful Informations and the AboutUs Popup */
|
|
/** Help Menu containing helpful Informations and the AboutUs Popup */
|
|
private final JMenu mnHelp = new JMenu("Help");
|
|
private final JMenu mnHelp = new JMenu("Help");
|
|
|
|
|
|
@@ -192,31 +200,7 @@ public class GUI{
|
|
// Model for single or multi selection
|
|
// Model for single or multi selection
|
|
private final JPanel scrollElements = new JPanel();
|
|
private final JPanel scrollElements = new JPanel();
|
|
private final JScrollPane tableHolonElementScrollPane = new JScrollPane();
|
|
private final JScrollPane tableHolonElementScrollPane = new JScrollPane();
|
|
- // In this section are all the properties that correspond to the clicked
|
|
|
|
- // HolonObject, such as connections, name, Type, etc.
|
|
|
|
- // Table for Properties --> Cell with (0,1) is editable by CpsObjt and
|
|
|
|
- // Cell(3,1) is editable by Edges
|
|
|
|
- private final JTable tableProperties = new JTable() {
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public TableCellRenderer getCellRenderer(int row, int column) {
|
|
|
|
- if (getValueAt(row, column) instanceof Boolean) {
|
|
|
|
- return super.getDefaultRenderer(Boolean.class);
|
|
|
|
- } else {
|
|
|
|
- return super.getCellRenderer(row, column);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public TableCellEditor getCellEditor(int row, int column) {
|
|
|
|
- if (getValueAt(row, column) instanceof Boolean) {
|
|
|
|
- return super.getDefaultEditor(Boolean.class);
|
|
|
|
- } else {
|
|
|
|
- return super.getCellEditor(row, column);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
- };
|
|
|
|
//Prechoosed local Periods
|
|
//Prechoosed local Periods
|
|
private String[] comboContext = {
|
|
private String[] comboContext = {
|
|
"", "5", "10", "20" ,"100", "1000"
|
|
"", "5", "10", "20" ,"100", "1000"
|
|
@@ -229,7 +213,6 @@ public class GUI{
|
|
private final JScrollPane scrollProperties = new JScrollPane();
|
|
private final JScrollPane scrollProperties = new JScrollPane();
|
|
// In this section is the graph for the selected HolonElement of the clicked
|
|
// In this section is the graph for the selected HolonElement of the clicked
|
|
// HolonObject
|
|
// HolonObject
|
|
- private final JTable tableGraph = new JTable();
|
|
|
|
private final DefaultTableModel tableModelGraph = new DefaultTableModel();
|
|
private final DefaultTableModel tableModelGraph = new DefaultTableModel();
|
|
private final JScrollPane scrollGraph = new JScrollPane();
|
|
private final JScrollPane scrollGraph = new JScrollPane();
|
|
private final Model model;
|
|
private final Model model;
|
|
@@ -304,10 +287,6 @@ public class GUI{
|
|
private int yBTis;
|
|
private int yBTis;
|
|
private int xBThis;
|
|
private int xBThis;
|
|
// Coord for the Edit-Modus in the PropertieTable
|
|
// Coord for the Edit-Modus in the PropertieTable
|
|
- private int yProThis;
|
|
|
|
- private int xProThis;
|
|
|
|
- private int yProThisOneClick;
|
|
|
|
- private int xProThisOneClick;
|
|
|
|
private AbstractCanvasObject temp = null;
|
|
private AbstractCanvasObject temp = null;
|
|
private String warningText = "Warning";
|
|
private String warningText = "Warning";
|
|
private String saveBeforeNew = "Do you want to save your current data?";
|
|
private String saveBeforeNew = "Do you want to save your current data?";
|
|
@@ -329,11 +308,11 @@ public class GUI{
|
|
*/
|
|
*/
|
|
GUI(Control control) {
|
|
GUI(Control control) {
|
|
this.controller = control;
|
|
this.controller = control;
|
|
|
|
+ this.informationPanel = new HolonInformationPanel(control);
|
|
this.model = control.getModel();
|
|
this.model = control.getModel();
|
|
control.setGui(this);
|
|
control.setGui(this);
|
|
this.unitGraph = new UnitGraph(model, control);
|
|
this.unitGraph = new UnitGraph(model, control);
|
|
this.canvas = new MyCanvas(model, control, unitGraph);
|
|
this.canvas = new MyCanvas(model, control, unitGraph);
|
|
- model.setTableProperties(tableProperties);
|
|
|
|
initialize();
|
|
initialize();
|
|
updateCategories(model.getCategories());
|
|
updateCategories(model.getCategories());
|
|
updCon = new UpdateController(model, controller);
|
|
updCon = new UpdateController(model, controller);
|
|
@@ -451,7 +430,7 @@ public class GUI{
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
chooseTabTemp();
|
|
chooseTabTemp();
|
|
|
|
|
|
- model.getSelectedCpsObjects().clear();
|
|
|
|
|
|
+ controller.clearSelection();
|
|
|
|
|
|
// Uppernode Canvas?
|
|
// Uppernode Canvas?
|
|
JScrollPane scrollPane = getScrollPaneFromTabbedPane();
|
|
JScrollPane scrollPane = getScrollPaneFromTabbedPane();
|
|
@@ -539,7 +518,7 @@ public class GUI{
|
|
controller.calculateStateAndVisualForCurrentTimeStep();
|
|
controller.calculateStateAndVisualForCurrentTimeStep();
|
|
}
|
|
}
|
|
|
|
|
|
- model.getSelectedCpsObjects().clear();
|
|
|
|
|
|
+ controller.clearSelection();
|
|
hideScrollGraph();
|
|
hideScrollGraph();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -973,17 +952,11 @@ public class GUI{
|
|
panelHolonEl.add(toolBarHolonEl);
|
|
panelHolonEl.add(toolBarHolonEl);
|
|
|
|
|
|
// Set up of the Properties section
|
|
// Set up of the Properties section
|
|
- tableProperties.setModel(model.getPropertyTable());
|
|
|
|
- tableProperties.setFillsViewportHeight(true);
|
|
|
|
- tableProperties.setCellSelectionEnabled(true);
|
|
|
|
- tableProperties.setColumnSelectionAllowed(true);
|
|
|
|
- scrollProperties.setViewportView(tableProperties);
|
|
|
|
-
|
|
|
|
|
|
+ scrollProperties.setViewportView(this.informationPanel);
|
|
|
|
+ scrollProperties.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
|
|
|
+ scrollProperties.getVerticalScrollBar().setUnitIncrement(16);
|
|
|
|
+
|
|
// Set up of the Graph section
|
|
// Set up of the Graph section
|
|
- tableGraph.setModel(tableModelGraph);
|
|
|
|
- tableGraph.setFillsViewportHeight(true);
|
|
|
|
- tableGraph.setCellSelectionEnabled(true);
|
|
|
|
- tableGraph.setColumnSelectionAllowed(true);
|
|
|
|
scrollGraph.setViewportView(unitGraph);
|
|
scrollGraph.setViewportView(unitGraph);
|
|
graphLabel.setLayout(new BorderLayout(0, 10));
|
|
graphLabel.setLayout(new BorderLayout(0, 10));
|
|
graphLabel.add(maxGraph, BorderLayout.NORTH);
|
|
graphLabel.add(maxGraph, BorderLayout.NORTH);
|
|
@@ -1386,124 +1359,7 @@ public class GUI{
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
- /***********************
|
|
|
|
- * HolonElement Properties Actions
|
|
|
|
- **********************/
|
|
|
|
-
|
|
|
|
- /*
|
|
|
|
- * Update of the mouse coord for Edit-Mode
|
|
|
|
- */
|
|
|
|
- tableProperties.addMouseListener(new MouseAdapter() {
|
|
|
|
- public void mousePressed(MouseEvent e) {
|
|
|
|
- if (e.getClickCount() == 2) {
|
|
|
|
- yProThis = e.getY();
|
|
|
|
- xProThis = e.getX();
|
|
|
|
- }
|
|
|
|
- yProThisOneClick = e.getY();
|
|
|
|
- xProThisOneClick = e.getX();
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
-
|
|
|
|
- /*
|
|
|
|
- * Update any change in the Property table
|
|
|
|
- */
|
|
|
|
- tableProperties.addPropertyChangeListener(propertyChangeEvent -> {
|
|
|
|
- try {
|
|
|
|
- Object temp;
|
|
|
|
- Object btemp;
|
|
|
|
- int selValueY = (int) Math.floor(yProThis / 16);
|
|
|
|
- int selValueX = (int) Math.floor(xProThis
|
|
|
|
- / (tableProperties.getWidth() / 2));
|
|
|
|
- int selValueYBool = (int) Math.floor(yProThisOneClick / 16);
|
|
|
|
- int selValueXBool = (int) Math.floor(xProThisOneClick
|
|
|
|
- / (tableProperties.getWidth() / 2));
|
|
|
|
- if (updCon.getActualCps() != null) {
|
|
|
|
- temp = model.getPropertyTable().getValueAt(selValueY,
|
|
|
|
- selValueX);
|
|
|
|
- btemp = model.getPropertyTable().getValueAt(selValueYBool,
|
|
|
|
- selValueXBool);
|
|
|
|
- // Case: Switch selected
|
|
|
|
-
|
|
|
|
- if (updCon.getActualCps() instanceof HolonSwitch) {
|
|
|
|
- if (selValueY == 0 && selValueX != 0) {
|
|
|
|
- updCon.getActualCps().setName(temp.toString());
|
|
|
|
- }
|
|
|
|
- if (selValueYBool == 2) {
|
|
|
|
- Boolean bbTemp = Boolean.parseBoolean(btemp.toString());
|
|
|
|
- ((HolonSwitch) updCon.getActualCps())
|
|
|
|
- .setManualMode(bbTemp);
|
|
|
|
- if (bbTemp) {
|
|
|
|
- model.getPropertyTable()
|
|
|
|
- .setCellEditable(3, 1, true);
|
|
|
|
- } else {
|
|
|
|
- model.getPropertyTable().setCellEditable(3, 1,
|
|
|
|
- false);
|
|
|
|
- }
|
|
|
|
- } else if (selValueYBool == 3) {
|
|
|
|
- if (((HolonSwitch) updCon.getActualCps())
|
|
|
|
- .getManualMode()) {
|
|
|
|
- model.getPropertyTable()
|
|
|
|
- .setCellEditable(3, 1, true);
|
|
|
|
- Boolean bTemp = Boolean.parseBoolean(btemp
|
|
|
|
- .toString());
|
|
|
|
- ((HolonSwitch) updCon.getActualCps())
|
|
|
|
- .setManualState(bTemp);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } // Case: UpperNode selected
|
|
|
|
- else if (updCon.getActualCps() instanceof GroupNode
|
|
|
|
- && selValueX != 0) {
|
|
|
|
- // Name edition through double click
|
|
|
|
- updCon.getActualCps().setName(temp.toString());
|
|
|
|
- // Update of name on the tab in the tab section
|
|
|
|
- for (int index = 4; index < tabbedPaneOriginal
|
|
|
|
- .getTabCount(); index++) {
|
|
|
|
- tabTemp = tabbedPaneOriginal;
|
|
|
|
- JScrollPane scrollPane = getScrollPaneFromTabbedPane();
|
|
|
|
-
|
|
|
|
- GroupNodeCanvas unc = ((GroupNodeCanvas) scrollPane
|
|
|
|
- .getViewport().getComponent(0));
|
|
|
|
-
|
|
|
|
- if (unc.upperNode.getId() == updCon.getActualCps()
|
|
|
|
- .getId()) {
|
|
|
|
- tabbedPaneOriginal.setTitleAt(index,
|
|
|
|
- unc.upperNode.getName());
|
|
|
|
- tabbedPaneOriginal.updateUI();
|
|
|
|
- if (!initSplit) {
|
|
|
|
- tabbedPaneSplit.setTitleAt(index,
|
|
|
|
- unc.upperNode.getName());
|
|
|
|
- tabbedPaneSplit.updateUI();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } // Case: HolonObject is selected
|
|
|
|
- else if (updCon.getActualCps() instanceof HolonObject
|
|
|
|
- && selValueX != 0) {
|
|
|
|
- // Name edition through double click
|
|
|
|
- updCon.getActualCps().setName(temp.toString());
|
|
|
|
- }
|
|
|
|
- } // Case: Edge is selected
|
|
|
|
- else {
|
|
|
|
- temp = model.getPropertyTable()
|
|
|
|
- .getValueAt(selValueY, selValueX);
|
|
|
|
- btemp = model.getPropertyTable().getValueAt(selValueYBool,
|
|
|
|
- selValueXBool);
|
|
|
|
- // Edit modus for capacity by double clicking
|
|
|
|
- if (selValueY == 2) {
|
|
|
|
- Float ftemp;
|
|
|
|
- if (Float.parseFloat(temp.toString()) >= 0.0) {
|
|
|
|
- ftemp = Float.parseFloat(temp.toString());
|
|
|
|
- } else {
|
|
|
|
- ftemp = model.getSelectedEdge().getCapacity();
|
|
|
|
- }
|
|
|
|
- model.getSelectedEdge().setCapacity(ftemp);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- canvas.repaint();
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- }
|
|
|
|
- }) ;
|
|
|
|
-
|
|
|
|
|
|
+
|
|
/***********************
|
|
/***********************
|
|
* HolonElement Graph Actions
|
|
* HolonElement Graph Actions
|
|
**********************/
|
|
**********************/
|
|
@@ -1955,7 +1811,7 @@ public class GUI{
|
|
}
|
|
}
|
|
if (e.isControlDown() && temp != null) {
|
|
if (e.isControlDown() && temp != null) {
|
|
if (model.getSelectedCpsObjects().contains(temp)) {
|
|
if (model.getSelectedCpsObjects().contains(temp)) {
|
|
- controller.deleteSelectedObject(temp);
|
|
|
|
|
|
+ controller.removeSelectedObjectFromSelection(temp);
|
|
} else {
|
|
} else {
|
|
controller.addSelectedObject(temp);
|
|
controller.addSelectedObject(temp);
|
|
}
|
|
}
|