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

📄 elanlayoutmanager.java

📁 编辑视频文件
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    private JSplitPane getTimeLineSplitPane() {        if (timeLineSplitPane == null) {            timeLineSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);            timeLineSplitPane.setOneTouchExpandable(true);            // HS 24 nov set the divider location when a top component is added            timeLineSplitPane.setDividerLocation(0);            timeLineSplitPane.setContinuousLayout(true);            container.add(timeLineSplitPane);        }        return timeLineSplitPane;    }    private void addSingleTierViewer(SingleTierViewer viewer) {        SingleTierViewerPanel panel = viewerManager.createSingleTierViewerPanel();        panel.setViewer(viewer);        if (viewer instanceof GridViewer) {            gridPanel = panel;            addToTabPane(ElanLocale.getString("Tab.Grid"), panel);        } else if (viewer instanceof TextViewer) {            textPanel = panel;            addToTabPane(ElanLocale.getString("Tab.Text"), panel);        } else if (viewer instanceof SubtitleViewer) {            getSubtitlePanel().add(panel);        }        doLayout();    }    private JPanel getSubtitlePanel() {        if (subtitlePanel == null) {            subtitlePanel = new JPanel(new GridLayout(0, 1));            addToTabPane(ElanLocale.getString("Tab.Subtitles"), subtitlePanel);        }        return subtitlePanel;    }    private JTabbedPane getTabPane() {        if (tabPane == null) {            tabPane = new JTabbedPane();            container.add(tabPane);        }        return tabPane;    }    private void addToTabPane(String tabName, Component component) {        int index = getTabPane().getTabCount();        if ((controlPanel != null) && (component != controlPanel)) {            index = getTabPane().indexOfComponent(controlPanel);        }        getTabPane().insertTab(tabName, null, component, null, index);        /*        if (tabName != null) {        //getTabPane().add(tabName, component);        getTabPane().insertTab(tabName, null, component, null, index);        } else {        //getTabPane().add(component);        getTabPane().insertTab(tabName, null, component, null, index);        }        */        /*        // always keep controls as last tab        if (controlPanel != null) {            getTabPane().remove(controlPanel);            getTabPane().add(controlPanel, getTabPane().getTabCount());        }        */        doLayout();    }    private void removeFromTabPane(Component component) {        getTabPane().remove(component);    }    /**     * Switches to annotation layout mode.     */    public void showNormalMode() {        // if old mode == sync, then check offsets of video and extracted audio         // and warn if they are not equal and the video is not the master        if (mode == SYNC_MODE) {            checkUnequalOffsets();            for (int i = 0; i < playerList.size(); i++) {                PlayerLayoutModel plm = (PlayerLayoutModel) playerList.get(i);                if (plm.syncOnly) {                    viewerManager.destroyMediaPlayer(plm.player);                    if (plm.player.getVisualComponent() != null) {                        container.remove(plm.player.getVisualComponent());                    }                }            }        }        mode = NORMAL_MODE;        //		normalMode = true;        //		syncMode = false;        // make sure the last offset is also frozen. The call is done here        // because at this moment SyncManager is only known here        syncManager.reconnect();        // make sure the signal viewer has the right offset, again this is done        // here because all the information is available here at the right moment        if (signalViewer != null) {            signalViewer.setOffset(viewerManager.getSignalViewerOffset());        }        // time panel can be removed by SyncManager        if (!containsComponent(mediaPlayerController.getTimePanel())) {            container.add(mediaPlayerController.getTimePanel());        }        if (masterMediaPlayer != null) {            viewerManager.setMasterMediaPlayer(masterMediaPlayer);        }        viewerManager.enableDisabledMediaPlayers();        // all viewers should be disconnected but for the time being only the problematic ones        if (timeLineViewer != null) {            viewerManager.enableViewer(timeLineViewer);        }        if (signalViewer != null) {            viewerManager.enableViewer(signalViewer);        }        clearLayout();        doLayout();        // this sucks but is needed to make Swing behave properly        /*        Dimension dimension = container.getSize();        container.setSize(dimension.width - 1, dimension.height - 1);        container.setSize(dimension);        */    }    /**     * Switches to media synchronization mode.     */    public void showSyncMode() {        mode = SYNC_MODE;        // add visual component of sync_only_players        for (int i = 0; i < playerList.size(); i++) {            PlayerLayoutModel plm = (PlayerLayoutModel) playerList.get(i);            if (plm.syncOnly) {                viewerManager.addMediaPlayer(plm.player);                if (plm.player.getVisualComponent() != null) {                    container.add(plm.player.getVisualComponent());                }            }        }        viewerManager.setMasterMediaPlayer(masterMediaPlayer);        viewerManager.enableDisabledMediaPlayers();        // all currently active viewers should be disconnected        if (timeLineViewer != null) {            viewerManager.disableViewer(timeLineViewer);        }        if (signalViewer != null) {            viewerManager.disableViewer(signalViewer);        }        clearLayout();        doLayout();        // this sucks but is needed to make Swing behave properly        /*        Dimension dimension = container.getSize();        container.setSize(dimension.width - 1, dimension.height - 1);        container.setSize(dimension);        */    }    /**     * Returns the current layout mode.     *     * @return the current layout mode     */    public int getMode() {        return mode;    }    /**     * Makes sure all players are connected. Current offsets in the     * sync mode are ignored accept for the current active player.     */    public void connectAllPlayers() {        if (mode == SYNC_MODE) {            syncManager.reconnect();        }    }    /**     * Make all components invisible     */    private void clearLayout() {        Component[] components = container.getComponents();        for (int i = 0; i < components.length; i++) {            components[i].setBounds(0, 0, 0, 0);        }    }    /**     * Checks the layout Mode flag and calls either doNormalLayout() or     * doSyncLayout().     */    public void doLayout() {        if (mode == NORMAL_MODE) {            doNormalLayout();        } else if (mode == SYNC_MODE) {            doSyncLayout();        }    }    /**     * Show the layout for synchronizing two or more video and audio players.     */    private void doSyncLayout() {        // get the width and height of the usable area        int containerWidth = container.getWidth();        int containerHeight = container.getHeight();        int containerMargin = 3;        int componentMargin = 5;        int controlsMargin = 20;        int labelHeight = 20;        if (playerList.size() > 0) {            for (int i = 0; i < playerList.size(); i++) {                PlayerLayoutModel m = (PlayerLayoutModel) playerList.get(i);                Dimension prefSize = syncManager.getPlayerLabel(m.player)                                                .getPreferredSize();                if (prefSize.height > labelHeight) {                    labelHeight = prefSize.height;                }            }        }        // initialize some fields        int playerSelectionWidth = 130;        int playerSelectionHeight = 70;        Dimension playerSelectionSize = syncManager.getPlayerSelectionPanel()                                                   .getPreferredSize();        playerSelectionWidth = Math.max(playerSelectionWidth,                playerSelectionSize.width);        playerSelectionHeight = Math.max(playerSelectionHeight,                playerSelectionSize.height);        int controlsHeight = (2 * componentMargin) +            mediaPlayerController.getSliderPanel().getPreferredSize().height +            playerSelectionHeight;        int totalPlayerWidth = containerWidth - (2 * containerMargin);        int totalPlayerHeight = containerHeight - containerMargin -            controlsHeight;        int[] colrow = getNumberOfColumnsAndRows(totalPlayerWidth,                totalPlayerHeight, labelHeight, playerList.size());        // conditionally layout players	        int mediaY = containerMargin;        int mediaX = containerMargin;        if ((colrow[0] > 0) && (colrow[1] > 0)) {            int maxMediaWidth = (totalPlayerWidth / colrow[0]) -                componentMargin;            int maxMediaHeight = (totalPlayerHeight / colrow[1]) - labelHeight -                componentMargin;            if ((maxMediaWidth > 0) && (maxMediaHeight > 0)) {                int playerIndex = 0;                // layout per row                for (int i = 0; i < colrow[1]; i++) {                    mediaY += (i * (maxMediaHeight + labelHeight));                    for (int j = 0; j < colrow[0]; j++) {                        PlayerLayoutModel model = null;                        ElanMediaPlayer player = null;                        if (playerIndex < playerList.size()) {                            model = (PlayerLayoutModel) playerList.get(playerIndex);                            player = model.player;                        }                        Component label = syncManager.getPlayerLabel(player);                        int curX = mediaX +                            (j * (maxMediaWidth + componentMargin));                        int curY = mediaY;                        int curW = maxMediaWidth;                        int curH = maxMediaHeight;                        if (label != null) {                            Dimension prefLabelSize = label.getPreferredSize();                            if (prefLabelSize.width <= maxMediaWidth) {                                label.setBounds(curX, curY + curH, curW,                                    labelHeight);                            } else {                                label.setBounds(0, 0, 0, 0);                            }                        }                        Component videoComp = null;                        float aspectRatio = 1.0f;                        if (model.syncOnly) {                            videoComp = model.player.getVisualComponent();                            aspectRatio = model.player.getAspectRatio();                        } else if (model.isVisual() && model.isAttached()) {                            videoComp = model.visualComponent;                            aspectRatio = model.player.getAspectRatio();                        }                        if (videoComp != null) {                            //Component videoComp = model.visualComponent;                            //float aspectRatio = model.player.getAspectRatio();                            curH = (int) ((float) curW / aspectRatio);                            if (curH > maxMediaHeight) {                                curH = maxMediaHeight;                                curW = (int) (curH * aspectRatio);                                curX += ((maxMediaWidth - curW) / 2);                            }                            videoComp.setBounds(curX, curY, curW, curH);                        }                        playerIndex++;                        if (playerIndex >= playerList.size()) {                            break;                        }                    }                    if (playerIndex >= playerList.size()) {                        mediaY += (maxMediaHeight + labelHeight +                        componentMargin);                        break;                    }                }            }        }        int controlsY = mediaY;

⌨️ 快捷键说明

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