|
@@ -111,7 +111,7 @@ public class VisualisationPanel extends JPanel implements Observer {
|
|
|
case VisualisationInteractor.DRAG_CONNECTION:
|
|
|
modus="Drag Connection";
|
|
|
break;
|
|
|
- case VisualisationInteractor.DRAG_DEVICE:
|
|
|
+ case VisualisationInteractor.SELECTED_DRAG:
|
|
|
modus="Drag Device";
|
|
|
break;
|
|
|
case VisualisationInteractor.DRAG_SELECT:
|
|
@@ -142,16 +142,23 @@ public class VisualisationPanel extends JPanel implements Observer {
|
|
|
* the Graphics object to visualize on
|
|
|
*/
|
|
|
public void paintDevices(Graphics g) {
|
|
|
-
|
|
|
+ //Values for dragging of multiple Devices
|
|
|
+ int x_offset = 0;
|
|
|
+ int y_offset = 0;
|
|
|
+ if(interactor.mode == VisualisationInteractor.SELECTED_DRAG && !interactor.selectedDevices.isEmpty()){
|
|
|
+ x_offset = interactor.dragged_x-interactor.dragged.getX();
|
|
|
+ y_offset = interactor.dragged_y-interactor.dragged.getY();
|
|
|
+ }
|
|
|
+ //Paint Devices
|
|
|
for (SmartDevice s: model.getDevices()) {
|
|
|
int x = s.getX();
|
|
|
int y = s.getY();
|
|
|
- if(interactor.mode==VisualisationInteractor.DRAG_DEVICE && s == interactor.dragged) {
|
|
|
+ if(interactor.mode==VisualisationInteractor.SELECTED_DRAG && interactor.selectedDevices.contains(s)) {
|
|
|
// Update visualization of dragged object
|
|
|
- x = interactor.dragged_x;
|
|
|
- y = interactor.dragged_y;
|
|
|
+ x += x_offset;
|
|
|
+ y += y_offset;
|
|
|
}
|
|
|
- if((interactor.mode==VisualisationInteractor.SELECTED||interactor.mode==VisualisationInteractor.DRAG_SELECT)&&(interactor.selectedDevices.contains(s)^interactor.selectedDevicesDrag.contains(s))){
|
|
|
+ if((interactor.mode==VisualisationInteractor.SELECTED||interactor.mode==VisualisationInteractor.DRAG_SELECT ||interactor.mode == VisualisationInteractor.SELECTED_DRAG)&&(interactor.selectedDevices.contains(s)^interactor.selectedDevicesDrag.contains(s))){
|
|
|
//HighlightSelected Devices
|
|
|
g.setColor(new Color(135,206,235));
|
|
|
}else
|
|
@@ -179,6 +186,13 @@ public class VisualisationPanel extends JPanel implements Observer {
|
|
|
* the Graphics object to visualize on
|
|
|
*/
|
|
|
private void paintConnections(Graphics g) {
|
|
|
+ //Values for dragging of multiple Devices
|
|
|
+ int x_offset = 0;
|
|
|
+ int y_offset = 0;
|
|
|
+ if(interactor.mode == VisualisationInteractor.SELECTED_DRAG && !interactor.selectedDevices.isEmpty()){
|
|
|
+ x_offset = interactor.dragged_x-interactor.dragged.getX();
|
|
|
+ y_offset = interactor.dragged_y-interactor.dragged.getY();
|
|
|
+ }
|
|
|
// For all Connections
|
|
|
for (Connection c : model.getConnections()) {
|
|
|
Color connectionState;
|
|
@@ -217,9 +231,9 @@ public class VisualisationPanel extends JPanel implements Observer {
|
|
|
* if broker was removed, paint broker at the average position
|
|
|
*/
|
|
|
for(Port p: c.getParticipants()){
|
|
|
- if(interactor.mode==VisualisationInteractor.DRAG_DEVICE && p.getOwner()==interactor.dragged){
|
|
|
- broker_x+=interactor.dragged_x;
|
|
|
- broker_y+=interactor.dragged_y;
|
|
|
+ if(interactor.mode==VisualisationInteractor.SELECTED_DRAG && interactor.selectedDevices.contains(p.getOwner())){
|
|
|
+ broker_x+=p.getOwner().getX()+x_offset;
|
|
|
+ broker_y+=p.getOwner().getY()+y_offset;
|
|
|
}else{
|
|
|
|
|
|
broker_x+=p.getOwner().getX();
|
|
@@ -230,8 +244,13 @@ public class VisualisationPanel extends JPanel implements Observer {
|
|
|
broker_y/=c.getParticipants().size();
|
|
|
g.fillOval(broker_x-control.getDevice_visualization_radius()/4, broker_y-control.getDevice_visualization_radius()/4, control.getDevice_visualization_radius()/2, control.getDevice_visualization_radius()/2);
|
|
|
}else{
|
|
|
- broker_x=broker.getOwner().getX();
|
|
|
- broker_y=broker.getOwner().getY();
|
|
|
+ if(interactor.mode==VisualisationInteractor.SELECTED_DRAG && interactor.selectedDevices.contains(broker.getOwner())){
|
|
|
+ broker_x=broker.getOwner().getX()+x_offset;
|
|
|
+ broker_y=broker.getOwner().getY()+y_offset;
|
|
|
+ }else{
|
|
|
+ broker_x=broker.getOwner().getX();
|
|
|
+ broker_y=broker.getOwner().getY();
|
|
|
+ }
|
|
|
}
|
|
|
for(Port sd:d){
|
|
|
if(!model.getDevices().contains(sd.getOwner())){
|
|
@@ -245,22 +264,22 @@ public class VisualisationPanel extends JPanel implements Observer {
|
|
|
if (broker!= sd) {
|
|
|
// Check if dragged object
|
|
|
int s_x, s_y, sd_x, sd_y;
|
|
|
- if (interactor.mode==VisualisationInteractor.DRAG_DEVICE && broker != null && broker.getOwner() == interactor.dragged) {
|
|
|
- s_x = interactor.dragged_x;
|
|
|
- s_y = interactor.dragged_y;
|
|
|
+ if (interactor.mode==VisualisationInteractor.SELECTED_DRAG && broker != null && interactor.selectedDevices.contains(broker.getOwner())) {
|
|
|
+ s_x = broker.getOwner().getX()+x_offset;
|
|
|
+ s_y = broker.getOwner().getY()+y_offset;
|
|
|
} else if(broker==null){
|
|
|
/**
|
|
|
* if broker was removed, paint edges to the previously calculated average position
|
|
|
*/
|
|
|
- s_x=broker_x;
|
|
|
- s_y=broker_y;
|
|
|
+ s_x = broker_x;
|
|
|
+ s_y = broker_y;
|
|
|
}else{
|
|
|
s_x = broker_x;
|
|
|
s_y = broker_y;
|
|
|
}
|
|
|
- if (interactor.mode==VisualisationInteractor.DRAG_DEVICE && sd.getOwner() == interactor.dragged) {
|
|
|
- sd_x = interactor.dragged_x;
|
|
|
- sd_y = interactor.dragged_y;
|
|
|
+ if (interactor.mode==VisualisationInteractor.SELECTED_DRAG && interactor.selectedDevices.contains(sd.getOwner())) {
|
|
|
+ sd_x = sd.getOwner().getX()+x_offset;
|
|
|
+ sd_y = sd.getOwner().getY()+y_offset;
|
|
|
} else {
|
|
|
sd_x = sd.getOwner().getX();
|
|
|
sd_y = sd.getOwner().getY();
|
|
@@ -282,16 +301,16 @@ public class VisualisationPanel extends JPanel implements Observer {
|
|
|
if (s != sd) {
|
|
|
// Check if dragged object
|
|
|
int s_x, s_y, sd_x, sd_y;
|
|
|
- if (interactor.mode==VisualisationInteractor.DRAG_DEVICE && s.getOwner() == interactor.dragged) {
|
|
|
- s_x = interactor.dragged_x;
|
|
|
- s_y = interactor.dragged_y;
|
|
|
+ if (interactor.mode==VisualisationInteractor.SELECTED_DRAG && interactor.selectedDevices.contains(s.getOwner())) {
|
|
|
+ s_x = s.getOwner().getX()+x_offset;
|
|
|
+ s_y = s.getOwner().getY()+y_offset;
|
|
|
} else {
|
|
|
s_x = s.getOwner().getX();
|
|
|
s_y = s.getOwner().getY();
|
|
|
}
|
|
|
- if (interactor.mode==VisualisationInteractor.DRAG_DEVICE && sd.getOwner() == interactor.dragged) {
|
|
|
- sd_x = interactor.dragged_x;
|
|
|
- sd_y = interactor.dragged_y;
|
|
|
+ if (interactor.mode==VisualisationInteractor.SELECTED_DRAG && interactor.selectedDevices.contains(sd.getOwner())) {
|
|
|
+ sd_x = sd.getOwner().getX()+x_offset;
|
|
|
+ sd_y = sd.getOwner().getY()+y_offset;
|
|
|
} else {
|
|
|
sd_x = sd.getOwner().getX();
|
|
|
sd_y = sd.getOwner().getY();
|