Java Code Examples for org.jfree.chart.renderer.category.LevelRenderer#setItemMargin()

The following examples show how to use org.jfree.chart.renderer.category.LevelRenderer#setItemMargin() . 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: LevelRendererTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Test that the equals() method distinguishes all fields.
 */
public void testEquals() {
    LevelRenderer r1 = new LevelRenderer();
    LevelRenderer r2 = new LevelRenderer();
    assertTrue(r1.equals(r2));
    assertTrue(r2.equals(r1));

    r1.setItemMargin(0.123);
    assertFalse(r1.equals(r2));
    r2.setItemMargin(0.123);
    assertTrue(r1.equals(r2));

    r1.setMaximumItemWidth(0.234);
    assertFalse(r1.equals(r2));
    r2.setMaximumItemWidth(0.234);
    assertTrue(r1.equals(r2));

}
 
Example 2
Source File: LevelRendererTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Test that the equals() method distinguishes all fields.
 */
public void testEquals() {
    LevelRenderer r1 = new LevelRenderer();
    LevelRenderer r2 = new LevelRenderer();
    assertTrue(r1.equals(r2));
    assertTrue(r2.equals(r1));
    
    r1.setItemMargin(0.123);
    assertFalse(r1.equals(r2));
    r2.setItemMargin(0.123);
    assertTrue(r1.equals(r2));

    r1.setMaximumItemWidth(0.234);
    assertFalse(r1.equals(r2));
    r2.setMaximumItemWidth(0.234);
    assertTrue(r1.equals(r2));

}
 
Example 3
Source File: LevelRendererTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks that the two renderers are equal but independent of one another.
 *
 * @param r1  renderer 1.
 * @param r2  renderer 2.
 *
 * @return A boolean.
 */
private boolean checkIndependence(LevelRenderer r1, LevelRenderer r2) {

    // should be equal...
    boolean b0 = r1.equals(r2);

    // and independent...
    r1.setItemMargin(0.0);
    boolean b1 = !r1.equals(r2);
    r2.setItemMargin(0.0);
    boolean b2 = r1.equals(r2);

    return b0 && b1 && b2;

}
 
Example 4
Source File: LevelRendererTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Checks that the two renderers are equal but independent of one another.
 * 
 * @param r1  renderer 1.
 * @param r2  renderer 2.
 * 
 * @return A boolean.
 */
private boolean checkIndependence(LevelRenderer r1, LevelRenderer r2) {

    // should be equal...
    boolean b0 = r1.equals(r2);
    
    // and independent...
    r1.setItemMargin(0.0);
    boolean b1 = !r1.equals(r2);
    r2.setItemMargin(0.0);
    boolean b2 = r1.equals(r2);
    
    return b0 && b1 && b2;

}
 
Example 5
Source File: LevelRenderCustomizer.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void customize(JFreeChart jfc, JRChart jrc) 
{
	if (jfc.getPlot() instanceof CategoryPlot)
	{
		CategoryPlot plot = (CategoryPlot)jfc.getPlot();

		ItemsCounter itemsCounter = new CategoryCounter(plot);
		
		Integer seriesIndex = 
			CustomizerUtil.resolveIndex(
				this, 
				itemsCounter,
				new CategorySeriesNameProvider(plot)
				);
		if (seriesIndex != null)
		{
			LevelRenderer levelRenderer = new LevelRenderer();

			Double itemMargin = getDoubleProperty(PROPERTY_ITEM_MARIGN);
			if (itemMargin != null)
			{
				levelRenderer.setItemMargin(itemMargin);
			}
			Double maxItemWidth = getDoubleProperty(PROPERTY_MAX_ITEM_WIDTH);
			if (maxItemWidth != null)
			{
				levelRenderer.setMaximumItemWidth(maxItemWidth);
			}

			if (seriesIndex == -1)
			{
				for (int i = 0; i < itemsCounter.getCount(); i++)
				{
					plot.setRenderer(i, levelRenderer);
				}
			}
			else
			{
				plot.setRenderer(seriesIndex, levelRenderer);
			}
		}
	}
}