Java Code Examples for org.jfree.chart.renderer.category.LineAndShapeRenderer#setSeriesStroke()

The following examples show how to use org.jfree.chart.renderer.category.LineAndShapeRenderer#setSeriesStroke() . 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: IntervalChartPanel.java    From nmonvisualizer with Apache License 2.0 5 votes vote down vote up
public void highlightElement(int row, int column) {
    if (getChart() != null) {
        CategoryDataset dataset = ((CategoryPlot) getChart().getPlot()).getDataset();

        if ((row >= 0) && (row < dataset.getRowCount())) {
            LineAndShapeRenderer renderer = (LineAndShapeRenderer) ((CategoryPlot) getChart().getPlot())
                    .getRenderer();
            renderer.setSeriesStroke(row, SELECTED_STROKE);
        }
    }
}
 
Example 2
Source File: ChartRendererFactory.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
private static void configureLineAndShapeRenderer(LineAndShapeRenderer renderer, ValueSource valueSource,
		PlotInstance plotInstance) {
	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) {
		// configure linestyle
		if (seriesFormat.getLineStyle() != LineStyle.NONE) {
			renderer.setSeriesLinesVisible(seriesIdx, true);
			renderer.setSeriesStroke(seriesIdx, seriesFormat.getStroke(), false);
		} else {
			renderer.setSeriesLinesVisible(seriesIdx, false);
		}

		// configure series shape if necessary
		if (!SeriesFormat.calculateIndividualFormatForEachItem(domainConfig, shapeDimensionConfig)) {
			if (seriesFormat.getItemShape() != ItemShape.NONE) {
				renderer.setSeriesShapesVisible(seriesIdx, true);
				renderer.setSeriesShape(seriesIdx, seriesFormat.getItemShape().getShape());
			} else {
				renderer.setSeriesShapesVisible(seriesIdx, false);
			}
		}

		// 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);
	}
}