MeterChartTest.java 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* ===========================================================
  2. * JFreeChart : a free chart library for the Java(tm) platform
  3. * ===========================================================
  4. *
  5. * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
  6. *
  7. * Project Info: http://www.jfree.org/jfreechart/index.html
  8. *
  9. * This library is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU Lesser General Public License as published by
  11. * the Free Software Foundation; either version 2.1 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This library is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  16. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  17. * License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
  22. * USA.
  23. *
  24. * [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
  25. * Other names may be trademarks of their respective owners.]
  26. *
  27. * -------------------
  28. * MeterChartTest.java
  29. * -------------------
  30. * (C) Copyright 2005-2013, by Object Refinery Limited.
  31. *
  32. * Original Author: David Gilbert (for Object Refinery Limited);
  33. * Contributor(s): -;
  34. *
  35. * Changes:
  36. * --------
  37. * 29-Mar-2005 : Version 1 (DG);
  38. *
  39. */
  40. package org.jfree.chart;
  41. import java.awt.Graphics2D;
  42. import java.awt.geom.Rectangle2D;
  43. import java.awt.image.BufferedImage;
  44. import org.jfree.chart.plot.MeterInterval;
  45. import org.jfree.chart.plot.MeterPlot;
  46. import org.jfree.data.Range;
  47. import org.jfree.data.general.DefaultValueDataset;
  48. import org.junit.Test;
  49. /**
  50. * Miscellaneous checks for meter charts.
  51. */
  52. public class MeterChartTest {
  53. /**
  54. * Draws the chart with a single range. At one point, this caused a null
  55. * pointer exception (fixed now).
  56. */
  57. @Test
  58. public void testDrawWithNullInfo() {
  59. MeterPlot plot = new MeterPlot(new DefaultValueDataset(60.0));
  60. plot.addInterval(new MeterInterval("Normal", new Range(0.0, 80.0)));
  61. JFreeChart chart = new JFreeChart(plot);
  62. BufferedImage image = new BufferedImage(200, 100,
  63. BufferedImage.TYPE_INT_RGB);
  64. Graphics2D g2 = image.createGraphics();
  65. chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
  66. g2.dispose();
  67. //FIXME we should really assert a value here
  68. }
  69. }