|
@@ -169,6 +169,8 @@ public class GUI<E> implements CategoryListener {
|
|
private final JLabel label_1 = new JLabel("New label");
|
|
private final JLabel label_1 = new JLabel("New label");
|
|
private final JLabel lblSelect = new JLabel("Select");
|
|
private final JLabel lblSelect = new JLabel("Select");
|
|
private final JComboBox comboBoxAlgo = new JComboBox();
|
|
private final JComboBox comboBoxAlgo = new JComboBox();
|
|
|
|
+ private int yTHIS;
|
|
|
|
+ private int xTHIS;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Create the application.
|
|
* Create the application.
|
|
@@ -355,6 +357,7 @@ public class GUI<E> implements CategoryListener {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+
|
|
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();
|
|
@@ -366,6 +369,10 @@ public class GUI<E> implements CategoryListener {
|
|
} else {
|
|
} else {
|
|
elementGraph.setText("None ");
|
|
elementGraph.setText("None ");
|
|
}
|
|
}
|
|
|
|
+ if (e.getClickCount() == 2) {
|
|
|
|
+ yTHIS = e.getY();
|
|
|
|
+ xTHIS = e.getX();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
@@ -392,35 +399,29 @@ public class GUI<E> implements CategoryListener {
|
|
@Override
|
|
@Override
|
|
public void propertyChange(PropertyChangeEvent evt) {
|
|
public void propertyChange(PropertyChangeEvent evt) {
|
|
try {
|
|
try {
|
|
- int xMouse = tableHolonElement.getMousePosition().x;
|
|
|
|
- int yMouse = tableHolonElement.getMousePosition().y;
|
|
|
|
- int xSizeCell = tableHolonElement.getWidth() / 3;
|
|
|
|
- int selectedValueX = (int) Math.floor(xMouse / xSizeCell);
|
|
|
|
|
|
+ int yMouse = yTHIS;
|
|
|
|
+ int selectedValueX = (int) Math.floor(xTHIS / (tableHolonElement.getWidth() / 3));
|
|
int selectedValueY = (int) Math.floor(yMouse / 16);
|
|
int selectedValueY = (int) Math.floor(yMouse / 16);
|
|
if (getActualCps() != null && getActualCps().getClass() == HolonObject.class) {
|
|
if (getActualCps() != null && getActualCps().getClass() == HolonObject.class) {
|
|
HolonElement eleTemp = getActualHolonElement((HolonObject) getActualCps(), yMouse);
|
|
HolonElement eleTemp = getActualHolonElement((HolonObject) getActualCps(), yMouse);
|
|
String newStuff = tableModelHolonElement.getValueAt(selectedValueY, selectedValueX).toString();
|
|
String newStuff = tableModelHolonElement.getValueAt(selectedValueY, selectedValueX).toString();
|
|
if (selectedValueX == 0) {
|
|
if (selectedValueX == 0) {
|
|
- System.out.println("Changin Name");
|
|
|
|
eleTemp.setEleName(newStuff);
|
|
eleTemp.setEleName(newStuff);
|
|
} else if (selectedValueX == 1) {
|
|
} else if (selectedValueX == 1) {
|
|
- System.out.println("Changin Energy");
|
|
|
|
Float ftemp = Float.parseFloat(newStuff);
|
|
Float ftemp = Float.parseFloat(newStuff);
|
|
eleTemp.setEnergy(ftemp);
|
|
eleTemp.setEnergy(ftemp);
|
|
} else if (selectedValueX == 2) {
|
|
} else if (selectedValueX == 2) {
|
|
- System.out.println("Changin Amount");
|
|
|
|
Integer iTemp = Integer.parseInt(newStuff);
|
|
Integer iTemp = Integer.parseInt(newStuff);
|
|
eleTemp.setAmount(iTemp);
|
|
eleTemp.setAmount(iTemp);
|
|
- tableHolonElement.firePropertyChange("amount", iTemp, iTemp);
|
|
|
|
}
|
|
}
|
|
- System.out.println(newStuff);
|
|
|
|
|
|
+ tableModelHolonElement.fireTableDataChanged();
|
|
}
|
|
}
|
|
-
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+
|
|
frmCyberPhysical.getContentPane().setLayout(new BorderLayout(0, 0));
|
|
frmCyberPhysical.getContentPane().setLayout(new BorderLayout(0, 0));
|
|
|
|
|
|
TreeCellRenderer customRenderer = new TreeCellRenderer() {
|
|
TreeCellRenderer customRenderer = new TreeCellRenderer() {
|
|
@@ -488,15 +489,6 @@ public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
h.setPosition(x, y);
|
|
h.setPosition(x, y);
|
|
controller.addObjectCanvas(h);
|
|
controller.addObjectCanvas(h);
|
|
- for (int i = 0; i < model.getObjectsOnCanvas().size(); i++) {
|
|
|
|
- CpsObject temp = model.getObjectsOnCanvas().get(i);
|
|
|
|
- String output = "Element: " + temp.getObjName() + " with ID: " + temp.getID();
|
|
|
|
-
|
|
|
|
- if (temp.getClass() == HolonObject.class) {
|
|
|
|
- output = output + " and Elements: " + ((HolonObject) temp).toStringElements();
|
|
|
|
- }
|
|
|
|
- System.out.println(output);
|
|
|
|
- }
|
|
|
|
canvas.repaint();
|
|
canvas.repaint();
|
|
dragging = false;
|
|
dragging = false;
|
|
}
|
|
}
|
|
@@ -613,9 +605,11 @@ public class GUI<E> implements CategoryListener {
|
|
canvas.addMouseListener(new MouseAdapter() {
|
|
canvas.addMouseListener(new MouseAdapter() {
|
|
@Override
|
|
@Override
|
|
public void mousePressed(MouseEvent e) {
|
|
public void mousePressed(MouseEvent e) {
|
|
|
|
+ CpsObject temp = getActualCps();
|
|
// Update of the Information about the HolonElements - only for
|
|
// Update of the Information about the HolonElements - only for
|
|
- refreshTableHolonElement();
|
|
|
|
-
|
|
|
|
|
|
+ if (temp instanceof HolonObject) {
|
|
|
|
+ refreshTableHolonElement();
|
|
|
|
+ }
|
|
// Update of the Information about the Properties - only for
|
|
// Update of the Information about the Properties - only for
|
|
// CpsObjects
|
|
// CpsObjects
|
|
// Erase old data
|
|
// Erase old data
|
|
@@ -625,13 +619,13 @@ public class GUI<E> implements CategoryListener {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// Write new data
|
|
// Write new data
|
|
- CpsObject temp = getActualCps();
|
|
|
|
if (temp != null) {
|
|
if (temp != null) {
|
|
Object[] tempName = { "Name", temp.getName() };
|
|
Object[] tempName = { "Name", temp.getName() };
|
|
tableModelProperties.addRow(tempName);
|
|
tableModelProperties.addRow(tempName);
|
|
Object[] tempId = { "ID", temp.getID() };
|
|
Object[] tempId = { "ID", temp.getID() };
|
|
tableModelProperties.addRow(tempId);
|
|
tableModelProperties.addRow(tempId);
|
|
- if (temp.getClass() == HolonObject.class) {
|
|
|
|
|
|
+ if (temp instanceof HolonObject) {
|
|
|
|
+ refreshTableHolonElement();
|
|
Object[] tempEnergy = { "Total Energy", ((HolonObject) temp).getCurrentEnergy() };
|
|
Object[] tempEnergy = { "Total Energy", ((HolonObject) temp).getCurrentEnergy() };
|
|
tableModelProperties.addRow(tempEnergy);
|
|
tableModelProperties.addRow(tempEnergy);
|
|
}
|
|
}
|
|
@@ -922,13 +916,13 @@ public class GUI<E> implements CategoryListener {
|
|
// Update of the Information about the HolonElements - only for
|
|
// Update of the Information about the HolonElements - only for
|
|
// HolonObjects
|
|
// HolonObjects
|
|
deleteRows();
|
|
deleteRows();
|
|
- if (canvas.dataSelected != null) {
|
|
|
|
- fillElementTable(canvas.dataSelected);
|
|
|
|
|
|
+ if (getActualCps() != null) {
|
|
|
|
+ fillElementTable(((HolonObject) getActualCps()).getElements());
|
|
} /**
|
|
} /**
|
|
* hinzugef�gt damit man auch nach dem objekt platziert wurde
|
|
* hinzugef�gt damit man auch nach dem objekt platziert wurde
|
|
* elemente von Objekten in Kategorien ansehen kann
|
|
* elemente von Objekten in Kategorien ansehen kann
|
|
*/
|
|
*/
|
|
- canvas.dataSelected = null;
|
|
|
|
|
|
+ tableModelHolonElement.fireTableDataChanged();
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|