Package org.jfree.chart.plot

Examples of org.jfree.chart.plot.ThermometerPlot


  protected JFreeChart createThermometerChart() throws JRException
  {
    JRThermometerPlot jrPlot = (JRThermometerPlot)getPlot();

    // Create the plot that will hold the thermometer.
    ThermometerPlot chartPlot = new ThermometerPlot((ValueDataset)getDataset());

    Range range = convertRange(jrPlot.getDataRange());

    // Set the boundary of the thermomoter
    chartPlot.setLowerBound(range.getLowerBound());
    chartPlot.setUpperBound(range.getUpperBound());

    // Units can only be Fahrenheit, Celsius or none, so turn off for now.
    chartPlot.setUnits(ThermometerPlot.UNITS_NONE);

    // Set the color of the mercury.  Only used when the value is outside of
    // any defined ranges.
    Color color = jrPlot.getMercuryColor();
    if (color != null)
    {
      chartPlot.setMercuryPaint(color);
      chartPlot.setUseSubrangePaint(false);
    }

    // Set the formatting of the value display
    JRValueDisplay display = jrPlot.getValueDisplay();
    if (display != null)
    {
      if (display.getColor() != null)
      {
        chartPlot.setValuePaint(display.getColor());
      }
      if (display.getMask() != null)
      {
        chartPlot.setValueFormat(new DecimalFormat(display.getMask()));
      }
      if (display.getFont() != null)
      {
        chartPlot.setValueFont(JRFontUtil.getAwtFont(display.getFont(), getLocale()));
      }
    }

    // Set the location of where the value is displayed
    switch (jrPlot.getValueLocationValue())
    {
      case NONE:
       chartPlot.setValueLocation(ThermometerPlot.NONE);
       break;
      case LEFT:
       chartPlot.setValueLocation(ThermometerPlot.LEFT);
       break;
      case RIGHT:
       chartPlot.setValueLocation(ThermometerPlot.RIGHT);
       break;
      case BULB:
      default:
       chartPlot.setValueLocation(ThermometerPlot.BULB);
       break;
    }

    // Define the three ranges
    range = convertRange(jrPlot.getLowRange());
    if (range != null)
    {
      chartPlot.setSubrangeInfo(2, range.getLowerBound(), range.getUpperBound());
    }

    range = convertRange(jrPlot.getMediumRange());
    if (range != null)
    {
      chartPlot.setSubrangeInfo(1, range.getLowerBound(), range.getUpperBound());
    }

    range = convertRange(jrPlot.getHighRange());
    if (range != null)
    {
      chartPlot.setSubrangeInfo(0, range.getLowerBound(), range.getUpperBound());
    }

    // Build a chart around this plot
    JFreeChart jfreeChart = new JFreeChart(chartPlot);
View Full Code Here


  protected JFreeChart createThermometerChart() throws JRException
  {
    JRThermometerPlot jrPlot = (JRThermometerPlot)getPlot();

    // Create the plot that will hold the thermometer.
    ThermometerPlot chartPlot = new ThermometerPlot((ValueDataset)getDataset());
    // Build a chart around this plot
    JFreeChart jfreeChart = new JFreeChart(chartPlot);

    // Set the generic options
    configureChart(jfreeChart, getPlot());
    jfreeChart.setBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT);
    jfreeChart.setBorderVisible(false);

    Range range = convertRange(jrPlot.getDataRange());

    if(range != null)
    {
      // Set the boundary of the thermomoter
      chartPlot.setLowerBound(range.getLowerBound());
      chartPlot.setUpperBound(range.getUpperBound());
    }
    chartPlot.setGap(0);

    // Units can only be Fahrenheit, Celsius or none, so turn off for now.
    chartPlot.setUnits(ThermometerPlot.UNITS_NONE);

    // Set the color of the mercury.  Only used when the value is outside of
    // any defined ranges.
    List seriesPaints = (List)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SERIES_COLORS);
   
    Paint paint = jrPlot.getMercuryColor();
    if(paint != null)
    {
      chartPlot.setUseSubrangePaint(false);
    }
    else
    {
      //it has no effect, but is kept for backward compatibility reasons
      paint = (Paint)seriesPaints.get(0);
    }
   
    chartPlot.setMercuryPaint(paint);

    chartPlot.setThermometerPaint(THERMOMETER_COLOR);
    chartPlot.setThermometerStroke(new BasicStroke(2f));
    chartPlot.setOutlineVisible(false);
    chartPlot.setValueFont(chartPlot.getValueFont().deriveFont(Font.BOLD));

    // Set the formatting of the value display
    JRValueDisplay display = jrPlot.getValueDisplay();
    if (display != null)
    {
      if (display.getColor() != null)
      {
        chartPlot.setValuePaint(display.getColor());
      }
      if (display.getMask() != null)
      {
        chartPlot.setValueFormat(new DecimalFormat(display.getMask()));
      }
      if (display.getFont() != null)
      {
//        chartPlot.setValueFont(JRFontUtil.getAwtFont(display.getFont()).deriveFont(Font.BOLD));
      }
    }

    // Set the location of where the value is displayed
    // Set the location of where the value is displayed
    ValueLocationEnum valueLocation = jrPlot.getValueLocationValue();
    switch (valueLocation)
    {
      case NONE:
       chartPlot.setValueLocation(ThermometerPlot.NONE);
       break;
      case LEFT:
       chartPlot.setValueLocation(ThermometerPlot.LEFT);
       break;
      case RIGHT:
       chartPlot.setValueLocation(ThermometerPlot.RIGHT);
       break;
      case BULB:
      default:
       chartPlot.setValueLocation(ThermometerPlot.BULB);
       break;
    }

    // Define the three ranges
    range = convertRange(jrPlot.getLowRange());
    if (range != null)
    {
      chartPlot.setSubrangeInfo(2, range.getLowerBound(), range.getUpperBound());
    }

    range = convertRange(jrPlot.getMediumRange());
    if (range != null)
    {
      chartPlot.setSubrangeInfo(1, range.getLowerBound(), range.getUpperBound());
    }

    range = convertRange(jrPlot.getHighRange());
    if (range != null)
    {
      chartPlot.setSubrangeInfo(0, range.getLowerBound(), range.getUpperBound());
    }

    return jfreeChart;
  }
