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

📄 subtitleviewer.java

📁 编辑视频文件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            begintime = ann.getBeginTimeBoundary();            endtime = ann.getEndTimeBoundary();            // special case: if a selection (active annotation) is played,             // at the end mediatime == end time of active annotation. Include endtime            // in comparison in such case            if (((ann == getActiveAnnotation()) && (endtime == mediatime)) ||                    ((begintime == selectionBeginTime) &&                    (endtime == selectionEndTime) && (endtime == mediatime))) {                bFound = true;                strTagValue = ann.getValue();                strTagValue = strTagValue.replace('\n', ' ');                break;            }            if ((mediatime >= begintime) && (mediatime < endtime)) {                bFound = true;                strTagValue = ann.getValue();                /*                if (ann == getActiveAnnotation()) {                    taSubtitle.setBorder(BorderFactory.createLineBorder(                        Constants.ACTIVEANNOTATIONCOLOR));                } else {                    taSubtitle.setBorder(null);                }                */                //next line for JDK1.4 only                //strTagValue = strTagValue.replaceAll("\n", "");                strTagValue = strTagValue.replace('\n', ' ');                break;            }        }        //set the appropriate text        if (bFound) {            try {                taSubtitle.setText(" " + strTagValue); //+ '\u0332')            } catch (Exception ex) {                taSubtitle.setText("");            }        } else {            taSubtitle.setText("");            //taSubtitle.setBorder(null);        }        //handle colors        if ((tier != null) && (selectionBeginTime != selectionEndTime) &&                (mediatime >= begintime) &&                ((mediatime < endtime) ||                ((mediatime == endtime) && (selectionBeginTime == begintime))) &&                (((selectionBeginTime >= begintime) &&                (selectionBeginTime < endtime)) ||                ((selectionEndTime >= begintime) &&                (selectionEndTime < endtime)))) {            try {                highlighter.addHighlight(1, taSubtitle.getText().length(),                    selectionPainter);            } catch (Exception ex) {                ex.printStackTrace();            }        } else {            taSubtitle.getHighlighter().removeAllHighlights();        }        repaint();    }    /**     * Sets the tier which is shown in the subtitle viewer     *     * @param tier The tier which should become visible     */    public void setTier(Tier tier) {        // added by AR        putOriginalComponentBack();        if (tier == null) {            this.tier = null;            annotations = new Vector();            doUpdate();        } else {            this.tier = (TierImpl) tier;            try {                annotations = this.tier.getAnnotations();            } catch (Exception ex) {                ex.printStackTrace();            }        }        buildArray();        doUpdate();    }    /**     * Gets the tier which is shown in the subtitle viewer     *     * @return DOCUMENT ME!     */    public Tier getTier() {        return tier;    }    /**     * Returns the current font size.     *     * @return the current font size     */    public int getFontSize() {        return fontSize;    }    /**     * Sets the font size.     *     * @param size the new font size     */    public void setFontSize(int size) {        fontSize = size;        if (fontSizeBG != null) {            Enumeration en = fontSizeBG.getElements();            JMenuItem item;            String value;            while (en.hasMoreElements()) {                item = (JMenuItem) en.nextElement();                value = item.getText();                try {                    int v = Integer.parseInt(value);                    if (v == fontSize) {                        item.setSelected(true);                        taSubtitle.setFont(Constants.DEFAULTFONT.deriveFont(                                (float) fontSize));                        break;                    }                } catch (NumberFormatException nfe) {                    //// do nothing                }            }        } else {            createPopup();            taSubtitle.setFont(Constants.DEFAULTFONT.deriveFont(                    (float) fontSize));        }    }    /**     * Builds an array with all begintimes and endtimes from a tag Used for     * searching (quickly) a particular tag     */    private void buildArray() {        int annotations_size = annotations.size();        arrTags = new long[2 * annotations_size];        int arrIndex = 0;        Annotation ann;        for (int i = 0; i < annotations_size; i++) {            ann = (Annotation) annotations.elementAt(i);            begintime = ann.getBeginTimeBoundary();            endtime = ann.getEndTimeBoundary();            arrTags[arrIndex++] = begintime;            arrTags[arrIndex++] = endtime;        }    }    //when inline edit box disappears, it calls this method    public void putOriginalComponentBack() {        inlineEditBox = null;        removeAll();        add(jspSubtitle, BorderLayout.CENTER);        validate();        repaint();    }    /**     * Hhandles mouse actions on the subtitle viewer     */    private class SubtitleViewerMouseListener extends MouseAdapter {        private SubtitleViewer subtitleViewer;        /**         * Creates a new SubtitleViewerMouseListener instance         *         * @param sv DOCUMENT ME!         */        SubtitleViewerMouseListener(SubtitleViewer sv) {            subtitleViewer = sv;        }        /**         * The mouse pressed event handler.         * @param e the mouse event         */        public void mousePressed(MouseEvent e) {            if (SwingUtilities.isRightMouseButton(e) || e.isPopupTrigger()) {                Point p = e.getPoint();                SwingUtilities.convertPointToScreen(p, subtitleViewer);                int x = e.getPoint().x;                int y = e.getPoint().y;                popup.show(subtitleViewer, x, y);                return;            }        }        /**         * DOCUMENT ME!         *         * @param e DOCUMENT ME!         */        public void mouseClicked(MouseEvent e) {            //bring up edit dialog            if (e.getClickCount() == 2) {                inlineEditBox = new InlineEditBox(subtitleViewer);                Annotation annotation = getAnnotation();                if (annotation != null) {                    if (e.isShiftDown()) {                        // open CV                        inlineEditBox.setAnnotation(annotation, true);                    } else {                        inlineEditBox.setAnnotation(annotation);                    }                    inlineEditBox.configureEditor(JPanel.class, null, getSize());                    removeAll();                    add(inlineEditBox, BorderLayout.CENTER);                    validate();                    //repaint();                    inlineEditBox.startEdit();                }                return;            }            if (!taSubtitle.getText().equals("")) {                stopPlayer();                setActiveAnnotation(getAnnotation());            }        }        private Annotation getAnnotation() {            Annotation annotation = null;            int annotations_size = annotations.size();            for (int i = 0; i < annotations_size; i++) {                annotation = (Annotation) annotations.elementAt(i);                //exact time always exists in this case                //if (getSelectionBeginTime() == tag.getBeginTime())                // HS 4 dec 03: the subtitle viewer always seems to show the tag                // at the media time, if any                if ((getMediaTime() >= annotation.getBeginTimeBoundary()) &&                        (getMediaTime() < annotation.getEndTimeBoundary())) {                    return annotation;                }            }            return null;        }    }    //end of SubtitleViewerMouseListener}

⌨️ 快捷键说明

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