|
@@ -202,9 +202,6 @@ public class GUI<E> implements CategoryListener {
|
|
|
private final JLabel lblImageSize = new JLabel("Image Size");
|
|
|
|
|
|
private TimePanel timePanel;
|
|
|
- private final JMenu mnAlgorithm = new JMenu("Algorithm");
|
|
|
- private final JCheckBoxMenuItem chckbxmntmUseAlgorithm = new JCheckBoxMenuItem("Use Algorithm");
|
|
|
- private final JComboBox comboBoxAlgo = new JComboBox();
|
|
|
|
|
|
private int yTHIS;
|
|
|
private int xTHIS;
|
|
@@ -219,10 +216,6 @@ public class GUI<E> implements CategoryListener {
|
|
|
private final JMenuItem mntmFindReplace = new JMenuItem("Find/ Replace");
|
|
|
private final JMenuItem mntmEditShowedInformation = new JMenuItem("Edit showed Information");
|
|
|
private final JMenuItem mntmResetCategory = new JMenuItem("Reset Categories");
|
|
|
- private final JMenuItem mntmSetFolder = new JMenuItem("Set Folder");
|
|
|
- private final JMenu mnSimulationSpeed = new JMenu("Simulation Speed");
|
|
|
- private final JTextField simulationSpeedField = new JTextField();
|
|
|
- private final JButton btnApply = new JButton("Apply");
|
|
|
|
|
|
|
|
|
* Create the application.
|
|
@@ -245,7 +238,6 @@ public class GUI<E> implements CategoryListener {
|
|
|
*/
|
|
|
@SuppressWarnings({ "serial", "unchecked" })
|
|
|
private void initialize() {
|
|
|
- simulationSpeedField.setColumns(10);
|
|
|
frmCyberPhysical = new JFrame();
|
|
|
frmCyberPhysical.setTitle("Cyber Physical Systems Model");
|
|
|
frmCyberPhysical.setBounds(100, 100, 1000, 800);
|
|
@@ -381,6 +373,21 @@ public class GUI<E> implements CategoryListener {
|
|
|
unitGraph.empty();
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ String cntrlFDown = "controlF";
|
|
|
+ inputMap.put(KeyStroke.getKeyStroke("control F"), cntrlFDown);
|
|
|
+ actionMap.put(cntrlFDown, new AbstractAction() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void actionPerformed(ActionEvent e) {
|
|
|
+ searchPopUp dialog = new searchPopUp(controller, canvas);
|
|
|
+ dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
|
|
+ dialog.setVisible(true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
String cntrlCDown = "controlC";
|
|
|
inputMap.put(KeyStroke.getKeyStroke("control C"), cntrlCDown);
|
|
@@ -483,10 +490,6 @@ public class GUI<E> implements CategoryListener {
|
|
|
mnNewMenu_2.add(mntmEditEdges);
|
|
|
|
|
|
mnNewMenu_2.add(mntmResetCategory);
|
|
|
-
|
|
|
- mnNewMenu_2.add(mnSimulationSpeed);
|
|
|
-
|
|
|
- mnSimulationSpeed.add(simulationSpeedField);
|
|
|
mntmResetCategory.addActionListener(new ActionListener() {
|
|
|
|
|
|
@Override
|
|
@@ -527,7 +530,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
@Override
|
|
|
public void stateChanged(ChangeEvent e) {
|
|
|
controller.setScale(sizeSlider.getValue());
|
|
|
- tree.setRowHeight(model.getScale());
|
|
|
+ tree.setRowHeight(50);
|
|
|
canvas.objectSelectionHighlighting();
|
|
|
canvas.repaint();
|
|
|
}
|
|
@@ -540,12 +543,6 @@ public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
mnHelp.add(aboutUs);
|
|
|
|
|
|
- menuBar.add(mnAlgorithm);
|
|
|
-
|
|
|
- mnAlgorithm.add(mntmSetFolder);
|
|
|
-
|
|
|
- mnAlgorithm.add(chckbxmntmUseAlgorithm);
|
|
|
-
|
|
|
canvas.setBackground(Color.WHITE);
|
|
|
canvas.setPreferredSize(new Dimension(1000, 1000));
|
|
|
|
|
@@ -641,6 +638,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
controller.calculateStateForTimeStep(model.getCurIteration());
|
|
|
|
|
|
}
|
|
|
+ eleToDelete.clear();
|
|
|
selectedElements.clear();
|
|
|
}
|
|
|
|
|
@@ -652,7 +650,11 @@ public class GUI<E> implements CategoryListener {
|
|
|
}
|
|
|
refreshTableHolonElement();
|
|
|
refreshTableProperties();
|
|
|
+ eleToDelete.clear();
|
|
|
+ selectedElements.clear();
|
|
|
}
|
|
|
+ elementGraph.setText("None ");
|
|
|
+ holonEleNamesDisplayed = "None ";
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -819,9 +821,17 @@ public class GUI<E> implements CategoryListener {
|
|
|
if (mousePos.y / tableProperties.getRowHeight() == 2) {
|
|
|
Boolean bTemp = Boolean.parseBoolean(temp.toString());
|
|
|
((HolonSwitch) getActualCps()).setManualMode(bTemp);
|
|
|
+ if (bTemp) {
|
|
|
+ tableModelProperties.setCellEditable(3, 1, true);
|
|
|
+ } else {
|
|
|
+ tableModelProperties.setCellEditable(3, 1, false);
|
|
|
+ }
|
|
|
} else if (mousePos.y / tableProperties.getRowHeight() == 3) {
|
|
|
- Boolean bTemp = Boolean.parseBoolean(temp.toString());
|
|
|
- ((HolonSwitch) getActualCps()).setActiveAt(bTemp);
|
|
|
+ if (((HolonSwitch) getActualCps()).getManualMode()) {
|
|
|
+ tableModelProperties.setCellEditable(3, 1, true);
|
|
|
+ Boolean bTemp = Boolean.parseBoolean(temp.toString());
|
|
|
+ ((HolonSwitch) getActualCps()).setManualState(bTemp);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -879,10 +889,10 @@ public class GUI<E> implements CategoryListener {
|
|
|
File checkPath = new File(cps.getImage());
|
|
|
if (checkPath.exists()) {
|
|
|
imgR = new ImageIcon(cps.getImage()).getImage().getScaledInstance(
|
|
|
- controller.getScale(), controller.getScale(), java.awt.Image.SCALE_SMOOTH);
|
|
|
+ 50, 50, java.awt.Image.SCALE_SMOOTH);
|
|
|
} else {
|
|
|
imgR = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage()
|
|
|
- .getScaledInstance(controller.getScale(), controller.getScale(),
|
|
|
+ .getScaledInstance(50, 50,
|
|
|
java.awt.Image.SCALE_SMOOTH);
|
|
|
}
|
|
|
if (imgR != null) {
|
|
@@ -893,7 +903,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- tree.setRowHeight(model.getScale());
|
|
|
+ tree.setRowHeight(50);
|
|
|
if (hasFocus) {
|
|
|
label.setForeground(new Color(0, 0, 255));
|
|
|
label.setOpaque(true);
|
|
@@ -986,11 +996,11 @@ public class GUI<E> implements CategoryListener {
|
|
|
File checkPath = new File(cps.getImage());
|
|
|
if (checkPath.exists()) {
|
|
|
img = new ImageIcon(cps.getImage()).getImage().getScaledInstance(
|
|
|
- controller.getScale(), controller.getScale(),
|
|
|
+ 50, 50,
|
|
|
java.awt.Image.SCALE_SMOOTH);
|
|
|
} else {
|
|
|
img = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage()
|
|
|
- .getScaledInstance(controller.getScale(), controller.getScale(),
|
|
|
+ .getScaledInstance(50, 50,
|
|
|
java.awt.Image.SCALE_SMOOTH);
|
|
|
}
|
|
|
tempCps = cps;
|
|
@@ -1127,15 +1137,22 @@ public class GUI<E> implements CategoryListener {
|
|
|
else if (temp instanceof HolonSwitch) {
|
|
|
deleteRows(tableModelHolonElementSingle);
|
|
|
deleteRows(tableModelHolonElementMulti);
|
|
|
- Object[] tempMode = { "Mode", ((HolonSwitch) temp).getManualMode() };
|
|
|
+ Object[] tempMode = { "Manual", ((HolonSwitch) temp).getManualMode() };
|
|
|
tableModelProperties.addRow(tempMode);
|
|
|
- Object[] tempActive = { "Active", ((HolonSwitch) temp).getActiveAt()[model.getCurIteration()] };
|
|
|
- tableModelProperties.addRow(tempActive);
|
|
|
+ if (((HolonSwitch) temp).getManualMode()) {
|
|
|
+ Object[] tempActive = { "Active", ((HolonSwitch) temp).getActiveManual() };
|
|
|
+ tableModelProperties.addRow(tempActive);
|
|
|
+ tableModelProperties.setCellEditable(3, 1, true);
|
|
|
+ } else {
|
|
|
+ Object[] tempActive = { "Active",
|
|
|
+ ((HolonSwitch) temp).getActiveAt()[model.getCurIteration()] };
|
|
|
+ tableModelProperties.addRow(tempActive);
|
|
|
+ tableModelProperties.setCellEditable(3, 1, false);
|
|
|
+ }
|
|
|
unitGraph.repaintWithNewSwitch((HolonSwitch) temp);
|
|
|
elementGraph.setText(temp.getName());
|
|
|
tableModelProperties.setCellEditable(0, 1, true);
|
|
|
tableModelProperties.setCellEditable(2, 1, true);
|
|
|
- tableModelProperties.setCellEditable(3, 1, true);
|
|
|
} else {
|
|
|
deleteRows(tableModelHolonElementSingle);
|
|
|
deleteRows(tableModelHolonElementMulti);
|
|
@@ -1183,7 +1200,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
Object[] tempCapacity = { "Max. Capacity", model.getSelectedEdge().getCapacity() };
|
|
|
tableModelProperties.addRow(tempCapacity);
|
|
|
|
|
|
- Object[] tempStatus = { "Status", model.getSelectedEdge().getStateEdge() };
|
|
|
+ Object[] tempStatus = { "Status", model.getSelectedEdge().getState() };
|
|
|
tableModelProperties.addRow(tempStatus);
|
|
|
|
|
|
|
|
@@ -1416,34 +1433,6 @@ public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
});
|
|
|
|
|
|
- mntmSetFolder.addActionListener(new java.awt.event.ActionListener() {
|
|
|
-
|
|
|
- @Override
|
|
|
- public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
-
|
|
|
- menuSetFolderActionPerformed(evt);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private void menuSetFolderActionPerformed(java.awt.event.ActionEvent evt) {
|
|
|
- JFileChooser fileChooser = new JFileChooser();
|
|
|
- JFrame test = new JFrame();
|
|
|
- fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
|
|
- fileChooser.setAcceptAllFileFilterUsed(false);
|
|
|
-
|
|
|
- if (fileChooser.showOpenDialog(test) == JFileChooser.APPROVE_OPTION) {
|
|
|
- comboBoxAlgo.removeAllItems();
|
|
|
- File[] files = fileChooser.getSelectedFile().listFiles();
|
|
|
- for (int i = 0; i < files.length; i++) {
|
|
|
- if (files[i].toString().endsWith(".java") || files[i].toString().endsWith(".class")) {
|
|
|
- comboBoxAlgo.addItem(files[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
-
|
|
|
timePanel = new TimePanel(model, controller);
|
|
|
timePanel.setBorder(null);
|
|
|
((JSlider) (timePanel.getComponent(1))).addChangeListener(new ChangeListener() {
|
|
@@ -1490,22 +1479,6 @@ public class GUI<E> implements CategoryListener {
|
|
|
tableHolonElementScrollPane.setBorder(null);
|
|
|
|
|
|
frmCyberPhysical.getContentPane().add(timePanel, BorderLayout.SOUTH);
|
|
|
-
|
|
|
- simulationSpeedField.setText(Integer.toString(model.getTimerSpeed()));
|
|
|
- btnApply.addActionListener(new ActionListener() {
|
|
|
- public void actionPerformed(ActionEvent e) {
|
|
|
- int speed = Integer.parseInt(simulationSpeedField.getText());
|
|
|
- controller.setTimerSpeed(speed);
|
|
|
- mnSimulationSpeed.setPopupMenuVisible(false);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- mnSimulationSpeed.add(btnApply);
|
|
|
- menuBar.add(comboBoxAlgo);
|
|
|
-
|
|
|
- Dimension height = comboBoxAlgo.getPreferredSize();
|
|
|
- comboBoxAlgo.setPreferredSize(new Dimension(200, (int) height.getHeight()));
|
|
|
- comboBoxAlgo.setMaximumSize(comboBoxAlgo.getPreferredSize());
|
|
|
}
|
|
|
|
|
|
|