Java Code Examples for org.jfree.chart.renderer.xy.XYBarRenderer#setShadowXOffset()

The following examples show how to use org.jfree.chart.renderer.xy.XYBarRenderer#setShadowXOffset() . 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: XYBarRendererTests.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() {

    // default instances
    XYBarRenderer r1 = new XYBarRenderer();
    XYBarRenderer r2 = new XYBarRenderer();
    assertTrue(r1.equals(r2));
    assertTrue(r2.equals(r1));

    // setBase()
    r1.setBase(1.0);
    assertFalse(r1.equals(r2));
    r2.setBase(1.0);
    assertTrue(r1.equals(r2));

    // setUseYInterval
    r1.setUseYInterval(!r1.getUseYInterval());
    assertFalse(r1.equals(r2));
    r2.setUseYInterval(!r2.getUseYInterval());
    assertTrue(r1.equals(r2));

    // setMargin()
    r1.setMargin(0.10);
    assertFalse(r1.equals(r2));
    r2.setMargin(0.10);
    assertTrue(r1.equals(r2));

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

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

    // legendBar
    r1.setLegendBar(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertFalse(r1.equals(r2));
    r2.setLegendBar(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
    assertTrue(r1.equals(r2));

    // positiveItemLabelFallbackPosition
    r1.setPositiveItemLabelPositionFallback(new ItemLabelPosition());
    assertFalse(r1.equals(r2));
    r2.setPositiveItemLabelPositionFallback(new ItemLabelPosition());
    assertTrue(r1.equals(r2));

    // negativeItemLabelFallbackPosition
    r1.setNegativeItemLabelPositionFallback(new ItemLabelPosition());
    assertFalse(r1.equals(r2));
    r2.setNegativeItemLabelPositionFallback(new ItemLabelPosition());
    assertTrue(r1.equals(r2));

    // barPainter
    r1.setBarPainter(new GradientXYBarPainter(0.11, 0.22, 0.33));
    assertFalse(r1.equals(r2));
    r2.setBarPainter(new GradientXYBarPainter(0.11, 0.22, 0.33));
    assertTrue(r1.equals(r2));

    // shadowsVisible
    r1.setShadowVisible(false);
    assertFalse(r1.equals(r2));
    r2.setShadowVisible(false);
    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 2
Source File: XYBarChartExpression.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected void configureChart( final JFreeChart chart ) {
  super.configureChart( chart );

  final XYPlot xypl = chart.getXYPlot();
  final XYItemRenderer renderer = xypl.getRenderer();
  final XYBarRenderer br = (XYBarRenderer) renderer;
  br.setDrawBarOutline( isChartSectionOutline() );
  if ( margin != null ) {
    br.setMargin( margin.doubleValue() );
  }

  br.setShadowVisible( shadowVisible );
  br.setShadowXOffset( shadowXOffset );
  br.setShadowYOffset( shadowYOffset );

  if ( ( isStacked() ) && renderPercentages && ( br instanceof StackedXYBarRenderer ) ) {
    final StackedXYBarRenderer sbr = (StackedXYBarRenderer) br;
    sbr.setRenderAsPercentages( true );

    final ValueAxis rangeAxis = xypl.getRangeAxis();
    final int level = getRuntime().getProcessingContext().getCompatibilityLevel();
    if ( ClassicEngineBoot.isEnforceCompatibilityFor( level, 3, 8 ) ) {
      if ( getRangeMinimum() != 0 ) {
        rangeAxis.setLowerBound( getRangeMinimum() );
      }
      if ( getRangeMaximum() != 1 ) {
        rangeAxis.setUpperBound( getRangeMaximum() );
      }
      if ( getRangeMinimum() == 0 && getRangeMaximum() == 0 ) {
        rangeAxis.setLowerBound( 0 );
        rangeAxis.setUpperBound( 1 );
        rangeAxis.setAutoRange( true );
      }
    } else {
      rangeAxis.setLowerBound( getRangeMinimum() );
      rangeAxis.setUpperBound( getRangeMaximum() );
      rangeAxis.setAutoRange( isRangeAxisAutoRange() );
    }
  }

}