|
@@ -10,6 +10,9 @@ import java.awt.Point;
|
|
|
import java.awt.RenderingHints;
|
|
|
import java.awt.event.ActionEvent;
|
|
|
import java.awt.event.ActionListener;
|
|
|
+import java.awt.event.ComponentAdapter;
|
|
|
+import java.awt.event.ComponentEvent;
|
|
|
+import java.awt.event.ComponentListener;
|
|
|
import java.awt.event.MouseEvent;
|
|
|
import java.awt.event.MouseListener;
|
|
|
import java.awt.event.MouseMotionListener;
|
|
@@ -86,13 +89,14 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
|
public JMenuItem itemUngroup = new JMenuItem(Languages.getLanguage()[100]);
|
|
|
public JMenuItem itemTrack = new JMenuItem(Languages.getLanguage()[101]);
|
|
|
public JMenuItem itemUntrack = new JMenuItem(Languages.getLanguage()[102]);
|
|
|
-
|
|
|
- //Tooltip
|
|
|
+
|
|
|
+ // Tooltip
|
|
|
private boolean toolTip; // Tooltip on or off
|
|
|
- private Position toolTipPos = new Position(); //Tooltip Position
|
|
|
+ private Position toolTipPos = new Position(); // Tooltip Position
|
|
|
private String toolTipText = "";
|
|
|
-
|
|
|
- private Point mousePosition = new Point(); // Mouse Position when rightclicked
|
|
|
+
|
|
|
+ private Point mousePosition = new Point(); // Mouse Position when
|
|
|
+ // rightclicked
|
|
|
|
|
|
javax.swing.Timer animT; // animation Timer
|
|
|
private final int ANIMTIME = 500; // animation Time
|
|
@@ -333,8 +337,12 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
// Remove the selected Object objects
|
|
|
- for (AbstractCpsObject cps : model.getSelectedCpsObjects()) {
|
|
|
- controller.delCanvasObject(cps);
|
|
|
+ boolean save = false;
|
|
|
+ for (int j = 0; j < model.getSelectedCpsObjects().size(); j++) {
|
|
|
+ AbstractCpsObject cps = model.getSelectedCpsObjects().get(j);
|
|
|
+ if (j == model.getSelectedCpsObjects().size() - 1)
|
|
|
+ save = true;
|
|
|
+ controller.delCanvasObject(cps, save);
|
|
|
controller.removeTrackingObj(cps);
|
|
|
// Remove UpperNodeTab if UpperNode deleted
|
|
|
if (cps instanceof CpsUpperNode) {
|
|
@@ -398,12 +406,10 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
|
g2 = (Graphics2D) g;
|
|
|
RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
|
|
g2.setRenderingHints(rh);
|
|
|
-
|
|
|
- /*
|
|
|
- img = new ImageIcon(this.getClass().getResource("/Images/Darmstadt.jpg")).getImage();
|
|
|
- g2.drawImage(img, 0, 0, model.getCanvasX(), model.getCanvasY(),
|
|
|
- null);
|
|
|
- */
|
|
|
+
|
|
|
+ img = new ImageIcon(this.getClass().getResource("/Images/Darmstadt.JPG")).getImage();
|
|
|
+ g2.drawImage(img, 0, 0, model.getCanvasX(), model.getCanvasY(), null);
|
|
|
+
|
|
|
// Test SubNet Coloring
|
|
|
int i = 0;
|
|
|
for (SubNet s : controller.getSimManager().getSubNets()) {
|
|
@@ -608,27 +614,35 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
|
|
|
|
}
|
|
|
|
|
|
- //Tooltip
|
|
|
+ // Tooltip
|
|
|
if (toolTip) {
|
|
|
g2.setColor(new Color(255, 225, 150));
|
|
|
g2.setStroke(new BasicStroke(1));
|
|
|
- int textWidth = g.getFontMetrics().stringWidth(toolTipText)+2; //Text width
|
|
|
- int fixXPos = toolTipPos.x-(textWidth>>1)+model.getScaleDiv2(); //Position fixed x Position to the screen
|
|
|
- int fixYPos = toolTipPos.y; ////Position fixed y Position to the screen
|
|
|
- if (fixXPos<0) {
|
|
|
+ int textWidth = g.getFontMetrics().stringWidth(toolTipText) + 2; // Text
|
|
|
+ // width
|
|
|
+ int fixXPos = toolTipPos.x - (textWidth >> 1) + model.getScaleDiv2(); // Position
|
|
|
+ // fixed
|
|
|
+ // x
|
|
|
+ // Position
|
|
|
+ // to
|
|
|
+ // the
|
|
|
+ // screen
|
|
|
+ int fixYPos = toolTipPos.y; //// Position fixed y Position to the
|
|
|
+ //// screen
|
|
|
+ if (fixXPos < 0) {
|
|
|
fixXPos = 0;
|
|
|
- } else if (fixXPos+textWidth+1>this.getWidth()) {
|
|
|
- fixXPos -= (fixXPos+textWidth+1)-this.getWidth();
|
|
|
+ } else if (fixXPos + textWidth + 1 > this.getWidth()) {
|
|
|
+ fixXPos -= (fixXPos + textWidth + 1) - this.getWidth();
|
|
|
}
|
|
|
- if (fixYPos+16>this.getHeight()) {
|
|
|
- fixYPos-= (fixYPos+16)-this.getHeight();
|
|
|
+ if (fixYPos + 16 > this.getHeight()) {
|
|
|
+ fixYPos -= (fixYPos + 16) - this.getHeight();
|
|
|
}
|
|
|
g2.fillRect(fixXPos, fixYPos, textWidth, 15);
|
|
|
g2.setColor(Color.BLACK);
|
|
|
g2.drawRect(fixXPos, fixYPos, textWidth, 15);
|
|
|
- g2.drawString(toolTipText, fixXPos+2, fixYPos+12);
|
|
|
+ g2.drawString(toolTipText, fixXPos + 2, fixYPos + 12);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// Dragg Highlighting
|
|
|
if (doMark) {
|
|
|
g2.setColor(Color.BLACK);
|
|
@@ -841,7 +855,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
|
tempCps.setPosition(x, y); // Drag Position
|
|
|
// TipText Position and name
|
|
|
toolTip = true;
|
|
|
- toolTipText = tempCps.getName()+", "+tempCps.getID();
|
|
|
+ toolTipText = tempCps.getName() + ", " + tempCps.getID();
|
|
|
toolTipPos.x = tempCps.getPosition().x;
|
|
|
toolTipPos.y = tempCps.getPosition().y + model.getScale();
|
|
|
|
|
@@ -909,8 +923,8 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
|
if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
|
|
|
on = true;
|
|
|
toolTipPos.x = cps.getPosition().x;
|
|
|
- toolTipPos.y = cps.getPosition().y+ model.getScale();
|
|
|
- toolTipText = cps.getName()+", "+cps.getID();
|
|
|
+ toolTipPos.y = cps.getPosition().y + model.getScale();
|
|
|
+ toolTipText = cps.getName() + ", " + cps.getID();
|
|
|
}
|
|
|
}
|
|
|
if (on) {
|
|
@@ -1008,7 +1022,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
|
|
|
|
// Wenn ein Node ohne Connections da ist
|
|
|
if (deleteNode) {
|
|
|
- controller.delCanvasObject(tempCps);
|
|
|
+ controller.delCanvasObject(tempCps, true);
|
|
|
tempCps = null;
|
|
|
}
|
|
|
}
|