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

📄 signalviewer.java

📁 编辑视频文件
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    }    //*************************************************************************************//    /* implement ComponentListener */    /*     * Calculate a new BufferedImage taken the new size of the Component     */    public void componentResized(ComponentEvent e) {        intervalEndTime = intervalBeginTime + (getWidth() * msPerPixel);        if (timeScaleConnected) {            setGlobalTimeScaleIntervalEndTime(intervalEndTime);        }        paintBuffer();        //repaint();    }    /**     * DOCUMENT ME!     *     * @param e DOCUMENT ME!     */    public void componentMoved(ComponentEvent e) {    }    /**     * DOCUMENT ME!     *     * @param e DOCUMENT ME!     */    public void componentShown(ComponentEvent e) {    }    /**     * DOCUMENT ME!     *     * @param e DOCUMENT ME!     */    public void componentHidden(ComponentEvent e) {    }    //***********************************************************************************    /* implement MouseListener and MouseMotionListener       /*     * A mouse click in the SignalViewer updates the media time     * to the time corresponding to the x-position.     */    public void mouseClicked(MouseEvent e) {        Point pp = e.getPoint();        if ((e.getClickCount() == 1) && e.isShiftDown()) {            // change the selection interval            if (getSelectionBeginTime() != getSelectionEndTime()) {                long clickTime = timeAt(pp.x);                if (clickTime > getSelectionEndTime()) {                    // expand to the right                    setSelection(getSelectionBeginTime(), clickTime);                } else if (clickTime < getSelectionBeginTime()) {                    // expand to the left                    setSelection(clickTime, getSelectionEndTime());                } else {                    // reduce from left or right, whichever boundary is closest                    // to the click time                    if ((clickTime - getSelectionBeginTime()) < (getSelectionEndTime() -                            clickTime)) {                        setSelection(clickTime, getSelectionEndTime());                    } else {                        setSelection(getSelectionBeginTime(), clickTime);                    }                }            }        } else {            setMediaTime(timeAt(pp.x));        }    }    /*     * @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent)     */    public void mousePressed(MouseEvent e) {        if (SwingUtilities.isRightMouseButton(e) || e.isPopupTrigger()) {            Point pp = e.getPoint();            if (popup == null) {                createPopupMenu();            }            if ((popup.getWidth() == 0) || (popup.getHeight() == 0)) {                popup.show(this, pp.x, pp.y);            } else {                popup.show(this, pp.x, pp.y);                SwingUtilities.convertPointToScreen(pp, this);                Dimension d = Toolkit.getDefaultToolkit().getScreenSize();                Window w = SwingUtilities.windowForComponent(this);                if ((pp.x + popup.getWidth()) > d.width) {                    pp.x -= popup.getWidth();                }                //this does not account for a desktop taskbar                if ((pp.y + popup.getHeight()) > d.height) {                    pp.y -= popup.getHeight();                }                //keep it in the window then                if ((pp.y + popup.getHeight()) > (w.getLocationOnScreen().y +                        w.getHeight())) {                    pp.y -= popup.getHeight();                }                popup.setLocation(pp);            }            return;        }        if (playerIsPlaying()) {            stopPlayer();        }        dragStartPoint = e.getPoint();        dragStartTime = timeAt(dragStartPoint.x);        if (e.isAltDown() && (dragStartPoint.y < rulerHeight)) {            panMode = true;            setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));            //System.out.println("alt down");        } else {            panMode = false;            /* just to be sure a running scroll thread can be stopped */            stopScroll();        }    }    /*     * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)     */    public void mouseReleased(MouseEvent e) {        //stop scrolling thread        stopScroll();        // changing the selection might have changed the intervalBeginTime        if (timeScaleConnected) {            setGlobalTimeScaleIntervalBeginTime(intervalBeginTime);            setGlobalTimeScaleIntervalEndTime(intervalEndTime);        }        if (panMode) {            panMode = false;            setCursor(Cursor.getDefaultCursor());        }    }    /*     * @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent)     */    public void mouseEntered(MouseEvent e) {    }    /*     * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)     */    public void mouseExited(MouseEvent e) {        stopScroll();        repaint();    }    /*     * @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent)     */    public void mouseDragged(MouseEvent e) {        if (SwingUtilities.isRightMouseButton(e)) {            return;        }        dragEndPoint = e.getPoint();        //panning        if (panMode) {            int scrolldiff = dragEndPoint.x - dragStartPoint.x;            long newTime = intervalBeginTime - (scrolldiff * msPerPixel);            setIntervalBeginTime((newTime < -mediaOffset) ? (-mediaOffset)                                                          : newTime);            dragStartPoint = dragEndPoint;            return;        }        /*e.getPoint can be outside the image size*/        if ((dragEndPoint.x <= 0) || (dragEndPoint.x >= getWidth())) {            stopScroll();            /*               if (timeScaleConnected) {                   setGlobalTimeScaleIntervalBeginTime(intervalBeginTime);                   setGlobalTimeScaleIntervalEndTime(intervalEndTime);               }             */            return;        }        //auto scroll first        if ((dragEndPoint.x < SCROLL_OFFSET) && (dragEndPoint.x > 0)) {            /*               long begin = intervalBeginTime - SCROLL_OFFSET * msPerPixel;               if (begin < 0) {                   begin = 0;               }               setIntervalBeginTime(begin);               paintBuffer();             */            if (scroller == null) {                // if the dragging starts close to the edge call setSelection                if ((dragStartPoint.x < SCROLL_OFFSET) &&                        (dragStartPoint.x > 0)) {                    setSelection(dragStartTime, dragStartTime);                }                stopScrolling = false;                scroller = new DragScroller(-SCROLL_OFFSET / 4, 30);                scroller.start();            }            return;        } else if ((dragEndPoint.x > (getWidth() - SCROLL_OFFSET)) &&                (dragEndPoint.x < getWidth())) {            /*               long begin = intervalBeginTime + SCROLL_OFFSET * msPerPixel;               setIntervalBeginTime(begin);               paintBuffer();             */            if (scroller == null) {                //			if the dragging starts close to the edge call setSelection                if ((dragStartPoint.x > (getWidth() - SCROLL_OFFSET)) &&                        (dragStartPoint.x < getWidth())) {                    setSelection(dragStartTime, dragStartTime);                }                stopScrolling = false;                scroller = new DragScroller(SCROLL_OFFSET / 4, 30);                scroller.start();            }            return;        } else {            stopScroll();            /* selection and media time, prevent from selecting beyond the media length*/            if (timeAt(dragEndPoint.x) > dragStartTime) { //left to right                selectionEndTime = timeAt(dragEndPoint.x);                if ((samp != null) && (selectionEndTime > samp.getDuration())) {                    selectionEndTime = (long) samp.getDuration();                }                selectionBeginTime = dragStartTime;                if (selectionBeginTime < 0) {                    selectionBeginTime = 0L;                }                if (selectionEndTime < 0) {                    selectionEndTime = 0L;                }                setMediaTime(selectionEndTime);            } else { //right to left                selectionBeginTime = timeAt(dragEndPoint.x);                if ((samp != null) &&                        (selectionBeginTime > samp.getDuration())) {                    selectionBeginTime = (long) samp.getDuration();                }                selectionEndTime = dragStartTime;                if ((samp != null) && (selectionEndTime > samp.getDuration())) {                    selectionEndTime = (long) samp.getDuration();                }                if (selectionBeginTime < 0) {                    selectionBeginTime = 0L;                }                if (selectionEndTime < 0) {                    selectionEndTime = 0L;                }                setMediaTime(selectionBeginTime);            }            setSelection(selectionBeginTime, selectionEndTime);            repaint();        }    }    /*     * @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent)     */    public void mouseMoved(MouseEvent e) {        if (e.getPoint().y <= rulerHeight) {            //setToolTipText(Long.toString(timeAt(e.getPoint().x)));            setToolTipText(TimeFormatter.toString(timeAt(e.getPoint().x)));        } else if ((e.getPoint().x >= selectionBeginPos) &&                (e.getPoint().x <= selectionEndPos)) {            setToolTipText("Selection: " +                TimeFormatter.toString(getSelectionBeginTime()) + " - " +                TimeFormatter.toString(getSelectionEndTime()));        } else {            setToolTipText("");        }    }    /*     * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)     */    public void actionPerformed(ActionEvent e) {        if (e.getActionCommand().equals("connect")) {            boolean connected = ((JCheckBoxMenuItem) e.getSource()).getState();            setTimeScaleConnected(connected);        } else if (e.getActionCommand().equals("sep")) {            setChannelMode(STEREO_SEPARATE);        } else if (e.getActionCommand().equals("merge")) {            setChannelMode(STEREO_MERGED);        } else if (e.getActionCommand().equals("blend")) {            setChannelMode(STEREO_BLENDED);        } else if (e.getActionCommand().equals("praat")) {            openInPraat(0, 0);        } else if (e.getActionCommand().equals("praatSel")) {            openSelectionInPraat();        } else if (e.getActionCommand().equals("clipSel")) {            clipSelectionWithPraat();        } else if (e.getActionCommand().equals("info")) {            showMediaInfo();        } /*else if (e.getActionCommand().indexOf("res") > -1) {          String com = e.getActionCommand();          String resString = com.substring(com.indexOf(" ") + 1);          float factor = 100 / Float.parseFloat(resString);          int newMsPerPixel = (int)(1000f / (PIXELS_FOR_SECOND * factor));          setMsPerPixel(newMsPerPixel);          }*/        else if (e.getActionCommand().startsWith("vz-")) {            // vertical zoom or amplification            int nvz = 100;            String vzVal = e.getActionCommand().substring(3);            try {                nvz = Integer.parseInt(vzVal);            } catch (NumberFormatException nfe) {                System.out.println("Error parsing the vertical zoom level");            }            vertZoom = nvz;            paintBuffer();        } else {            /* the rest are zoom menu items*/            String zoomString = e.getActionCommand();            int zoom = 100;            try {                zoom = Integer.parseInt(zoomString);            } catch (NumberFormatException nfe) {                System.err.println("Error parsing the zoom level");            }            int newMsPerPixel = (int) ((100f / zoom) * 10);            setMsPerPixel(newMsPerPixel);        }    }    /**     * Try to close the RandomAccessFile of the WAVSampler.     */    public void finalize() {        if (samp != null) {            samp.close();        }    }    /**     * Scrolls the image while dragging to the left or right with the specified  

⌨️ 快捷键说明

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