|
@@ -47,13 +47,14 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
private Model model;
|
|
private Model model;
|
|
private final Control controller;
|
|
private final Control controller;
|
|
Graphics2D g2; // For Painting
|
|
Graphics2D g2; // For Painting
|
|
- private int cx;
|
|
|
|
- private int cy;
|
|
|
|
|
|
+ private int cx, cy, sx, sy;
|
|
|
|
+
|
|
ArrayList<HolonElement> dataSelected = new ArrayList<HolonElement>();
|
|
ArrayList<HolonElement> dataSelected = new ArrayList<HolonElement>();
|
|
|
|
|
|
private boolean dragging = false; // for dragging
|
|
private boolean dragging = false; // for dragging
|
|
private boolean drawEdge = false; // for drawing edges
|
|
private boolean drawEdge = false; // for drawing edges
|
|
private boolean click = false; // for double click
|
|
private boolean click = false; // for double click
|
|
|
|
+ private boolean doMark = false; // for double click
|
|
public CpsObject tempCps = null;
|
|
public CpsObject tempCps = null;
|
|
private Rectangle selectRect = new Rectangle();
|
|
private Rectangle selectRect = new Rectangle();
|
|
private CpsEdge edgeHighlight = null;
|
|
private CpsEdge edgeHighlight = null;
|
|
@@ -166,15 +167,14 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
if (cps.getID() == model.getSelectedObjectID() && controller.searchByID(model.getSelectedObjectID()) != null
|
|
if (cps.getID() == model.getSelectedObjectID() && controller.searchByID(model.getSelectedObjectID()) != null
|
|
&& controller.searchByID(model.getSelectedObjectID()) instanceof CpsNode) {
|
|
&& controller.searchByID(model.getSelectedObjectID()) instanceof CpsNode) {
|
|
img = new ImageIcon(this.getClass().getResource("/Images/node_selected.png")).getImage();
|
|
img = new ImageIcon(this.getClass().getResource("/Images/node_selected.png")).getImage();
|
|
- }
|
|
|
|
- else {
|
|
|
|
|
|
+ } else {
|
|
if (cps instanceof HolonSwitch) {
|
|
if (cps instanceof HolonSwitch) {
|
|
if (((HolonSwitch) cps).getActiveAt()[model.getCurIteration()]) {
|
|
if (((HolonSwitch) cps).getActiveAt()[model.getCurIteration()]) {
|
|
((HolonSwitch) cps).setState(true);
|
|
((HolonSwitch) cps).setState(true);
|
|
} else {
|
|
} else {
|
|
((HolonSwitch) cps).setState(false);
|
|
((HolonSwitch) cps).setState(false);
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ }
|
|
if (cps == tempCps) {
|
|
if (cps == tempCps) {
|
|
g2.setColor(Color.BLUE);
|
|
g2.setColor(Color.BLUE);
|
|
g2.fillRect((int) selectRect.getX(), (int) selectRect.getY(), (int) selectRect.getWidth(),
|
|
g2.fillRect((int) selectRect.getX(), (int) selectRect.getY(), (int) selectRect.getWidth(),
|
|
@@ -183,10 +183,10 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
if (((HolonObject) cps).getSupplied()) {
|
|
if (((HolonObject) cps).getSupplied()) {
|
|
g2.setColor(Color.GREEN);
|
|
g2.setColor(Color.GREEN);
|
|
} else {
|
|
} else {
|
|
- g2.setColor(Color.RED);
|
|
|
|
|
|
+ g2.setColor(Color.YELLOW);
|
|
}
|
|
}
|
|
g2.fillRect(cps.getPosition().x - (controller.getScale() / 20),
|
|
g2.fillRect(cps.getPosition().x - (controller.getScale() / 20),
|
|
- cps.getPosition().y - (controller.getScale() / 20),
|
|
|
|
|
|
+ cps.getPosition().y - (controller.getScale() / 20),
|
|
controller.getScale() + ((controller.getScale() / 20) * 2),
|
|
controller.getScale() + ((controller.getScale() / 20) * 2),
|
|
controller.getScale() + ((controller.getScale() / 20) * 2));
|
|
controller.getScale() + ((controller.getScale() / 20) * 2));
|
|
}
|
|
}
|
|
@@ -199,8 +199,21 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
}
|
|
}
|
|
g2.drawImage(img, cps.getPosition().x, cps.getPosition().y, controller.getScale(), controller.getScale(),
|
|
g2.drawImage(img, cps.getPosition().x, cps.getPosition().y, controller.getScale(), controller.getScale(),
|
|
null);
|
|
null);
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //Dragg Highlighting
|
|
|
|
+ if (doMark) {
|
|
|
|
+ if (sx<x && sy<y) {
|
|
|
|
+ g2.drawRect(sx, sy, x-sx, y-sy);
|
|
|
|
+ } else if (sx>=x) {
|
|
|
|
+ g2.drawRect(x, sy, sx-x, y-sy);
|
|
|
|
+ } else if (sy>=y){
|
|
|
|
+ g2.drawRect(sx, y, x-sx, sy-y);
|
|
|
|
+ } else {
|
|
|
|
+ g2.drawRect(x, y, 30, 30x);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -228,13 +241,14 @@ 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()) {
|
|
|
|
- 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();
|
|
|
|
+ dragging = true;
|
|
|
|
+ }
|
|
|
|
+ if (e.isControlDown()) {
|
|
|
|
+ drawEdge = true;
|
|
|
|
+ dragging = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -243,6 +257,12 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
edgeHighlight = mousePositionOnEdge(x, y);
|
|
edgeHighlight = mousePositionOnEdge(x, y);
|
|
controller.setSelecteEdge(edgeHighlight);
|
|
controller.setSelecteEdge(edgeHighlight);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (edgeHighlight == null) {
|
|
|
|
+ sx = e.getX();
|
|
|
|
+ sy = e.getY();
|
|
|
|
+ doMark = true;
|
|
|
|
+ }
|
|
// Object Selection Highlighting (selectRect)
|
|
// Object Selection Highlighting (selectRect)
|
|
objectSelectionHighlighting();
|
|
objectSelectionHighlighting();
|
|
|
|
|
|
@@ -274,17 +294,16 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
popmenu.show(e.getComponent(), e.getX(), e.getY());
|
|
popmenu.show(e.getComponent(), e.getX(), e.getY());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ doMark = false;
|
|
repaint();
|
|
repaint();
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void mouseDragged(MouseEvent e) {
|
|
public void mouseDragged(MouseEvent e) {
|
|
// If Edge is drawn
|
|
// If Edge is drawn
|
|
- if (drawEdge) {
|
|
|
|
- x = e.getX();
|
|
|
|
- y = e.getY();
|
|
|
|
- repaint();
|
|
|
|
- } else {
|
|
|
|
|
|
+ x = e.getX();
|
|
|
|
+ y = e.getY();
|
|
|
|
+ if (dragging) {
|
|
try {
|
|
try {
|
|
// Au�erhalb des Randes gedragged?
|
|
// Au�erhalb des Randes gedragged?
|
|
x = e.getX() - controller.getScaleDiv2();
|
|
x = e.getX() - controller.getScaleDiv2();
|
|
@@ -309,6 +328,7 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ repaint();
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -416,11 +436,11 @@ class MyCanvas extends JPanel implements MouseListener, MouseMotionListener {
|
|
k = p.getB();
|
|
k = p.getB();
|
|
|
|
|
|
e = new CpsEdge(n, tempCps);
|
|
e = new CpsEdge(n, tempCps);
|
|
-
|
|
|
|
|
|
+
|
|
e1 = new CpsEdge(n, r);
|
|
e1 = new CpsEdge(n, r);
|
|
-
|
|
|
|
|
|
+
|
|
e2 = new CpsEdge(n, k);
|
|
e2 = new CpsEdge(n, k);
|
|
-
|
|
|
|
|
|
+
|
|
p.getA().getConnections().remove(p);
|
|
p.getA().getConnections().remove(p);
|
|
p.getB().getConnections().remove(p);
|
|
p.getB().getConnections().remove(p);
|
|
|
|
|