org.jfree.chart.plot.DialShape Java Examples

The following examples show how to use org.jfree.chart.plot.DialShape. 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: DefaultChartService.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private JFreeChart getGaugeChart( BaseChart chart, ValueDataset dataSet )
{
    MeterPlot meterPlot = new MeterPlot( dataSet );

    meterPlot.setUnits( "" );
    meterPlot.setRange( new Range( 0.0d, 100d ) );

    for ( int i = 0; i < 10; i++ )
    {
        double start = i * 10d;
        double end = start + 10d;
        String label = String.valueOf( start );

        meterPlot.addInterval( new MeterInterval( label, new Range( start, end ), COLOR_LIGHT_GRAY, null, COLOR_LIGHT_GRAY ) );
    }

    meterPlot.setMeterAngle( 180 );
    meterPlot.setDialBackgroundPaint( COLOR_LIGHT_GRAY );
    meterPlot.setDialShape( DialShape.CHORD );
    meterPlot.setNeedlePaint( COLORS[0] );
    meterPlot.setTickLabelsVisible( true );
    meterPlot.setTickLabelFont( LABEL_FONT );
    meterPlot.setTickLabelPaint( Color.BLACK );
    meterPlot.setTickPaint( COLOR_LIGHTER_GRAY );
    meterPlot.setValueFont( TITLE_FONT );
    meterPlot.setValuePaint( Color.BLACK );

    JFreeChart meterChart = new JFreeChart( chart.getName(), meterPlot );
    setBasicConfig( meterChart, chart );
    meterChart.removeLegend();

    return meterChart;
}
 
Example #2
Source File: ChartImageGenerator.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private JFreeChart getGaugeChart( final Visualization visualization, ValueDataset dataSet )
{
    MeterPlot meterPlot = new MeterPlot( dataSet );

    meterPlot.setUnits( "" );
    meterPlot.setRange( new Range( 0.0d, 100d ) );

    for ( int i = 0; i < 10; i++ )
    {
        double start = i * 10d;
        double end = start + 10d;
        String label = String.valueOf( start );

        meterPlot.addInterval( new MeterInterval( label, new Range( start, end ), COLOR_LIGHT_GRAY, null, COLOR_LIGHT_GRAY ) );
    }

    meterPlot.setMeterAngle( 180 );
    meterPlot.setDialBackgroundPaint( COLOR_LIGHT_GRAY );
    meterPlot.setDialShape( DialShape.CHORD );
    meterPlot.setNeedlePaint( COLORS[0] );
    meterPlot.setTickLabelsVisible( true );
    meterPlot.setTickLabelFont( LABEL_FONT );
    meterPlot.setTickLabelPaint( Color.BLACK );
    meterPlot.setTickPaint( COLOR_LIGHTER_GRAY );
    meterPlot.setValueFont( TITLE_FONT );
    meterPlot.setValuePaint( Color.BLACK );

    JFreeChart meterChart = new JFreeChart( visualization.getName(), meterPlot );
    setBasicConfig( meterChart, visualization );
    meterChart.removeLegend();

    return meterChart;
}
 
Example #3
Source File: Meter.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Creates the chart .
 * 
 * @param chartTitle  the chart title.
 * @param dataset  the dataset.
 * 
 * @return A chart .
 */

public JFreeChart createChart(DatasetMap datasets) {

	Dataset dataset=(Dataset)datasets.getDatasets().get("1");

	MeterPlot plot = new MeterPlot((ValueDataset)dataset);
	plot.setRange(new Range(lower, upper));


	for (Iterator iterator = intervals.iterator(); iterator.hasNext();) {
		KpiInterval interval = (KpiInterval) iterator.next();

		plot.addInterval(new MeterInterval(interval.getLabel(), new Range(interval.getMin(), interval.getMax()), 
				Color.lightGray, new BasicStroke(2.0f), 
				interval.getColor()));
	}

	plot.setNeedlePaint(Color.darkGray);
	plot.setDialBackgroundPaint(Color.white);
	plot.setDialOutlinePaint(Color.gray);
	plot.setDialShape(DialShape.CHORD);
	plot.setMeterAngle(260);
	plot.setTickLabelsVisible(true);
	//set tick label style
	Font tickLabelsFont = new Font(labelsTickStyle.getFontName(), Font.PLAIN, labelsTickStyle.getSize());
	plot.setTickLabelFont(tickLabelsFont);
	plot.setTickLabelPaint(labelsTickStyle.getColor());
	plot.setTickSize(5.0);
	plot.setTickPaint(Color.lightGray);
	if(units!=null){
		plot.setUnits(units);
	}

	plot.setValuePaint(labelsValueStyle.getColor());
	plot.setValueFont(new Font(labelsValueStyle.getFontName(), Font.PLAIN, labelsValueStyle.getSize()));

	JFreeChart chart = new JFreeChart(name, 
			JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
	chart.setBackgroundPaint(color);
	
	TextTitle title = setStyleTitle(name, styleTitle);
	chart.setTitle(title);
	if(subName!= null && !subName.equals("")){
		TextTitle subTitle =setStyleTitle(subName, styleSubTitle);
		chart.addSubtitle(subTitle);
	}

	return chart;
}