Search in sources :

Example 6 with TextBlock

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

the class CategoryTickTest method testSerialization.

/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    CategoryTick t1 = new CategoryTick("C1", new TextBlock(), TextBlockAnchor.CENTER, TextAnchor.CENTER, 1.5f);
    CategoryTick t2 = TestUtils.serialised(t1);
    assertEquals(t1, t2);
}
Also used : TextBlock(org.jfree.chart.text.TextBlock) Test(org.junit.jupiter.api.Test)

Example 7 with TextBlock

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

the class CategoryTickTest method testCloning.

/**
 * Confirm that cloning works.
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    CategoryTick t1 = new CategoryTick("C1", new TextBlock(), TextBlockAnchor.CENTER, TextAnchor.CENTER, 1.5f);
    CategoryTick t2 = (CategoryTick) t1.clone();
    assertNotSame(t1, t2);
    assertSame(t1.getClass(), t2.getClass());
    assertEquals(t1, t2);
}
Also used : TextBlock(org.jfree.chart.text.TextBlock) Test(org.junit.jupiter.api.Test)

Example 8 with TextBlock

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

the class CategoryTickTest method testEquals.

/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    Comparable<String> c1 = "C1";
    Comparable<String> c2 = "C2";
    TextBlock tb1 = new TextBlock();
    tb1.addLine(new TextLine("Block 1"));
    TextBlock tb2 = new TextBlock();
    tb1.addLine(new TextLine("Block 2"));
    TextBlockAnchor tba1 = TextBlockAnchor.CENTER;
    TextBlockAnchor tba2 = TextBlockAnchor.BOTTOM_CENTER;
    TextAnchor ta1 = TextAnchor.CENTER;
    TextAnchor ta2 = TextAnchor.BASELINE_LEFT;
    CategoryTick t1 = new CategoryTick(c1, tb1, tba1, ta1, 1.0f);
    CategoryTick t2 = new CategoryTick(c1, tb1, tba1, ta1, 1.0f);
    assertEquals(t1, t2);
    t1 = new CategoryTick(c2, tb1, tba1, ta1, 1.0f);
    assertNotEquals(t1, t2);
    t2 = new CategoryTick(c2, tb1, tba1, ta1, 1.0f);
    assertEquals(t1, t2);
    t1 = new CategoryTick(c2, tb2, tba1, ta1, 1.0f);
    assertNotEquals(t1, t2);
    t2 = new CategoryTick(c2, tb2, tba1, ta1, 1.0f);
    assertEquals(t1, t2);
    t1 = new CategoryTick(c2, tb2, tba2, ta1, 1.0f);
    assertNotEquals(t1, t2);
    t2 = new CategoryTick(c2, tb2, tba2, ta1, 1.0f);
    assertEquals(t1, t2);
    t1 = new CategoryTick(c2, tb2, tba2, ta2, 1.0f);
    assertNotEquals(t1, t2);
    t2 = new CategoryTick(c2, tb2, tba2, ta2, 1.0f);
    assertEquals(t1, t2);
    t1 = new CategoryTick(c2, tb2, tba2, ta2, 2.0f);
    assertNotEquals(t1, t2);
    t2 = new CategoryTick(c2, tb2, tba2, ta2, 2.0f);
    assertEquals(t1, t2);
}
Also used : TextAnchor(org.jfree.chart.text.TextAnchor) TextLine(org.jfree.chart.text.TextLine) TextBlockAnchor(org.jfree.chart.text.TextBlockAnchor) TextBlock(org.jfree.chart.text.TextBlock) Test(org.junit.jupiter.api.Test)

Aggregations

TextBlock (org.jfree.chart.text.TextBlock)8 Test (org.junit.jupiter.api.Test)4 TextLine (org.jfree.chart.text.TextLine)3 Paint (java.awt.Paint)2 Shape (java.awt.Shape)2 List (java.util.List)2 TextAnchor (org.jfree.chart.text.TextAnchor)2 TextBlockAnchor (org.jfree.chart.text.TextBlockAnchor)2 Point2D (java.awt.geom.Point2D)1 Rectangle2D (java.awt.geom.Rectangle2D)1 CategoryLabelEntity (org.jfree.chart.entity.CategoryLabelEntity)1 EntityCollection (org.jfree.chart.entity.EntityCollection)1 CategoryPlot (org.jfree.chart.plot.CategoryPlot)1 G2TextMeasurer (org.jfree.chart.text.G2TextMeasurer)1 TextFragment (org.jfree.chart.text.TextFragment)1