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

📄 timeseriesviewer.java

📁 编辑视频文件
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    }    /**     * Returns the vertical scroll offset.     *     * @return the vertical scroll offset     */    public int getVerticalScrollOffset() {        return verticalScrollOffset;    }    /**     * Sets the vertical scroll offset on this component.     *     * @param offset the new vertical scroll offset     */    public void setVerticalScrollOffset(int offset) {        verticalScrollOffset = offset;        repaint();    }    /**     * Returns the current number of trackpanels.     *     * @return the number of trackpanels     */    public int getNumberOfTrackPanels() {        return trackPanels.size();    }    /**     * Sets the number of trackpanels. Adds a number of empty trackpanels     * untill there are the given number of panels. If there are already     * more panels nothing happens.     *     * @param num the number of panels     */    public void setNumberOfTrackPanels(int num) {        int curSize = trackPanels.size();        for (int i = 0; i < (num - curSize); i++) {            addEmptyTrackPanel();        }    }    /**     * Returns the names of the tracks of the trackpanel at the specified index.     *     * @param panelIndex index of the panel     *     * @return an array of track names     */    public String[] getTracksForPanel(int panelIndex) {        if ((panelIndex < 0) || (panelIndex >= trackPanels.size())) {            return null; // rather than ArrayIndexOutOfBoundsException        }        TSTrackPanelImpl panel = (TSTrackPanelImpl) trackPanels.get(panelIndex);        List tracks = panel.getTracks();        AbstractTSTrack tr;        String[] names = new String[tracks.size()];        for (int i = 0; i < tracks.size(); i++) {            tr = (AbstractTSTrack) tracks.get(i);            names[i] = tr.getName();        }        return names;    }    /**     * Tells the viewer to add the given predefined tracks to the panel     * at index <code>panelIndex</code>.     *     * @param panelIndex the index of the panel     * @param trackNames the names of the tracks to add     */    public void setTracksForPanel(int panelIndex, String[] trackNames) {        if ((panelIndex < 0) || (panelIndex >= trackPanels.size()) ||                (trackNames == null)) {            return; // rather than ArrayIndexOutOfBoundsException        }        TSTrackPanelImpl panel = (TSTrackPanelImpl) trackPanels.get(panelIndex);        String name;        AbstractTSTrack tr;        for (int i = 0; i < trackNames.length; i++) {            name = trackNames[i];            if (name != null) {                tr = trackManager.getTrack(name);                if (tr != null) {                    panel.addTrack(tr);                    panel.getRuler().setRange(tr.getRange());                    panel.getRuler().setUnitString(tr.getUnitString());                }            }        }        paintBuffer();    }    /**     * Update the values of the scrollbar.<br>     * Called after a change in the number of visible tracks.     */    private void updateScrollBar() {        int value = scrollBar.getValue();        int max = (imageHeight > getHeight()) ? imageHeight : getHeight();        // before changing scrollbar values do a setValue(0), otherwise        // setMaxiimum and/or setVisibleAmount will not be accurate        scrollBar.setValue(0);        scrollBar.setMaximum(max);        scrollBar.setVisibleAmount(getHeight());        if ((value + getHeight()) > max) {            value = max - getHeight();        }        scrollBar.setValue(value);        scrollBar.revalidate();    }    /**     * @see mpi.eudico.client.annotator.viewer.DefaultTimeScaleBasedViewer#getLeftMargin()     */    public int getLeftMargin() {        return vertRulerWidth;    }    /**     * @see mpi.eudico.client.annotator.viewer.DefaultTimeScaleBasedViewer#getRightMargin()     */    public int getRightMargin() {        return scrollBar.getWidth();    }    /**     * @see mpi.eudico.client.annotator.viewer.DefaultTimeScaleBasedViewer#createPopupMenu()     */    protected void createPopupMenu() {        super.createPopupMenu();        timeScaleConMI.setEnabled(false);        fitVerticalMI = new JCheckBoxMenuItem(ElanLocale.getString(                    "TimeSeriesViewer.TrackPanel.FitVertically"));        fitVerticalMI.setSelected(autoFitVertical);        fitVerticalMI.addActionListener(this);        popup.add(fitVerticalMI);        popup.addSeparator();        addPanelMI = new JMenuItem(ElanLocale.getString(                    "TimeSeriesViewer.TrackPanel.AddPanel"));        addPanelMI.addActionListener(this);        popup.add(addPanelMI);        removePanelMI = new JMenuItem(ElanLocale.getString(                    "TimeSeriesViewer.TrackPanel.RemovePanel"));        removePanelMI.addActionListener(this);        popup.add(removePanelMI);        //popup.addSeparator();        addPanelForEachTrackMI = new JMenuItem(ElanLocale.getString(                    "TimeSeriesViewer.TrackPanel.AddPanelForEachTrack"));        addPanelForEachTrackMI.addActionListener(this);        popup.add(addPanelForEachTrackMI);        removeAllPanelsMI = new JMenuItem(ElanLocale.getString(                    "TimeSeriesViewer.TrackPanel.RemoveAllPanels"));        removeAllPanelsMI.addActionListener(this);        popup.add(removeAllPanelsMI);        popup.addSeparator();        trPanelMenu = new JMenu(ElanLocale.getString(                    "TimeSeriesViewer.TrackPanel"));        popup.add(trPanelMenu);        setRangeMenu = new JMenu(ElanLocale.getString(                    "TimeSeriesViewer.TrackPanel.SetRange"));        trPanelMenu.add(setRangeMenu);        addTrackMenu = new JMenu(ElanLocale.getString(                    "TimeSeriesViewer.Track.Add"));        trPanelMenu.add(addTrackMenu);        removeTrackMenu = new JMenu(ElanLocale.getString(                    "TimeSeriesViewer.Track.Remove"));        trPanelMenu.add(removeTrackMenu);        popup.addSeparator();        // $sidgrid        trPanelMenu.addSeparator();        addAllTrackMI = new JMenuItem(ElanLocale.getString(                    "TimeSeriesViewer.Track.Addall"));        addAllTrackMI.addActionListener(this);        trPanelMenu.add(addAllTrackMI);        removeAllTrackMI = new JMenuItem(ElanLocale.getString(                    "TimeSeriesViewer.Track.Removeall"));        removeAllTrackMI.addActionListener(this);        trPanelMenu.add(removeAllTrackMI);        // end $sidgrid        extractDataMI = new JMenuItem(ElanLocale.getString(                    "TimeSeriesViewer.Extract"));        extractDataMI.addActionListener(this);        popup.add(extractDataMI);        configureTrMI = new JMenuItem(ElanLocale.getString(                    "TimeSeriesViewer.Tracks.Configure"));        configureTrMI.addActionListener(this);        popup.add(configureTrMI);    }    /**     * @see mpi.eudico.client.annotator.viewer.DefaultTimeScaleBasedViewer#updatePopup(java.awt.Point)     */    protected void updatePopup(Point p) {        selTrackPanel = null;        removePanelMI.setEnabled(false);        trPanelMenu.setEnabled(false);        if (!pointInHorizontalRuler(p.y)) {            Point inverse = new Point(p);            inverse.y += verticalScrollOffset;            selTrackPanel = getPanelAtY(inverse.y);            if (selTrackPanel != null) {                removePanelMI.setEnabled(true);                trPanelMenu.setEnabled(true);            }        }        addTrackMenu.removeAll();        removeTrackMenu.removeAll();        setRangeMenu.removeAll();        removeAllPanelsMI.setEnabled(trackPanels.size() > 0);        if (selTrackPanel == null) {            return;        }        if (trackManager != null) {            ArrayList trs = trackManager.getRegisteredTracks();            if ((trs.size() == 0) || (transcription.getTiers().size() == 0)) {                extractDataMI.setEnabled(false);            } else {                extractDataMI.setEnabled(true);            }            // Lefvert - May 9 2006            // Sort the menu items in alphabetical order            Collections.sort(trs);            AbstractTSTrack tra;            for (int i = 0; i < trs.size(); i++) {                tra = (AbstractTSTrack) trs.get(i);                if ((tra != null) && !selTrackPanel.getTracks().contains(tra)) {                    JMenuItem it = new JMenuItem(tra.getName());                    it.setActionCommand(ADD_PR + tra.getName());                    it.addActionListener(this);                    addTrackMenu.add(it);                }            }            List curTracks = selTrackPanel.getTracks();            for (int i = 0; i < curTracks.size(); i++) {                tra = (AbstractTSTrack) curTracks.get(i);                if (tra != null) {                    JMenuItem it = new JMenuItem(tra.getName());                    it.setActionCommand(REM_PR + tra.getName());                    it.addActionListener(this);                    removeTrackMenu.add(it);                    JMenuItem is = new JMenuItem(tra.getName());                    is.setActionCommand(RANGE + tra.getName());                    is.addActionListener(this);                    setRangeMenu.add(is);                }            }            removeAllTrackMI.setEnabled(curTracks.size() > 0);        }    }    /**     * Integrate the vertical ruler's width in calculation.     *     * @see mpi.eudico.client.annotator.viewer.DefaultTimeScaleBasedViewer#timeAt(int)     */    public long timeAt(int x) {        return intervalBeginTime + (int) ((x - vertRulerWidth) * msPerPixel);    }    /**     * Integrate the vertical ruler's width in calculation.     *     * @see mpi.eudico.client.annotator.viewer.DefaultTimeScaleBasedViewer#xAt(long)     */    public int xAt(long t) {        return super.xAt(t) + vertRulerWidth;    }    /**     * @see mpi.eudico.client.annotator.viewer.TimeScaleBasedViewer#updateTimeScale()     */    //public void updateTimeScale() {    //}    /**     * To be implemented by each extending class.     *     * @param begin the interval begintime     */    protected void setLocalTimeScaleIntervalBeginTime(long begin) {        if (begin == intervalBeginTime) {            return;        }        intervalBeginTime = begin;        intervalEndTime = intervalBeginTime +            (long) (intervalWidth * msPerPixel);        crossHairPos = xAt(crossHairTime);        selectionBeginPos = xAt(getSelectionBeginTime());        selectionEndPos = xAt(getSelectionEndTime());        paintBuffer();    }    /**     * To be implemented by each extending class.     *     * @param step new msPerPixel value     */    protected void setLocalTimeScaleMsPerPixel(float step) {        if (msPerPixel == step) {            return;        }        msPerPixel = step;        /*stop the player if necessary*/        boolean playing = playerIsPlaying();        if (playing) {            stopPlayer();        }        long mediaTime = getMediaTime();        int oldScreenPos = crossHairPos;        long newMediaX = (long) (mediaTime / msPerPixel);        int numScreens;        if (intervalWidth > 0) {            numScreens = (int) (mediaTime / (intervalWidth * msPerPixel));        } else {            numScreens = 0;        }        int newScreenPos = (int) newMediaX - (numScreens * intervalWidth);        int diff = oldScreenPos - newScreenPos;        //new values        intervalBeginTime = (long) (((numScreens * intervalWidth) - diff) * msPerPixel);        if (intervalBeginTime < 0) {            intervalBeginTime = 0;        }        intervalEndTime = intervalBeginTime +            (long) (intervalWidth * msPerPixel);        crossHairPos = xAt(mediaTime);        selectionBeginPos = xAt(getSelectionBeginTime());        selectionEndPos = xAt(getSelectionEndTime());        TSTrackPanelImpl panel;        for (int i = 0; i < trackPanels.size(); i++) {            panel = (TSTrackPanelImpl) trackPanels.get(i);            panel.setMsPerPixel(msPerPixel);        }        paintBuffer();        if (playing) {            startPlayer();        }        int zoom = (int) (100f * (10f / msPerPixel));        if (zoom <= 0) {            zoom = 100;        }        updateZoomPopup(zoom);    }    /**     * Removes the contents of the panel     * $sidgrid     */    private void clearPanel() {        trackPanels.clear();        adjustPanelHeight();        paintBuffer();        updateScrollBar();    }    /**     * Sets new media offset. Should only be called if all tracks in all panels     * in the viewer should have the same offset.     *     * @param offset the new media offset in ms     */    public void setMediaTimeOffset(long offset) {        if (offset != mediaTimeOffset) {            super.setMediaTimeOffset(offset);            TSTrackPanelImpl panel;            List tracks;            AbstractTSTrack track;            for (int i = 0; i < trackPanels.size(); i++) {                panel = (TSTrackPanelImpl) trackPanels.get(i);                tracks = panel.getTracks();                for (int j = 0; j < tracks.size(); j++) {                    track = (AbstractTSTrack) tracks.get(j);                    if (track != null) {                        track.setTimeOffset((int) mediaTimeOffset);                    }                }            }        }    }    /**     * @see DefaultTimeScaleBasedViewer#pointInHorizontalRuler(int)     */    protected boolean pointInHorizontalRuler(int yPos) {        int h = getHeight();        return (yPos <= h) && (yPos >= (h - rulerHeight));    }    /**     * Finds and returns the track panel at the specified y-coordinate.     *     * @param y the y coordinate     *     * @return the panel at that point or null     */    private TSTrackPanelImpl getPanelAtY(int y) {        TSTrackPanelImpl panel = null;        int h = Math.max(getHeight(), imageHeight);        int ymin = h;        int ymax = h - rulerHeight;        for (int i = 0; i < trackPanels.size(); i++) {            panel = (TSTrackPanelImpl) trackPanels.get(i);

⌨️ 快捷键说明

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