|
@@ -22,24 +22,27 @@ import classes.CpsObject;
|
|
|
import classes.GlobalVariables;
|
|
|
import classes.HolonElement;
|
|
|
import classes.HolonObject;
|
|
|
+import ui.controller.Control;
|
|
|
import ui.model.*;
|
|
|
|
|
|
class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
|
private Image img = null; // Contains the image to draw on MyCanvas
|
|
|
private int x = 0;
|
|
|
private int y = 0;
|
|
|
- Model model;
|
|
|
+ private Model model;
|
|
|
+ private final Control controller;
|
|
|
|
|
|
boolean dragging = false;
|
|
|
boolean dropDelete = false;
|
|
|
- CpsObject tempCps = null;
|
|
|
- Rectangle selectRect = new Rectangle();
|
|
|
+ private CpsObject tempCps = null;
|
|
|
+ private Rectangle selectRect = new Rectangle();
|
|
|
|
|
|
// PopUpMenu
|
|
|
- JPopupMenu popmenu = new JPopupMenu();
|
|
|
- JMenuItem itemDelete = new JMenuItem("Delete Object");
|
|
|
+ private JPopupMenu popmenu = new JPopupMenu();
|
|
|
+ private JMenuItem itemDelete = new JMenuItem("Delete Object");
|
|
|
|
|
|
- public MyCanvas(final Model model) {
|
|
|
+ public MyCanvas(final Model model, Control control) {
|
|
|
+ this.controller = control;
|
|
|
this.model = model;
|
|
|
popmenu.add(itemDelete);
|
|
|
itemDelete.setEnabled(false);
|
|
@@ -107,8 +110,10 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
|
}
|
|
|
if(tempCps != null){
|
|
|
selectRect.setBounds(tempCps.getPos().x-(GlobalVariables.SCALE/20), tempCps.getPos().y-(GlobalVariables.SCALE/20), GlobalVariables.SCALE+GlobalVariables.SCALE/10, GlobalVariables.SCALE+GlobalVariables.SCALE/10);
|
|
|
+ controller.setSelectedObjectID(tempCps.getID());
|
|
|
System.out.println("Select");
|
|
|
}else {
|
|
|
+ controller.setSelectedObjectID(0);
|
|
|
selectRect.setRect(0, 0, 0, 0);
|
|
|
System.out.println("Unselect");
|
|
|
}
|