|
@@ -54,7 +54,8 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
|
|
|
|
ArrayList<HolonElement> dataSelected = new ArrayList<HolonElement>();
|
|
|
ArrayList<CpsObject> TempSelected = new ArrayList<CpsObject>();
|
|
|
-
|
|
|
+
|
|
|
+ private boolean[] showedInformation = new boolean[3];
|
|
|
private boolean dragging = false; // for dragging
|
|
|
private boolean dragged = false; // if an object/objects was/were dragged
|
|
|
private boolean drawEdge = false; // for drawing edges
|
|
@@ -77,6 +78,8 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
|
this.controller = control;
|
|
|
this.model = model;
|
|
|
|
|
|
+ showedInformation[0] = true;
|
|
|
+ showedInformation[1] = false;
|
|
|
edgeCapacity = 10000;
|
|
|
popmenu.add(itemDelete);
|
|
|
itemDelete.setEnabled(false);
|
|
@@ -102,6 +105,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
|
*
|
|
|
*/
|
|
|
public void paintComponent(Graphics g) {
|
|
|
+ String maxCap;
|
|
|
super.paintComponent(g);
|
|
|
// Rendering
|
|
|
g2 = (Graphics2D) g;
|
|
@@ -120,9 +124,11 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
|
for (CpsEdge con : model.getEdgesOnCanvas()) {
|
|
|
if (con.getA().getID() != model.getSelectedObjectID() && con.getB().getID() != model.getSelectedObjectID()
|
|
|
&& con != edgeHighlight) {
|
|
|
- if (con.getFlow() <= con.getCapacity()) {
|
|
|
+ if (con.getFlow() <= con.getCapacity() || con.getCapacity() == -1) {
|
|
|
g2.setColor(Color.GREEN);
|
|
|
- g2.setStroke(new BasicStroke(Math.min((con.getFlow() / con.getCapacity() * 4), 4)));
|
|
|
+ if(con.getCapacity() != -1){
|
|
|
+ g2.setStroke(new BasicStroke(Math.min((con.getFlow() / con.getCapacity() * 4), 4)));
|
|
|
+ }
|
|
|
} else {
|
|
|
g2.setColor(Color.RED);
|
|
|
g2.setStroke(new BasicStroke(2));
|
|
@@ -131,9 +137,17 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
|
con.getA().getPosition().y + controller.getScaleDiv2(),
|
|
|
con.getB().getPosition().x + controller.getScaleDiv2(),
|
|
|
con.getB().getPosition().y + controller.getScaleDiv2());
|
|
|
- g2.drawString(con.getFlow() + "/" + con.getCapacity(),
|
|
|
- (con.getA().getPosition().x + con.getB().getPosition().x) / 2 + controller.getScaleDiv2(),
|
|
|
- (con.getA().getPosition().y + con.getB().getPosition().y) / 2 + controller.getScaleDiv2());
|
|
|
+
|
|
|
+ if(con.getCapacity() == -1){
|
|
|
+ maxCap = Character.toString('\u221e');
|
|
|
+ }else{
|
|
|
+ maxCap = String.valueOf(con.getCapacity());
|
|
|
+ }
|
|
|
+ if(showedInformation[0]){
|
|
|
+ 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());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -152,9 +166,17 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
|
con.getA().getPosition().y + controller.getScaleDiv2(),
|
|
|
con.getB().getPosition().x + controller.getScaleDiv2(),
|
|
|
con.getB().getPosition().y + controller.getScaleDiv2());
|
|
|
- g2.drawString(con.getFlow() + "/" + con.getCapacity(),
|
|
|
- (con.getA().getPosition().x + con.getB().getPosition().x) / 2 + controller.getScaleDiv2(),
|
|
|
- (con.getA().getPosition().y + con.getB().getPosition().y) / 2 + controller.getScaleDiv2());
|
|
|
+
|
|
|
+ if(con.getCapacity() == -1){
|
|
|
+ maxCap = Character.toString('\u221e');
|
|
|
+ }else{
|
|
|
+ maxCap = String.valueOf(con.getCapacity());
|
|
|
+ }
|
|
|
+ if(showedInformation[0]){
|
|
|
+ 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());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
} else if (edgeHighlight != null) {
|
|
@@ -164,11 +186,19 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
|
edgeHighlight.getA().getPosition().y + controller.getScaleDiv2(),
|
|
|
edgeHighlight.getB().getPosition().x + controller.getScaleDiv2(),
|
|
|
edgeHighlight.getB().getPosition().y + controller.getScaleDiv2());
|
|
|
- g2.drawString(edgeHighlight.getFlow() + "/" + edgeHighlight.getCapacity(),
|
|
|
- (edgeHighlight.getA().getPosition().x + edgeHighlight.getB().getPosition().x) / 2
|
|
|
+
|
|
|
+ if(edgeHighlight.getCapacity() == -1){
|
|
|
+ maxCap = Character.toString('\u221e');
|
|
|
+ }else{
|
|
|
+ maxCap = String.valueOf(edgeHighlight.getCapacity());
|
|
|
+ }
|
|
|
+ if(showedInformation[0]){
|
|
|
+ g2.drawString(edgeHighlight.getFlow() + "/" + maxCap,
|
|
|
+ (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());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// Objects
|
|
@@ -629,4 +659,15 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
|
public void setEdgeCapacity(float cap) {
|
|
|
edgeCapacity = cap;
|
|
|
}
|
|
|
+
|
|
|
+ public void setShowedInformation(boolean connection, boolean object) {
|
|
|
+ showedInformation[0] = connection;
|
|
|
+ showedInformation[1] = object;
|
|
|
+ }
|
|
|
+
|
|
|
+ public boolean[] getShowedInformation(){
|
|
|
+ return showedInformation;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|