Search in sources :

Example 1 with BlockContainer

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

the class CompositeTitleTest method testSerialization.

/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    CompositeTitle t1 = new CompositeTitle(new BlockContainer());
    t1.getContainer().add(new TextTitle("T1"));
    t1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue));
    CompositeTitle t2 = (CompositeTitle) TestUtilities.serialised(t1);
    assertEquals(t1, t2);
}
Also used : BlockContainer(org.jfree.chart.block.BlockContainer) GradientPaint(java.awt.GradientPaint) Test(org.junit.Test)

Example 2 with BlockContainer

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

the class StandardChartTheme method applyToTitle.

/**
 * Applies the attributes of this theme to the specified title.
 *
 * @param title  the title.
 */
protected void applyToTitle(Title title) {
    if (title instanceof TextTitle) {
        TextTitle tt = (TextTitle) title;
        tt.setFont(this.largeFont);
        tt.setPaint(this.subtitlePaint);
    } else if (title instanceof LegendTitle) {
        LegendTitle lt = (LegendTitle) title;
        if (lt.getBackgroundPaint() != null) {
            lt.setBackgroundPaint(this.legendBackgroundPaint);
        }
        lt.setItemFont(this.regularFont);
        lt.setItemPaint(this.legendItemPaint);
        if (lt.getWrapper() != null) {
            applyToBlockContainer(lt.getWrapper());
        }
    } else if (title instanceof PaintScaleLegend) {
        PaintScaleLegend psl = (PaintScaleLegend) title;
        psl.setBackgroundPaint(this.legendBackgroundPaint);
        ValueAxis axis = psl.getAxis();
        if (axis != null) {
            applyToValueAxis(axis);
        }
    } else if (title instanceof CompositeTitle) {
        CompositeTitle ct = (CompositeTitle) title;
        BlockContainer bc = ct.getContainer();
        List blocks = bc.getBlocks();
        Iterator iterator = blocks.iterator();
        while (iterator.hasNext()) {
            Block b = (Block) iterator.next();
            if (b instanceof Title) {
                applyToTitle((Title) b);
            }
        }
    }
}
Also used : TextTitle(org.jfree.chart.title.TextTitle) PaintScaleLegend(org.jfree.chart.title.PaintScaleLegend) BlockContainer(org.jfree.chart.block.BlockContainer) ValueAxis(org.jfree.chart.axis.ValueAxis) Iterator(java.util.Iterator) LabelBlock(org.jfree.chart.block.LabelBlock) Block(org.jfree.chart.block.Block) Title(org.jfree.chart.title.Title) TextTitle(org.jfree.chart.title.TextTitle) LegendTitle(org.jfree.chart.title.LegendTitle) CompositeTitle(org.jfree.chart.title.CompositeTitle) LegendTitle(org.jfree.chart.title.LegendTitle) List(java.util.List) CompositeTitle(org.jfree.chart.title.CompositeTitle)

Example 3 with BlockContainer

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

the class LegendTitle method arrange.

/**
 * Arranges the contents of the block, within the given constraints, and
 * returns the block size.
 *
 * @param g2  the graphics device.
 * @param constraint  the constraint (<code>null</code> not permitted).
 *
 * @return The block size (in Java2D units, never <code>null</code>).
 */
@Override
public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) {
    Size2D result = new Size2D();
    fetchLegendItems();
    if (this.items.isEmpty()) {
        return result;
    }
    BlockContainer container = this.wrapper;
    if (container == null) {
        container = this.items;
    }
    RectangleConstraint c = toContentConstraint(constraint);
    Size2D size = container.arrange(g2, c);
    result.height = calculateTotalHeight(size.height);
    result.width = calculateTotalWidth(size.width);
    return result;
}
Also used : Size2D(org.jfree.ui.Size2D) BlockContainer(org.jfree.chart.block.BlockContainer) RectangleConstraint(org.jfree.chart.block.RectangleConstraint)

Example 4 with BlockContainer

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

the class LegendTitle method createLegendItemBlock.

/**
 * Creates a legend item block.
 *
 * @param item  the legend item.
 *
 * @return The block.
 */
protected Block createLegendItemBlock(LegendItem item) {
    BlockContainer result;
    LegendGraphic lg = new LegendGraphic(item.getShape(), item.getFillPaint());
    lg.setFillPaintTransformer(item.getFillPaintTransformer());
    lg.setShapeFilled(item.isShapeFilled());
    lg.setLine(item.getLine());
    lg.setLineStroke(item.getLineStroke());
    lg.setLinePaint(item.getLinePaint());
    lg.setLineVisible(item.isLineVisible());
    lg.setShapeVisible(item.isShapeVisible());
    lg.setShapeOutlineVisible(item.isShapeOutlineVisible());
    lg.setOutlinePaint(item.getOutlinePaint());
    lg.setOutlineStroke(item.getOutlineStroke());
    lg.setPadding(this.legendItemGraphicPadding);
    LegendItemBlockContainer legendItem = new LegendItemBlockContainer(new BorderArrangement(), item.getDataset(), item.getSeriesKey());
    lg.setShapeAnchor(getLegendItemGraphicAnchor());
    lg.setShapeLocation(getLegendItemGraphicLocation());
    legendItem.add(lg, this.legendItemGraphicEdge);
    Font textFont = item.getLabelFont();
    if (textFont == null) {
        textFont = this.itemFont;
    }
    Paint textPaint = item.getLabelPaint();
    if (textPaint == null) {
        textPaint = this.itemPaint;
    }
    LabelBlock labelBlock = new LabelBlock(item.getLabel(), textFont, textPaint);
    labelBlock.setPadding(this.itemLabelPadding);
    legendItem.add(labelBlock);
    legendItem.setToolTipText(item.getToolTipText());
    legendItem.setURLText(item.getURLText());
    result = new BlockContainer(new CenterArrangement());
    result.add(legendItem);
    return result;
}
Also used : BlockContainer(org.jfree.chart.block.BlockContainer) Paint(java.awt.Paint) BorderArrangement(org.jfree.chart.block.BorderArrangement) LabelBlock(org.jfree.chart.block.LabelBlock) Font(java.awt.Font) CenterArrangement(org.jfree.chart.block.CenterArrangement)

Example 5 with BlockContainer

use of org.jfree.chart.block.BlockContainer 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

BlockContainer (org.jfree.chart.block.BlockContainer)8 GradientPaint (java.awt.GradientPaint)4 Test (org.junit.Test)4 LabelBlock (org.jfree.chart.block.LabelBlock)2 Font (java.awt.Font)1 Paint (java.awt.Paint)1 Rectangle2D (java.awt.geom.Rectangle2D)1 Iterator (java.util.Iterator)1 List (java.util.List)1 ValueAxis (org.jfree.chart.axis.ValueAxis)1 Block (org.jfree.chart.block.Block)1 BlockBorder (org.jfree.chart.block.BlockBorder)1 BlockFrame (org.jfree.chart.block.BlockFrame)1 BlockResult (org.jfree.chart.block.BlockResult)1 BorderArrangement (org.jfree.chart.block.BorderArrangement)1 CenterArrangement (org.jfree.chart.block.CenterArrangement)1 EntityBlockParams (org.jfree.chart.block.EntityBlockParams)1 RectangleConstraint (org.jfree.chart.block.RectangleConstraint)1 EntityCollection (org.jfree.chart.entity.EntityCollection)1 StandardEntityCollection (org.jfree.chart.entity.StandardEntityCollection)1