org.jfree.chart.block.BlockContainer Java Examples

The following examples show how to use org.jfree.chart.block.BlockContainer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LegendTitle.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * 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>.
 */
public Object draw(Graphics2D g2, Rectangle2D area, Object params) {
    Rectangle2D target = (Rectangle2D) area.clone();
    target = trimMargin(target);
    if (this.backgroundPaint != null) {
        g2.setPaint(this.backgroundPaint);
        g2.fill(target);
    }
    getBorder().draw(g2, target);
    getBorder().getInsets().trim(target);
    BlockContainer container = this.wrapper;
    if (container == null) {
        container = this.items; 
    }
    target = trimPadding(target);
    return container.draw(g2, target, params);   
}
 
Example #2
Source File: LegendTitle.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #3
Source File: BlockContainerTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Confirm that the equals() method can distinguish all the required fields.
 */
public void testEquals() {
    BlockContainer c1 = new BlockContainer(new FlowArrangement());
    BlockContainer c2 = new BlockContainer(new FlowArrangement());
    assertTrue(c1.equals(c2));
    assertTrue(c2.equals(c2));

    c1.setArrangement(new ColumnArrangement());
    assertFalse(c1.equals(c2));
    c2.setArrangement(new ColumnArrangement());
    assertTrue(c1.equals(c2));

    c1.add(new EmptyBlock(1.2, 3.4));
    assertFalse(c1.equals(c2));
    c2.add(new EmptyBlock(1.2, 3.4));
    assertTrue(c1.equals(c2));
}
 
Example #4
Source File: LegendTitle.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a new legend title with the specified arrangement.
 *
 * @param source  the source.
 * @param hLayout  the horizontal item arrangement (<code>null</code> not
 *                 permitted).
 * @param vLayout  the vertical item arrangement (<code>null</code> not
 *                 permitted).
 */
public LegendTitle(LegendItemSource source,
                   Arrangement hLayout, Arrangement vLayout) {
    this.sources = new LegendItemSource[] {source};
    this.items = new BlockContainer(hLayout);
    this.hLayout = hLayout;
    this.vLayout = vLayout;
    this.backgroundPaint = null;
    this.legendItemGraphicEdge = RectangleEdge.LEFT;
    this.legendItemGraphicAnchor = RectangleAnchor.CENTER;
    this.legendItemGraphicLocation = RectangleAnchor.CENTER;
    this.legendItemGraphicPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
    this.itemFont = DEFAULT_ITEM_FONT;
    this.itemPaint = DEFAULT_ITEM_PAINT;
    this.itemLabelPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
}
 
Example #5
Source File: LegendTitle.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new legend title with the specified arrangement.
 *
 * @param source  the source.
 * @param hLayout  the horizontal item arrangement (<code>null</code> not
 *                 permitted).
 * @param vLayout  the vertical item arrangement (<code>null</code> not
 *                 permitted).
 */
public LegendTitle(LegendItemSource source,
                   Arrangement hLayout, Arrangement vLayout) {
    this.sources = new LegendItemSource[] {source};
    this.items = new BlockContainer(hLayout);
    this.hLayout = hLayout;
    this.vLayout = vLayout;
    this.backgroundPaint = null;
    this.legendItemGraphicEdge = RectangleEdge.LEFT;
    this.legendItemGraphicAnchor = RectangleAnchor.CENTER;
    this.legendItemGraphicLocation = RectangleAnchor.CENTER;
    this.legendItemGraphicPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
    this.itemFont = DEFAULT_ITEM_FONT;
    this.itemPaint = DEFAULT_ITEM_PAINT;
    this.itemLabelPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
    this.sortOrder = SortOrder.ASCENDING;
}
 
Example #6
Source File: LegendTitle.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * 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>).
 */
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;
}
 
Example #7
Source File: LegendTitle.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a new legend title with the specified arrangement.
 *
 * @param source  the source.
 * @param hLayout  the horizontal item arrangement (<code>null</code> not
 *                 permitted).
 * @param vLayout  the vertical item arrangement (<code>null</code> not
 *                 permitted).
 */
