Search in sources :

Example 6 with EntityBlockParams

use of org.jfree.chart.block.EntityBlockParams in project seng438-a3-R41Ryan by seng438-winter-2022.

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)

Example 7 with EntityBlockParams

use of org.jfree.chart.block.EntityBlockParams in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.

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}.
 */
@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.chart.api.RectangleEdge)

Example 8 with EntityBlockParams

use of org.jfree.chart.block.EntityBlockParams in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.

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} permitted).
 *
 * @return An instance of {@link EntityBlockResult}, or {@code null}.
 */
@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.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 9 with EntityBlockParams

use of org.jfree.chart.block.EntityBlockParams in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.

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} permitted).
 *
 * @return An {@link org.jfree.chart.block.EntityBlockResult} or
 *         {@code null}.
 */
@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)9 EntityBlockParams (org.jfree.chart.block.EntityBlockParams)9 StandardEntityCollection (org.jfree.chart.entity.StandardEntityCollection)9 EntityCollection (org.jfree.chart.entity.EntityCollection)6 TitleEntity (org.jfree.chart.entity.TitleEntity)6 Rectangle2D (java.awt.geom.Rectangle2D)3 BlockContainer (org.jfree.chart.block.BlockContainer)3 BlockFrame (org.jfree.chart.block.BlockFrame)3 EntityBlockResult (org.jfree.chart.block.EntityBlockResult)3 ChartEntity (org.jfree.chart.entity.ChartEntity)3 LegendItemEntity (org.jfree.chart.entity.LegendItemEntity)3 RectangleEdge (org.jfree.ui.RectangleEdge)2 RectangleEdge (org.jfree.chart.api.RectangleEdge)1