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

📄 timelineviewer.java

📁 编辑视频文件
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    /**     * Calculate the index in the visible tiers array for the given annotation.     *     * @param annotation DOCUMENT ME!     *     * @return the index of the Tier2D or -1 when not found     */    private int getTierIndexForAnnotation(Annotation annotation) {        Tier tier = annotation.getTier();        int index = -1;        for (int i = 0; i < visibleTiers.size(); i++) {            if (((Tier2D) visibleTiers.get(i)).getTier() == tier) {                index = i;                break;            }        }        return index;    }    /**     * Inverts the point and finds the Tag2D at that point.     *     * @param p point in component space     *     * @return a tag2d or null     */    private Tag2D getHoverTag(Point p) {        p.x += timeToPixels(intervalBeginTime);        p.y += verticalScrollOffset;        hoverTierIndex = getTierIndexForPoint(p);        Tag2D hover = getTagAt(p, hoverTierIndex);        return hover;    }    /**     * Update the dragedit tag2d while dragging. <br>     * Checks on the parent's boundaries (if any).     *     * @param dragEndPoint the position of the mouse pointer     */    private void updateDragEditTag(Point dragEndPoint) {        if (dragEditTag2D == null) {            return;        }        int diff = dragEndPoint.x - dragStartPoint.x;        switch (dragEditMode) {        case DRAG_EDIT_CENTER:            if (dragParentBegin == -1) {                dragEditTag2D.setX(dragEditTag2D.getX() + diff);                dragStartPoint = dragEndPoint;            } else {                long bt = pixelToTime(dragEditTag2D.getX() + diff);                if (diff < 0) {                    if (bt < dragParentBegin) {                        bt = dragParentBegin;                        int nx = timeToPixels(bt);                        dragEditTag2D.setX(nx);                    } else {                        dragEditTag2D.setX(dragEditTag2D.getX() + diff);                        dragStartPoint = dragEndPoint;                    }                } else {                    long et = pixelToTime(dragEditTag2D.getX() +                            dragEditTag2D.getWidth() + diff);                    if (et > dragParentEnd) {                        et = dragParentEnd;                        bt = et - pixelToTime(dragEditTag2D.getWidth());                        dragEditTag2D.setX(timeToPixels(bt));                    } else {                        dragEditTag2D.setX(dragEditTag2D.getX() + diff);                        dragStartPoint = dragEndPoint;                    }                }            }            setMediaTime(pixelToTime(dragEditTag2D.getX()));            break;        case DRAG_EDIT_LEFT:            if ((dragEditTag2D.getX() + diff) < ((dragEditTag2D.getX() +                    dragEditTag2D.getWidth()) - 1)) {                if ((dragParentBegin == -1) || (diff > 0)) {                    dragEditTag2D.setX(dragEditTag2D.getX() + diff);                    dragEditTag2D.setWidth(dragEditTag2D.getWidth() - diff);                    dragStartPoint = dragEndPoint;                } else if ((dragParentBegin > -1) && (diff < 0)) {                    long bt = pixelToTime(dragEditTag2D.getX() + diff);                    if (bt < dragParentBegin) {                        bt = dragParentBegin;                        int nx = timeToPixels(bt);                        dragEditTag2D.setX(nx);                        dragEditTag2D.setWidth(timeToPixels(dragEditTag2D.getEndTime() -                                bt));                    } else {                        dragEditTag2D.setX(dragEditTag2D.getX() + diff);                        dragEditTag2D.setWidth(dragEditTag2D.getWidth() - diff);                        dragStartPoint = dragEndPoint;                    }                }                setMediaTime(pixelToTime(dragEditTag2D.getX()));            }            break;        case DRAG_EDIT_RIGHT:            if ((dragEditTag2D.getWidth() + diff) > 1) {                if ((dragParentEnd == -1) || (diff < 0)) {                    dragEditTag2D.setWidth(dragEditTag2D.getWidth() + diff);                    dragStartPoint = dragEndPoint;                } else if ((dragParentEnd > -1) && (diff > 0)) {                    long et = pixelToTime(dragEditTag2D.getX() +                            dragEditTag2D.getWidth() + diff);                    if (et > dragParentEnd) {                        et = dragParentEnd;                        dragEditTag2D.setWidth(timeToPixels(et) -                            dragEditTag2D.getX());                    } else {                        dragEditTag2D.setWidth(dragEditTag2D.getWidth() + diff);                        dragStartPoint = dragEndPoint;                    }                }                setMediaTime(pixelToTime(dragEditTag2D.getX() +                        dragEditTag2D.getWidth()));            }            break;        }        repaint();    }    /**     * DOCUMENT ME!     *     * @return the current interval begin time     */    public long getIntervalBeginTime() {        return intervalBeginTime;    }    /**     * DOCUMENT ME!     *     * @return the current interval end time     */    public long getIntervalEndTime() {        return intervalEndTime;    }    /**     * Checks whether this viewer is TimeScale connected and changes the     * interval begin time globally or locally.     *     * @param begin the new interval begin time     */    public void setIntervalBeginTime(long begin) {        if (timeScaleConnected) {            setGlobalTimeScaleIntervalBeginTime(begin);            setGlobalTimeScaleIntervalEndTime(intervalEndTime);        } else {            setLocalTimeScaleIntervalBeginTime(begin);        }    }    /**     * Calculates the new interval begin and/or end time.<br>     * There are two special cases taken into account:<br>     *     * <ul>     * <li>     * when the player is playing attempts are made to shift the interval     * <i>n</i> times the interval size to the left or to the right, until the     * new interval contains the new mediatime.     * </li>     * <li>     * when the player is not playing and the new interval begin time coincides     * with the selection begin time, the interval is shifted a certain offset     * away from the image edge. Same thing when the interval end time     * coincides with the selection end time.     * </li>     * </ul>     *     *     * @param mediaTime     */    private void recalculateInterval(final long mediaTime) {        long newBeginTime = intervalBeginTime;        long newEndTime = intervalEndTime;        if (playerIsPlaying()) {            // we might be in a selection outside the new interval            // shift the interval n * intervalsize to the left or right            if (mediaTime > intervalEndTime) {                newBeginTime = intervalEndTime;                newEndTime = newBeginTime + (imageWidth * msPerPixel);                while ((newEndTime += (imageWidth + msPerPixel)) < mediaTime) {                    newBeginTime += (imageWidth * msPerPixel);                }            } else if (mediaTime < intervalBeginTime) {                newEndTime = intervalBeginTime;                newBeginTime = newEndTime - (imageWidth * msPerPixel);                while ((newEndTime -= (imageWidth * msPerPixel)) > mediaTime) {                    newBeginTime -= (imageWidth * msPerPixel);                }                if (newBeginTime < 0) {                    newBeginTime = 0;                    newEndTime = imageWidth * msPerPixel;                }            } else {                // the new time appears to be in the current interval after all                return;            }        } else { //player is not playing            // is the new media time to the left or to the right of the current interval            if (mediaTime < intervalBeginTime) {                newBeginTime = mediaTime - (SCROLL_OFFSET * msPerPixel);                if (newBeginTime < 0) {                    newBeginTime = 0;                }                newEndTime = newBeginTime + (imageWidth * msPerPixel);            } else if (mediaTime > intervalEndTime) {                newEndTime = mediaTime + (SCROLL_OFFSET * msPerPixel);                newBeginTime = newEndTime - (imageWidth * msPerPixel);                if (newBeginTime < 0) { // somehing would be wrong??                    newBeginTime = 0;                    newEndTime = newBeginTime + (imageWidth * msPerPixel);                }            }            if ((newBeginTime == getSelectionBeginTime()) &&                    (newBeginTime > (SCROLL_OFFSET * msPerPixel))) {                newBeginTime -= (SCROLL_OFFSET * msPerPixel);                newEndTime = newBeginTime + (imageWidth * msPerPixel);            }            if (newEndTime == getSelectionEndTime()) {                newEndTime += (SCROLL_OFFSET * msPerPixel);                newBeginTime = newEndTime - (imageWidth * msPerPixel);                if (newBeginTime < 0) { // something would be wrong??                    newBeginTime = 0;                    newEndTime = newBeginTime + (imageWidth * msPerPixel);                }            }            // try to position the whole selection in the view            if ((mediaTime == getSelectionBeginTime()) &&                    (getSelectionEndTime() > (newEndTime -                    (SCROLL_OFFSET * msPerPixel))) && !panMode) {                newEndTime = getSelectionEndTime() +                    (SCROLL_OFFSET * msPerPixel);                newBeginTime = newEndTime - (imageWidth * msPerPixel);                if ((newBeginTime > mediaTime) &&                        (mediaTime > (SCROLL_OFFSET * msPerPixel))) {                    newBeginTime = mediaTime - (SCROLL_OFFSET * msPerPixel);                    newEndTime = newBeginTime + (imageWidth * msPerPixel);                } else if (newBeginTime > mediaTime) {                    newBeginTime = 0;                    newEndTime = imageWidth * msPerPixel;                }            }        }        if (timeScaleConnected) {            //System.out.println("TLV new begin time: " + newBeginTime);            //System.out.println("TLV new end time: " + newEndTime);            setGlobalTimeScaleIntervalBeginTime(newBeginTime);            setGlobalTimeScaleIntervalEndTime(newEndTime);        } else {            setLocalTimeScaleIntervalBeginTime(newBeginTime);        }    }    /**     * Changes the interval begin time locally.     *     * @param begin the new local interval begin time     */    private void setLocalTimeScaleIntervalBeginTime(long begin) {        if (begin == intervalBeginTime) {            return;        }        intervalBeginTime = begin;        intervalEndTime = intervalBeginTime + (imageWidth * msPerPixel);        //        if (editBox.isVisible()) {            if (getActiveAnnotation() != null) {                int x = xAt(getActiveAnnotation().getBeginTimeBoundary());                editBox.setLocation(x, editBox.getY());            } else {                dismissEditBox();            }            /*               if (x < 0 || x > imageWidth) {                   dismissEditBox();               } else {                   editBox.setLocation(x, editBox.getY());               }             */        }        //        crossHairPos = xAt(crossHairTime);        selectionBeginPos = xAt(getSelectionBeginTime());        selectionEndPos = xAt(getSelectionEndTime());        updateHorScrollBar();        paintBuffer();    }    /**     * DOCUMENT ME!     *     * @return the vertical scroll offset     */    public int getVerticalScrollOffset() {        return verticalScrollOffset;    }    /**     * Sets the vertical scroll offset of the tags on this component. <b>Note:</b><br>     * There should be some kind of synchronization with other viewers:     * pending..     *     * @param offset the new vertical scroll offset     */    public void setVerticalScrollOffset(int offset) {        verticalScrollOffset = offset;        repaint();    }    /**     * Scrolls the viewport vertically to ensure the cursorTag is visible.     */    private void ensureVerticalVisibilityOfActiveAnnotation() {        if (cursorTag2D == null) {            return;        }        int cy = cursorTierIndex * pixelsForTierHeight;        if (cy < verticalScrollOffset) {            scrollBar.setValue(cy);        } else if (((cy + pixelsForTierHeight) - verticalScrollOffset) > (getHeight() -                rulerHeight)) {            scrollBar.setValue((cy + pixelsForTierHeight + rulerHeight) -                getHeight());        }    }    /**     * Update the values of the scrollbar.<br>     * Called after a change in the number of visible tiers.     */    private void updateScrollBar() {        int value = scrollBar.getValue();        int max = (visibleTiers.size() * pixelsForTierHei

⌨️ 快捷键说明

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