List of usage examples for org.jfree.chart.block ColumnArrangement ColumnArrangement
public ColumnArrangement(HorizontalAlignment hAlign, VerticalAlignment vAlign, double hGap, double vGap)
From source file:com.hmsinc.epicenter.webapp.chart.ChartService.java
/** * @param chart/*from www .ja v a2s. com*/ * @return */ private static void configureTitleAndLegend(final JFreeChart chart, final AbstractChart adapter) { final TextTitle title = chart.getTitle(); if (title != null) { title.setFont(new Font("Arial", Font.BOLD, 12)); // title.setBackgroundPaint(Color.CYAN); title.setTextAlignment(HorizontalAlignment.LEFT); title.setHorizontalAlignment(HorizontalAlignment.CENTER); title.setMargin(0, 4, 5, 6); } if (chart.getLegend() != null) { chart.removeLegend(); final LegendTitle legend = new LegendTitle(chart.getPlot(), new SNColumnArrangement(0, 0), new ColumnArrangement(HorizontalAlignment.CENTER, VerticalAlignment.CENTER, 0, 0)); legend.setItemFont(LEGEND_FONT); legend.setPosition(RectangleEdge.BOTTOM); legend.setHorizontalAlignment(HorizontalAlignment.CENTER); legend.setBackgroundPaint(Color.WHITE); legend.setFrame(new LineBorder()); legend.setMargin(0, 4, 5, 6); chart.addLegend(legend); // Now we'll try to remove any duplicate items from the legend.. final Map<String, Integer> keys = new HashMap<String, Integer>(); final LegendItemCollection items = new LegendItemCollection(); for (LegendItemSource source : legend.getSources()) { for (int i = 0; i < source.getLegendItems().getItemCount(); i++) { final LegendItem item = source.getLegendItems().get(i); if (!keys.containsKey(item.getLabel())) { keys.put(item.getLabel(), i); items.add(item); } } } legend.setSources(new LegendItemSource[] { new LegendItemSource() { /* * (non-Javadoc) * * @see org.jfree.chart.LegendItemSource#getLegendItems() */ public LegendItemCollection getLegendItems() { return items; } } }); } }
From source file:edu.ucla.stat.SOCR.chart.demo.XYBarChartDemo2.java
protected JFreeChart createLegendChart(JFreeChart origchart) { JFreeChart legendChart = new JFreeChart("", null, new HiddenPlot(), false); legendChart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) origchart.getPlot(); LegendTitle legendTitle = new LegendTitle(plot, new ColumnArrangement(HorizontalAlignment.LEFT, VerticalAlignment.CENTER, 0, 0), new ColumnArrangement(HorizontalAlignment.LEFT, VerticalAlignment.CENTER, 0, 0)); legendChart.addLegend(legendTitle);/* ww w .jav a 2s . c o m*/ return legendChart; }
From source file:edu.ucla.stat.SOCR.chart.SuperBoxAndWhiskerChart.java
protected JFreeChart createLegendChart(JFreeChart origchart) { JFreeChart legendChart = new JFreeChart("", null, new HiddenPlot(), false); legendChart.setBackgroundPaint(Color.white); CategoryPlot plot = origchart.getCategoryPlot(); LegendTitle legendTitle = new LegendTitle(plot, new ColumnArrangement(HorizontalAlignment.LEFT, VerticalAlignment.CENTER, 0, 0), new ColumnArrangement(HorizontalAlignment.LEFT, VerticalAlignment.CENTER, 0, 0)); legendChart.addLegend(legendTitle);/* w w w . j av a 2 s . c o m*/ return legendChart; }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.JFreeChartPlotEngine.java
/** * Creates {@link LegendTitle}s for all dimensions from the PlotConfiguration of this Plotter2D. * Expects that all {@link ValueSource} s in the provided PlotConfiguration use the same * {@link DimensionConfig} s./* ww w . j a va2s . c om*/ */ private List<LegendTitle> createLegendTitles() { List<LegendTitle> legendTitles = new LinkedList<LegendTitle>(); LegendConfiguration legendConfiguration = plotInstance.getCurrentPlotConfigurationClone() .getLegendConfiguration(); LegendTitle legendTitle = new SmartLegendTitle(this, new FlowArrangement(HorizontalAlignment.CENTER, VerticalAlignment.CENTER, 30, 2), new ColumnArrangement(HorizontalAlignment.LEFT, VerticalAlignment.CENTER, 0, 2)); legendTitle.setItemPaint(legendConfiguration.getLegendFontColor()); RectangleEdge position = legendConfiguration.getLegendPosition().getPosition(); if (position == null) { return legendTitles; } legendTitle.setPosition(position); if (legendConfiguration.isShowLegendFrame()) { legendTitle.setFrame(new BlockBorder(legendConfiguration.getLegendFrameColor())); } ColoredBlockContainer wrapper = new ColoredBlockContainer(legendConfiguration.getLegendBackgroundColor()); wrapper.add(legendTitle.getItemContainer()); wrapper.setPadding(3, 3, 3, 3); legendTitle.setWrapper(wrapper); legendTitles.add(legendTitle); return legendTitles; }