Package org.jfree.chart.plot

Examples of org.jfree.chart.plot.PiePlot


    TextTitle t1 = new TextTitle("Total Open Tickets: " + String.valueOf(totalTickets),
                                 new Font("SansSerif", Font.PLAIN, 11));
    pieChart.addSubtitle(t1);

    // set the chart visual options
    PiePlot plot = (PiePlot)pieChart.getPlot();
    plot.setForegroundAlpha(0.65f);
    plot.setNoDataMessage("There are no currently open tickets.");

    // print the chart image directly the the HTTP stream
    OutputStream out = response.getOutputStream();
    response.setContentType("image/jpeg");
View Full Code Here


                                 "Total Amount: " + totalActualString,
                                 new Font("SansSerif", Font.PLAIN, 11));
    pieChart.addSubtitle(t1);

    // set the chart visual options
    PiePlot plot = (PiePlot)pieChart.getPlot();
    plot.setForegroundAlpha(0.65f);
    plot.setNoDataMessage("No data to display");
    plot.setLabelGenerator(new CustomLabelGenerator(numFormatter));

    // print the chart image directly the the HTTP stream
    OutputStream out = response.getOutputStream();
    response.setContentType("image/jpeg");
     
View Full Code Here

      CategoryItemRenderer rendrer = categoryPlot.getRenderer();
      for(int index = 0; index < colors.getSeries().size(); index++){
        rendrer.setSeriesPaint(index, new Color(colors.getSeries().get(index)));
      }
    }else if(plot instanceof PiePlot){
      PiePlot piePlot = (PiePlot)plot;
     
      piePlot.setSimpleLabels(visibility.isPieSimpleLabels());
      piePlot.setSectionOutlinesVisible(visibility.isPieOutlines());
      piePlot.setLabelLinksVisible(visibility.isPieLabelLinks());
     
      //piePlot.setExplodePercent("1", 0.07000000000000001D);
      //piePlot.setInteriorGap(0.00D);
      piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator(chartConfig.getDataSettings().getPieSectionLabel()));
      //piePlot.setLabelBackgroundPaint(new Color(220, 220, 220));
      for(int index = 0; index < colors.getSeries().size(); index++){
        piePlot.setSectionPaint(String.valueOf(index), new Color(colors.getSeries().get(index)));
      }
    }
  }
View Full Code Here

  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 StandardPieSectionLabelGenerator labelGen = new StandardPieSectionLabelGenerator(pieLabelFormat);
      pp.setLabelGenerator(labelGen);

      final StandardPieSectionLabelGenerator legendGen = new StandardPieSectionLabelGenerator(pieLegendLabelFormat);
      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);
  }
View Full Code Here

    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 StandardPieSectionLabelGenerator labelGen = new StandardPieSectionLabelGenerator(multipieLabelFormat);
      pp.setLabelGenerator(labelGen);
    }
  }
View Full Code Here

    this(chart,0,0,300,300);
  }

  public PieChartShape(JFreeChart chart, int ox, int oy, int width, int height) {
    super(chart, ox, oy, width, height);
    PiePlot plot = (PiePlot)chart.getPlot();
    mapperSources = new Vector();
    mappers = new Vector();
  }
