List of usage examples for org.jfree.chart.block BlockContainer add
public void add(Block block)
From source file:org.codehaus.mojo.dashboard.report.plugin.chart.time.MarkerTimeChartDecorator.java
public void createChart() { XYPlot xyplot = (XYPlot) report.getPlot(); // if (this.decoratedChart instanceof TimeChartRenderer ) { if (this.results != null && !this.results.isEmpty()) { Iterator iter1 = this.results.iterator(); ValueMarker valuemarker = null;/*from w ww .j av a 2 s.c om*/ BlockContainer blockcontainerLabel = new BlockContainer(new ColumnArrangement()); // blockcontainerLabel.setFrame( new LineBorder() ); int i = 0; while (iter1.hasNext()) { Object[] item = (Object[]) iter1.next(); Date date = (Date) item[1]; Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); valuemarker = new ValueMarker(cal.getTimeInMillis(), ChartColor.createDefaultPaintArray()[i], new BasicStroke(2.0F)); xyplot.addDomainMarker(valuemarker); LegendItem legendLabel = new LegendItem((String) item[0], null, null, null, new Line2D.Double(-7.0, 0.0, 7.0, 0.0), valuemarker.getPaint(), valuemarker.getStroke(), valuemarker.getPaint()); blockcontainerLabel.add(createLegendItemBlock(legendLabel, i)); i++; } createLegendBlock(blockcontainerLabel); } // } }
From source file:org.codehaus.mojo.dashboard.report.plugin.chart.time.MarkerTimeChartDecorator.java
/** * Creates a legend item block./* w w w. java 2 s . c om*/ * * @param item * the legend item. * * @return The block. */ protected Block createLegendItemBlock(LegendItem item, int i) { BlockContainer result = null; LegendGraphic lg = new LegendGraphic(item.getShape(), item.getFillPaint()); lg.setFillPaintTransformer(item.getFillPaintTransformer()); lg.setShapeFilled(true); lg.setLine(item.getLine()); lg.setLineStroke(item.getLineStroke()); lg.setLinePaint(item.getFillPaint()); lg.setLineVisible(true); lg.setShapeVisible(true); lg.setShapeOutlineVisible(true); lg.setOutlinePaint(item.getFillPaint()); lg.setOutlineStroke(item.getOutlineStroke()); lg.setPadding(new RectangleInsets(2.0, 2.0, 2.0, 2.0)); LegendItemBlockContainer legendItem = new LegendItemBlockContainer(new BorderArrangement(), 0, i); lg.setShapeAnchor(RectangleAnchor.CENTER); lg.setShapeLocation(RectangleAnchor.CENTER); legendItem.add(lg, RectangleEdge.LEFT); LabelBlock labelBlock = new LabelBlock(item.getLabel(), new Font("SansSerif", Font.BOLD, 10), Color.black); labelBlock.setPadding(new RectangleInsets(2.0, 2.0, 2.0, 2.0)); legendItem.add(labelBlock); legendItem.setToolTipText(item.getToolTipText()); legendItem.setURLText(item.getURLText()); result = new BlockContainer(new CenterArrangement()); result.add(legendItem); return result; }
From source file:it.eng.spagobi.engines.chart.bo.ChartImpl.java
public void drawLegend(JFreeChart chart) { //remove ipotetical other legend chart.removeLegend();//from w w w. j ava2 s . com BlockContainer wrapper = new BlockContainer(new BorderArrangement()); wrapper.setFrame(new BlockBorder(1.0, 1.0, 1.0, 1.0)); /*LabelBlock titleBlock = new LabelBlock("Legend Items:", new Font("SansSerif", Font.BOLD, 12)); titleBlock.setPadding(5, 5, 5, 5); wrapper.add(titleBlock, RectangleEdge.TOP);*/ LegendTitle legend = new LegendTitle(chart.getPlot()); BlockContainer items = legend.getItemContainer(); if (styleLegend != null && styleLegend.getFont() != null) { legend.setItemFont(new Font(styleLegend.getFontName(), Font.BOLD, styleLegend.getSize())); } items.setPadding(2, 5, 5, 2); wrapper.add(items); legend.setWrapper(wrapper); if (legendPosition.equalsIgnoreCase("bottom")) legend.setPosition(RectangleEdge.BOTTOM); else if (legendPosition.equalsIgnoreCase("left")) legend.setPosition(RectangleEdge.LEFT); else if (legendPosition.equalsIgnoreCase("right")) legend.setPosition(RectangleEdge.RIGHT); else if (legendPosition.equalsIgnoreCase("top")) legend.setPosition(RectangleEdge.TOP); else legend.setPosition(RectangleEdge.BOTTOM); legend.setHorizontalAlignment(HorizontalAlignment.CENTER); chart.addSubtitle(legend); }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.legend.SmartLegendTitle.java
private Block createDefaultLegendItem(LegendItem item) { BlockContainer result = null; Shape shape = item.getShape(); if (shape == null) { shape = new Rectangle(); }/*from w w w.j a v a 2s . c om*/ LegendGraphic lg = new LegendGraphic(shape, item.getFillPaint()); lg.setFillPaintTransformer(item.getFillPaintTransformer()); lg.setShapeFilled(item.isShapeFilled()); lg.setLine(item.getLine()); lg.setLineStroke(item.getLineStroke()); lg.setLinePaint(item.getLinePaint()); lg.setLineVisible(item.isLineVisible()); lg.setShapeVisible(item.isShapeVisible()); lg.setShapeOutlineVisible(item.isShapeOutlineVisible()); lg.setOutlinePaint(item.getOutlinePaint()); lg.setOutlineStroke(item.getOutlineStroke()); lg.setPadding(getLegendItemGraphicPadding()); LegendItemBlockContainer legendItem = new LegendItemBlockContainer(new BorderArrangement(), item.getDataset(), item.getSeriesKey()); lg.setShapeAnchor(getLegendItemGraphicAnchor()); lg.setShapeLocation(getLegendItemGraphicLocation()); legendItem.add(lg, getLegendItemGraphicEdge()); Font textFont = item.getLabelFont(); if (textFont == null) { textFont = getItemFont(); } Paint textPaint = item.getLabelPaint(); if (textPaint == null) { textPaint = getItemPaint(); } LabelBlock labelBlock = new LabelBlock(item.getLabel(), textFont, textPaint); labelBlock.setPadding(getItemLabelPadding()); legendItem.add(labelBlock); legendItem.setToolTipText(item.getToolTipText()); legendItem.setURLText(item.getURLText()); result = new BlockContainer(new CenterArrangement()); result.add(legendItem); return result; }
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.legend.SmartLegendTitle.java
private Block createFlankedShapeLegendItem(FlankedShapeLegendItem item) { BlockContainer result = null; LegendGraphic lg = new CustomLegendGraphic(item.getShape(), item.getFillPaint()); lg.setFillPaintTransformer(item.getFillPaintTransformer()); lg.setShapeFilled(item.isShapeFilled()); lg.setLine(item.getLine());/* w ww . ja va 2s . c o m*/ lg.setLineStroke(item.getLineStroke()); lg.setLinePaint(item.getLinePaint()); lg.setLineVisible(item.isLineVisible()); lg.setShapeVisible(item.isShapeVisible()); lg.setShapeOutlineVisible(item.isShapeOutlineVisible()); lg.setOutlinePaint(item.getOutlinePaint()); lg.setOutlineStroke(item.getOutlineStroke()); lg.setPadding(this.getLegendItemGraphicPadding()); LegendItemBlockContainer legendItem = new LegendItemBlockContainer(new BorderArrangement(), item.getDataset(), item.getSeriesKey()); Font textFont = item.getLabelFont(); if (textFont == null) { textFont = getItemFont(); } Paint textPaint = item.getLabelPaint(); if (textPaint == null) { textPaint = getItemPaint(); } ColoredBlockContainer graphicsContainer = new ColoredBlockContainer(new Color(0, 0, 0, 0), new BorderArrangement()); LabelBlock labelBlock; Font smallerTextFont = textFont.deriveFont(textFont.getSize() * .8f); Font labelTextFont = textFont; labelBlock = new LabelBlock(item.getLeftShapeLabel(), smallerTextFont, textPaint); graphicsContainer.add(labelBlock, RectangleEdge.LEFT); graphicsContainer.add(lg, null); labelBlock = new LabelBlock(item.getRightShapeLabel(), smallerTextFont, textPaint); graphicsContainer.add(labelBlock, RectangleEdge.RIGHT); legendItem.add(graphicsContainer, getLegendItemGraphicEdge()); labelBlock = new LabelBlock(item.getLabel(), labelTextFont, textPaint); labelBlock.setPadding(getItemLabelPadding()); legendItem.add(labelBlock); legendItem.setToolTipText(item.getToolTipText()); legendItem.setURLText(item.getURLText()); result = new BlockContainer(new CenterArrangement()); result.add(legendItem); return result; }