Example usage for org.jfree.chart.entity StandardEntityCollection add

List of usage examples for org.jfree.chart.entity StandardEntityCollection add

Introduction

In this page you can find the example usage for org.jfree.chart.entity StandardEntityCollection add.

Prototype

@Override
public void add(ChartEntity entity) 

Source Link

Document

Adds an entity to the collection.

Usage

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   w ww .  ja  v  a2s.com
 * @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:gda.plots.SimpleLegendLabelBlock.java

/**
 * Overrides super class method to provide a BlockResult which contains a SimpleLegendEntity instead of an ordinary
 * ChartEntity.//from ww w  . j  av 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;
}