Search in sources :

Example 1 with BlockResult

use of org.jfree.chart.block.BlockResult in project SIMVA-SoS by SESoS.

the class LegendItemBlockContainer method draw.

/**
 * 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>.
 */
@Override
public Object draw(Graphics2D g2, Rectangle2D area, Object params) {
    // draw the block without collecting entities
    super.draw(g2, area, null);
    EntityBlockParams ebp;
    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;
}
Also used : StandardEntityCollection(org.jfree.chart.entity.StandardEntityCollection) EntityBlockResult(org.jfree.chart.block.EntityBlockResult) BlockResult(org.jfree.chart.block.BlockResult) EntityCollection(org.jfree.chart.entity.EntityCollection) StandardEntityCollection(org.jfree.chart.entity.StandardEntityCollection) LegendItemEntity(org.jfree.chart.entity.LegendItemEntity) EntityBlockParams(org.jfree.chart.block.EntityBlockParams)

Example 2 with BlockResult

use of org.jfree.chart.block.BlockResult in project SIMVA-SoS by SESoS.

the class TextTitle method draw.

/**
 * 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;
}
Also used : StandardEntityCollection(org.jfree.chart.entity.StandardEntityCollection) BlockResult(org.jfree.chart.block.BlockResult) TitleEntity(org.jfree.chart.entity.TitleEntity) ChartEntity(org.jfree.chart.entity.ChartEntity) EntityBlockParams(org.jfree.chart.block.EntityBlockParams) RectangleEdge(org.jfree.ui.RectangleEdge)

Example 3 with BlockResult

use of org.jfree.chart.block.BlockResult in project SIMVA-SoS by SESoS.

the class LegendTitle method draw.

/**
 * 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>.
 */
@Override
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;
}
Also used : StandardEntityCollection(org.jfree.chart.entity.StandardEntityCollection) BlockResult(org.jfree.chart.block.BlockResult) StandardEntityCollection(org.jfree.chart.entity.StandardEntityCollection) EntityCollection(org.jfree.chart.entity.EntityCollection) BlockContainer(org.jfree.chart.block.BlockContainer) Rectangle2D(java.awt.geom.Rectangle2D) TitleEntity(org.jfree.chart.entity.TitleEntity) EntityBlockParams(org.jfree.chart.block.EntityBlockParams) BlockFrame(org.jfree.chart.block.BlockFrame)

Aggregations

BlockResult (org.jfree.chart.block.BlockResult)3 EntityBlockParams (org.jfree.chart.block.EntityBlockParams)3 StandardEntityCollection (org.jfree.chart.entity.StandardEntityCollection)3 EntityCollection (org.jfree.chart.entity.EntityCollection)2 TitleEntity (org.jfree.chart.entity.TitleEntity)2 Rectangle2D (java.awt.geom.Rectangle2D)1 BlockContainer (org.jfree.chart.block.BlockContainer)1 BlockFrame (org.jfree.chart.block.BlockFrame)1 EntityBlockResult (org.jfree.chart.block.EntityBlockResult)1 ChartEntity (org.jfree.chart.entity.ChartEntity)1 LegendItemEntity (org.jfree.chart.entity.LegendItemEntity)1 RectangleEdge (org.jfree.ui.RectangleEdge)1