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);
}
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);
}
}
}
}
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;
}
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;
}
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;
}
Aggregations