public LegendTitle(LegendItemSource source,
                   Arrangement hLayout, Arrangement vLayout) {
    this.sources = new LegendItemSource[] {source};
    this.items = new BlockContainer(hLayout);
    this.hLayout = hLayout;
    this.vLayout = vLayout;
    this.backgroundPaint = null;
    this.legendItemGraphicEdge = RectangleEdge.LEFT;
    this.legendItemGraphicAnchor = RectangleAnchor.CENTER;
    this.legendItemGraphicLocation = RectangleAnchor.CENTER;
    this.legendItemGraphicPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
    this.itemFont = DEFAULT_ITEM_FONT;
    this.itemPaint = DEFAULT_ITEM_PAINT;
    this.itemLabelPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
    this.sortOrder = SortOrder.ASCENDING;
}
 
Example #8
Source File: LegendTitle.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #9
Source File: LegendTitle.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new legend title with the specified arrangement.
 * 
 * @param source  the source.
 * @param hLayout  the horizontal item arrangement (<code>null</code> not
 *                 permitted).
 * @param vLayout  the vertical item arrangement (<code>null</code> not
 *                 permitted).
 */
public LegendTitle(LegendItemSource source, 
                   Arrangement hLayout, Arrangement vLayout) {
    this.sources = new LegendItemSource[] {source};
    this.items = new BlockContainer(hLayout);
    this.hLayout = hLayout;
    this.vLayout = vLayout;
    this.backgroundPaint = null;  
    this.legendItemGraphicEdge = RectangleEdge.LEFT;
    this.legendItemGraphicAnchor = RectangleAnchor.CENTER;
    this.legendItemGraphicLocation = RectangleAnchor.CENTER;
    this.legendItemGraphicPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
    this.itemFont = DEFAULT_ITEM_FONT;
    this.itemPaint = DEFAULT_ITEM_PAINT;
    this.itemLabelPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
}
 
Example #10
Source File: LegendTitle.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #11
Source File: CompositeTitleTest.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Confirm that cloning works.
 */
@Test
public void testCloning() {
    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.yellow));
    CompositeTitle t2 = null;
    try {
        t2 = (CompositeTitle) t1.clone();
    }
    catch (CloneNotSupportedException e) {
        fail(e.toString());
    }
    assertTrue(t1 != t2);
    assertTrue(t1.getClass() == t2.getClass());
    assertTrue(t1.equals(t2));
}
 
Example #12
Source File: LegendTitle.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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>.
 */
public Object draw(Graphics2D g2, Rectangle2D area, Object params) {
    Rectangle2D target = (Rectangle2D) area.clone();
    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);
    return container.draw(g2, target, params);   
}
 
Example #13
Source File: LegendTitle.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a new legend title with the specified arrangement.
 *
 * @param source  the source.
 * @param hLayout  the horizontal item arrangement (<code>null</code> not
 *                 permitted).
 * @param vLayout  the vertical item arrangement (<code>null</code> not
 *                 permitted).
 */
public LegendTitle(LegendItemSource source,
                   Arrangement hLayout, Arrangement vLayout) {
    this.sources = new LegendItemSource[] {source};
    this.items = new BlockContainer(hLayout);
    this.hLayout = hLayout;
    this.vLayout = vLayout;
    this.backgroundPaint = null;
    this.legendItemGraphicEdge = RectangleEdge.LEFT;
    this.legendItemGraphicAnchor = RectangleAnchor.CENTER;
    this.legendItemGraphicLocation = RectangleAnchor.CENTER;
    this.legendItemGraphicPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
    this.itemFont = DEFAULT_ITEM_FONT;
    this.itemPaint = DEFAULT_ITEM_PAINT;
    this.itemLabelPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0);
    this.sortOrder = SortOrder.ASCENDING;
}
 
Example #14
Source File: LegendTitle.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #15
Source File: CompositeTitleTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Confirm that cloning works.
 */
@Test
public void testCloning() {
    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.yellow));
    CompositeTitle t2 = null;
    try {
        t2 = (CompositeTitle) t1.clone();
    }
    catch (CloneNotSupportedException e) {
        fail(e.toString());
    }
    assertTrue(t1 != t2);
    assertTrue(t1.getClass() == t2.getClass());
    assertTrue(t1.equals(t2));
}
 
Example #16
Source File: CompositeTitleTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check that the equals() method distinguishes all fields.
 */
@Test
public void testEquals() {
    CompositeTitle t1 = new CompositeTitle(new BlockContainer());
    CompositeTitle t2 = new CompositeTitle(new BlockContainer());
    assertEquals(t1, t2);
    assertEquals(t2, t1);

    // margin
    t1.setMargin(new RectangleInsets(1.0, 2.0, 3.0, 4.0));
    assertFalse(t1.equals(t2));
    t2.setMargin(new RectangleInsets(1.0, 2.0, 3.0, 4.0));
    assertTrue(t1.equals(t2));

    // border
    t1.setBorder(new BlockBorder(Color.red));
    assertFalse(t1.equals(t2));
    t2.setBorder(new BlockBorder(Color.red));
    assertTrue(t1.equals(t2));

    // padding
    t1.setPadding(new RectangleInsets(1.0, 2.0, 3.0, 4.0));
    assertFalse(t1.equals(t2));
    t2.setPadding(new RectangleInsets(1.0, 2.0, 3.0, 4.0));
    assertTrue(t1.equals(t2));

    // contained titles
    t1.getContainer().add(new TextTitle("T1"));
    assertFalse(t1.equals(t2));
    t2.getContainer().add(new TextTitle("T1"));
    assertTrue(t1.equals(t2));

    t1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.yellow));
    assertFalse(t1.equals(t2));
    t2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.yellow));
    assertTrue(t1.equals(t2));

}
 
Example #17
Source File: CompositeTitle.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new title using the specified container. 
 * 
 * @param container  the container (<code>null</code> not permitted).
 */
public CompositeTitle(BlockContainer container) {
    if (container == null) {
        throw new IllegalArgumentException("Null 'container' argument.");
    }
    this.container = container;
}
 
Example #18
Source File: StandardChartTheme.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Applies the attributes of this theme to the specified container.
 *
 * @param bc  a block container (<code>null</code> not permitted).
 */
protected void applyToBlockContainer(BlockContainer bc) {
    Iterator iterator = bc.getBlocks().iterator();
    while (iterator.hasNext()) {
        Block b = (Block) iterator.next();
        applyToBlock(b);
    }
}
 
Example #19
Source File: StandardChartTheme.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Applies the attributes of this theme to the specified container.
 *
 * @param bc  a block container (<code>null</code> not permitted).
 */
protected void applyToBlockContainer(BlockContainer bc) {
    Iterator iterator = bc.getBlocks().iterator();
    while (iterator.hasNext()) {
        Block b = (Block) iterator.next();
        applyToBlock(b);
    }
}
 
Example #20
Source File: StandardChartTheme.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
            }
        }
    }
}
 
Example #21
Source File: CompositeTitleTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Two objects that are equal are required to return the same hashCode.
 */
@Test
public void testHashcode() {
    CompositeTitle t1 = new CompositeTitle(new BlockContainer());
    t1.getContainer().add(new TextTitle("T1"));
    CompositeTitle t2 = new CompositeTitle(new BlockContainer());
    t2.getContainer().add(new TextTitle("T1"));
    assertTrue(t1.equals(t2));
    int h1 = t1.hashCode();
    int h2 = t2.hashCode();
    assertEquals(h1, h2);
}
 
Example #22
Source File: StandardChartTheme.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Applies the attributes of this theme to the specified container.
 *
 * @param bc  a block container (<code>null</code> not permitted).
 */
protected void applyToBlockContainer(BlockContainer bc) {
    Iterator iterator = bc.getBlocks().iterator();
    while (iterator.hasNext()) {
        Block b = (Block) iterator.next();
        applyToBlock(b);
    }
}
 
Example #23
Source File: CompositeTitle.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new title using the specified container.
 *
 * @param container  the container (<code>null</code> not permitted).
 */
