@Test public void testGetLegendItem() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(21.0, "R1", "C1"); BarRenderer r = new BarRenderer(); CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("x"), new NumberAxis("y"), r); new JFreeChart(plot); LegendItem li = r.getLegendItem(0, 0); assertNotNull(li); r.setSeriesVisibleInLegend(0, Boolean.FALSE); li = r.getLegendItem(0, 0); assertNull(li); }
@Override public LegendItem getLegendItem(int datasetIndex, int series) { CategoryPlot cp = getPlot(); if (cp == null) { return null; } if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) { return null; } CategoryDataset dataset = cp.getDataset(datasetIndex); String label = getLegendItemLabelGenerator().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 = lookupLegendShape(series); Paint paint = lookupSeriesPaint(series); Paint outlinePaint = lookupSeriesOutlinePaint(series); Stroke outlineStroke = lookupSeriesOutlineStroke(series); LegendItem result = new LegendItem(label, description, toolTipText, urlText, true, shape, true, paint, isDrawBarOutline(), outlinePaint, outlineStroke, false, new Line2D.Float(), new BasicStroke(1.0f), Color.BLACK); result.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { result.setLabelPaint(labelPaint); } result.setDataset(dataset); result.setDatasetIndex(datasetIndex); result.setSeriesKey(dataset.getRowKey(series)); result.setSeriesIndex(series); if (this.gradientPaintTransformer != null) { result.setFillPaintTransformer(this.gradientPaintTransformer); } return result; }
BarRenderer extends AbstractCategoryItemRenderer implements Cloneable, PublicCloneable, Serializable { @Override public LegendItem getLegendItem(int datasetIndex, int series) { CategoryPlot cp = getPlot(); if (cp == null) { return null; } if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) { return null; } CategoryDataset dataset = cp.getDataset(datasetIndex); String label = getLegendItemLabelGenerator().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 = lookupLegendShape(series); Paint paint = lookupSeriesPaint(series); Paint outlinePaint = lookupSeriesOutlinePaint(series); Stroke outlineStroke = lookupSeriesOutlineStroke(series); LegendItem result = new LegendItem(label, description, toolTipText, urlText, true, shape, true, paint, isDrawBarOutline(), outlinePaint, outlineStroke, false, new Line2D.Float(), new BasicStroke(1.0f), Color.BLACK); result.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { result.setLabelPaint(labelPaint); } result.setDataset(dataset); result.setDatasetIndex(datasetIndex); result.setSeriesKey(dataset.getRowKey(series)); result.setSeriesIndex(series); if (this.gradientPaintTransformer != null) { result.setFillPaintTransformer(this.gradientPaintTransformer); } return result; } }
BarRenderer extends AbstractCategoryItemRenderer implements Cloneable, PublicCloneable, Serializable { @Override public LegendItem getLegendItem(int datasetIndex, int series) { CategoryPlot cp = getPlot(); if (cp == null) { return null; } if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) { return null; } CategoryDataset dataset = cp.getDataset(datasetIndex); String label = getLegendItemLabelGenerator().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 = lookupLegendShape(series); Paint paint = lookupSeriesPaint(series); Paint outlinePaint = lookupSeriesOutlinePaint(series); Stroke outlineStroke = lookupSeriesOutlineStroke(series); LegendItem result = new LegendItem(label, description, toolTipText, urlText, true, shape, true, paint, isDrawBarOutline(), outlinePaint, outlineStroke, false, new Line2D.Float(), new BasicStroke(1.0f), Color.BLACK); result.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { result.setLabelPaint(labelPaint); } result.setDataset(dataset); result.setDatasetIndex(datasetIndex); result.setSeriesKey(dataset.getRowKey(series)); result.setSeriesIndex(series); if (this.gradientPaintTransformer != null) { result.setFillPaintTransformer(this.gradientPaintTransformer); } return result; } BarRenderer(); }
BarRenderer extends AbstractCategoryItemRenderer implements Cloneable, PublicCloneable, Serializable { @Override public LegendItem getLegendItem(int datasetIndex, int series) { CategoryPlot cp = getPlot(); if (cp == null) { return null; } if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) { return null; } CategoryDataset dataset = cp.getDataset(datasetIndex); String label = getLegendItemLabelGenerator().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 = lookupLegendShape(series); Paint paint = lookupSeriesPaint(series); Paint outlinePaint = lookupSeriesOutlinePaint(series); Stroke outlineStroke = lookupSeriesOutlineStroke(series); LegendItem result = new LegendItem(label, description, toolTipText, urlText, true, shape, true, paint, isDrawBarOutline(), outlinePaint, outlineStroke, false, new Line2D.Float(), new BasicStroke(1.0f), Color.BLACK); result.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { result.setLabelPaint(labelPaint); } result.setDataset(dataset); result.setDatasetIndex(datasetIndex); result.setSeriesKey(dataset.getRowKey(series)); result.setSeriesIndex(series); if (this.gradientPaintTransformer != null) { result.setFillPaintTransformer(this.gradientPaintTransformer); } return result; } BarRenderer(); static BarPainter getDefaultBarPainter(); static void setDefaultBarPainter(BarPainter painter); static boolean getDefaultShadowsVisible(); static void setDefaultShadowsVisible(boolean visible); double getBase(); void setBase(double base); double getItemMargin(); void setItemMargin(double percent); boolean isDrawBarOutline(); void setDrawBarOutline(boolean draw); double getMaximumBarWidth(); void setMaximumBarWidth(double percent); double getMinimumBarLength(); void setMinimumBarLength(double min); GradientPaintTransformer getGradientPaintTransformer(); void setGradientPaintTransformer(
            GradientPaintTransformer transformer); ItemLabelPosition getPositiveItemLabelPositionFallback(); void setPositiveItemLabelPositionFallback(
            ItemLabelPosition position); ItemLabelPosition getNegativeItemLabelPositionFallback(); void setNegativeItemLabelPositionFallback(
            ItemLabelPosition position); boolean getIncludeBaseInRange(); void setIncludeBaseInRange(boolean include); BarPainter getBarPainter(); void setBarPainter(BarPainter painter); boolean getShadowsVisible(); void setShadowVisible(boolean visible); Paint getShadowPaint(); void setShadowPaint(Paint paint); double getShadowXOffset(); void setShadowXOffset(double offset); double getShadowYOffset(); void setShadowYOffset(double offset); double getLowerClip(); double getUpperClip(); @Override CategoryItemRendererState initialise(Graphics2D g2,
                                                Rectangle2D dataArea,
                                                CategoryPlot plot,
                                                int rendererIndex,
                                                PlotRenderingInfo info); @Override Range findRangeBounds(CategoryDataset dataset,
            boolean includeInterval); @Override LegendItem getLegendItem(int datasetIndex, int series); @Override void drawItem(Graphics2D g2,
                         CategoryItemRendererState state,
                         Rectangle2D dataArea,
                         CategoryPlot plot,
                         CategoryAxis domainAxis,
                         ValueAxis rangeAxis,
                         CategoryDataset dataset,
                         int row,
                         int column,
                         int pass); @Override boolean equals(Object obj); }
