|
@@ -6,7 +6,17 @@ import com.google.gson.JsonParseException;
|
|
|
|
|
|
import ui.controller.Control;
|
|
|
import ui.controller.UpdateController;
|
|
|
+import ui.model.Consumer;
|
|
|
+import ui.model.DecoratedCable;
|
|
|
+import ui.model.DecoratedGroupNode;
|
|
|
+import ui.model.DecoratedHolonObject;
|
|
|
+import ui.model.DecoratedSwitch;
|
|
|
import ui.model.Model;
|
|
|
+import ui.model.Passiv;
|
|
|
+import ui.model.Supplier;
|
|
|
+import ui.model.VisualRepresentationalState;
|
|
|
+import ui.model.DecoratedHolonObject.HolonObjectState;
|
|
|
+import ui.model.DecoratedSwitch.SwitchState;
|
|
|
|
|
|
import javax.swing.*;
|
|
|
|
|
@@ -16,9 +26,11 @@ import java.awt.event.MouseEvent;
|
|
|
import java.awt.event.MouseListener;
|
|
|
import java.awt.event.MouseMotionListener;
|
|
|
import java.awt.geom.Line2D;
|
|
|
+import java.awt.image.BufferedImage;
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.HashSet;
|
|
|
|
|
|
/**
|
|
|
* This Class is the Canvas. All Objects will be visualized here
|
|
@@ -35,7 +47,8 @@ public class UpperNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
|
int code;
|
|
|
private JLabel breadCrumb;
|
|
|
private int upperNodeID;
|
|
|
-
|
|
|
+ private Component parent;
|
|
|
+ private BufferedImage parentPreview;
|
|
|
/**
|
|
|
* Constructor.
|
|
|
*
|
|
@@ -43,7 +56,7 @@ public class UpperNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
|
* @param control the Controller
|
|
|
* @param unitGraph
|
|
|
*/
|
|
|
- UpperNodeCanvas(Model mod, Control control, UnitGraph unitGraph, CpsUpperNode UpperNode, String parentPath) {
|
|
|
+ UpperNodeCanvas(Model mod, Control control, UnitGraph unitGraph, CpsUpperNode UpperNode, String parentPath, Component parentComponent) {
|
|
|
toolTip = false;
|
|
|
|
|
|
this.controller = control;
|
|
@@ -53,6 +66,8 @@ public class UpperNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
|
this.code = UpperNode.hashCode();
|
|
|
this.path = parentPath + upperNode.getName();
|
|
|
this.breadCrumb = new JLabel(path);
|
|
|
+ this.parent = parentComponent;
|
|
|
+ parentPreview = this.getScaledImageOfComponent(parentComponent, 1f);
|
|
|
// this.add(breadCrumb);
|
|
|
scalediv20 = model.getScale() / 20;
|
|
|
|
|
@@ -138,7 +153,7 @@ public class UpperNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
|
animCps.get(i).getPosition().x = savePos.get(i).x;
|
|
|
animCps.get(i).getPosition().y = savePos.get(i).y;
|
|
|
}
|
|
|
- controller.addUpperNode("NodeOfNode", upperNode, model.getSelectedCpsObjects());
|
|
|
+ controller.addUpperNode("GroupNode", upperNode, model.getSelectedCpsObjects());
|
|
|
controller.calculateStateForCurrentTimeStep();
|
|
|
repaint();
|
|
|
}
|
|
@@ -328,14 +343,331 @@ public class UpperNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
|
this.addMouseMotionListener(this);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Paints all Components on the Canvas.
|
|
|
- *
|
|
|
- * @param g Graphics
|
|
|
- */
|
|
|
- public void paintComponent(Graphics g) {
|
|
|
- String maxCap = null;
|
|
|
- super.paintComponent(g);
|
|
|
+ /**
|
|
|
+ * Paints all Components on the Canvas.
|
|
|
+ *
|
|
|
+ * @param g
|
|
|
+ * Graphics
|
|
|
+ */
|
|
|
+
|
|
|
+ private Color getStateColor(HolonObjectState state) {
|
|
|
+ switch(state) {
|
|
|
+ case NOT_SUPPLIED:
|
|
|
+ return new Color(230, 120, 100);
|
|
|
+ case NO_ENERGY:
|
|
|
+ return Color.white;
|
|
|
+ case OVER_SUPPLIED:
|
|
|
+ return new Color(166, 78, 229);
|
|
|
+ case PARTIALLY_SUPPLIED:
|
|
|
+ return Color.yellow;
|
|
|
+ case PRODUCER:
|
|
|
+ return Color.lightGray;
|
|
|
+ case SUPPLIED:
|
|
|
+ return new Color(13, 175, 28);
|
|
|
+ default:
|
|
|
+ return Color.BLACK;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void paintCanvasObject(Graphics2D g, DecoratedHolonObject decoratedHolonObject){
|
|
|
+ Position pos = decoratedHolonObject.getModel().getPosition();
|
|
|
+ Color statecolor = getStateColor(decoratedHolonObject.getState());
|
|
|
+ g.setColor(statecolor);
|
|
|
+ g.fillRect(pos.x - controller.getScaleDiv2(), pos.y - controller.getScaleDiv2(), controller.getScale(), controller.getScale());
|
|
|
+ drawCanvasObject(g, decoratedHolonObject.getModel().getImage(), pos);
|
|
|
+ }
|
|
|
+ private void drawCanvasObjectString(Graphics2D g, Position posOfCanvasObject, float energy) {
|
|
|
+ g.setColor(Color.BLACK);
|
|
|
+ g.setFont(new Font("TimesNewRoman", Font.PLAIN, (int) (controller.getScale() / 4f) ));
|
|
|
+ g.drawString((energy > 0)? "+" + Float.toString(energy): Float.toString(energy), posOfCanvasObject.x - controller.getScaleDiv2(), posOfCanvasObject.y - controller.getScaleDiv2() - 1);
|
|
|
+ }
|
|
|
+ private void paintConsumer(Graphics2D g, Consumer con){
|
|
|
+ paintCanvasObject(g, con);
|
|
|
+ paintSupplyBar(g,con.getSupplyBarPercentage(), getStateColor(con.getState()), con.getModel().getPosition());
|
|
|
+ drawCanvasObjectString(g, con.getModel().getPosition(), -con.getEnergyNeededFromNetwork());
|
|
|
+ }
|
|
|
+ private void paintSupplier(Graphics2D g, Supplier sup){
|
|
|
+ paintCanvasObject(g, sup);
|
|
|
+ drawCanvasObjectString(g, sup.getModel().getPosition(), sup.getEnergyToSupplyNetwork());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void drawCanvasObject(Graphics2D g, String Image, Position pos) {
|
|
|
+ g.drawImage(Util.loadImage(Image, controller.getScale(), controller.getScale()) ,
|
|
|
+ pos.x - controller.getScaleDiv2(),
|
|
|
+ pos.y - controller.getScaleDiv2(),
|
|
|
+ controller.getScale(), controller.getScale() , null);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void paintCable(Graphics2D g, DecoratedCable cable, boolean isSelected)
|
|
|
+ {
|
|
|
+ Position start = cable.getModel().getA().getPosition();
|
|
|
+ Position end = cable.getModel().getB().getPosition();
|
|
|
+ float currentEnergy = cable.getFlowEnergy();
|
|
|
+ float capacity = cable.getModel().getCapacity();
|
|
|
+ switch(cable.getState()) {
|
|
|
+ case Burned:
|
|
|
+ g.setColor(Color.RED);
|
|
|
+ g.setStroke(new BasicStroke(2));
|
|
|
+ break;
|
|
|
+ case Working:
|
|
|
+ g.setColor(new Color(13, 175, 28));
|
|
|
+ g.setStroke(new BasicStroke((currentEnergy / capacity* 2f) + 1));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if(isSelected){
|
|
|
+ g.setColor(Color.lightGray);
|
|
|
+ }
|
|
|
+ g.drawLine(start.x, start.y, end.x, end.y);
|
|
|
+ Position middle = new Position((start.x + end.x) / 2, (start.y + end.y) / 2);
|
|
|
+ g.setFont(new Font("TimesRoman", Font.PLAIN, Math.max((int) (controller.getScale() / 3.5f), 10) ));
|
|
|
+ g.drawString(currentEnergy + "/" + capacity , middle.x, middle.y);
|
|
|
+ }
|
|
|
+ private void paintSwitch(Graphics2D g, DecoratedSwitch dSwitch)
|
|
|
+ {
|
|
|
+ drawCanvasObject(g, dSwitch.getState() == SwitchState.Open ? HolonSwitch.getSwitchOpenImage(): HolonSwitch.getSwitchClosedImage() , dSwitch.getModel().getPosition());
|
|
|
+ }
|
|
|
+ private void paintGroupNode(Graphics2D g, DecoratedGroupNode dGroupNode) {
|
|
|
+ Position pos = dGroupNode.getModel().getPosition();
|
|
|
+ g.setColor(Color.lightGray);
|
|
|
+ g.fillRect(pos.x - controller.getScaleDiv2(), pos.y - controller.getScaleDiv2(), controller.getScale(), controller.getScale());
|
|
|
+ drawCanvasObject(g, "/Images/upper_node.png" , pos);
|
|
|
+ }
|
|
|
+ private void paintExitCable(Graphics2D g, ExitCableV2 eCable) {
|
|
|
+ Position start = eCable.getStart().getPosition();
|
|
|
+ Position end = eCable.getFinish().getPosition();
|
|
|
+ float currentEnergy = eCable.getCable().getFlowEnergy();
|
|
|
+ float capacity = eCable.getCable().getModel().getCapacity();
|
|
|
+ switch(eCable.getCable().getState()) {
|
|
|
+ case Burned:
|
|
|
+ g.setColor(Color.RED);
|
|
|
+ g.setStroke(new BasicStroke(2));
|
|
|
+ break;
|
|
|
+ case Working:
|
|
|
+ g.setColor(new Color(13, 175, 28));
|
|
|
+ g.setStroke(new BasicStroke((currentEnergy / capacity* 2f) + 1));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ switch(eCable.getState()) {
|
|
|
+ case DOWN:
|
|
|
+ case DOWNDOWN:
|
|
|
+ g.drawLine(start.x, start.y, end.x, end.y);
|
|
|
+ Position middle = new Position((start.x + end.x) / 2, (start.y + end.y) / 2);
|
|
|
+ g.setFont(new Font("TimesRoman", Font.PLAIN, Math.max((int) (controller.getScale() / 3.5f), 10) ));
|
|
|
+ g.drawString(currentEnergy + "/" + capacity , middle.x, middle.y);
|
|
|
+ break;
|
|
|
+ case DOWNUP:
|
|
|
+ case UP:
|
|
|
+ Vector2d vStart = new Vector2d(start.x, start.y);
|
|
|
+ Vector2d vEnd = new Vector2d(end.x, end.y);
|
|
|
+ float stretchFactor = 4 * model.getScale();
|
|
|
+ stretchFactor = (stretchFactor > vStart.getDistance(vEnd))? vStart.getDistance(vEnd) : stretchFactor;
|
|
|
+ Vector2d vPosition = vStart.add((vEnd.subtract(vStart)).normalize().multiply(stretchFactor));
|
|
|
+ Position result = new Position(Math.round(vPosition.getX()),Math.round(vPosition.getY()));
|
|
|
+ g.drawLine(start.x, start.y, result.x, result.y);
|
|
|
+ Position middle1 = new Position((start.x +result.x) / 2, (start.y + +result.y) / 2);
|
|
|
+ g.setFont(new Font("TimesRoman", Font.PLAIN, Math.max((int) (controller.getScale() / 3.5f), 10) ));
|
|
|
+ g.drawString(currentEnergy + "/" + capacity , middle1.x, middle1.y);
|
|
|
+ drawCanvasObject(g, "/Images/arrowUp.png" , result);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ System.out.println("Error");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void paintSupplyBar(Graphics2D g, float percentage, Color color, Position pos) {
|
|
|
+ // +1, -2, -1 little Adjustment for pixel perfect alignment
|
|
|
+ int barWidth = (int) (controller.getScale());
|
|
|
+ int barHeight = (int) (controller.getScale() / 5);
|
|
|
+ g.setColor(Color.WHITE);
|
|
|
+ g.fillRect(pos.x - controller.getScaleDiv2(), pos.y + controller.getScaleDiv2() - 1, (int) barWidth, barHeight);
|
|
|
+ g.setColor(color);
|
|
|
+ g.fillRect(pos.x - controller.getScaleDiv2(), pos.y + controller.getScaleDiv2() - 1, (int) (barWidth * (percentage < 1 ? percentage : 1.0f) - 1), barHeight);
|
|
|
+ g.setColor(Color.BLACK);
|
|
|
+ g.setStroke(new BasicStroke(1));
|
|
|
+ g.drawRect(pos.x - controller.getScaleDiv2(), pos.y + controller.getScaleDiv2() - 1, barWidth - 1 , barHeight);
|
|
|
+ g.setFont(new Font("TimesNewRoman", Font.PLAIN, (int) (barHeight * 1.5) - 2));
|
|
|
+ String percentageString = (Math.round((percentage * 100))) + "%";
|
|
|
+ int stringWidth = (int) g.getFontMetrics().getStringBounds(percentageString, g).getWidth();
|
|
|
+ if(percentage > 1.0f) g.setColor(Color.WHITE); //Just to see better on purple
|
|
|
+ g.drawString(percentageString, pos.x + 1 - stringWidth / 2, pos.y + controller.getScaleDiv2() - 1+ barHeight);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //old code
|
|
|
+ void drawMarker(Graphics2D g) {
|
|
|
+ Color transparentGrey = new Color(128, 174, 247, 40);
|
|
|
+ if (sx > x && sy > y) {
|
|
|
+ g.drawRect(x, y, sx - x, sy - y);
|
|
|
+ g.setColor(transparentGrey);
|
|
|
+ g.fillRect(x, y, sx - x, sy - y);
|
|
|
+ } else if (sx < x && sy < y) {
|
|
|
+ g.drawRect(sx, sy, x - sx, y - sy);
|
|
|
+ g.setColor(transparentGrey);
|
|
|
+ g.fillRect(sx, sy, x - sx, y - sy);
|
|
|
+ } else if (sx >= x) {
|
|
|
+ g.drawRect(x, sy, sx - x, y - sy);
|
|
|
+ g.setColor(transparentGrey);
|
|
|
+ g.fillRect(x, sy, sx - x, y - sy);
|
|
|
+ } else if (sy >= y) {
|
|
|
+ g.drawRect(sx, y, x - sx, sy - y);
|
|
|
+ g.setColor(transparentGrey);
|
|
|
+ g.fillRect(sx, y, x - sx, sy - y);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private BufferedImage getScaledImageOfComponent(Component component, double scale) {
|
|
|
+ BufferedImage bi = new BufferedImage(
|
|
|
+ (int)(component.getWidth()*scale),
|
|
|
+ (int)(component.getHeight()*scale),
|
|
|
+ BufferedImage.TYPE_INT_RGB);
|
|
|
+ Graphics2D gNew = bi.createGraphics();
|
|
|
+ gNew.scale(scale, scale);
|
|
|
+ component.paint(gNew);
|
|
|
+ gNew.dispose();
|
|
|
+
|
|
|
+ return bi;
|
|
|
+ }
|
|
|
+ public void paintComponent(Graphics g) {
|
|
|
+ super.paintComponent(g);
|
|
|
+ Graphics2D g2d = (Graphics2D) g;
|
|
|
+ g2d.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING,
|
|
|
+ RenderingHints.VALUE_ANTIALIAS_ON));
|
|
|
+ //-->Old code
|
|
|
+ if (drawEdge) {
|
|
|
+ g2d.setColor(Color.BLACK);
|
|
|
+ g2d.setStroke(new BasicStroke(1));
|
|
|
+ g2d.drawLine(tempCps.getPosition().x, tempCps.getPosition().y, x, y);
|
|
|
+ }
|
|
|
+ //<--
|
|
|
+ //SelectedCable
|
|
|
+ HashSet<CpsEdge> selectedEdges = new HashSet<CpsEdge>();
|
|
|
+ for(AbstractCpsObject aCps: model.getSelectedCpsObjects()) {
|
|
|
+ for(CpsEdge edge: aCps.getConnections()) {
|
|
|
+ selectedEdges.add(edge);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(model.getSelectedEdge() != null) selectedEdges.add(model.getSelectedEdge());
|
|
|
+
|
|
|
+
|
|
|
+ DecoratedGroupNode actualGroupNode = controller.getSimManager().getActualVisualRepresentationalState().getCreatedGroupNodes().get(upperNode);
|
|
|
+ //VisualState Representation:
|
|
|
+ for(ExitCableV2 cable : actualGroupNode.getExitCableList()) {
|
|
|
+ paintExitCable(g2d, cable);
|
|
|
+ }
|
|
|
+ for(DecoratedCable cable : actualGroupNode.getInternCableList()) {
|
|
|
+ paintCable(g2d, cable, selectedEdges.contains(cable.getModel()));
|
|
|
+ }
|
|
|
+ //ExitCable:
|
|
|
+// for(ExitCable exitCable : actualGroupNode.getExitCableList()) {
|
|
|
+// Position start = exitCable.getInsideObject().getPosition();
|
|
|
+// Position end = exitCable.getOusideObject().getPosition();
|
|
|
+// Vector2d vStart = new Vector2d(start.x, start.y);
|
|
|
+// Vector2d vEnd = new Vector2d(end.x, end.y);
|
|
|
+// float stretchFactor = 4 * model.getScale();
|
|
|
+// stretchFactor = (stretchFactor > vStart.getDistance(vEnd))? vStart.getDistance(vEnd) : stretchFactor;
|
|
|
+// Vector2d vPosition = vStart.add((vEnd.subtract(vStart)).normalize().multiply(stretchFactor));// vStart + (direction to end) * magnitude;
|
|
|
+// float currentEnergy = exitCable.getCable().getFlowEnergy();
|
|
|
+// float capacity = exitCable.getModel().getCapacity();
|
|
|
+// switch(exitCable.getCable().getState()) {
|
|
|
+// case Burned:
|
|
|
+// g2d.setColor(Color.RED);
|
|
|
+// g2d.setStroke(new BasicStroke(2));
|
|
|
+// break;
|
|
|
+// case Working:
|
|
|
+// g2d.setColor(new Color(13, 175, 28));
|
|
|
+// g2d.setStroke(new BasicStroke((currentEnergy / capacity* 2f) + 1));
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// Position result = new Position(Math.round(vPosition.getX()),Math.round(vPosition.getY()));
|
|
|
+// g2d.drawLine(start.x, start.y, result.x, result.y);
|
|
|
+// Position middle = new Position((start.x +result.x) / 2, (start.y + +result.y) / 2);
|
|
|
+// g2d.setFont(new Font("TimesRoman", Font.PLAIN, Math.max((int) (controller.getScale() / 3.5f), 10) ));
|
|
|
+// g2d.drawString(currentEnergy + "/" + capacity , middle.x, middle.y);
|
|
|
+// drawCanvasObject(g2d, "/Images/arrowUp.png" , result);
|
|
|
+ //Get Window:
|
|
|
+// int scale = controller.getScale() * 2 ;
|
|
|
+// g2d.drawRect(result.x - scale/2 - 1 , result.y - scale/2 -1 ,scale + 2,scale + 2);
|
|
|
+// Position groupNode = exitCable.getCpsUpperNode().getPosition();
|
|
|
+// Position outSideNode = exitCable.getOusideObject().getPosition();;
|
|
|
+// int smallX, smallY, bigX, bigY;
|
|
|
+// smallX = Math.min(groupNode.x, outSideNode.x) - controller.getScaleDiv2() ;
|
|
|
+// smallY = Math.min(groupNode.y, outSideNode.y) - controller.getScaleDiv2();
|
|
|
+// bigX = Math.max(groupNode.x, outSideNode.x)+ controller.getScaleDiv2();
|
|
|
+// bigY = Math.max(groupNode.y, outSideNode.y)+ controller.getScaleDiv2();
|
|
|
+// smallX = groupNode.x - controller.getScaleDiv2() * 3;
|
|
|
+// smallY = groupNode.y - controller.getScaleDiv2() * 3;
|
|
|
+// bigX = groupNode.x + controller.getScaleDiv2() * 3;
|
|
|
+// bigY = groupNode.y + controller.getScaleDiv2() * 3;
|
|
|
+// smallX= (smallX < 0) ? 0: smallX;
|
|
|
+// smallY = (smallY < 0) ? 0: smallY;
|
|
|
+// bigX = (bigX < parentPreview.getWidth()) ? bigX : parentPreview.getWidth();
|
|
|
+// bigY = (bigY < parentPreview.getHeight()) ? bigY : parentPreview.getHeight();
|
|
|
+// float aspectratio = ((float)bigX-smallX) / ((float)bigY-smallY);
|
|
|
+// g2d.drawImage(parentPreview.getSubimage(smallX, smallY,bigX-smallX,bigY-smallY).getScaledInstance(Math.round(((float)scale) * aspectratio), Math.round(((float)scale) / aspectratio), Image.SCALE_SMOOTH),
|
|
|
+// result.x - scale/2,
|
|
|
+// result.y - scale/2,
|
|
|
+// scale, scale , null);
|
|
|
+// }
|
|
|
+
|
|
|
+ for(DecoratedGroupNode dGroupNode : actualGroupNode.getGroupNodeList()) {
|
|
|
+ paintGroupNode(g2d, dGroupNode);
|
|
|
+ }
|
|
|
+ for(Consumer con: actualGroupNode.getConsumerList()) {
|
|
|
+ paintConsumer(g2d, con);
|
|
|
+ }
|
|
|
+ for(Supplier sup: actualGroupNode.getSupplierList()) {
|
|
|
+ paintSupplier(g2d, sup);
|
|
|
+ }
|
|
|
+ for(Passiv pas: actualGroupNode.getPassivList()) {
|
|
|
+ paintCanvasObject(g2d, pas);
|
|
|
+ }
|
|
|
+ for(DecoratedSwitch dSwitch : actualGroupNode.getSwitchList()) {
|
|
|
+ paintSwitch(g2d, dSwitch);
|
|
|
+ }
|
|
|
+ for(CpsNode node : actualGroupNode.getNodeList()) {
|
|
|
+ drawCanvasObject(g2d, "/Images/node.png" , node.getPosition());
|
|
|
+ }
|
|
|
+
|
|
|
+ //-->oldCode
|
|
|
+ if (doMark) {
|
|
|
+ g2d.setColor(Color.BLACK);
|
|
|
+ g2d.setStroke(new BasicStroke(0));
|
|
|
+ drawMarker(g2d);
|
|
|
+ }
|
|
|
+ //Test Selection
|
|
|
+ //Objects:
|
|
|
+ g2d.setColor(Color.BLUE);
|
|
|
+ g2d.setStroke(new BasicStroke(1));
|
|
|
+ Color transparentGrey = new Color(128, 174, 247, 40);
|
|
|
+ for(AbstractCpsObject aCps: model.getSelectedCpsObjects()) {
|
|
|
+ if(aCps instanceof CpsNode) {
|
|
|
+ Position pos = aCps.getPosition();
|
|
|
+ g2d.setColor(transparentGrey);
|
|
|
+ g2d.fillOval(pos.x - (int) (controller.getScaleDiv2()), pos.y - (int) (controller.getScaleDiv2()), controller.getScale(), controller.getScale());
|
|
|
+ g2d.setColor(Color.LIGHT_GRAY);
|
|
|
+ g2d.setStroke(new BasicStroke(2));
|
|
|
+ g2d.drawOval(pos.x - (int) (controller.getScaleDiv2()), pos.y - (int) (controller.getScaleDiv2()), controller.getScale(), controller.getScale());
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Position pos = aCps.getPosition();
|
|
|
+ g2d.setColor(transparentGrey);
|
|
|
+ g2d.fillRect(pos.x - (int) (controller.getScaleDiv2()* 1.5f), pos.y - (int) (controller.getScaleDiv2()* 1.5f), (int) (controller.getScale()* 1.5f) , (int) (controller.getScale()* 1.5f));
|
|
|
+ g2d.setColor(Color.LIGHT_GRAY);
|
|
|
+ g2d.setStroke(new BasicStroke(2));
|
|
|
+ g2d.drawRect(pos.x - (int) (controller.getScaleDiv2()* 1.5f), pos.y - (int) (controller.getScaleDiv2()* 1.5f), (int) (controller.getScale()* 1.5f) , (int) (controller.getScale()* 1.5f));
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //maybeReplace:
|
|
|
+ if(mayBeReplaced != null){
|
|
|
+ g2d.setColor(Color.RED);
|
|
|
+ Position pos = mayBeReplaced.getPosition();
|
|
|
+ g.drawImage(Util.loadImage("/Images/replace.png") ,
|
|
|
+ pos.x + controller.getScaleDiv2(),
|
|
|
+ pos.y - controller.getScale(),
|
|
|
+ controller.getScaleDiv2(), controller.getScaleDiv2(), null);
|
|
|
+ }
|
|
|
+ //<-- OldCode
|
|
|
+ }
|
|
|
+
|
|
|
// ((JScrollPane) this.getParent().getParent()).setColumnHeaderView(breadCrumb);
|
|
|
// // Rendering
|
|
|
// g2 = (Graphics2D) g;
|
|
@@ -580,8 +912,7 @@ public class UpperNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
|
//
|
|
|
// // Tooltip
|
|
|
// showTooltip(g);
|
|
|
- System.out.println("PaintCanvas");
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public void mouseClicked(MouseEvent e) {
|
|
@@ -984,12 +1315,14 @@ public class UpperNodeCanvas extends AbstractCanvas implements MouseListener, Mo
|
|
|
deleteNode = true;
|
|
|
}
|
|
|
} else {
|
|
|
- e = new CpsEdge(cps, tempCps, model.getMaxCapacity());
|
|
|
- if (outsideCon) {
|
|
|
- controller.connectNodes(e, upperNode);
|
|
|
- } else {
|
|
|
- controller.addEdgeUpperNode(e, upperNode);
|
|
|
- }
|
|
|
+ if(!(cps instanceof CpsUpperNode || tempCps instanceof CpsUpperNode)) {
|
|
|
+ e = new CpsEdge(cps, tempCps, model.getMaxCapacity());
|
|
|
+ if (outsideCon) {
|
|
|
+ controller.connectNodes(e, upperNode);
|
|
|
+ } else {
|
|
|
+ controller.addEdgeUpperNode(e, upperNode);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|