本文整理汇总了Java中org.jfree.chart.LegendItemCollection.add方法的典型用法代码示例。如果您正苦于以下问题:Java LegendItemCollection.add方法的具体用法?Java LegendItemCollection.add怎么用?Java LegendItemCollection.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.chart.LegendItemCollection
的用法示例。
在下文中一共展示了LegendItemCollection.add方法的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: 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));
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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);
}
示例9: testCloning3
import org.jfree.chart.LegendItemCollection; //导入方法依赖的package包/类
/**
* Tests cloning for a plot where the fixed legend items have been
* specified.
*/
@Test
public void testCloning3() throws CloneNotSupportedException {
XYPlot p1 = new XYPlot(null, new NumberAxis("Domain Axis"),
new NumberAxis("Range Axis"), new StandardXYItemRenderer());
LegendItemCollection c1 = new LegendItemCollection();
p1.setFixedLegendItems(c1);
XYPlot p2 = (XYPlot) p1.clone();
assertTrue(p1 != p2);
assertTrue(p1.getClass() == p2.getClass());
assertTrue(p1.equals(p2));
// verify independence of fixed legend item collection
c1.add(new LegendItem("X"));
assertFalse(p1.equals(p2));
}
示例10: getLegendItems
import org.jfree.chart.LegendItemCollection; //导入方法依赖的package包/类
/**
* Returns an item for each interval.
*
* @return A collection of legend items.
*/
@Override
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);
item.setDataset(getDataset());
result.add(item);
}
return result;
}
示例11: 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>).
*/
@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;
}
示例12: 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.
*/
@Override
public LegendItemCollection getLegendItems() {
if (this.fixedLegendItems != null) {
return this.fixedLegendItems;
}
LegendItemCollection result = new LegendItemCollection();
int count = this.datasets.size();
for (int datasetIndex = 0; datasetIndex < count; datasetIndex++) {
XYDataset dataset = getDataset(datasetIndex);
PolarItemRenderer renderer = getRenderer(datasetIndex);
if (dataset != null && renderer != null) {
int seriesCount = dataset.getSeriesCount();
for (int i = 0; i < seriesCount; i++) {
LegendItem item = renderer.getLegendItem(i);
result.add(item);
}
}
}
return result;
}
示例13: createLegendItems
import org.jfree.chart.LegendItemCollection; //导入方法依赖的package包/类
/**
* Creates the legend items for the chart. In this case, we set them
* manually because we only want legend items for a subset of the data
* series.
*
* @return The legend items.
*/
private static LegendItemCollection createLegendItems() {
LegendItemCollection result = new LegendItemCollection();
LegendItem item1 = new LegendItem("US", "-", null, null,
Plot.DEFAULT_LEGEND_ITEM_BOX, new Color(0x22, 0x22, 0xFF));
LegendItem item2 = new LegendItem("Europe", "-", null, null,
Plot.DEFAULT_LEGEND_ITEM_BOX, new Color(0x22, 0xFF, 0x22));
LegendItem item3 = new LegendItem("Asia", "-", null, null,
Plot.DEFAULT_LEGEND_ITEM_BOX, new Color(0xFF, 0x22, 0x22));
LegendItem item4 = new LegendItem("Middle East", "-", null, null,
Plot.DEFAULT_LEGEND_ITEM_BOX, new Color(0xFF, 0xFF, 0x22));
result.add(item1);
result.add(item2);
result.add(item3);
result.add(item4);
return result;
}
示例14: buildPortfolioBenchmarkChart
import org.jfree.chart.LegendItemCollection; //导入方法依赖的package包/类
private ChartPanel buildPortfolioBenchmarkChart(TimeSeriesModel timeSeriesModel) {
XYDataset xyDataset = buildXYDataset(timeSeriesModel, totalReturnTimeSeriesTypes);
LegendItemCollection legendItems = new LegendItemCollection();
if (xyDataset.getSeriesCount() == 0) {
xyDataset = buildXYDataset(timeSeriesModel, timeSeriesTypes);
legendItems.add(new LegendItem(resourceManager.getString("portfolio"), Color.blue));
legendItems.add(new LegendItem(resourceManager.getString("benchmark"), Colors.navy));
} else {
legendItems.add(new LegendItem(resourceManager.getString("portfolio.total.return"), Color.blue));
legendItems.add(new LegendItem(resourceManager.getString("benchmark.total.return"), Colors.navy));
}
XYItemRenderer xyItemRenderer = buildXYItemRenderer(Color.blue, Colors.navy);
XYPlot xyPlot = new XYPlot(xyDataset, buildDateAxis(), buildLogAxis(), xyItemRenderer);
xyPlot.setRangeAxis(1, buildLogAxis());
xyPlot.mapDatasetToRangeAxes(0, buildRangeAxes());
xyPlot.setFixedLegendItems(legendItems);
applyXYPlotLookAndFeel(xyPlot, true);
xyPlots.add(xyPlot);
return buildChartPanel(buildChart(benchmarkPortfolio, xyPlot));
}
示例15: 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;
}