List of usage examples for org.jfree.chart.block BlockResult setEntityCollection
public void setEntityCollection(EntityCollection entities)
From source file:gda.plots.SimpleLegendGraphic.java
/** * Overrides the super class method but is the same except that it creates a SimpleLegendEntity for itself and then * returns a non-null BlockResult containing the entity. * /*from www.ja v a2 s . co m*/ * @param g2 * the Graphics2D to use * @param area * the area to draw in * @param params * ignored * @return a BlockResult containing a StandardEntityCollection containing the SimpleLegendEntity */ @Override public Object draw(Graphics2D g2, Rectangle2D area, Object params) { draw(g2, area); ChartEntity entity = null; // This was written by looking at what happens in LabelBlock's draw // method. The area has to be transformed into the actual coordinates // of the overall ChartPanel for the MouseEvents to work properly. entity = new SimpleLegendEntity(g2.getTransform().createTransformedShape(area), sxys.getName(), null, sxys); BlockResult result = new BlockResult(); StandardEntityCollection sec = new StandardEntityCollection(); sec.add(entity); result.setEntityCollection(sec); return result; }
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 . j a v a2 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; }
From source file:gda.plots.SimpleLegendLabelBlock.java
/** * Overrides super class method to provide a BlockResult which contains a SimpleLegendEntity instead of an ordinary * ChartEntity.//w ww . jav a 2 s . c o m * * @param g2 * the Graphics to use * @param area * the area to draw in * @param params * ignored * @return a BlockResult containing the SimpleLegendEntity */ @Override public Object draw(Graphics2D g2, Rectangle2D area, Object params) { // It was impossible to reuse the super class code because of // private fields with no accessor methods. So run the method // then replace the EntityCollection with one containing a // SimpleLegendEntity. The super class method may return null // (e.g. when being drawn for printing). If it does then we // should too. BlockResult result = (BlockResult) super.draw(g2, area, params); if (result != null) { StandardEntityCollection sec = new StandardEntityCollection(); ChartEntity ce = result.getEntityCollection().getEntity(0); sec.add(new SimpleLegendEntity(ce, sxys)); result.setEntityCollection(sec); } return result; }