|
@@ -66,6 +66,9 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
model.getObjectsOnCanvas().remove(tempCps);
|
|
|
+ for (CpsObject cps : model.getObjectsOnCanvas()) {
|
|
|
+ cps.getConnectedTo().remove(tempCps);
|
|
|
+ }
|
|
|
tempCps = null;
|
|
|
selectRect.setRect(0, 0, 0, 0);
|
|
|
repaint();
|
|
@@ -99,6 +102,12 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
|
g.setColor(Color.BLACK);
|
|
|
if(drawEdge)g.drawLine(tempCps.getPos().x+GlobalVariables.SCALE_DIVIDED2, tempCps.getPos().y+GlobalVariables.SCALE_DIVIDED2, x, y);
|
|
|
|
|
|
+ for (CpsObject cps : model.getObjectsOnCanvas()) {
|
|
|
+ for (CpsObject con : cps.getConnectedTo()) {
|
|
|
+ g.drawLine(cps.getPos().x+GlobalVariables.SCALE_DIVIDED2, cps.getPos().y+GlobalVariables.SCALE_DIVIDED2, con.getPos().x+GlobalVariables.SCALE_DIVIDED2, con.getPos().y+GlobalVariables.SCALE_DIVIDED2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//Objects
|
|
|
for (CpsObject cps : model.getObjectsOnCanvas()) {
|
|
|
img = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage();
|
|
@@ -150,6 +159,14 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
|
public void mouseReleased(MouseEvent e) {
|
|
|
if(drawEdge){
|
|
|
drawEdge = false;
|
|
|
+ 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) {
|
|
|
+ cps.AddConnection(tempCps);
|
|
|
+ tempCps.AddConnection(cps);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (dragging) {
|