Class: DelEdgeMouseListener
- Inherits:
-
Object
- Object
- DelEdgeMouseListener
- Includes:
- AppMouseListener
- Defined in:
- lib/app/simple_controller.rb
Instance Method Summary collapse
-
#initialize(controller) ⇒ DelEdgeMouseListener
constructor
A new instance of DelEdgeMouseListener.
- #mousePressed(event) ⇒ Object
- #mouseReleased(event) ⇒ Object
Methods included from AppMouseListener
#mouseClicked, #mouseEntered, #mouseExited
Constructor Details
#initialize(controller) ⇒ DelEdgeMouseListener
Returns a new instance of DelEdgeMouseListener.
366 367 368 |
# File 'lib/app/simple_controller.rb', line 366 def initialize(controller) @controller = controller end |
Instance Method Details
#mousePressed(event) ⇒ Object
370 371 372 373 374 375 376 377 378 379 380 381 |
# File 'lib/app/simple_controller.rb', line 370 def mousePressed(event) if (!@first) @first = @controller.model.get_nearest_node(event.x, event.y) @controller.model.click(@first) else @second = @controller.model.get_nearest_node(event.x, event.y) @controller.model.click(@second) @controller.model.click(@first) @edge = @controller.model.get_edge(@first, @second) @controller.model.click_edge(@edge) if @edge end end |
#mouseReleased(event) ⇒ Object
383 384 385 386 387 388 389 390 391 |
# File 'lib/app/simple_controller.rb', line 383 def mouseReleased(event) @controller.model.unclick(@first) if @first if @second @controller.view.remove_mouse_listener(self) @controller.model.unclick(@second) @controller.model.unclick_edge(@edge) if @edge @controller.model.del_edge(@edge) if @edge end end |