Java Code Examples for org.jfree.ui.TextAnchor#BASELINE_LEFT

The following examples show how to use org.jfree.ui.TextAnchor#BASELINE_LEFT . 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: CategoryLabelPositionTest.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Check that the equals() method can distinguish all fields.
 */
@Test
public void testEquals() {
    CategoryLabelPosition p1 = new CategoryLabelPosition(
            RectangleAnchor.BOTTOM_LEFT, TextBlockAnchor.CENTER_RIGHT,
            TextAnchor.BASELINE_LEFT, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    CategoryLabelPosition p2 = new CategoryLabelPosition(
            RectangleAnchor.BOTTOM_LEFT, TextBlockAnchor.CENTER_RIGHT,
            TextAnchor.BASELINE_LEFT, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertTrue(p1.equals(p2));
    assertTrue(p2.equals(p1));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER_RIGHT, TextAnchor.BASELINE_LEFT,
            Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER_RIGHT, TextAnchor.BASELINE_LEFT,
            Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f);
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.BASELINE_LEFT, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.BASELINE_LEFT, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0,
            CategoryLabelWidthType.CATEGORY, 0.44f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0,
            CategoryLabelWidthType.CATEGORY, 0.44f);
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER,  Math.PI / 6.0,
            CategoryLabelWidthType.CATEGORY, 0.55f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0,
            CategoryLabelWidthType.CATEGORY, 0.55f);
    assertTrue(p1.equals(p2));
}
 
Example 2
Source File: CategoryTickTest.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    Comparable c1 = "C1";
    Comparable 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);
    assertTrue(t1.equals(t2));

    t1 = new CategoryTick(c2, tb1, tba1, ta1, 1.0f);
    assertFalse(t1.equals(t2));
    t2 = new CategoryTick(c2, tb1, tba1, ta1, 1.0f);
    assertTrue(t1.equals(t2));

    t1 = new CategoryTick(c2, tb2, tba1, ta1, 1.0f);
    assertFalse(t1.equals(t2));
    t2 = new CategoryTick(c2, tb2, tba1, ta1, 1.0f);
    assertTrue(t1.equals(t2));

    t1 = new CategoryTick(c2, tb2, tba2, ta1, 1.0f);
    assertFalse(t1.equals(t2));
    t2 = new CategoryTick(c2, tb2, tba2, ta1, 1.0f);
    assertTrue(t1.equals(t2));

    t1 = new CategoryTick(c2, tb2, tba2, ta2, 1.0f);
    assertFalse(t1.equals(t2));
    t2 = new CategoryTick(c2, tb2, tba2, ta2, 1.0f);
    assertTrue(t1.equals(t2));

    t1 = new CategoryTick(c2, tb2, tba2, ta2, 2.0f);
    assertFalse(t1.equals(t2));
    t2 = new CategoryTick(c2, tb2, tba2, ta2, 2.0f);
    assertTrue(t1.equals(t2));

}
 
