@Override public void disconnect() { stop(); landing(); manager.close(); if (videoManager != null) videoManager.close(); if (navdataManager != null) navdataManager.close(); }
/** connect video */ @Override public boolean connectVideo() { if (inetaddr == null) { inetaddr = getInetAddress(ipaddr); } videoManager = new VideoManager(inetaddr, manager); videoManager.setImageListener( new ImageListener() { @Override public void imageUpdated(BufferedImage image) { if (imageListener != null) { imageListener.imageUpdated(image); } } }); return videoManager.connect(ARDroneUtils.VIDEO_PORT); }
public CCPanel(final ARDrone ardrone) { super(new GridBagLayout()); setBackground(Color.BLUE); video = new VideoPanel(ardrone); battery = new BatteryPanel(); state = new StatePanel(); attitude = new AttitudePanel(); add( video, new GridBagConstraints( 0, 0, 1, 1, 0.7, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); add( new JScrollPane(state), new GridBagConstraints( 1, 0, 1, 2, 0.3, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 0), 0, 0)); add( attitude.getPane(), new GridBagConstraints( 0, 1, 1, 1, 1, 1, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); // add(battery, new GridBagConstraints(0, 1, 1, 1, 1, 1, // GridBagConstraints.FIRST_LINE_START, GridBagConstraints.BOTH, new // Insets(0,0,0,0), 0, 0)); // CommandManager handles (keyboard) input and dispatches events to the // drone System.out.println("CCPanel.KeyEventDispatcher: grab the whole keyboard input from now on ..."); KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager(); manager.addKeyEventDispatcher( new KeyEventDispatcher() { private KeyboardCommandManager cmdManager = new KeyboardCommandManager(ardrone, 45); public boolean dispatchKeyEvent(KeyEvent e) { if (e.getID() == KeyEvent.KEY_PRESSED) { cmdManager.keyPressed(e); } else if (e.getID() == KeyEvent.KEY_RELEASED) { cmdManager.keyReleased(e); } return true; } }); VideoManager vm = ardrone.getVideoManager(); vm.setImageListener(this); NavDataManager m = ardrone.getNavDataManager(); m.setStateListener(this); m.setAttitudeListener(this); m.setBatteryListener(this); }