|
@@ -25,6 +25,7 @@ import javax.swing.JMenuItem;
|
|
import javax.swing.JPanel;
|
|
import javax.swing.JPanel;
|
|
import javax.swing.JPopupMenu;
|
|
import javax.swing.JPopupMenu;
|
|
import javax.swing.JScrollPane;
|
|
import javax.swing.JScrollPane;
|
|
|
|
+import javax.swing.JTabbedPane;
|
|
import javax.swing.JToolTip;
|
|
import javax.swing.JToolTip;
|
|
|
|
|
|
import classes.CpsEdge;
|
|
import classes.CpsEdge;
|
|
@@ -34,6 +35,7 @@ import classes.AbstractCpsObject;
|
|
import classes.HolonElement;
|
|
import classes.HolonElement;
|
|
import classes.HolonObject;
|
|
import classes.HolonObject;
|
|
import classes.HolonSwitch;
|
|
import classes.HolonSwitch;
|
|
|
|
+import classes.Position;
|
|
import classes.SubNet;
|
|
import classes.SubNet;
|
|
import ui.controller.Control;
|
|
import ui.controller.Control;
|
|
import ui.model.Model;
|
|
import ui.model.Model;
|
|
@@ -56,6 +58,7 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
private int cx, cy;
|
|
private int cx, cy;
|
|
private int sx, sy; // Mark Coords
|
|
private int sx, sy; // Mark Coords
|
|
private float scalediv20;
|
|
private float scalediv20;
|
|
|
|
+ private int borderPos = 0; // Border Position
|
|
|
|
|
|
// Path
|
|
// Path
|
|
public String path;
|
|
public String path;
|
|
@@ -86,13 +89,12 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
public JMenuItem itemUngroup = new JMenuItem("Ungroup");
|
|
public JMenuItem itemUngroup = new JMenuItem("Ungroup");
|
|
public JMenuItem itemTrack = new JMenuItem("Track");
|
|
public JMenuItem itemTrack = new JMenuItem("Track");
|
|
public JMenuItem itemUntrack = new JMenuItem("Untrack");
|
|
public JMenuItem itemUntrack = new JMenuItem("Untrack");
|
|
- private JToolTip objectTT = new JToolTip();
|
|
|
|
|
|
+ // private JToolTip objectTT = new JToolTip();
|
|
|
|
|
|
private Point mousePosition = new Point(); // Mouse Position when
|
|
private Point mousePosition = new Point(); // Mouse Position when
|
|
// rightclicked
|
|
// rightclicked
|
|
|
|
|
|
// contains the value of the Capacity for new created Edges
|
|
// contains the value of the Capacity for new created Edges
|
|
- private float edgeCapacity;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* Constructor.
|
|
* Constructor.
|
|
@@ -103,7 +105,7 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
* the Controller
|
|
* the Controller
|
|
*/
|
|
*/
|
|
public UpperNodeCanvas(Model mod, Control control, CpsUpperNode UpperNode, String parentPath) {
|
|
public UpperNodeCanvas(Model mod, Control control, CpsUpperNode UpperNode, String parentPath) {
|
|
- this.add(objectTT);
|
|
|
|
|
|
+ // this.add(objectTT);
|
|
this.controller = control;
|
|
this.controller = control;
|
|
this.model = mod;
|
|
this.model = mod;
|
|
this.upperNode = UpperNode;
|
|
this.upperNode = UpperNode;
|
|
@@ -112,9 +114,15 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
// this.add(breadCrumb);
|
|
// this.add(breadCrumb);
|
|
scalediv20 = model.getScale() / 20;
|
|
scalediv20 = model.getScale() / 20;
|
|
|
|
|
|
|
|
+ for (AbstractCpsObject cps : upperNode.getNodes()) {
|
|
|
|
+ if (cps.getPosition().x < model.getScaleDiv2() + borderPos + 5) {
|
|
|
|
+ cps.setPosition(new Position(borderPos + 5, cps.getPosition().y));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
showedInformation[0] = true;
|
|
showedInformation[0] = true;
|
|
showedInformation[1] = true;
|
|
showedInformation[1] = true;
|
|
- edgeCapacity = 10000;
|
|
|
|
|
|
+ control.setMaxCapacity(10000);
|
|
|
|
|
|
popmenu.add(itemCut);
|
|
popmenu.add(itemCut);
|
|
popmenu.add(itemCopy);
|
|
popmenu.add(itemCopy);
|
|
@@ -138,7 +146,7 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
itemGroup.addActionListener(new ActionListener() {
|
|
itemGroup.addActionListener(new ActionListener() {
|
|
@Override
|
|
@Override
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
- controller.addUpperNode("NodeOfNode", UpperNode);
|
|
|
|
|
|
+ controller.addUpperNode("NodeOfNode", upperNode);
|
|
repaint();
|
|
repaint();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -146,7 +154,7 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
itemUngroup.addActionListener(new ActionListener() {
|
|
itemUngroup.addActionListener(new ActionListener() {
|
|
@Override
|
|
@Override
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
- controller.delUpperNode((CpsUpperNode) tempCps, UpperNode);
|
|
|
|
|
|
+ controller.delUpperNode((CpsUpperNode) tempCps, upperNode);
|
|
repaint();
|
|
repaint();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -213,7 +221,18 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
// Remove the selected Object objects
|
|
// Remove the selected Object objects
|
|
for (AbstractCpsObject cps : model.getSelectedCpsObjects()) {
|
|
for (AbstractCpsObject cps : model.getSelectedCpsObjects()) {
|
|
- controller.delObjUpperNode(cps, UpperNode);
|
|
|
|
|
|
+ controller.delObjUpperNode(cps, upperNode);
|
|
|
|
+ // Remove UpperNodeTab if UpperNode deleted
|
|
|
|
+ if (cps instanceof CpsUpperNode) {
|
|
|
|
+ JTabbedPane tabbedPane = (JTabbedPane) getParent().getParent().getParent();
|
|
|
|
+ for (int i = 2; i < tabbedPane.getTabCount(); i++) {
|
|
|
|
+ if (((UpperNodeCanvas) ((JScrollPane) tabbedPane.getComponentAt(i)).getViewport()
|
|
|
|
+ .getComponent(0)).upperNode.getID() == cps.getID()) {
|
|
|
|
+ tabbedPane.remove(i);
|
|
|
|
+ i = tabbedPane.getTabCount();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
model.getSelectedCpsObjects().clear();
|
|
model.getSelectedCpsObjects().clear();
|
|
tempCps = null;
|
|
tempCps = null;
|
|
@@ -266,6 +285,13 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
|
RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
|
g2.setRenderingHints(rh);
|
|
g2.setRenderingHints(rh);
|
|
|
|
|
|
|
|
+ // Left Border
|
|
|
|
+ borderPos = (int) (model.getScale() + scalediv20 + scalediv20 + 10);
|
|
|
|
+ g2.setColor(new Color(230, 230, 230));
|
|
|
|
+ g2.fillRect(0, 0, borderPos, this.getHeight());
|
|
|
|
+ g2.setColor(Color.BLACK);
|
|
|
|
+ g2.drawLine(0, 0, this.getWidth(), 0);
|
|
|
|
+
|
|
// Test SubNet Coloring
|
|
// Test SubNet Coloring
|
|
int i = 0;
|
|
int i = 0;
|
|
for (SubNet s : controller.getSimManager().getSubNets()) {
|
|
for (SubNet s : controller.getSimManager().getSubNets()) {
|
|
@@ -378,7 +404,7 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- // Objects
|
|
|
|
|
|
+ // Objects in upper node
|
|
for (AbstractCpsObject cps : upperNode.getNodes()) {
|
|
for (AbstractCpsObject cps : upperNode.getNodes()) {
|
|
// Border Highlighting
|
|
// Border Highlighting
|
|
g2.setColor(cps.getBorderColor());
|
|
g2.setColor(cps.getBorderColor());
|
|
@@ -437,10 +463,89 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
null);
|
|
null);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Objects connected to upperNode
|
|
|
|
+ int count = 0;
|
|
|
|
+ for (CpsEdge e : upperNode.getConnections()) {
|
|
|
|
+ AbstractCpsObject cps;
|
|
|
|
+ if (e.getA().equals(this.upperNode)) {
|
|
|
|
+ cps = e.getB();
|
|
|
|
+ } else {
|
|
|
|
+ cps = e.getA();
|
|
|
|
+ }
|
|
|
|
+ // Show and Highlight
|
|
|
|
+ if (model.getSelectedCpsObjects().contains(cps)) {
|
|
|
|
+ for (CpsEdge ed : cps.getConnections()) {
|
|
|
|
+ AbstractCpsObject obj = null;
|
|
|
|
+ if (upperNode.getNodes().contains(ed.getA())) {
|
|
|
|
+ obj = ed.getA();
|
|
|
|
+ } else if (upperNode.getNodes().contains(ed.getB())) {
|
|
|
|
+ obj = ed.getB();
|
|
|
|
+ }
|
|
|
|
+ if (obj != null) {
|
|
|
|
+ g2.setColor(Color.BLUE);
|
|
|
|
+ g2.drawLine(obj.getPosition().x + model.getScaleDiv2(),
|
|
|
|
+ obj.getPosition().y + model.getScaleDiv2(), (borderPos >> 1),
|
|
|
|
+ (int) (scalediv20 + 5 + (model.getScale() + scalediv20 + 10) * count)
|
|
|
|
+ + model.getScaleDiv2());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Border Highlighting
|
|
|
|
+ g2.setColor(cps.getBorderColor());
|
|
|
|
+ if (g2.getColor() != Color.WHITE) {
|
|
|
|
+ g2.fillRect((int) ((borderPos >> 1) - model.getScaleDiv2() - scalediv20) - 3,
|
|
|
|
+ (int) (scalediv20 + 5 + (model.getScale() + scalediv20 + 10) * count - scalediv20) - 3,
|
|
|
|
+ (int) (controller.getScale() + ((scalediv20 + 3) * 2)),
|
|
|
|
+ (int) (controller.getScale() + ((scalediv20 + 3) * 2)));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // node image
|
|
|
|
+ if (cps instanceof CpsNode && (cps == tempCps || model.getSelectedCpsObject() == cps
|
|
|
|
+ || model.getSelectedCpsObjects().contains(cps) || tempSelected.contains(cps))) {
|
|
|
|
+ img = new ImageIcon(this.getClass().getResource("/Images/node_selected.png")).getImage();
|
|
|
|
+ } else {
|
|
|
|
+ if (cps instanceof HolonSwitch) {
|
|
|
|
+ if (((HolonSwitch) cps).getActiveAt()[model.getCurIteration()]) {
|
|
|
|
+ ((HolonSwitch) cps).setAutoState(true);
|
|
|
|
+ } else {
|
|
|
|
+ ((HolonSwitch) cps).setAutoState(false);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Highlighting
|
|
|
|
+ if ((cps == tempCps && model.getSelectedCpsObjects().size() == 0 && tempSelected.size() == 0)
|
|
|
|
+ || model.getSelectedCpsObjects().contains(cps) || tempSelected.contains(cps)) {
|
|
|
|
+ g2.setColor(Color.BLUE);
|
|
|
|
+ g2.fillRect((int) ((borderPos >> 1) - model.getScaleDiv2() - scalediv20),
|
|
|
|
+ (int) (scalediv20 + 5 + (model.getScale() + scalediv20 + 10) * count - scalediv20),
|
|
|
|
+ (int) (controller.getScale() + (scalediv20 * 2)),
|
|
|
|
+ (int) (controller.getScale() + (scalediv20 * 2)));
|
|
|
|
+ } else if (cps instanceof HolonObject) {
|
|
|
|
+ g2.setColor(((HolonObject) cps).getColor());
|
|
|
|
+
|
|
|
|
+ g2.fillRect((int) ((borderPos >> 1) - model.getScaleDiv2() - scalediv20),
|
|
|
|
+ (int) (scalediv20 + 5 + (model.getScale() + scalediv20 + 10) * count - scalediv20),
|
|
|
|
+ (int) (controller.getScale() + (scalediv20 * 2)),
|
|
|
|
+ (int) (controller.getScale() + (scalediv20 * 2)));
|
|
|
|
+ }
|
|
|
|
+ // draw image
|
|
|
|
+ File checkPath = new File(cps.getImage());
|
|
|
|
+ if (checkPath.exists()) {
|
|
|
|
+ img = new ImageIcon(cps.getImage()).getImage();
|
|
|
|
+ } else {
|
|
|
|
+ img = new ImageIcon(this.getClass().getResource(cps.getImage())).getImage();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ g2.drawImage(img, (borderPos >> 1) - model.getScaleDiv2(),
|
|
|
|
+ (int) (scalediv20 + 5 + (model.getScale() + scalediv20 + 10) * count), controller.getScale(),
|
|
|
|
+ controller.getScale(), null);
|
|
|
|
+ count++;
|
|
|
|
+ }
|
|
|
|
+
|
|
// Dragg Highlighting
|
|
// Dragg Highlighting
|
|
|
|
+ g2.setStroke(new BasicStroke(1));
|
|
if (doMark) {
|
|
if (doMark) {
|
|
g2.setColor(Color.BLACK);
|
|
g2.setColor(Color.BLACK);
|
|
- g2.setStroke(new BasicStroke(1));
|
|
|
|
if (sx > x && sy > y) {
|
|
if (sx > x && sy > y) {
|
|
g2.drawRect(x, y, sx - x, sy - y);
|
|
g2.drawRect(x, y, sx - x, sy - y);
|
|
} else if (sx < x && sy < y) {
|
|
} else if (sx < x && sy < y) {
|
|
@@ -451,6 +556,10 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
g2.drawRect(sx, y, x - sx, sy - y);
|
|
g2.drawRect(sx, y, x - sx, sy - y);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // Border Line
|
|
|
|
+ g2.setColor(Color.BLACK);
|
|
|
|
+ g2.drawLine(borderPos, 0, borderPos, this.getHeight());
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -473,31 +582,64 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
edgeHighlight = null;
|
|
edgeHighlight = null;
|
|
controller.setSelecteEdge(null);
|
|
controller.setSelecteEdge(null);
|
|
// Object Selection
|
|
// Object Selection
|
|
- for (AbstractCpsObject cps : upperNode.getNodes()) {
|
|
|
|
- cx = cps.getPosition().x;
|
|
|
|
- cy = cps.getPosition().y;
|
|
|
|
- if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
|
|
|
|
- tempCps = cps;
|
|
|
|
- controller.addTextToConsole("Selected: ", Color.BLACK, 12, false, false, false);
|
|
|
|
- controller.addTextToConsole("" + cps.getName(), Color.BLUE, 12, true, false, false);
|
|
|
|
- controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
|
|
|
|
- controller.addTextToConsole("" + cps.getID(), Color.RED, 12, true, false, true);
|
|
|
|
- dragging = true;
|
|
|
|
- controller.setSelectedObjectID(tempCps.getID());
|
|
|
|
- // If drawing an Edge (CTRL down)
|
|
|
|
- if (tempCps.getClass() == HolonObject.class) {
|
|
|
|
- HolonObject tempObj = ((HolonObject) tempCps);
|
|
|
|
- dataSelected = tempObj.getElements();
|
|
|
|
|
|
+ if (e.getX() > borderPos) {
|
|
|
|
+ for (AbstractCpsObject cps : upperNode.getNodes()) {
|
|
|
|
+ cx = cps.getPosition().x;
|
|
|
|
+ cy = cps.getPosition().y;
|
|
|
|
+ if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
|
|
|
|
+ tempCps = cps;
|
|
|
|
+ controller.addTextToConsole("Selected: ", Color.BLACK, 12, false, false, false);
|
|
|
|
+ controller.addTextToConsole("" + cps.getName(), Color.BLUE, 12, true, false, false);
|
|
|
|
+ controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
|
|
|
|
+ controller.addTextToConsole("" + cps.getID(), Color.RED, 12, true, false, true);
|
|
|
|
+ dragging = true;
|
|
|
|
+ controller.setSelectedObjectID(tempCps.getID());
|
|
|
|
+ // If drawing an Edge (CTRL down)
|
|
|
|
+ if (tempCps.getClass() == HolonObject.class) {
|
|
|
|
+ HolonObject tempObj = ((HolonObject) tempCps);
|
|
|
|
+ dataSelected = tempObj.getElements();
|
|
|
|
+ }
|
|
|
|
+ if (e.isShiftDown()) {
|
|
|
|
+ drawEdge = true;
|
|
|
|
+ dragging = false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ int count = 0;
|
|
|
|
+ for (CpsEdge ed : upperNode.getConnections()) {
|
|
|
|
+ AbstractCpsObject cps;
|
|
|
|
+ if (ed.getA().equals(this.upperNode)) {
|
|
|
|
+ cps = ed.getB();
|
|
|
|
+ } else {
|
|
|
|
+ cps = ed.getA();
|
|
}
|
|
}
|
|
- if (e.isShiftDown()) {
|
|
|
|
- drawEdge = true;
|
|
|
|
- dragging = false;
|
|
|
|
|
|
+ if (x - controller.getScale() <= ((borderPos >> 1) - model.getScaleDiv2())
|
|
|
|
+ && y - controller.getScale() <= (scalediv20 + 5 + (model.getScale() + scalediv20 + 10) * count)
|
|
|
|
+ && x >= (borderPos >> 1) - model.getScaleDiv2()
|
|
|
|
+ && y >= (scalediv20 + 5 + (model.getScale() + scalediv20 + 10) * count)) {
|
|
|
|
+ tempCps = cps;
|
|
|
|
+ controller.addTextToConsole("Selected: ", Color.BLACK, 12, false, false, false);
|
|
|
|
+ controller.addTextToConsole("" + cps.getName(), Color.BLUE, 12, true, false, false);
|
|
|
|
+ controller.addTextToConsole(", ID:", Color.BLACK, 12, false, false, false);
|
|
|
|
+ controller.addTextToConsole("" + cps.getID(), Color.RED, 12, true, false, true);
|
|
|
|
+ controller.setSelectedObjectID(tempCps.getID());
|
|
|
|
+ // If drawing an Edge (CTRL down)
|
|
|
|
+ if (tempCps.getClass() == HolonObject.class) {
|
|
|
|
+ HolonObject tempObj = ((HolonObject) tempCps);
|
|
|
|
+ dataSelected = tempObj.getElements();
|
|
|
|
+ }
|
|
|
|
+ if (e.isShiftDown()) {
|
|
|
|
+ drawEdge = true;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ count++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
// Selection of CpsObject
|
|
// Selection of CpsObject
|
|
model.setSelectedCpsObject(tempCps);
|
|
model.setSelectedCpsObject(tempCps);
|
|
-
|
|
|
|
|
|
+
|
|
// Edge Selection
|
|
// Edge Selection
|
|
if (tempCps == null) {
|
|
if (tempCps == null) {
|
|
edgeHighlight = mousePositionOnEdge(x, y);
|
|
edgeHighlight = mousePositionOnEdge(x, y);
|
|
@@ -610,48 +752,55 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
}
|
|
}
|
|
if (dragging) {
|
|
if (dragging) {
|
|
try {
|
|
try {
|
|
- dragged = true;
|
|
|
|
- float xDist, yDist; // Distance
|
|
|
|
-
|
|
|
|
- x = e.getX() - controller.getScaleDiv2();
|
|
|
|
- y = e.getY() - controller.getScaleDiv2();
|
|
|
|
-
|
|
|
|
- // Make sure its in bounds
|
|
|
|
- if (e.getX() < controller.getScaleDiv2())
|
|
|
|
- x = 0;
|
|
|
|
- else if (e.getX() > this.getWidth() - controller.getScaleDiv2())
|
|
|
|
- x = this.getWidth() - controller.getScale();
|
|
|
|
- if (e.getY() < controller.getScaleDiv2())
|
|
|
|
- y = 0;
|
|
|
|
- else if (e.getY() > this.getHeight() - controller.getScaleDiv2())
|
|
|
|
- y = this.getHeight() - controller.getScale();
|
|
|
|
-
|
|
|
|
- // Distance
|
|
|
|
- xDist = x - tempCps.getPosition().x;
|
|
|
|
- yDist = y - tempCps.getPosition().y;
|
|
|
|
-
|
|
|
|
- tempCps.setPosition(x, y); // Drag Position
|
|
|
|
- // TipText Position and name
|
|
|
|
- objectTT.setTipText(tempCps.getName() + ", " + tempCps.getID());
|
|
|
|
- objectTT.setLocation(x, y + controller.getScale());
|
|
|
|
-
|
|
|
|
- // All Selected Objects
|
|
|
|
- for (AbstractCpsObject cps : model.getSelectedCpsObjects()) {
|
|
|
|
- if (cps != tempCps) {
|
|
|
|
- x = (int) (cps.getPosition().x + xDist);
|
|
|
|
- y = (int) (cps.getPosition().y + yDist);
|
|
|
|
-
|
|
|
|
- // Make sure its in bounds
|
|
|
|
- if (x <= 0)
|
|
|
|
- x = 0;
|
|
|
|
- else if (x > this.getWidth() - controller.getScale())
|
|
|
|
- x = this.getWidth() - controller.getScale();
|
|
|
|
- if (y <= 0)
|
|
|
|
- y = 0;
|
|
|
|
- else if (y > this.getHeight() - controller.getScale())
|
|
|
|
- y = this.getHeight() - controller.getScale();
|
|
|
|
-
|
|
|
|
- cps.setPosition(x, y);
|
|
|
|
|
|
+ if (upperNode.getNodes().contains(tempCps)) {
|
|
|
|
+ dragged = true;
|
|
|
|
+ float xDist, yDist; // Distance
|
|
|
|
+
|
|
|
|
+ x = e.getX() - controller.getScaleDiv2();
|
|
|
|
+ y = e.getY() - controller.getScaleDiv2();
|
|
|
|
+
|
|
|
|
+ // tempCps in the upperNode? if not its a connected Object
|
|
|
|
+ // from
|
|
|
|
+ // outside
|
|
|
|
+
|
|
|
|
+ // Make sure its in bounds
|
|
|
|
+ if (e.getX() < controller.getScaleDiv2() + borderPos + 5)
|
|
|
|
+ x = borderPos + 5;
|
|
|
|
+ else if (e.getX() > this.getWidth() - controller.getScaleDiv2())
|
|
|
|
+ x = this.getWidth() - controller.getScale();
|
|
|
|
+ if (e.getY() < controller.getScaleDiv2())
|
|
|
|
+ y = 0;
|
|
|
|
+ else if (e.getY() > this.getHeight() - controller.getScaleDiv2())
|
|
|
|
+ y = this.getHeight() - controller.getScale();
|
|
|
|
+
|
|
|
|
+ // Distance
|
|
|
|
+ xDist = x - tempCps.getPosition().x;
|
|
|
|
+ yDist = y - tempCps.getPosition().y;
|
|
|
|
+
|
|
|
|
+ tempCps.setPosition(x, y); // Drag Position
|
|
|
|
+ // TipText Position and name
|
|
|
|
+ // objectTT.setTipText(tempCps.getName() + ", " +
|
|
|
|
+ // tempCps.getID());
|
|
|
|
+ // objectTT.setLocation(x, y + controller.getScale());
|
|
|
|
+
|
|
|
|
+ // All Selected Objects
|
|
|
|
+ for (AbstractCpsObject cps : model.getSelectedCpsObjects()) {
|
|
|
|
+ if (cps != tempCps) {
|
|
|
|
+ x = (int) (cps.getPosition().x + xDist);
|
|
|
|
+ y = (int) (cps.getPosition().y + yDist);
|
|
|
|
+
|
|
|
|
+ // Make sure its in bounds
|
|
|
|
+ if (x <= 0)
|
|
|
|
+ x = 0;
|
|
|
|
+ else if (x > this.getWidth() - controller.getScale())
|
|
|
|
+ x = this.getWidth() - controller.getScale();
|
|
|
|
+ if (y <= 0)
|
|
|
|
+ y = 0;
|
|
|
|
+ else if (y > this.getHeight() - controller.getScale())
|
|
|
|
+ y = this.getHeight() - controller.getScale();
|
|
|
|
+
|
|
|
|
+ cps.setPosition(x, y);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
repaint();
|
|
repaint();
|
|
@@ -692,22 +841,19 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
x = e.getX();
|
|
x = e.getX();
|
|
y = e.getY();
|
|
y = e.getY();
|
|
// Everytghing for the tooltip :)
|
|
// Everytghing for the tooltip :)
|
|
- boolean on = false;
|
|
|
|
- for (AbstractCpsObject cps : upperNode.getNodes()) {
|
|
|
|
-
|
|
|
|
- cx = cps.getPosition().x;
|
|
|
|
- cy = cps.getPosition().y;
|
|
|
|
- if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
|
|
|
|
-
|
|
|
|
- objectTT.setTipText(cps.getName() + ", " + cps.getID());
|
|
|
|
- objectTT.setLocation(cx, cy + controller.getScale());
|
|
|
|
- on = true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (!on) {
|
|
|
|
- objectTT.setLocation(-200, -200);
|
|
|
|
- objectTT.setTipText("");
|
|
|
|
- }
|
|
|
|
|
|
+ /*
|
|
|
|
+ * boolean on = false; for (AbstractCpsObject cps :
|
|
|
|
+ * upperNode.getNodes()) {
|
|
|
|
+ *
|
|
|
|
+ * cx = cps.getPosition().x; cy = cps.getPosition().y; if (x -
|
|
|
|
+ * controller.getScale() <= cx && y - controller.getScale() <= cy && x
|
|
|
|
+ * >= cx && y >= cy) {
|
|
|
|
+ *
|
|
|
|
+ * objectTT.setTipText(cps.getName() + ", " + cps.getID());
|
|
|
|
+ * objectTT.setLocation(cx, cy + controller.getScale()); on = true; } }
|
|
|
|
+ * if (!on) { objectTT.setLocation(-200, -200); objectTT.setTipText("");
|
|
|
|
+ * }
|
|
|
|
+ */
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -747,7 +893,7 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (newEdge) {
|
|
if (newEdge) {
|
|
- e = new CpsEdge(cps, tempCps, edgeCapacity);
|
|
|
|
|
|
+ e = new CpsEdge(cps, tempCps, model.getMaxCapacity());
|
|
controller.addEdgeUpperNode(e, upperNode);
|
|
controller.addEdgeUpperNode(e, upperNode);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -770,11 +916,11 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
r = p.getA();
|
|
r = p.getA();
|
|
k = p.getB();
|
|
k = p.getB();
|
|
|
|
|
|
- e = new CpsEdge(n, tempCps, edgeCapacity);
|
|
|
|
|
|
+ e = new CpsEdge(n, tempCps, model.getMaxCapacity());
|
|
|
|
|
|
- e1 = new CpsEdge(n, r, edgeCapacity);
|
|
|
|
|
|
+ e1 = new CpsEdge(n, r, model.getMaxCapacity());
|
|
|
|
|
|
- e2 = new CpsEdge(n, k, edgeCapacity);
|
|
|
|
|
|
+ e2 = new CpsEdge(n, k, model.getMaxCapacity());
|
|
|
|
|
|
controller.delEdgeUpperNode(p, upperNode);
|
|
controller.delEdgeUpperNode(p, upperNode);
|
|
controller.addEdgeUpperNode(e, upperNode);
|
|
controller.addEdgeUpperNode(e, upperNode);
|
|
@@ -790,7 +936,7 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
n.setPosition(x - model.getScaleDiv2(), y - model.getScaleDiv2());
|
|
n.setPosition(x - model.getScaleDiv2(), y - model.getScaleDiv2());
|
|
controller.addObjUpperNode(n, upperNode);
|
|
controller.addObjUpperNode(n, upperNode);
|
|
|
|
|
|
- e = new CpsEdge(n, tempCps, edgeCapacity);
|
|
|
|
|
|
+ e = new CpsEdge(n, tempCps, model.getMaxCapacity());
|
|
|
|
|
|
controller.addEdgeUpperNode(e, upperNode);
|
|
controller.addEdgeUpperNode(e, upperNode);
|
|
}
|
|
}
|
|
@@ -870,7 +1016,7 @@ public class UpperNodeCanvas extends JPanel implements MouseListener, MouseMotio
|
|
* capacity
|
|
* capacity
|
|
*/
|
|
*/
|
|
public void setEdgeCapacity(float cap) {
|
|
public void setEdgeCapacity(float cap) {
|
|
- edgeCapacity = cap;
|
|
|
|
|
|
+ controller.setMaxCapacity(cap);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|