Examples of PiePlot


Examples of org.jfree.chart.plot.PiePlot

        true,
        false
        );

    configureChart(jfreeChart, getPlot());
    PiePlot piePlot = (PiePlot)jfreeChart.getPlot();
    //plot.setStartAngle(290);
    //plot.setDirection(Rotation.CLOCKWISE);
    //plot.setNoDataMessage("No data to display");
    JRPiePlot jrPiePlot = (JRPiePlot)getPlot();
    boolean isCircular = jrPiePlot.getCircular() == null ? true : jrPiePlot.getCircular().booleanValue();
    piePlot.setCircular(isCircular);

    boolean isShowLabels = jrPiePlot.getShowLabels() == null ? true : jrPiePlot.getShowLabels().booleanValue();
   
    if(isShowLabels)
    {
      PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator)getLabelGenerator();
      JRItemLabel itemLabel = jrPiePlot.getItemLabel();
      if (labelGenerator != null)
      {
        piePlot.setLabelGenerator(labelGenerator);
      }
      else if (jrPiePlot.getLabelFormat() != null)
      {
        piePlot.setLabelGenerator(
          new StandardPieSectionLabelGenerator(jrPiePlot.getLabelFormat())
          );
      }
  //    else if (itemLabel != null && itemLabel.getMask() != null)
  //    {
  //      piePlot.setLabelGenerator(
  //          new StandardPieSectionLabelGenerator(itemLabel.getMask())
  //          );
  //    }
     
      if(itemLabel != null && itemLabel.getFont() != null)
      {
        piePlot.setLabelFont(JRFontUtil.getAwtFont(itemLabel.getFont(), getLocale()));
      }
      else
      {
        piePlot.setLabelFont(JRFontUtil.getAwtFont(new JRBaseFont(getChart(), null), getLocale()));
      }
 
      if(itemLabel != null && itemLabel.getColor() != null)
      {
        piePlot.setLabelPaint(itemLabel.getColor());
      }
      else
      {
        piePlot.setLabelPaint(getChart().getForecolor());
      }
 
      if(itemLabel != null && itemLabel.getBackgroundColor() != null)
      {
        piePlot.setLabelBackgroundPaint(itemLabel.getBackgroundColor());
      }
      else
      {
        piePlot.setLabelBackgroundPaint(getChart().getBackcolor());
      }
    }
    else
    {
      piePlot.setLabelGenerator(null);
    }
   
    if (jrPiePlot.getLegendLabelFormat() != null)
    {
      piePlot.setLegendLabelGenerator(
        new StandardPieSectionLabelGenerator(((JRPie3DPlot)getPlot()).getLegendLabelFormat())
        );
    }
   
    return jfreeChart;
View Full Code Here

