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

📄 tstrackpanelimpl.java

📁 编辑视频文件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                if (i < 0) {                    continue;                }                float v = data[i];                if (x2 == -1) {                    // first point                    x2 = (int) (i * pixelPerSample) - xShift;                    y2 = (int) (scaleUnit * (range[1] - v));                } else {                    x1 = x2;                    y1 = y2;                    x2 = (int) (i * pixelPerSample) - xShift;                    y2 = (int) (scaleUnit * (range[1] - v));                    g2d.drawLine(x1, y1, x2, y2);                }            }        }    }    /**     * Renders a track that stores its data in a TimeValue List, like a NonContinuousRateTSTrack.     * Null checking has been done in paintTrack().     *     * @param g2d the Graphics context     * @param track the time series track to render.     * @param beginTime interval begin time     * @param w the width of the paint area     * @param h the height of the paint area     * @see #paintTrack(Graphics2D, AbstractTSTrack, long, int, int)     */    private void paintTimeValueTrack(Graphics2D g2d, AbstractTSTrack track,        long beginTime, int w, int h) {        TimeValue tv;        g2d.setColor(track.getColor());        List data = (List) track.getData();        float[] range = vertRuler.getRange();        float scaleUnit = h / (range[1] - range[0]);        long endTime = beginTime + (long) (w * msPerPixel);        int xShift = (int) (beginTime / msPerPixel) +            (int) (track.timeOffset / msPerPixel);        int beginIndex = 0;        if (beginTime >= 0) {            beginIndex = track.getIndexForTime(beginTime);        } else {            beginIndex = track.getIndexForTime(0);        }        int endIndex = track.getIndexForTime(endTime);        // if the time at end index is less than endtime take the next index, if it exists        if ((endIndex >= 0) && (endIndex < (data.size() - 1))) {            tv = (TimeValue) data.get(endIndex);            if (tv.time < endTime) {                endIndex++;            }        }        int x1 = 0;        int x2 = -1;        int y1 = 0;        int y2 = 0;        for (int i = beginIndex; i <= endIndex; i++) {            tv = (TimeValue) data.get(i);            if (x2 == -1) {                // first point                x2 = (int) (tv.time / msPerPixel) - xShift;                y2 = (int) (scaleUnit * (range[1] - tv.value));            } else {                x1 = x2;                y1 = y2;                x2 = (int) (tv.time / msPerPixel) - xShift;                y2 = (int) (scaleUnit * (range[1] - tv.value));                if (!(tv instanceof TimeValueStart)) {                    g2d.drawLine(x1, y1, x2, y2);                }            }        }    }    /**     * Sets the vertical zoom level.     *     * @param vertZoom the vertical zoom level     */    public void setVerticalZoom(float vertZoom) {        zoomLevel = vertZoom;    }    /**     * Returns the current vertical zoomlevel.     *     * @return the current vertical zoomlevel     */    public float getVerticalZoom() {        return zoomLevel;    }    /**     * Adds a track to the panel.     *     * @param track the track to add to the panel     *     * @see mpi.eudico.client.annotator.timeseries.TSTrackPanel#addTrack(mpi.eudico.client.annotator.timeseries.ContinuousRateTSTrack)     */    public void addTrack(AbstractTSTrack track) {        tracks.add(track);    }    /**     * Removes a track from the panel.     *     * @param track the track to remove from the panel     *     * @return true if the track was in the list of tracks and has been     *         removed, false otherwise     *     * @see mpi.eudico.client.annotator.timeseries.TSTrackPanel#removeTrack(mpi.eudico.client.annotator.timeseries.AbstractTSTrack)     */    public boolean removeTrack(AbstractTSTrack track) {        return tracks.remove(track);    }    /**     * Removes a track identified by trackID from the panel.     *     * @param trackID the name or id of the track to remove from the panel     *     * @return true if the track was in the list of tracks and has been     *         removed, false otherwise     *     * @see mpi.eudico.client.annotator.timeseries.TSTrackPanel#removeTrack(java.lang.String)     */    public boolean removeTrack(String trackID) {        if (trackID == null) {            return false;        }        AbstractTSTrack track = getTrack(trackID);        if (track != null) {            return tracks.remove(track);        }        return false;    }    /**     * Returns the track identified by trackID.     *     * @param trackID the name or id of the track     *     * @return the track, or null if not present in the list     *     * @see mpi.eudico.client.annotator.timeseries.TSTrackPanel#getTrack(java.lang.String)     */    public AbstractTSTrack getTrack(String trackID) {        AbstractTSTrack track = null;        AbstractTSTrack tr = null;        for (int i = 0; i < tracks.size(); i++) {            tr = (AbstractTSTrack) tracks.get(i);            if (tr.getName().equals(trackID)) {                track = tr;                break;            }        }        return track;    }    /**     * Returns the list of tracks in this panel.     *     * @return the list of tracks     *     * @see mpi.eudico.client.annotator.timeseries.TSTrackPanel#getTracks()     */    public List getTracks() {        return tracks;    }    /**     * Sets the display height for this panel.     *     * @param height the new height     *     * @see mpi.eudico.client.annotator.timeseries.TSTrackPanel#setHeight(int)     */    public void setHeight(int height) {        this.height = height;        vertRuler.setHeight(height - margin.top - margin.bottom);        trackRect.height = height - margin.top - margin.bottom;    }    /**     * @see mpi.eudico.client.annotator.timeseries.TSTrackPanel#getHeight()     */    public int getHeight() {        return height;    }    /**     * @see mpi.eudico.client.annotator.timeseries.TSTrackPanel#setWidth(int)     */    public void setWidth(int width) {        this.width = width;        trackRect.width = width - rulerWidth - margin.left - margin.right;    }    /**     * @see mpi.eudico.client.annotator.timeseries.TSTrackPanel#getWidth()     */    public int getWidth() {        return width;    }    /**     * @see mpi.eudico.client.annotator.timeseries.TSTrackPanel#setMargin(int[])     */    public void setMargin(Insets margin) {        this.margin = margin;        vertRuler.setHeight(height - margin.top - margin.bottom);        trackRect.x = margin.left;        trackRect.y = margin.top;        trackRect.width = width - rulerWidth - margin.left - margin.right;        trackRect.height = height - margin.top - margin.bottom;    }    /**     * @see mpi.eudico.client.annotator.timeseries.TSTrackPanel#getMargin()     */    public Insets getMargin() {        return margin;    }    /**     * Returns the current resolution, or number of milliseconds per pixel.     * @return number of milliseconds per pixel     */    public float getMsPerPixel() {        return msPerPixel;    }    /**     * Sets the resolution or number of milliseconds per pixel.     * @param msPerPixel the number of ms that each pixel represents     */    public void setMsPerPixel(float msPerPixel) {        this.msPerPixel = msPerPixel;    }}

⌨️ 快捷键说明

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