1 16 package com.buchuki.ensmer.input; 17 18 import com.buchuki.ensmer.EnsmerManager; 19 import java.awt.event.MouseEvent ; 20 import com.buchuki.ensmer.input.command.*; 21 import com.buchuki.ensmer.input.event.*; 22 import com.sun.j3d.utils.picking.PickCanvas; 23 import com.sun.j3d.utils.picking.PickResult; 24 import java.awt.Point ; 25 import javax.media.j3d.Node; 26 27 33 public class Selector implements InputProcessor { 34 35 38 public Selector() { 39 CommandMap map = InputManager.getCommandMap(); 40 Command toggleSelection = 41 new Command() { 42 public boolean execute(EnsmerInputEvent event) { 43 selectionPicked(((MouseEvent ) event.getInputEvent()).getPoint()); 44 return true; 45 } 46 }; 47 48 map.addCommand(this, toggleSelection, new MousePressEvent(MouseEvent.BUTTON1)); 49 } 50 51 57 public void processInput(EnsmerInputEvent event) { 58 CommandMap map = InputManager.getCommandMap(); 59 map.interpretEvent(this, event); 60 } 61 62 68 private void selectionPicked(Point point){ 69 Long id = EnsmerManager.instance().getInterfaceManager().pickObject(point.x, point.y); 70 if (id != null) { 71 EnsmerManager.instance().getSelectionManager().toggleSelection(id); 72 } 73 } 74 } 75 76 | Popular Tags |