Java Code Examples for org.jfree.chart.plot.ThermometerPlot#setGap()

The following examples show how to use org.jfree.chart.plot.ThermometerPlot#setGap() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Thermometer.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Creates a chart of type thermometer.
 * 
 * @param chartTitle  the chart title.
 * @param dataset  the dataset.
 * 
 * @return A chart thermometer.
 */


public JFreeChart createChart(DatasetMap datasets) {
	logger.debug("IN");
	Dataset dataset=(Dataset)datasets.getDatasets().get("1");

	ThermometerPlot plot = new ThermometerPlot((ValueDataset)dataset);
	JFreeChart chart = new JFreeChart(name, JFreeChart.DEFAULT_TITLE_FONT,	plot, true);               
	chart.setBackgroundPaint(color);

	TextTitle title = setStyleTitle(name, styleTitle);
	chart.setTitle(title);
	if(subName!= null && !subName.equals("")){
		TextTitle subTitle =setStyleTitle(subName, styleSubTitle);
		chart.addSubtitle(subTitle);
	}

	
	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.setGap(3);
	plot.setValueLocation(3);
	plot.setValuePaint(labelsValueStyle.getColor());
	plot.setValueFont(new Font(labelsValueStyle.getFontName(), Font.PLAIN, labelsValueStyle.getSize()));

	plot.setRange(lower, upper);


	if(units.equalsIgnoreCase(FAHRENHEIT))plot.setUnits(ThermometerPlot.UNITS_FAHRENHEIT);	
	else if(units.equalsIgnoreCase(CELCIUS)) plot.setUnits(ThermometerPlot.UNITS_CELCIUS);	
	else if(units.equalsIgnoreCase(KELVIN)) plot.setUnits(ThermometerPlot.UNITS_KELVIN);	
	else plot.setUnits(ThermometerPlot.UNITS_NONE);


	// set subranges	
	for (Iterator iterator = intervals.iterator(); iterator.hasNext();){
		KpiInterval subrange = (KpiInterval) iterator.next();
		int range=0;
		if(subrange.getLabel().equalsIgnoreCase(NORMAL))range=(ThermometerPlot.NORMAL);
		else if(subrange.getLabel().equalsIgnoreCase(WARNING))range=(ThermometerPlot.WARNING);
		else if(subrange.getLabel().equalsIgnoreCase(CRITICAL))range=(ThermometerPlot.CRITICAL);

		plot.setSubrange(range, subrange.getMin(), subrange.getMax());
		if(subrange.getColor()!=null){
			plot.setSubrangePaint(range, subrange.getColor());
		}
		//plot.setDisplayRange(subrange.getRange(), subrange.getLower(), subrange.getUpper());	
	}
	//plot.setFollowDataInSubranges(true);
	logger.debug("OUT");

	return chart;       
}