1 42 43 package org.jfree.chart.junit; 44 45 import java.awt.Graphics2D ; 46 import java.awt.geom.Rectangle2D ; 47 import java.awt.image.BufferedImage ; 48 49 import junit.framework.Test; 50 import junit.framework.TestCase; 51 import junit.framework.TestSuite; 52 53 import org.jfree.chart.JFreeChart; 54 import org.jfree.chart.plot.MeterInterval; 55 import org.jfree.chart.plot.MeterPlot; 56 import org.jfree.data.Range; 57 import org.jfree.data.general.DefaultValueDataset; 58 59 62 public class MeterChartTests extends TestCase { 63 64 69 public static Test suite() { 70 return new TestSuite(MeterChartTests.class); 71 } 72 73 78 public MeterChartTests(String name) { 79 super(name); 80 } 81 82 86 public void testDrawWithNullInfo() { 87 boolean success = false; 88 MeterPlot plot = new MeterPlot(new DefaultValueDataset(60.0)); 89 plot.addInterval(new MeterInterval("Normal", new Range(0.0, 80.0))); 90 JFreeChart chart = new JFreeChart(plot); 91 try { 92 BufferedImage image = new BufferedImage ( 93 200, 100, BufferedImage.TYPE_INT_RGB 94 ); 95 Graphics2D g2 = image.createGraphics(); 96 chart.draw( 97 g2, new Rectangle2D.Double (0, 0, 200, 100), null, null 98 ); 99 g2.dispose(); 100 success = true; 101 } 102 catch (Exception e) { 103 success = false; 104 } 105 assertTrue(success); 106 } 107 108 } 109 | Popular Tags |