xyplot.java

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

JAVA
1,937
字号
     * Maps a dataset to a particular range axis.  All data will be plotted     * against axis zero by default, no mapping is required for this case.     *     * @param index  the dataset index (zero-based).     * @param axisIndex  the axis index.     */    public void mapDatasetToRangeAxis(int index, int axisIndex) {        this.datasetToRangeAxisMap.put(            new Integer(index), new Integer(axisIndex)        );        // fake a dataset change event to update axes...        datasetChanged(new DatasetChangeEvent(this, getDataset(index)));    }    /**     * Returns the renderer for the primary dataset.     *     * @return The item renderer (possibly <code>null</code>).     */    public XYItemRenderer getRenderer() {        return getRenderer(0);    }    /**     * Returns the renderer for a dataset, or <code>null</code>.     *     * @param index  the renderer index.     *     * @return The renderer (possibly <code>null</code>).     */    public XYItemRenderer getRenderer(int index) {        XYItemRenderer result = null;        if (this.renderers.size() > index) {            result = (XYItemRenderer) this.renderers.get(index);        }        return result;    }    /**     * Sets the renderer for the primary dataset and sends a     * {@link PlotChangeEvent} to all registered listeners.  If the renderer     * is set to <code>null</code>, no data will be displayed.     *     * @param renderer  the renderer (<code>null</code> permitted).     */    public void setRenderer(XYItemRenderer renderer) {        setRenderer(0, renderer);    }    /**     * Sets a renderer and sends a {@link PlotChangeEvent} is sent to all     * registered listeners.     *     * @param index  the index.     * @param renderer  the renderer.     */    public void setRenderer(int index, XYItemRenderer renderer) {        XYItemRenderer existing = getRenderer(index);        if (existing != null) {            existing.removeChangeListener(this);        }        this.renderers.set(index, renderer);        if (renderer != null) {            renderer.setPlot(this);            renderer.addChangeListener(this);        }        configureDomainAxes();        configureRangeAxes();        notifyListeners(new PlotChangeEvent(this));    }    /**     * Returns the dataset rendering order.     *     * @return The order (never <code>null</code>).     */    public DatasetRenderingOrder getDatasetRenderingOrder() {        return this.datasetRenderingOrder;    }    /**     * Sets the rendering order and sends a {@link PlotChangeEvent} to all     * registered listeners.  By default, the plot renders the primary dataset     * last (so that the primary dataset overlays the secondary datasets).     * You can reverse this if you want to.     *     * @param order  the rendering order (<code>null</code> not permitted).     */    public void setDatasetRenderingOrder(DatasetRenderingOrder order) {        if (order == null) {            throw new IllegalArgumentException("Null 'order' argument.");        }        this.datasetRenderingOrder = order;        notifyListeners(new PlotChangeEvent(this));    }    /**     * Returns the series rendering order.     *     * @return the order (never <code>null</code>).     */    public SeriesRenderingOrder getSeriesRenderingOrder() {        return this.seriesRenderingOrder;    }    /**     * Sets the series order and sends a {@link PlotChangeEvent} to all     * registered listeners.  By default, the plot renders the primary series     * last (so that the primary series appears to be on top).     * You can reverse this if you want to.     *     * @param order  the rendering order (<code>null</code> not permitted).     */    public void setSeriesRenderingOrder(SeriesRenderingOrder order) {        if (order == null) {            throw new IllegalArgumentException("Null 'order' argument.");        }        this.seriesRenderingOrder = order;        notifyListeners(new PlotChangeEvent(this));    }    /**     * Returns the index of the specified renderer, or <code>-1</code> if the     * renderer is not assigned to this plot.     *     * @param renderer  the renderer (<code>null</code> permitted).     *     * @return The renderer index.     */    public int getIndexOf(XYItemRenderer renderer) {        return this.renderers.indexOf(renderer);    }    /**     * Returns the renderer for the specified dataset.  The code first     * determines the index of the dataset, then checks if there is a     * renderer with the same index (if not, the method returns renderer(0).     *     * @param dataset  the dataset (<code>null</code> permitted).     *     * @return The renderer (possibly <code>null</code>).     */    public XYItemRenderer getRendererForDataset(XYDataset dataset) {        XYItemRenderer result = null;        for (int i = 0; i < this.datasets.size(); i++) {            if (this.datasets.get(i) == dataset) {                result = (XYItemRenderer) this.renderers.get(i);                if (result == null) {                    result = getRenderer();                }                break;            }        }        return result;    }    /**     * Returns the weight for this plot when it is used as a subplot within a     * combined plot.     *     * @return The weight.     */    public int getWeight() {        return this.weight;    }    /**     * Sets the weight for the plot.     *     * @param weight  the weight.     */    public void setWeight(int weight) {        this.weight = weight;    }    /**     * Returns <code>true</code> if the domain gridlines are visible, and     * <code>false<code> otherwise.     *     * @return <code>true</code> or <code>false</code>.     */    public boolean isDomainGridlinesVisible() {        return this.domainGridlinesVisible;    }    /**     * Sets the flag that controls whether or not the domain grid-lines are     * visible.     * <p>     * If the flag value is changed, a {@link PlotChangeEvent} is sent to all     * registered listeners.     *     * @param visible  the new value of the flag.     */    public void setDomainGridlinesVisible(boolean visible) {        if (this.domainGridlinesVisible != visible) {            this.domainGridlinesVisible = visible;            notifyListeners(new PlotChangeEvent(this));        }    }    /**     * Returns the stroke for the grid-lines (if any) plotted against the     * domain axis.     *     * @return The stroke.     */    public Stroke getDomainGridlineStroke() {        return this.domainGridlineStroke;    }    /**     * Sets the stroke for the grid lines plotted against the domain axis.     * <p>     * If you set this to <code>null</code>, no grid lines will be drawn.     *     * @param stroke  the stroke (<code>null</code> permitted).     */    public void setDomainGridlineStroke(Stroke stroke) {        this.domainGridlineStroke = stroke;        notifyListeners(new PlotChangeEvent(this));    }    /**     * Returns the paint for the grid lines (if any) plotted against the domain     * axis.     *     * @return The paint.     */    public Paint getDomainGridlinePaint() {        return this.domainGridlinePaint;    }    /**     * Sets the paint for the grid lines plotted against the domain axis.     * <p>     * If you set this to <code>null</code>, no grid lines will be drawn.     *     * @param paint  the paint (<code>null</code> permitted).     */    public void setDomainGridlinePaint(Paint paint) {        this.domainGridlinePaint = paint;        notifyListeners(new PlotChangeEvent(this));    }    /**     * Returns <code>true</code> if the range axis grid is visible, and     * <code>false<code> otherwise.     *     * @return A boolean.     */    public boolean isRangeGridlinesVisible() {        return this.rangeGridlinesVisible;    }    /**     * Sets the flag that controls whether or not the range axis grid lines     * are visible.     * <p>     * If the flag value is changed, a {@link PlotChangeEvent} is sent to all     * registered listeners.     *     * @param visible  the new value of the flag.     */    public void setRangeGridlinesVisible(boolean visible) {        if (this.rangeGridlinesVisible != visible) {            this.rangeGridlinesVisible = visible;            notifyListeners(new PlotChangeEvent(this));        }    }    /**     * Returns the stroke for the grid lines (if any) plotted against the     * range axis.     *     * @return The stroke (never <code>null</code>).     */    public Stroke getRangeGridlineStroke() {        return this.rangeGridlineStroke;    }    /**     * Sets the stroke for the grid lines plotted against the range axis,     * and sends a {@link PlotChangeEvent} to all registered listeners.     *     * @param stroke  the stroke (<code>null</code> not permitted).     */    public void setRangeGridlineStroke(Stroke stroke) {        if (stroke == null) {            throw new IllegalArgumentException("Null 'stroke' argument.");        }        this.rangeGridlineStroke = stroke;        notifyListeners(new PlotChangeEvent(this));    }    /**     * Returns the paint for the grid lines (if any) plotted against the range     * axis.     *     * @return The paint (never <code>null</code>).     */    public Paint getRangeGridlinePaint() {        return this.rangeGridlinePaint;    }    /**     * Sets the paint for the grid lines plotted against the range axis and     * sends a {@link PlotChangeEvent} to all registered listeners.     *     * @param paint  the paint (<code>null</code> permitted).     */    public void setRangeGridlinePaint(Paint paint) {        this.rangeGridlinePaint = paint;        notifyListeners(new PlotChangeEvent(this));    }    /**     * Returns a flag that controls whether or not a zero baseline is     * displayed for the range axis.     *     * @return A boolean.     */    public boolean isRangeZeroBaselineVisible() {        return this.rangeZeroBaselineVisible;    }    /**     * Sets the flag that controls whether or not the zero baseline is     * displayed for the range axis, and sends a {@link PlotChangeEvent} to     * all registered listeners.     *     * @param visible  the flag.     */    public void setRangeZeroBaselineVisible(boolean visible) {        this.rangeZeroBaselineVisible = visible;        notifyListeners(new PlotChangeEvent(this));    }    /**     * Returns the stroke used for the zero baseline against the range axis.     *     * @return The stroke (never <code>null</code>).     */    public Stroke getRangeZeroBaselineStroke() {        return this.rangeZeroBaselineStroke;    }    /**     * Sets the stroke for the zero baseline for the range axis,     * and sends a {@link PlotChangeEvent} to all registered listeners.     *     * @param stroke  the stroke (<code>null</code> not permitted).     */    public void setRangeZeroBaselineStroke(Stroke stroke) {        if (stroke == null) {            throw new IllegalArgumentException("Null 'stroke' argument.");        }        this.rangeZeroBaselineStroke = stroke;        notifyListeners(new PlotChangeEvent(this));    }    /**     * Returns the paint for the zero baseline (if any) plotted against the     * range axis.     *     * @return The paint (never <code>null</code>).     */    public Paint getRangeZeroBaselinePaint() {        return this.rangeZeroBaselinePaint;    }    /**     * Sets the paint for the zero baseline plotted against the range axis and     * sends a {@link PlotChangeEvent} to all registered listeners.     *     * @param paint  the paint (<code>null</code> permitted).     */    public void setRangeZeroBaselinePaint(Paint paint) {        this.rangeZeroBaselinePaint = paint;        notifyListeners(new PlotChangeEvent(this));    }    /**     * Returns the paint used for the domain tick bands.  If this is     * <code>null</code>, no tick bands will be drawn.     *     * @return The paint (possibly <code>null</code>).

⌨️ 快捷键说明

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