1 43 44 package org.jfree.chart.plot.junit; 45 46 import java.awt.BasicStroke ; 47 import java.awt.Color ; 48 import java.awt.Font ; 49 import java.awt.GradientPaint ; 50 import java.awt.Paint ; 51 import java.awt.Rectangle ; 52 import java.awt.Shape ; 53 import java.awt.Stroke ; 54 55 import junit.framework.Test; 56 import junit.framework.TestCase; 57 import junit.framework.TestSuite; 58 59 import org.jfree.chart.JFreeChart; 60 import org.jfree.chart.plot.DefaultDrawingSupplier; 61 import org.jfree.chart.plot.PiePlot; 62 import org.jfree.chart.plot.Plot; 63 import org.jfree.ui.Align; 64 import org.jfree.ui.RectangleInsets; 65 66 69 public class PlotTests extends TestCase { 70 71 76 public static Test suite() { 77 return new TestSuite(PlotTests.class); 78 } 79 80 85 public PlotTests(String name) { 86 super(name); 87 } 88 89 93 public void testEquals() { 94 PiePlot plot1 = new PiePlot(); 95 PiePlot plot2 = new PiePlot(); 96 assertTrue(plot1.equals(plot2)); 97 assertTrue(plot2.equals(plot1)); 98 99 plot1.setNoDataMessage("No data XYZ"); 101 assertFalse(plot1.equals(plot2)); 102 plot2.setNoDataMessage("No data XYZ"); 103 assertTrue(plot1.equals(plot2)); 104 105 plot1.setNoDataMessageFont(new Font ("SansSerif", Font.PLAIN, 13)); 107 assertFalse(plot1.equals(plot2)); 108 plot2.setNoDataMessageFont(new Font ("SansSerif", Font.PLAIN, 13)); 109 assertTrue(plot1.equals(plot2)); 110 111 plot1.setNoDataMessagePaint(new GradientPaint (1.0f, 2.0f, Color.red, 113 3.0f, 4.0f, Color.blue)); 114 assertFalse(plot1.equals(plot2)); 115 plot2.setNoDataMessagePaint(new GradientPaint (1.0f, 2.0f, Color.red, 116 3.0f, 4.0f, Color.blue)); 117 assertTrue(plot1.equals(plot2)); 118 119 plot1.setInsets(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); 121 assertFalse(plot1.equals(plot2)); 122 plot2.setInsets(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); 123 assertTrue(plot1.equals(plot2)); 124 125 BasicStroke s = new BasicStroke (1.23f); 127 plot1.setOutlineStroke(s); 128 assertFalse(plot1.equals(plot2)); 129 plot2.setOutlineStroke(s); 130 assertTrue(plot1.equals(plot2)); 131 132 plot1.setOutlinePaint(new GradientPaint (1.0f, 2.0f, Color.yellow, 134 3.0f, 4.0f, Color.green)); 135 assertFalse(plot1.equals(plot2)); 136 plot2.setOutlinePaint(new GradientPaint (1.0f, 2.0f, Color.yellow, 137 3.0f, 4.0f, Color.green)); 138 assertTrue(plot1.equals(plot2)); 139 140 plot1.setBackgroundPaint(new GradientPaint (1.0f, 2.0f, Color.cyan, 142 3.0f, 4.0f, Color.green)); 143 assertFalse(plot1.equals(plot2)); 144 plot2.setBackgroundPaint(new GradientPaint (1.0f, 2.0f, Color.cyan, 145 3.0f, 4.0f, Color.green)); 146 assertTrue(plot1.equals(plot2)); 147 148 plot1.setBackgroundImage(JFreeChart.INFO.getLogo()); 150 assertFalse(plot1.equals(plot2)); 151 plot2.setBackgroundImage(JFreeChart.INFO.getLogo()); 152 assertTrue(plot1.equals(plot2)); 153 154 plot1.setBackgroundImageAlignment(Align.BOTTOM_RIGHT); 156 assertFalse(plot1.equals(plot2)); 157 plot2.setBackgroundImageAlignment(Align.BOTTOM_RIGHT); 158 assertTrue(plot1.equals(plot2)); 159 160 plot1.setBackgroundImageAlpha(0.77f); 162 assertFalse(plot1.equals(plot2)); 163 plot2.setBackgroundImageAlpha(0.77f); 164 assertTrue(plot1.equals(plot2)); 165 166 plot1.setForegroundAlpha(0.99f); 168 assertFalse(plot1.equals(plot2)); 169 plot2.setForegroundAlpha(0.99f); 170 assertTrue(plot1.equals(plot2)); 171 172 plot1.setBackgroundAlpha(0.99f); 174 assertFalse(plot1.equals(plot2)); 175 plot2.setBackgroundAlpha(0.99f); 176 assertTrue(plot1.equals(plot2)); 177 178 plot1.setDrawingSupplier(new DefaultDrawingSupplier( 180 new Paint [] {Color.blue}, new Paint [] {Color.red}, 181 new Stroke [] {new BasicStroke (1.1f)}, 182 new Stroke [] {new BasicStroke (9.9f)}, 183 new Shape [] {new Rectangle (1, 2, 3, 4)})); 184 assertFalse(plot1.equals(plot2)); 185 plot2.setDrawingSupplier(new DefaultDrawingSupplier( 186 new Paint [] {Color.blue}, new Paint [] {Color.red}, 187 new Stroke [] {new BasicStroke (1.1f)}, 188 new Stroke [] {new BasicStroke (9.9f)}, 189 new Shape [] {new Rectangle (1, 2, 3, 4)})); 190 assertTrue(plot1.equals(plot2)); 191 } 192 193 } 194 | Popular Tags |