Examples of PiePlot


Examples of org.jfree.chart.plot.PiePlot

      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

Examples of org.jfree.chart.plot.PiePlot

  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

Examples of org.jfree.chart.plot.PiePlot

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

Examples of org.jfree.chart.plot.PiePlot

     
      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

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

Examples of org.jfree.chart.plot.PiePlot

                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

Examples of org.jfree.chart.plot.PiePlot

                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

Examples of org.jfree.chart.plot.PiePlot

        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

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(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

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())
  //          );
  //
  //    }
 
      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
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.