|
@@ -25,7 +25,7 @@ import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Link;
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Port;
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.Port;
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.SmartDevice;
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.SmartDevice;
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.util.Pair;
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.core.util.Pair;
|
|
-import de.tu_darmstadt.tk.SmartHomeNetworkSim.view.VisualisationInteractor;
|
|
|
|
|
|
+import de.tu_darmstadt.tk.SmartHomeNetworkSim.view.VisualizationInteractor;
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.view.util.LinkToolTip;
|
|
import de.tu_darmstadt.tk.SmartHomeNetworkSim.view.util.LinkToolTip;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -35,7 +35,7 @@ import de.tu_darmstadt.tk.SmartHomeNetworkSim.view.util.LinkToolTip;
|
|
* @author Andreas T. Meyer-Berg
|
|
* @author Andreas T. Meyer-Berg
|
|
*/
|
|
*/
|
|
@SuppressWarnings("serial")
|
|
@SuppressWarnings("serial")
|
|
-public class VisualisationPanel extends JPanel implements Observer {
|
|
|
|
|
|
+public class VisualizationPanel extends JPanel implements Observer {
|
|
|
|
|
|
/**
|
|
/**
|
|
* Controller to notify when the model changes
|
|
* Controller to notify when the model changes
|
|
@@ -55,7 +55,7 @@ public class VisualisationPanel extends JPanel implements Observer {
|
|
/**
|
|
/**
|
|
* Listener which processes the GUI Interactions
|
|
* Listener which processes the GUI Interactions
|
|
*/
|
|
*/
|
|
- private VisualisationInteractor interactor;
|
|
|
|
|
|
+ private VisualizationInteractor interactor;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Initializes the Visualization Panel
|
|
* Initializes the Visualization Panel
|
|
@@ -63,14 +63,14 @@ public class VisualisationPanel extends JPanel implements Observer {
|
|
* @param control
|
|
* @param control
|
|
* Control, which changes the model
|
|
* Control, which changes the model
|
|
*/
|
|
*/
|
|
- public VisualisationPanel(Controller control) {
|
|
|
|
|
|
+ public VisualizationPanel(Controller control) {
|
|
super();
|
|
super();
|
|
|
|
|
|
this.control = control;
|
|
this.control = control;
|
|
this.config = control.getSettingsController();
|
|
this.config = control.getSettingsController();
|
|
this.network = control.getNetworkController();
|
|
this.network = control.getNetworkController();
|
|
|
|
|
|
- this.interactor = new VisualisationInteractor(control, this);
|
|
|
|
|
|
+ this.interactor = new VisualizationInteractor(control, this);
|
|
this.addMouseMotionListener(interactor);
|
|
this.addMouseMotionListener(interactor);
|
|
this.addMouseListener(interactor);
|
|
this.addMouseListener(interactor);
|
|
this.addKeyListener(interactor);
|
|
this.addKeyListener(interactor);
|
|
@@ -158,22 +158,22 @@ public class VisualisationPanel extends JPanel implements Observer {
|
|
g.setColor(Color.RED);
|
|
g.setColor(Color.RED);
|
|
String modus;
|
|
String modus;
|
|
switch (interactor.mode) {
|
|
switch (interactor.mode) {
|
|
- case VisualisationInteractor.DRAG_CONNECTION:
|
|
|
|
|
|
+ case VisualizationInteractor.DRAG_CONNECTION:
|
|
modus="Drag Connection";
|
|
modus="Drag Connection";
|
|
break;
|
|
break;
|
|
- case VisualisationInteractor.SELECTED_DRAG:
|
|
|
|
|
|
+ case VisualizationInteractor.SELECTED_DRAG:
|
|
modus="Drag Device";
|
|
modus="Drag Device";
|
|
break;
|
|
break;
|
|
- case VisualisationInteractor.DRAG_SELECT:
|
|
|
|
|
|
+ case VisualizationInteractor.DRAG_SELECT:
|
|
modus="Drag Select";
|
|
modus="Drag Select";
|
|
break;
|
|
break;
|
|
- case VisualisationInteractor.NOTHING:
|
|
|
|
|
|
+ case VisualizationInteractor.NOTHING:
|
|
modus="Nothing";
|
|
modus="Nothing";
|
|
break;
|
|
break;
|
|
- case VisualisationInteractor.RIGHTCLICK_MENU:
|
|
|
|
|
|
+ case VisualizationInteractor.RIGHTCLICK_MENU:
|
|
modus="RightClick Menu";
|
|
modus="RightClick Menu";
|
|
break;
|
|
break;
|
|
- case VisualisationInteractor.SELECTED:
|
|
|
|
|
|
+ case VisualizationInteractor.SELECTED:
|
|
modus="Selected";
|
|
modus="Selected";
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
@@ -248,7 +248,7 @@ public class VisualisationPanel extends JPanel implements Observer {
|
|
* Pixel offset of dragged devices on the y axis
|
|
* Pixel offset of dragged devices on the y axis
|
|
*/
|
|
*/
|
|
int y_offset = 0;
|
|
int y_offset = 0;
|
|
- if(interactor.mode == VisualisationInteractor.SELECTED_DRAG && !control.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices.isEmpty()){
|
|
|
|
|
|
+ if(interactor.mode == VisualizationInteractor.SELECTED_DRAG && !control.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices.isEmpty()){
|
|
x_offset = interactor.dragged_x-interactor.dragged.getX();
|
|
x_offset = interactor.dragged_x-interactor.dragged.getX();
|
|
y_offset = interactor.dragged_y-interactor.dragged.getY();
|
|
y_offset = interactor.dragged_y-interactor.dragged.getY();
|
|
}
|
|
}
|
|
@@ -262,7 +262,7 @@ public class VisualisationPanel extends JPanel implements Observer {
|
|
* y Position of the device
|
|
* y Position of the device
|
|
*/
|
|
*/
|
|
int y = s.getY();
|
|
int y = s.getY();
|
|
- if(interactor.mode==VisualisationInteractor.SELECTED_DRAG && control.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices.contains(s)) {
|
|
|
|
|
|
+ if(interactor.mode==VisualizationInteractor.SELECTED_DRAG && control.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices.contains(s)) {
|
|
// Update visualization of dragged object
|
|
// Update visualization of dragged object
|
|
x += x_offset;
|
|
x += x_offset;
|
|
y += y_offset;
|
|
y += y_offset;
|
|
@@ -322,7 +322,7 @@ public class VisualisationPanel extends JPanel implements Observer {
|
|
//Values for dragging of multiple Devices
|
|
//Values for dragging of multiple Devices
|
|
int x_offset = 0;
|
|
int x_offset = 0;
|
|
int y_offset = 0;
|
|
int y_offset = 0;
|
|
- if(interactor.mode == VisualisationInteractor.SELECTED_DRAG && !control.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices.isEmpty()){
|
|
|
|
|
|
+ if(interactor.mode == VisualizationInteractor.SELECTED_DRAG && !control.getSettingsController().getConfigurationManager().getSelectionModel().selectedDevices.isEmpty()){
|
|
x_offset = interactor.dragged_x-interactor.dragged.getX();
|
|
x_offset = interactor.dragged_x-interactor.dragged.getX();
|
|
y_offset = interactor.dragged_y-interactor.dragged.getY();
|
|
y_offset = interactor.dragged_y-interactor.dragged.getY();
|
|
}
|
|
}
|
|
@@ -417,7 +417,7 @@ public class VisualisationPanel extends JPanel implements Observer {
|
|
}
|
|
}
|
|
// paint new in progress connection, if a connection or link is in
|
|
// paint new in progress connection, if a connection or link is in
|
|
// creation
|
|
// creation
|
|
- if (interactor.mode == VisualisationInteractor.DRAG_CONNECTION && interactor.connectionFrom != null){
|
|
|
|
|
|
+ if (interactor.mode == VisualizationInteractor.DRAG_CONNECTION && interactor.connectionFrom != null){
|
|
g.setColor(Color.ORANGE);
|
|
g.setColor(Color.ORANGE);
|
|
g.drawLine(interactor.connectionFrom.getX(),
|
|
g.drawLine(interactor.connectionFrom.getX(),
|
|
interactor.connectionFrom.getY(), interactor.dragged_x,
|
|
interactor.connectionFrom.getY(), interactor.dragged_x,
|
|
@@ -430,7 +430,7 @@ public class VisualisationPanel extends JPanel implements Observer {
|
|
* @param g graphics of this panel
|
|
* @param g graphics of this panel
|
|
*/
|
|
*/
|
|
protected void paintDrag(Graphics g){
|
|
protected void paintDrag(Graphics g){
|
|
- if(interactor.mode!=VisualisationInteractor.DRAG_SELECT)
|
|
|
|
|
|
+ if(interactor.mode!=VisualizationInteractor.DRAG_SELECT)
|
|
return;
|
|
return;
|
|
int low_x = Math.min(interactor.dragged_x, interactor.dragged_x_start);
|
|
int low_x = Math.min(interactor.dragged_x, interactor.dragged_x_start);
|
|
int low_y = Math.min(interactor.dragged_y, interactor.dragged_y_start);
|
|
int low_y = Math.min(interactor.dragged_y, interactor.dragged_y_start);
|