Example usage for org.jfree.chart.plot ThermometerPlot getClass

List of usage examples for org.jfree.chart.plot ThermometerPlot getClass

Introduction

In this page you can find the example usage for org.jfree.chart.plot ThermometerPlot getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:net.sf.dynamicreports.test.jasper.chart.ThermometerChartTest.java

@Override
public void test() {
    super.test();

    numberOfPagesTest(1);/*from   www .  java  2  s.  com*/

    JFreeChart chart = getChart("summary.chart1", 0);
    Plot plot = chart.getPlot();
    Assert.assertEquals("renderer", ThermometerPlot.class, plot.getClass());
    ThermometerPlot thermometerPlot = (ThermometerPlot) plot;
    Assert.assertEquals("value", 15, thermometerPlot.getDataset().getValue());
    Assert.assertEquals("data range low", 3d, thermometerPlot.getLowerBound());
    Assert.assertEquals("data range high", 30d, thermometerPlot.getUpperBound());
    Assert.assertEquals("value color", Color.BLUE, thermometerPlot.getValuePaint());
    try {
        Field field = thermometerPlot.getClass().getDeclaredField("valueFormat");
        field.setAccessible(true);
        Assert.assertEquals("value mask", "15.0", ((NumberFormat) field.get(thermometerPlot)).format(15));
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail(e.getMessage());
    }
    Assert.assertEquals("value font", new Font("Arial", Font.PLAIN, 10), thermometerPlot.getValueFont());
    Assert.assertEquals("value location", ThermometerPlot.BULB, thermometerPlot.getValueLocation());
    Assert.assertEquals("mercury color", Color.LIGHT_GRAY, thermometerPlot.getMercuryPaint());
    try {
        Field field = thermometerPlot.getClass().getDeclaredField("subrangeInfo");
        field.setAccessible(true);
        double[][] subrangeInfo = (double[][]) field.get(thermometerPlot);
        Assert.assertEquals("low data range low", 8d, subrangeInfo[2][0]);
        Assert.assertEquals("low data range high", 10d, subrangeInfo[2][1]);
        Assert.assertEquals("medium data range low", 18d, subrangeInfo[1][0]);
        Assert.assertEquals("medium data range high", 20d, subrangeInfo[1][1]);
        Assert.assertEquals("high data range low", 28d, subrangeInfo[0][0]);
        Assert.assertEquals("high data range high", 30d, subrangeInfo[0][1]);
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail(e.getMessage());
    }
}