⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 elanlayoutmanager.java

📁 编辑视频文件
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * File:     ElanLayoutManager.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;import mpi.eudico.client.annotator.grid.*;import mpi.eudico.client.annotator.linkedmedia.MediaDescriptorUtil;import mpi.eudico.client.annotator.player.*;import mpi.eudico.client.annotator.viewer.*;import mpi.eudico.server.corpora.clomimpl.abstr.MediaDescriptor;import java.awt.Component;import java.awt.Container;import java.awt.Dimension;import java.awt.EventQueue;import java.awt.GridLayout;import java.awt.Point;import java.awt.Rectangle;import java.awt.event.ComponentAdapter;import java.awt.event.ComponentEvent;import java.awt.event.MouseEvent;import java.util.ArrayList;import java.util.HashMap;import java.util.Iterator;import java.util.List;import javax.swing.JComponent;import javax.swing.JDialog;import javax.swing.JFrame;import javax.swing.JMenuBar;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JSplitPane;import javax.swing.JTabbedPane;import javax.swing.SwingUtilities;import javax.swing.border.EmptyBorder;import javax.swing.event.MouseInputAdapter;/** * Takes care of layout in an ElanFrame */public class ElanLayoutManager implements ElanLocaleListener {    /* Note: when more modi are added, SyncModeCA should be adapted */    /** sync layout mode */    public final static int SYNC_MODE = 0;    /** normal layout mode */    public final static int NORMAL_MODE = 1;    /** the default width for the first video */    private final static int MASTER_MEDIA_WIDTH = 352;    /** the minimum height for the first video and the tabpane */    private final static int MASTER_MEDIA_HEIGHT = 250;    /** outer content pane margin */    private final static int CONTAINER_MARGIN = 3;    /** the default height of the signalviewer */    private final static int DEF_SIGNAL_HEIGHT = 70;    private ElanFrame2 elanFrame;    private Container container;    private ViewerManager2 viewerManager;    private int mode;    //	private boolean normalMode; // can/should? be done with a mode parameter    //	private boolean syncMode;    private boolean showTimeLineViewer;    private boolean showInterlinearViewer;    // temp permanent detached flag    private boolean permanentDetached;    // media players    private ElanMediaPlayer masterMediaPlayer;    //private ElanMediaPlayer mediaPlayer2;    // a list of player layout info objects    private List playerList;    private ElanMediaPlayerController mediaPlayerController;    private SyncManager syncManager;    private SignalViewer signalViewer;    private JComponent signalComponent;    private TimeLineViewer timeLineViewer;    private InterlinearViewer interlinearViewer;    private TimeSeriesViewer timeseriesViewer;    private JPanel timeLineComponent;    private MultiTierControlPanel multiTierControlPanel;    private JSplitPane timeLineSplitPane;    //	private JSplitPane mediaTabSplitPane;    private JTabbedPane tabPane;    private JPanel gridPanel;    private JPanel textPanel;    private JPanel subtitlePanel;    private JPanel controlPanel;    private Component glasspane;    /**     * DOCUMENT ME!     *     * @param elanFrame the content pane of the ElanFrame     * @param viewerManager DOCUMENT ME!     */    public ElanLayoutManager(ElanFrame2 elanFrame, ViewerManager2 viewerManager) {        this.elanFrame = elanFrame;        this.container = elanFrame.getContentPane();        this.viewerManager = viewerManager;        playerList = new ArrayList(8);        // listen to locale changes        ElanLocale.addElanLocaleListener(viewerManager.getTranscription(), this);        // no java LayoutManager, we take care of it ourselves        container.setLayout(null);        // listen for ComponentEvents on the Container        container.addComponentListener(new ContainerComponentListener());        mode = NORMAL_MODE;        //		normalMode = true;        //		syncMode = false;        showTimeLineViewer = true;        controlPanel = new JPanel();        controlPanel.setName(ElanLocale.getString("Tab.Controls"));        //controlPanel.setLayout(null);        controlPanel.setLayout(new GridLayout(2, 1, 10, 10));        controlPanel.setBorder(new EmptyBorder(10, 10, 10, 10));        glasspane = elanFrame.getGlassPane();        //MouseHandler mh = new MouseHandler();        //       glasspane.addMouseListener(mh);        //       glasspane.addMouseMotionListener(mh);        //       glasspane.setVisible(true);        // The sync manager is created here because all viewers that are added to        // this layout manager must also be added to the sync manager for a useable        // sync layout mode.        syncManager = new SyncManager(viewerManager, this);        // initially attached, temp from here        // temporary code to allow permanent detached mode until swapping is possible on the mac        Boolean permDetached = (Boolean) Preferences.get("PreferredMediaWindow",                null);        if (permDetached == null) {            permDetached = new Boolean(false); // default usage is attached media window        }        permanentDetached = permDetached.booleanValue();        if (!System.getProperty("os.name").startsWith("Mac OS")) {            permanentDetached = false;        }        // end temp    }    /*     *     */    public void updateLocale() {        if (tabPane != null) {            int nTabs = tabPane.getTabCount();            for (int i = 0; i < nTabs; i++) {                Component component = tabPane.getComponentAt(i);                if (component == gridPanel) {                    tabPane.setTitleAt(i, ElanLocale.getString("Tab.Grid"));                } else if (component == textPanel) {                    tabPane.setTitleAt(i, ElanLocale.getString("Tab.Text"));                } else if (component == subtitlePanel) {                    tabPane.setTitleAt(i, ElanLocale.getString("Tab.Subtitles"));                } else if (component == controlPanel) {                    tabPane.setTitleAt(i, ElanLocale.getString("Tab.Controls"));                }            }        }        if (syncManager != null) {            syncManager.updateLocale();            if (mode == SYNC_MODE) {                doLayout();            }        }    }    /**     * Make an object visible in the layout.     *     * @param object     */    public void add(Object object) {        if (object instanceof ElanMediaPlayer) {            addMediaPlayer((ElanMediaPlayer) object);        } else if (object instanceof ElanMediaPlayerController) {            setMediaPlayerController((ElanMediaPlayerController) object);        } else if (object instanceof SignalViewer) {            setSignalViewer((SignalViewer) object);        } else if (object instanceof TimeLineViewer) {            setTimeLineViewer((TimeLineViewer) object);        } else if (object instanceof InterlinearViewer) {            setInterlinearViewer((InterlinearViewer) object);        } else if (object instanceof GridViewer) {            addSingleTierViewer((SingleTierViewer) object);        } else if (object instanceof TextViewer) {            addSingleTierViewer((SingleTierViewer) object);        } else if (object instanceof SubtitleViewer) {            addSingleTierViewer((SingleTierViewer) object);        } else if (object instanceof mpi.eudico.p2p.CollaborationPanel) {            addToTabPane("P2P", (Component) object);        } else if (object instanceof TimeSeriesViewer) {            setTimeSeriesViewer((TimeSeriesViewer) object);        }    }    /**     * Remove an object from the layout.     *     * @param object     */    public void remove(Object object) {        if (object instanceof ElanMediaPlayer) {            removeMediaPlayer((ElanMediaPlayer) object);        } else if (object instanceof SignalViewer) {            removeSignalViewer();        } else if (object instanceof mpi.eudico.p2p.CollaborationPanel) {            removeFromTabPane((Component) object);        }    }    /**     * Make an object invisible in the layout.     *     * @param object     */    public void hide(Object object) {    }    // needed by sync master, not so nice    public ElanMediaPlayer getMasterMediaPlayer() {        return masterMediaPlayer;    }    /**     * Add a mediaplayer to the layout- and syncmanager.     * Before adding/removing a player while in sync mode be sure that all players     * are connected by calling connectAllPlayers.     *     * @see #connectAllPlayers()     * @param player the player to add     */    private void addMediaPlayer(ElanMediaPlayer player) {        if (player == null) {            return; //cannot happen now        }        if (player instanceof SyncPlayer) {            player.setLayoutManager(this); //??            PlayerLayoutModel plModel = new PlayerLayoutModel(player);            plModel.syncOnly = true;            playerList.add(plModel);            syncManager.add(player);            container.add(syncManager.getPlayerLabel(player));            if (mode == SYNC_MODE) {                doLayout();            }            return;        }        player.setLayoutManager(this);        PlayerLayoutModel plModel = new PlayerLayoutModel(player);        playerList.add(plModel);        // should we check whether the player already has been added before??        if (permanentDetached) {            plModel.detach();        }        int nextIndex = playerList.size();        syncManager.add(player);        container.add(syncManager.getPlayerLabel(player));        if (plModel.isVisual() && plModel.isAttached()) {            container.add(plModel.visualComponent);        }        if (!containsComponent(syncManager.getPlayerSelectionPanel())) {            container.add(syncManager.getPlayerSelectionPanel());        }        if (nextIndex == 1) {            masterMediaPlayer = player;        }        doLayout(); // maybe call from the outside    }    /**     * Removes a player from the layout and syncmanager.     * Before adding/removing a player while in sync mode be sure that all players     * are connected by calling connectAllPlayers.     *     * @see #connectAllPlayers()     * @param player the player to remove     */    private void removeMediaPlayer(ElanMediaPlayer player) {        if (player == null) {            return;        }        PlayerLayoutModel plModel = null;        int index = -1;        for (int i = 0; i < playerList.size(); i++) {            plModel = (PlayerLayoutModel) playerList.get(i);            if (plModel.player == player) {                index = i;                break;            }        }        if (plModel == null) {            return;        }        if (player instanceof SyncPlayer) {            if (playerList.remove(plModel)) {                container.remove(syncManager.getPlayerLabel(plModel.player));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -