List of usage examples for org.jfree.chart.entity StandardEntityCollection addAll
@Override public void addAll(EntityCollection collection)
From source file:com.rapidminer.gui.new_plotter.engine.jfreechart.legend.ColoredBlockContainer.java
/** * Disclaimer: this is a "works for me" implementation, and probably only works as long as the * items are arranged horizontally in exactly one line, since it brutally enforces the items to * be aligned vertically centered./* w w w . jav a 2 s . c om*/ */ @Override public Object draw(Graphics2D g2, Rectangle2D area, Object params) { area = drawFill(g2, area); // check if we need to collect chart entities from the container EntityBlockParams ebp = null; StandardEntityCollection sec = null; if (params instanceof EntityBlockParams) { ebp = (EntityBlockParams) params; if (ebp.getGenerateEntities()) { sec = new StandardEntityCollection(); } } Rectangle2D contentArea = (Rectangle2D) area.clone(); contentArea = trimMargin(contentArea); drawBorder(g2, contentArea); contentArea = trimBorder(contentArea); contentArea = trimPadding(contentArea); Iterator iterator = getBlocks().iterator(); while (iterator.hasNext()) { Block block = (Block) iterator.next(); Rectangle2D bounds = block.getBounds(); // enforce vertically centered alignment double y = area.getY() + (area.getHeight() - bounds.getHeight()) / 2.0; Rectangle2D drawArea = new Rectangle2D.Double(bounds.getX() + area.getX(), y, bounds.getWidth(), bounds.getHeight()); Object r = block.draw(g2, drawArea, params); if (sec != null) { if (r instanceof EntityBlockResult) { EntityBlockResult ebr = (EntityBlockResult) r; EntityCollection ec = ebr.getEntityCollection(); sec.addAll(ec); } } } BlockResult result = null; if (sec != null) { result = new BlockResult(); result.setEntityCollection(sec); } return result; }