|
@@ -30,7 +30,6 @@ import javax.swing.JPopupMenu;
|
|
import javax.swing.JToolTip;
|
|
import javax.swing.JToolTip;
|
|
|
|
|
|
import classes.CpsObject;
|
|
import classes.CpsObject;
|
|
-import classes.GlobalVariables;
|
|
|
|
import classes.HolonElement;
|
|
import classes.HolonElement;
|
|
import classes.HolonObject;
|
|
import classes.HolonObject;
|
|
import ui.controller.Control;
|
|
import ui.controller.Control;
|
|
@@ -103,16 +102,16 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
// drawEdges
|
|
// drawEdges
|
|
g2.setColor(Color.BLACK);
|
|
g2.setColor(Color.BLACK);
|
|
if (drawEdge)
|
|
if (drawEdge)
|
|
- g2.drawLine(tempCps.getPos().x + GlobalVariables.SCALE_DIVIDED2,
|
|
|
|
- tempCps.getPos().y + GlobalVariables.SCALE_DIVIDED2, x, y);
|
|
|
|
|
|
+ g2.drawLine(tempCps.getPos().x + controller.getScaleDiv2(),
|
|
|
|
+ tempCps.getPos().y + controller.getScaleDiv2(), x, y);
|
|
|
|
|
|
for (CpsObject cps : model.getObjectsOnCanvas()) {
|
|
for (CpsObject cps : model.getObjectsOnCanvas()) {
|
|
for (CpsObject con : cps.getConnectedTo()) {
|
|
for (CpsObject con : cps.getConnectedTo()) {
|
|
if (con.getID() != model.getSelectedObjectID() && cps.getID() != model.getSelectedObjectID())
|
|
if (con.getID() != model.getSelectedObjectID() && cps.getID() != model.getSelectedObjectID())
|
|
- g2.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);
|
|
|
|
|
|
+ g2.drawLine(cps.getPos().x + controller.getScaleDiv2(),
|
|
|
|
+ cps.getPos().y + controller.getScaleDiv2(),
|
|
|
|
+ con.getPos().x + controller.getScaleDiv2(),
|
|
|
|
+ con.getPos().y + controller.getScaleDiv2());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -121,17 +120,17 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
for (CpsObject cps : model.getObjectsOnCanvas()) {
|
|
for (CpsObject cps : model.getObjectsOnCanvas()) {
|
|
for (CpsObject con : cps.getConnectedTo()) {
|
|
for (CpsObject con : cps.getConnectedTo()) {
|
|
if (con.getID() == model.getSelectedObjectID())
|
|
if (con.getID() == model.getSelectedObjectID())
|
|
- g2.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);
|
|
|
|
|
|
+ g2.drawLine(cps.getPos().x + controller.getScaleDiv2(),
|
|
|
|
+ cps.getPos().y + controller.getScaleDiv2(),
|
|
|
|
+ con.getPos().x + controller.getScaleDiv2(),
|
|
|
|
+ con.getPos().y + controller.getScaleDiv2());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// Objects
|
|
// Objects
|
|
for (CpsObject cps : model.getObjectsOnCanvas()) {
|
|
for (CpsObject cps : model.getObjectsOnCanvas()) {
|
|
img = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage();
|
|
img = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage();
|
|
- g2.drawImage(img, cps.getPos().x, cps.getPos().y, GlobalVariables.SCALE, GlobalVariables.SCALE, null);
|
|
|
|
|
|
+ g2.drawImage(img, cps.getPos().x, cps.getPos().y, controller.getScale(), controller.getScale(), null);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -163,7 +162,7 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
for (CpsObject cps : model.getObjectsOnCanvas()) {
|
|
for (CpsObject cps : model.getObjectsOnCanvas()) {
|
|
cx = cps.getPos().x;
|
|
cx = cps.getPos().x;
|
|
cy = cps.getPos().y;
|
|
cy = cps.getPos().y;
|
|
- if (x - GlobalVariables.SCALE <= cx && y - GlobalVariables.SCALE <= cy && x >= cx && y >= cy) {
|
|
|
|
|
|
+ if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
|
|
tempCps = cps;
|
|
tempCps = cps;
|
|
if (e.isControlDown())
|
|
if (e.isControlDown())
|
|
drawEdge = true;
|
|
drawEdge = true;
|
|
@@ -188,7 +187,7 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
y = e.getY();
|
|
y = e.getY();
|
|
|
|
|
|
dragging = false;
|
|
dragging = false;
|
|
- tempCps.setPos(e.getX() - GlobalVariables.SCALE_DIVIDED2, e.getY() - GlobalVariables.SCALE_DIVIDED2);
|
|
|
|
|
|
+ tempCps.setPos(e.getX() - controller.getScaleDiv2(), e.getY() - controller.getScaleDiv2());
|
|
tempCps = null;
|
|
tempCps = null;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -214,10 +213,10 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
repaint();
|
|
repaint();
|
|
} else {
|
|
} else {
|
|
try {
|
|
try {
|
|
- tempCps.setPos(e.getX() - GlobalVariables.SCALE_DIVIDED2, e.getY() - GlobalVariables.SCALE_DIVIDED2);
|
|
|
|
|
|
+ tempCps.setPos(e.getX() - controller.getScaleDiv2(), e.getY() - controller.getScaleDiv2());
|
|
dragging = true;
|
|
dragging = true;
|
|
- selectRect.setLocation(tempCps.getPos().x - (GlobalVariables.SCALE / 20),
|
|
|
|
- tempCps.getPos().y - (GlobalVariables.SCALE / 20));
|
|
|
|
|
|
+ selectRect.setLocation(tempCps.getPos().x - (controller.getScale() / 20),
|
|
|
|
+ tempCps.getPos().y - (controller.getScale() / 20));
|
|
objectTT.setTipText(tempCps.getName());
|
|
objectTT.setTipText(tempCps.getName());
|
|
objectTT.setLocation(tempCps.getPos().x, tempCps.getPos().y);
|
|
objectTT.setLocation(tempCps.getPos().x, tempCps.getPos().y);
|
|
repaint();
|
|
repaint();
|
|
@@ -236,7 +235,7 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
for (CpsObject cps : model.getObjectsOnCanvas()) {
|
|
for (CpsObject cps : model.getObjectsOnCanvas()) {
|
|
cx = cps.getPos().x;
|
|
cx = cps.getPos().x;
|
|
cy = cps.getPos().y;
|
|
cy = cps.getPos().y;
|
|
- if (x - GlobalVariables.SCALE <= cx && y - GlobalVariables.SCALE <= cy && x >= cx && y >= cy) {
|
|
|
|
|
|
+ if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
|
|
objectTT.setTipText(cps.getName());
|
|
objectTT.setTipText(cps.getName());
|
|
objectTT.setLocation(cx, cy);
|
|
objectTT.setLocation(cx, cy);
|
|
on = true;
|
|
on = true;
|
|
@@ -253,10 +252,10 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
*/
|
|
*/
|
|
private void objectSelectionHighlighting() {
|
|
private void objectSelectionHighlighting() {
|
|
if (tempCps != null) {
|
|
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);
|
|
|
|
|
|
+ selectRect.setBounds(tempCps.getPos().x - (controller.getScale() / 20),
|
|
|
|
+ tempCps.getPos().y - (controller.getScale() / 20),
|
|
|
|
+ controller.getScale() + controller.getScale() / 10,
|
|
|
|
+ controller.getScale() + controller.getScale() / 10);
|
|
controller.setSelectedObjectID(tempCps.getID());
|
|
controller.setSelectedObjectID(tempCps.getID());
|
|
} else {
|
|
} else {
|
|
controller.setSelectedObjectID(0);
|
|
controller.setSelectedObjectID(0);
|
|
@@ -271,7 +270,7 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
for (CpsObject cps : model.getObjectsOnCanvas()) {
|
|
for (CpsObject cps : model.getObjectsOnCanvas()) {
|
|
cx = cps.getPos().x;
|
|
cx = cps.getPos().x;
|
|
cy = cps.getPos().y;
|
|
cy = cps.getPos().y;
|
|
- if (x - GlobalVariables.SCALE <= cx && y - GlobalVariables.SCALE <= cy && x >= cx && y >= cy) {
|
|
|
|
|
|
+ if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
|
|
if (!cps.getConnectedTo().contains(tempCps)) {
|
|
if (!cps.getConnectedTo().contains(tempCps)) {
|
|
cps.AddConnection(tempCps);
|
|
cps.AddConnection(tempCps);
|
|
tempCps.AddConnection(cps);
|
|
tempCps.AddConnection(cps);
|