Java Code Examples for org.jfree.chart.renderer.category.BarRenderer#setMaximumBarWidth()

The following examples show how to use org.jfree.chart.renderer.category.BarRenderer#setMaximumBarWidth() . 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
/**
 * Returns a bar renderer.
 */
private BarRenderer getBarRenderer()
{
    BarRenderer renderer = new BarRenderer();

    renderer.setMaximumBarWidth( 0.07 );

    for ( int i = 0; i < COLORS.length; i++ )
    {
        renderer.setSeriesPaint( i, COLORS[i] );
        renderer.setShadowVisible( false );
    }

    return renderer;
}
 
Example 2
Source File: ChartImageGenerator.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Returns a bar renderer.
 */
private BarRenderer getBarRenderer()
{
    BarRenderer renderer = new BarRenderer();

    renderer.setMaximumBarWidth( 0.07 );

    for ( int i = 0; i < COLORS.length; i++ )
    {
        renderer.setSeriesPaint( i, COLORS[i] );
        renderer.setShadowVisible( false );
    }

    return renderer;
}
 
Example 3
Source File: ChartWriterFactory.java    From entity-system-benchmarks with Apache License 2.0 5 votes vote down vote up
private static void notSoUglyPlease(JFreeChart chart) {
	String fontName = "Lucida Sans";

	StandardChartTheme theme = (StandardChartTheme)org.jfree.chart.StandardChartTheme.createJFreeTheme();

	theme.setTitlePaint( Color.decode("#4572a7") );
	theme.setExtraLargeFont(new Font(fontName, Font.BOLD, 14)); //title
	theme.setLargeFont(new Font(fontName, Font.BOLD, 15)); //axis-title
	theme.setRegularFont(new Font(fontName, Font.PLAIN, 11));
	theme.setRangeGridlinePaint(Color.decode("#C0C0C0"));
	theme.setPlotBackgroundPaint(Color.white);
	theme.setChartBackgroundPaint(Color.white);
	theme.setGridBandPaint(Color.red);
	theme.setAxisOffset(new RectangleInsets(0, 0, 0, 0));
	theme.setBarPainter(new StandardBarPainter());
	theme.setAxisLabelPaint(Color.decode("#666666"));
	theme.apply(chart);
	chart.getCategoryPlot().setOutlineVisible(false);
	chart.getCategoryPlot().getRangeAxis().setAxisLineVisible(false);
	chart.getCategoryPlot().getRangeAxis().setTickMarksVisible(false);
	chart.getCategoryPlot().setRangeGridlineStroke(new BasicStroke());
	chart.getCategoryPlot().getRangeAxis().setTickLabelPaint(Color.decode("#666666"));
	chart.getCategoryPlot().getDomainAxis().setTickLabelPaint(Color.decode("#666666"));
	chart.setTextAntiAlias(true);
	chart.setAntiAlias(true);
	BarRenderer rend = (BarRenderer) chart.getCategoryPlot().getRenderer();
	rend.setShadowVisible(true);
	rend.setShadowXOffset(2);
	rend.setShadowYOffset(0);
	rend.setShadowPaint(Color.decode("#C0C0C0"));
	rend.setMaximumBarWidth(0.1);
}
 
Example 4
Source File: BarChartExpression.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected void configureChart( final JFreeChart chart ) {
  final CategoryPlot cpl = chart.getCategoryPlot();
  final CategoryItemRenderer renderer = cpl.getRenderer();
  final BarRenderer br = (BarRenderer) renderer;
  if ( isAutoRange() ) {
    br.setIncludeBaseInRange( false );
  }
  super.configureChart( chart );
  br.setDrawBarOutline( isChartSectionOutline() );
  if ( maxBarWidth != null ) {
    br.setMaximumBarWidth( maxBarWidth.doubleValue() );
  }

  if ( itemMargin != null ) {
    br.setItemMargin( itemMargin.doubleValue() );
  }

  if ( ( isStacked() ) && stackedBarRenderPercentages && ( br instanceof StackedBarRenderer ) ) {
    final StackedBarRenderer sbr = (StackedBarRenderer) br;
    sbr.setRenderAsPercentages( true );
  }

  br.setShadowVisible( shadowVisible );
  if ( shadowColor != null ) {
    br.setShadowPaint( shadowColor );
  }
  br.setShadowXOffset( shadowXOffset );
  br.setShadowYOffset( shadowYOffset );
}
 
Example 5
Source File: BarRendererTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Test that the equals() method distinguishes all fields.
 */
