Class: MainKeyListener
- Inherits:
-
Object
- Object
- MainKeyListener
- Includes:
- AppKeyListener
- Defined in:
- lib/app/simple_controller.rb
Instance Method Summary collapse
-
#initialize(controller) ⇒ MainKeyListener
constructor
A new instance of MainKeyListener.
- #keyPressed(event) ⇒ Object
- #keyTyped(event) ⇒ Object
Methods included from AppKeyListener
Constructor Details
#initialize(controller) ⇒ MainKeyListener
Returns a new instance of MainKeyListener.
251 252 253 |
# File 'lib/app/simple_controller.rb', line 251 def initialize(controller) @controller = controller end |
Instance Method Details
#keyPressed(event) ⇒ Object
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/app/simple_controller.rb', line 255 def keyPressed(event) case event.getKeyCode when KeyEvent::VK_RIGHT if event.isShiftDown @controller.rotate_layout_right else @controller.move_layout_right end when KeyEvent::VK_LEFT if event.isShiftDown @controller.rotate_layout_left else @controller.move_layout_left end when KeyEvent::VK_UP @controller.move_layout_up when KeyEvent::VK_DOWN @controller.move_layout_down end end |
#keyTyped(event) ⇒ Object
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
# File 'lib/app/simple_controller.rb', line 276 def keyTyped(event) case event.key_char.chr when 'a' @controller.add_node when 'c' @controller.count_nodes when 'd' @controller.del_node when 'u' @controller.del_edge when 'e' @controller.add_edge when 'n' @controller.new_graph when 'g' @controller.choose_generator when 'l' @controller.choose_layout when 'r' @controller.do_layout when 'i' @controller.toggle_paint_iterations when 's' @controller.select_nodes when 'm' @controller.move_node when 'p' @controller.shortest_path when 't' @controller.shortest_tree when 't' @controller.choose_graph_type when 'x' @controller.center_x when 'y' @controller.center_y end end |