本文整理汇总了Java中org.jfree.chart.LegendItemCollection类的典型用法代码示例。如果您正苦于以下问题:Java LegendItemCollection类的具体用法?Java LegendItemCollection怎么用?Java LegendItemCollection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LegendItemCollection类属于org.jfree.chart包,在下文中一共展示了LegendItemCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLegendItems
import org.jfree.chart.LegendItemCollection; //导入依赖的package包/类
/**
* 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}).
*/
@Override
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;
}
示例2: getLegendItems
import org.jfree.chart.LegendItemCollection; //导入依赖的package包/类
/**
* Returns the legend items for the plot. Each legend item is generated by the plot's
* m_Renderer, since the m_Renderer is responsible for the visual representation of the
* data.
*
* @return the legend items.
*/
public LegendItemCollection getLegendItems() {
LegendItemCollection result = new LegendItemCollection();
// get the legend items for the main m_Dataset...
if (this.dataset != null) {
if (this.renderer != null) {
int seriesCount = this.dataset.getSeriesCount();
for (int i = 0; i < seriesCount; i++) {
LegendItem item = this.renderer.getLegendItem(i);
result.add(item);
}
}
}
return result;
}
示例3: getLegendItems
import org.jfree.chart.LegendItemCollection; //导入依赖的package包/类
/**
* Returns a collection of legend items for the plot.
*
* @return the legend items.
*/
public LegendItemCollection getLegendItems() {
LegendItemCollection result = new LegendItemCollection();
if (this.subplots != null) {
Iterator iterator = this.subplots.iterator();
while (iterator.hasNext()) {
CategoryPlot plot = (CategoryPlot) iterator.next();
LegendItemCollection more = plot.getLegendItems();
result.addAll(more);
}
}
return result;
}
示例4: getLegendItems
import org.jfree.chart.LegendItemCollection; //导入依赖的package包/类
/**
* Returns a collection of legend items for the plot.
*
* @return the legend items.
*/
public LegendItemCollection getLegendItems() {
LegendItemCollection result = new LegendItemCollection();
if (this.subplots != null) {
Iterator iterator = this.subplots.iterator();
while (iterator.hasNext()) {
XYPlot plot = (XYPlot) iterator.next();
LegendItemCollection more = plot.getLegendItems();
result.addAll(more);
}
}
return result;
}
示例5: getLegendItems
import org.jfree.chart.LegendItemCollection; //导入依赖的package包/类
/**
* Returns a collection of legend items for the plot.
*
* @return The legend items.
*/
public LegendItemCollection getLegendItems() {
LegendItemCollection result = new LegendItemCollection();
if (this.subplots != null) {
Iterator iterator = this.subplots.iterator();
while (iterator.hasNext()) {
CategoryPlot plot = (CategoryPlot) iterator.next();
LegendItemCollection more = plot.getLegendItems();
result.addAll(more);
}
}
return result;
}
示例6: testEquals
import org.jfree.chart.LegendItemCollection; //导入依赖的package包/类
/**
* Confirm that the equals method can distinguish all the required fields.
*/
public void testEquals() {
LegendItemCollection c1 = new LegendItemCollection();
LegendItemCollection c2 = new LegendItemCollection();
assertTrue(c1.equals(c2));
assertTrue(c2.equals(c1));
LegendItem item1 = new LegendItem("Label", "Description",
"ToolTip", "URL", true,
new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red,
true, Color.blue, new BasicStroke(1.2f), true,
new Line2D.Double(1.0, 2.0, 3.0, 4.0),
new BasicStroke(2.1f), Color.green);
LegendItem item2 = new LegendItem("Label", "Description",
"ToolTip", "URL", true,
new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0),
true, Color.red, true, Color.blue, new BasicStroke(1.2f), true,
new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f),
Color.green);
c1.add(item1);
c2.add(item2);
assertTrue(c1.equals(c2));
}
示例7: fetchLegendItems
import org.jfree.chart.LegendItemCollection; //导入依赖的package包/类
/**
* Fetches the latest legend items.
*/
protected void fetchLegendItems() {
this.items.clear();
RectangleEdge p = getPosition();
if (RectangleEdge.isTopOrBottom(p)) {
this.items.setArrangement(this.hLayout);
}
else {
this.items.setArrangement(this.vLayout);
}
for (int s = 0; s < this.sources.length; s++) {
LegendItemCollection legendItems = this.sources[s].getLegendItems();
if (legendItems != null) {
for (int i = 0; i < legendItems.getItemCount(); i++) {
LegendItem item = legendItems.get(i);
Block block = createLegendItemBlock(item);
this.items.add(block);
}
}
}
}
示例8: getLegendItems
import org.jfree.chart.LegendItemCollection; //导入依赖的package包/类
/**
* 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;
}
示例9: getLegendItems
import org.jfree.chart.LegendItemCollection; //导入依赖的package包/类
/**
* 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>).
*
* @see #getLegendItem(int, int)
*/
public LegendItemCollection getLegendItems() {
if (this.plot == null) {
return new LegendItemCollection();
}
LegendItemCollection result = new LegendItemCollection();
int index = this.plot.getIndexOf(this);
CategoryDataset dataset = this.plot.getDataset(index);
if (dataset != null) {
int seriesCount = dataset.getRowCount();
for (int i = 0; i < seriesCount; i++) {
if (isSeriesVisibleInLegend(i)) {
LegendItem item = getLegendItem(index, i);
if (item != null) {
result.add(item);
}
}
}
}
return result;
}
示例10: getLegendItems
import org.jfree.chart.LegendItemCollection; //导入依赖的package包/类
/**
* Returns an item for each interval.
*
* @return A collection of legend items.
*/
public LegendItemCollection getLegendItems() {
LegendItemCollection result = new LegendItemCollection();
Iterator iterator = this.intervals.iterator();
while (iterator.hasNext()) {
MeterInterval mi = (MeterInterval) iterator.next();
Paint color = mi.getBackgroundPaint();
if (color == null) {
color = mi.getOutlinePaint();
}
LegendItem item = new LegendItem(mi.getLabel(), mi.getLabel(),
null, null, new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0),
color);
result.add(item);
}
return result;
}
示例11: getLegendItems
import org.jfree.chart.LegendItemCollection; //导入依赖的package包/类
/**
* Returns the legend items for the plot. Each legend item is generated by
* the plot's m_Renderer, since the m_Renderer is responsible for the visual
* representation of the data.
*
* @return The legend items.
*/
public LegendItemCollection getLegendItems() {
LegendItemCollection result = new LegendItemCollection();
// get the legend items for the main m_Dataset...
if (this.dataset != null) {
if (this.renderer != null) {
int seriesCount = this.dataset.getSeriesCount();
for (int i = 0; i < seriesCount; i++) {
LegendItem item = this.renderer.getLegendItem(i);
result.add(item);
}
}
}
return result;
}
示例12: updateLegend
import org.jfree.chart.LegendItemCollection; //导入依赖的package包/类
/**
* Update legend
*/
private void updateLegend() {
_chart.removeLegend();
final LegendTitle legend = new LegendTitle(() -> {
final LegendItemCollection collection = new LegendItemCollection();
if (_currentMode == DisplayMode.TIME) {
collection.add(new LegendItem(Legend.LATENCY.label, null, null, null, new Rectangle(30, 20), Legend.LATENCY.color));
if (_dnsLookup && _services.isEmbeddedTRAvailable() && !Env.INSTANCE.isUseOSTraceroute()) {
collection.add(new LegendItem(Legend.DNS.label, null, null, null, new Rectangle(30, 20), Legend.DNS.color));
}
} else {
collection.add(new LegendItem(Legend.DISTANCE.label, Legend.DISTANCE.color));
}
return collection;
});
legend.setPosition(RectangleEdge.BOTTOM);
_chart.addLegend(legend);
}
示例13: test2947660
import org.jfree.chart.LegendItemCollection; //导入依赖的package包/类
/**
* A test that reproduces the problem reported in bug 2947660.
*/
@Test
public void test2947660() {
AbstractCategoryItemRenderer r = new LineAndShapeRenderer();
assertNotNull(r.getLegendItems());
assertEquals(0, r.getLegendItems().getItemCount());
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
CategoryPlot plot = new CategoryPlot();
plot.setDataset(dataset);
plot.setRenderer(r);
assertEquals(0, r.getLegendItems().getItemCount());
dataset.addValue(1.0, "S1", "C1");
LegendItemCollection lic = r.getLegendItems();
assertEquals(1, lic.getItemCount());
assertEquals("S1", lic.get(0).getLabel());
}
示例14: testGetLegendItems
import org.jfree.chart.LegendItemCollection; //导入依赖的package包/类
/**
* Fetches the legend items and checks the values.
*/
@Test
public void testGetLegendItems() {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(35.0, "S1", "C1");
dataset.addValue(45.0, "S1", "C2");
dataset.addValue(55.0, "S2", "C1");
dataset.addValue(15.0, "S2", "C2");
MultiplePiePlot plot = new MultiplePiePlot(dataset);
JFreeChart chart = new JFreeChart(plot);
LegendItemCollection legendItems = plot.getLegendItems();
assertEquals(2, legendItems.getItemCount());
LegendItem item1 = legendItems.get(0);
assertEquals("S1", item1.getLabel());
assertEquals("S1", item1.getSeriesKey());
assertEquals(0, item1.getSeriesIndex());
assertEquals(dataset, item1.getDataset());
assertEquals(0, item1.getDatasetIndex());
LegendItem item2 = legendItems.get(1);
assertEquals("S2", item2.getLabel());
assertEquals("S2", item2.getSeriesKey());
assertEquals(1, item2.getSeriesIndex());
assertEquals(dataset, item2.getDataset());
assertEquals(0, item2.getDatasetIndex());
}
示例15: testGetLegendItems
import org.jfree.chart.LegendItemCollection; //导入依赖的package包/类
/**
* Some checks for the getLegendItems() method.
*/
@Test
public void testGetLegendItems() {
XYSeriesCollection d = new XYSeriesCollection();
d.addSeries(new XYSeries("A"));
d.addSeries(new XYSeries("B"));
DefaultPolarItemRenderer r = new DefaultPolarItemRenderer();
PolarPlot plot = new PolarPlot();
plot.setDataset(d);
plot.setRenderer(r);
LegendItemCollection items = plot.getLegendItems();
assertEquals(2, items.getItemCount());
LegendItem item1 = items.get(0);
assertEquals("A", item1.getLabel());
LegendItem item2 = items.get(1);
assertEquals("B", item2.getLabel());
}