Examples of org.jfree.chart.plot.PiePlot

   */
  protected JFreeChart createPieChart() throws JRException
  {
    JFreeChart jfreeChart = super.createPieChart();

    PiePlot piePlot = (PiePlot)jfreeChart.getPlot();
    if(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;
  }
View Full Code Here

Examples of org.jfree.chart.plot.PiePlot

    plot.setOutlinePaint(WidgetUtils.BG_COLOR_BRIGHTEST);
    plot.setOutlineVisible(true);

    if (plot instanceof PiePlot) {
      // tweaks for pie charts
      final PiePlot piePlot = (PiePlot) plot;
      piePlot.setBaseSectionOutlinePaint(WidgetUtils.BG_COLOR_DARK);
      piePlot.setBaseSectionOutlineStroke(normalStroke);
      piePlot.setLabelFont(WidgetUtils.FONT_SMALL);
      piePlot.setLabelBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHT);
      piePlot.setLabelOutlineStroke(normalStroke);
      piePlot.setLabelPaint(WidgetUtils.BG_COLOR_DARK);
      piePlot.setSectionOutlinesVisible(false);
      piePlot.setLabelLinkStyle(PieLabelLinkStyle.QUAD_CURVE);
    } else if (plot instanceof CategoryPlot) {
      // tweaks for bar charts
      final CategoryPlot categoryPlot = (CategoryPlot) plot;
     
      int columnCount = categoryPlot.getDataset().getColumnCount();
View Full Code Here

Examples of org.jfree.chart.plot.PiePlot

    ChartUtils.applyStyles(chart);

    // code-block for tweaking style and coloring of chart
    {
      final PiePlot plot = (PiePlot) chart.getPlot();

      int colorIndex = 0;
      for (int i = 0; i < _dataset.getItemCount(); i++) {
        final String key = (String) _dataset.getKey(i);
        if (!LabelUtils.UNIQUE_LABEL.equals(key) && !LabelUtils.NULL_LABEL.equals(key)) {
          if (i == _dataset.getItemCount() - 1) {
            // the last color should not be the same as the first
            if (colorIndex == 0) {
              colorIndex++;
            }
          }

          Color color = SLICE_COLORS[colorIndex];
          int darkAmount = i / SLICE_COLORS.length;
          for (int j = 0; j < darkAmount; j++) {
            color = WidgetUtils.slightlyDarker(color);
          }

          plot.setSectionPaint(key, color);

          colorIndex++;
          if (colorIndex >= SLICE_COLORS.length) {
            colorIndex = 0;
          }
        }
      }
      plot.setSectionPaint(LabelUtils.UNIQUE_LABEL, WidgetUtils.BG_COLOR_BRIGHT);
      plot.setSectionPaint(LabelUtils.NULL_LABEL, WidgetUtils.BG_COLOR_DARKEST);
    }

    final ChartPanel chartPanel = new ChartPanel(chart);
    int chartHeight = 450;
    if (_dataset.getItemCount() > 32) {
View Full Code Here

Examples of org.jfree.chart.plot.PiePlot

        data = new DefaultPieDataset();
        final JFreeChart chart = ChartFactory.createPieChart("Employee Survey", data, false, false, false);
        chart.setTitle(new TextTitle());
        chart.setBackgroundPaint(null);
        chart.setPadding(new RectangleInsets(0, 0, 0, 0));
        PiePlot plot = (PiePlot) chart.getPlot();
        plot.setShadowPaint(null);
        plot.setSimpleLabels(true);
        plot.setLabelBackgroundPaint(null);
        plot.setLabelOutlineStroke(null);
        plot.setLabelShadowPaint(null);
        plot.setOutlineVisible(false);
        plot.setLabelFont(new java.awt.Font("Tahoma", 0, 10));
        plot.setLabelPaint(Color.WHITE);
        plot.setLabelGap(0.5);
        plot.setCircular(true);
        plot.setInteriorGap(0);
        plot.setBackgroundPaint(null);
        plot.setBackgroundAlpha(1f);
        plot.setSectionPaint(NbBundle.getMessage(getClass(), "ContextPieChart.visible"), new Color(0x222222));
        plot.setSectionPaint(NbBundle.getMessage(getClass(), "ContextPieChart.notVisible"), new Color(0xDDDDDD));
        chartPanel = new ChartPanel(chart, 100, 100, 10, 10, 300, 300, true, false, false, false, false, false);
        ((FlowLayout) chartPanel.getLayout()).setHgap(0);
        ((FlowLayout) chartPanel.getLayout()).setVgap(0);
        chartPanel.setOpaque(false);
        chartPanel.setPopupMenu(null);
View Full Code Here

Examples of org.jfree.chart.plot.PiePlot

            data.setValue(p.getDisplayName(), p.getPercentage());
        }
        final JFreeChart chart = ChartFactory.createPieChart("test", data, false, false, false);
        chart.setTitle(new TextTitle());
        chart.setBackgroundPaint(null);
        PiePlot plot = (PiePlot) chart.getPlot();
        plot.setShadowPaint(null);
        //plot.setSimpleLabels(true);
        plot.setLabelBackgroundPaint(Color.WHITE);
        plot.setLabelOutlineStroke(null);
        plot.setLabelShadowPaint(null);
        plot.setOutlineVisible(false);
        plot.setLabelFont(new java.awt.Font("Tahoma", 0, 10));
        plot.setLabelPaint(Color.BLACK);
        //plot.setLabelGap(0.05);
        plot.setCircular(true);
        plot.setBackgroundPaint(null);
        plot.setBackgroundAlpha(1f);
        for (Part p : partition.getParts()) {
            plot.setSectionPaint(p.getDisplayName(), p.getColor());
        }
        chartPanel = new ChartPanel(chart, true);
        chartPanel.setOpaque(false);
        chartPanel.setPopupMenu(null);
        add(chartPanel, BorderLayout.CENTER);
View Full Code Here

Examples of org.jfree.chart.plot.PiePlot

    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);
    }
  }
View Full Code Here

Examples of org.jfree.chart.plot.PiePlot

  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);
      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(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);
View Full Code Here

Examples of org.jfree.chart.plot.PiePlot

     * @since 1.0.7
     */
    public static JFreeChart createPieChart(String title, PieDataset dataset,
            boolean legend, boolean tooltips, Locale locale) {

        PiePlot plot = new PiePlot(dataset);
        plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale));
        plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
        if (tooltips) {
            plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale));
        }
        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
                plot, legend);
        currentTheme.apply(chart);
        return chart;
View Full Code Here

Examples of org.jfree.chart.plot.PiePlot

                                            PieDataset dataset,
                                            boolean legend,
                                            boolean tooltips,
                                            boolean urls) {

        PiePlot plot = new PiePlot(dataset);
        plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
        plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
        if (tooltips) {
            plot.setToolTipGenerator(new StandardPieToolTipGenerator());
        }
        if (urls) {
            plot.setURLGenerator(new StandardPieURLGenerator());
        }
        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
                plot, legend);
        currentTheme.apply(chart);
        return chart;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.