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

📄 timeperiodvaluescollection.java

📁 这是一个segy数据显示程序
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        return getSeries(series).getName();    }    /**     * Adds a series to the collection.  A {@link org.jfree.data.DatasetChangeEvent} is      * sent to all registered listeners.     *     * @param series  the time series.     */    public void addSeries(final TimePeriodValues series) {        // check argument...        if (series == null) {            throw new IllegalArgumentException(                "TimePeriodValuesCollection.addSeries(...): cannot add null series.");        }        // add the series...        this.data.add(series);        series.addChangeListener(this);        fireDatasetChanged();    }    /**     * Removes the specified series from the collection.     *     * @param series  the series to remove.     */    public void removeSeries(final TimePeriodValues series) {        // check argument...        if (series == null) {            throw new IllegalArgumentException(                "TimePeriodValuesCollection.addSeries(...): cannot add null series.");        }        // remove the series...        this.data.remove(series);        series.removeChangeListener(this);        fireDatasetChanged();    }    /**     * Removes a series from the collection.     *     * @param index  the series index (zero-based).     */    public void removeSeries(final int index) {        final TimePeriodValues series = getSeries(index);        if (series != null) {            removeSeries(series);        }    }    /**     * Returns the number of items in the specified series.     * <P>     * This method is provided for convenience.     *     * @param series The index of the series of interest (zero-based).     *     * @return the number of items in the specified series.     */    public int getItemCount(final int series) {        return getSeries(series).getItemCount();    }    /**     * Returns the x-value for the specified series and item.     *     * @param series The series (zero-based index).     * @param item The item (zero-based index).     *     * @return the x-value for the specified series and item.     */    public Number getXValue(final int series, final int item) {        final TimePeriodValues ts = (TimePeriodValues) this.data.get(series);        final TimePeriodValue dp = ts.getDataItem(item);        final TimePeriod period = dp.getPeriod();        return new Long(getX(period));    }    /**     * Returns the x-value for a time period.     *     * @param period  the time period.     *     * @return the x-value.     */    private long getX(final TimePeriod period) {        if (this.xPosition == TimePeriodAnchor.START) {            return period.getStart().getTime();        }        else if (this.xPosition == TimePeriodAnchor.MIDDLE) {            return period.getStart().getTime() / 2 + period.getEnd().getTime() / 2;        }        else if (this.xPosition == TimePeriodAnchor.END) {            return period.getEnd().getTime();        }        else {            throw new IllegalStateException("TimePeriodValuesCollection.getX(...).");        }    }    /**     * Returns the starting X value for the specified series and item.     *     * @param series The series (zero-based index).     * @param item The item (zero-based index).     *     * @return the starting X value for the specified series and item.     */    public Number getStartXValue(final int series, final int item) {        final TimePeriodValues ts = (TimePeriodValues) this.data.get(series);        final TimePeriodValue dp = ts.getDataItem(item);        return new Long(dp.getPeriod().getStart().getTime());    }    /**     * Returns the ending X value for the specified series and item.     *     * @param series The series (zero-based index).     * @param item  The item (zero-based index).     *     * @return the ending X value for the specified series and item.     */    public Number getEndXValue(final int series, final int item) {        final TimePeriodValues ts = (TimePeriodValues) this.data.get(series);        final TimePeriodValue dp = ts.getDataItem(item);        return new Long(dp.getPeriod().getEnd().getTime());    }    /**     * Returns the y-value for the specified series and item.     *     * @param series The series (zero-based index).     * @param item The item (zero-based index).     *     * @return the y-value for the specified series and item.     */    public Number getYValue(final int series, final int item) {        final TimePeriodValues ts = (TimePeriodValues) this.data.get(series);        final TimePeriodValue dp = ts.getDataItem(item);        return dp.getValue();    }    /**     * Returns the starting Y value for the specified series and item.     *     * @param series The series (zero-based index).     * @param item The item (zero-based index).     *     * @return the starting Y value for the specified series and item.     */    public Number getStartYValue(final int series, final int item) {        return getYValue(series, item);    }    /**     * Returns the ending Y value for the specified series and item.     *     * @param series The series (zero-based index).     * @param item The item (zero-based index).     *     * @return the ending Y value for the specified series and item.     */    public Number getEndYValue(final int series, final int item) {        return getYValue(series, item);    }    /**     * Returns the minimum value in the dataset (or null if all the values in     * the domain are null).     *     * @return the minimum value.     */    public Number getMinimumDomainValue() {        final Range r = getDomainRange();        return new Double(r.getLowerBound());    }    /**     * Returns the maximum value in the dataset (or null if all the values in     * the domain are null).     *     * @return the maximum value.     */    public Number getMaximumDomainValue() {        final Range r = getDomainRange();        return new Double(r.getUpperBound());    }    /**     * Returns the range of the values in the series domain.     *     * @return the range.     */    public Range getDomainRange() {        Range result = null;        Range temp = null;        final Iterator iterator = this.data.iterator();        while (iterator.hasNext()) {            final TimePeriodValues series = (TimePeriodValues) iterator.next();            final int count = series.getItemCount();            if (count > 0) {                final TimePeriod start = series.getTimePeriod(series.getMinStartIndex());                final TimePeriod end = series.getTimePeriod(series.getMaxEndIndex());                if (this.domainIsPointsInTime) {                    if (this.xPosition == TimePeriodAnchor.START) {                        final TimePeriod maxStart = series.getTimePeriod(series.getMaxStartIndex());                        temp = new Range(start.getStart().getTime(), maxStart.getStart().getTime());                    }                    else if (this.xPosition == TimePeriodAnchor.MIDDLE) {                        final TimePeriod minMiddle = series.getTimePeriod(                            series.getMinMiddleIndex()                        );                        final long s1 = minMiddle.getStart().getTime();                        final long e1 = minMiddle.getEnd().getTime();                        final TimePeriod maxMiddle = series.getTimePeriod(                            series.getMaxMiddleIndex()                        );                        final long s2 = maxMiddle.getStart().getTime();                        final long e2 = maxMiddle.getEnd().getTime();                        temp = new Range(s1 + (e1 - s1) / 2, s2 + (e2 - s2) / 2);                    }                    else if (this.xPosition == TimePeriodAnchor.END) {                        final TimePeriod minEnd = series.getTimePeriod(series.getMinEndIndex());                        temp = new Range(minEnd.getEnd().getTime(), end.getEnd().getTime());                    }                }                else {                    temp = new Range(start.getStart().getTime(), end.getEnd().getTime());                }                result = Range.combine(result, temp);            }        }        return result;    }}

⌨️ 快捷键说明

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