@Test public void testGetLegendItems() { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("Item 1", 1.0); dataset.setValue("Item 2", 2.0); dataset.setValue("Item 3", 0.0); dataset.setValue("Item 4", null); PiePlot plot = new PiePlot(dataset); plot.setIgnoreNullValues(false); plot.setIgnoreZeroValues(false); List<LegendItem> items = plot.getLegendItems(); assertEquals(4, items.size()); plot.setIgnoreNullValues(true); items = plot.getLegendItems(); assertEquals(3, items.size()); plot.setIgnoreZeroValues(true); items = plot.getLegendItems(); assertEquals(2, items.size()); dataset.setValue("Item 5", -1.0); items = plot.getLegendItems(); assertEquals(2, items.size()); }
@Override public List<LegendItem> getLegendItems() { List<LegendItem> result = new ArrayList<LegendItem>(); if (this.dataset == null) { return result; } List<Comparable> keys = this.dataset.getKeys(); int section = 0; Shape shape = getLegendItemShape(); for (Comparable key : keys) { Number n = this.dataset.getValue(key); boolean include; if (n == null) { include = !this.ignoreNullValues; } else { double v = n.doubleValue(); if (v == 0.0) { include = !this.ignoreZeroValues; } else { include = v > 0.0; } } if (include) { String label = this.legendLabelGenerator.generateSectionLabel( this.dataset, key); if (label != null) { String description = label; String toolTipText = null; if (this.legendLabelToolTipGenerator != null) { toolTipText = this.legendLabelToolTipGenerator .generateSectionLabel(this.dataset, key); } String urlText = null; if (this.legendLabelURLGenerator != null) { urlText = this.legendLabelURLGenerator.generateURL( this.dataset, key, this.pieIndex); } Paint paint = lookupSectionPaint(key); Paint outlinePaint = lookupSectionOutlinePaint(key); Stroke outlineStroke = lookupSectionOutlineStroke(key); LegendItem item = new LegendItem(label, description, toolTipText, urlText, true, shape, true, paint, true, outlinePaint, outlineStroke, false, new Line2D.Float(), new BasicStroke(), Color.BLACK); item.setDataset(getDataset()); item.setSeriesIndex(this.dataset.getIndex(key)); item.setSeriesKey(key); result.add(item); } section++; } else { section++; } } return result; }
PiePlot extends Plot implements Cloneable, Serializable { @Override public List<LegendItem> getLegendItems() { List<LegendItem> result = new ArrayList<LegendItem>(); if (this.dataset == null) { return result; } List<Comparable> keys = this.dataset.getKeys(); int section = 0; Shape shape = getLegendItemShape(); for (Comparable key : keys) { Number n = this.dataset.getValue(key); boolean include; if (n == null) { include = !this.ignoreNullValues; } else { double v = n.doubleValue(); if (v == 0.0) { include = !this.ignoreZeroValues; } else { include = v > 0.0; } } if (include) { String label = this.legendLabelGenerator.generateSectionLabel( this.dataset, key); if (label != null) { String description = label; String toolTipText = null; if (this.legendLabelToolTipGenerator != null) { toolTipText = this.legendLabelToolTipGenerator .generateSectionLabel(this.dataset, key); } String urlText = null; if (this.legendLabelURLGenerator != null) { urlText = this.legendLabelURLGenerator.generateURL( this.dataset, key, this.pieIndex); } Paint paint = lookupSectionPaint(key); Paint outlinePaint = lookupSectionOutlinePaint(key); Stroke outlineStroke = lookupSectionOutlineStroke(key); LegendItem item = new LegendItem(label, description, toolTipText, urlText, true, shape, true, paint, true, outlinePaint, outlineStroke, false, new Line2D.Float(), new BasicStroke(), Color.BLACK); item.setDataset(getDataset()); item.setSeriesIndex(this.dataset.getIndex(key)); item.setSeriesKey(key); result.add(item); } section++; } else { section++; } } return result; } }
PiePlot extends Plot implements Cloneable, Serializable { @Override public List<LegendItem> getLegendItems() { List<LegendItem> result = new ArrayList<LegendItem>(); if (this.dataset == null) { return result; } List<Comparable> keys = this.dataset.getKeys(); int section = 0; Shape shape = getLegendItemShape(); for (Comparable key : keys) { Number n = this.dataset.getValue(key); boolean include; if (n == null) { include = !this.ignoreNullValues; } else { double v = n.doubleValue(); if (v == 0.0) { include = !this.ignoreZeroValues; } else { include = v > 0.0; } } if (include) { String label = this.legendLabelGenerator.generateSectionLabel( this.dataset, key); if (label != null) { String description = label; String toolTipText = null; if (this.legendLabelToolTipGenerator != null) { toolTipText = this.legendLabelToolTipGenerator .generateSectionLabel(this.dataset, key); } String urlText = null; if (this.legendLabelURLGenerator != null) { urlText = this.legendLabelURLGenerator.generateURL( this.dataset, key, this.pieIndex); } Paint paint = lookupSectionPaint(key); Paint outlinePaint = lookupSectionOutlinePaint(key); Stroke outlineStroke = lookupSectionOutlineStroke(key); LegendItem item = new LegendItem(label, description, toolTipText, urlText, true, shape, true, paint, true, outlinePaint, outlineStroke, false, new Line2D.Float(), new BasicStroke(), Color.BLACK); item.setDataset(getDataset()); item.setSeriesIndex(this.dataset.getIndex(key)); item.setSeriesKey(key); result.add(item); } section++; } else { section++; } } return result; } PiePlot();  PiePlot(PieDataset dataset); }
PiePlot extends Plot implements Cloneable, Serializable { @Override public List<LegendItem> getLegendItems() { List<LegendItem> result = new ArrayList<LegendItem>(); if (this.dataset == null) { return result; } List<Comparable> keys = this.dataset.getKeys(); int section = 0; Shape shape = getLegendItemShape(); for (Comparable key : keys) { Number n = this.dataset.getValue(key); boolean include; if (n == null) { include = !this.ignoreNullValues; } else { double v = n.doubleValue(); if (v == 0.0) { include = !this.ignoreZeroValues; } else { include = v > 0.0; } } if (include) { String label = this.legendLabelGenerator.generateSectionLabel( this.dataset, key); if (label != null) { String description = label; String toolTipText = null; if (this.legendLabelToolTipGenerator != null) { toolTipText = this.legendLabelToolTipGenerator .generateSectionLabel(this.dataset, key); } String urlText = null; if (this.legendLabelURLGenerator != null) { urlText = this.legendLabelURLGenerator.generateURL( this.dataset, key, this.pieIndex); } Paint paint = lookupSectionPaint(key); Paint outlinePaint = lookupSectionOutlinePaint(key); Stroke outlineStroke = lookupSectionOutlineStroke(key); LegendItem item = new LegendItem(label, description, toolTipText, urlText, true, shape, true, paint, true, outlinePaint, outlineStroke, false, new Line2D.Float(), new BasicStroke(), Color.BLACK); item.setDataset(getDataset()); item.setSeriesIndex(this.dataset.getIndex(key)); item.setSeriesKey(key); result.add(item); } section++; } else { section++; } } return result; } PiePlot();  PiePlot(PieDataset dataset); PieDataset getDataset(); void setDataset(PieDataset dataset); int getPieIndex(); void setPieIndex(int index); double getStartAngle(); void setStartAngle(double angle); Rotation getDirection(); void setDirection(Rotation direction); double getInteriorGap(); void setInteriorGap(double percent); boolean isCircular(); void setCircular(boolean flag); void setCircular(boolean circular, boolean notify); boolean getIgnoreNullValues(); void setIgnoreNullValues(boolean flag); boolean getIgnoreZeroValues(); void setIgnoreZeroValues(boolean flag); Paint getSectionPaint(Comparable key); void setSectionPaint(Comparable key, Paint paint); void clearSectionPaints(boolean notify); Paint getBaseSectionPaint(); void setBaseSectionPaint(Paint paint); boolean getAutoPopulateSectionPaint(); void setAutoPopulateSectionPaint(boolean auto); boolean getSectionOutlinesVisible(); void setSectionOutlinesVisible(boolean visible); Paint getSectionOutlinePaint(Comparable key); void setSectionOutlinePaint(Comparable key, Paint paint); void clearSectionOutlinePaints(boolean notify); Paint getBaseSectionOutlinePaint(); void setBaseSectionOutlinePaint(Paint paint); boolean getAutoPopulateSectionOutlinePaint(); void setAutoPopulateSectionOutlinePaint(boolean auto); Stroke getSectionOutlineStroke(Comparable key); void setSectionOutlineStroke(Comparable key, Stroke stroke); void clearSectionOutlineStrokes(boolean notify); Stroke getBaseSectionOutlineStroke(); void setBaseSectionOutlineStroke(Stroke stroke); boolean getAutoPopulateSectionOutlineStroke(); void setAutoPopulateSectionOutlineStroke(boolean auto); Paint getShadowPaint(); void setShadowPaint(Paint paint); double getShadowXOffset(); void setShadowXOffset(double offset); double getShadowYOffset(); void setShadowYOffset(double offset); double getExplodePercent(Comparable key); void setExplodePercent(Comparable key, double percent); double getMaximumExplodePercent(); PieSectionLabelGenerator getLabelGenerator(); void setLabelGenerator(PieSectionLabelGenerator generator); double getLabelGap(); void setLabelGap(double gap); double getMaximumLabelWidth(); void setMaximumLabelWidth(double width); boolean getLabelLinksVisible(); void setLabelLinksVisible(boolean visible); PieLabelLinkStyle getLabelLinkStyle(); void setLabelLinkStyle(PieLabelLinkStyle style); double getLabelLinkMargin(); void setLabelLinkMargin(double margin); Paint getLabelLinkPaint(); void setLabelLinkPaint(Paint paint); Stroke getLabelLinkStroke(); void setLabelLinkStroke(Stroke stroke); Font getLabelFont(); void setLabelFont(Font font); Paint getLabelPaint(); void setLabelPaint(Paint paint); Paint getLabelBackgroundPaint(); void setLabelBackgroundPaint(Paint paint); Paint getLabelOutlinePaint(); void setLabelOutlinePaint(Paint paint); Stroke getLabelOutlineStroke(); void setLabelOutlineStroke(Stroke stroke); Paint getLabelShadowPaint(); void setLabelShadowPaint(Paint paint); RectangleInsets getLabelPadding(); void setLabelPadding(RectangleInsets padding); boolean getSimpleLabels(); void setSimpleLabels(boolean simple); RectangleInsets getSimpleLabelOffset(); void setSimpleLabelOffset(RectangleInsets offset); AbstractPieLabelDistributor getLabelDistributor(); void setLabelDistributor(AbstractPieLabelDistributor distributor); PieToolTipGenerator getToolTipGenerator(); void setToolTipGenerator(PieToolTipGenerator generator); PieURLGenerator getURLGenerator(); void setURLGenerator(PieURLGenerator generator); double getMinimumArcAngleToDraw(); void setMinimumArcAngleToDraw(double angle); Shape getLegendItemShape(); void setLegendItemShape(Shape shape); PieSectionLabelGenerator getLegendLabelGenerator(); void setLegendLabelGenerator(PieSectionLabelGenerator generator); PieSectionLabelGenerator getLegendLabelToolTipGenerator(); void setLegendLabelToolTipGenerator(
            PieSectionLabelGenerator generator); PieURLGenerator getLegendLabelURLGenerator(); void setLegendLabelURLGenerator(PieURLGenerator generator); ShadowGenerator getShadowGenerator(); void setShadowGenerator(ShadowGenerator generator); void handleMouseWheelRotation(int rotateClicks); PiePlotState initialise(Graphics2D g2, Rectangle2D plotArea,
            PiePlot plot, Integer index, PlotRenderingInfo info); @Override void draw(Graphics2D g2, Rectangle2D area, Point2D anchor,
            PlotState parentState, PlotRenderingInfo info); @Override List<LegendItem> getLegendItems(); @Override String getPlotType(); @Override boolean equals(Object obj); @Override Object clone(); }
