abstractxyitemrenderer.java

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

JAVA
1,452
字号
     * @param row  the row index (zero based).     * @param column  the column index (zero based).     *     * @return The generator (possibly <code>null</code>).     */    public XYToolTipGenerator getToolTipGenerator(int row, int column) {        return getSeriesToolTipGenerator(row);    }    /**     * Returns the tool tip generator for a series.     *     * @param series  the series index (zero based).     *     * @return The generator (possibly <code>null</code>).     */    public XYToolTipGenerator getSeriesToolTipGenerator(int series) {        // return the generator for ALL series, if there is one...        if (this.toolTipGenerator != null) {            return this.toolTipGenerator;        }        // otherwise look up the generator table        XYToolTipGenerator generator            = (XYToolTipGenerator) this.toolTipGeneratorList.get(series);        if (generator == null) {            generator = this.baseToolTipGenerator;        }        return generator;    }    /**     * Sets the tool tip generator for ALL series and sends a      * {@link RendererChangeEvent} to all registered listeners.     *     * @param generator  the generator (<code>null</code> permitted).     */    public void setToolTipGenerator(XYToolTipGenerator generator) {        this.toolTipGenerator = generator;        notifyListeners(new RendererChangeEvent(this));    }    /**     * Sets the tool tip generator for a series and sends a      * {@link RendererChangeEvent} to all registered listeners.     *     * @param series  the series index (zero based).     * @param generator  the generator (<code>null</code> permitted).     */    public void setSeriesToolTipGenerator(int series,                                           XYToolTipGenerator generator) {        this.toolTipGeneratorList.set(series, generator);        notifyListeners(new RendererChangeEvent(this));    }    /**     * Returns the base tool tip generator.     *     * @return The generator (possibly <code>null</code>).     */    public XYToolTipGenerator getBaseToolTipGenerator() {        return this.baseToolTipGenerator;    }    /**     * Sets the base tool tip generator and sends a {@link RendererChangeEvent}     * to all registered listeners.     *     * @param generator  the generator (<code>null</code> permitted).     */    public void setBaseToolTipGenerator(XYToolTipGenerator generator) {        this.baseToolTipGenerator = generator;        notifyListeners(new RendererChangeEvent(this));    }    // URL GENERATOR        /**     * Returns the URL generator for HTML image maps.     *     * @return The URL generator (possibly <code>null</code>).     */    public XYURLGenerator getURLGenerator() {        return this.urlGenerator;    }    /**     * Sets the URL generator for HTML image maps.     *     * @param urlGenerator  the URL generator (<code>null</code> permitted).     */    public void setURLGenerator(XYURLGenerator urlGenerator) {        this.urlGenerator = urlGenerator;        notifyListeners(new RendererChangeEvent(this));    }    /**     * Adds an annotation and sends a {@link RendererChangeEvent} to all      * registered listeners.  The annotation is added to the foreground     * layer.     *      * @param annotation  the annotation (<code>null</code> not permitted).     */    public void addAnnotation(XYAnnotation annotation) {        // defer argument checking        addAnnotation(annotation, Layer.FOREGROUND);    }        /**     * Adds an annotation to the specified layer.     *      * @param annotation  the annotation (<code>null</code> not permitted).     * @param layer  the layer (<code>null</code> not permitted).     */    public void addAnnotation(XYAnnotation annotation, Layer layer) {        if (annotation == null) {            throw new IllegalArgumentException("Null 'annotation' argument.");        }        if (layer.equals(Layer.FOREGROUND)) {            this.foregroundAnnotations.add(annotation);            notifyListeners(new RendererChangeEvent(this));        }        else if (layer.equals(Layer.BACKGROUND)) {            this.backgroundAnnotations.add(annotation);            notifyListeners(new RendererChangeEvent(this));        }        else {            // should never get here            throw new RuntimeException("Unknown layer.");        }    }    /**     * Removes the specified annotation and sends a {@link RendererChangeEvent}     * to all registered listeners.     *      * @param annotation  the annotation to remove (<code>null</code> not      *                    permitted).     *      * @return A boolean to indicate whether or not the annotation was      *         successfully removed.     */    public boolean removeAnnotation(XYAnnotation annotation) {        boolean removed = this.foregroundAnnotations.remove(annotation);        removed = removed & this.backgroundAnnotations.remove(annotation);        notifyListeners(new RendererChangeEvent(this));        return removed;    }        /**     * Removes all annotations and sends a {@link RendererChangeEvent}     * to all registered listeners.     */    public void removeAnnotations() {        this.foregroundAnnotations.clear();        this.backgroundAnnotations.clear();        notifyListeners(new RendererChangeEvent(this));            }        /**     * Returns the radius of the circle used for the default entity area     * when no area is specified.     *     * @return A radius.     */    public int getDefaultEntityRadius() {        return this.defaultEntityRadius;    }        /**     * Sets the radius of the circle used for the default entity area     * when no area is specified.     *      * @param radius  the radius.     */    public void setDefaultEntityRadius(int radius) {        this.defaultEntityRadius = radius;    }        /**     * Returns the legend item label generator.     *      * @return The label generator (never <code>null</code>).     */    public XYSeriesLabelGenerator getLegendItemLabelGenerator() {        return this.legendItemLabelGenerator;    }        /**     * Sets the legend item label generator.     *      * @param generator  the generator (<code>null</code> not permitted).     */    public void setLegendItemLabelGenerator(XYSeriesLabelGenerator generator) {        if (generator == null) {            throw new IllegalArgumentException("Null 'generator' argument.");        }        this.legendItemLabelGenerator = generator;    }        /**     * Returns the legend item tool tip generator.     *      * @return The tool tip generator (possibly <code>null</code>).     */    public XYSeriesLabelGenerator getLegendItemToolTipGenerator() {        return this.legendItemToolTipGenerator;    }        /**     * Sets the legend item tool tip generator.     *      * @param generator  the generator (<code>null</code> permitted).     */    public void setLegendItemToolTipGenerator(XYSeriesLabelGenerator generator)     {        this.legendItemToolTipGenerator = generator;    }        /**     * Returns the legend item URL generator.     *      * @return The URL generator (possibly <code>null</code>).     */    public XYSeriesLabelGenerator getLegendItemURLGenerator() {        return this.legendItemURLGenerator;    }        /**     * Sets the legend item URL generator.     *      * @param generator  the generator (<code>null</code> permitted).     */    public void setLegendItemURLGenerator(XYSeriesLabelGenerator generator)     {        this.legendItemURLGenerator = generator;    }        /**     * Returns the lower and upper bounds (range) of the x-values in the      * specified dataset.     *      * @param dataset  the dataset (<code>null</code> permitted).     *      * @return The range (<code>null</code> if the dataset is <code>null</code>     *         or empty).     */    public Range findDomainBounds(XYDataset dataset) {        if (dataset != null) {            return DatasetUtilities.findDomainBounds(dataset, false);        }        else {            return null;        }    }    /**     * Returns the range of values the renderer requires to display all the      * items from the specified dataset.     *      * @param dataset  the dataset (<code>null</code> permitted).     *      * @return The range (<code>null</code> if the dataset is <code>null</code>      *         or empty).     */    public Range findRangeBounds(XYDataset dataset) {        if (dataset != null) {            return DatasetUtilities.findRangeBounds(dataset, false);        }        else {            return null;        }    }    /**     * Returns a (possibly empty) collection of legend items for the series     * that this renderer is responsible for drawing.     *     * @return The legend item collection (never <code>null</code>).     */    public LegendItemCollection getLegendItems() {        if (this.plot == null) {            return new LegendItemCollection();        }        LegendItemCollection result = new LegendItemCollection();        int index = this.plot.getIndexOf(this);        XYDataset dataset = this.plot.getDataset(index);        if (dataset != null) {            int seriesCount = dataset.getSeriesCount();            for (int i = 0; i < seriesCount; i++) {                if (isSeriesVisibleInLegend(i)) {                    LegendItem item = getLegendItem(index, i);                    if (item != null) {                        result.add(item);                    }                }            }           }        return result;    }    /**     * Returns a default legend item for the specified series.  Subclasses      * should override this method to generate customised items.     *     * @param datasetIndex  the dataset index (zero-based).     * @param series  the series index (zero-based).     *     * @return A legend item for the series.     */    public LegendItem getLegendItem(int datasetIndex, int series) {        LegendItem result = null;        XYPlot xyplot = getPlot();        if (xyplot != null) {            XYDataset dataset = xyplot.getDataset(datasetIndex);            if (dataset != null) {                String label = this.legendItemLabelGenerator.generateLabel(                    dataset, series                );                String description = label;                String toolTipText = null;                if (getLegendItemToolTipGenerator() != null) {                    toolTipText = getLegendItemToolTipGenerator().generateLabel(                        dataset, series                    );                }                String urlText = null;                if (getLegendItemURLGenerator() != null) {                    urlText = getLegendItemURLGenerator().generateLabel(                        dataset, series                    );                }                Shape shape = getSeriesShape(series);                Paint paint = getSeriesPaint(series);                Paint outlinePaint = getSeriesOutlinePaint(series);                Stroke outlineStroke = getSeriesOutlineStroke(series);                result = new LegendItem(                    label, description, toolTipText, urlText, shape, paint,                     outlineStroke, outlinePaint                );            }        }        return result;    }    /**     * Fills a band between two values on the axis.  This can be used to color      * bands between the grid lines.     *     * @param g2  the graphics device.     * @param plot  the plot.     * @param axis  the domain axis.     * @param dataArea  the data area.     * @param start  the start value.     * @param end  the end value.     */    public void fillDomainGridBand(Graphics2D g2,                                   XYPlot plot,                                   ValueAxis axis,                                   Rectangle2D dataArea,                                   double start, double end) {

⌨️ 快捷键说明

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