Example 3
Source File: DateTickTest.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    Date d1 = new Date(0L);
    Date d2 = new Date(1L);
    String l1 = "Label 1";
    String l2 = "Label 2";
    TextAnchor ta1 = TextAnchor.CENTER;
    TextAnchor ta2 = TextAnchor.BASELINE_LEFT;

    DateTick t1 = new DateTick(d1, l1, ta1, ta1, Math.PI / 2.0);
    DateTick t2 = new DateTick(d1, l1, ta1, ta1, Math.PI / 2.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(d2, l1, ta1, ta1, Math.PI / 2.0);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(d2, l1, ta1, ta1, Math.PI / 2.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(d1, l2, ta1, ta1, Math.PI / 2.0);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(d1, l2, ta1, ta1, Math.PI / 2.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(d1, l1, ta2, ta1, Math.PI / 2.0);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(d1, l1, ta2, ta1, Math.PI / 2.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(d1, l1, ta1, ta2, Math.PI / 2.0);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(d1, l1, ta1, ta2, Math.PI / 2.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(d1, l1, ta1, ta1, Math.PI / 3.0);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(d1, l1, ta1, ta1, Math.PI / 3.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(TickType.MINOR, d1, l1, ta1, ta1, Math.PI);
    t2 = new DateTick(TickType.MAJOR, d1, l1, ta1, ta1, Math.PI);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(TickType.MINOR, d1, l1, ta1, ta1, Math.PI);
    assertTrue(t1.equals(t2));
}
 
Example 4
Source File: CategoryLabelPositionTest.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Check that the equals() method can distinguish all fields.
 */
@Test
public void testEquals() {
    CategoryLabelPosition p1 = new CategoryLabelPosition(
            RectangleAnchor.BOTTOM_LEFT, TextBlockAnchor.CENTER_RIGHT,
            TextAnchor.BASELINE_LEFT, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    CategoryLabelPosition p2 = new CategoryLabelPosition(
            RectangleAnchor.BOTTOM_LEFT, TextBlockAnchor.CENTER_RIGHT,
            TextAnchor.BASELINE_LEFT, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertTrue(p1.equals(p2));
    assertTrue(p2.equals(p1));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER_RIGHT, TextAnchor.BASELINE_LEFT,
            Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER_RIGHT, TextAnchor.BASELINE_LEFT,
            Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f);
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.BASELINE_LEFT, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.BASELINE_LEFT, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0,
            CategoryLabelWidthType.CATEGORY, 0.44f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0,
            CategoryLabelWidthType.CATEGORY, 0.44f);
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER,  Math.PI / 6.0,
            CategoryLabelWidthType.CATEGORY, 0.55f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0,
            CategoryLabelWidthType.CATEGORY, 0.55f);
    assertTrue(p1.equals(p2));
}
 
Example 5
Source File: CategoryTickTest.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    Comparable c1 = "C1";
    Comparable 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);
    assertTrue(t1.equals(t2));

    t1 = new CategoryTick(c2, tb1, tba1, ta1, 1.0f);
    assertFalse(t1.equals(t2));
    t2 = new CategoryTick(c2, tb1, tba1, ta1, 1.0f);
    assertTrue(t1.equals(t2));

    t1 = new CategoryTick(c2, tb2, tba1, ta1, 1.0f);
    assertFalse(t1.equals(t2));
    t2 = new CategoryTick(c2, tb2, tba1, ta1, 1.0f);
    assertTrue(t1.equals(t2));

    t1 = new CategoryTick(c2, tb2, tba2, ta1, 1.0f);
    assertFalse(t1.equals(t2));
    t2 = new CategoryTick(c2, tb2, tba2, ta1, 1.0f);
    assertTrue(t1.equals(t2));

    t1 = new CategoryTick(c2, tb2, tba2, ta2, 1.0f);
    assertFalse(t1.equals(t2));
    t2 = new CategoryTick(c2, tb2, tba2, ta2, 1.0f);
    assertTrue(t1.equals(t2));

    t1 = new CategoryTick(c2, tb2, tba2, ta2, 2.0f);
    assertFalse(t1.equals(t2));
    t2 = new CategoryTick(c2, tb2, tba2, ta2, 2.0f);
    assertTrue(t1.equals(t2));

}
 
Example 6
Source File: DateTickTest.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    Date d1 = new Date(0L);
    Date d2 = new Date(1L);
    String l1 = "Label 1";
    String l2 = "Label 2";
    TextAnchor ta1 = TextAnchor.CENTER;
    TextAnchor ta2 = TextAnchor.BASELINE_LEFT;

    DateTick t1 = new DateTick(d1, l1, ta1, ta1, Math.PI / 2.0);
    DateTick t2 = new DateTick(d1, l1, ta1, ta1, Math.PI / 2.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(d2, l1, ta1, ta1, Math.PI / 2.0);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(d2, l1, ta1, ta1, Math.PI / 2.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(d1, l2, ta1, ta1, Math.PI / 2.0);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(d1, l2, ta1, ta1, Math.PI / 2.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(d1, l1, ta2, ta1, Math.PI / 2.0);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(d1, l1, ta2, ta1, Math.PI / 2.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(d1, l1, ta1, ta2, Math.PI / 2.0);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(d1, l1, ta1, ta2, Math.PI / 2.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(d1, l1, ta1, ta1, Math.PI / 3.0);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(d1, l1, ta1, ta1, Math.PI / 3.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(TickType.MINOR, d1, l1, ta1, ta1, Math.PI);
    t2 = new DateTick(TickType.MAJOR, d1, l1, ta1, ta1, Math.PI);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(TickType.MINOR, d1, l1, ta1, ta1, Math.PI);
    assertTrue(t1.equals(t2));
}
 
Example 7
Source File: DrawStringDemo.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Converts a string to a corresponding {@link TextAnchor} instance.
 *
 * @param text  the text.
 *
 * @return The anchor.
 */
private TextAnchor convertStringToAnchor(final String text) {

    if (text.equals("TextAnchor.TOP_LEFT")) {
        return TextAnchor.TOP_LEFT;
    }
    else if (text.equals("TextAnchor.TOP_CENTER")) {
        return TextAnchor.TOP_CENTER;
    }
    else if (text.equals("TextAnchor.TOP_RIGHT")) {
        return TextAnchor.TOP_RIGHT;
    }
    else if (text.equals("TextAnchor.CENTER_LEFT")) {
        return TextAnchor.CENTER_LEFT;
    }
    else if (text.equals("TextAnchor.CENTER")) {
        return TextAnchor.CENTER;
    }
    else if (text.equals("TextAnchor.CENTER_RIGHT")) {
        return TextAnchor.CENTER_RIGHT;
    }
    else if (text.equals("TextAnchor.HALF_ASCENT_LEFT")) {
        return TextAnchor.HALF_ASCENT_LEFT;
    }
    else if (text.equals("TextAnchor.HALF_ASCENT_CENTER")) {
        return TextAnchor.HALF_ASCENT_CENTER;
    }
    else if (text.equals("TextAnchor.HALF_ASCENT_RIGHT")) {
        return TextAnchor.HALF_ASCENT_RIGHT;
    }
    else if (text.equals("TextAnchor.BASELINE_LEFT")) {
        return TextAnchor.BASELINE_LEFT;
    }
    else if (text.equals("TextAnchor.BASELINE_CENTER")) {
        return TextAnchor.BASELINE_CENTER;
    }
    else if (text.equals("TextAnchor.BASELINE_RIGHT")) {
        return TextAnchor.BASELINE_RIGHT;
    }
    else if (text.equals("TextAnchor.BOTTOM_LEFT")) {
        return TextAnchor.BOTTOM_LEFT;
    }
    else if (text.equals("TextAnchor.BOTTOM_CENTER")) {
        return TextAnchor.BOTTOM_CENTER;
    }
    else if (text.equals("TextAnchor.BOTTOM_RIGHT")) {
        return TextAnchor.BOTTOM_RIGHT;
    }
    else {
        return null;
    }

}
 
Example 8
Source File: CategoryLabelPositionTest.java    From SIMVA-SoS with Apache License 2.0 4 votes vote down vote up
/**
 * Check that the equals() method can distinguish all fields.
 */
@Test
public void testEquals() {
    CategoryLabelPosition p1 = new CategoryLabelPosition(
            RectangleAnchor.BOTTOM_LEFT, TextBlockAnchor.CENTER_RIGHT,
            TextAnchor.BASELINE_LEFT, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    CategoryLabelPosition p2 = new CategoryLabelPosition(
            RectangleAnchor.BOTTOM_LEFT, TextBlockAnchor.CENTER_RIGHT,
            TextAnchor.BASELINE_LEFT, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertTrue(p1.equals(p2));
    assertTrue(p2.equals(p1));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER_RIGHT, TextAnchor.BASELINE_LEFT,
            Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER_RIGHT, TextAnchor.BASELINE_LEFT,
            Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f);
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.BASELINE_LEFT, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.BASELINE_LEFT, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0,
            CategoryLabelWidthType.CATEGORY, 0.44f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0,
            CategoryLabelWidthType.CATEGORY, 0.44f);
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER,  Math.PI / 6.0,
            CategoryLabelWidthType.CATEGORY, 0.55f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0,
            CategoryLabelWidthType.CATEGORY, 0.55f);
    assertTrue(p1.equals(p2));
}
 
Example 9
Source File: CategoryTickTest.java    From SIMVA-SoS with Apache License 2.0 4 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    Comparable c1 = "C1";
    Comparable 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);
    assertTrue(t1.equals(t2));

    t1 = new CategoryTick(c2, tb1, tba1, ta1, 1.0f);
    assertFalse(t1.equals(t2));
    t2 = new CategoryTick(c2, tb1, tba1, ta1, 1.0f);
    assertTrue(t1.equals(t2));

    t1 = new CategoryTick(c2, tb2, tba1, ta1, 1.0f);
    assertFalse(t1.equals(t2));
    t2 = new CategoryTick(c2, tb2, tba1, ta1, 1.0f);
    assertTrue(t1.equals(t2));

    t1 = new CategoryTick(c2, tb2, tba2, ta1, 1.0f);
    assertFalse(t1.equals(t2));
    t2 = new CategoryTick(c2, tb2, tba2, ta1, 1.0f);
    assertTrue(t1.equals(t2));

    t1 = new CategoryTick(c2, tb2, tba2, ta2, 1.0f);
    assertFalse(t1.equals(t2));
    t2 = new CategoryTick(c2, tb2, tba2, ta2, 1.0f);
    assertTrue(t1.equals(t2));

    t1 = new CategoryTick(c2, tb2, tba2, ta2, 2.0f);
    assertFalse(t1.equals(t2));
    t2 = new CategoryTick(c2, tb2, tba2, ta2, 2.0f);
    assertTrue(t1.equals(t2));

}
 
Example 10
Source File: DateTickTest.java    From SIMVA-SoS with Apache License 2.0 4 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    Date d1 = new Date(0L);
    Date d2 = new Date(1L);
    String l1 = "Label 1";
    String l2 = "Label 2";
    TextAnchor ta1 = TextAnchor.CENTER;
    TextAnchor ta2 = TextAnchor.BASELINE_LEFT;

    DateTick t1 = new DateTick(d1, l1, ta1, ta1, Math.PI / 2.0);
    DateTick t2 = new DateTick(d1, l1, ta1, ta1, Math.PI / 2.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(d2, l1, ta1, ta1, Math.PI / 2.0);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(d2, l1, ta1, ta1, Math.PI / 2.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(d1, l2, ta1, ta1, Math.PI / 2.0);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(d1, l2, ta1, ta1, Math.PI / 2.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(d1, l1, ta2, ta1, Math.PI / 2.0);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(d1, l1, ta2, ta1, Math.PI / 2.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(d1, l1, ta1, ta2, Math.PI / 2.0);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(d1, l1, ta1, ta2, Math.PI / 2.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(d1, l1, ta1, ta1, Math.PI / 3.0);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(d1, l1, ta1, ta1, Math.PI / 3.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(TickType.MINOR, d1, l1, ta1, ta1, Math.PI);
    t2 = new DateTick(TickType.MAJOR, d1, l1, ta1, ta1, Math.PI);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(TickType.MINOR, d1, l1, ta1, ta1, Math.PI);
    assertTrue(t1.equals(t2));
}
 
Example 11
Source File: CategoryLabelPositionTest.java    From ECG-Viewer with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Check that the equals() method can distinguish all fields.
 */
@Test
public void testEquals() {
    CategoryLabelPosition p1 = new CategoryLabelPosition(
            RectangleAnchor.BOTTOM_LEFT, TextBlockAnchor.CENTER_RIGHT,
            TextAnchor.BASELINE_LEFT, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    CategoryLabelPosition p2 = new CategoryLabelPosition(
            RectangleAnchor.BOTTOM_LEFT, TextBlockAnchor.CENTER_RIGHT,
            TextAnchor.BASELINE_LEFT, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertTrue(p1.equals(p2));
    assertTrue(p2.equals(p1));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER_RIGHT, TextAnchor.BASELINE_LEFT,
            Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER_RIGHT, TextAnchor.BASELINE_LEFT,
            Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f);
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.BASELINE_LEFT, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.BASELINE_LEFT, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0,
            CategoryLabelWidthType.CATEGORY, 0.44f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0,
            CategoryLabelWidthType.CATEGORY, 0.44f);
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER,  Math.PI / 6.0,
            CategoryLabelWidthType.CATEGORY, 0.55f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0,
            CategoryLabelWidthType.CATEGORY, 0.55f);
    assertTrue(p1.equals(p2));
}
 
Example 12
Source File: CategoryTickTest.java    From ECG-Viewer with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    Comparable c1 = "C1";
    Comparable 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);
    assertTrue(t1.equals(t2));

    t1 = new CategoryTick(c2, tb1, tba1, ta1, 1.0f);
    assertFalse(t1.equals(t2));
    t2 = new CategoryTick(c2, tb1, tba1, ta1, 1.0f);
    assertTrue(t1.equals(t2));

    t1 = new CategoryTick(c2, tb2, tba1, ta1, 1.0f);
    assertFalse(t1.equals(t2));
    t2 = new CategoryTick(c2, tb2, tba1, ta1, 1.0f);
    assertTrue(t1.equals(t2));

    t1 = new CategoryTick(c2, tb2, tba2, ta1, 1.0f);
    assertFalse(t1.equals(t2));
    t2 = new CategoryTick(c2, tb2, tba2, ta1, 1.0f);
    assertTrue(t1.equals(t2));

    t1 = new CategoryTick(c2, tb2, tba2, ta2, 1.0f);
    assertFalse(t1.equals(t2));
    t2 = new CategoryTick(c2, tb2, tba2, ta2, 1.0f);
    assertTrue(t1.equals(t2));

    t1 = new CategoryTick(c2, tb2, tba2, ta2, 2.0f);
    assertFalse(t1.equals(t2));
    t2 = new CategoryTick(c2, tb2, tba2, ta2, 2.0f);
    assertTrue(t1.equals(t2));

}
 
Example 13
Source File: DateTickTest.java    From ECG-Viewer with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    Date d1 = new Date(0L);
    Date d2 = new Date(1L);
    String l1 = "Label 1";
    String l2 = "Label 2";
    TextAnchor ta1 = TextAnchor.CENTER;
    TextAnchor ta2 = TextAnchor.BASELINE_LEFT;

    DateTick t1 = new DateTick(d1, l1, ta1, ta1, Math.PI / 2.0);
    DateTick t2 = new DateTick(d1, l1, ta1, ta1, Math.PI / 2.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(d2, l1, ta1, ta1, Math.PI / 2.0);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(d2, l1, ta1, ta1, Math.PI / 2.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(d1, l2, ta1, ta1, Math.PI / 2.0);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(d1, l2, ta1, ta1, Math.PI / 2.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(d1, l1, ta2, ta1, Math.PI / 2.0);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(d1, l1, ta2, ta1, Math.PI / 2.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(d1, l1, ta1, ta2, Math.PI / 2.0);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(d1, l1, ta1, ta2, Math.PI / 2.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(d1, l1, ta1, ta1, Math.PI / 3.0);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(d1, l1, ta1, ta1, Math.PI / 3.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(TickType.MINOR, d1, l1, ta1, ta1, Math.PI);
    t2 = new DateTick(TickType.MAJOR, d1, l1, ta1, ta1, Math.PI);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(TickType.MINOR, d1, l1, ta1, ta1, Math.PI);
    assertTrue(t1.equals(t2));
}
 
Example 14
Source File: CategoryLabelPositionTest.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Check that the equals() method can distinguish all fields.
 */
@Test
public void testEquals() {
    CategoryLabelPosition p1 = new CategoryLabelPosition(
            RectangleAnchor.BOTTOM_LEFT, TextBlockAnchor.CENTER_RIGHT,
            TextAnchor.BASELINE_LEFT, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    CategoryLabelPosition p2 = new CategoryLabelPosition(
            RectangleAnchor.BOTTOM_LEFT, TextBlockAnchor.CENTER_RIGHT,
            TextAnchor.BASELINE_LEFT, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertTrue(p1.equals(p2));
    assertTrue(p2.equals(p1));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER_RIGHT, TextAnchor.BASELINE_LEFT,
            Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER_RIGHT, TextAnchor.BASELINE_LEFT,
            Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f);
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.BASELINE_LEFT, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.BASELINE_LEFT, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 4.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0,
            CategoryLabelWidthType.RANGE, 0.44f);
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0,
            CategoryLabelWidthType.CATEGORY, 0.44f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0,
            CategoryLabelWidthType.CATEGORY, 0.44f);
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER,  Math.PI / 6.0,
            CategoryLabelWidthType.CATEGORY, 0.55f);
    assertFalse(p1.equals(p2));
    p2 = new CategoryLabelPosition(RectangleAnchor.TOP,
            TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0,
            CategoryLabelWidthType.CATEGORY, 0.55f);
    assertTrue(p1.equals(p2));
}
 
Example 15
Source File: CategoryTickTest.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    Comparable c1 = "C1";
    Comparable 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);
    assertTrue(t1.equals(t2));

    t1 = new CategoryTick(c2, tb1, tba1, ta1, 1.0f);
    assertFalse(t1.equals(t2));
    t2 = new CategoryTick(c2, tb1, tba1, ta1, 1.0f);
    assertTrue(t1.equals(t2));

    t1 = new CategoryTick(c2, tb2, tba1, ta1, 1.0f);
    assertFalse(t1.equals(t2));
    t2 = new CategoryTick(c2, tb2, tba1, ta1, 1.0f);
    assertTrue(t1.equals(t2));

    t1 = new CategoryTick(c2, tb2, tba2, ta1, 1.0f);
    assertFalse(t1.equals(t2));
    t2 = new CategoryTick(c2, tb2, tba2, ta1, 1.0f);
    assertTrue(t1.equals(t2));

    t1 = new CategoryTick(c2, tb2, tba2, ta2, 1.0f);
    assertFalse(t1.equals(t2));
    t2 = new CategoryTick(c2, tb2, tba2, ta2, 1.0f);
    assertTrue(t1.equals(t2));

    t1 = new CategoryTick(c2, tb2, tba2, ta2, 2.0f);
    assertFalse(t1.equals(t2));
    t2 = new CategoryTick(c2, tb2, tba2, ta2, 2.0f);
    assertTrue(t1.equals(t2));

}
 
Example 16
Source File: DateTickTest.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    Date d1 = new Date(0L);
    Date d2 = new Date(1L);
    String l1 = "Label 1";
    String l2 = "Label 2";
    TextAnchor ta1 = TextAnchor.CENTER;
    TextAnchor ta2 = TextAnchor.BASELINE_LEFT;

    DateTick t1 = new DateTick(d1, l1, ta1, ta1, Math.PI / 2.0);
    DateTick t2 = new DateTick(d1, l1, ta1, ta1, Math.PI / 2.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(d2, l1, ta1, ta1, Math.PI / 2.0);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(d2, l1, ta1, ta1, Math.PI / 2.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(d1, l2, ta1, ta1, Math.PI / 2.0);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(d1, l2, ta1, ta1, Math.PI / 2.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(d1, l1, ta2, ta1, Math.PI / 2.0);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(d1, l1, ta2, ta1, Math.PI / 2.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(d1, l1, ta1, ta2, Math.PI / 2.0);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(d1, l1, ta1, ta2, Math.PI / 2.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(d1, l1, ta1, ta1, Math.PI / 3.0);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(d1, l1, ta1, ta1, Math.PI / 3.0);
    assertTrue(t1.equals(t2));

    t1 = new DateTick(TickType.MINOR, d1, l1, ta1, ta1, Math.PI);
    t2 = new DateTick(TickType.MAJOR, d1, l1, ta1, ta1, Math.PI);
    assertFalse(t1.equals(t2));
    t2 = new DateTick(TickType.MINOR, d1, l1, ta1, ta1, Math.PI);
    assertTrue(t1.equals(t2));
}