View Full Code Here

  protected JFreeChart createThermometerChart() throws JRException
  {
    JRThermometerPlot jrPlot = (JRThermometerPlot)getPlot();

    // Create the plot that will hold the thermometer.
    ThermometerPlot chartPlot = new ThermometerPlot((ValueDataset)getDataset());

    Range range = convertRange(jrPlot.getDataRange());

    // Set the boundary of the thermomoter
    chartPlot.setLowerBound(range.getLowerBound());
    chartPlot.setUpperBound(range.getUpperBound());

    // Units can only be Fahrenheit, Celsius or none, so turn off for now.
    chartPlot.setUnits(ThermometerPlot.UNITS_NONE);

    // Set the color of the mercury.  Only used when the value is outside of
    // any defined ranges.
    Color color = jrPlot.getMercuryColor();
    if (color != null)
    {
      chartPlot.setMercuryPaint(color);
      chartPlot.setUseSubrangePaint(false);
    }

    // Set the formatting of the value display
    JRValueDisplay display = jrPlot.getValueDisplay();
    if (display != null)
    {
      if (display.getColor() != null)
      {
        chartPlot.setValuePaint(display.getColor());
      }
      if (display.getMask() != null)
      {
        chartPlot.setValueFormat(new DecimalFormat(display.getMask()));
      }
      if (display.getFont() != null)
      {
//        chartPlot.setValueFont(JRFontUtil.getAwtFont(display.getFont()));
      }
    }

    // Set the location of where the value is displayed
    ValueLocationEnum valueLocation = jrPlot.getValueLocationValue();
    switch (valueLocation)
    {
      case NONE:
       chartPlot.setValueLocation(ThermometerPlot.NONE);
       break;
      case LEFT:
       chartPlot.setValueLocation(ThermometerPlot.LEFT);
       break;
      case RIGHT:
       chartPlot.setValueLocation(ThermometerPlot.RIGHT);
       break;
      case BULB:
      default:
       chartPlot.setValueLocation(ThermometerPlot.BULB);
       break;
    }

    // Define the three ranges
    range = convertRange(jrPlot.getLowRange());
    if (range != null)
    {
      chartPlot.setSubrangeInfo(2, range.getLowerBound(), range.getUpperBound());
    }

    range = convertRange(jrPlot.getMediumRange());
    if (range != null)
    {
      chartPlot.setSubrangeInfo(1, range.getLowerBound(), range.getUpperBound());
    }

    range = convertRange(jrPlot.getHighRange());
    if (range != null)
    {
      chartPlot.setSubrangeInfo(0, range.getLowerBound(), range.getUpperBound());
    }

    // Build a chart around this plot
    JFreeChart jfreeChart = new JFreeChart(chartPlot);
View Full Code Here

  protected JFreeChart createThermometerChart() throws JRException
  {
    JRThermometerPlot jrPlot = (JRThermometerPlot)getPlot();

    // Create the plot that will hold the thermometer.
    ThermometerPlot chartPlot = new ThermometerPlot((ValueDataset)getDataset());

    Range range = convertRange(jrPlot.getDataRange());

    // Set the boundary of the thermomoter
    chartPlot.setLowerBound(range.getLowerBound());
    chartPlot.setUpperBound(range.getUpperBound());

    // Units can only be Fahrenheit, Celsius or none, so turn off for now.
    chartPlot.setUnits(ThermometerPlot.UNITS_NONE);

    // Set the color of the mercury.  Only used when the value is outside of
    // any defined ranges.
    Color color = jrPlot.getMercuryColor();
    if (color != null)
    {
      chartPlot.setMercuryPaint(color);
      chartPlot.setUseSubrangePaint(false);
    }

    // Set the formatting of the value display
    JRValueDisplay display = jrPlot.getValueDisplay();
    if (display != null)
    {
      if (display.getColor() != null)
      {
        chartPlot.setValuePaint(display.getColor());
      }
      if (display.getMask() != null)
      {
        chartPlot.setValueFormat(new DecimalFormat(display.getMask()));
      }
      if (display.getFont() != null)
      {
//        chartPlot.setValueFont(JRFontUtil.getAwtFont(display.getFont()));
      }
    }

    // Set the location of where the value is displayed
    ValueLocationEnum valueLocation = jrPlot.getValueLocationValue();
    switch (valueLocation)
    {
      case NONE:
       chartPlot.setValueLocation(ThermometerPlot.NONE);
       break;
      case LEFT:
       chartPlot.setValueLocation(ThermometerPlot.LEFT);
       break;
      case RIGHT:
       chartPlot.setValueLocation(ThermometerPlot.RIGHT);
       break;
      case BULB:
      default:
       chartPlot.setValueLocation(ThermometerPlot.BULB);
       break;
    }

    // Define the three ranges
    range = convertRange(jrPlot.getLowRange());
    if (range != null)
    {
      chartPlot.setSubrangeInfo(2, range.getLowerBound(), range.getUpperBound());
    }

    range = convertRange(jrPlot.getMediumRange());
    if (range != null)
    {
      chartPlot.setSubrangeInfo(1, range.getLowerBound(), range.getUpperBound());
    }

    range = convertRange(jrPlot.getHighRange());
    if (range != null)
    {
      chartPlot.setSubrangeInfo(0, range.getLowerBound(), range.getUpperBound());
    }

    // Build a chart around this plot
    JFreeChart jfreeChart = new JFreeChart(chartPlot);
View Full Code Here

  protected JFreeChart createThermometerChart() throws JRException
  {
    JRThermometerPlot jrPlot = (JRThermometerPlot)getPlot();

    // Create the plot that will hold the thermometer.
    ThermometerPlot chartPlot = new ThermometerPlot((ValueDataset)getDataset());
    // Build a chart around this plot
    JFreeChart jfreeChart = new JFreeChart(chartPlot);

    // Set the generic options
    configureChart(jfreeChart, getPlot());
    jfreeChart.setBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT);
    jfreeChart.setBorderVisible(false);

    Range range = convertRange(jrPlot.getDataRange());

    if(range != null)
    {
      // Set the boundary of the thermomoter
      chartPlot.setLowerBound(range.getLowerBound());
      chartPlot.setUpperBound(range.getUpperBound());
    }
    chartPlot.setGap(0);

    // Units can only be Fahrenheit, Celsius or none, so turn off for now.
    chartPlot.setUnits(ThermometerPlot.UNITS_NONE);

    // Set the color of the mercury.  Only used when the value is outside of
    // any defined ranges.
    Paint paint = jrPlot.getMercuryColor();
    if(paint != null)
    {
      chartPlot.setUseSubrangePaint(false);
    }
    else
    {
      //it has no effect, but is kept for backward compatibility reasons
      paint = (Paint)ChartThemesConstants.EYE_CANDY_SIXTIES_GRADIENT_PAINTS.get(0);
    }
   
    chartPlot.setMercuryPaint(paint);

    chartPlot.setThermometerPaint(THERMOMETER_COLOR);
    chartPlot.setThermometerStroke(new BasicStroke(2f));
    chartPlot.setOutlineVisible(false);
    chartPlot.setValueFont(chartPlot.getValueFont().deriveFont(Font.BOLD));



    // Set the formatting of the value display
    JRValueDisplay display = jrPlot.getValueDisplay();
    if (display != null)
    {
      if (display.getColor() != null)
      {
        chartPlot.setValuePaint(display.getColor());
      }
      if (display.getMask() != null)
      {
        chartPlot.setValueFormat(new DecimalFormat(display.getMask()));
      }
      if (display.getFont() != null)
      {
//        chartPlot.setValueFont(JRFontUtil.getAwtFont(display.getFont()).deriveFont(Font.BOLD));
      }
    }

    // Set the location of where the value is displayed
    ValueLocationEnum valueLocation = jrPlot.getValueLocationValue();
    switch (valueLocation)
    {
      case NONE:
       chartPlot.setValueLocation(ThermometerPlot.NONE);
       break;
      case LEFT:
       chartPlot.setValueLocation(ThermometerPlot.LEFT);
       break;
      case RIGHT:
       chartPlot.setValueLocation(ThermometerPlot.RIGHT);
       break;
      case BULB:
      default:
       chartPlot.setValueLocation(ThermometerPlot.BULB);
       break;
    }

    // Define the three ranges
    range = convertRange(jrPlot.getLowRange());
    if (range != null)
    {
      chartPlot.setSubrangeInfo(2, range.getLowerBound(), range.getUpperBound());
    }

    range = convertRange(jrPlot.getMediumRange());
    if (range != null)
    {
      chartPlot.setSubrangeInfo(1, range.getLowerBound(), range.getUpperBound());
    }

    range = convertRange(jrPlot.getHighRange());
    if (range != null)
    {
      chartPlot.setSubrangeInfo(0, range.getLowerBound(), range.getUpperBound());
    }

    return jfreeChart;

  }
View Full Code Here

  private JFreeChart createThermometerChart(ReportChart reportChart,
      ChartValue[] values, boolean displayInline)
  {
    DefaultValueDataset dataset = createDefaultValueDataset(values);

    ThermometerPlot plot = new ThermometerPlot(dataset);

    plot.setInsets(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setPadding(new RectangleInsets(10.0, 10.0, 10.0, 10.0));
    plot.setThermometerStroke(new BasicStroke(2.0f));
    plot.setThermometerPaint(Color.lightGray);
    plot.setUnits(ThermometerPlot.UNITS_FAHRENHEIT);

    JFreeChart chart = new JFreeChart(reportChart.getTitle(),
        JFreeChart.DEFAULT_TITLE_FONT, plot, reportChart.isShowLegend());

    return chart;
View Full Code Here

    /**
     * Some checks for the equals() method.
     */
    public void testEquals() {
        ThermometerPlot p1 = new ThermometerPlot();
        ThermometerPlot p2 = new ThermometerPlot();
        assertTrue(p1.equals(p2));
        assertTrue(p2.equals(p1));

        // padding
        p1.setPadding(new RectangleInsets(1.0, 2.0, 3.0, 4.0));
        assertFalse(p1.equals(p2));
        p2.setPadding(new RectangleInsets(1.0, 2.0, 3.0, 4.0));
        assertTrue(p2.equals(p1));

        // thermometerStroke
        BasicStroke s = new BasicStroke(1.23f);
        p1.setThermometerStroke(s);
        assertFalse(p1.equals(p2));
        p2.setThermometerStroke(s);
        assertTrue(p2.equals(p1));

        // thermometerPaint
        p1.setThermometerPaint(new GradientPaint(1.0f, 2.0f, Color.blue,
                3.0f, 4.0f, Color.red));
        assertFalse(p1.equals(p2));
        p2.setThermometerPaint(new GradientPaint(1.0f, 2.0f, Color.blue,
                3.0f, 4.0f, Color.red));
        assertTrue(p2.equals(p1));

        // units
        p1.setUnits(ThermometerPlot.UNITS_KELVIN);
        assertFalse(p1.equals(p2));
        p2.setUnits(ThermometerPlot.UNITS_KELVIN);
        assertTrue(p2.equals(p1));

        // valueLocation
        p1.setValueLocation(ThermometerPlot.LEFT);
        assertFalse(p1.equals(p2));
        p2.setValueLocation(ThermometerPlot.LEFT);
        assertTrue(p2.equals(p1));

        // axisLocation
        p1.setAxisLocation(ThermometerPlot.RIGHT);
        assertFalse(p1.equals(p2));
        p2.setAxisLocation(ThermometerPlot.RIGHT);
        assertTrue(p2.equals(p1));

        // valueFont
        p1.setValueFont(new Font("Serif", Font.PLAIN, 9));
        assertFalse(p1.equals(p2));
        p2.setValueFont(new Font("Serif", Font.PLAIN, 9));
        assertTrue(p2.equals(p1));

        // valuePaint
        p1.setValuePaint(new GradientPaint(4.0f, 5.0f, Color.red,
                6.0f, 7.0f, Color.white));
        assertFalse(p1.equals(p2));
        p2.setValuePaint(new GradientPaint(4.0f, 5.0f, Color.red,
                6.0f, 7.0f, Color.white));
        assertTrue(p2.equals(p1));

        // valueFormat
        p1.setValueFormat(new DecimalFormat("0.0000"));
        assertFalse(p1.equals(p2));
        p2.setValueFormat(new DecimalFormat("0.0000"));
        assertTrue(p2.equals(p1));

        // mercuryPaint
        p1.setMercuryPaint(new GradientPaint(9.0f, 8.0f, Color.red,
                7.0f, 6.0f, Color.blue));
        assertFalse(p1.equals(p2));
        p2.setMercuryPaint(new GradientPaint(9.0f, 8.0f, Color.red,
                7.0f, 6.0f, Color.blue));
        assertTrue(p2.equals(p1));

        // showValueLines
        p1.setShowValueLines(true);
        assertFalse(p1.equals(p2));
        p2.setShowValueLines(true);
        assertTrue(p2.equals(p1));

        p1.setSubrange(1, 1.0, 2.0);
        assertFalse(p1.equals(p2));
        p2.setSubrange(1, 1.0, 2.0);
        assertTrue(p2.equals(p1));

        p1.setSubrangePaint(1, new GradientPaint(1.0f, 2.0f, Color.red,
                3.0f, 4.0f, Color.yellow));
        assertFalse(p1.equals(p2));
        p2.setSubrangePaint(1, new GradientPaint(1.0f, 2.0f, Color.red,
                3.0f, 4.0f, Color.yellow));
        assertTrue(p2.equals(p1));

        p1.setBulbRadius(9);
        assertFalse(p1.equals(p2));
        p2.setBulbRadius(9);
        assertTrue(p2.equals(p1));

        p1.setColumnRadius(8);
        assertFalse(p1.equals(p2));
        p2.setColumnRadius(8);
        assertTrue(p2.equals(p1));

        p1.setGap(7);
        assertFalse(p1.equals(p2));
        p2.setGap(7);
        assertTrue(p2.equals(p1));
    }
View Full Code Here

    /**
     * Confirm that cloning works.
     */
    public void testCloning() {
        ThermometerPlot p1 = new ThermometerPlot();
        ThermometerPlot p2 = null;
        try {
            p2 = (ThermometerPlot) p1.clone();
        }
        catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        assertTrue(p1 != p2);
        assertTrue(p1.getClass() == p2.getClass());
        assertTrue(p1.equals(p2));
    }
View Full Code Here

    /**
     * Serialize an instance, restore it, and check for equality.
     */
    public void testSerialization() {

        ThermometerPlot p1 = new ThermometerPlot();
        ThermometerPlot p2 = null;

        try {
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
            ObjectOutput out = new ObjectOutputStream(buffer);
            out.writeObject(p1);
View Full Code Here

    /**
     * Serialize an instance, restore it, and check for equality.
     */
    public void testSerialization2() {
        ThermometerPlot p1 = new ThermometerPlot();
        p1.setSubrangePaint(1, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f,
                4.0f, Color.blue));
        ThermometerPlot p2 = null;

        try {
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
            ObjectOutput out = new ObjectOutputStream(buffer);
            out.writeObject(p1);
View Full Code Here

TOP

Related Classes of org.jfree.chart.plot.ThermometerPlot

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.