Java Code Examples for org.jfree.text.TextBlockAnchor#CENTER

The following examples show how to use org.jfree.text.TextBlockAnchor#CENTER . 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: CategoryTickTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Two objects that are equal are required to return the same hashCode.
 */
@Test
public void testHashCode() {
    Comparable c1 = "C1";
    TextBlock tb1 = new TextBlock();
    tb1.addLine(new TextLine("Block 1"));
    tb1.addLine(new TextLine("Block 2"));
    TextBlockAnchor tba1 = TextBlockAnchor.CENTER;
    TextAnchor ta1 = TextAnchor.CENTER;

    CategoryTick t1 = new CategoryTick(c1, tb1, tba1, ta1, 1.0f);
    CategoryTick t2 = new CategoryTick(c1, tb1, tba1, ta1, 1.0f);
    assertTrue(t1.equals(t2));
    int h1 = t1.hashCode();
    int h2 = t2.hashCode();
    assertEquals(h1, h2);
}
 
Example 2
Source File: CategoryLabelPositionsTest.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Two objects that are equal are required to return the same hashCode.
 */
@Test
public void testHashCode() {
    CategoryLabelPositions p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    CategoryLabelPositions p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(p1.equals(p2));
    int h1 = p1.hashCode();
    int h2 = p2.hashCode();
    assertEquals(h1, h2);
}
 
Example 3
Source File: CategoryLabelPositionsTest.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Two objects that are equal are required to return the same hashCode.
 */
@Test
public void testHashCode() {
    CategoryLabelPositions p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    CategoryLabelPositions p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(p1.equals(p2));
    int h1 = p1.hashCode();
    int h2 = p2.hashCode();
    assertEquals(h1, h2);
}
 
Example 4
Source File: LabelBlock.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new label block.
 *
 * @param text  the text for the label (<code>null</code> not permitted).
 * @param font  the font (<code>null</code> not permitted).
 * @param paint the paint (<code>null</code> not permitted).
 */
public LabelBlock(String text, Font font, Paint paint) {
    this.text = text;
    this.paint = paint;
    this.label = TextUtilities.createTextBlock(text, font, this.paint);
    this.font = font;
    this.toolTipText = null;
    this.urlText = null;
    this.contentAlignmentPoint = TextBlockAnchor.CENTER;
    this.textAnchor = RectangleAnchor.CENTER;
}
 
Example 5
Source File: LabelBlock.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new label block.
 *
 * @param text  the text for the label (<code>null</code> not permitted).
 * @param font  the font (<code>null</code> not permitted).
 * @param paint the paint (<code>null</code> not permitted).
 */
public LabelBlock(String text, Font font, Paint paint) {
    this.text = text;
    this.paint = paint;
    this.label = TextUtilities.createTextBlock(text, font, this.paint);
    this.font = font;
    this.toolTipText = null;
    this.urlText = null;
    this.contentAlignmentPoint = TextBlockAnchor.CENTER;
    this.textAnchor = RectangleAnchor.CENTER;
}
 
Example 6
Source File: CategoryTickTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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();
    assertTrue(t1 != t2);
    assertTrue(t1.getClass() == t2.getClass());
    assertTrue(t1.equals(t2));
}
 
Example 7
Source File: CategoryTickTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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();
    assertTrue(t1 != t2);
    assertTrue(t1.getClass() == t2.getClass());
    assertTrue(t1.equals(t2));
}
 
Example 8
Source File: CategoryTickTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * 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();
    assertTrue(t1 != t2);
    assertTrue(t1.getClass() == t2.getClass());
    assertTrue(t1.equals(t2));
}
 
Example 9
Source File: CategoryTickTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 = (CategoryTick) TestUtilities.serialised(t1);
    assertEquals(t1, t2);
}
 
Example 10
Source File: LabelBlock.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new label block.
 *
 * @param text  the text for the label (<code>null</code> not permitted).
 * @param font  the font (<code>null</code> not permitted).
 * @param paint the paint (<code>null</code> not permitted).
 */
public LabelBlock(String text, Font font, Paint paint) {
    this.text = text;
    this.paint = paint;
    this.label = TextUtilities.createTextBlock(text, font, this.paint);
    this.font = font;
    this.toolTipText = null;
    this.urlText = null;
    this.contentAlignmentPoint = TextBlockAnchor.CENTER;
    this.textAnchor = RectangleAnchor.CENTER;
}
 
Example 11
Source File: CategoryTickTest.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 = (CategoryTick) TestUtilities.serialised(t1);
    assertEquals(t1, t2);
}
 
Example 12
Source File: CategoryTickTest.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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();
    assertTrue(t1 != t2);
    assertTrue(t1.getClass() == t2.getClass());
    assertTrue(t1.equals(t2));
}
 
Example 13
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 14
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 15
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 16
Source File: CategoryLabelPositionsTest.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Check that the equals method distinguishes all fields.
 */
@Test
public void testEquals() {
    CategoryLabelPositions p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    CategoryLabelPositions p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertEquals(p1, p2);

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER));
    assertTrue(p1.equals(p2));
}
 
Example 17
Source File: CategoryLabelPositionsTest.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Check that the equals method distinguishes all fields.
 */
@Test
public void testEquals() {
    CategoryLabelPositions p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    CategoryLabelPositions p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertEquals(p1, p2);

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER));
    assertTrue(p1.equals(p2));

    p1 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER));
    assertTrue(!p1.equals(p2));
    p2 = new CategoryLabelPositions(
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER),
            new CategoryLabelPosition(RA_BOTTOM,
                    TextBlockAnchor.TOP_CENTER));
    assertTrue(p1.equals(p2));
}
 
Example 18
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 19
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 20
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));

}