|
@@ -95,6 +95,10 @@ public class GUI implements CategoryListener {
|
|
private final JButton btnDel = new JButton("-");
|
|
private final JButton btnDel = new JButton("-");
|
|
|
|
|
|
private final JToolBar toolBar = new JToolBar();
|
|
private final JToolBar toolBar = new JToolBar();
|
|
|
|
+
|
|
|
|
+ //variables
|
|
|
|
+ boolean dragging = false;
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* Create the application.
|
|
* Create the application.
|
|
@@ -209,10 +213,13 @@ public class GUI implements CategoryListener {
|
|
tree.addMouseListener(new MouseAdapter(){
|
|
tree.addMouseListener(new MouseAdapter(){
|
|
public void mouseReleased(MouseEvent e){
|
|
public void mouseReleased(MouseEvent e){
|
|
try {
|
|
try {
|
|
- HolonObject h = new HolonObject("House");
|
|
|
|
- h.setPos((int)canvas.getMousePosition().getX(),(int)canvas.getMousePosition().getY());
|
|
|
|
- canvas.choords.add(h);
|
|
|
|
- canvas.repaint();
|
|
|
|
|
|
+ if(dragging){
|
|
|
|
+ HolonObject h = new HolonObject("House");
|
|
|
|
+ h.setPos((int)canvas.getMousePosition().getX(),(int)canvas.getMousePosition().getY());
|
|
|
|
+ canvas.choords.add(h);
|
|
|
|
+ canvas.repaint();
|
|
|
|
+ dragging = false;
|
|
|
|
+ }
|
|
} catch (Exception e2) {}
|
|
} catch (Exception e2) {}
|
|
frmCyberPhysical.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
|
frmCyberPhysical.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
|
}
|
|
}
|
|
@@ -220,13 +227,17 @@ public class GUI implements CategoryListener {
|
|
|
|
|
|
|
|
|
|
tree.addTreeSelectionListener(new TreeSelectionListener() {
|
|
tree.addTreeSelectionListener(new TreeSelectionListener() {
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
public void valueChanged(TreeSelectionEvent e) {
|
|
public void valueChanged(TreeSelectionEvent e) {
|
|
- // TODO Auto-generated method stub
|
|
|
|
try {
|
|
try {
|
|
- Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(img, new Point(0,0), "red Cursor");
|
|
|
|
- frmCyberPhysical.setCursor(cursor);
|
|
|
|
|
|
+ String name = tree.getLastSelectedPathComponent().toString();
|
|
|
|
+ System.out.println(name);
|
|
|
|
+ tree.clearSelection();
|
|
|
|
+ if(name.compareTo("Power Plant")==0 || name.compareTo("House")==0 || name.compareTo("Switch")==0 || name.compareTo("Transformer")==0){
|
|
|
|
+ dragging = true;
|
|
|
|
+ Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(img, new Point(0,0), "red Cursor");
|
|
|
|
+ frmCyberPhysical.setCursor(cursor);
|
|
|
|
+ }
|
|
} catch (Exception e2) {
|
|
} catch (Exception e2) {
|
|
// TODO: handle exception
|
|
// TODO: handle exception
|
|
}
|
|
}
|