|
@@ -124,7 +124,9 @@ public class GUI<E> implements CategoryListener {
|
|
// In this section are all the Holonelements that correspond to the clicked
|
|
// In this section are all the Holonelements that correspond to the clicked
|
|
// HolonObject with consumption/production, name and amount.
|
|
// HolonObject with consumption/production, name and amount.
|
|
|
|
|
|
|
|
+ // Table for HolonElements --> all cells are editable
|
|
private JTable tableHolonElement = new JTable();
|
|
private JTable tableHolonElement = new JTable();
|
|
|
|
+ // Model for single or multi selection
|
|
private PropertyTable tableModelHolonElementMulti = new PropertyTable();
|
|
private PropertyTable tableModelHolonElementMulti = new PropertyTable();
|
|
private PropertyTable tableModelHolonElementSingle = new PropertyTable();
|
|
private PropertyTable tableModelHolonElementSingle = new PropertyTable();
|
|
private final JPanel scrollElements = new JPanel();
|
|
private final JPanel scrollElements = new JPanel();
|
|
@@ -132,7 +134,8 @@ public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
// In this section are all the properties that correspond to the clicked
|
|
// In this section are all the properties that correspond to the clicked
|
|
// HolonObject, such as connections, name, Type, etc.
|
|
// 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 JTable tableProperties = new JTable();
|
|
private JTable tableProperties = new JTable();
|
|
private JPanel graphLabel = new JPanel();
|
|
private JPanel graphLabel = new JPanel();
|
|
private DefaulTable tableModelProperties;
|
|
private DefaulTable tableModelProperties;
|
|
@@ -140,7 +143,6 @@ public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
// 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 JTable tableGraph = new JTable();
|
|
private JTable tableGraph = new JTable();
|
|
private DefaultTableModel tableModelGraph = new DefaultTableModel();
|
|
private DefaultTableModel tableModelGraph = new DefaultTableModel();
|
|
private final JScrollPane scrollGraph = new JScrollPane();
|
|
private final JScrollPane scrollGraph = new JScrollPane();
|
|
@@ -174,7 +176,6 @@ public class GUI<E> implements CategoryListener {
|
|
private String actualObjectClicked;
|
|
private String actualObjectClicked;
|
|
private Image img = null;
|
|
private Image img = null;
|
|
private CpsObject tempCps = null;
|
|
private CpsObject tempCps = null;
|
|
- private HolonElement tempElement = null;
|
|
|
|
private int yValueElements = 0;
|
|
private int yValueElements = 0;
|
|
|
|
|
|
private MyCanvas canvas;
|
|
private MyCanvas canvas;
|
|
@@ -187,8 +188,10 @@ public class GUI<E> implements CategoryListener {
|
|
private final JMenu mnAlgorithm = new JMenu("Algorithm");
|
|
private final JMenu mnAlgorithm = new JMenu("Algorithm");
|
|
private final JCheckBoxMenuItem chckbxmntmUseAlgorithm = new JCheckBoxMenuItem("Use Algorithm");
|
|
private final JCheckBoxMenuItem chckbxmntmUseAlgorithm = new JCheckBoxMenuItem("Use Algorithm");
|
|
private final JComboBox comboBoxAlgo = new JComboBox();
|
|
private final JComboBox comboBoxAlgo = new JComboBox();
|
|
|
|
+ // Coord for all Cells with text
|
|
private int yTHIS;
|
|
private int yTHIS;
|
|
private int xTHIS;
|
|
private int xTHIS;
|
|
|
|
+ // Coord for all Cells with boolean values (checkbox)
|
|
private int yBTHIS;
|
|
private int yBTHIS;
|
|
private int xBTHIS;
|
|
private int xBTHIS;
|
|
private CpsObject temp = null;
|
|
private CpsObject temp = null;
|
|
@@ -531,12 +534,13 @@ public class GUI<E> implements CategoryListener {
|
|
* RIGHT CONTAINER (INFORMATION)
|
|
* RIGHT CONTAINER (INFORMATION)
|
|
**********************/
|
|
**********************/
|
|
// Set up of the HolonElements section
|
|
// Set up of the HolonElements section
|
|
- Object[] columnNamesMulti = { "Object", "ID", "Device", "Energy", "Quantity", "Activated" };
|
|
|
|
|
|
+ // Two different Models: Multi for multi-selection mode and Single for
|
|
|
|
+ // single-selection mode (CPS-Object)
|
|
|
|
+ Object[] columnNamesMulti = { "Object", "Nr.", "Device", "Energy", "Quantity", "Activated" };
|
|
tableModelHolonElementMulti.setColumnIdentifiers(columnNamesMulti);
|
|
tableModelHolonElementMulti.setColumnIdentifiers(columnNamesMulti);
|
|
- Object[] columnNamesSingle = { "ID", "Device", "Energy", "Quantity", "Activated" };
|
|
|
|
|
|
+ Object[] columnNamesSingle = { "Nr.", "Device", "Energy", "Quantity", "Activated" };
|
|
tableModelHolonElementSingle.setColumnIdentifiers(columnNamesSingle);
|
|
tableModelHolonElementSingle.setColumnIdentifiers(columnNamesSingle);
|
|
tableHolonElement.setBorder(null);
|
|
tableHolonElement.setBorder(null);
|
|
-
|
|
|
|
tableHolonElement.setFillsViewportHeight(true);
|
|
tableHolonElement.setFillsViewportHeight(true);
|
|
tableHolonElement.setCellSelectionEnabled(true);
|
|
tableHolonElement.setCellSelectionEnabled(true);
|
|
tableHolonElement.setColumnSelectionAllowed(true);
|
|
tableHolonElement.setColumnSelectionAllowed(true);
|
|
@@ -552,7 +556,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
// Set up of the Properties section
|
|
// Set up of the Properties section
|
|
Object[] colNames = { "Field", "Information" };
|
|
Object[] colNames = { "Field", "Information" };
|
|
- tableModelProperties = new DefaulTable(100, colNames.length);
|
|
|
|
|
|
+ tableModelProperties = new DefaulTable(1000, colNames.length);
|
|
tableModelProperties.setColumnIdentifiers(colNames);
|
|
tableModelProperties.setColumnIdentifiers(colNames);
|
|
tableProperties.setModel(tableModelProperties);
|
|
tableProperties.setModel(tableModelProperties);
|
|
tableProperties.setFillsViewportHeight(true);
|
|
tableProperties.setFillsViewportHeight(true);
|
|
@@ -561,8 +565,6 @@ public class GUI<E> implements CategoryListener {
|
|
scrollProperties.setViewportView(tableProperties);
|
|
scrollProperties.setViewportView(tableProperties);
|
|
|
|
|
|
// Set up of the Graph section
|
|
// Set up of the Graph section
|
|
- Object[] tempText = { "Here comes the graph for each clicked HolonElement" };
|
|
|
|
- tableModelGraph.setColumnIdentifiers(tempText);
|
|
|
|
tableGraph.setModel(tableModelGraph);
|
|
tableGraph.setModel(tableModelGraph);
|
|
tableGraph.setFillsViewportHeight(true);
|
|
tableGraph.setFillsViewportHeight(true);
|
|
tableGraph.setCellSelectionEnabled(true);
|
|
tableGraph.setCellSelectionEnabled(true);
|
|
@@ -604,46 +606,53 @@ public class GUI<E> implements CategoryListener {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
/*
|
|
/*
|
|
- * Delete the choosen HolonElement of the selected HolonObject
|
|
|
|
|
|
+ * Delete the chosen HolonElement of the selected HolonObject,
|
|
|
|
+ * Multi-Selection for CpsObjects as well as for HolonElements possible
|
|
*/
|
|
*/
|
|
btnDelHolEL.addActionListener(new ActionListener() {
|
|
btnDelHolEL.addActionListener(new ActionListener() {
|
|
public void actionPerformed(ActionEvent arg0) {
|
|
public void actionPerformed(ActionEvent arg0) {
|
|
|
|
+ // For Single Selection of CpsObject
|
|
if (model.getSelectedCpsObjects().size() == 1) {
|
|
if (model.getSelectedCpsObjects().size() == 1) {
|
|
if (getActualCps().getClass() == HolonObject.class) {
|
|
if (getActualCps().getClass() == HolonObject.class) {
|
|
HolonObject obj = (HolonObject) getActualCps();
|
|
HolonObject obj = (HolonObject) getActualCps();
|
|
for (HolonElement e : selectedElements) {
|
|
for (HolonElement e : selectedElements) {
|
|
- controller.deleteElementCanvas(obj.getID(), e.getEleName());
|
|
|
|
|
|
+ controller.deleteElementCanvas(obj.getID(), e.getId());
|
|
refreshTableHolonElement();
|
|
refreshTableHolonElement();
|
|
refreshTableProperties();
|
|
refreshTableProperties();
|
|
controller.calculateStateForTimeStep(model.getCurIteration());
|
|
controller.calculateStateForTimeStep(model.getCurIteration());
|
|
// Names displayed in graph are not updated
|
|
// Names displayed in graph are not updated
|
|
}
|
|
}
|
|
|
|
+ selectedElements.clear();
|
|
}
|
|
}
|
|
|
|
+ // For MultiSelection of CpsObject
|
|
} else if (model.getSelectedCpsObjects().size() > 1) {
|
|
} else if (model.getSelectedCpsObjects().size() > 1) {
|
|
for (Integer i : eleToDelete.keySet()) {
|
|
for (Integer i : eleToDelete.keySet()) {
|
|
for (HolonElement e : eleToDelete.get(i)) {
|
|
for (HolonElement e : eleToDelete.get(i)) {
|
|
- controller.deleteElementCanvas(i, e.getEleName());
|
|
|
|
|
|
+ controller.deleteElementCanvas(i, e.getId());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
refreshTableHolonElement();
|
|
refreshTableHolonElement();
|
|
refreshTableProperties();
|
|
refreshTableProperties();
|
|
}
|
|
}
|
|
- holonEleNamesDisplayed = "None ";
|
|
|
|
}
|
|
}
|
|
});
|
|
});
|
|
/*
|
|
/*
|
|
- * Communication between HolonElement Table and displayed Graph
|
|
|
|
|
|
+ * Communication between HolonElement Table and displayed Graph and
|
|
|
|
+ * Properties, as well as selection of differet HolonElements
|
|
*/
|
|
*/
|
|
tableHolonElement.addMouseListener(new MouseAdapter() {
|
|
tableHolonElement.addMouseListener(new MouseAdapter() {
|
|
public void mousePressed(MouseEvent e) {
|
|
public void mousePressed(MouseEvent e) {
|
|
HolonObject obj = (HolonObject) getActualCps();
|
|
HolonObject obj = (HolonObject) getActualCps();
|
|
yValueElements = e.getY();
|
|
yValueElements = e.getY();
|
|
HolonElement ele = null;
|
|
HolonElement ele = null;
|
|
|
|
+ // Search for current clicked HolonElement
|
|
if (model.getSelectedCpsObjects().size() == 1) {
|
|
if (model.getSelectedCpsObjects().size() == 1) {
|
|
ele = getActualHolonElement(obj, yValueElements, 0);
|
|
ele = getActualHolonElement(obj, yValueElements, 0);
|
|
} else {
|
|
} else {
|
|
ele = getActualHolonElement(null, yValueElements, 0);
|
|
ele = getActualHolonElement(null, yValueElements, 0);
|
|
}
|
|
}
|
|
|
|
+ // Multi-Selection of HolonElements through control button +
|
|
|
|
+ // mouse click
|
|
if (e.isControlDown() && ele != null) {
|
|
if (e.isControlDown() && ele != null) {
|
|
if (!selectedElements.contains(ele)) {
|
|
if (!selectedElements.contains(ele)) {
|
|
selectedElements.add(ele);
|
|
selectedElements.add(ele);
|
|
@@ -655,34 +664,29 @@ public class GUI<E> implements CategoryListener {
|
|
unitGraph.repaintWithNewElement(selectedElements);
|
|
unitGraph.repaintWithNewElement(selectedElements);
|
|
}
|
|
}
|
|
getActualHolonElement(null, yValueElements, 2);
|
|
getActualHolonElement(null, yValueElements, 2);
|
|
- } else if (ele != null) {
|
|
|
|
|
|
+ } // if no control-button pressed but a HolonElement choose
|
|
|
|
+ else if (ele != null) {
|
|
selectedElements.clear();
|
|
selectedElements.clear();
|
|
selectedElements.add(ele);
|
|
selectedElements.add(ele);
|
|
getActualHolonElement(null, yValueElements, 1);
|
|
getActualHolonElement(null, yValueElements, 1);
|
|
holonEleNamesDisplayed = ele.getEleName() + " ";
|
|
holonEleNamesDisplayed = ele.getEleName() + " ";
|
|
unitGraph.repaintWithNewElement(selectedElements);
|
|
unitGraph.repaintWithNewElement(selectedElements);
|
|
- } else {
|
|
|
|
|
|
+ } // If any empty space is clicked
|
|
|
|
+ else {
|
|
elementGraph.setText("None ");
|
|
elementGraph.setText("None ");
|
|
unitGraph.empty();
|
|
unitGraph.empty();
|
|
}
|
|
}
|
|
- // if any HolonElement is double-clicked --> Edit instance of
|
|
|
|
- // selected HolonElement
|
|
|
|
|
|
+ // if any HolonElement is double-clicked --> Edit-Mode started
|
|
|
|
+ // for selected HolonElement
|
|
if (e.getClickCount() == 2) {
|
|
if (e.getClickCount() == 2) {
|
|
yTHIS = e.getY();
|
|
yTHIS = e.getY();
|
|
xTHIS = e.getX();
|
|
xTHIS = e.getX();
|
|
}
|
|
}
|
|
|
|
+ // for single click and empty slot
|
|
if (e.getClickCount() == 1 && ele == null) {
|
|
if (e.getClickCount() == 1 && ele == null) {
|
|
selectedElements.clear();
|
|
selectedElements.clear();
|
|
holonEleNamesDisplayed = "None ";
|
|
holonEleNamesDisplayed = "None ";
|
|
}
|
|
}
|
|
- // for (int i = 0; i < selectedElements.size(); i++) {
|
|
|
|
- // if (i == 0) {
|
|
|
|
- // System.out.println("Selected Items: " +
|
|
|
|
- // selectedElements.get(i).getEleName());
|
|
|
|
- // } else {
|
|
|
|
- // System.out.println(selectedElements.get(i).getEleName());
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
elementGraph.setText(holonEleNamesDisplayed);
|
|
elementGraph.setText(holonEleNamesDisplayed);
|
|
yBTHIS = e.getY();
|
|
yBTHIS = e.getY();
|
|
xBTHIS = e.getX();
|
|
xBTHIS = e.getX();
|
|
@@ -691,8 +695,7 @@ public class GUI<E> implements CategoryListener {
|
|
});
|
|
});
|
|
|
|
|
|
/*
|
|
/*
|
|
- * If the HolonElement Table enters to editing instance, than is the
|
|
|
|
- * propertyChangeListener triggered
|
|
|
|
|
|
+ * Triggered every time a change is made
|
|
*/
|
|
*/
|
|
tableHolonElement.addPropertyChangeListener(new PropertyChangeListener() {
|
|
tableHolonElement.addPropertyChangeListener(new PropertyChangeListener() {
|
|
@Override
|
|
@Override
|
|
@@ -702,11 +705,12 @@ public class GUI<E> implements CategoryListener {
|
|
int yBMouse = yBTHIS;
|
|
int yBMouse = yBTHIS;
|
|
int selectedValueY = (int) Math.floor(yMouse / 16);
|
|
int selectedValueY = (int) Math.floor(yMouse / 16);
|
|
int selectedValueBY = (int) Math.floor(yBMouse / 16);
|
|
int selectedValueBY = (int) Math.floor(yBMouse / 16);
|
|
|
|
+ // for multi-selection mode
|
|
if (model.getSelectedCpsObjects().size() > 1) {
|
|
if (model.getSelectedCpsObjects().size() > 1) {
|
|
- // Multiple Selection
|
|
|
|
int selectedValueX = (int) Math.floor(xTHIS / (tableHolonElement.getWidth() / 6));
|
|
int selectedValueX = (int) Math.floor(xTHIS / (tableHolonElement.getWidth() / 6));
|
|
int selectedValueBX = (int) Math.floor(xBTHIS / (tableHolonElement.getWidth() / 6));
|
|
int selectedValueBX = (int) Math.floor(xBTHIS / (tableHolonElement.getWidth() / 6));
|
|
if (getHolonObj(yMouse) != null) {
|
|
if (getHolonObj(yMouse) != null) {
|
|
|
|
+ // For last column (boolean with a checkbox)
|
|
if (selectedValueBX == 5) {
|
|
if (selectedValueBX == 5) {
|
|
HolonElement eleBTemp = getActualHolonElement(null, yBMouse, 0);
|
|
HolonElement eleBTemp = getActualHolonElement(null, yBMouse, 0);
|
|
String newBStuff = tableModelHolonElementMulti
|
|
String newBStuff = tableModelHolonElementMulti
|
|
@@ -714,25 +718,32 @@ public class GUI<E> implements CategoryListener {
|
|
Boolean bTemp = Boolean.parseBoolean(newBStuff);
|
|
Boolean bTemp = Boolean.parseBoolean(newBStuff);
|
|
eleBTemp.setActive(bTemp);
|
|
eleBTemp.setActive(bTemp);
|
|
} else {
|
|
} else {
|
|
|
|
+ // Update of HolonElement
|
|
HolonElement eleTemp = getActualHolonElement(null, yMouse, 0);
|
|
HolonElement eleTemp = getActualHolonElement(null, yMouse, 0);
|
|
String newStuff = tableModelHolonElementMulti.getValueAt(selectedValueY, selectedValueX)
|
|
String newStuff = tableModelHolonElementMulti.getValueAt(selectedValueY, selectedValueX)
|
|
.toString();
|
|
.toString();
|
|
|
|
+ // Name update
|
|
if (selectedValueX == 2) {
|
|
if (selectedValueX == 2) {
|
|
eleTemp.setEleName(newStuff);
|
|
eleTemp.setEleName(newStuff);
|
|
- } else if (selectedValueX == 3) {
|
|
|
|
|
|
+ }
|
|
|
|
+ // Energy Update
|
|
|
|
+ else if (selectedValueX == 3) {
|
|
Float ftemp = Float.parseFloat(newStuff);
|
|
Float ftemp = Float.parseFloat(newStuff);
|
|
eleTemp.setEnergy(ftemp);
|
|
eleTemp.setEnergy(ftemp);
|
|
- } else if (selectedValueX == 4) {
|
|
|
|
|
|
+ }
|
|
|
|
+ // Amount of Elements update
|
|
|
|
+ else if (selectedValueX == 4) {
|
|
Integer iTemp = Integer.parseInt(newStuff);
|
|
Integer iTemp = Integer.parseInt(newStuff);
|
|
eleTemp.setAmount(iTemp);
|
|
eleTemp.setAmount(iTemp);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- } else if (model.getSelectedCpsObjects().size() == 1) {
|
|
|
|
- // Single Selection
|
|
|
|
|
|
+ } // For single-selection mode
|
|
|
|
+ else if (model.getSelectedCpsObjects().size() == 1) {
|
|
int selectedValueX = (int) Math.floor(xTHIS / (tableHolonElement.getWidth() / 5));
|
|
int selectedValueX = (int) Math.floor(xTHIS / (tableHolonElement.getWidth() / 5));
|
|
int selectedValueBX = (int) Math.floor(xBTHIS / (tableHolonElement.getWidth() / 5));
|
|
int selectedValueBX = (int) Math.floor(xBTHIS / (tableHolonElement.getWidth() / 5));
|
|
if (getActualCps() != null && getActualCps().getClass() == HolonObject.class) {
|
|
if (getActualCps() != null && getActualCps().getClass() == HolonObject.class) {
|
|
|
|
+ // For last column (boolean with a checkbox)
|
|
if (selectedValueBX == 4) {
|
|
if (selectedValueBX == 4) {
|
|
HolonElement eleBTemp = getActualHolonElement((HolonObject) getActualCps(), yBMouse, 0);
|
|
HolonElement eleBTemp = getActualHolonElement((HolonObject) getActualCps(), yBMouse, 0);
|
|
String newBStuff = tableModelHolonElementSingle
|
|
String newBStuff = tableModelHolonElementSingle
|
|
@@ -740,15 +751,19 @@ public class GUI<E> implements CategoryListener {
|
|
Boolean bTemp = Boolean.parseBoolean(newBStuff);
|
|
Boolean bTemp = Boolean.parseBoolean(newBStuff);
|
|
eleBTemp.setActive(bTemp);
|
|
eleBTemp.setActive(bTemp);
|
|
} else {
|
|
} else {
|
|
|
|
+ // Update of HolonElement
|
|
HolonElement eleTemp = getActualHolonElement((HolonObject) getActualCps(), yMouse, 0);
|
|
HolonElement eleTemp = getActualHolonElement((HolonObject) getActualCps(), yMouse, 0);
|
|
String newStuff = tableModelHolonElementSingle
|
|
String newStuff = tableModelHolonElementSingle
|
|
.getValueAt(selectedValueY, selectedValueX).toString();
|
|
.getValueAt(selectedValueY, selectedValueX).toString();
|
|
|
|
+ // Name update
|
|
if (selectedValueX == 1) {
|
|
if (selectedValueX == 1) {
|
|
eleTemp.setEleName(newStuff);
|
|
eleTemp.setEleName(newStuff);
|
|
- } else if (selectedValueX == 2) {
|
|
|
|
|
|
+ } // Energy Update
|
|
|
|
+ else if (selectedValueX == 2) {
|
|
Float ftemp = Float.parseFloat(newStuff);
|
|
Float ftemp = Float.parseFloat(newStuff);
|
|
eleTemp.setEnergy(ftemp);
|
|
eleTemp.setEnergy(ftemp);
|
|
- } else if (selectedValueX == 3) {
|
|
|
|
|
|
+ } // Amount of Elements update
|
|
|
|
+ else if (selectedValueX == 3) {
|
|
Integer iTemp = Integer.parseInt(newStuff);
|
|
Integer iTemp = Integer.parseInt(newStuff);
|
|
eleTemp.setAmount(iTemp);
|
|
eleTemp.setAmount(iTemp);
|
|
}
|
|
}
|
|
@@ -768,9 +783,7 @@ public class GUI<E> implements CategoryListener {
|
|
* HolonElement Properties Actions
|
|
* HolonElement Properties Actions
|
|
**********************/
|
|
**********************/
|
|
/*
|
|
/*
|
|
- * If any value at the Properties Table enters to editing instance, than
|
|
|
|
- * is PropertyChangeListener triggered (For HolonObject, the only value
|
|
|
|
- * to be edited is the name and for CpsEdge the Max.flow)
|
|
|
|
|
|
+ * Update any change in the Property table
|
|
*/
|
|
*/
|
|
tableProperties.addPropertyChangeListener(new PropertyChangeListener() {
|
|
tableProperties.addPropertyChangeListener(new PropertyChangeListener() {
|
|
|
|
|
|
@@ -1000,7 +1013,6 @@ public class GUI<E> implements CategoryListener {
|
|
controller.addCategory(catName);
|
|
controller.addCategory(catName);
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
-
|
|
|
|
case "Object":
|
|
case "Object":
|
|
if (selectedNode == null) {
|
|
if (selectedNode == null) {
|
|
JOptionPane.showMessageDialog(new JFrame(),
|
|
JOptionPane.showMessageDialog(new JFrame(),
|
|
@@ -1037,7 +1049,8 @@ public class GUI<E> implements CategoryListener {
|
|
/**
|
|
/**
|
|
* Update of every interaction between the user and the canvas (only on
|
|
* Update of every interaction between the user and the canvas (only on
|
|
* the canvas). Basically the update of all the information concerning
|
|
* the canvas). Basically the update of all the information concerning
|
|
- * the clicked HolonObject
|
|
|
|
|
|
+ * the clicked HolonObject. For multi-selection, the propertyTable would
|
|
|
|
+ * be disabled
|
|
*/
|
|
*/
|
|
canvas.addMouseListener(new MouseAdapter() {
|
|
canvas.addMouseListener(new MouseAdapter() {
|
|
|
|
|
|
@@ -1045,19 +1058,13 @@ public class GUI<E> implements CategoryListener {
|
|
public void mousePressed(MouseEvent e) {
|
|
public void mousePressed(MouseEvent e) {
|
|
selectedElements.clear();
|
|
selectedElements.clear();
|
|
holonEleNamesDisplayed = "None ";
|
|
holonEleNamesDisplayed = "None ";
|
|
-
|
|
|
|
|
|
+ // If any empty space is clicked
|
|
if (temp == null || temp.getID() != model.getSelectedObjectID()) {
|
|
if (temp == null || temp.getID() != model.getSelectedObjectID()) {
|
|
unitGraph.empty();
|
|
unitGraph.empty();
|
|
elementGraph.setText("None ");
|
|
elementGraph.setText("None ");
|
|
}
|
|
}
|
|
temp = getActualCps();
|
|
temp = getActualCps();
|
|
- // Update of the Information about the HolonElements - only for
|
|
|
|
- // if (temp instanceof HolonObject) {
|
|
|
|
- // refreshTableHolonElement();
|
|
|
|
- // }
|
|
|
|
- // Update of the Information about the Properties - only for
|
|
|
|
- // CpsObjects
|
|
|
|
- // Erase old data
|
|
|
|
|
|
+ // Erase old data in the PropertyTable
|
|
if (tableModelProperties.getRowCount() > 0) {
|
|
if (tableModelProperties.getRowCount() > 0) {
|
|
for (int i = tableModelProperties.getRowCount() - 1; i > -1; i--) {
|
|
for (int i = tableModelProperties.getRowCount() - 1; i > -1; i--) {
|
|
tableModelProperties.removeRow(i);
|
|
tableModelProperties.removeRow(i);
|
|
@@ -1070,35 +1077,23 @@ public class GUI<E> implements CategoryListener {
|
|
controller.addSelectedObject(temp);
|
|
controller.addSelectedObject(temp);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- // } else if (e.isShiftDown() && model.getSelectedEdge() !=
|
|
|
|
- // null) {
|
|
|
|
- // selectedObjects.add(model.getSelectedEdge());
|
|
|
|
- // }
|
|
|
|
- // boolean nothingImportant = true;
|
|
|
|
- // for (CpsObject c : model.getSelectedCpsObjects()) {
|
|
|
|
- // if (nothingImportant) {
|
|
|
|
- // System.out.println("Elements: " + c.getName() + " and ID: " +
|
|
|
|
- // c.getID());
|
|
|
|
- // nothingImportant = false;
|
|
|
|
- // } else {
|
|
|
|
- // System.out.println(c.getName() + " and ID: " + c.getID());
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // Write new data
|
|
|
|
|
|
+ // Write new data in the PropertyTable
|
|
if (temp != null) {
|
|
if (temp != null) {
|
|
|
|
+ // Name of the CpsObject
|
|
Object[] tempName = { "Name", temp.getName() };
|
|
Object[] tempName = { "Name", temp.getName() };
|
|
tableModelProperties.addRow(tempName);
|
|
tableModelProperties.addRow(tempName);
|
|
|
|
+ // Id of the CpsObject
|
|
Object[] tempId = { "ID", temp.getID() };
|
|
Object[] tempId = { "ID", temp.getID() };
|
|
tableModelProperties.addRow(tempId);
|
|
tableModelProperties.addRow(tempId);
|
|
|
|
+ // For HolonObjects the Total Energy (production or
|
|
|
|
+ // consumption) is calculated
|
|
if (temp instanceof HolonObject) {
|
|
if (temp instanceof HolonObject) {
|
|
refreshTableHolonElement();
|
|
refreshTableHolonElement();
|
|
Object[] tempEnergy = { "Total Energy", ((HolonObject) temp).getCurrentEnergy() };
|
|
Object[] tempEnergy = { "Total Energy", ((HolonObject) temp).getCurrentEnergy() };
|
|
tableModelProperties.addRow(tempEnergy);
|
|
tableModelProperties.addRow(tempEnergy);
|
|
- // } else if (temp instanceof HolonTransformer) {
|
|
|
|
- // deleteRows();
|
|
|
|
- // Object[] tempRatioPerc = { "Ratio Type", true };
|
|
|
|
- // tableModelProperties.addRow(tempRatioPerc);
|
|
|
|
- } else if (temp instanceof HolonSwitch) {
|
|
|
|
|
|
+ } // For HolonSwitches is showed the actual status (active
|
|
|
|
+ // or inactive)
|
|
|
|
+ else if (temp instanceof HolonSwitch) {
|
|
deleteRows(tableModelHolonElementSingle);
|
|
deleteRows(tableModelHolonElementSingle);
|
|
deleteRows(tableModelHolonElementMulti);
|
|
deleteRows(tableModelHolonElementMulti);
|
|
Object[] tempActive = { "Active", ((HolonSwitch) temp).getActiveAt()[model.getCurIteration()] };
|
|
Object[] tempActive = { "Active", ((HolonSwitch) temp).getActiveAt()[model.getCurIteration()] };
|
|
@@ -1109,10 +1104,12 @@ public class GUI<E> implements CategoryListener {
|
|
deleteRows(tableModelHolonElementSingle);
|
|
deleteRows(tableModelHolonElementSingle);
|
|
deleteRows(tableModelHolonElementMulti);
|
|
deleteRows(tableModelHolonElementMulti);
|
|
}
|
|
}
|
|
|
|
+ // For Objects the only editable cell is the name
|
|
tableModelProperties.setCellEditable(0, 1, true);
|
|
tableModelProperties.setCellEditable(0, 1, true);
|
|
tableModelProperties.setCellEditable(2, 1, false);
|
|
tableModelProperties.setCellEditable(2, 1, false);
|
|
tableModelProperties.setCellEditable(3, 1, false);
|
|
tableModelProperties.setCellEditable(3, 1, false);
|
|
ArrayList<CpsEdge> temp_array = temp.getConnections();
|
|
ArrayList<CpsEdge> temp_array = temp.getConnections();
|
|
|
|
+ // If the clicked object has connections
|
|
if (!temp_array.isEmpty()) {
|
|
if (!temp_array.isEmpty()) {
|
|
boolean first = true;
|
|
boolean first = true;
|
|
for (CpsEdge temp2 : temp_array) {
|
|
for (CpsEdge temp2 : temp_array) {
|
|
@@ -1140,23 +1137,31 @@ public class GUI<E> implements CategoryListener {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- } else if (model.getSelectedEdge() != null) {
|
|
|
|
|
|
+ } // If the clicked Object is an edge
|
|
|
|
+ else if (model.getSelectedEdge() != null) {
|
|
|
|
+ // Name displayed
|
|
Object[] tempName = { "Name", "Edge: " + model.getSelectedEdge().getA().getName() + " to "
|
|
Object[] tempName = { "Name", "Edge: " + model.getSelectedEdge().getA().getName() + " to "
|
|
+ model.getSelectedEdge().getB().getName() };
|
|
+ model.getSelectedEdge().getB().getName() };
|
|
tableModelProperties.addRow(tempName);
|
|
tableModelProperties.addRow(tempName);
|
|
|
|
+ // Current Flow displayed
|
|
Object[] tempFlow = { "Current flow", model.getSelectedEdge().getFlow() };
|
|
Object[] tempFlow = { "Current flow", model.getSelectedEdge().getFlow() };
|
|
tableModelProperties.addRow(tempFlow);
|
|
tableModelProperties.addRow(tempFlow);
|
|
|
|
+ // Max Capacity displayed
|
|
Object[] tempCapacity = { "Max. Capacity", model.getSelectedEdge().getCapacity() };
|
|
Object[] tempCapacity = { "Max. Capacity", model.getSelectedEdge().getCapacity() };
|
|
tableModelProperties.addRow(tempCapacity);
|
|
tableModelProperties.addRow(tempCapacity);
|
|
|
|
+ // Status displayed
|
|
Object[] tempStatus = { "Status", model.getSelectedEdge().getStateEdge() };
|
|
Object[] tempStatus = { "Status", model.getSelectedEdge().getStateEdge() };
|
|
tableModelProperties.addRow(tempStatus);
|
|
tableModelProperties.addRow(tempStatus);
|
|
|
|
+ // For edges, the only possible editable cell is the max
|
|
|
|
+ // flow
|
|
tableModelProperties.setCellEditable(0, 1, false);
|
|
tableModelProperties.setCellEditable(0, 1, false);
|
|
tableModelProperties.setCellEditable(2, 1, true);
|
|
tableModelProperties.setCellEditable(2, 1, true);
|
|
tableModelProperties.setCellEditable(3, 1, true);
|
|
tableModelProperties.setCellEditable(3, 1, true);
|
|
} else if (getActualCps() == null) {
|
|
} else if (getActualCps() == null) {
|
|
deleteRows(tableModelHolonElementSingle);
|
|
deleteRows(tableModelHolonElementSingle);
|
|
deleteRows(tableModelHolonElementMulti);
|
|
deleteRows(tableModelHolonElementMulti);
|
|
- }
|
|
|
|
|
|
+ } // Update of the HolonElementTable (Single- or
|
|
|
|
+ // Multi-Selection)
|
|
if (model.getSelectedCpsObjects().size() > 1) {
|
|
if (model.getSelectedCpsObjects().size() > 1) {
|
|
tableHolonElement.setModel(tableModelHolonElementMulti);
|
|
tableHolonElement.setModel(tableModelHolonElementMulti);
|
|
} else if (model.getSelectedCpsObjects().size() == 1) {
|
|
} else if (model.getSelectedCpsObjects().size() == 1) {
|
|
@@ -1545,7 +1550,8 @@ public class GUI<E> implements CategoryListener {
|
|
* Search for actual selected HolonElement
|
|
* Search for actual selected HolonElement
|
|
*
|
|
*
|
|
* @param obj
|
|
* @param obj
|
|
- * selected HolonObject
|
|
|
|
|
|
+ * selected HolonObject, if obj==null means multi-selection
|
|
|
|
+ * active
|
|
* @param yValue
|
|
* @param yValue
|
|
* Y-Coord in the HolonElementsTable
|
|
* Y-Coord in the HolonElementsTable
|
|
* @param toMultiHash
|
|
* @param toMultiHash
|
|
@@ -1556,15 +1562,19 @@ public class GUI<E> implements CategoryListener {
|
|
public HolonElement getActualHolonElement(HolonObject obj, int yValue, int toMultiHash) {
|
|
public HolonElement getActualHolonElement(HolonObject obj, int yValue, int toMultiHash) {
|
|
final int yTemp = (int) Math.floor(yValue / 16);
|
|
final int yTemp = (int) Math.floor(yValue / 16);
|
|
int rowsTotal = 0;
|
|
int rowsTotal = 0;
|
|
|
|
+ // Filter for search --> single and multi selection
|
|
if (obj == null) {
|
|
if (obj == null) {
|
|
rowsTotal = tableModelHolonElementMulti.getRowCount();
|
|
rowsTotal = tableModelHolonElementMulti.getRowCount();
|
|
} else {
|
|
} else {
|
|
rowsTotal = tableModelHolonElementSingle.getRowCount();
|
|
rowsTotal = tableModelHolonElementSingle.getRowCount();
|
|
}
|
|
}
|
|
|
|
+ // search for the clicked HolonObject and HolonElement --> in the
|
|
|
|
+ // HolonElementTable
|
|
HolonObject obtTemp = null;
|
|
HolonObject obtTemp = null;
|
|
HolonElement toReturnEle = null;
|
|
HolonElement toReturnEle = null;
|
|
int id = 0;
|
|
int id = 0;
|
|
if (rowsTotal != 0 && rowsTotal > yTemp) {
|
|
if (rowsTotal != 0 && rowsTotal > yTemp) {
|
|
|
|
+ // Multi-Selection search
|
|
if (obj == null) {
|
|
if (obj == null) {
|
|
String tempStringObj = tableModelHolonElementMulti.getValueAt(yTemp, 0).toString();
|
|
String tempStringObj = tableModelHolonElementMulti.getValueAt(yTemp, 0).toString();
|
|
int idTempObj = Integer.parseInt(tempStringObj.split(", ")[1]);
|
|
int idTempObj = Integer.parseInt(tempStringObj.split(", ")[1]);
|
|
@@ -1576,7 +1586,6 @@ public class GUI<E> implements CategoryListener {
|
|
if (!eleTemp.contains(obtTemp.searchElementById(id))) {
|
|
if (!eleTemp.contains(obtTemp.searchElementById(id))) {
|
|
eleTemp.add(obtTemp.searchElementById(id));
|
|
eleTemp.add(obtTemp.searchElementById(id));
|
|
eleToDelete.replace(idTempObj, eleTemp);
|
|
eleToDelete.replace(idTempObj, eleTemp);
|
|
-
|
|
|
|
}
|
|
}
|
|
} else if (toMultiHash == 2) {
|
|
} else if (toMultiHash == 2) {
|
|
eleTemp.add(obtTemp.searchElementById(id));
|
|
eleTemp.add(obtTemp.searchElementById(id));
|
|
@@ -1588,20 +1597,28 @@ public class GUI<E> implements CategoryListener {
|
|
} else if (toMultiHash == 0) {
|
|
} else if (toMultiHash == 0) {
|
|
toReturnEle = obtTemp.searchElementById(id);
|
|
toReturnEle = obtTemp.searchElementById(id);
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
|
|
+ } // Single-Selection search
|
|
|
|
+ else {
|
|
eleToDelete = new HashMap<Integer, ArrayList<HolonElement>>();
|
|
eleToDelete = new HashMap<Integer, ArrayList<HolonElement>>();
|
|
id = Integer.parseInt(tableModelHolonElementSingle.getValueAt(yTemp, 0).toString());
|
|
id = Integer.parseInt(tableModelHolonElementSingle.getValueAt(yTemp, 0).toString());
|
|
toReturnEle = obj.searchElementById(id);
|
|
toReturnEle = obj.searchElementById(id);
|
|
}
|
|
}
|
|
model.setSelectedHolonElement(toReturnEle);
|
|
model.setSelectedHolonElement(toReturnEle);
|
|
return toReturnEle;
|
|
return toReturnEle;
|
|
- } else {
|
|
|
|
|
|
+ } // If no HolonObject selected
|
|
|
|
+ else {
|
|
eleToDelete = new HashMap<Integer, ArrayList<HolonElement>>();
|
|
eleToDelete = new HashMap<Integer, ArrayList<HolonElement>>();
|
|
model.setSelectedHolonElement(null);
|
|
model.setSelectedHolonElement(null);
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Search for clicked HolonObject through the mouse's y-Coord
|
|
|
|
+ *
|
|
|
|
+ * @param yValue
|
|
|
|
+ * @return clicked HolonObject
|
|
|
|
+ */
|
|
public HolonObject getHolonObj(int yValue) {
|
|
public HolonObject getHolonObj(int yValue) {
|
|
final int yTemp = (int) Math.floor(yValue / 16);
|
|
final int yTemp = (int) Math.floor(yValue / 16);
|
|
HolonObject obtTemp = null;
|
|
HolonObject obtTemp = null;
|