|
@@ -2,11 +2,13 @@ package ui.view;
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+
|
|
import javax.swing.JFrame;
|
|
import javax.swing.JFrame;
|
|
import javax.swing.JLabel;
|
|
import javax.swing.JLabel;
|
|
import javax.swing.JMenuBar;
|
|
import javax.swing.JMenuBar;
|
|
import javax.swing.JMenu;
|
|
import javax.swing.JMenu;
|
|
import javax.swing.JMenuItem;
|
|
import javax.swing.JMenuItem;
|
|
|
|
+import javax.swing.JSlider;
|
|
import javax.swing.JOptionPane;
|
|
import javax.swing.JOptionPane;
|
|
import javax.swing.JTree;
|
|
import javax.swing.JTree;
|
|
import javax.swing.border.LineBorder;
|
|
import javax.swing.border.LineBorder;
|
|
@@ -18,6 +20,8 @@ import javax.swing.JTable;
|
|
import javax.swing.tree.DefaultTreeModel;
|
|
import javax.swing.tree.DefaultTreeModel;
|
|
import javax.swing.tree.TreeCellRenderer;
|
|
import javax.swing.tree.TreeCellRenderer;
|
|
|
|
|
|
|
|
+import com.sun.javafx.geom.Edge;
|
|
|
|
+
|
|
import ui.controller.Control;
|
|
import ui.controller.Control;
|
|
import ui.model.*;
|
|
import ui.model.*;
|
|
|
|
|
|
@@ -25,6 +29,7 @@ import javax.swing.tree.DefaultMutableTreeNode;
|
|
import javax.swing.JEditorPane;
|
|
import javax.swing.JEditorPane;
|
|
import javax.swing.JFileChooser;
|
|
import javax.swing.JFileChooser;
|
|
import javax.swing.table.DefaultTableModel;
|
|
import javax.swing.table.DefaultTableModel;
|
|
|
|
+
|
|
import java.awt.Color;
|
|
import java.awt.Color;
|
|
import java.awt.Component;
|
|
import java.awt.Component;
|
|
import java.awt.Cursor;
|
|
import java.awt.Cursor;
|
|
@@ -57,8 +62,10 @@ import java.awt.event.MouseListener;
|
|
import java.beans.PropertyChangeEvent;
|
|
import java.beans.PropertyChangeEvent;
|
|
import java.beans.PropertyChangeListener;
|
|
import java.beans.PropertyChangeListener;
|
|
import java.awt.event.ActionEvent;
|
|
import java.awt.event.ActionEvent;
|
|
|
|
+
|
|
import javax.swing.JSlider;
|
|
import javax.swing.JSlider;
|
|
import javax.swing.event.ChangeListener;
|
|
import javax.swing.event.ChangeListener;
|
|
|
|
+import javax.swing.event.TableModelEvent;
|
|
import javax.swing.event.ChangeEvent;
|
|
import javax.swing.event.ChangeEvent;
|
|
|
|
|
|
public class GUI implements CategoryListener {
|
|
public class GUI implements CategoryListener {
|
|
@@ -109,7 +116,8 @@ public class GUI implements CategoryListener {
|
|
// HolonObject, such as connections, name, Type, etc.
|
|
// HolonObject, such as connections, name, Type, etc.
|
|
|
|
|
|
private JTable tableProperties = new JTable();
|
|
private JTable tableProperties = new JTable();
|
|
- private DefaultTableModel tableModelProperties = new DefaultTableModel();
|
|
|
|
|
|
+ private JPanel graphLabel = new JPanel();
|
|
|
|
+ private DefaulTable tableModelProperties;
|
|
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
|
|
@@ -152,12 +160,12 @@ public class GUI implements CategoryListener {
|
|
private int yValueElements = 0;
|
|
private int yValueElements = 0;
|
|
|
|
|
|
private MyCanvas canvas;
|
|
private MyCanvas canvas;
|
|
- private UnitGraph testgraph; // for testing, remove later
|
|
|
|
|
|
+ private UnitGraph unitGraph; // for testing, remove later
|
|
private final JSplitPane splitPane_3 = new JSplitPane();
|
|
private final JSplitPane splitPane_3 = new JSplitPane();
|
|
private final JSlider sizeSlider = new JSlider();
|
|
private final JSlider sizeSlider = new JSlider();
|
|
private final JLabel lblImageSize = new JLabel("Image Size");
|
|
private final JLabel lblImageSize = new JLabel("Image Size");
|
|
// Time Stuff
|
|
// Time Stuff
|
|
- private final TimePanel timePanel;
|
|
|
|
|
|
+ private TimePanel timePanel;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Create the application.
|
|
* Create the application.
|
|
@@ -166,10 +174,7 @@ public class GUI implements CategoryListener {
|
|
this.controller = control;
|
|
this.controller = control;
|
|
this.model = control.getModel();
|
|
this.model = control.getModel();
|
|
this.canvas = new MyCanvas(model, control);
|
|
this.canvas = new MyCanvas(model, control);
|
|
- this.testgraph = new UnitGraph(model, control); // for testing, remove
|
|
|
|
-
|
|
|
|
- timePanel = new TimePanel(model, controller);
|
|
|
|
- timePanel.setBorder(null);
|
|
|
|
|
|
+ this.unitGraph = new UnitGraph(model, control); // for testing, remove
|
|
|
|
|
|
// later
|
|
// later
|
|
control.initListener(this);
|
|
control.initListener(this);
|
|
@@ -227,7 +232,7 @@ public class GUI implements CategoryListener {
|
|
|
|
|
|
mnHelp.add(aboutUs);
|
|
mnHelp.add(aboutUs);
|
|
|
|
|
|
- testgraph.setBackground(Color.WHITE);
|
|
|
|
|
|
+ unitGraph.setBackground(Color.WHITE);
|
|
|
|
|
|
canvas.setBackground(Color.WHITE);
|
|
canvas.setBackground(Color.WHITE);
|
|
canvas.setPreferredSize(new Dimension(10000, 10000));
|
|
canvas.setPreferredSize(new Dimension(10000, 10000));
|
|
@@ -260,12 +265,12 @@ public class GUI 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.setColumnIdentifiers(colNames);
|
|
tableModelProperties.setColumnIdentifiers(colNames);
|
|
tableProperties.setModel(tableModelProperties);
|
|
tableProperties.setModel(tableModelProperties);
|
|
tableProperties.setFillsViewportHeight(true);
|
|
tableProperties.setFillsViewportHeight(true);
|
|
tableProperties.setCellSelectionEnabled(true);
|
|
tableProperties.setCellSelectionEnabled(true);
|
|
tableProperties.setColumnSelectionAllowed(true);
|
|
tableProperties.setColumnSelectionAllowed(true);
|
|
-
|
|
|
|
// Set up of the Graph section
|
|
// Set up of the Graph section
|
|
|
|
|
|
Object[] tempText = { "Here comes the graph for each clicked HolonElement" };
|
|
Object[] tempText = { "Here comes the graph for each clicked HolonElement" };
|
|
@@ -280,13 +285,11 @@ public class GUI implements CategoryListener {
|
|
*/
|
|
*/
|
|
scrollProperties.setViewportView(tableProperties);
|
|
scrollProperties.setViewportView(tableProperties);
|
|
tableHolonElementScrollPane.setViewportView(tableHolonElement);
|
|
tableHolonElementScrollPane.setViewportView(tableHolonElement);
|
|
- scrollGraph.setViewportView(testgraph);
|
|
|
|
- JPanel graphLabel = new JPanel();
|
|
|
|
- graphLabel.setLayout(new BoxLayout(graphLabel, BoxLayout.Y_AXIS));
|
|
|
|
- minGraph.setBounds(0, 150, 10, 10);
|
|
|
|
- graphLabel.add(maxGraph);
|
|
|
|
- graphLabel.add(medGraph);
|
|
|
|
- graphLabel.add(minGraph);
|
|
|
|
|
|
+ scrollGraph.setViewportView(unitGraph);
|
|
|
|
+ graphLabel.setLayout(new BorderLayout(0, 10));
|
|
|
|
+ graphLabel.add(maxGraph, BorderLayout.NORTH);
|
|
|
|
+ graphLabel.add(medGraph, BorderLayout.CENTER);
|
|
|
|
+ graphLabel.add(minGraph, BorderLayout.SOUTH);
|
|
toolBarGraph.add(elementGraph);
|
|
toolBarGraph.add(elementGraph);
|
|
comboBoxGraph.setModel(new DefaultComboBoxModel(new String[] { "Day", "Month", "Year" }));
|
|
comboBoxGraph.setModel(new DefaultComboBoxModel(new String[] { "Day", "Month", "Year" }));
|
|
toolBarGraph.add(comboBoxGraph);
|
|
toolBarGraph.add(comboBoxGraph);
|
|
@@ -310,16 +313,17 @@ public class GUI implements CategoryListener {
|
|
&& tempCpsObject.getID() != 0) {
|
|
&& tempCpsObject.getID() != 0) {
|
|
addElementPopUp = new AddElementPopUp();
|
|
addElementPopUp = new AddElementPopUp();
|
|
addElementPopUp.setVisible(true);
|
|
addElementPopUp.setVisible(true);
|
|
- controller.addElementCanvasObject(tempCpsObject.getName(),
|
|
|
|
- addElementPopUp.getElement().getEleName(), addElementPopUp.getElement().getAmount(),
|
|
|
|
- addElementPopUp.getElement().getEnergy());
|
|
|
|
|
|
+ controller.addElementCanvasObject(tempCpsObject.getID(), addElementPopUp.getElement().getEleName(),
|
|
|
|
+ addElementPopUp.getElement().getAmount(), addElementPopUp.getElement().getEnergy());
|
|
|
|
+ refreshTableHolonElement();
|
|
|
|
+ refreshTableProperties();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
resetGraphBtn.addActionListener(new ActionListener() {
|
|
resetGraphBtn.addActionListener(new ActionListener() {
|
|
|
|
|
|
public void actionPerformed(ActionEvent arg0) {
|
|
public void actionPerformed(ActionEvent arg0) {
|
|
- testgraph.reset();
|
|
|
|
|
|
+ unitGraph.reset();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
toolBarHolonEl.add(btnDelHolEL);
|
|
toolBarHolonEl.add(btnDelHolEL);
|
|
@@ -330,11 +334,12 @@ public class GUI implements CategoryListener {
|
|
tempElement = getActualHolonElement(obj, yValueElements);
|
|
tempElement = getActualHolonElement(obj, yValueElements);
|
|
if (tempElement != null && obj.getClass() == HolonObject.class && obj.getID() != 0) {
|
|
if (tempElement != null && obj.getClass() == HolonObject.class && obj.getID() != 0) {
|
|
controller.deleteElementCanvas(obj.getID(), tempElement.getEleName());
|
|
controller.deleteElementCanvas(obj.getID(), tempElement.getEleName());
|
|
|
|
+ refreshTableHolonElement();
|
|
|
|
+ refreshTableProperties();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
-
|
|
|
|
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();
|
|
@@ -342,12 +347,28 @@ public class GUI implements CategoryListener {
|
|
HolonElement ele = getActualHolonElement(obj, yValueElements);
|
|
HolonElement ele = getActualHolonElement(obj, yValueElements);
|
|
if (ele != null) {
|
|
if (ele != null) {
|
|
elementGraph.setText(ele.getEleName() + " ");
|
|
elementGraph.setText(ele.getEleName() + " ");
|
|
- testgraph.repaintWithNewElement(ele);
|
|
|
|
|
|
+ unitGraph.repaintWithNewElement(ele);
|
|
} else {
|
|
} else {
|
|
elementGraph.setText("None ");
|
|
elementGraph.setText("None ");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ tableProperties.addMouseListener(new MouseAdapter() {
|
|
|
|
+ public void mousePressed(MouseEvent e) {
|
|
|
|
+ int selectedX = (int) Math
|
|
|
|
+ .floor(e.getX() / (tableProperties.getColumnModel().getTotalColumnWidth() / 2));
|
|
|
|
+ int selectedY = (int) Math.floor(e.getY() / 16);
|
|
|
|
+ if (tableModelProperties.isCellEditable(selectedY, selectedX) && e.getClickCount() == 2) {
|
|
|
|
+ if (getActualCps() != null) {
|
|
|
|
+
|
|
|
|
+ tableModelProperties.fireTableCellUpdated(selectedY, selectedX);
|
|
|
|
+ } else {
|
|
|
|
+ System.out.println("Edge");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
frmCyberPhysical.getContentPane().setLayout(new BorderLayout(0, 0));
|
|
frmCyberPhysical.getContentPane().setLayout(new BorderLayout(0, 0));
|
|
|
|
|
|
TreeCellRenderer customRenderer = new TreeCellRenderer() {
|
|
TreeCellRenderer customRenderer = new TreeCellRenderer() {
|
|
@@ -360,9 +381,15 @@ public class GUI implements CategoryListener {
|
|
for (Category cat : model.getCategories()) {
|
|
for (Category cat : model.getCategories()) {
|
|
for (CpsObject cps : cat.getObjects()) {
|
|
for (CpsObject cps : cat.getObjects()) {
|
|
if (value.toString().compareTo(cps.getCompareName()) == 0) {
|
|
if (value.toString().compareTo(cps.getCompareName()) == 0) {
|
|
- imgR = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage()
|
|
|
|
- .getScaledInstance(controller.getScale(), controller.getScale(),
|
|
|
|
- java.awt.Image.SCALE_SMOOTH);
|
|
|
|
|
|
+ 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);
|
|
|
|
+ } else {
|
|
|
|
+ imgR = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage()
|
|
|
|
+ .getScaledInstance(controller.getScale(), controller.getScale(),
|
|
|
|
+ java.awt.Image.SCALE_SMOOTH);
|
|
|
|
+ }
|
|
if (imgR != null) {
|
|
if (imgR != null) {
|
|
label.setIcon(new ImageIcon(imgR));
|
|
label.setIcon(new ImageIcon(imgR));
|
|
}
|
|
}
|
|
@@ -431,12 +458,31 @@ public class GUI implements CategoryListener {
|
|
public void mousePressed(MouseEvent e) {
|
|
public void mousePressed(MouseEvent e) {
|
|
try {
|
|
try {
|
|
actualObjectClicked = tree.getPathForLocation(e.getX(), e.getY()).getLastPathComponent().toString();
|
|
actualObjectClicked = tree.getPathForLocation(e.getX(), e.getY()).getLastPathComponent().toString();
|
|
|
|
+ // if an Object was selected, the porperties are shown in
|
|
|
|
+ // the table
|
|
|
|
+ DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) tree
|
|
|
|
+ .getPathForLocation(e.getX(), e.getY()).getLastPathComponent();
|
|
|
|
+ if (selectedNode.getLevel() == 2) {
|
|
|
|
+ CpsObject selected = controller.searchObjInCat(selectedNode.toString(),
|
|
|
|
+ selectedNode.getParent().toString());
|
|
|
|
+ deleteRows();
|
|
|
|
+ if (selected instanceof HolonObject && selected != null) {
|
|
|
|
+ selected = (HolonObject) selected;
|
|
|
|
+ fillElementTable(((HolonObject) selected).getElements());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
for (Category cat : model.getCategories()) {
|
|
for (Category cat : model.getCategories()) {
|
|
for (CpsObject cps : cat.getObjects()) {
|
|
for (CpsObject cps : cat.getObjects()) {
|
|
if (actualObjectClicked.compareTo(cps.getCompareName()) == 0) {
|
|
if (actualObjectClicked.compareTo(cps.getCompareName()) == 0) {
|
|
- img = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage()
|
|
|
|
- .getScaledInstance(controller.getScale(), controller.getScale(),
|
|
|
|
- java.awt.Image.SCALE_SMOOTH);
|
|
|
|
|
|
+ File checkPath = new File(cps.getImage());
|
|
|
|
+ if (checkPath.exists()) {
|
|
|
|
+ img = new ImageIcon(cps.getImage()).getImage().getScaledInstance(
|
|
|
|
+ controller.getScale(), controller.getScale(), java.awt.Image.SCALE_SMOOTH);
|
|
|
|
+ } else {
|
|
|
|
+ img = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage()
|
|
|
|
+ .getScaledInstance(controller.getScale(), controller.getScale(),
|
|
|
|
+ java.awt.Image.SCALE_SMOOTH);
|
|
|
|
+ }
|
|
tempCps = cps;
|
|
tempCps = cps;
|
|
dragging = true;
|
|
dragging = true;
|
|
Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(img, new Point(0, 0),
|
|
Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(img, new Point(0, 0),
|
|
@@ -516,18 +562,7 @@ public class GUI implements CategoryListener {
|
|
@Override
|
|
@Override
|
|
public void mousePressed(MouseEvent e) {
|
|
public void mousePressed(MouseEvent e) {
|
|
// Update of the Information about the HolonElements - only for
|
|
// Update of the Information about the HolonElements - only for
|
|
- // HolonObjects
|
|
|
|
- if (tableModelHolonElement.getRowCount() > 0) {
|
|
|
|
- for (int i = tableModelHolonElement.getRowCount() - 1; i > -1; i--) {
|
|
|
|
- tableModelHolonElement.removeRow(i);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (canvas.dataSelected != null) {
|
|
|
|
- for (HolonElement he : canvas.dataSelected) {
|
|
|
|
- Object[] temp = { he.getEleName(), he.getEnergy(), he.getAmount() };
|
|
|
|
- tableModelHolonElement.addRow(temp);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ refreshTableHolonElement();
|
|
|
|
|
|
// Update of the Information about the Properties - only for
|
|
// Update of the Information about the Properties - only for
|
|
// CpsObjects
|
|
// CpsObjects
|
|
@@ -547,6 +582,8 @@ public class GUI implements CategoryListener {
|
|
Object[] tempEnergy = { "Total Energy", ((HolonObject) canvas.tempCps).getCurrentEnergy() };
|
|
Object[] tempEnergy = { "Total Energy", ((HolonObject) canvas.tempCps).getCurrentEnergy() };
|
|
tableModelProperties.addRow(tempEnergy);
|
|
tableModelProperties.addRow(tempEnergy);
|
|
}
|
|
}
|
|
|
|
+ tableModelProperties.setCellEditable(0, 1, true);
|
|
|
|
+ tableModelProperties.setCellEditable(2, 1, false);
|
|
ArrayList<CpsEdge> temp_array = canvas.tempCps.getConnectedTo();
|
|
ArrayList<CpsEdge> temp_array = canvas.tempCps.getConnectedTo();
|
|
if (!temp_array.isEmpty()) {
|
|
if (!temp_array.isEmpty()) {
|
|
boolean first = true;
|
|
boolean first = true;
|
|
@@ -577,6 +614,16 @@ public class GUI implements CategoryListener {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ } else if (model.getSelectedEdge() != null) {
|
|
|
|
+ Object[] tempName = { "Name", "Edge: " + model.getSelectedEdge().getA().getName() + " to "
|
|
|
|
+ + model.getSelectedEdge().getB().getName() };
|
|
|
|
+ tableModelProperties.addRow(tempName);
|
|
|
|
+ Object[] tempFlow = { "Current flow", model.getSelectedEdge().getFlow() };
|
|
|
|
+ tableModelProperties.addRow(tempFlow);
|
|
|
|
+ Object[] tempCapacity = { "Max. Capacity", model.getSelectedEdge().getCapacity() };
|
|
|
|
+ tableModelProperties.addRow(tempCapacity);
|
|
|
|
+ tableModelProperties.setCellEditable(0, 1, false);
|
|
|
|
+ tableModelProperties.setCellEditable(2, 1, true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -595,16 +642,17 @@ public class GUI implements CategoryListener {
|
|
for (int c = 0; c < tableModelHolonElement.getColumnCount(); c++) {
|
|
for (int c = 0; c < tableModelHolonElement.getColumnCount(); c++) {
|
|
temp.add(tableHolonElement.getValueAt(r, c));
|
|
temp.add(tableHolonElement.getValueAt(r, c));
|
|
}
|
|
}
|
|
- float ch;
|
|
|
|
- if (temp.get(1).toString().compareTo("-") == 0) {
|
|
|
|
- ch = -1;
|
|
|
|
- } else {
|
|
|
|
- ch = 1;
|
|
|
|
- }
|
|
|
|
- float fa = Float.parseFloat(temp.get(2).toString());
|
|
|
|
- int i = Integer.parseInt(temp.get(3).toString());
|
|
|
|
|
|
+ // float ch;
|
|
|
|
+ // if (temp.get(1).toString().compareTo("-") == 0) {
|
|
|
|
+ // ch = -1;
|
|
|
|
+ // } else {
|
|
|
|
+ // ch = 1;
|
|
|
|
+ // }
|
|
|
|
+ float fa = Float.parseFloat(temp.get(1).toString());
|
|
|
|
+ int i = Integer.parseInt(temp.get(2).toString());
|
|
((HolonObject) tempCps).getElements().get(r).setEleName((String) temp.get(0));
|
|
((HolonObject) tempCps).getElements().get(r).setEleName((String) temp.get(0));
|
|
- ((HolonObject) tempCps).getElements().get(r).setSign(ch);
|
|
|
|
|
|
+ // ((HolonObject)
|
|
|
|
+ // tempCps).getElements().get(r).setSign(ch);
|
|
((HolonObject) tempCps).getElements().get(r).setEnergy(fa);
|
|
((HolonObject) tempCps).getElements().get(r).setEnergy(fa);
|
|
((HolonObject) tempCps).getElements().get(r).setAmount(i);
|
|
((HolonObject) tempCps).getElements().get(r).setAmount(i);
|
|
// System.out.println(tableHolonElement.getRowCount()
|
|
// System.out.println(tableHolonElement.getRowCount()
|
|
@@ -646,10 +694,8 @@ public class GUI implements CategoryListener {
|
|
JOptionPane.YES_NO_OPTION);
|
|
JOptionPane.YES_NO_OPTION);
|
|
if (dialogResult == JOptionPane.YES_OPTION) {
|
|
if (dialogResult == JOptionPane.YES_OPTION) {
|
|
controller.deleteCategory(nodeName);
|
|
controller.deleteCategory(nodeName);
|
|
- break;
|
|
|
|
- } else {
|
|
|
|
- break;
|
|
|
|
}
|
|
}
|
|
|
|
+ break;
|
|
case 2:
|
|
case 2:
|
|
DefaultMutableTreeNode parent = (DefaultMutableTreeNode) selectedNode.getParent();
|
|
DefaultMutableTreeNode parent = (DefaultMutableTreeNode) selectedNode.getParent();
|
|
controller.delObjectCategory(nodeName, parent.getUserObject().toString());
|
|
controller.delObjectCategory(nodeName, parent.getUserObject().toString());
|
|
@@ -686,6 +732,16 @@ public class GUI implements CategoryListener {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ timePanel = new TimePanel(model, controller);
|
|
|
|
+ timePanel.setBorder(null);
|
|
|
|
+ ((JSlider) (timePanel.getComponent(1))).addChangeListener(new ChangeListener() {
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void stateChanged(ChangeEvent e) {
|
|
|
|
+ unitGraph.repaint();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
splitPane.setRightComponent(splitPane_1);
|
|
splitPane.setRightComponent(splitPane_1);
|
|
splitPane.setDividerLocation(200);
|
|
splitPane.setDividerLocation(200);
|
|
splitPane_1.setDividerLocation(500);
|
|
splitPane_1.setDividerLocation(500);
|
|
@@ -734,11 +790,11 @@ public class GUI implements CategoryListener {
|
|
switch (objType) {
|
|
switch (objType) {
|
|
|
|
|
|
case "Switch":
|
|
case "Switch":
|
|
- controller.addSwitch(cat, objname, objType);
|
|
|
|
|
|
+ controller.addSwitch(cat, objname);
|
|
break;
|
|
break;
|
|
|
|
|
|
case "Transformer":
|
|
case "Transformer":
|
|
- controller.addTransformer(cat, objname, objType);
|
|
|
|
|
|
+ controller.addTransformer(cat, objname);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -787,15 +843,27 @@ public class GUI implements CategoryListener {
|
|
return frmCyberPhysical;
|
|
return frmCyberPhysical;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Getter for selected CpsObject
|
|
|
|
+ *
|
|
|
|
+ * @return selected CpsObject
|
|
|
|
+ */
|
|
public CpsObject getActualCps() {
|
|
public CpsObject getActualCps() {
|
|
int tempID = model.getSelectedObjectID();
|
|
int tempID = model.getSelectedObjectID();
|
|
CpsObject tempCps = controller.searchByID(tempID);
|
|
CpsObject tempCps = controller.searchByID(tempID);
|
|
- System.out.println(tempCps.getID());
|
|
|
|
return tempCps;
|
|
return tempCps;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Search for actual selected HolonElement
|
|
|
|
+ *
|
|
|
|
+ * @param obj
|
|
|
|
+ * selected HolonObject
|
|
|
|
+ * @param yValue
|
|
|
|
+ * Y-Coord in the HolonElementsTable
|
|
|
|
+ * @return the selected HolonElement
|
|
|
|
+ */
|
|
public HolonElement getActualHolonElement(HolonObject obj, int yValue) {
|
|
public HolonElement getActualHolonElement(HolonObject obj, int yValue) {
|
|
- HolonObject tempCps = obj;
|
|
|
|
final int yTemp = (int) Math.floor(yValue / 16);
|
|
final int yTemp = (int) Math.floor(yValue / 16);
|
|
int rowsTotal = tableModelHolonElement.getRowCount();
|
|
int rowsTotal = tableModelHolonElement.getRowCount();
|
|
if (rowsTotal != 0 && rowsTotal > yTemp) {
|
|
if (rowsTotal != 0 && rowsTotal > yTemp) {
|
|
@@ -806,4 +874,49 @@ public class GUI implements CategoryListener {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * Refresh the Table displaying the HolonElements
|
|
|
|
+ */
|
|
|
|
+ public void refreshTableHolonElement() {
|
|
|
|
+ // Update of the Information about the HolonElements - only for
|
|
|
|
+ // HolonObjects
|
|
|
|
+ deleteRows();
|
|
|
|
+ if (canvas.dataSelected != null) {
|
|
|
|
+ fillElementTable(canvas.dataSelected);
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * hinzugef�gt damit man auch nach dem objekt platziert wurde elemente
|
|
|
|
+ * von Objekten in Kategorien ansehen kann
|
|
|
|
+ */
|
|
|
|
+ canvas.dataSelected = null;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void deleteRows() {
|
|
|
|
+ if (tableModelHolonElement.getRowCount() > 0) {
|
|
|
|
+ for (int i = tableModelHolonElement.getRowCount() - 1; i > -1; i--) {
|
|
|
|
+ tableModelHolonElement.removeRow(i);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void fillElementTable(ArrayList<HolonElement> elements) {
|
|
|
|
+ for (HolonElement he : elements) {
|
|
|
|
+ Object[] temp = { he.getEleName(), he.getEnergy(), he.getAmount() };
|
|
|
|
+ tableModelHolonElement.addRow(temp);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Update the information about properties of the selected CpsObject
|
|
|
|
+ */
|
|
|
|
+ public void refreshTableProperties() {
|
|
|
|
+ CpsObject tempCps = getActualCps();
|
|
|
|
+ if (tempCps.getClass() == HolonObject.class && tempCps != null) {
|
|
|
|
+ tableModelProperties.removeRow(2);
|
|
|
|
+ Object[] tempEnergy = { "Total Energy", ((HolonObject) canvas.tempCps).getCurrentEnergy() };
|
|
|
|
+ tableModelProperties.insertRow(2, tempEnergy);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|