|
@@ -53,6 +53,8 @@ import javax.swing.ImageIcon;
|
|
|
import classes.Category;
|
|
|
import classes.CpsObject;
|
|
|
import classes.HolonObject;
|
|
|
+import classes.HolonSwitch;
|
|
|
+import classes.HolonTransformer;
|
|
|
import Interfaces.CategoryListener;
|
|
|
|
|
|
import java.awt.event.ActionListener;
|
|
@@ -102,8 +104,17 @@ public class GUI implements CategoryListener {
|
|
|
private final JToolBar toolBar = new JToolBar();
|
|
|
|
|
|
// variables
|
|
|
+<<<<<<< HEAD
|
|
|
boolean dragging = false;
|
|
|
String actualObjectClicked;
|
|
|
+=======
|
|
|
+ private boolean dragging = false;
|
|
|
+ private Image img = null;
|
|
|
+ private CpsObject tempCps = null;
|
|
|
+ private HolonObject tempHol = null;
|
|
|
+ private HolonSwitch tempSw = null;
|
|
|
+ private HolonTransformer tempTrans = null;
|
|
|
+>>>>>>> 1c5a1a2c88c580db3f508d880b0796434747d61f
|
|
|
|
|
|
private final MyCanvas canvas;
|
|
|
|
|
@@ -191,9 +202,8 @@ public class GUI implements CategoryListener {
|
|
|
splitPane_2.setDividerLocation(200);
|
|
|
|
|
|
splitPane.setLeftComponent(scrollPane_1);
|
|
|
- final Image img = new ImageIcon(this.getClass().getResource("/Images/Dummy_House.png")).getImage()
|
|
|
- .getScaledInstance(30, 30, java.awt.Image.SCALE_SMOOTH);
|
|
|
- Icon icon = new ImageIcon(img);
|
|
|
+
|
|
|
+ Icon icon = new ImageIcon(new ImageIcon(this.getClass().getResource("/Images/Dummy_House.png")).getImage().getScaledInstance(30, 30, java.awt.Image.SCALE_SMOOTH));
|
|
|
DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree.getCellRenderer();
|
|
|
renderer.setLeafIcon(icon);
|
|
|
// renderer.setClosedIcon(icon);
|
|
@@ -203,9 +213,14 @@ public class GUI implements CategoryListener {
|
|
|
|
|
|
tree.addMouseListener(new MouseAdapter() {
|
|
|
public void mouseReleased(MouseEvent e) {
|
|
|
- try {
|
|
|
+ try {//wenn ein bild "gedraged" wird
|
|
|
if (dragging) {
|
|
|
+<<<<<<< HEAD
|
|
|
HolonObject h = new HolonObject(actualObjectClicked);
|
|
|
+=======
|
|
|
+ //neues Object
|
|
|
+ CpsObject h = new CpsObject(tempCps);
|
|
|
+>>>>>>> 1c5a1a2c88c580db3f508d880b0796434747d61f
|
|
|
h.setPos((int) canvas.getMousePosition().getX(), (int) canvas.getMousePosition().getY());
|
|
|
controller.addObject(h);
|
|
|
canvas.repaint();
|
|
@@ -213,6 +228,7 @@ public class GUI implements CategoryListener {
|
|
|
}
|
|
|
} catch (Exception e2) {
|
|
|
}
|
|
|
+ //Cursor normalisieren
|
|
|
frmCyberPhysical.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
|
|
}
|
|
|
});
|
|
@@ -220,6 +236,7 @@ public class GUI implements CategoryListener {
|
|
|
tree.addMouseListener(new MouseAdapter() {
|
|
|
public void mousePressed(MouseEvent e) {
|
|
|
try {
|
|
|
+<<<<<<< HEAD
|
|
|
actualObjectClicked = tree.getPathForLocation(e.getX(), e.getY()).getLastPathComponent().toString();
|
|
|
// System.out.println(name);
|
|
|
if (actualObjectClicked.compareTo("Power Plant") == 0 || actualObjectClicked.compareTo("House") == 0
|
|
@@ -228,11 +245,30 @@ public class GUI implements CategoryListener {
|
|
|
dragging = true;
|
|
|
Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(img, new Point(0, 0), "Image");
|
|
|
frmCyberPhysical.setCursor(cursor);
|
|
|
+=======
|
|
|
+ //Object zum draggen?
|
|
|
+ String name = tree.getPathForLocation(e.getX(), e.getY()).getLastPathComponent().toString();
|
|
|
+ //System.out.println(name);
|
|
|
+ boolean found = false;
|
|
|
+ for (Category cat : model.getCategories()) {
|
|
|
+ System.out.println(cat.getName()+":");
|
|
|
+ for (CpsObject cps : cat.getObjects()) {
|
|
|
+ System.out.println(name+" - "+cps.getCompareName());
|
|
|
+ if(name.compareTo(cps.getCompareName())==0 ){
|
|
|
+ tempCps = cps;
|
|
|
+ img = new ImageIcon(this.getClass().getResource(tempCps.getImage())).getImage().getScaledInstance(30, 30, java.awt.Image.SCALE_SMOOTH);
|
|
|
+ dragging = true;
|
|
|
+ Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(img, new Point(0, 0),"Image");
|
|
|
+ frmCyberPhysical.setCursor(cursor);
|
|
|
+ }
|
|
|
+ }
|
|
|
+>>>>>>> 1c5a1a2c88c580db3f508d880b0796434747d61f
|
|
|
}
|
|
|
} catch (Exception e2) {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
+<<<<<<< HEAD
|
|
|
|
|
|
/*
|
|
|
* tree.addTreeSelectionListener(new TreeSelectionListener() {
|
|
@@ -247,6 +283,9 @@ public class GUI implements CategoryListener {
|
|
|
* (Exception e2) {} } });
|
|
|
*/
|
|
|
|
|
|
+=======
|
|
|
+
|
|
|
+>>>>>>> 1c5a1a2c88c580db3f508d880b0796434747d61f
|
|
|
scrollPane_1.setViewportView(tree);
|
|
|
|
|
|
scrollPane_1.setColumnHeaderView(panel);
|