📄 elanlayoutmanager.java
字号:
int interlinearX = 0; int interlinearY = 0; int interlinearWidth = 0; int interlinearHeight = 0; if (timeLineComponent != null) { int bottomHeight = timeLineSplitPane.getHeight() - timeLineSplitPane.getDividerLocation() - timeLineSplitPane.getDividerSize(); multiTierControlWidth = multiTierControlPanel.getWidth(); multiTierControlHeight = bottomHeight; //timeLineComponent.getHeight(); multiTierControlPanel.setBounds(multiTierControlX, multiTierControlY, multiTierControlWidth, multiTierControlHeight); if (showTimeLineViewer) { timeLineX = multiTierControlWidth; //timeLineWidth = timeLineComponent.getWidth() - multiTierControlWidth; timeLineWidth = timeLineSplitPane.getWidth() - multiTierControlWidth; timeLineHeight = bottomHeight; //timeLineComponent.getHeight(); } else { interlinearX = multiTierControlWidth; //interlinearWidth = timeLineComponent.getWidth() - multiTierControlWidth; interlinearWidth = timeLineSplitPane.getWidth() - multiTierControlWidth; interlinearHeight = bottomHeight; //timeLineComponent.getHeight(); } if (timeLineViewer != null) { timeLineViewer.setBounds(timeLineX, timeLineY, timeLineWidth, timeLineHeight); timeLineViewer.setPreferredSize(new Dimension(timeLineWidth, timeLineHeight)); // force a component event on the viewer, does not happen automatically apparently timeLineViewer.componentResized(null); } if (interlinearViewer != null) { interlinearViewer.setBounds(interlinearX, interlinearY, interlinearWidth, interlinearHeight); interlinearViewer.setPreferredSize(new Dimension( interlinearWidth, interlinearHeight)); // force a component event on the viewer, does not happen automatically apparently interlinearViewer.componentResized(null); } } // layout signal pane int signalX = multiTierControlWidth; int signalY = 0; int signalWidth = 0; int signalHeight = 0; if ((signalComponent != null) && (signalViewer != null)) { int rMargin = 0; if (timeLineViewer != null) { rMargin = timeLineViewer.getRightMargin(); } // signalWidth = signalComponent.getWidth() - multiTierControlWidth - rMargin; signalWidth = timeLineSplitPane.getWidth() - multiTierControlWidth - rMargin; signalHeight = signalComponent.getHeight(); signalViewer.setBounds(signalX, signalY, signalWidth, signalHeight); signalComponent.setPreferredSize(new Dimension(signalWidth, signalHeight)); } if (timeLineSplitPane != null) { timeLineSplitPane.resetToPreferredSizes(); } // layout control panel components /* if (mediaPlayerController != null) { int vX = 10; int vY = 30; int vWidth = controlPanel.getWidth() - (2 * vX); int vHeight = mediaPlayerController.getVolumePanel() .getPreferredSize().height; mediaPlayerController.getVolumePanel().setBounds(vX, vY, vWidth, vHeight); int rX = 10; int rY = vY + vHeight + 10; int rWidth = controlPanel.getWidth() - (2 * vX); //mediaPlayerController.getRatePanel().getPreferredSize().width; int rHeight = mediaPlayerController.getRatePanel().getPreferredSize().height; mediaPlayerController.getRatePanel().setBounds(rX, rY, rWidth, rHeight); } */ container.validate(); } /** * Helper class to detect if a Component is added to the content pane of * the Elan frame. * * @param component the component that is looked for in the content pane * * @return boolean to tell if the component was found */ private boolean containsComponent(Component component) { Component[] components = container.getComponents(); for (int i = 0; i < components.length; i++) { if (components[i] == component) { return true; } } return false; } /** * Returns the players that have a visual component and are attached. * The player that is denoted to be displayed first (largest) is inserted * as the first element in the array. * * @return an array of PlayerLayoutModel objects. */ private PlayerLayoutModel[] getAttachedVisualPlayers() { List plList = new ArrayList(playerList.size()); PlayerLayoutModel model = null; for (int i = 0; i < playerList.size(); i++) { model = (PlayerLayoutModel) playerList.get(i); if (model.isVisual() && model.isAttached()) { if (model.isDisplayedFirst()) { plList.add(0, model); } else { plList.add(model); } } } return (PlayerLayoutModel[]) plList.toArray(new PlayerLayoutModel[] { }); } /** * Calculates the optimal combination of number of columns and number of rows * for the specified width, height, labelheight and number of players. * Optimal means that the players are displayed as large as possible in the given * area. * * @param availableWidth the width available for the players * @param availableHeight the height available for the players * @param labelHeight the height of the label that is displayed beneath each player * @param numPlayers the total number of players * @return an int array of length 2; the first int is the number of columns, * the second int is the number of rows */ private int[] getNumberOfColumnsAndRows(int availableWidth, int availableHeight, int labelHeight, int numPlayers) { // calculate the average aspect ratio of the players with a visual component float averageAspectRatio = 0.0f; int visualCount = 0; for (int i = 0; i < playerList.size(); i++) { PlayerLayoutModel plModel = (PlayerLayoutModel) playerList.get(i); if (plModel.isVisual()) { averageAspectRatio += plModel.player.getAspectRatio(); visualCount++; } } if (visualCount > 0) { averageAspectRatio /= visualCount; } else { averageAspectRatio = 1.3f; //default } if ((numPlayers == 0) || (numPlayers == 1)) { return new int[] { numPlayers, numPlayers }; } if ((availableWidth <= 0) || (availableHeight <= 0) || (availableHeight <= labelHeight)) { return new int[] { 0, 0 }; } int maxArea = 0; int maxWidth = 0; int maxHeight = 0; int numColumns = 0; int numRows = 0; for (int i = 1; i <= numPlayers; i++) { for (int j = numPlayers; (j >= 1) && ((i * j) >= numPlayers); j--) { maxWidth = availableWidth / i; maxHeight = (availableHeight - (j * labelHeight)) / j; if (maxHeight > (maxWidth * (1 / averageAspectRatio))) { maxHeight = (int) (maxWidth * (1 / averageAspectRatio)); } if (maxWidth > (maxHeight * averageAspectRatio)) { maxWidth = (int) (maxHeight * averageAspectRatio); } if ((maxWidth <= 0) || (maxHeight <= 0)) { continue; } int area = maxWidth * maxHeight; if (area > maxArea) { maxArea = area; numColumns = i; numRows = j; } } } return new int[] { numColumns, numRows }; } /** * Tests the media descriptors for video files and extracted audio files * with different offsets. When found with different offset while the video * is not the master media a warning message is generated. */ private void checkUnequalOffsets() { if (playerList.size() < 2) { return; } StringBuffer mesBuf = null; MediaDescriptor amd; MediaDescriptor vmd; PlayerLayoutModel amodel; PlayerLayoutModel vmodel; for (int i = 0; i < playerList.size(); i++) { amodel = (PlayerLayoutModel) playerList.get(i); amd = amodel.player.getMediaDescriptor(); if (amd == null) { continue; } if (amd.mimeType.equals(MediaDescriptor.WAV_MIME_TYPE)) { for (int j = 0; j < playerList.size(); j++) { vmodel = (PlayerLayoutModel) playerList.get(j); vmd = vmodel.player.getMediaDescriptor(); if (vmd == null) { continue; } if (MediaDescriptorUtil.isVideoType(vmd)) { if (vmd.mediaURL.equals(amd.extractedFrom) && (j != 0) && (vmd.timeOrigin != amd.timeOrigin)) { // add to the message if (mesBuf == null) { mesBuf = new StringBuffer(ElanLocale.getString( "LinkedFilesDialog.Message.OffsetNotEqual") + "\n\n"); } mesBuf.append("- " + vmd.mediaURL + "\n"); mesBuf.append("- " + amd.mediaURL + "\n\n"); break; } } } } } if (mesBuf != null) { JOptionPane.showMessageDialog(container, mesBuf.toString(), ElanLocale.getString("Message.Warning"), JOptionPane.WARNING_MESSAGE); } } /** * Remove references to the ElanFrame etc. for garbage collection. * */ public void cleanUpOnClose() { container.removeAll(); if (timeLineComponent != null) { timeLineComponent.removeAll(); } multiTierControlPanel = null; timeLineViewer = null; interlinearViewer = null; glasspane = null; container = null; viewerManager = null; elanFrame = null; } /** * DOCUMENT ME! * * @return DOCUMENT ME! */ public JFrame getElanFrame() { return elanFrame; } /** * Give access to the viewermanager. * * @return the viewermanager */ public ViewerManager2 getViewerManager() { return viewerManager; } /** * Stores preferences/current state into a HashMap. * * @return a HashMap */ public HashMap getState() { HashMap map = new HashMap(); // multitier control panel if (multiTierControlPanel != null) { int sortMode = multiTierControlPanel.getSorting(); map.put("TierSortingMode", new Integer(sortMode)); } // tabpane if (tabPane != null) { map.put("SelectedTabIndex", new Integer(tabPane.getSelectedIndex())); for (int i = 0; i < tabPane.getTabCount(); i++) { SingleTierViewerPanel panel; JComponent comp = (JComponent) tabPane.getComponent(i); if (comp instanceof SingleTierViewerPanel) { panel = (SingleTierViewerPanel) comp; if (panel.getViewer() instanceof GridViewer) { map.put("GridMultiMode", new Boolean(panel.isMultiTierMode())); map.put("GridTierName", panel.getSelectedTierName()); map.put("GridFontSize", new Integer( ((GridViewer) panel.getViewer()).getFontSize())); } else if (panel.getViewer() instanceof TextViewer) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -