Search in sources :

Example 6 with BlockContainer

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

the class CompositeTitleTest method testCloning.

/**
 * 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));
}
Also used : BlockContainer(org.jfree.chart.block.BlockContainer) GradientPaint(java.awt.GradientPaint) Test(org.junit.Test)

Example 7 with BlockContainer

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

the class CompositeTitleTest method testEquals.

/**
 * 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));
}
Also used : BlockContainer(org.jfree.chart.block.BlockContainer) BlockBorder(org.jfree.chart.block.BlockBorder) RectangleInsets(org.jfree.ui.RectangleInsets) GradientPaint(java.awt.GradientPaint) Test(org.junit.Test)

Example 8 with BlockContainer

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

the class CompositeTitleTest method testHashcode.

/**
 * 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);
}
Also used : BlockContainer(org.jfree.chart.block.BlockContainer) GradientPaint(java.awt.GradientPaint) Test(org.junit.Test)

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