Package org.jfree.chart.plot

Examples of org.jfree.chart.plot.PiePlot


     * dataset should be null.
     */
    public void testReplaceDatasetOnPieChart() {
        LocalListener l = new LocalListener();
        this.pieChart.addChangeListener(l);
        PiePlot plot = (PiePlot) this.pieChart.getPlot();
        plot.setDataset(null);
        assertEquals(true, l.flag);
        assertNull(plot.getDataset());
    }
View Full Code Here


    /**
     * Check that the equals() method can distinguish all fields (note that
     * the dataset is NOT considered in the equals() method).
     */
    public void testEquals() {
        PiePlot plot1 = new PiePlot();
        PiePlot plot2 = new PiePlot();
        assertTrue(plot1.equals(plot2));
        assertTrue(plot2.equals(plot1));

        // noDataMessage
        plot1.setNoDataMessage("No data XYZ");
        assertFalse(plot1.equals(plot2));
        plot2.setNoDataMessage("No data XYZ");
        assertTrue(plot1.equals(plot2));

        // noDataMessageFont
        plot1.setNoDataMessageFont(new Font("SansSerif", Font.PLAIN, 13));
        assertFalse(plot1.equals(plot2));
        plot2.setNoDataMessageFont(new Font("SansSerif", Font.PLAIN, 13));
        assertTrue(plot1.equals(plot2));

        // noDataMessagePaint
        plot1.setNoDataMessagePaint(new GradientPaint(1.0f, 2.0f, Color.red,
                3.0f, 4.0f, Color.blue));
        assertFalse(plot1.equals(plot2));
        plot2.setNoDataMessagePaint(new GradientPaint(1.0f, 2.0f, Color.red,
                3.0f, 4.0f, Color.blue));
        assertTrue(plot1.equals(plot2));

        // insets
        plot1.setInsets(new RectangleInsets(1.0, 2.0, 3.0, 4.0));
        assertFalse(plot1.equals(plot2));
        plot2.setInsets(new RectangleInsets(1.0, 2.0, 3.0, 4.0));
        assertTrue(plot1.equals(plot2));

        // outlineVisible
        plot1.setOutlineVisible(false);
        assertFalse(plot1.equals(plot2));
        plot2.setOutlineVisible(false);
        assertTrue(plot1.equals(plot2));

        // outlineStroke
        BasicStroke s = new BasicStroke(1.23f);
        plot1.setOutlineStroke(s);
        assertFalse(plot1.equals(plot2));
        plot2.setOutlineStroke(s);
        assertTrue(plot1.equals(plot2));

        // outlinePaint
        plot1.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.yellow,
                3.0f, 4.0f, Color.green));
        assertFalse(plot1.equals(plot2));
        plot2.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.yellow,
                3.0f, 4.0f, Color.green));
        assertTrue(plot1.equals(plot2));

        // backgroundPaint
        plot1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.cyan,
                3.0f, 4.0f, Color.green));
        assertFalse(plot1.equals(plot2));
        plot2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.cyan,
                3.0f, 4.0f, Color.green));
        assertTrue(plot1.equals(plot2));

        // backgroundImage
        plot1.setBackgroundImage(JFreeChart.INFO.getLogo());
        assertFalse(plot1.equals(plot2));
        plot2.setBackgroundImage(JFreeChart.INFO.getLogo());
        assertTrue(plot1.equals(plot2));

        // backgroundImageAlignment
        plot1.setBackgroundImageAlignment(Align.BOTTOM_RIGHT);
        assertFalse(plot1.equals(plot2));
        plot2.setBackgroundImageAlignment(Align.BOTTOM_RIGHT);
        assertTrue(plot1.equals(plot2));

        // backgroundImageAlpha
        plot1.setBackgroundImageAlpha(0.77f);
        assertFalse(plot1.equals(plot2));
        plot2.setBackgroundImageAlpha(0.77f);
        assertTrue(plot1.equals(plot2));

        // foregroundAlpha
        plot1.setForegroundAlpha(0.99f);
        assertFalse(plot1.equals(plot2));
        plot2.setForegroundAlpha(0.99f);
        assertTrue(plot1.equals(plot2));

        // backgroundAlpha
        plot1.setBackgroundAlpha(0.99f);
        assertFalse(plot1.equals(plot2));
        plot2.setBackgroundAlpha(0.99f);
        assertTrue(plot1.equals(plot2));

        // drawingSupplier
        plot1.setDrawingSupplier(new DefaultDrawingSupplier(
                new Paint[] {Color.blue}, new Paint[] {Color.red},
                new Stroke[] {new BasicStroke(1.1f)},
                new Stroke[] {new BasicStroke(9.9f)},
                new Shape[] {new Rectangle(1, 2, 3, 4)}));
        assertFalse(plot1.equals(plot2));
        plot2.setDrawingSupplier(new DefaultDrawingSupplier(
                new Paint[] {Color.blue}, new Paint[] {Color.red},
                new Stroke[] {new BasicStroke(1.1f)},
                new Stroke[] {new BasicStroke(9.9f)},
                new Shape[] {new Rectangle(1, 2, 3, 4)}));
        assertTrue(plot1.equals(plot2));
