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

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

Introduction

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

Prototype

public int getValueLocation() 

Source Link

Document

Returns a code indicating the location at which the value label is displayed.

Usage

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

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

    numberOfPagesTest(1);/*ww  w  .jav  a2  s  .c o m*/

    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());
    }
}