public final void setSeriesStyle ( final JFreeChart chart , final int seriesIndex , final String style ) { if ( chart != null && style != null ) { BasicStroke stroke = ChartUtility . toStroke ( style ) ; Plot plot = chart . getPlot ( ) ; if ( plot instanceof CategoryPlot ) { CategoryPlot categoryPlot = chart . getCategoryPlot ( ) ; CategoryItemRenderer cir = categoryPlot . getRenderer ( ) ; try { cir . setSeriesStroke ( seriesIndex , stroke ) ; // series line // style } catch ( Exception e ) { LOG . log ( Level . SEVERE , "Error setting style '" + style + "' for series '" + Integer . toString ( seriesIndex ) + "' of chart '" + chart . toString ( ) + "': " + e . getLocalizedMessage ( ) , e ) ; } } else if ( plot instanceof XYPlot ) { XYPlot xyPlot = chart . getXYPlot ( ) ; XYItemRenderer xyir = xyPlot . getRenderer ( ) ; try { xyir . setSeriesStroke ( seriesIndex , stroke ) ; // series line // style } catch ( Exception e ) { LOG . log ( Level . SEVERE , "Error setting style '" + style + "' for series '" + Integer . toString ( seriesIndex ) + "' of chart '" + chart . toString ( ) + "': " + e . getLocalizedMessage ( ) , e ) ; } } else { LOG . log ( Level . FINE , "setSeriesColor() unsupported plot: {}" , plot . toString ( ) ) ; } } }
Set color of series .