Package org.jfree.chart.plot

Examples of org.jfree.chart.plot.PiePlot


   
    protected void updateChartProperties() {

      chart.setTitle(tfTitle.getText());

      PiePlot plot = (PiePlot)chart.getPlot();
      SourcePieDataset dst = (SourcePieDataset)plot.getDataset();

      int n = dst.getItemCount();

      // If some curves were deleted, remove them
      if (n != pcbxcurves.getItemCount()) {
        boolean[] toKeep = new boolean[n]; // boolean are initialized to false by JVM
        for (int i=0; i<pcbxcurves.getItemCount(); ++i)
          toKeep[((CbxEntry)pcbxcurves.getItemAt(i)).datasetIndex] = true;

        // Now we can remove the deleted curves, and update the existing ones
        // Start from the end, to remove the entries and keep the index OK
        for (int i=n-1; i>=0; i--) {
          if (!toKeep[i]) {
            GenericMapper mapper = (GenericMapper)mappers.remove(i);
            if (mapper!=null) mapper.removeListener(PieChartShape.this);
            DataSource source = (DataSource)mapperSources.remove(i);
            if (source!=null) source.removeListener(PieChartShape.this);
            dst.removeSource(i);
          }
        }
      }
     
      // Now we match the data set and the list
      int len = pcbxcurves.getItemCount();
     
      // first compute max ratio => define JFreeChart 100% and compute 1.0 equivalent
      double maxratio = Double.NEGATIVE_INFINITY;
      for (int i=0; i<len; ++i) {
        CbxEntry e = (CbxEntry)pcbxcurves.getItemAt(i);
        maxratio = Math.max(e.ratio, maxratio);
      }
      double delta = maxratio - 1.0;
     
      // now apply changes
      for (int i=0; i<len; ++i) {
        CbxEntry e = (CbxEntry)pcbxcurves.getItemAt(i);
        dst.setName(i,e.name);
        DataSource ds = (DataSource)mapperSources.get(i);
        if ((e.source==null) && (ds!=null)) {
            ds.removeListener(PieChartShape.this);
            ds.removeEndNotificationListener(PieChartShape.this);
        }
        mapperSources.set(i,e.source);
        if (e.source!=null) {
            e.source.addListener(PieChartShape.this);
            e.source.addEndNotificationListener(PieChartShape.this);
        }
        ColorMapper cm = (ColorMapper)mappers.get(i);
        if ((e.mapper==null) && (cm!=null)) cm.removeListener(PieChartShape.this);
        mappers.set(i,e.mapper);
        if (e.mapper!=null) e.mapper.addListener(PieChartShape.this);
       
        if ((e.mapper!=null) && (e.source!=null)) {
          e.mapper.setDefaultPaint(e.color);
          plot.setSectionPaint(i,e.mapper.getPaint(e.source));
        }
        else plot.setSectionPaint(i,e.color);

        plot.setExplodePercent(i, (delta==0) ? 0.0 : (e.ratio-1.0) / delta );
      }
     
      plot.setRadius(1.0/maxratio);
   
    }
View Full Code Here


                false);
        // E6EEF9
        chart.setBackgroundPaint(new Color(230, 238, 249));
        chart.setBorderVisible(false);
       
        final PiePlot plot = (PiePlot) chart.getPlot();
        plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 10));
        plot.setNoDataMessage("No data available");
        plot.setCircular(false);
        plot.setLabelLinkPaint(Color.red);
        plot.setLabelGap(0.02);
        plot.setOutlinePaint(new Color(230, 238, 249));
       
        // set paint for unavailable/available sections
        plot.setSectionPaint(0, Color.RED);
        plot.setSectionPaint(1, Color.GREEN);
       
        plot.setBackgroundPaint(new Color(230, 238, 249));
       
        //plot.set
        return chart;
    }
View Full Code Here

                false);
        // E6EEF9
        chart.setBackgroundPaint(new Color(230, 238, 249));
        chart.setBorderVisible(false);
       
        final PiePlot plot = (PiePlot) chart.getPlot();
        plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 10));
        plot.setNoDataMessage("No data available");
        plot.setCircular(false);
        plot.setLabelLinkPaint(Color.red);
        plot.setLabelGap(0.02);
        plot.setOutlinePaint(new Color(230, 238, 249));
       
        // set paint for unavailable/available sections
        int itemCount = dataset.getItemCount();
        for(int ctr=0; ctr < itemCount; ctr++){
          if(ctr % 2 == 0)
            plot.setSectionPaint(ctr, Color.BLUE);
          else
                plot.setSectionPaint(ctr, Color.RED);
        }
        plot.setBackgroundPaint(new Color(230, 238, 249));
        //plot.set
        return chart;
    }
View Full Code Here

        true,
        false
        );

    configureChart(jfreeChart);
    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(jrPiePlot.getLegendLabelFormat())
        );
    }
   
    return jfreeChart;
View Full Code Here

   */
  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(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;
  }
View Full Code Here

        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())
  //          );
  //
  //    }
 
      Integer baseFontSize = (Integer)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.BASEFONT_SIZE);
      JRFont font = itemLabel != null && itemLabel.getFont() != null ? itemLabel.getFont() : null;
     
      piePlot.setLabelFont(getFont(new JRBaseFont(getChart(), null), font, baseFontSize));
 
      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(jrPiePlot.getLegendLabelFormat())
        );
    }
   
    return jfreeChart;
View Full Code Here

        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

   */
  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

    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

    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

TOP

Related Classes of org.jfree.chart.plot.PiePlot

Copyright © 2018 www.massapicom. 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.