public CompositeTitle(BlockContainer container) {
    if (container == null) {
        throw new IllegalArgumentException("Null 'container' argument.");
    }
    this.container = container;
    this.backgroundPaint = null;
}
 
Example #24
Source File: CompositeTitleTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Two objects that are equal are required to return the same hashCode.
 */
public void testHashcode() {
    CompositeTitle t1 = new CompositeTitle(new BlockContainer());
    t1.getContainer().add(new TextTitle("T1"));
    CompositeTitle t2 = new CompositeTitle(new BlockContainer());
    t2.getContainer().add(new TextTitle("T1"));
    assertTrue(t1.equals(t2));
    int h1 = t1.hashCode();
    int h2 = t2.hashCode();
    assertEquals(h1, h2);
}
 
Example #25
Source File: CompositeTitleTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check that the equals() method distinguishes all fields.
 */
public void testEquals() {
    CompositeTitle t1 = new CompositeTitle(new BlockContainer());
    CompositeTitle t2 = new CompositeTitle(new BlockContainer());
    assertEquals(t1, t2);
    assertEquals(t2, t1);

    // margin
    t1.setMargin(new RectangleInsets(1.0, 2.0, 3.0, 4.0));
    assertFalse(t1.equals(t2));
    t2.setMargin(new RectangleInsets(1.0, 2.0, 3.0, 4.0));
    assertTrue(t1.equals(t2));

    // frame
    t1.setFrame(new BlockBorder(Color.red));
    assertFalse(t1.equals(t2));
    t2.setFrame(new BlockBorder(Color.red));
    assertTrue(t1.equals(t2));

    // padding
    t1.setPadding(new RectangleInsets(1.0, 2.0, 3.0, 4.0));
    assertFalse(t1.equals(t2));
    t2.setPadding(new RectangleInsets(1.0, 2.0, 3.0, 4.0));
    assertTrue(t1.equals(t2));

    // contained titles
    t1.getContainer().add(new TextTitle("T1"));
    assertFalse(t1.equals(t2));
    t2.getContainer().add(new TextTitle("T1"));
    assertTrue(t1.equals(t2));

    t1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.yellow));
    assertFalse(t1.equals(t2));
    t2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.yellow));
    assertTrue(t1.equals(t2));

}
 
Example #26
Source File: GridArrangementTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test arrangement with a fixed width and no height constraint.
 */
public void testFN() {
    BlockContainer c = createTestContainer1();
    RectangleConstraint constraint = new RectangleConstraint(100.0, null,
            LengthConstraintType.FIXED, 0.0, null,
            LengthConstraintType.NONE);
    Size2D s = c.arrange(null, constraint);
    assertEquals(100.0, s.width, EPSILON);
    assertEquals(33.0, s.height, EPSILON);
}
 
Example #27
Source File: GridArrangementTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The arrangement should be able to handle null blocks in the layout.
 */
public void testNullBlock_FF() {
    BlockContainer c = new BlockContainer(new GridArrangement(1, 1));
    c.add(null);
    Size2D s = c.arrange(null, new RectangleConstraint(20, 10));
    assertEquals(20.0, s.getWidth(), EPSILON);
    assertEquals(10.0, s.getHeight(), EPSILON);
}
 
Example #28
Source File: StandardChartTheme.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
            }
        }
    }
}
 
Example #29
Source File: GridArrangementTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The arrangement should be able to handle null blocks in the layout.
 */
public void testNullBlock_FN() {
    BlockContainer c = new BlockContainer(new GridArrangement(1, 1));
    c.add(null);
    Size2D s = c.arrange(null, RectangleConstraint.NONE.toFixedWidth(10));
    assertEquals(10.0, s.getWidth(), EPSILON);
    assertEquals(0.0, s.getHeight(), EPSILON);
}
 
Example #30
Source File: StandardChartTheme.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Applies the attributes of this theme to the specified container.
 *
 * @param bc  a block container (<code>null</code> not permitted).
 */
protected void applyToBlockContainer(BlockContainer bc) {
    Iterator iterator = bc.getBlocks().iterator();
    while (iterator.hasNext()) {
        Block b = (Block) iterator.next();
        applyToBlock(b);
    }
}