View Full Code Here

/**
* Post processor which is used change the border colour of a pie chart.
*/
public class BorderPostProcessor implements ChartPostProcessor {
    public void processChart(Object chart, Map params) {
        PiePlot plot = (PiePlot)((JFreeChart)chart).getPlot();
        plot.setOutlinePaint(Color.WHITE);
    }
View Full Code Here

        ChartColor.VERY_DARK_MAGENTA,
        ChartColor.VERY_DARK_CYAN,
    };

    public void processChart(Object chart, Map parameters) {
        PiePlot plot = (PiePlot)((JFreeChart)chart).getPlot();
        setPlotDefaults(plot);
        for (Iterator iterator = parameters.keySet().iterator(); iterator.hasNext();) {
            String key = (String)iterator.next();
            if (key.equals("border.color")) {
                plot.setOutlinePaint(parseColor(parameters.get(key)));
            } else if (key.startsWith("section.exploded") && isTrue(parameters.get(key))) {
                plot.setRadius(0.90);
                plot.setExplodePercent(getIndex(key), 1.0);
            } else if (key.startsWith("depth") && isTrue(parameters.get(key))) {
                if (plot instanceof Pie3DPlot) {
                    ((Pie3DPlot)plot).setDepthFactor(Double.parseDouble(parameters.get(key).toString()));
                }
            } else if (key.startsWith("section.color")) {
                plot.setPaint(getIndex(key), parseColor(parameters.get(key)));
            }
        }
    }
View Full Code Here

    public CategoryEnhancer() {
        // DO NOTHING
    }

    public void processChart(Object chart, Map params) {
        PiePlot plot = (PiePlot) ((JFreeChart) chart).getPlot();

        plot.setBackgroundAlpha(0.7f);
        plot.setLabelGenerator(new StandardPieItemLabelGenerator(
                "{0}: {1} [ {2} ]"));

        setSectionPaints(COLORS, plot);

    }
View Full Code Here

    // -----------------------------------------------------------

    String title = chartDefinition.getTitle();
    boolean legend = chartDefinition.isLegendIncluded();

    PiePlot plot = null;
    plot = chartDefinition.isThreeD() ? new PiePlot3D( chartDefinition ) : new PiePlot( chartDefinition );
    JFreeChartEngine.updatePlot( plot, chartDefinition );
    JFreeChart pieChart = new JFreeChart( title, chartDefinition.getTitleFont(), plot, legend );
    TextTitle seriesTitle = new TextTitle( "Series Title", new Font( "SansSerif", Font.BOLD, 12 ) ); //$NON-NLS-1$ //$NON-NLS-2$
    seriesTitle.setPosition( RectangleEdge.BOTTOM );
    pieChart.setTitle( title );
    pieChart.setBackgroundPaint( chartDefinition.getChartBackgroundPaint() );

    if ( tooltips ) {
      PieToolTipGenerator tooltipGenerator = new StandardPieToolTipGenerator();
      plot.setToolTipGenerator( tooltipGenerator );
    }

    if ( urls ) {
      PieURLGenerator urlGenerator = new StandardPieURLGenerator();
      plot.setURLGenerator( urlGenerator );
    }

    return pieChart;
  }
