1 42 43 package org.jfree.chart.annotations.junit; 44 45 import java.awt.Color ; 46 import java.awt.Font ; 47 48 import junit.framework.Test; 49 import junit.framework.TestCase; 50 import junit.framework.TestSuite; 51 52 import org.jfree.chart.annotations.CategoryTextAnnotation; 53 import org.jfree.chart.annotations.TextAnnotation; 54 import org.jfree.ui.TextAnchor; 55 56 59 public class TextAnnotationTests extends TestCase { 60 61 66 public static Test suite() { 67 return new TestSuite(TextAnnotationTests.class); 68 } 69 70 75 public TextAnnotationTests(String name) { 76 super(name); 77 } 78 79 82 public void testEquals() { 83 84 TextAnnotation a1 = new CategoryTextAnnotation("Test", "Category", 1.0); 85 TextAnnotation a2 = new CategoryTextAnnotation("Test", "Category", 1.0); 86 assertTrue(a1.equals(a2)); 87 88 a1.setText("Text"); 90 assertFalse(a1.equals(a2)); 91 a2.setText("Text"); 92 assertTrue(a1.equals(a2)); 93 94 a1.setFont(new Font ("Serif", Font.BOLD, 18)); 96 assertFalse(a1.equals(a2)); 97 a2.setFont(new Font ("Serif", Font.BOLD, 18)); 98 assertTrue(a1.equals(a2)); 99 100 a1.setPaint(Color.red); 102 assertFalse(a1.equals(a2)); 103 a2.setPaint(Color.red); 104 assertTrue(a1.equals(a2)); 105 106 a1.setTextAnchor(TextAnchor.BOTTOM_LEFT); 108 assertFalse(a1.equals(a2)); 109 a2.setTextAnchor(TextAnchor.BOTTOM_LEFT); 110 assertTrue(a1.equals(a2)); 111 112 a1.setRotationAnchor(TextAnchor.BOTTOM_LEFT); 114 assertFalse(a1.equals(a2)); 115 a2.setRotationAnchor(TextAnchor.BOTTOM_LEFT); 116 assertTrue(a1.equals(a2)); 117 118 a1.setRotationAngle(Math.PI); 120 assertFalse(a1.equals(a2)); 121 a2.setRotationAngle(Math.PI); 122 assertTrue(a1.equals(a2)); 123 124 } 125 126 129 public void testHashCode() { 130 TextAnnotation a1 = new CategoryTextAnnotation("Test", "Category", 1.0); 131 TextAnnotation a2 = new CategoryTextAnnotation("Test", "Category", 1.0); 132 assertTrue(a1.equals(a2)); 133 int h1 = a1.hashCode(); 134 int h2 = a2.hashCode(); 135 assertEquals(h1, h2); 136 } 137 138 } 139 | Popular Tags |