|
@@ -13,6 +13,7 @@ import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Connection;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Model;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Port;
|
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.SmartDevice;
|
|
|
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.protocols.MQTT_protocol;
|
|
|
|
|
|
@SuppressWarnings("serial")
|
|
|
public class VisualisationPanel extends JPanel {
|
|
@@ -153,7 +154,36 @@ public class VisualisationPanel extends JPanel {
|
|
|
* All Devices that are part of the connection
|
|
|
*/
|
|
|
Collection<Port> d = c.getParticipants();
|
|
|
- if (d.size() == 2) {
|
|
|
+ if(c.getProtocol() instanceof MQTT_protocol){
|
|
|
+ Port broker = c.getProtocol().getDevicesWithRole(0).iterator().next();
|
|
|
+ for(Port sd:d){
|
|
|
+ if(!model.getDevices().contains(sd.getOwner())){
|
|
|
+ SmartDevice removed = sd.getOwner();
|
|
|
+ g.fillOval(removed.getX()-visualisationRadius/4, removed.getY()-visualisationRadius/4, visualisationRadius/2, visualisationRadius/2);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (broker!= sd) {
|
|
|
+
|
|
|
+ int s_x, s_y, sd_x, sd_y;
|
|
|
+ if (broker.getOwner() == interactor.dragged) {
|
|
|
+ s_x = interactor.dragged_x;
|
|
|
+ s_y = interactor.dragged_y;
|
|
|
+ } else {
|
|
|
+ s_x = broker.getOwner().getX();
|
|
|
+ s_y = broker.getOwner().getY();
|
|
|
+ }
|
|
|
+ if (sd.getOwner() == interactor.dragged) {
|
|
|
+ sd_x = interactor.dragged_x;
|
|
|
+ sd_y = interactor.dragged_y;
|
|
|
+ } else {
|
|
|
+ sd_x = sd.getOwner().getX();
|
|
|
+ sd_y = sd.getOwner().getY();
|
|
|
+ }
|
|
|
+ g.drawLine(s_x, s_y, sd_x, sd_y);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (d.size() == 2) {
|
|
|
Port s = c.getSource();
|
|
|
for (Port sd : d) {
|
|
|
if(!model.getDevices().contains(sd.getOwner())){
|