|
@@ -175,10 +175,6 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void mousePressed(MouseEvent e) {
|
|
public void mousePressed(MouseEvent e) {
|
|
- // TODO Auto-generated method stub
|
|
|
|
- x = e.getX();
|
|
|
|
- y = e.getY();
|
|
|
|
-
|
|
|
|
tempCps = null;
|
|
tempCps = null;
|
|
// Object Selection
|
|
// Object Selection
|
|
for (CpsObject cps : model.getObjectsOnCanvas()) {
|
|
for (CpsObject cps : model.getObjectsOnCanvas()) {
|
|
@@ -187,17 +183,15 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
|
|
if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
|
|
tempCps = cps;
|
|
tempCps = cps;
|
|
// If drawing an Edge (CTRL down)
|
|
// If drawing an Edge (CTRL down)
|
|
- if (e.isControlDown())
|
|
|
|
-
|
|
|
|
|
|
+ if (e.isControlDown()){
|
|
drawEdge = true;
|
|
drawEdge = true;
|
|
|
|
+ }
|
|
if (tempCps.getClass() == HolonObject.class) {
|
|
if (tempCps.getClass() == HolonObject.class) {
|
|
HolonObject tempObj = ((HolonObject) tempCps);
|
|
HolonObject tempObj = ((HolonObject) tempCps);
|
|
dataSelected = tempObj.getElements();
|
|
dataSelected = tempObj.getElements();
|
|
} else {
|
|
} else {
|
|
dataSelected = new ArrayList<>();
|
|
dataSelected = new ArrayList<>();
|
|
}
|
|
}
|
|
-
|
|
|
|
- drawEdge = true;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// Object Selection Highlighting (selectRect)
|
|
// Object Selection Highlighting (selectRect)
|
|
@@ -236,24 +230,30 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void mouseDragged(MouseEvent e) {
|
|
public void mouseDragged(MouseEvent e) {
|
|
- // If Edge is drawn
|
|
|
|
|
|
+ //If Edge is drawn
|
|
if (drawEdge) {
|
|
if (drawEdge) {
|
|
x = e.getX();
|
|
x = e.getX();
|
|
y = e.getY();
|
|
y = e.getY();
|
|
repaint();
|
|
repaint();
|
|
} else {
|
|
} else {
|
|
try {
|
|
try {
|
|
- // Drag Position
|
|
|
|
- tempCps.setPosition(e.getX() - controller.getScaleDiv2(), e.getY() - controller.getScaleDiv2());
|
|
|
|
- dragging = true;
|
|
|
|
- // Highlighting Position
|
|
|
|
- selectRect.setLocation(tempCps.getPosition().x - (controller.getScale() / 20),
|
|
|
|
- tempCps.getPosition().y - (controller.getScale() / 20));
|
|
|
|
- // TipText Position and name
|
|
|
|
|
|
+ x = e.getX()-controller.getScaleDiv2();
|
|
|
|
+ y = e.getY()-controller.getScaleDiv2();
|
|
|
|
+ if(e.getX()<controller.getScaleDiv2())x = 0;
|
|
|
|
+ else if(e.getX()>this.getWidth()-controller.getScaleDiv2())x = this.getWidth()-controller.getScale();
|
|
|
|
+ if(e.getY()<controller.getScaleDiv2())y = 0;
|
|
|
|
+ else if(e.getY()>this.getHeight()-controller.getScaleDiv2())y = this.getHeight()-controller.getScale();
|
|
|
|
+ //Drag Position
|
|
|
|
+ tempCps.setPosition(x, y);
|
|
|
|
+ //Highlighting Position
|
|
|
|
+ selectRect.setLocation(x - (controller.getScale() / 20),y - (controller.getScale() / 20));
|
|
|
|
+ //TipText Position and name
|
|
objectTT.setTipText(tempCps.getName());
|
|
objectTT.setTipText(tempCps.getName());
|
|
- objectTT.setLocation(tempCps.getPosition().x, tempCps.getPosition().y + controller.getScale());
|
|
|
|
|
|
+ objectTT.setLocation(x, y+controller.getScale());
|
|
repaint();
|
|
repaint();
|
|
- } catch (Exception e2) {
|
|
|
|
|
|
+ }
|
|
|
|
+ catch (Exception e2) {
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|