Package org.jfree.chart

Examples of org.jfree.chart.LegendItemSource


        // remove the temp 'Area' dataset from the legend
        LegendItemCollection legendItemsOld = confidencePlot.getLegendItems();
        final LegendItemCollection legendItemsNew = new LegendItemCollection();
        legendItemsNew.add(legendItemsOld.get(0));

        LegendItemSource source = new LegendItemSource() {
            LegendItemCollection lic = new LegendItemCollection();

            {
                lic.addAll(legendItemsNew);
            }
View Full Code Here


            return;
        }


    // prepare legend
    LegendItemSource lis = new LegendItemSource() {     
      LegendItemCollection lic = new LegendItemCollection();     
      public LegendItemCollection getLegendItems() {
        return lic;
      }
    };
   
    double minDomainAxis = Double.MAX_VALUE;
    double maxDomainAxis = Double.NEGATIVE_INFINITY;   
    double minNumberOfPoints = Double.MAX_VALUE;
    double minDomainAxisSeries, maxDomainAxisSeries, numberOfSeriesPoints;
    boolean anyBarRendered = false;
   
    // prepare series
    for (int i=0; i<numberOfSeries; i++){
      minDomainAxisSeries = series.get(i).get(0).getX();
      maxDomainAxisSeries = series.get(i).get(series.get(i).getSize()-1).getX();
      numberOfSeriesPoints = series.get(i).getSize();
     
      if(minDomainAxisSeries<minDomainAxis) minDomainAxis = minDomainAxisSeries;
      if(maxDomainAxisSeries>maxDomainAxis) maxDomainAxis = maxDomainAxisSeries;
      if(numberOfSeriesPoints<minNumberOfPoints) minNumberOfPoints = numberOfSeriesPoints;

            if(renderers.get(i) instanceof DeviationRenderer){
        YIntervalSeries currentIntervalSeries = new YIntervalSeries(names.get(i));
       
        // add points
        XYIntervalItem item;
        for(int j=0; j<series.get(i).getSize(); j++){
          item = (XYIntervalItem) series.get(i).get(j);         
          currentIntervalSeries.add(item.getX(),item.getY(),item.getyDownDeviation(),item.getyUpDeviation());
        }
       
        // add series
        YIntervalSeriesCollection data = new YIntervalSeriesCollection();
        data.addSeries(currentIntervalSeries);
        chart.getXYPlot().setDataset(i,data);
            } else {
        if(renderers.get(i) instanceof XYBarRenderer) anyBarRendered = true;
        // init series
        XYSeries currentSeries = new XYSeries(names.get(i));
       
        // add points
        for(int j=0; j<series.get(i).getSize(); j++){
          currentSeries.add(series.get(i).get(j).getX(),series.get(i).get(j).getY());
        }
       
        // add series
        chart.getXYPlot().setDataset(i, new XYSeriesCollection(currentSeries));
            }
     
      // set stroke
      renderers.get(i).setSeriesStroke(0, strokes.get(i));

      // set color
      renderers.get(i).setSeriesPaint(0, colors.get(i));

            // set tooltip generator
            renderers.get(i).setBaseToolTipGenerator(toolTipGenerator);

            // add renderer
            chart.getXYPlot().setRenderer(i,renderers.get(i));

      // add legend item
      LegendItem legendItem = new LegendItem(names.get(i));
      legendItem.setLabelFont(new Font(Font.SANS_SERIF,Font.PLAIN,11));
      legendItem.setLabelPaint(Color.darkGray);
      legendItem.setFillPaint(colors.get(i));
      lis.getLegendItems().add(legendItem);
    }

    // finalize legend
        if (showLegend) {
            chart.addLegend(new LegendTitle(lis));
View Full Code Here

TOP

Related Classes of org.jfree.chart.LegendItemSource

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.