org.jfree.chart.renderer.category.ScatterRenderer Java Examples

The following examples show how to use org.jfree.chart.renderer.category.ScatterRenderer. 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: ChartRendererFactory.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
private static void configureScatterRenderer(ScatterRenderer renderer, ValueSource valueSource, PlotInstance plotInstance)
		throws ChartPlottimeException {
	ValueSourceData valueSourceData = plotInstance.getPlotData().getValueSourceData(valueSource);
	int seriesCount = valueSourceData.getSeriesCount();
	SeriesFormat seriesFormat = valueSource.getSeriesFormat();
	DimensionConfig domainConfig = valueSource.getDomainConfig();
	DimensionConfig colorDimensionConfig = plotInstance.getCurrentPlotConfigurationClone().getDimensionConfig(
			PlotDimension.COLOR);
	DimensionConfig shapeDimensionConfig = plotInstance.getCurrentPlotConfigurationClone().getDimensionConfig(
			PlotDimension.SHAPE);

	renderer.setDefaultEntityRadius(4);

	// loop all series and set series format
	for (int seriesIdx = 0; seriesIdx < seriesCount; ++seriesIdx) {
		// lines are not supported in a ScatterRenderer, but this is already checked in
		// JFreeChartPlotEngine.getWarnings().

		// configure series shape if necessary
		if (!SeriesFormat.calculateIndividualFormatForEachItem(domainConfig, shapeDimensionConfig)) {
			// if(seriesFormat.getItemShape() != ItemShape.NONE) {
			renderer.setSeriesShape(seriesIdx, seriesFormat.getItemShape().getShape());
			// } else {
			// throw new ChartPlottimeException("unsupported_item_shape",
			// valueSource.toString(), seriesFormat.getItemShape());
			// }
		}

		// configure series color if necessary
		if (!SeriesFormat.calculateIndividualFormatForEachItem(domainConfig, colorDimensionConfig)) {
			Color itemColor = seriesFormat.getItemColor();
			renderer.setSeriesPaint(seriesIdx, itemColor);
		}
		renderer.setSeriesOutlinePaint(seriesIdx, PlotConfiguration.DEFAULT_SERIES_OUTLINE_PAINT);
		renderer.setUseOutlinePaint(true);
		renderer.setDrawOutlines(true);
		renderer.setUseSeriesOffset(false);
	}
}
 
Example #2
Source File: ScatterRendererTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test that the equals() method distinguishes all fields.
 */
public void testEquals() {

    ScatterRenderer r1 = new ScatterRenderer();
    ScatterRenderer r2 = new ScatterRenderer();
    assertEquals(r1, r2);

    r1.setSeriesShapesFilled(1, true);
    assertFalse(r1.equals(r2));
    r2.setSeriesShapesFilled(1, true);
    assertTrue(r1.equals(r2));

    r1.setBaseShapesFilled(false);
    assertFalse(r1.equals(r2));
    r2.setBaseShapesFilled(false);
    assertTrue(r1.equals(r2));

    r1.setUseFillPaint(true);
    assertFalse(r1.equals(r2));
    r2.setUseFillPaint(true);
    assertTrue(r1.equals(r2));

    r1.setDrawOutlines(true);
    assertFalse(r1.equals(r2));
    r2.setDrawOutlines(true);
    assertTrue(r1.equals(r2));

    r1.setUseOutlinePaint(true);
    assertFalse(r1.equals(r2));
    r2.setUseOutlinePaint(true);
    assertTrue(r1.equals(r2));

    r1.setUseSeriesOffset(false);
    assertFalse(r1.equals(r2));
    r2.setUseSeriesOffset(false);
    assertTrue(r1.equals(r2));

}
 
Example #3
Source File: ScatterRendererTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Two objects that are equal are required to return the same hashCode.
 */
public void testHashcode() {
    ScatterRenderer r1 = new ScatterRenderer();
    ScatterRenderer r2 = new ScatterRenderer();
    assertTrue(r1.equals(r2));
    int h1 = r1.hashCode();
    int h2 = r2.hashCode();
    assertEquals(h1, h2);
}
 
Example #4
Source File: ScatterRendererTests.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(ScatterRenderer r1,
        ScatterRenderer r2) {

    // should be equal...
    if (!r1.equals(r2)) {
        return false;
    }

    // and independent...
    r1.setSeriesShapesFilled(1, true);
    if (r1.equals(r2)) {
        return false;
    }
    r2.setSeriesShapesFilled(1, true);
    if (!r1.equals(r2)) {
        return false;
    }

    r1.setBaseShapesFilled(false);
    r2.setBaseShapesFilled(true);
    if (r1.equals(r2)) {
        return false;
    }
    r2.setBaseShapesFilled(false);
    if (!r1.equals(r2)) {
        return false;
    }
    return true;

}
 
Example #5
Source File: ScatterRendererTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test that the equals() method distinguishes all fields.
 */
public void testEquals() {
    
    ScatterRenderer r1 = new ScatterRenderer();
    ScatterRenderer r2 = new ScatterRenderer();
    assertEquals(r1, r2);
    
    r1.setSeriesShapesFilled(1, true);
    assertFalse(r1.equals(r2));
    r2.setSeriesShapesFilled(1, true);
    assertTrue(r1.equals(r2));
    
    r1.setBaseShapesFilled(false);
    assertFalse(r1.equals(r2));
    r2.setBaseShapesFilled(false);
    assertTrue(r1.equals(r2));
    
    r1.setUseFillPaint(true);
    assertFalse(r1.equals(r2));
    r2.setUseFillPaint(true);
    assertTrue(r1.equals(r2));
    
    r1.setDrawOutlines(true);
    assertFalse(r1.equals(r2));
    r2.setDrawOutlines(true);
    assertTrue(r1.equals(r2));
    
    r1.setUseOutlinePaint(true);
    assertFalse(r1.equals(r2));
    r2.setUseOutlinePaint(true);
    assertTrue(r1.equals(r2));
    
    r1.setUseSeriesOffset(false);
    assertFalse(r1.equals(r2));
    r2.setUseSeriesOffset(false);
    assertTrue(r1.equals(r2));
    
}
 
Example #6
Source File: ScatterRendererTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Two objects that are equal are required to return the same hashCode. 
 */
public void testHashcode() {
    ScatterRenderer r1 = new ScatterRenderer();
    ScatterRenderer r2 = new ScatterRenderer();
    assertTrue(r1.equals(r2));
    int h1 = r1.hashCode();
    int h2 = r2.hashCode();
    assertEquals(h1, h2);
}
 
Example #7
Source File: ScatterRendererTests.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(ScatterRenderer r1, 
        ScatterRenderer r2) {

    // should be equal...
    if (!r1.equals(r2)) {
        return false;
    }
    
    // and independent...
    r1.setSeriesShapesFilled(1, true);
    if (r1.equals(r2)) {
        return false;
    }
    r2.setSeriesShapesFilled(1, true);
    if (!r1.equals(r2)) {
        return false;
    }
    
    r1.setBaseShapesFilled(false);
    r2.setBaseShapesFilled(true);
    if (r1.equals(r2)) {
        return false;
    }
    r2.setBaseShapesFilled(false);
    if (!r1.equals(r2)) {
        return false;
    }
    return true;

}
 
Example #8
Source File: ScatterRendererTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Check that this class implements PublicCloneable.
 */
public void testPublicCloneable() {
    ScatterRenderer r1 = new ScatterRenderer();
    assertTrue(r1 instanceof PublicCloneable);
}