cyclicxyitemrenderer.java

来自「JfreeChart 常用图表例子」· Java 代码 · 共 520 行 · 第 1/2 页

JAVA
520
字号
            return;        }        OverwriteDataSet newset = new OverwriteDataSet(x, y, dataset);        if (cnax != null) {            if (xcycleBound == x[0]) {                cnax.setBoundMappedToLastCycle(x[1] <= xcycleBound);            }            if (xcycleBound == x[1]) {                cnax.setBoundMappedToLastCycle(x[0] <= xcycleBound);            }        }        if (cnay != null) {            if (ycycleBound == y[0]) {                cnay.setBoundMappedToLastCycle(y[1] <= ycycleBound);            }            if (ycycleBound == y[1]) {                cnay.setBoundMappedToLastCycle(y[0] <= ycycleBound);            }        }        super.drawItem(            g2, state, dataArea, info, plot, domainAxis, rangeAxis,             newset, series, 1, crosshairState, pass        );        if (cnax != null) {            if (xcycleBound == x[1]) {                cnax.setBoundMappedToLastCycle(x[2] <= xcycleBound);            }            if (xcycleBound == x[2]) {                cnax.setBoundMappedToLastCycle(x[1] <= xcycleBound);            }        }        if (cnay != null) {            if (ycycleBound == y[1]) {                cnay.setBoundMappedToLastCycle(y[2] <= ycycleBound);            }            if (ycycleBound == y[2]) {                cnay.setBoundMappedToLastCycle(y[1] <= ycycleBound);            }        }        super.drawItem(            g2, state, dataArea, info, plot, domainAxis, rangeAxis, newset,             series, 2, crosshairState, pass        );        if (x.length == 4) {            if (cnax != null) {                if (xcycleBound == x[2]) {                    cnax.setBoundMappedToLastCycle(x[3] <= xcycleBound);                }                if (xcycleBound == x[3]) {                    cnax.setBoundMappedToLastCycle(x[2] <= xcycleBound);                }            }            if (cnay != null) {                if (ycycleBound == y[2]) {                    cnay.setBoundMappedToLastCycle(y[3] <= ycycleBound);                }                if (ycycleBound == y[3]) {                    cnay.setBoundMappedToLastCycle(y[2] <= ycycleBound);                }            }            super.drawItem(                g2, state, dataArea, info, plot, domainAxis, rangeAxis, newset,                 series, 3, crosshairState, pass            );        }                if (cnax != null) {            cnax.setBoundMappedToLastCycle(xBoundMapping);        }        if (cnay != null) {            cnay.setBoundMappedToLastCycle(yBoundMapping);        }    }    /**      * A dataset to hold the interpolated points when drawing new lines.      */    protected static class OverwriteDataSet implements XYDataset {                /** The delegate dataset. */        protected XYDataset delegateSet;                /** Storage for the x and y values. */        Double[] x, y;                /**         * Creates a new dataset.         *          * @param x  the x values.         * @param y  the y values.         * @param delegateSet  the dataset.         */        public OverwriteDataSet(double [] x, double[] y,                                 XYDataset delegateSet) {            this.delegateSet = delegateSet;            this.x = new Double[x.length]; this.y = new Double[y.length];            for (int i = 0; i < x.length; ++i) {                 this.x[i] = new Double(x[i]);                this.y[i] = new Double(y[i]);            }        }        /**         * Returns the order of the domain (X) values.         *          * @return The domain order.         */        public DomainOrder getDomainOrder() {            return DomainOrder.NONE;        }                /**         * Returns the number of items for the given series.         *          * @param series  the series index (zero-based).         *          * @return The item count.         */        public int getItemCount(int series) {            return this.x.length;        }        /**         * Returns the x-value.         *          * @param series  the series index (zero-based).         * @param item  the item index (zero-based).         *          * @return The x-value.         */        public Number getX(int series, int item) {            return this.x[item];        }        /**         * Returns the x-value (as a double primitive) for an item within a          * series.         *          * @param series  the series (zero-based index).         * @param item  the item (zero-based index).         *          * @return The x-value.         */        public double getXValue(int series, int item) {            double result = Double.NaN;            Number x = getX(series, item);            if (x != null) {                result = x.doubleValue();               }            return result;           }        /**         * Returns the y-value.         *          * @param series  the series index (zero-based).         * @param item  the item index (zero-based).         *          * @return The y-value.         */        public Number getY(int series, int item) {            return this.y[item];        }        /**         * Returns the y-value (as a double primitive) for an item within a          * series.         *          * @param series  the series (zero-based index).         * @param item  the item (zero-based index).         *          * @return The y-value.         */        public double getYValue(int series, int item) {            double result = Double.NaN;            Number y = getY(series, item);            if (y != null) {                result = y.doubleValue();               }            return result;           }        /**         * Returns the number of series in the dataset.         *          * @return The series count.         */        public int getSeriesCount() {            return this.delegateSet.getSeriesCount();        }        /**         * Returns the name of the given series.         *          * @param series  the series index (zero-based).         *          * @return The series name.         */        public Comparable getSeriesKey(int series) {            return this.delegateSet.getSeriesKey(series);        }        /**         * Returns the index of the named series, or -1.         *          * @param seriesName  the series name.         *          * @return The index.         */        public int indexOf(Comparable seriesName) {            return this.delegateSet.indexOf(seriesName);        }        /**         * Does nothing.         *          * @param listener  ignored.         */        public void addChangeListener(DatasetChangeListener listener) {            // unused in parent        }        /**         * Does nothing.         *          * @param listener  ignored.         */        public void removeChangeListener(DatasetChangeListener listener) {            // unused in parent        }        /**         * Returns the dataset group.         *          * @return The dataset group.         */        public DatasetGroup getGroup() {            // unused but must return something, so while we are at it...            return this.delegateSet.getGroup();        }        /**         * Does nothing.         *          * @param group  ignored.         */        public void setGroup(DatasetGroup group) {            // unused in parent        }            }    }

⌨️ 快捷键说明

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