View Full Code Here

      return true;
    }

    if (action.equals(resources.getString("AddSource"))) {
      try {
        PiePlot plot = (PiePlot)chart.getPlot();
        SourcePieDataset dst = (SourcePieDataset)plot.getDataset();
        dst.addSource((DataSource)o);
        mappers.add(null); mapperSources.add(null); // no mapper by default
        notifyChange();
      } catch (ClassCastException cce) {
        JSynoptic.setStatus(resources.getString("ErrorWhileSettingDataSource"));
      }
    }

    if (action.equals(resources.getString("AddSources"))) {
      try {
        PiePlot plot = (PiePlot)chart.getPlot();
        SourcePieDataset dst = (SourcePieDataset)plot.getDataset();
        dst.addDataSourceCollection((DataSourceCollection)o);
        for (int i=0; i<((DataSourceCollection)o).size(); ++i) {
          mappers.add(null); mapperSources.add(null); // no mapper by default
        }
        notifyChange();
      } catch (ClassCastException cce) {
        JSynoptic.setStatus(resources.getString("ErrorWhileSettingDataSourceCollection"));
      }
    }

    if (action.equals(resources.getString("SetSources"))) {
      try {
        PiePlot plot = (PiePlot)chart.getPlot();
        SourcePieDataset dst = (SourcePieDataset)plot.getDataset();
        dst.setDataSourceCollection((DataSourceCollection)o);
        chart.setTitle(dst.getName());
        for (int i=0; i<mappers.size(); ++i) {
          DataSource ds = (DataSource)mapperSources.get(i);
          if (ds!=null) ds.removeListener(this);
View Full Code Here

  public void mappingChanged(GenericMapper mapper) {
    notifyChange();
  }

  public boolean checkMapperChange(DataSource ds, long index) {
    PiePlot plot = (PiePlot)chart.getPlot();
    SourcePieDataset dst = (SourcePieDataset)plot.getDataset();
    boolean hasChanged = false;
    for (int i=0; i<mapperSources.size(); ++i) {
      if (ds.equals(mapperSources.get(i))) {
        ColorMapper cm = (ColorMapper)mappers.get(i);
        if (cm!=null) {
          Paint p1 = hasChanged ? null : plot.getSectionPaint(i);
          plot.setSectionPaint(i,cm.getPaint(ds,index));
          // check colors only if useful => when one color changed, don't check the others
          if (!hasChanged) {
            Paint p2 = plot.getSectionPaint(i);
            if (!p1.equals(p2)) hasChanged = true;
          }
        }
      }
    }
View Full Code Here

  /* (non-Javadoc)
   * @see simtools.shapes.AbstractShape#cloneShape()
   */
  protected AbstractShape cloneShape() {
      ChartShape cs = (ChartShape)super.cloneShape();
      PiePlot plot = (PiePlot)chart.getPlot();
      SourcePieDataset dst = (SourcePieDataset)plot.getDataset();
      ((PiePlot)cs.chart.getPlot()).setDataset(dst.cloneSet());
      return cs;
  }
View Full Code Here

     
      Box content = Box.createVerticalBox();
     
      setName(resources.getString("PlotProperties"));

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

      // Create the title section
      section=Box.createHorizontalBox();
      section.add(new JLabel(resources.getString("PlotTitle:")));
      section.add(tfTitle = new JTextField());
      tfTitle.setText(chart.getTitle().getText());
      content.add(section);

      section=Box.createVerticalBox();
      section.setBorder(BorderFactory.createTitledBorder(resources.getString("Series")));

      Box box = Box.createHorizontalBox();
      box.add(pcbxcurves = new JComboBox());
      box.add(pcurvecolor = new JButton("    "));
      box.add(pcurvedelete = new JButton(resources.getString("Delete")));
      section.add(box);
     
      box = Box.createHorizontalBox();
      box.add(new JLabel(resources.getString("ExplodedRatio(>=1)")));
      box.add(tfRatio = new NumberField(1.0));
     
      // So long as this does not work for 3D pies, do not show it
      if (!(plot instanceof Pie3DPlot)) section.add(box);
     
      content.add(section);

      pcbxcurves.setEditable(true);
      Color noCurveColor = pcurvecolor.getBackground();
      pcurvecolor.setFocusPainted(false);

      int n = dst.getItemCount();
      double factor = 1.0 / plot.getRadius() - 1.0; // may be null
      // Now initialize entries
      for (int i=0; i<n; ++i) {
        DataSource ds = (DataSource)mapperSources.get(i);
        if (ds==null) ds = dst.getSource(i); // take the datasource associated with this series by default
        pcbxcurves.addItem(new CbxEntry(
                i,
                dst.getName(i),
                (Color)plot.getSectionPaint(i),
                ds,
                (ColorMapper)mappers.get(i),
                plot.getExplodePercent(i) * factor + 1.0
        ));
      }
      pcbxeditortf = (JTextField)pcbxcurves.getEditor().getEditorComponent();
      pupdateForEntry(pcbxcurves.getSelectedItem());
     
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.