|
@@ -54,7 +54,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
|
|
|
|
ArrayList<HolonElement> dataSelected = new ArrayList<HolonElement>();
|
|
ArrayList<HolonElement> dataSelected = new ArrayList<HolonElement>();
|
|
ArrayList<CpsObject> TempSelected = new ArrayList<CpsObject>();
|
|
ArrayList<CpsObject> TempSelected = new ArrayList<CpsObject>();
|
|
-
|
|
|
|
|
|
+
|
|
private boolean[] showedInformation = new boolean[3];
|
|
private boolean[] showedInformation = new boolean[3];
|
|
private boolean dragging = false; // for dragging
|
|
private boolean dragging = false; // for dragging
|
|
private boolean dragged = false; // if an object/objects was/were dragged
|
|
private boolean dragged = false; // if an object/objects was/were dragged
|
|
@@ -87,7 +87,14 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
@Override
|
|
@Override
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
// Remove the selected Object object
|
|
// Remove the selected Object object
|
|
- controller.delCanvasObject(tempCps);
|
|
|
|
|
|
+ if (model.getSelectedCpsObjects().size() <= 1) {
|
|
|
|
+ controller.delCanvasObject(tempCps);
|
|
|
|
+ } else {
|
|
|
|
+ for (CpsObject cps : model.getSelectedCpsObjects()) {
|
|
|
|
+ controller.delCanvasObject(cps);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ model.getSelectedCpsObjects().clear();
|
|
tempCps = null;
|
|
tempCps = null;
|
|
selectRect.setRect(0, 0, 0, 0);
|
|
selectRect.setRect(0, 0, 0, 0);
|
|
repaint();
|
|
repaint();
|
|
@@ -126,7 +133,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
&& con != edgeHighlight) {
|
|
&& con != edgeHighlight) {
|
|
if (con.getFlow() <= con.getCapacity() || con.getCapacity() == -1) {
|
|
if (con.getFlow() <= con.getCapacity() || con.getCapacity() == -1) {
|
|
g2.setColor(Color.GREEN);
|
|
g2.setColor(Color.GREEN);
|
|
- if(con.getCapacity() != -1){
|
|
|
|
|
|
+ if (con.getCapacity() != -1) {
|
|
g2.setStroke(new BasicStroke(Math.min((con.getFlow() / con.getCapacity() * 4), 4)));
|
|
g2.setStroke(new BasicStroke(Math.min((con.getFlow() / con.getCapacity() * 4), 4)));
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -137,13 +144,13 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
con.getA().getPosition().y + controller.getScaleDiv2(),
|
|
con.getA().getPosition().y + controller.getScaleDiv2(),
|
|
con.getB().getPosition().x + controller.getScaleDiv2(),
|
|
con.getB().getPosition().x + controller.getScaleDiv2(),
|
|
con.getB().getPosition().y + controller.getScaleDiv2());
|
|
con.getB().getPosition().y + controller.getScaleDiv2());
|
|
-
|
|
|
|
- if(con.getCapacity() == -1){
|
|
|
|
|
|
+
|
|
|
|
+ if (con.getCapacity() == -1) {
|
|
maxCap = Character.toString('\u221e');
|
|
maxCap = Character.toString('\u221e');
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
maxCap = String.valueOf(con.getCapacity());
|
|
maxCap = String.valueOf(con.getCapacity());
|
|
}
|
|
}
|
|
- if(showedInformation[0]){
|
|
|
|
|
|
+ if (showedInformation[0]) {
|
|
g2.drawString(con.getFlow() + "/" + maxCap,
|
|
g2.drawString(con.getFlow() + "/" + maxCap,
|
|
(con.getA().getPosition().x + con.getB().getPosition().x) / 2 + controller.getScaleDiv2(),
|
|
(con.getA().getPosition().x + con.getB().getPosition().x) / 2 + controller.getScaleDiv2(),
|
|
(con.getA().getPosition().y + con.getB().getPosition().y) / 2 + controller.getScaleDiv2());
|
|
(con.getA().getPosition().y + con.getB().getPosition().y) / 2 + controller.getScaleDiv2());
|
|
@@ -166,16 +173,18 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
con.getA().getPosition().y + controller.getScaleDiv2(),
|
|
con.getA().getPosition().y + controller.getScaleDiv2(),
|
|
con.getB().getPosition().x + controller.getScaleDiv2(),
|
|
con.getB().getPosition().x + controller.getScaleDiv2(),
|
|
con.getB().getPosition().y + controller.getScaleDiv2());
|
|
con.getB().getPosition().y + controller.getScaleDiv2());
|
|
-
|
|
|
|
- if(con.getCapacity() == -1){
|
|
|
|
|
|
+
|
|
|
|
+ if (con.getCapacity() == -1) {
|
|
maxCap = Character.toString('\u221e');
|
|
maxCap = Character.toString('\u221e');
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
maxCap = String.valueOf(con.getCapacity());
|
|
maxCap = String.valueOf(con.getCapacity());
|
|
}
|
|
}
|
|
- if(showedInformation[0]){
|
|
|
|
|
|
+ if (showedInformation[0]) {
|
|
g2.drawString(con.getFlow() + "/" + maxCap,
|
|
g2.drawString(con.getFlow() + "/" + maxCap,
|
|
- (con.getA().getPosition().x + con.getB().getPosition().x) / 2 + controller.getScaleDiv2(),
|
|
|
|
- (con.getA().getPosition().y + con.getB().getPosition().y) / 2 + controller.getScaleDiv2());
|
|
|
|
|
|
+ (con.getA().getPosition().x + con.getB().getPosition().x) / 2
|
|
|
|
+ + controller.getScaleDiv2(),
|
|
|
|
+ (con.getA().getPosition().y + con.getB().getPosition().y) / 2
|
|
|
|
+ + controller.getScaleDiv2());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -186,17 +195,17 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
edgeHighlight.getA().getPosition().y + controller.getScaleDiv2(),
|
|
edgeHighlight.getA().getPosition().y + controller.getScaleDiv2(),
|
|
edgeHighlight.getB().getPosition().x + controller.getScaleDiv2(),
|
|
edgeHighlight.getB().getPosition().x + controller.getScaleDiv2(),
|
|
edgeHighlight.getB().getPosition().y + controller.getScaleDiv2());
|
|
edgeHighlight.getB().getPosition().y + controller.getScaleDiv2());
|
|
-
|
|
|
|
- if(edgeHighlight.getCapacity() == -1){
|
|
|
|
|
|
+
|
|
|
|
+ if (edgeHighlight.getCapacity() == -1) {
|
|
maxCap = Character.toString('\u221e');
|
|
maxCap = Character.toString('\u221e');
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
maxCap = String.valueOf(edgeHighlight.getCapacity());
|
|
maxCap = String.valueOf(edgeHighlight.getCapacity());
|
|
}
|
|
}
|
|
- if(showedInformation[0]){
|
|
|
|
|
|
+ if (showedInformation[0]) {
|
|
g2.drawString(edgeHighlight.getFlow() + "/" + maxCap,
|
|
g2.drawString(edgeHighlight.getFlow() + "/" + maxCap,
|
|
(edgeHighlight.getA().getPosition().x + edgeHighlight.getB().getPosition().x) / 2
|
|
(edgeHighlight.getA().getPosition().x + edgeHighlight.getB().getPosition().x) / 2
|
|
- + controller.getScaleDiv2(),
|
|
|
|
- (edgeHighlight.getA().getPosition().y + edgeHighlight.getB().getPosition().y) / 2
|
|
|
|
|
|
+ + controller.getScaleDiv2(),
|
|
|
|
+ (edgeHighlight.getA().getPosition().y + edgeHighlight.getB().getPosition().y) / 2
|
|
+ controller.getScaleDiv2());
|
|
+ controller.getScaleDiv2());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -311,7 +320,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
if (tempCps == null) {
|
|
if (tempCps == null) {
|
|
edgeHighlight = mousePositionOnEdge(x, y);
|
|
edgeHighlight = mousePositionOnEdge(x, y);
|
|
controller.setSelecteEdge(edgeHighlight);
|
|
controller.setSelecteEdge(edgeHighlight);
|
|
- if (!e.isControlDown()) {
|
|
|
|
|
|
+ if (!e.isControlDown() && e.getButton() != MouseEvent.BUTTON3) {
|
|
model.getSelectedCpsObjects().clear();
|
|
model.getSelectedCpsObjects().clear();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -336,7 +345,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
drawDeleteEdge();
|
|
drawDeleteEdge();
|
|
}
|
|
}
|
|
|
|
|
|
- if (!e.isControlDown() && dragged == false && tempCps != null) {
|
|
|
|
|
|
+ if (!e.isControlDown() && e.getButton() != MouseEvent.BUTTON3 && dragged == false && tempCps != null) {
|
|
model.getSelectedCpsObjects().clear();
|
|
model.getSelectedCpsObjects().clear();
|
|
controller.addSelectedObject(tempCps);
|
|
controller.addSelectedObject(tempCps);
|
|
}
|
|
}
|
|
@@ -664,10 +673,9 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
showedInformation[0] = connection;
|
|
showedInformation[0] = connection;
|
|
showedInformation[1] = object;
|
|
showedInformation[1] = object;
|
|
}
|
|
}
|
|
-
|
|
|
|
- public boolean[] getShowedInformation(){
|
|
|
|
|
|
+
|
|
|
|
+ public boolean[] getShowedInformation() {
|
|
return showedInformation;
|
|
return showedInformation;
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+
|
|
}
|
|
}
|