|
@@ -13,7 +13,9 @@ import java.awt.event.MouseMotionListener;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.LinkedList;
|
|
import java.util.LinkedList;
|
|
|
|
|
|
|
|
+import javax.swing.AbstractButton;
|
|
import javax.swing.ImageIcon;
|
|
import javax.swing.ImageIcon;
|
|
|
|
+import javax.swing.JLabel;
|
|
import javax.swing.JMenuItem;
|
|
import javax.swing.JMenuItem;
|
|
import javax.swing.JPanel;
|
|
import javax.swing.JPanel;
|
|
import javax.swing.JPopupMenu;
|
|
import javax.swing.JPopupMenu;
|
|
@@ -40,6 +42,7 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
// PopUpMenu
|
|
// PopUpMenu
|
|
private JPopupMenu popmenu = new JPopupMenu();
|
|
private JPopupMenu popmenu = new JPopupMenu();
|
|
private JMenuItem itemDelete = new JMenuItem("Delete Object");
|
|
private JMenuItem itemDelete = new JMenuItem("Delete Object");
|
|
|
|
+ private JLabel labelID = new JLabel();
|
|
|
|
|
|
public MyCanvas(final Model model, Control control) {
|
|
public MyCanvas(final Model model, Control control) {
|
|
this.controller = control;
|
|
this.controller = control;
|
|
@@ -100,10 +103,12 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
// TODO Auto-generated method stub
|
|
// TODO Auto-generated method stub
|
|
x = e.getX();
|
|
x = e.getX();
|
|
y = e.getY();
|
|
y = e.getY();
|
|
|
|
+ int cx;
|
|
|
|
+ int cy;
|
|
tempCps = null;
|
|
tempCps = null;
|
|
for (CpsObject cps : model.getObjectsOnCanvas()) {
|
|
for (CpsObject cps : model.getObjectsOnCanvas()) {
|
|
- int cx = cps.getPos().x;
|
|
|
|
- int cy = cps.getPos().y;
|
|
|
|
|
|
+ cx = cps.getPos().x;
|
|
|
|
+ cy = cps.getPos().y;
|
|
if (x - GlobalVariables.SCALE <= cx && y - GlobalVariables.SCALE <= cy && x >= cx && y >= cy) {
|
|
if (x - GlobalVariables.SCALE <= cx && y - GlobalVariables.SCALE <= cy && x >= cx && y >= cy) {
|
|
tempCps = cps;
|
|
tempCps = cps;
|
|
}
|
|
}
|
|
@@ -158,7 +163,19 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void mouseMoved(MouseEvent e) {
|
|
public void mouseMoved(MouseEvent e) {
|
|
- // TODO Auto-generated method stub
|
|
|
|
-
|
|
|
|
|
|
+ x = e.getX();
|
|
|
|
+ y = e.getY();
|
|
|
|
+ int cx;
|
|
|
|
+ int cy;
|
|
|
|
+ tempCps = null;
|
|
|
|
+ for (CpsObject cps : model.getObjectsOnCanvas()) {
|
|
|
|
+ cx = cps.getPos().x;
|
|
|
|
+ cy = cps.getPos().y;
|
|
|
|
+ if (x - GlobalVariables.SCALE <= cx && y - GlobalVariables.SCALE <= cy && x >= cx && y >= cy) {
|
|
|
|
+ labelID.setText("ID: "+cps.getID());
|
|
|
|
+ labelID.setLocation(cx, cy);
|
|
|
|
+ System.out.println("show");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|