本文整理了Java中org.jfree.chart.JFreeChart.addLegend()
方法的一些代码示例,展示了JFreeChart.addLegend()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JFreeChart.addLegend()
方法的具体详情如下:
包路径:org.jfree.chart.JFreeChart
类名称:JFreeChart
方法名:addLegend
[英]Adds a legend to the plot and sends a ChartChangeEvent to all registered listeners.
[中]向绘图添加图例,并向所有注册的侦听器发送ChartChangeEvent。
代码示例来源:origin: graphhopper/jsprit
private BufferedImage plot(VehicleRoutingProblem vrp, final Collection<VehicleRoute> routes, String pngFile, String title) {
log.info("plot to {}", pngFile);
XYSeriesCollection problem;
XYSeriesCollection solution = null;
final XYSeriesCollection shipments;
try {
retrieveActivities(vrp);
problem = new XYSeriesCollection(activities);
shipments = makeShipmentSeries(vrp.getJobs().values());
if (routes != null) solution = makeSolutionSeries(vrp, routes);
} catch (NoLocationFoundException e) {
log.warn("cannot plot vrp, since coord is missing");
return null;
}
final XYPlot plot = createPlot(problem, shipments, solution);
JFreeChart chart = new JFreeChart(title, plot);
LegendTitle legend = createLegend(routes, shipments, plot);
chart.removeLegend();
chart.addLegend(legend);
save(chart, pngFile);
return chart.createBufferedImage(1024, 1024);
}
代码示例来源:origin: us.ihmc/simulation-construction-set-tools
public void addLegend(LegendTitle legend)
{
legend.setItemFont(new Font("SansSerif", Font.PLAIN, 22));
graph.addLegend(legend);
}
代码示例来源:origin: stackoverflow.com
JFreeChart chart = // your chart
chart.removeLegend();
LegendTitle legend = new LegendTitle(new LineLegendItemSource());
chart.addLegend(legend);
代码示例来源:origin: net.sourceforge.jadex/jadex-tools-comanalyzer
/**
* @param showLegend <code>true</code> if the legend is to be shown.
*/
public void setShowLegend(boolean showLegend)
{
this.showLegend = showLegend;
if(showLegend)
{
chart.addLegend(createLegend(chart.getPlot()));
}
else
{
chart.removeLegend();
}
}
代码示例来源:origin: senbox-org/snap-desktop
private void setLegend(JFreeChart chart) {
chart.removeLegend();
final LegendTitle legend = new LegendTitle(new SpectrumLegendItemSource());
legend.setPosition(RectangleEdge.BOTTOM);
LineBorder border = new LineBorder(Color.BLACK, new BasicStroke(), new RectangleInsets(2, 2, 2, 2));
legend.setFrame(border);
chart.addLegend(legend);
}
代码示例来源:origin: bcdev/beam
private void setLegend(JFreeChart chart) {
chart.removeLegend();
final LegendTitle legend = new LegendTitle(new SpectrumLegendItemSource());
legend.setPosition(RectangleEdge.BOTTOM);
LineBorder border = new LineBorder(Color.BLACK, new BasicStroke(), new RectangleInsets(2, 2, 2, 2));
legend.setFrame(border);
chart.addLegend(legend);
}
代码示例来源:origin: com.graphhopper/jsprit-analysis
private void plot(VehicleRoutingProblem vrp, final Collection<VehicleRoute> routes, String pngFile, String title) {
log.info("plot to {}", pngFile);
XYSeriesCollection problem;
XYSeriesCollection solution = null;
final XYSeriesCollection shipments;
try {
retrieveActivities(vrp);
problem = new XYSeriesCollection(activities);
shipments = makeShipmentSeries(vrp.getJobs().values());
if (routes != null) solution = makeSolutionSeries(vrp, routes);
} catch (NoLocationFoundException e) {
log.warn("cannot plot vrp, since coord is missing");
return;
}
final XYPlot plot = createPlot(problem, shipments, solution);
JFreeChart chart = new JFreeChart(title, plot);
LegendTitle legend = createLegend(routes, shipments, plot);
chart.removeLegend();
chart.addLegend(legend);
save(chart, pngFile);
}
代码示例来源:origin: stackoverflow.com
private static JFreeChart createChart() {
CombinedDomainXYPlot localCombinedDomainXYPlot = new CombinedDomainXYPlot(new DateAxis("Time"));
JFreeChart localJFreeChart = new JFreeChart("Sample", localCombinedDomainXYPlot);
localCombinedDomainXYPlot.add(createSubplot1(createDataset1()), 1);
ChartUtilities.applyCurrentTheme(localJFreeChart);
localJFreeChart.setBackgroundPaint(Color.white);
final LegendItemCollection legendItemsOld = localCombinedDomainXYPlot.getLegendItems();
LegendItemSource source = new LegendItemSource() {
public LegendItemCollection getLegendItems() {
LegendItemCollection lic = new LegendItemCollection();
int itemCount = legendItemsOld.getItemCount();
for (int i = 0; i < itemCount; i++) {
lic.add(legendItemsOld.get(i));
}
return lic;
}
};
localJFreeChart.removeLegend();
localJFreeChart.addLegend(new LegendTitle(source));
localJFreeChart.getLegend().setPosition(RectangleEdge.TOP);
localJFreeChart.getLegend().getItemContainer().getBlocks();
return localJFreeChart;
}
代码示例来源:origin: net.sourceforge.jadex/jadex-tools-comanalyzer
chart.addLegend(createLegend(plot));
代码示例来源:origin: net.sourceforge.jadex/jadex-tools-comanalyzer
chart.addLegend(createLegend(plot));
内容来源于网络,如有侵权,请联系作者删除!