BarRenderer extends AbstractCategoryItemRenderer implements Cloneable, PublicCloneable, Serializable { @Override public LegendItem getLegendItem(int datasetIndex, int series) { CategoryPlot cp = getPlot(); if (cp == null) { return null; } if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) { return null; } CategoryDataset dataset = cp.getDataset(datasetIndex); String label = getLegendItemLabelGenerator().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 = lookupLegendShape(series); Paint paint = lookupSeriesPaint(series); Paint outlinePaint = lookupSeriesOutlinePaint(series); Stroke outlineStroke = lookupSeriesOutlineStroke(series); LegendItem result = new LegendItem(label, description, toolTipText, urlText, true, shape, true, paint, isDrawBarOutline(), outlinePaint, outlineStroke, false, new Line2D.Float(), new BasicStroke(1.0f), Color.BLACK); result.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { result.setLabelPaint(labelPaint); } result.setDataset(dataset); result.setDatasetIndex(datasetIndex); result.setSeriesKey(dataset.getRowKey(series)); result.setSeriesIndex(series); if (this.gradientPaintTransformer != null) { result.setFillPaintTransformer(this.gradientPaintTransformer); } return result; } BarRenderer(); static BarPainter getDefaultBarPainter(); static void setDefaultBarPainter(BarPainter painter); static boolean getDefaultShadowsVisible(); static void setDefaultShadowsVisible(boolean visible); double getBase(); void setBase(double base); double getItemMargin(); void setItemMargin(double percent); boolean isDrawBarOutline(); void setDrawBarOutline(boolean draw); double getMaximumBarWidth(); void setMaximumBarWidth(double percent); double getMinimumBarLength(); void setMinimumBarLength(double min); GradientPaintTransformer getGradientPaintTransformer(); void setGradientPaintTransformer(
            GradientPaintTransformer transformer); ItemLabelPosition getPositiveItemLabelPositionFallback(); void setPositiveItemLabelPositionFallback(
            ItemLabelPosition position); ItemLabelPosition getNegativeItemLabelPositionFallback(); void setNegativeItemLabelPositionFallback(
            ItemLabelPosition position); boolean getIncludeBaseInRange(); void setIncludeBaseInRange(boolean include); BarPainter getBarPainter(); void setBarPainter(BarPainter painter); boolean getShadowsVisible(); void setShadowVisible(boolean visible); Paint getShadowPaint(); void setShadowPaint(Paint paint); double getShadowXOffset(); void setShadowXOffset(double offset); double getShadowYOffset(); void setShadowYOffset(double offset); double getLowerClip(); double getUpperClip(); @Override CategoryItemRendererState initialise(Graphics2D g2,
                                                Rectangle2D dataArea,
                                                CategoryPlot plot,
                                                int rendererIndex,
                                                PlotRenderingInfo info); @Override Range findRangeBounds(CategoryDataset dataset,
            boolean includeInterval); @Override LegendItem getLegendItem(int datasetIndex, int series); @Override void drawItem(Graphics2D g2,
                         CategoryItemRendererState state,
                         Rectangle2D dataArea,
                         CategoryPlot plot,
                         CategoryAxis domainAxis,
                         ValueAxis rangeAxis,
                         CategoryDataset dataset,
                         int row,
                         int column,
                         int pass); @Override boolean equals(Object obj); static final double DEFAULT_ITEM_MARGIN; static final double BAR_OUTLINE_WIDTH_THRESHOLD; }