public void testEquals() {
    BarRenderer r1 = new BarRenderer();
    BarRenderer r2 = new BarRenderer();
    assertTrue(r1.equals(r2));
    assertTrue(r2.equals(r1));

    // base value
    r1.setBase(0.123);
    assertFalse(r1.equals(r2));
    r2.setBase(0.123);
    assertTrue(r1.equals(r2));

    // itemMargin
    r1.setItemMargin(0.22);
    assertFalse(r1.equals(r2));
    r2.setItemMargin(0.22);
    assertTrue(r1.equals(r2));

    // drawBarOutline
    r1.setDrawBarOutline(!r1.isDrawBarOutline());
    assertFalse(r1.equals(r2));
    r2.setDrawBarOutline(!r2.isDrawBarOutline());
    assertTrue(r1.equals(r2));

    // maximumBarWidth
    r1.setMaximumBarWidth(0.11);
    assertFalse(r1.equals(r2));
    r2.setMaximumBarWidth(0.11);
    assertTrue(r1.equals(r2));

    // minimumBarLength
    r1.setMinimumBarLength(0.04);
    assertFalse(r1.equals(r2));
    r2.setMinimumBarLength(0.04);
    assertTrue(r1.equals(r2));

    // gradientPaintTransformer
    r1.setGradientPaintTransformer(new StandardGradientPaintTransformer(
            GradientPaintTransformType.CENTER_VERTICAL));
    assertFalse(r1.equals(r2));
    r2.setGradientPaintTransformer(new StandardGradientPaintTransformer(
            GradientPaintTransformType.CENTER_VERTICAL));
    assertTrue(r1.equals(r2));

    // positiveItemLabelPositionFallback
    r1.setPositiveItemLabelPositionFallback(new ItemLabelPosition(
            ItemLabelAnchor.INSIDE1, TextAnchor.CENTER));
    assertFalse(r1.equals(r2));
    r2.setPositiveItemLabelPositionFallback(new ItemLabelPosition(
            ItemLabelAnchor.INSIDE1, TextAnchor.CENTER));
    assertTrue(r1.equals(r2));

    // negativeItemLabelPositionFallback
    r1.setNegativeItemLabelPositionFallback(new ItemLabelPosition(
            ItemLabelAnchor.INSIDE1, TextAnchor.CENTER));
    assertFalse(r1.equals(r2));
    r2.setNegativeItemLabelPositionFallback(new ItemLabelPosition(
            ItemLabelAnchor.INSIDE1, TextAnchor.CENTER));
    assertTrue(r1.equals(r2));

    // barPainter
    r1.setBarPainter(new GradientBarPainter(0.1, 0.2, 0.3));
    assertFalse(r1.equals(r2));
    r2.setBarPainter(new GradientBarPainter(0.1, 0.2, 0.3));
    assertTrue(r1.equals(r2));

    // shadowsVisible
    r1.setShadowVisible(false);
    assertFalse(r1.equals(r2));
    r2.setShadowVisible(false);
    assertTrue(r1.equals(r2));

    r1.setShadowPaint(Color.red);
    assertFalse(r1.equals(r2));
    r2.setShadowPaint(Color.red);
    assertTrue(r1.equals(r2));

    // shadowXOffset
    r1.setShadowXOffset(3.3);
    assertFalse(r1.equals(r2));
    r2.setShadowXOffset(3.3);
    assertTrue(r1.equals(r2));

    // shadowYOffset
    r1.setShadowYOffset(3.3);
    assertFalse(r1.equals(r2));
    r2.setShadowYOffset(3.3);
    assertTrue(r1.equals(r2));

}
 
Example 6
Source File: BarRendererTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Test that the equals() method distinguishes all fields.
 */
public void testEquals() {
    BarRenderer r1 = new BarRenderer();
    BarRenderer r2 = new BarRenderer();
    assertTrue(r1.equals(r2));
    assertTrue(r2.equals(r1));
    
    // base value
    r1.setBase(0.123);
    assertFalse(r1.equals(r2));
    r2.setBase(0.123);
    assertTrue(r1.equals(r2));
    
    // itemMargin
    r1.setItemMargin(0.22);
    assertFalse(r1.equals(r2));
    r2.setItemMargin(0.22);
    assertTrue(r1.equals(r2));
    
    // drawBarOutline
    r1.setDrawBarOutline(!r1.isDrawBarOutline());
    assertFalse(r1.equals(r2));
    r2.setDrawBarOutline(!r2.isDrawBarOutline());
    assertTrue(r1.equals(r2));
    
    // maximumBarWidth
    r1.setMaximumBarWidth(0.11);
    assertFalse(r1.equals(r2));
    r2.setMaximumBarWidth(0.11);
    assertTrue(r1.equals(r2));
    
    // minimumBarLength
    r1.setMinimumBarLength(0.04);
    assertFalse(r1.equals(r2));
    r2.setMinimumBarLength(0.04);
    assertTrue(r1.equals(r2));
    
    // gradientPaintTransformer
    r1.setGradientPaintTransformer(new StandardGradientPaintTransformer(
            GradientPaintTransformType.CENTER_VERTICAL));
    assertFalse(r1.equals(r2));
    r2.setGradientPaintTransformer(new StandardGradientPaintTransformer(
            GradientPaintTransformType.CENTER_VERTICAL));
    assertTrue(r1.equals(r2));
    
    // positiveItemLabelPositionFallback
    r1.setPositiveItemLabelPositionFallback(new ItemLabelPosition(
            ItemLabelAnchor.INSIDE1, TextAnchor.CENTER));
    assertFalse(r1.equals(r2));
    r2.setPositiveItemLabelPositionFallback(new ItemLabelPosition(
            ItemLabelAnchor.INSIDE1, TextAnchor.CENTER));
    assertTrue(r1.equals(r2));

    // negativeItemLabelPositionFallback
    r1.setNegativeItemLabelPositionFallback(new ItemLabelPosition(
            ItemLabelAnchor.INSIDE1, TextAnchor.CENTER));
    assertFalse(r1.equals(r2));
    r2.setNegativeItemLabelPositionFallback(new ItemLabelPosition(
            ItemLabelAnchor.INSIDE1, TextAnchor.CENTER));
    assertTrue(r1.equals(r2));

}