|
@@ -75,14 +75,14 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
|
|
|
|
// PopUpMenu
|
|
// PopUpMenu
|
|
private JPopupMenu popmenu = new JPopupMenu();
|
|
private JPopupMenu popmenu = new JPopupMenu();
|
|
- private JMenuItem itemDelete = new JMenuItem("Delete");
|
|
|
|
- private JMenuItem itemCut = new JMenuItem("Cut");
|
|
|
|
- private JMenuItem itemCopy = new JMenuItem("Copy");
|
|
|
|
- public JMenuItem itemPaste = new JMenuItem("Paste");
|
|
|
|
- public JMenuItem itemGroup = new JMenuItem("Group");
|
|
|
|
- public JMenuItem itemUngroup = new JMenuItem("Ungroup");
|
|
|
|
- public JMenuItem itemTrack = new JMenuItem("Track");
|
|
|
|
- public JMenuItem itemUntrack = new JMenuItem("Untrack");
|
|
|
|
|
|
+ private JMenuItem itemDelete = new JMenuItem(Languages.getLanguage()[98]);
|
|
|
|
+ private JMenuItem itemCut = new JMenuItem(Languages.getLanguage()[95]);
|
|
|
|
+ private JMenuItem itemCopy = new JMenuItem(Languages.getLanguage()[96]);
|
|
|
|
+ public JMenuItem itemPaste = new JMenuItem(Languages.getLanguage()[97]);
|
|
|
|
+ public JMenuItem itemGroup = new JMenuItem(Languages.getLanguage()[99]);
|
|
|
|
+ public JMenuItem itemUngroup = new JMenuItem(Languages.getLanguage()[100]);
|
|
|
|
+ public JMenuItem itemTrack = new JMenuItem(Languages.getLanguage()[101]);
|
|
|
|
+ public JMenuItem itemUntrack = new JMenuItem(Languages.getLanguage()[102]);
|
|
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
|
|
@@ -140,6 +140,8 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
itemTrack.setEnabled(false);
|
|
itemTrack.setEnabled(false);
|
|
itemUntrack.setEnabled(false);
|
|
itemUntrack.setEnabled(false);
|
|
|
|
|
|
|
|
+ itemCut.setText(Languages.getLanguage()[95]);
|
|
|
|
+
|
|
itemGroup.addActionListener(new ActionListener() {
|
|
itemGroup.addActionListener(new ActionListener() {
|
|
@Override
|
|
@Override
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
@@ -209,7 +211,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
savePos = new ArrayList<>();
|
|
savePos = new ArrayList<>();
|
|
animCps = ((CpsUpperNode) tempCps).getNodes();
|
|
animCps = ((CpsUpperNode) tempCps).getNodes();
|
|
controller.delUpperNode((CpsUpperNode) tempCps, null);
|
|
controller.delUpperNode((CpsUpperNode) tempCps, null);
|
|
@@ -260,21 +262,21 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
animT.start();
|
|
animT.start();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
-
|
|
|
|
- //adds the selected object(s) to the statistic panel
|
|
|
|
|
|
+
|
|
|
|
+ // adds the selected object(s) to the statistic panel
|
|
itemTrack.addActionListener(new ActionListener() {
|
|
itemTrack.addActionListener(new ActionListener() {
|
|
@Override
|
|
@Override
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
for (AbstractCpsObject o : model.getSelectedCpsObjects()) {
|
|
for (AbstractCpsObject o : model.getSelectedCpsObjects()) {
|
|
boolean found = false;
|
|
boolean found = false;
|
|
if (controller.getTrackingObj() != null) {
|
|
if (controller.getTrackingObj() != null) {
|
|
- if(controller.getTrackingObj().contains(o)){
|
|
|
|
|
|
+ if (controller.getTrackingObj().contains(o)) {
|
|
found = true;
|
|
found = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!found) {
|
|
if (!found) {
|
|
controller.addTrackingObj(o);
|
|
controller.addTrackingObj(o);
|
|
- if(o instanceof HolonObject){
|
|
|
|
|
|
+ if (o instanceof HolonObject) {
|
|
((HolonObject) o).updateTrackingInfo();
|
|
((HolonObject) o).updateTrackingInfo();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -295,7 +297,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
boolean found = false;
|
|
boolean found = false;
|
|
if (controller.getTrackingObj() != null) {
|
|
if (controller.getTrackingObj() != null) {
|
|
for (AbstractCpsObject obj : controller.getTrackingObj()) {
|
|
for (AbstractCpsObject obj : controller.getTrackingObj()) {
|
|
- if(obj instanceof HolonObject){
|
|
|
|
|
|
+ if (obj instanceof HolonObject) {
|
|
if (obj.getID() == o.getID()) {
|
|
if (obj.getID() == o.getID()) {
|
|
found = true;
|
|
found = true;
|
|
}
|
|
}
|
|
@@ -396,10 +398,10 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
controller.addSubNetColor(new Color((int) (Math.random() * 255), (int) (Math.random() * 255),
|
|
controller.addSubNetColor(new Color((int) (Math.random() * 255), (int) (Math.random() * 255),
|
|
(int) (Math.random() * 255)));
|
|
(int) (Math.random() * 255)));
|
|
}
|
|
}
|
|
- if(showedInformation[3]){
|
|
|
|
- for (HolonObject cps : s.getObjects()) {
|
|
|
|
- cps.setBorderColor(model.getSubNetColors().get(i));
|
|
|
|
- }
|
|
|
|
|
|
+ if (showedInformation[3]) {
|
|
|
|
+ for (HolonObject cps : s.getObjects()) {
|
|
|
|
+ cps.setBorderColor(model.getSubNetColors().get(i));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
i++;
|
|
i++;
|
|
}
|
|
}
|
|
@@ -415,7 +417,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
for (CpsEdge con : model.getEdgesOnCanvas()) {
|
|
for (CpsEdge con : model.getEdgesOnCanvas()) {
|
|
if (con.getA().getID() != model.getSelectedObjectID() && con.getB().getID() != model.getSelectedObjectID()
|
|
if (con.getA().getID() != model.getSelectedObjectID() && con.getB().getID() != model.getSelectedObjectID()
|
|
&& con != edgeHighlight) {
|
|
&& con != edgeHighlight) {
|
|
- if(con.getConnected()){
|
|
|
|
|
|
+ if (con.getConnected()) {
|
|
if (con.getState()) {
|
|
if (con.getState()) {
|
|
g2.setColor(Color.GREEN);
|
|
g2.setColor(Color.GREEN);
|
|
if (con.getCapacity() != -1) {
|
|
if (con.getCapacity() != -1) {
|
|
@@ -425,7 +427,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
g2.setColor(Color.RED);
|
|
g2.setColor(Color.RED);
|
|
g2.setStroke(new BasicStroke(2));
|
|
g2.setStroke(new BasicStroke(2));
|
|
}
|
|
}
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
g2.setColor(Color.DARK_GRAY);
|
|
g2.setColor(Color.DARK_GRAY);
|
|
g2.setStroke(new BasicStroke(2));
|
|
g2.setStroke(new BasicStroke(2));
|
|
}
|
|
}
|
|
@@ -440,14 +442,18 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
maxCap = String.valueOf(con.getCapacity());
|
|
maxCap = String.valueOf(con.getCapacity());
|
|
}
|
|
}
|
|
if (showedInformation[0]) {
|
|
if (showedInformation[0]) {
|
|
- if(con.getConnected()){
|
|
|
|
|
|
+ if (con.getConnected()) {
|
|
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());
|
|
|
|
- }else{
|
|
|
|
- g2.drawString("not connected",
|
|
|
|
- (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());
|
|
|
|
+ } else {
|
|
|
|
+ g2.drawString("not connected",
|
|
|
|
+ (con.getA().getPosition().x + con.getB().getPosition().x) / 2
|
|
|
|
+ + controller.getScaleDiv2(),
|
|
|
|
+ (con.getA().getPosition().y + con.getB().getPosition().y) / 2
|
|
|
|
+ + controller.getScaleDiv2());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -478,17 +484,17 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
maxCap = String.valueOf(con.getCapacity());
|
|
maxCap = String.valueOf(con.getCapacity());
|
|
}
|
|
}
|
|
if (showedInformation[0]) {
|
|
if (showedInformation[0]) {
|
|
- if(con.getConnected()){
|
|
|
|
|
|
+ if (con.getConnected()) {
|
|
g2.drawString(con.getFlow() + "/" + maxCap,
|
|
g2.drawString(con.getFlow() + "/" + maxCap,
|
|
(con.getA().getPosition().x + con.getB().getPosition().x) / 2
|
|
(con.getA().getPosition().x + con.getB().getPosition().x) / 2
|
|
+ controller.getScaleDiv2(),
|
|
+ controller.getScaleDiv2(),
|
|
- (con.getA().getPosition().y + con.getB().getPosition().y) / 2
|
|
|
|
|
|
+ (con.getA().getPosition().y + con.getB().getPosition().y) / 2
|
|
+ controller.getScaleDiv2());
|
|
+ controller.getScaleDiv2());
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
g2.drawString("not connected",
|
|
g2.drawString("not connected",
|
|
(con.getA().getPosition().x + con.getB().getPosition().x) / 2
|
|
(con.getA().getPosition().x + con.getB().getPosition().x) / 2
|
|
+ controller.getScaleDiv2(),
|
|
+ controller.getScaleDiv2(),
|
|
- (con.getA().getPosition().y + con.getB().getPosition().y) / 2
|
|
|
|
|
|
+ (con.getA().getPosition().y + con.getB().getPosition().y) / 2
|
|
+ controller.getScaleDiv2());
|
|
+ controller.getScaleDiv2());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -523,10 +529,11 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
// Objects
|
|
// Objects
|
|
for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
|
|
for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
|
|
// Border Highlighting
|
|
// Border Highlighting
|
|
- if(showedInformation[3]){
|
|
|
|
|
|
+ if (showedInformation[3]) {
|
|
g2.setColor(cps.getBorderColor());
|
|
g2.setColor(cps.getBorderColor());
|
|
if (g2.getColor() != Color.WHITE) {
|
|
if (g2.getColor() != Color.WHITE) {
|
|
- g2.fillRect((int) (cps.getPosition().x - scalediv20 - 3), (int) (cps.getPosition().y - scalediv20 - 3),
|
|
|
|
|
|
+ g2.fillRect((int) (cps.getPosition().x - scalediv20 - 3),
|
|
|
|
+ (int) (cps.getPosition().y - scalediv20 - 3),
|
|
(int) (controller.getScale() + ((scalediv20 + 3) * 2)),
|
|
(int) (controller.getScale() + ((scalediv20 + 3) * 2)),
|
|
(int) (controller.getScale() + ((scalediv20 + 3) * 2)));
|
|
(int) (controller.getScale() + ((scalediv20 + 3) * 2)));
|
|
}
|
|
}
|
|
@@ -697,16 +704,15 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
else
|
|
else
|
|
itemUngroup.setEnabled(false);
|
|
itemUngroup.setEnabled(false);
|
|
/*
|
|
/*
|
|
- if (!(tempCps instanceof HolonSwitch)) {
|
|
|
|
- itemTrack.setEnabled(true);
|
|
|
|
- itemUntrack.setEnabled(true);
|
|
|
|
- } else {
|
|
|
|
- */
|
|
|
|
- itemTrack.setEnabled(true);
|
|
|
|
- itemUntrack.setEnabled(true);
|
|
|
|
- /*
|
|
|
|
- }
|
|
|
|
- */
|
|
|
|
|
|
+ * if (!(tempCps instanceof HolonSwitch)) {
|
|
|
|
+ * itemTrack.setEnabled(true); itemUntrack.setEnabled(true); }
|
|
|
|
+ * else {
|
|
|
|
+ */
|
|
|
|
+ itemTrack.setEnabled(true);
|
|
|
|
+ itemUntrack.setEnabled(true);
|
|
|
|
+ /*
|
|
|
|
+ * }
|
|
|
|
+ */
|
|
if (model.getSelectedCpsObjects().size() == 0) {
|
|
if (model.getSelectedCpsObjects().size() == 0) {
|
|
controller.addSelectedObject(tempCps);
|
|
controller.addSelectedObject(tempCps);
|
|
}
|
|
}
|
|
@@ -988,6 +994,17 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void updateLanguages() {
|
|
|
|
+ itemCut.setText(Languages.getLanguage()[95]);
|
|
|
|
+ itemCopy.setText(Languages.getLanguage()[96]);
|
|
|
|
+ itemPaste.setText(Languages.getLanguage()[97]);
|
|
|
|
+ itemDelete.setText(Languages.getLanguage()[98]);
|
|
|
|
+ itemGroup.setText(Languages.getLanguage()[99]);
|
|
|
|
+ itemUngroup.setText(Languages.getLanguage()[100]);
|
|
|
|
+ itemTrack.setText(Languages.getLanguage()[101]);
|
|
|
|
+ itemUntrack.setText(Languages.getLanguage()[102]);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Checks if a double click was made.
|
|
* Checks if a double click was made.
|
|
*
|
|
*
|