/**
  * Draws the block within the specified area.
  *
  * @param g2 the graphics device.
  * @param area the area.
  * @param params ignored (<code>null</code> permitted).
  * @return An {@link org.jfree.chart.block.EntityBlockResult} or <code>null</code>.
  */
 public Object draw(Graphics2D g2, Rectangle2D area, Object params) {
   Rectangle2D target = (Rectangle2D) area.clone();
   Rectangle2D hotspot = (Rectangle2D) area.clone();
   StandardEntityCollection sec = null;
   if (params instanceof EntityBlockParams && ((EntityBlockParams) params).getGenerateEntities()) {
     sec = new StandardEntityCollection();
     sec.add(new TitleEntity(hotspot, this));
   }
   target = trimMargin(target);
   if (this.backgroundPaint != null) {
     g2.setPaint(this.backgroundPaint);
     g2.fill(target);
   }
   BlockFrame border = getFrame();
   border.draw(g2, target);
   border.getInsets().trim(target);
   BlockContainer container = this.wrapper;
   if (container == null) {
     container = this.items;
   }
   target = trimPadding(target);
   Object val = container.draw(g2, target, params);
   if (val instanceof BlockResult) {
     EntityCollection ec = ((BlockResult) val).getEntityCollection();
     if (ec != null && sec != null) {
       sec.addAll(ec);
       ((BlockResult) val).setEntityCollection(sec);
     }
   }
   return val;
 }
 /**
  * Draws the block within the specified area.
  *
  * @param g2  the graphics device.
  * @param area  the area.
  * @param params  passed on to blocks within the container
  *                (<code>null</code> permitted).
  *
  * @return An instance of {@link EntityBlockResult}, or <code>null</code>.
  */
 public Object draw(Graphics2D g2, Rectangle2D area, Object params) {
     // draw the block without collecting entities
     super.draw(g2, area, null);
     EntityBlockParams ebp = null;
     BlockResult r = new BlockResult();
     if (params instanceof EntityBlockParams) {
         ebp = (EntityBlockParams) params;
         if (ebp.getGenerateEntities()) {
             EntityCollection ec = new StandardEntityCollection();
             LegendItemEntity entity = new LegendItemEntity(
                     (Shape) area.clone());
             entity.setSeriesIndex(this.series);
             entity.setSeriesKey(this.seriesKey);
             entity.setDataset(this.dataset);
             entity.setToolTipText(getToolTipText());
             entity.setURLText(getURLText());
             ec.add(entity);
             r.setEntityCollection(ec);
         }
     }
     return r;
 }
 /**
  * Draws the block within the specified area.
  *
  * @param g2 the graphics device.
  * @param area the area.
  * @param params if this is an instance of {@link EntityBlockParams} it is used to determine
  *     whether or not an {@link EntityCollection} is returned by this method.
  * @return An {@link EntityCollection} containing a chart entity for the title, or <code>null
  *     </code>.
  */
 @Override
 public Object draw(Graphics2D g2, Rectangle2D area, Object params) {
   if (this.content == null) {
     return null;
   }
   area = trimMargin(area);
   drawBorder(g2, area);
   if (this.text.equals("")) {
     return null;
   }
   ChartEntity entity = null;
   if (params instanceof EntityBlockParams) {
     EntityBlockParams p = (EntityBlockParams) params;
     if (p.getGenerateEntities()) {
       entity = new TitleEntity(area, this, this.toolTipText, this.urlText);
     }
   }
   area = trimBorder(area);
   if (this.backgroundPaint != null) {
     g2.setPaint(this.backgroundPaint);
     g2.fill(area);
   }
   area = trimPadding(area);
   RectangleEdge position = getPosition();
   if (position == RectangleEdge.TOP || position == RectangleEdge.BOTTOM) {
     drawHorizontal(g2, area);
   } else if (position == RectangleEdge.LEFT || position == RectangleEdge.RIGHT) {
     drawVertical(g2, area);
   }
   BlockResult result = new BlockResult();
   if (entity != null) {
     StandardEntityCollection sec = new StandardEntityCollection();
     sec.add(entity);
     result.setEntityCollection(sec);
   }
   return result;
 }