|
@@ -24,6 +24,8 @@ import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.Timer;
|
|
|
+import java.util.TimerTask;
|
|
|
|
|
|
import javax.swing.AbstractAction;
|
|
|
import javax.swing.ActionMap;
|
|
@@ -90,6 +92,9 @@ import ui.model.Model;
|
|
|
*/
|
|
|
public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
+ // for doubleclick
|
|
|
+ private boolean click = false;
|
|
|
+
|
|
|
private JFrame frmCyberPhysical;
|
|
|
|
|
|
private final SimulationMenu simMenu;
|
|
@@ -1010,24 +1015,49 @@ public class GUI<E> implements CategoryListener {
|
|
|
public void mouseReleased(MouseEvent e) {
|
|
|
try {
|
|
|
if (dragging) {
|
|
|
- int x = (int) canvas.getMousePosition().getX();
|
|
|
- int y = (int) canvas.getMousePosition().getY();
|
|
|
- AbstractCpsObject h = null;
|
|
|
- if (tempCps.getClass() == HolonObject.class) {
|
|
|
- h = new HolonObject(tempCps);
|
|
|
- }
|
|
|
- if (tempCps.getClass() == HolonSwitch.class) {
|
|
|
- h = new HolonSwitch(tempCps);
|
|
|
- }
|
|
|
- if (tempCps.getClass() == HolonTransformer.class) {
|
|
|
- h = new HolonTransformer(tempCps);
|
|
|
- }
|
|
|
+ if (((JScrollPane) tabbedPane.getSelectedComponent()).getViewport().getComponent(0) instanceof UpperNodeCanvas) {
|
|
|
+ UpperNodeCanvas unc = ((UpperNodeCanvas)((JScrollPane) tabbedPane.getSelectedComponent()).getViewport().getComponent(0));
|
|
|
+
|
|
|
+ int x = (int) unc.getMousePosition().getX();
|
|
|
+ int y = (int) unc.getMousePosition().getY();
|
|
|
+
|
|
|
+ AbstractCpsObject h = null;
|
|
|
+ if (tempCps instanceof HolonObject) {
|
|
|
+ h = new HolonObject(tempCps);
|
|
|
+ }
|
|
|
+ if (tempCps instanceof HolonSwitch) {
|
|
|
+ h = new HolonSwitch(tempCps);
|
|
|
+ }
|
|
|
+ if (tempCps instanceof HolonTransformer) {
|
|
|
+ h = new HolonTransformer(tempCps);
|
|
|
+ }
|
|
|
|
|
|
- h.setPosition(x, y);
|
|
|
- controller.addObjectCanvas(h);
|
|
|
- canvas.invalidate();
|
|
|
- canvas.repaint();
|
|
|
+ h.setPosition(x, y);
|
|
|
+
|
|
|
+ controller.addObjectInUpperNode(h, unc.upperNode);
|
|
|
+ unc.invalidate();
|
|
|
+ unc.repaint();
|
|
|
+ } else {
|
|
|
+ int x = (int) canvas.getMousePosition().getX();
|
|
|
+ int y = (int) canvas.getMousePosition().getY();
|
|
|
+
|
|
|
+ AbstractCpsObject h = null;
|
|
|
+ if (tempCps instanceof HolonObject) {
|
|
|
+ h = new HolonObject(tempCps);
|
|
|
+ }
|
|
|
+ if (tempCps instanceof HolonSwitch) {
|
|
|
+ h = new HolonSwitch(tempCps);
|
|
|
+ }
|
|
|
+ if (tempCps instanceof HolonTransformer) {
|
|
|
+ h = new HolonTransformer(tempCps);
|
|
|
+ }
|
|
|
|
|
|
+ h.setPosition(x, y);
|
|
|
+
|
|
|
+ controller.addObjectCanvas(h);
|
|
|
+ canvas.invalidate();
|
|
|
+ canvas.repaint();
|
|
|
+ }
|
|
|
dragging = false;
|
|
|
}
|
|
|
} catch (Exception eex) {
|
|
@@ -1308,7 +1338,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
tableHolonElement.setModel(tableModelHolonElementSingle);
|
|
|
}
|
|
|
// New Tab with NodeOfNode
|
|
|
- if (canvas.click && temp instanceof CpsUpperNode) {
|
|
|
+ if (doubleClick() && temp instanceof CpsUpperNode) {
|
|
|
UpperNodeCanvas unc = new UpperNodeCanvas(model, controller, (CpsUpperNode) temp);
|
|
|
unc.setBorder(null);
|
|
|
unc.setBackground(Color.WHITE);
|
|
@@ -1316,6 +1346,8 @@ public class GUI<E> implements CategoryListener {
|
|
|
JScrollPane sp = new JScrollPane(unc);
|
|
|
sp.setBorder(null);
|
|
|
tabbedPane.add(temp.getName(), sp);
|
|
|
+ tabbedPane.setSelectedComponent(sp);
|
|
|
+ tabbedPane.setTabComponentAt(tabbedPane.getTabCount() - 1, new ButtonTabComponent(tabbedPane));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1605,10 +1637,8 @@ public class GUI<E> implements CategoryListener {
|
|
|
splitPane.setLeftComponent(scrollPane1);
|
|
|
splitPaneCanvasConsole.setLeftComponent(panelTapped_SimMenu);
|
|
|
tabbedPane.addTab("View", canvasSP);
|
|
|
- tabbedPane.setTabComponentAt(0, new ButtonTabComponent(tabbedPane));
|
|
|
- tabbedPane.addTab("Statistics", statScrollPane);
|
|
|
- tabbedPane.setTabComponentAt(1, new ButtonTabComponent(tabbedPane));
|
|
|
-
|
|
|
+ tabbedPane.addTab("Statistics", statScrollPane);
|
|
|
+
|
|
|
splitPaneCanvasConsole.setRightComponent(console);
|
|
|
splitPane1.setLeftComponent(splitPaneCanvasConsole);
|
|
|
splitPane1.setRightComponent(splitHolonElPro);
|
|
@@ -2004,4 +2034,28 @@ public class GUI<E> implements CategoryListener {
|
|
|
// Image Size Slider
|
|
|
lblImageSize.setText(Languages.getLanguage()[94]);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Checks if a double click was made.
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ *
|
|
|
+ * @return true if doublecklick, false if not
|
|
|
+ */
|
|
|
+ private boolean doubleClick() {
|
|
|
+ if (click) {
|
|
|
+ click = false;
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ click = true;
|
|
|
+ Timer t = new Timer("doubleclickTimer", false);
|
|
|
+ t.schedule(new TimerTask() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ click = false;
|
|
|
+ }
|
|
|
+ }, 350);
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|