[Javanetsim-cvs] javaNetSim/guiUI GuiNode.java, 1.12, 1.13 SandBox.java, 1.12, 1.13
Status: Beta
Brought to you by:
darkkey
From: QweR <qw...@us...> - 2008-10-25 22:16:44
|
Update of /cvsroot/javanetsim/javaNetSim/guiUI In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv31738/guiUI Modified Files: GuiNode.java SandBox.java Log Message: Drag'n'Drop was fixed Index: GuiNode.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/GuiNode.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** GuiNode.java 25 Oct 2008 16:35:11 -0000 1.12 --- GuiNode.java 25 Oct 2008 21:33:32 -0000 1.13 *************** *** 111,119 **** public abstract class GuiNode extends JPanel implements MouseListener, ! MouseMotionListener, Serializable, DragGestureListener, ! DragSourceListener, DropTargetListener { // The node's name within a label protected JLabel lblNodeName = new JLabel(); --- 111,124 ---- public abstract class GuiNode extends JPanel implements MouseListener, ! MouseMotionListener, Serializable, DragGestureListener, ! DragSourceListener, DropTargetListener { // The node's name within a label + /** + * + */ + private static final long serialVersionUID = 3501858129186840165L; + protected JLabel lblNodeName = new JLabel(); *************** *** 130,134 **** protected String tmpName = ""; ! // A Refence to the MainScreen protected MainScreen controller; --- 135,139 ---- protected String tmpName = ""; ! // A Reference to the MainScreen protected MainScreen controller; *************** *** 154,158 **** private String strNodeName; ! private Vector vecConnectedLinks = new Vector(); boolean acceptDrop = true; --- 159,163 ---- private String strNodeName; ! private Vector<String> vecConnectedLinks = new Vector<String>(); boolean acceptDrop = true; *************** *** 166,176 **** private int SandBoxHeight; ! //private int lastX; ! ! //private int lastY; ! ! private int controlX; ! ! private int controlY; // These statics are only for sandbox class. These shouldn't be used --- 171,176 ---- private int SandBoxHeight; ! private int pressedX = 0; ! private int pressedY = 0; // These statics are only for sandbox class. These shouldn't be used *************** *** 328,332 **** mnuTurn.setText(controller.DeviceState(lblNodeName.getText())); } ! public void updateInterfacesMenu(){ try { --- 328,332 ---- mnuTurn.setText(controller.DeviceState(lblNodeName.getText())); } ! public void updateInterfacesMenu(){ try { *************** *** 335,339 **** for (int i = 0; i < ints.length; i++) { int int_type = Simulation.Sim.getNode(this.strNodeName).getIntType((String)ints[i]); ! if(int_type != core.NetworkInterface.Console){ JMenuItem mnuI = new JMenuItem((String) ints[i]); --- 335,339 ---- for (int i = 0; i < ints.length; i++) { int int_type = Simulation.Sim.getNode(this.strNodeName).getIntType((String)ints[i]); ! if(int_type != core.NetworkInterface.Console){ JMenuItem mnuI = new JMenuItem((String) ints[i]); *************** *** 343,347 **** controller.showIntProps(lblNodeName.getText(), ! ((JMenuItem) e.getSource()).getText()); } --- 343,347 ---- controller.showIntProps(lblNodeName.getText(), ! ((JMenuItem) e.getSource()).getText()); } *************** *** 350,354 **** mnuInt.add(mnuI); } ! if(int_type != core.NetworkInterface.Wireless){ --- 350,354 ---- mnuInt.add(mnuI); } ! if(int_type != core.NetworkInterface.Wireless){ *************** *** 359,363 **** controller.breakLink(lblNodeName.getText(), ! ((JMenuItem) e.getSource()).getText()); } --- 359,363 ---- controller.breakLink(lblNodeName.getText(), ! ((JMenuItem) e.getSource()).getText()); } *************** *** 372,376 **** } } ! public void updateConnectedLinkMenu(){ try { --- 372,376 ---- } } ! public void updateConnectedLinkMenu(){ try { *************** *** 380,384 **** int int_type = Simulation.Sim.getNode(this.strNodeName).getIntType((String)ints[i]); boolean lineIsConnected = (Simulation.Sim.getNode(this.strNodeName).getNetworkInterface((String)ints[i]).getConnectedLink()!=null); ! if(int_type != core.NetworkInterface.Wireless && lineIsConnected){ --- 380,384 ---- int int_type = Simulation.Sim.getNode(this.strNodeName).getIntType((String)ints[i]); boolean lineIsConnected = (Simulation.Sim.getNode(this.strNodeName).getNetworkInterface((String)ints[i]).getConnectedLink()!=null); ! if(int_type != core.NetworkInterface.Wireless && lineIsConnected){ *************** *** 389,393 **** controller.breakLink(lblNodeName.getText(), ! ((JMenuItem) e.getSource()).getText()); } --- 389,393 ---- controller.breakLink(lblNodeName.getText(), ! ((JMenuItem) e.getSource()).getText()); } *************** *** 402,409 **** } } ! public abstract void addInterfaces(MainScreen parent, Node node); ! ! /** * --- 402,409 ---- } } ! public abstract void addInterfaces(MainScreen parent, Node node); ! ! /** * *************** *** 555,559 **** (this.getX() + this.getWidth() / 2), (this.getY() + ! this.getHeight() / 2)); controller.addFakeLine(tempPoint); --- 555,559 ---- (this.getX() + this.getWidth() / 2), (this.getY() + ! this.getHeight() / 2)); controller.addFakeLine(tempPoint); *************** *** 707,715 **** for (int i = 2; i < GuiNodePopMenu.getSubElements().length; i++) { ((JMenuItem) GuiNodePopMenu.getSubElements()[i]) ! .setEnabled(ena); } updateConnectedLinkMenu(); GuiNodePopMenu.show(e.getComponent(), e.getX(), e.getY()); } } --- 707,719 ---- for (int i = 2; i < GuiNodePopMenu.getSubElements().length; i++) { ((JMenuItem) GuiNodePopMenu.getSubElements()[i]) ! .setEnabled(ena); } updateConnectedLinkMenu(); GuiNodePopMenu.show(e.getComponent(), e.getX(), e.getY()); } + else if (e.getModifiers() == InputEvent.BUTTON1_MASK) { + pressedX = e.getX(); + pressedY = e.getY(); + } } *************** *** 751,792 **** else { ! //lastX = this.getX() + e.getX() - this.getWidth(); ! ! //lastY = this.getY() + e.getY() - this.getHeight(); ! ! controlX = this.getX() + e.getX() + this.getWidth() / 2; ! ! controlY = this.getY() + e.getY() + this.getHeight() / 2; ! ! if (controlX < SandBoxWidth && controlX > this.getWidth()) ! ! { ! ! if (controlY < SandBoxHeight ! && controlY > this.getHeight()) ! ! { ! ! this.setLocation(this.getX() + e.getX() ! - this.getWidth() / 2, this.getY() ! + e.getY() - this.getHeight() / 2); ! ! Point position = new Point(this.getX() + e.getX(), ! this.getY() + e.getY()); ! Iterator it = vecConnectedLinks.iterator(); ! while (it.hasNext()) { ! String linkString = (String) it.next(); ! String LinkDetails[] = linkString.split(":"); ! controller.moveLink(LinkDetails[0], Integer ! .parseInt(LinkDetails[1]), position); ! } ! } } --- 755,779 ---- else { ! int controlX = this.getX() + e.getX();// + this.getWidth() / 2; ! int controlY = this.getY() + e.getY();// + this.getHeight() / 2; ! if (controlX > SandBoxWidth) controlX = SandBoxWidth; ! else if (controlX < 0) controlX = 0; ! if (controlY > SandBoxHeight) controlY = SandBoxHeight; ! else if (controlY < 0) controlY = 0; ! this.setLocation(controlX-pressedX, controlY-pressedY); ! Point position = new Point(this.getX()+this.getWidth()/2, this.getY()+this.getHeight()/2); ! Iterator<String> it = vecConnectedLinks.iterator(); ! while (it.hasNext()) { ! String linkString = it.next(); ! String LinkDetails[] = linkString.split(":"); ! controller.moveLink(LinkDetails[0], Integer ! .parseInt(LinkDetails[1]), position); } *************** *** 886,898 **** */ ! public Vector getConnectedLinks() { ! Vector linkList = new Vector(); ! Iterator it = vecConnectedLinks.iterator(); while (it.hasNext()) { ! String linkString = (String) it.next(); String LinkDetails[] = linkString.split(":"); --- 873,885 ---- */ ! public Vector<String> getConnectedLinks() { ! Vector<String> linkList = new Vector<String>(); ! Iterator<String> it = vecConnectedLinks.iterator(); while (it.hasNext()) { ! String linkString = it.next(); String LinkDetails[] = linkString.split(":"); *************** *** 921,929 **** { ! Iterator it = vecConnectedLinks.iterator(); while (it.hasNext()) { ! String linkString = (String) it.next(); String LinkDetails[] = linkString.split(":"); --- 908,916 ---- { ! Iterator<String> it = vecConnectedLinks.iterator(); while (it.hasNext()) { ! String linkString = it.next(); String LinkDetails[] = linkString.split(":"); Index: SandBox.java =================================================================== RCS file: /cvsroot/javanetsim/javaNetSim/guiUI/SandBox.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** SandBox.java 24 Oct 2008 16:18:48 -0000 1.12 --- SandBox.java 25 Oct 2008 21:33:32 -0000 1.13 *************** *** 209,213 **** this.setCursor(csrDefault); ! controller.addNode(cursorClass, new Point(e.getX(), e.getY())); cursorClass = ""; } --- 209,213 ---- this.setCursor(csrDefault); ! controller.addNode(cursorClass, new Point(e.getX()-GuiNode.NodeWidth/2, e.getY()-GuiNode.NodeHeight/2)); cursorClass = ""; } |