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

📄 elanlayoutmanager.java

📁 编辑视频文件
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        int sliderPanelX = CONTAINER_MARGIN + controlsMargin;        int sliderPanelY = controlsY;        int sliderPanelWidth = 0;        int sliderPanelHeight = 0;        if (mediaPlayerController != null) {            sliderPanelWidth = containerWidth - (2 * CONTAINER_MARGIN) -                (2 * controlsMargin);            sliderPanelHeight = mediaPlayerController.getSliderPanel()                                                     .getPreferredSize().height;            mediaPlayerController.getSliderPanel().setBounds(sliderPanelX,                sliderPanelY, sliderPanelWidth, sliderPanelHeight);        }        int timePanelX = 0;        int timePanelY = sliderPanelY + sliderPanelHeight + componentMargin;        int timePanelWidth = 0;        int timePanelHeight = 0;        if ((mediaPlayerController != null) && syncManager.connectedPlayers()) {            // time panel can be removed by SyncManager            if (!containsComponent(mediaPlayerController.getTimePanel())) {                container.add(mediaPlayerController.getTimePanel());            }            timePanelX = (containerWidth / 2) -                (mediaPlayerController.getTimePanel().getPreferredSize().width / 2);            timePanelWidth = mediaPlayerController.getTimePanel()                                                  .getPreferredSize().width;            timePanelHeight = mediaPlayerController.getTimePanel()                                                   .getPreferredSize().height;            mediaPlayerController.getTimePanel().setBounds(timePanelX,                timePanelY, timePanelWidth, timePanelHeight);        }        int playButtonsX = 0;        int playButtonsY = timePanelY + 40;        int playButtonsWidth = 0;        int playButtonsHeight = 0;        if (mediaPlayerController != null) {            playButtonsX = (containerWidth / 2) -                (mediaPlayerController.getPlayButtonsPanel().getPreferredSize().width / 2);            playButtonsWidth = mediaPlayerController.getPlayButtonsPanel()                                                    .getPreferredSize().width;            playButtonsHeight = mediaPlayerController.getPlayButtonsPanel()                                                     .getPreferredSize().height;            // adjust the position to prevent overlap with the player selection panel            if (playButtonsX < (sliderPanelX + playerSelectionWidth +                    componentMargin)) {                playButtonsX = sliderPanelX + playerSelectionWidth +                    componentMargin;                int adjTimePanelX = playButtonsX +                    ((playButtonsWidth - timePanelWidth) / 2);                mediaPlayerController.getTimePanel().setBounds(adjTimePanelX,                    timePanelY, timePanelWidth, timePanelHeight);            }            mediaPlayerController.getPlayButtonsPanel().setBounds(playButtonsX,                playButtonsY, playButtonsWidth, playButtonsHeight);        }        int playerSelectionX = playButtonsX - playerSelectionWidth -            componentMargin;        if (playerSelectionX < sliderPanelX) {            playerSelectionX = sliderPanelX;        }        int playerSelectionY = timePanelY;        syncManager.getPlayerSelectionPanel().setBounds(playerSelectionX,            playerSelectionY, playerSelectionWidth, playerSelectionHeight);        container.validate();        container.repaint();    }    /**     * Show the layout for media players and elan viewers     */    private void doNormalLayout() {        // get the width and height of the usable area        int containerWidth = container.getWidth();        int containerHeight = container.getHeight();        int containerMargin = 3;        int componentMargin = 5;        PlayerLayoutModel[] visualPlayers = getAttachedVisualPlayers();        int numVisualPlayers = visualPlayers.length;        // first layout the player components, next the tabpane        int visibleMediaX = containerMargin;        int visibleMediaY = containerMargin;        int visibleMediaWidth = 0;        int visibleMediaHeight = 0;        int firstMediaWidth = visibleMediaWidth;        if (numVisualPlayers == 0) {            visibleMediaHeight = MASTER_MEDIA_HEIGHT;        }        if (numVisualPlayers >= 1) {            // layout the first video            Component firstVisualComp = visualPlayers[0].visualComponent;            float aspectRatio = visualPlayers[0].player.getAspectRatio();            firstMediaWidth = MASTER_MEDIA_WIDTH;            // jan 2007 if the source- or encoded-width of the video is more than twice the MASTER_            // MEDIA_WIDTH constant, then divide the real source width by 2 for optimal rendering            if (visualPlayers[0].player.getSourceWidth() > (2 * MASTER_MEDIA_WIDTH)) {                firstMediaWidth = visualPlayers[0].player.getSourceWidth() / 2;                //System.out.println("adj. width: " + firstMediaWidth);            }            int firstMediaHeight = (int) ((float) firstMediaWidth / aspectRatio);            if (firstMediaHeight < MASTER_MEDIA_HEIGHT) {                firstMediaHeight = MASTER_MEDIA_HEIGHT;                firstMediaWidth = (int) (firstMediaHeight * aspectRatio);                //System.out.println("height: " + firstMediaHeight + " width: " + firstMediaWidth);            }            firstVisualComp.setBounds(visibleMediaX, visibleMediaY,                firstMediaWidth, firstMediaHeight);            visibleMediaWidth = firstMediaWidth + componentMargin;            visibleMediaHeight = firstMediaHeight;            //System.out.println("width: " + firstMediaWidth + " height: " + firstMediaHeight);        }        if (numVisualPlayers == 2) {            Component secondVisualComp = visualPlayers[1].visualComponent;            float aspectRatio = visualPlayers[1].player.getAspectRatio();            int secondMediaWidth = (int) (visibleMediaHeight * aspectRatio);            int secondMediaHeight = visibleMediaHeight;            if ((visualPlayers[1].player.getSourceWidth() > (2 * MASTER_MEDIA_WIDTH)) &&                    (visualPlayers[1].player.getSourceWidth() > visualPlayers[0].player.getSourceWidth())) {                secondMediaWidth = visualPlayers[1].player.getSourceWidth() / 2;                secondMediaHeight = (int) ((float) secondMediaWidth / aspectRatio);                if (secondMediaHeight > visibleMediaHeight) {                    visibleMediaHeight = secondMediaHeight;                }            }            secondVisualComp.setBounds(visibleMediaX + visibleMediaWidth,                visibleMediaY, secondMediaWidth, secondMediaHeight);            visibleMediaWidth += (secondMediaWidth + componentMargin);            //System.out.println("sec width: " + secondMediaWidth + " sec height: " + secondMediaHeight);        } else if (numVisualPlayers == 3) {            Component secondVisualComp = visualPlayers[1].visualComponent;            float secondAR = visualPlayers[1].player.getAspectRatio();            Component thirdVisualComp = visualPlayers[2].visualComponent;            float thirdAR = visualPlayers[2].player.getAspectRatio();            int heightPerPlayer = (visibleMediaHeight - componentMargin) / 2;            int secondWidth = (int) (secondAR * heightPerPlayer);            int thirdWidth = (int) (thirdAR * heightPerPlayer);            int widthPerPlayer = Math.max(secondWidth, thirdWidth);            secondVisualComp.setBounds(visibleMediaX + visibleMediaWidth +                ((widthPerPlayer - secondWidth) / 2), visibleMediaY,                secondWidth, heightPerPlayer);            thirdVisualComp.setBounds(visibleMediaX + visibleMediaWidth +                ((widthPerPlayer - thirdWidth) / 2),                visibleMediaY + heightPerPlayer + componentMargin, thirdWidth,                heightPerPlayer);            visibleMediaWidth += (widthPerPlayer + componentMargin);        } else if (numVisualPlayers == 4) {            Component secondVisualComp = visualPlayers[1].visualComponent;            float secondAR = visualPlayers[1].player.getAspectRatio();            Component thirdVisualComp = visualPlayers[2].visualComponent;            float thirdAR = visualPlayers[2].player.getAspectRatio();            Component fourthVisualComp = visualPlayers[3].visualComponent;            float fourthAR = visualPlayers[3].player.getAspectRatio();            int heightPerPlayer = (visibleMediaHeight - (2 * componentMargin)) / 3;            int secondWidth = (int) (secondAR * heightPerPlayer);            int thirdWidth = (int) (thirdAR * heightPerPlayer);            int fourthWidth = (int) (fourthAR * heightPerPlayer);            int widthPerPlayer = Math.max(secondWidth, thirdWidth);            widthPerPlayer = Math.max(widthPerPlayer, fourthWidth);            secondVisualComp.setBounds(visibleMediaX + visibleMediaWidth +                ((widthPerPlayer - secondWidth) / 2), visibleMediaY,                secondWidth, heightPerPlayer);            thirdVisualComp.setBounds(visibleMediaX + visibleMediaWidth +                ((widthPerPlayer - thirdWidth) / 2),                visibleMediaY + heightPerPlayer + componentMargin, thirdWidth,                heightPerPlayer);            fourthVisualComp.setBounds(visibleMediaX + visibleMediaWidth +                ((widthPerPlayer - fourthWidth) / 2),                visibleMediaY + (2 * heightPerPlayer) + (2 * componentMargin),                fourthWidth, heightPerPlayer);            visibleMediaWidth += (widthPerPlayer + componentMargin);        }        // layout the tab panel        int tabPaneX = visibleMediaX + visibleMediaWidth;        int tabPaneY = visibleMediaY;        int tabPaneWidth = containerWidth - tabPaneX;        int tabPaneHeight = visibleMediaHeight;        if (tabPane != null) {            tabPane.setBounds(tabPaneX, tabPaneY, tabPaneWidth, tabPaneHeight);            if ((mediaPlayerController != null) && (controlPanel != null)) {                controlPanel.setSize(tabPaneWidth, tabPaneHeight);            }        }        int timePanelX = 0;        int timePanelY = visibleMediaY + visibleMediaHeight + 2;        int timePanelWidth = 0;        int timePanelHeight = 0;        if (mediaPlayerController != null) {            timePanelWidth = mediaPlayerController.getTimePanel()                                                  .getPreferredSize().width;            timePanelHeight = mediaPlayerController.getTimePanel()                                                   .getPreferredSize().height;            if (numVisualPlayers == 0) {                timePanelX = containerMargin;            } else {                timePanelX = (containerMargin + (firstMediaWidth / 2)) -                    (timePanelWidth / 2);            }            mediaPlayerController.getTimePanel().setBounds(timePanelX,                timePanelY, timePanelWidth, timePanelHeight);        }        int playButtonsX = CONTAINER_MARGIN;        int playButtonsY = timePanelY + timePanelHeight + 4;        int playButtonsWidth = 0;        int playButtonsHeight = 0;        if (mediaPlayerController != null) {            playButtonsWidth = mediaPlayerController.getPlayButtonsPanel()                                                    .getPreferredSize().width;            playButtonsHeight = mediaPlayerController.getPlayButtonsPanel()                                                     .getPreferredSize().height;            if (numVisualPlayers > 0) {                playButtonsX = (containerMargin + (firstMediaWidth / 2)) -                    (playButtonsWidth / 2);                if (playButtonsX < CONTAINER_MARGIN) {                    playButtonsX = CONTAINER_MARGIN;                }            }            mediaPlayerController.getPlayButtonsPanel().setBounds(playButtonsX,                playButtonsY, playButtonsWidth, playButtonsHeight);        }        int selectionPanelX = playButtonsX + playButtonsWidth + 20;        int selectionPanelY = visibleMediaY + visibleMediaHeight + 2;        int selectionPanelWidth = 0;        int selectionPanelHeight = 0;        if (mediaPlayerController != null) {            selectionPanelWidth = 100 +                mediaPlayerController.getSelectionPanel().getPreferredSize().width;            selectionPanelHeight = mediaPlayerController.getSelectionPanel()                                                        .getPreferredSize().height;            mediaPlayerController.getSelectionPanel().setBounds(selectionPanelX,                selectionPanelY, selectionPanelWidth, selectionPanelHeight);        }        int selectionButtonsX = selectionPanelX;        int selectionButtonsY = selectionPanelY + selectionPanelHeight + 4;        int selectionButtonsWidth = 0;        int selectionButtonsHeight = 0;        if (mediaPlayerController != null) {            selectionButtonsWidth = mediaPlayerController.getSelectionButtonsPanel()                                                         .getPreferredSize().width;            selectionButtonsHeight = mediaPlayerController.getSelectionButtonsPanel()                                                          .getPreferredSize().height;            mediaPlayerController.getSelectionButtonsPanel().setBounds(selectionButtonsX,                selectionButtonsY, selectionButtonsWidth, selectionButtonsHeight);        }        int annotationButtonsX = selectionButtonsX + selectionButtonsWidth +            15;        int annotationButtonsY = selectionPanelY + selectionPanelHeight + 4;        int annotationButtonsWidth = 0;        int annotationButtonsHeight = 0;        if (mediaPlayerController != null) {            annotationButtonsWidth = mediaPlayerController.getAnnotationNavigationPanel()                                                          .getPreferredSize().width;            annotationButtonsHeight = mediaPlayerController.getAnnotationNavigationPanel()                                                           .getPreferredSize().height;            mediaPlayerController.getAnnotationNavigationPanel().setBounds(annotationButtonsX,                annotationButtonsY, annotationButtonsWidth,                annotationButtonsHeight);        }        int modePanelX = annotationButtonsX + annotationButtonsWidth + 10;        int modePanelY = annotationButtonsY - 1;        int modePanelWidth = 0;        int modePanelHeight = 0;        if (mediaPlayerController != null) {            modePanelWidth = 300; //mediaPlayerController.getModePanel().getPreferredSize().width;            modePanelHeight = mediaPlayerController.getModePanel()                                                   .getPreferredSize().height;            mediaPlayerController.getModePanel().setBounds(modePanelX,                modePanelY, modePanelWidth, modePanelHeight);        }        int sliderPanelX = CONTAINER_MARGIN;        int sliderPanelY = playButtonsY + playButtonsHeight;        int sliderPanelWidth = 0;        int sliderPanelHeight = 0;        if (mediaPlayerController != null) {            sliderPanelWidth = containerWidth - (2 * CONTAINER_MARGIN);            sliderPanelHeight = mediaPlayerController.getSliderPanel()                                                     .getPreferredSize().height;            mediaPlayerController.getSliderPanel().setBounds(sliderPanelX,                sliderPanelY, sliderPanelWidth, sliderPanelHeight);        }        int densityPanelX = CONTAINER_MARGIN;        int densityPanelY = sliderPanelY + componentMargin; //sliderPanelHeight;        int densityPanelWidth = sliderPanelWidth;        int densityPanelHeight = 0;        if (mediaPlayerController != null) {            densityPanelHeight = mediaPlayerController.getAnnotationDensityViewer()                                                      .getPreferredSize().height;            mediaPlayerController.getAnnotationDensityViewer().setBounds(densityPanelX,                densityPanelY, densityPanelWidth, densityPanelHeight);        }        // layout time line split pane        int timeLineSplitPaneX = CONTAINER_MARGIN;        int timeLineSplitPaneY = densityPanelY + densityPanelHeight + 4;        int timeLineSplitPaneWidth = 0;        int timeLineSplitPaneHeight = 0;        if (timeLineSplitPane != null) {            timeLineSplitPaneWidth = containerWidth - (2 * CONTAINER_MARGIN);            timeLineSplitPaneHeight = containerHeight - timeLineSplitPaneY;            timeLineSplitPane.setBounds(timeLineSplitPaneX, timeLineSplitPaneY,                timeLineSplitPaneWidth, timeLineSplitPaneHeight);        }        // layout time line pane        int multiTierControlX = 0;        int multiTierControlY = 0;        int multiTierControlWidth = 0;        int multiTierControlHeight = 0;        int timeLineX = 0;        int timeLineY = 0;        int timeLineWidth = 0;        int timeLineHeight = 0;

⌨️ 快捷键说明

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