PiePlot extends Plot implements Cloneable, Serializable { @Override public List<LegendItem> getLegendItems() { List<LegendItem> result = new ArrayList<LegendItem>(); if (this.dataset == null) { return result; } List<Comparable> keys = this.dataset.getKeys(); int section = 0; Shape shape = getLegendItemShape(); for (Comparable key : keys) { Number n = this.dataset.getValue(key); boolean include; if (n == null) { include = !this.ignoreNullValues; } else { double v = n.doubleValue(); if (v == 0.0) { include = !this.ignoreZeroValues; } else { include = v > 0.0; } } if (include) { String label = this.legendLabelGenerator.generateSectionLabel( this.dataset, key); if (label != null) { String description = label; String toolTipText = null; if (this.legendLabelToolTipGenerator != null) { toolTipText = this.legendLabelToolTipGenerator .generateSectionLabel(this.dataset, key); } String urlText = null; if (this.legendLabelURLGenerator != null) { urlText = this.legendLabelURLGenerator.generateURL( this.dataset, key, this.pieIndex); } Paint paint = lookupSectionPaint(key); Paint outlinePaint = lookupSectionOutlinePaint(key); Stroke outlineStroke = lookupSectionOutlineStroke(key); LegendItem item = new LegendItem(label, description, toolTipText, urlText, true, shape, true, paint, true, outlinePaint, outlineStroke, false, new Line2D.Float(), new BasicStroke(), Color.BLACK); item.setDataset(getDataset()); item.setSeriesIndex(this.dataset.getIndex(key)); item.setSeriesKey(key); result.add(item); } section++; } else { section++; } } return result; } PiePlot();  PiePlot(PieDataset dataset); PieDataset getDataset(); void setDataset(PieDataset dataset); int getPieIndex(); void setPieIndex(int index); double getStartAngle(); void setStartAngle(double angle); Rotation getDirection(); void setDirection(Rotation direction); double getInteriorGap(); void setInteriorGap(double percent); boolean isCircular(); void setCircular(boolean flag); void setCircular(boolean circular, boolean notify); boolean getIgnoreNullValues(); void setIgnoreNullValues(boolean flag); boolean getIgnoreZeroValues(); void setIgnoreZeroValues(boolean flag); Paint getSectionPaint(Comparable key); void setSectionPaint(Comparable key, Paint paint); void clearSectionPaints(boolean notify); Paint getBaseSectionPaint(); void setBaseSectionPaint(Paint paint); boolean getAutoPopulateSectionPaint(); void setAutoPopulateSectionPaint(boolean auto); boolean getSectionOutlinesVisible(); void setSectionOutlinesVisible(boolean visible); Paint getSectionOutlinePaint(Comparable key); void setSectionOutlinePaint(Comparable key, Paint paint); void clearSectionOutlinePaints(boolean notify); Paint getBaseSectionOutlinePaint(); void setBaseSectionOutlinePaint(Paint paint); boolean getAutoPopulateSectionOutlinePaint(); void setAutoPopulateSectionOutlinePaint(boolean auto); Stroke getSectionOutlineStroke(Comparable key); void setSectionOutlineStroke(Comparable key, Stroke stroke); void clearSectionOutlineStrokes(boolean notify); Stroke getBaseSectionOutlineStroke(); void setBaseSectionOutlineStroke(Stroke stroke); boolean getAutoPopulateSectionOutlineStroke(); void setAutoPopulateSectionOutlineStroke(boolean auto); Paint getShadowPaint(); void setShadowPaint(Paint paint); double getShadowXOffset(); void setShadowXOffset(double offset); double getShadowYOffset(); void setShadowYOffset(double offset); double getExplodePercent(Comparable key); void setExplodePercent(Comparable key, double percent); double getMaximumExplodePercent(); PieSectionLabelGenerator getLabelGenerator(); void setLabelGenerator(PieSectionLabelGenerator generator); double getLabelGap(); void setLabelGap(double gap); double getMaximumLabelWidth(); void setMaximumLabelWidth(double width); boolean getLabelLinksVisible(); void setLabelLinksVisible(boolean visible); PieLabelLinkStyle getLabelLinkStyle(); void setLabelLinkStyle(PieLabelLinkStyle style); double getLabelLinkMargin(); void setLabelLinkMargin(double margin); Paint getLabelLinkPaint(); void setLabelLinkPaint(Paint paint); Stroke getLabelLinkStroke(); void setLabelLinkStroke(Stroke stroke); Font getLabelFont(); void setLabelFont(Font font); Paint getLabelPaint(); void setLabelPaint(Paint paint); Paint getLabelBackgroundPaint(); void setLabelBackgroundPaint(Paint paint); Paint getLabelOutlinePaint(); void setLabelOutlinePaint(Paint paint); Stroke getLabelOutlineStroke(); void setLabelOutlineStroke(Stroke stroke); Paint getLabelShadowPaint(); void setLabelShadowPaint(Paint paint); RectangleInsets getLabelPadding(); void setLabelPadding(RectangleInsets padding); boolean getSimpleLabels(); void setSimpleLabels(boolean simple); RectangleInsets getSimpleLabelOffset(); void setSimpleLabelOffset(RectangleInsets offset); AbstractPieLabelDistributor getLabelDistributor(); void setLabelDistributor(AbstractPieLabelDistributor distributor); PieToolTipGenerator getToolTipGenerator(); void setToolTipGenerator(PieToolTipGenerator generator); PieURLGenerator getURLGenerator(); void setURLGenerator(PieURLGenerator generator); double getMinimumArcAngleToDraw(); void setMinimumArcAngleToDraw(double angle); Shape getLegendItemShape(); void setLegendItemShape(Shape shape); PieSectionLabelGenerator getLegendLabelGenerator(); void setLegendLabelGenerator(PieSectionLabelGenerator generator); PieSectionLabelGenerator getLegendLabelToolTipGenerator(); void setLegendLabelToolTipGenerator(
            PieSectionLabelGenerator generator); PieURLGenerator getLegendLabelURLGenerator(); void setLegendLabelURLGenerator(PieURLGenerator generator); ShadowGenerator getShadowGenerator(); void setShadowGenerator(ShadowGenerator generator); void handleMouseWheelRotation(int rotateClicks); PiePlotState initialise(Graphics2D g2, Rectangle2D plotArea,
            PiePlot plot, Integer index, PlotRenderingInfo info); @Override void draw(Graphics2D g2, Rectangle2D area, Point2D anchor,
            PlotState parentState, PlotRenderingInfo info); @Override List<LegendItem> getLegendItems(); @Override String getPlotType(); @Override boolean equals(Object obj); @Override Object clone(); static final double DEFAULT_INTERIOR_GAP; static final double MAX_INTERIOR_GAP; static final double DEFAULT_START_ANGLE; static final Font DEFAULT_LABEL_FONT; static final Paint DEFAULT_LABEL_PAINT; static final Paint DEFAULT_LABEL_BACKGROUND_PAINT; static final Paint DEFAULT_LABEL_OUTLINE_PAINT; static final Stroke DEFAULT_LABEL_OUTLINE_STROKE; static final Paint DEFAULT_LABEL_SHADOW_PAINT; static final double DEFAULT_MINIMUM_ARC_ANGLE_TO_DRAW; }