View Full Code Here

        }
      }

    }
    if ( plot instanceof PiePlot ) {
      PiePlot pie = (PiePlot) plot;
      PieDatasetChartDefinition pieDefinition = (PieDatasetChartDefinition) chartDefinition;
      pie.setInteriorGap( pieDefinition.getInteriorGap() );
      pie.setStartAngle( pieDefinition.getStartAngle() );
      pie.setLabelFont( pieDefinition.getLabelFont() );
      if ( pieDefinition.getLabelPaint() != null ) {
        pie.setLabelPaint( pieDefinition.getLabelPaint() );
      }
      pie.setLabelBackgroundPaint( pieDefinition.getLabelBackgroundPaint() );
      if ( pieDefinition.isLegendIncluded() ) {
        StandardPieSectionLabelGenerator labelGen = new StandardPieSectionLabelGenerator( "{0}" ); //$NON-NLS-1$
        pie.setLegendLabelGenerator( labelGen );
      }
      if ( pieDefinition.getExplodedSlices() != null ) {
        for ( Iterator iter = pieDefinition.getExplodedSlices().iterator(); iter.hasNext(); ) {
          pie.setExplodePercent( (Comparable) iter.next(), .30 );
        }
      }
      pie.setLabelGap( pieDefinition.getLabelGap() );
      if ( !pieDefinition.isDisplayLabels() ) {
        pie.setLabelGenerator( null );
      } else {
        if ( pieDefinition.isLegendIncluded() ) {
          StandardPieSectionLabelGenerator labelGen = new StandardPieSectionLabelGenerator( "{1} ({2})" ); //$NON-NLS-1$
          pie.setLabelGenerator( labelGen );
        } else {
          StandardPieSectionLabelGenerator labelGen = new StandardPieSectionLabelGenerator( "{0} = {1} ({2})" ); //$NON-NLS-1$
          pie.setLabelGenerator( labelGen );
        }
      }
    }
    if ( plot instanceof MultiplePiePlot ) {
      MultiplePiePlot pies = (MultiplePiePlot) plot;
View Full Code Here

        chart.setBackgroundPaint(Color.white);
       
        //Sets legend labels
        SymbolAxis scaleAxis = new SymbolAxis(null,legendLabels);
        scaleAxis.setRange(0.5, 0.5+zvalues.length);
        scaleAxis.setPlot(new PiePlot());
        scaleAxis.setGridBandsVisible(false);
        scaleAxis.setLabel(zLabel);
        //scaleAxis.setLabelAngle(3.14/2);
        scaleAxis.setLabelFont(addLabelsStyle.getFont());
        scaleAxis.setLabelPaint(addLabelsStyle.getColor());
     
        //draws legend as chart subtitle
        PaintScaleLegend psl = new PaintScaleLegend(legendPaintScale, scaleAxis);
        psl.setAxisOffset(2.0);
        psl.setPosition(RectangleEdge.RIGHT);
        psl.setMargin(new RectangleInsets(5, 1, 5, 1));       
        chart.addSubtitle(psl);
       
        if(yLabels!=null){
          //Sets y legend labels
          LookupPaintScale legendPaintScale2 = new LookupPaintScale(0, (yLabels.length-1), Color.white);
         
          for (int ke=0; ke<yLabels.length ; ke++){
            Color temp =Color.white;
            legendPaintScale2.add(1+ke, temp);
          }
         
          SymbolAxis scaleAxis2 = new SymbolAxis(null,yLabels);
          scaleAxis2.setRange(0, (yLabels.length-1));
          scaleAxis2.setPlot(new PiePlot());
          scaleAxis2.setGridBandsVisible(false);
       
          //draws legend as chart subtitle
          PaintScaleLegend psl2 = new PaintScaleLegend(legendPaintScale2, scaleAxis2);
          psl2.setAxisOffset(5.0);
View Full Code Here



    SymbolAxis scaleAxis = new SymbolAxis(null, labels);
    scaleAxis.setRange(0.5, ranges.size()+0.5);
    scaleAxis.setPlot(new PiePlot());
    scaleAxis.setGridBandsVisible(false);

    org.jfree.chart.title.PaintScaleLegend psl = new PaintScaleLegend(paintScale, scaleAxis);
    psl.setMargin(new RectangleInsets(3, 10, 3, 10));
    psl.setPosition(RectangleEdge.BOTTOM);
View Full Code Here

      TextTitle title = chart.getTitle();
      title.setToolTipText("A title tooltip!");


      PiePlot plot = (PiePlot) chart.getPlot();
      plot.setLabelFont(new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize()));
      plot.setCircular(false);
      plot.setLabelGap(0.02);
      plot.setNoDataMessage("No data available");

      if(percentage==false){
        plot.setLabelGenerator(new StandardPieSectionLabelGenerator(
        "{0} ({1})"));}
      else
      {
        plot.setLabelGenerator(new StandardPieSectionLabelGenerator(
        "{0} ({2})"));
      }

      MyPieUrlGenerator pieUrl=new MyPieUrlGenerator(rootUrl);
      pieUrl.setDocument_composition(document_composition);
      pieUrl.setCategoryUrlLabel(categoryUrlName);
      pieUrl.setDrillDocTitle(drillDocTitle);
      pieUrl.setTarget(target);

      plot.setURLGenerator(pieUrl);     

     
     


    }
    else{
      chart = ChartFactory.createPieChart3D(
          name, 
          (PieDataset)dataset,             // data
          true,                // include legend
          true,
          false
      );



      chart.setBackgroundPaint(color);

      TextTitle title = chart.getTitle();
      title.setToolTipText("A title tooltip!");


      PiePlot3D plot = (PiePlot3D) chart.getPlot();

      plot.setDarkerSides(true);
      plot.setStartAngle(290);
      plot.setDirection(Rotation.CLOCKWISE);
      plot.setForegroundAlpha(1.0f);
      plot.setDepthFactor(0.2);

      plot.setLabelFont(new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize()));
      plot.setCircular(false);
      plot.setLabelGap(0.02);
      plot.setNoDataMessage("No data available");



      //org.jfree.chart.renderer.category.BarRenderer renderer = new org.jfree.chart.renderer.category.AreaRenderer);

      MyPieUrlGenerator pieUrl=new MyPieUrlGenerator(rootUrl);
      pieUrl.setDocument_composition(document_composition);
      pieUrl.setCategoryUrlLabel(categoryUrlName);
      pieUrl.setDrillDocTitle(drillDocTitle);
      pieUrl.setTarget(target);

      plot.setURLGenerator(pieUrl);     


      if(percentage==false){
        plot.setLabelGenerator(new StandardPieSectionLabelGenerator(
            "{0} ({1})"));}
      else
      {
        plot.setLabelGenerator(new StandardPieSectionLabelGenerator(
        "{0} ({2})"));
      }
    }

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.