📄 kioskmodecommand.java
字号:
/* * File: KioskModeCommand.java * Project: MPI Linguistic Application * Date: 02 May 2007 * * Copyright (C) 2001-2007 Max Planck Institute for Psycholinguistics * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */package mpi.eudico.client.annotator.commands;import mpi.eudico.client.annotator.ElanFrame2;import mpi.eudico.client.annotator.ViewerManager2;import mpi.eudico.client.annotator.util.FrameConstants;/** * A Command to switch to and from Kisok Mode. * * @author Han Sloetjes, MPI * @version 1.0 */public class KioskModeCommand implements Command { private String commandName; private ViewerManager2 vm; /** * Creates a new KioskModeCommand instance * * @param name the name of the command */ public KioskModeCommand(String name) { commandName = name; } /** * <b>Note: </b>it is assumed the types and order of the arguments are * correct. * * @param receiver the ViewerManager * @param arguments the arguments: <ul><li>arg[0] = on or off flag * (Boolean)</li> </ul> */ public void execute(Object receiver, Object[] arguments) { vm = (ViewerManager2) receiver; boolean onOff = ((Boolean) arguments[0]).booleanValue(); if (onOff) { // start looping in Kiosk Mode, disable menu's and commands // re-use (abuse) the playingSelection flag of the controller if (vm.getMasterMediaPlayer().isPlaying()) { vm.getMasterMediaPlayer().stop(); } ElanFrame2 ef2 = (ElanFrame2) ELANCommandFactory.getRootFrame(vm.getTranscription()); ef2.enableCommands(false); enableMenus(ef2, false); vm.getMediaPlayerController().setPlaySelectionMode(true); vm.getMasterMediaPlayer().start(); new LoopThread().start(); } else { // stop Kiosk Mode, enable menu's and commands vm.getMediaPlayerController().setPlaySelectionMode(false); if (vm.getMasterMediaPlayer().isPlaying()) { vm.getMasterMediaPlayer().stop(); } ElanFrame2 ef2 = (ElanFrame2) ELANCommandFactory.getRootFrame(vm.getTranscription()); ef2.enableCommands(true); enableMenus(ef2, true); } } /** * Enables/disables the relevant menu's and menu items. * * @param ef2 the frame * @param enable the enable flag; if true all relevant menu's will be enabled */ private void enableMenus(ElanFrame2 ef2, boolean enable) { ef2.setMenuEnabled(FrameConstants.FILE, enable); ef2.setMenuEnabled(FrameConstants.EDIT, enable); ef2.setMenuEnabled(FrameConstants.ANNOTATION, enable); ef2.setMenuEnabled(FrameConstants.TIER, enable); ef2.setMenuEnabled(FrameConstants.TYPE, enable); ef2.setMenuEnabled(FrameConstants.SEARCH, enable); ef2.setMenuEnabled(FrameConstants.VIEW, enable); ef2.setMenuEnabled(FrameConstants.WINDOW, enable); ef2.setMenuEnabled(FrameConstants.HELP, enable); // now the options menu ef2.setMenuEnabled(FrameConstants.PROPAGATION, enable); ef2.setMenuEnabled(FrameConstants.ANNOTATION_MODE, enable); ef2.setMenuEnabled(FrameConstants.SYNC_MODE, enable); ef2.setMenuEnabled(FrameConstants.PLAY_AROUND_SEL, enable); ef2.setMenuEnabled(FrameConstants.RATE_VOL_TOGGLE, enable); ef2.setMenuEnabled(FrameConstants.LANG, enable); if (enable) { if (vm.getMasterMediaPlayer().isFrameRateAutoDetected()) { ef2.setMenuEnabled(FrameConstants.FRAME_LENGTH, enable); } } else { ef2.setMenuEnabled(FrameConstants.FRAME_LENGTH, enable); } } /** * Returns the name of the command. * * @return the name of the command */ public String getName() { return commandName; } /** * A thread that regularly checks if the player is still playing; when the * player has stopped (= has reached the end) it starts the player again * from the beginning. */ private class LoopThread extends Thread { /** * The actual work */ public void run() { while (vm.getMediaPlayerController().isPlaySelectionMode()) { if (!vm.getMasterMediaPlayer().isPlaying()) { vm.getMasterMediaPlayer().setMediaTime(0); vm.getMasterMediaPlayer().start(); } while (vm.getMasterMediaPlayer().isPlaying()) { try { Thread.sleep(10); } catch (Exception ex) { } } try { Thread.sleep(vm.getMediaPlayerController() .getUserTimeBetweenLoops()); } catch (Exception ex) { } } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -