Java Code Examples for org.jfree.chart.plot.PiePlot#setShadowXOffset()
The following examples show how to use
org.jfree.chart.plot.PiePlot#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: ChartJFreeChartOutputPie.java From gama with GNU General Public License v3.0 | 6 votes |
@Override public void initChart(final IScope scope, final String chartname) { super.initChart(scope, chartname); final PiePlot pp = (PiePlot) chart.getPlot(); pp.setShadowXOffset(0); pp.setShadowYOffset(0); if (!this.series_label_position.equals("none")) { pp.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} = {1} ({2})")); if (axesColor != null) { pp.setLabelLinkPaint(axesColor); } pp.setLabelFont(getTickFont()); } if (this.series_label_position.equals("none")) { pp.setLabelLinksVisible(false); pp.setLabelGenerator(null); } if (textColor != null) { // pp.setLabelPaint(textColor); // not for Pie since the label background is always yellow for // now... } }
Example 2
Source File: EyeCandySixtiesChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected JFreeChart createPieChart() throws JRException { JFreeChart jfreeChart = super.createPieChart(); PiePlot piePlot = (PiePlot)jfreeChart.getPlot(); JRPiePlot jrPiePlot = (JRPiePlot)getPlot(); boolean isShowLabels = jrPiePlot.getShowLabels() == null ? true : jrPiePlot.getShowLabels(); if (isShowLabels && piePlot.getLabelGenerator() != null) { piePlot.setLabelBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT); piePlot.setLabelShadowPaint(ChartThemesConstants.TRANSPARENT_PAINT); piePlot.setLabelOutlinePaint(ChartThemesConstants.TRANSPARENT_PAINT); } piePlot.setShadowXOffset(5); piePlot.setShadowYOffset(10); piePlot.setShadowPaint(new GradientPaint(0, getChart().getHeight() / 2, new Color(41, 120, 162), 0, getChart().getHeight(), Color.white)); PieDataset pieDataset = piePlot.getDataset(); if (pieDataset != null) { for (int i = 0; i < pieDataset.getItemCount(); i++) { piePlot.setSectionOutlinePaint(pieDataset.getKey(i), ChartThemesConstants.TRANSPARENT_PAINT); //makes pie colors darker //piePlot.setSectionPaint(pieDataset.getKey(i), GRADIENT_PAINTS[i]); } } piePlot.setCircular(true); return jfreeChart; }
Example 3
Source File: AegeanChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected JFreeChart createPieChart() throws JRException { JFreeChart jfreeChart = super.createPieChart(); PiePlot piePlot = (PiePlot)jfreeChart.getPlot(); JRPiePlot jrPiePlot = (JRPiePlot)getPlot(); boolean isShowLabels = jrPiePlot.getShowLabels() == null ? true : jrPiePlot.getShowLabels(); if(isShowLabels && piePlot.getLabelGenerator() != null) { piePlot.setLabelBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT); piePlot.setLabelShadowPaint(ChartThemesConstants.TRANSPARENT_PAINT); piePlot.setLabelOutlinePaint(ChartThemesConstants.TRANSPARENT_PAINT); } piePlot.setShadowXOffset(0); piePlot.setShadowYOffset(0); PieDataset pieDataset = piePlot.getDataset(); if(pieDataset != null) { for(int i = 0; i < pieDataset.getItemCount(); i++) { piePlot.setSectionOutlinePaint(pieDataset.getKey(i), ChartThemesConstants.TRANSPARENT_PAINT); //makes pie colors darker //piePlot.setSectionPaint(pieDataset.getKey(i), GRADIENT_PAINTS[i]); } } piePlot.setCircular(true); return jfreeChart; }
Example 4
Source File: DefaultChartService.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
private JFreeChart getMultiplePieChart( BaseChart chart, CategoryDataset[] dataSets ) { JFreeChart multiplePieChart = ChartFactory.createMultiplePieChart( chart.getName(), dataSets[0], TableOrder.BY_ROW, !chart.isHideLegend(), false, false ); setBasicConfig( multiplePieChart, chart ); if ( multiplePieChart.getLegend() != null ) { multiplePieChart.getLegend().setItemFont( SUB_TITLE_FONT ); } MultiplePiePlot multiplePiePlot = (MultiplePiePlot) multiplePieChart.getPlot(); JFreeChart pieChart = multiplePiePlot.getPieChart(); pieChart.setBackgroundPaint( DEFAULT_BACKGROUND_COLOR ); pieChart.getTitle().setFont( SUB_TITLE_FONT ); PiePlot piePlot = (PiePlot) pieChart.getPlot(); piePlot.setBackgroundPaint( DEFAULT_BACKGROUND_COLOR ); piePlot.setOutlinePaint( DEFAULT_BACKGROUND_COLOR ); piePlot.setLabelFont( LABEL_FONT ); piePlot.setLabelGenerator( new StandardPieSectionLabelGenerator( "{2}" ) ); piePlot.setSimpleLabels( true ); piePlot.setIgnoreZeroValues( true ); piePlot.setIgnoreNullValues( true ); piePlot.setShadowXOffset( 0d ); piePlot.setShadowYOffset( 0d ); for ( int i = 0; i < dataSets[0].getColumnCount(); i++ ) { piePlot.setSectionPaint( dataSets[0].getColumnKey( i ), COLORS[(i % COLORS.length)] ); } return multiplePieChart; }
Example 5
Source File: ChartImageGenerator.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
private JFreeChart getMultiplePieChart( final Visualization visualization, CategoryDataset[] dataSets ) { JFreeChart multiplePieChart = ChartFactory.createMultiplePieChart( visualization.getName(), dataSets[0], TableOrder.BY_ROW, !visualization.isHideLegend(), false, false ); setBasicConfig( multiplePieChart, visualization ); if ( multiplePieChart.getLegend() != null ) { multiplePieChart.getLegend().setItemFont( SUB_TITLE_FONT ); } MultiplePiePlot multiplePiePlot = (MultiplePiePlot) multiplePieChart.getPlot(); JFreeChart pieChart = multiplePiePlot.getPieChart(); pieChart.setBackgroundPaint( DEFAULT_BACKGROUND_COLOR ); pieChart.getTitle().setFont( SUB_TITLE_FONT ); PiePlot piePlot = (PiePlot) pieChart.getPlot(); piePlot.setBackgroundPaint( DEFAULT_BACKGROUND_COLOR ); piePlot.setOutlinePaint( DEFAULT_BACKGROUND_COLOR ); piePlot.setLabelFont( LABEL_FONT ); piePlot.setLabelGenerator( new StandardPieSectionLabelGenerator( "{2}" ) ); piePlot.setSimpleLabels( true ); piePlot.setIgnoreZeroValues( true ); piePlot.setIgnoreNullValues( true ); piePlot.setShadowXOffset( 0d ); piePlot.setShadowYOffset( 0d ); for ( int i = 0; i < dataSets[0].getColumnCount(); i++ ) { piePlot.setSectionPaint( dataSets[0].getColumnKey( i ), COLORS[(i % COLORS.length)] ); } return multiplePieChart; }
Example 6
Source File: PieChartExpression.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
protected void configureChart( final JFreeChart chart ) { super.configureChart( chart ); final Plot plot = chart.getPlot(); final PiePlot pp = (PiePlot) plot; final PieDataset pieDS = pp.getDataset(); pp.setDirection( rotationClockwise ? Rotation.CLOCKWISE : Rotation.ANTICLOCKWISE ); if ( ( explodeSegment != null ) && ( explodePct != null ) ) { configureExplode( pp ); } if ( StringUtils.isEmpty( getTooltipFormula() ) == false ) { pp.setToolTipGenerator( new FormulaPieTooltipGenerator( getRuntime(), getTooltipFormula() ) ); } if ( StringUtils.isEmpty( getUrlFormula() ) == false ) { pp.setURLGenerator( new FormulaPieURLGenerator( getRuntime(), getUrlFormula() ) ); } pp.setIgnoreNullValues( ignoreNulls ); pp.setIgnoreZeroValues( ignoreZeros ); if ( Boolean.FALSE.equals( getItemsLabelVisible() ) ) { pp.setLabelGenerator( null ); } else { final ExpressionRuntime runtime = getRuntime(); final Locale locale = runtime.getResourceBundleFactory().getLocale(); final FastDecimalFormat fastPercent = new FastDecimalFormat( FastDecimalFormat.TYPE_PERCENT, locale, true ); final FastDecimalFormat fastInteger = new FastDecimalFormat( FastDecimalFormat.TYPE_INTEGER, locale, true ); final DecimalFormat numFormat = new DecimalFormat( fastInteger.getPattern(), new DecimalFormatSymbols( locale ) ); numFormat.setRoundingMode( RoundingMode.HALF_UP ); final DecimalFormat percentFormat = new DecimalFormat( fastPercent.getPattern(), new DecimalFormatSymbols( locale ) ); percentFormat.setRoundingMode( RoundingMode.HALF_UP ); final StandardPieSectionLabelGenerator labelGen = new StandardPieSectionLabelGenerator( pieLabelFormat, numFormat, percentFormat ); pp.setLabelGenerator( labelGen ); final StandardPieSectionLabelGenerator legendGen = new StandardPieSectionLabelGenerator( pieLegendLabelFormat, numFormat, percentFormat ); pp.setLegendLabelGenerator( legendGen ); } if ( StringUtils.isEmpty( getLabelFont() ) == false ) { pp.setLabelFont( Font.decode( getLabelFont() ) ); } if ( pieDS != null ) { final String[] colors = getSeriesColor(); for ( int i = 0; i < colors.length; i++ ) { if ( i < pieDS.getItemCount() ) { pp.setSectionPaint( pieDS.getKey( i ), parseColorFromString( colors[ i ] ) ); } else { break; } } } if ( shadowPaint != null ) { pp.setShadowPaint( shadowPaint ); } if ( shadowXOffset != null ) { pp.setShadowXOffset( shadowXOffset.doubleValue() ); } if ( shadowYOffset != null ) { pp.setShadowYOffset( shadowYOffset.doubleValue() ); } pp.setCircular( circular ); if ( isShowBorder() == false || isChartSectionOutline() == false ) { chart.setBorderVisible( false ); chart.getPlot().setOutlineVisible( false ); } }
Example 7
Source File: MultiPieChartExpression.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
protected void configureChart( final JFreeChart chart ) { super.configureChart( chart ); final Plot plot = chart.getPlot(); final MultiplePiePlot mpp = (MultiplePiePlot) plot; final JFreeChart pc = mpp.getPieChart(); configureSubChart( pc ); final PiePlot pp = (PiePlot) pc.getPlot(); if ( StringUtils.isEmpty( getTooltipFormula() ) == false ) { pp.setToolTipGenerator( new FormulaPieTooltipGenerator( getRuntime(), getTooltipFormula() ) ); } if ( StringUtils.isEmpty( getUrlFormula() ) == false ) { pp.setURLGenerator( new FormulaPieURLGenerator( getRuntime(), getUrlFormula() ) ); } if ( shadowPaint != null ) { pp.setShadowPaint( shadowPaint ); } if ( shadowXOffset != null ) { pp.setShadowXOffset( shadowXOffset.doubleValue() ); } if ( shadowYOffset != null ) { pp.setShadowYOffset( shadowYOffset.doubleValue() ); } final CategoryDataset c = mpp.getDataset(); if ( c != null ) { final String[] colors = getSeriesColor(); final int keysSize = c.getColumnKeys().size(); for ( int i = 0; i < colors.length; i++ ) { if ( keysSize > i ) { pp.setSectionPaint( c.getColumnKey( i ), parseColorFromString( colors[ i ] ) ); } } } if ( StringUtils.isEmpty( getLabelFont() ) == false ) { pp.setLabelFont( Font.decode( getLabelFont() ) ); } if ( Boolean.FALSE.equals( getItemsLabelVisible() ) ) { pp.setLabelGenerator( null ); } else { final ExpressionRuntime runtime = getRuntime(); final Locale locale = runtime.getResourceBundleFactory().getLocale(); final FastDecimalFormat fastPercent = new FastDecimalFormat( FastDecimalFormat.TYPE_PERCENT, locale ); final FastDecimalFormat fastInteger = new FastDecimalFormat( FastDecimalFormat.TYPE_INTEGER, locale ); final DecimalFormat numFormat = new DecimalFormat( fastInteger.getPattern(), new DecimalFormatSymbols( locale ) ); numFormat.setRoundingMode( RoundingMode.HALF_UP ); final DecimalFormat percentFormat = new DecimalFormat( fastPercent.getPattern(), new DecimalFormatSymbols( locale ) ); percentFormat.setRoundingMode( RoundingMode.HALF_UP ); final StandardPieSectionLabelGenerator labelGen = new StandardPieSectionLabelGenerator( multipieLabelFormat, numFormat, percentFormat ); pp.setLabelGenerator( labelGen ); } }