Java 类org.jfree.chart.title.LegendTitle 实例源码

项目:AgentWorkbench    文件:ChartTab.java   
/**
 * Exports the current chart as an image.
 * @param width The width of the image
 * @param height The height of the image
 * @param hideLegend If true, the image will not contain the legend
 * @return The image
 */
public BufferedImage exportAsImage(int width, int height, boolean hideLegend){

    LegendTitle legend = null;
    if(hideLegend){
        // Remove legend while exporting the image
        legend = this.chartPanel.getChart().getLegend();
        this.chartPanel.getChart().removeLegend();
    }

    BufferedImage thumb = this.chartPanel.getChart().createBufferedImage(width, height, 600, 400, null);

    if(hideLegend){
        // If the legend was removed, add it after exporting the image 
        this.chartPanel.getChart().addLegend(legend);
    }
    return thumb;
}
项目:rapidminer    文件:JFreeChartPlotEngine.java   
private void legendPositionChanged(LegendPosition legendPosition) {
    JFreeChart chart = getCurrentChart();
    if (chart != null) {
        LegendTitle legend = chart.getLegend();
        RectangleEdge position = legendPosition.getPosition();
        if (legend != null) {
            if (position != null) {
                legend.setPosition(position);
            } else {
                while (chart.getLegend() != null) {
                    chart.removeLegend();
                }
            }
        } else {
            if (position != null) {
                resetLegend();
            }
        }
    }
}
项目:rapidminer    文件:ROCChartPlotter.java   
public void paintDeviationChart(Graphics graphics, int width, int height) {
    prepareData();

    JFreeChart chart = createChart(this.dataset);

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // legend settings
    LegendTitle legend = chart.getLegend();
    if (legend != null) {
        legend.setPosition(RectangleEdge.TOP);
        legend.setFrame(BlockBorder.NONE);
        legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
    }

    Rectangle2D drawRect = new Rectangle2D.Double(0, 0, width, height);
    chart.draw((Graphics2D) graphics, drawRect);
}
项目:parabuild-ci    文件:JFreeChart.java   
/**
 * Returns the nth legend for a chart, or <code>null</code>.
 * 
 * @param index  the legend index (zero-based).
 * 
 * @return The legend (possibly <code>null</code>).
 * 
 * @see #addLegend(LegendTitle)
 */
public LegendTitle getLegend(int index) {
    int seen = 0;
    Iterator iterator = this.subtitles.iterator();
    while (iterator.hasNext()) {
        Title subtitle = (Title) iterator.next();
        if (subtitle instanceof LegendTitle) {
            if (seen == index) {
                return (LegendTitle) subtitle;
            }
            else {
                seen++;   
            }
        }
    }
    return null;        
}
项目:openvisualtraceroute    文件:GanttPanel.java   
/**
 * Update legend
 */
private void updateLegend() {
    _chart.removeLegend();
    final LegendTitle legend = new LegendTitle(() -> {
        final LegendItemCollection collection = new LegendItemCollection();
        if (_currentMode == DisplayMode.TIME) {
            collection.add(new LegendItem(Legend.LATENCY.label, null, null, null, new Rectangle(30, 20), Legend.LATENCY.color));
            if (_dnsLookup && _services.isEmbeddedTRAvailable() && !Env.INSTANCE.isUseOSTraceroute()) {
                collection.add(new LegendItem(Legend.DNS.label, null, null, null, new Rectangle(30, 20), Legend.DNS.color));
            }
        } else {
            collection.add(new LegendItem(Legend.DISTANCE.label, Legend.DISTANCE.color));
        }
        return collection;
    });
    legend.setPosition(RectangleEdge.BOTTOM);
    _chart.addLegend(legend);
}
项目:ccu-historian    文件:JFreeChart.java   
/**
 * Returns the nth legend for a chart, or <code>null</code>.
 *
 * @param index  the legend index (zero-based).
 *
 * @return The legend (possibly <code>null</code>).
 *
 * @see #addLegend(LegendTitle)
 */
public LegendTitle getLegend(int index) {
    int seen = 0;
    Iterator iterator = this.subtitles.iterator();
    while (iterator.hasNext()) {
        Title subtitle = (Title) iterator.next();
        if (subtitle instanceof LegendTitle) {
            if (seen == index) {
                return (LegendTitle) subtitle;
            }
            else {
                seen++;
            }
        }
    }
    return null;
}
项目:jfreechart    文件:JFreeChart.java   
/**
 * Returns the nth legend for a chart, or {@code null}.
 *
 * @param index  the legend index (zero-based).
 *
 * @return The legend (possibly {@code null}).
 *
 * @see #addLegend(LegendTitle)
 */
public LegendTitle getLegend(int index) {
    int seen = 0;
    Iterator iterator = this.subtitles.iterator();
    while (iterator.hasNext()) {
        Title subtitle = (Title) iterator.next();
        if (subtitle instanceof LegendTitle) {
            if (seen == index) {
                return (LegendTitle) subtitle;
            }
            else {
                seen++;
            }
        }
    }
    return null;
}
项目:aya-lang    文件:JFreeChart.java   
/**
 * Returns the nth legend for a chart, or <code>null</code>.
 *
 * @param index  the legend index (zero-based).
 *
 * @return The legend (possibly <code>null</code>).
 *
 * @see #addLegend(LegendTitle)
 */
public LegendTitle getLegend(int index) {
    int seen = 0;
    Iterator iterator = this.subtitles.iterator();
    while (iterator.hasNext()) {
        Title subtitle = (Title) iterator.next();
        if (subtitle instanceof LegendTitle) {
            if (seen == index) {
                return (LegendTitle) subtitle;
            }
            else {
                seen++;
            }
        }
    }
    return null;
}
项目:rapidminer-studio    文件:JFreeChartPlotEngine.java   
private void legendPositionChanged(LegendPosition legendPosition) {
    JFreeChart chart = getCurrentChart();
    if (chart != null) {
        LegendTitle legend = chart.getLegend();
        RectangleEdge position = legendPosition.getPosition();
        if (legend != null) {
            if (position != null) {
                legend.setPosition(position);
            } else {
                while (chart.getLegend() != null) {
                    chart.removeLegend();
                }
            }
        } else {
            if (position != null) {
                resetLegend();
            }
        }
    }
}
项目:rapidminer-studio    文件:ROCChartPlotter.java   
public void paintDeviationChart(Graphics graphics, int width, int height) {
    prepareData();

    JFreeChart chart = createChart(this.dataset);

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // legend settings
    LegendTitle legend = chart.getLegend();
    if (legend != null) {
        legend.setPosition(RectangleEdge.TOP);
        legend.setFrame(BlockBorder.NONE);
        legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
    }

    Rectangle2D drawRect = new Rectangle2D.Double(0, 0, width, height);
    chart.draw((Graphics2D) graphics, drawRect);
}
项目:bamboobsc    文件:CommonPieChartAction.java   
private void fillChart(String title, List<String> names, 
        List<String> colors, List<Float> values) throws Exception {
    DefaultPieDataset data=new DefaultPieDataset();
    for (int ix=0; ix<names.size(); ix++) {
        data.setValue( names.get(ix), values.get(ix) );
    }
       this.chart=ChartFactory.createPieChart3D(
            title, 
            data, 
            true,
            true, 
            false);
       LegendTitle legend=this.chart.getLegend();
       legend.setItemFont(new Font("", Font.TRUETYPE_FONT, 9) );
       PiePlot plot=(PiePlot)this.chart.getPlot();
       plot.setCircular(true);
       plot.setBackgroundAlpha(0.9f);       
       plot.setForegroundAlpha(0.5f);
       plot.setLabelFont(new Font("", Font.TRUETYPE_FONT, 9) );
       this.setPlotColor( plot, names, colors );
       this.chart.setTitle(new TextTitle(title, new Font("", Font.TRUETYPE_FONT, 9) ) );        
}
项目:vizardous    文件:CorrelationChart2D.java   
/** 
 * TODO Documentation
 * 
 * @param chart
 * @return
 */
protected JFreeChart styleChart(JFreeChart chart) {
    chart.setBackgroundPaint(Color.white);
       LegendTitle legend = chart.getLegend();
       legend.setPosition(RectangleEdge.RIGHT);
       legend.setVisible(false);

       final CategoryPlot plot = chart.getCategoryPlot();
       plot.setBackgroundPaint(Color.white);
       plot.setRangeGridlinePaint(Color.lightGray);      

       final LineAndShapeRenderer renderer = new LineAndShapeRenderer();
       renderer.setSeriesLinesVisible(0,true);
       renderer.setSeriesShapesVisible(1, true);
       renderer.setBaseLinesVisible(true);
       renderer.setBaseShapesFilled(true);
       plot.setDomainGridlinesVisible(true);
       plot.setDomainGridlinePaint(Color.lightGray);
       plot.setRenderer(renderer);
       // customise the range axis...
       final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
       rangeAxis.setAutoRangeIncludesZero(false);
       rangeAxis.setStandardTickUnits(rangeAxis.getStandardTickUnits());

       return chart;
}
项目:vizardous    文件:DistributionChart2D.java   
/**
 * TODO Documentation
 * 
 * @param chart
 * @return
 */
public JFreeChart styleChart(JFreeChart chart) {
    chart.setBackgroundPaint(Color.white);
       LegendTitle legend = chart.getLegend();
       legend.setPosition(RectangleEdge.RIGHT);
       legend.setVisible(false);

       XYPlot chartPlot = chart.getXYPlot();
       chartPlot.setBackgroundPaint(Color.white);
       chartPlot.setForegroundAlpha(0.7F);

       XYItemRenderer brRenderer = chartPlot.getRenderer();
       chartPlot.setDomainGridlinesVisible(true);
       chartPlot.setDomainGridlinePaint(Color.GRAY);
       chartPlot.setRangeGridlinePaint(Color.GRAY);
       brRenderer.setSeriesPaint(0, new Color(0,0,139));

       // customise the range axis...
       final ValueAxis domainAxis = chartPlot.getDomainAxis();
       domainAxis.setLowerMargin(0.0);

       return chart;
}
项目:HTML5_WebSite    文件:SpiderWebChartDemo1.java   
/**
   * Creates a sample chart.
   * 
   * @param dataset  the dataset.
   * 
   * @return The chart.
   */
  protected JFreeChart createChart(CategoryDataset dataset) {

      // get a reference to the plot for further customisation...
      SOCRSpiderWebPlot plot = new SOCRSpiderWebPlot(dataset);
      JFreeChart chart = new JFreeChart(
          chartTitle, TextTitle.DEFAULT_FONT, plot, false
      );

LegendTitle legend = new LegendTitle(plot);
      legend.setPosition(RectangleEdge.BOTTOM);

//renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());
      chart.addSubtitle(legend);   

    setCategorySummary(dataset);
    if (legendPanelOn)
        chart.removeLegend();
      return chart;

  }
项目:HTML5_WebSite    文件:JFreeChart.java   
/**
 * Returns the nth legend for a chart, or <code>null</code>.
 *
 * @param index  the legend index (zero-based).
 *
 * @return The legend (possibly <code>null</code>).
 *
 * @see #addLegend(LegendTitle)
 */
public LegendTitle getLegend(int index) {
    int seen = 0;
    Iterator iterator = this.subtitles.iterator();
    while (iterator.hasNext()) {
        Title subtitle = (Title) iterator.next();
        if (subtitle instanceof LegendTitle) {
            if (seen == index) {
                return (LegendTitle) subtitle;
            }
            else {
                seen++;
            }
        }
    }
    return null;
}
项目:populus    文件:JFreeChart.java   
/**
 * Returns the nth legend for a chart, or <code>null</code>.
 *
 * @param index  the legend index (zero-based).
 *
 * @return The legend (possibly <code>null</code>).
 *
 * @see #addLegend(LegendTitle)
 */
public LegendTitle getLegend(int index) {
    int seen = 0;
    Iterator iterator = this.subtitles.iterator();
    while (iterator.hasNext()) {
        Title subtitle = (Title) iterator.next();
        if (subtitle instanceof LegendTitle) {
            if (seen == index) {
                return (LegendTitle) subtitle;
            }
            else {
                seen++;
            }
        }
    }
    return null;
}
项目:PI    文件:JFreeChart.java   
/**
 * Returns the nth legend for a chart, or <code>null</code>.
 *
 * @param index  the legend index (zero-based).
 *
 * @return The legend (possibly <code>null</code>).
 *
 * @see #addLegend(LegendTitle)
 */
public LegendTitle getLegend(int index) {
    int seen = 0;
    Iterator iterator = this.subtitles.iterator();
    while (iterator.hasNext()) {
        Title subtitle = (Title) iterator.next();
        if (subtitle instanceof LegendTitle) {
            if (seen == index) {
                return (LegendTitle) subtitle;
            }
            else {
                seen++;
            }
        }
    }
    return null;
}
项目:nabs    文件:JFreeChart.java   
/**
 * Returns the nth legend for a chart, or <code>null</code>.
 * 
 * @param index  the legend index (zero-based).
 * 
 * @return The legend (possibly <code>null</code>).
 * 
 * @see #addLegend(LegendTitle)
 */
public LegendTitle getLegend(int index) {
    int seen = 0;
    Iterator iterator = this.subtitles.iterator();
    while (iterator.hasNext()) {
        Title subtitle = (Title) iterator.next();
        if (subtitle instanceof LegendTitle) {
            if (seen == index) {
                return (LegendTitle) subtitle;
            }
            else {
                seen++;   
            }
        }
    }
    return null;        
}
项目:ECG-Viewer    文件:JFreeChart.java   
/**
 * Returns the nth legend for a chart, or <code>null</code>.
 *
 * @param index  the legend index (zero-based).
 *
 * @return The legend (possibly <code>null</code>).
 *
 * @see #addLegend(LegendTitle)
 */
public LegendTitle getLegend(int index) {
    int seen = 0;
    Iterator iterator = this.subtitles.iterator();
    while (iterator.hasNext()) {
        Title subtitle = (Title) iterator.next();
        if (subtitle instanceof LegendTitle) {
            if (seen == index) {
                return (LegendTitle) subtitle;
            }
            else {
                seen++;
            }
        }
    }
    return null;
}
项目:astor    文件:JFreeChart.java   
/**
 * Returns the nth legend for a chart, or <code>null</code>.
 *
 * @param index  the legend index (zero-based).
 *
 * @return The legend (possibly <code>null</code>).
 *
 * @see #addLegend(LegendTitle)
 */
public LegendTitle getLegend(int index) {
    int seen = 0;
    Iterator iterator = this.subtitles.iterator();
    while (iterator.hasNext()) {
        Title subtitle = (Title) iterator.next();
        if (subtitle instanceof LegendTitle) {
            if (seen == index) {
                return (LegendTitle) subtitle;
            }
            else {
                seen++;
            }
        }
    }
    return null;
}
项目:opensim-gui    文件:JFreeChart.java   
/**
 * Returns the nth legend for a chart, or <code>null</code>.
 * 
 * @param index  the legend index (zero-based).
 * 
 * @return The legend (possibly <code>null</code>).
 */
public LegendTitle getLegend(int index) {
    int seen = 0;
    Iterator iterator = this.subtitles.iterator();
    while (iterator.hasNext()) {
        Title subtitle = (Title) iterator.next();
        if (subtitle instanceof LegendTitle) {
            if (seen == index) {
                return (LegendTitle) subtitle;
            }
            else {
                seen++;   
            }
        }
    }
    return null;        
}
项目:svarog    文件:EvokedPotentialChart.java   
protected void removeItemFromLegend(int itemToRemove, JFreeChart chart) {

        LegendItemCollection legendItems = chart.getPlot().getLegendItems();
        final LegendItemCollection newLegendItems = new LegendItemCollection();

        for (int i = 0; i < legendItems.getItemCount(); i++) {
            if (itemToRemove != i)
                newLegendItems.add(legendItems.get(i));
        }

        LegendItemSource source = new LegendItemSource() {

            @Override
            public LegendItemCollection getLegendItems() {
                return newLegendItems;
            }
        };

        chart.removeLegend();
        chart.addLegend(new LegendTitle(source));
    }
项目:group-five    文件:JFreeChart.java   
/**
 * Returns the nth legend for a chart, or <code>null</code>.
 *
 * @param index  the legend index (zero-based).
 *
 * @return The legend (possibly <code>null</code>).
 *
 * @see #addLegend(LegendTitle)
 */
public LegendTitle getLegend(int index) {
    int seen = 0;
    Iterator iterator = this.subtitles.iterator();
    while (iterator.hasNext()) {
        Title subtitle = (Title) iterator.next();
        if (subtitle instanceof LegendTitle) {
            if (seen == index) {
                return (LegendTitle) subtitle;
            }
            else {
                seen++;
            }
        }
    }
    return null;
}
项目:manydesigns.cn    文件:JFreeChart.java   
/**
 * Returns the nth legend for a chart, or <code>null</code>.
 * 
 * @param index the legend index (zero-based).
 * @return The legend (possibly <code>null</code>).
 * @see #addLegend(LegendTitle)
 */
public LegendTitle getLegend(int index) {
    int seen = 0;
    Iterator iterator = this.subtitles.iterator();
    while (iterator.hasNext()) {
        Title subtitle = (Title) iterator.next();
        if (subtitle instanceof LegendTitle) {
            if (seen == index) {
                return (LegendTitle) subtitle;
            } else {
                seen++;
            }
        }
    }
    return null;
}
项目:rapidminer-5    文件:JFreeChartPlotEngine.java   
/**
 * Creates {@link LegendTitle}s for all dimensions from the PlotConfiguration of this Plotter2D.
 * Expects that all {@link ValueSource} s in the provided PlotConfiguration use the same
 * {@link DimensionConfig} s.
 */
private List<LegendTitle> createLegendTitles() {
    List<LegendTitle> legendTitles = new LinkedList<LegendTitle>();
    LegendConfiguration legendConfiguration = plotInstance.getCurrentPlotConfigurationClone().getLegendConfiguration();

    LegendTitle legendTitle = new SmartLegendTitle(this, new FlowArrangement(HorizontalAlignment.CENTER, VerticalAlignment.CENTER, 30, 2), new ColumnArrangement(
            HorizontalAlignment.LEFT, VerticalAlignment.CENTER, 0, 2));
    legendTitle.setItemPaint(legendConfiguration.getLegendFontColor());

    RectangleEdge position = legendConfiguration.getLegendPosition().getPosition();
    if (position == null) {
        return legendTitles;
    }
    legendTitle.setPosition(position);

    if (legendConfiguration.isShowLegendFrame()) {
        legendTitle.setFrame(new BlockBorder(legendConfiguration.getLegendFrameColor()));
    }
    ColoredBlockContainer wrapper = new ColoredBlockContainer(legendConfiguration.getLegendBackgroundColor());
    wrapper.add(legendTitle.getItemContainer());
    wrapper.setPadding(3, 3, 3, 3);
    legendTitle.setWrapper(wrapper);

    legendTitles.add(legendTitle);
    return legendTitles;
}
项目:rapidminer-5    文件:JFreeChartPlotEngine.java   
private void legendPositionChanged(LegendPosition legendPosition) {
    JFreeChart chart = getCurrentChart();
    if (chart != null) {
        LegendTitle legend = chart.getLegend();
        RectangleEdge position = legendPosition.getPosition();
        if (legend != null) {
            if (position != null) {
                legend.setPosition(position);
            } else {
                while (chart.getLegend() != null) {
                    chart.removeLegend();
                }
            }
        } else {
            if (position != null) {
                resetLegend();
            }
        }
    }
}
项目:rapidminer-5    文件:ROCChartPlotter.java   
public void paintDeviationChart(Graphics graphics, int width, int height) {      
    prepareData();

    JFreeChart chart = createChart(this.dataset);

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // legend settings
    LegendTitle legend = chart.getLegend();
    if (legend != null) {
        legend.setPosition(RectangleEdge.TOP);
        legend.setFrame(BlockBorder.NONE);
        legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
    }

    Rectangle2D drawRect = new Rectangle2D.Double(0, 0, width, height);
    chart.draw((Graphics2D)graphics, drawRect);
}
项目:aorra    文件:ErrorIndicatorLegend.java   
public static LegendTitle createLegend() {
  final LegendItemCollection legendItems = new LegendItemCollection();
  FontRenderContext frc = new FontRenderContext(null, true, true);
  Font legenfont = new Font(Font.SANS_SERIF, Font.PLAIN, 12);
  GlyphVector gv = legenfont.createGlyphVector(frc, new char[] {'I', 'I'});
  Shape shape = gv.getVisualBounds();
  Rectangle2D bounds = shape.getBounds2D();
  {
    LegendItem li = new LegendItem("Standard error", null, null, null,
        new ErrorIndicator(bounds), new BasicStroke(), ErrorIndicator.ERROR_INDICATOR_COLOR);
    li.setLabelFont(legenfont);
    legendItems.add(li);
  }
  LegendTitle legend = new LegendTitle(new LegendItemSource() {
    @Override
    public LegendItemCollection getLegendItems() {
      return legendItems;
    }});
  legend.setPosition(RectangleEdge.BOTTOM);
  legend.setMargin(new RectangleInsets(0,30,0,0));
  legend.setPadding(RectangleInsets.ZERO_INSETS);
  legend.setLegendItemGraphicPadding(new RectangleInsets(0,20,0,0));
  legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
  return legend;
}
项目:aorra    文件:LandPracticeSystems.java   
private LegendTitle createLegend() {
  final LegendItemCollection legendItems = new LegendItemCollection();
  FontRenderContext frc = new FontRenderContext(null, true, true);
  GlyphVector gv = LEGEND_FONT.createGlyphVector(frc, new char[] {'X'});
  Shape shape = gv.getGlyphVisualBounds(0);
  for(Pair<String, Color> p : getLegend()) {
    LegendItem li = new LegendItem(p.getLeft(), null, null, null, shape, p.getRight());
    li.setLabelFont(LEGEND_FONT);
    legendItems.add(li);
  }
  LegendTitle legend = new LegendTitle(new LegendItemSource() {
    @Override
    public LegendItemCollection getLegendItems() {
      return legendItems;
    }});
  legend.setPosition(RectangleEdge.BOTTOM);
  return legend;
}
项目:nmonvisualizer    文件:BaseChartBuilder.java   
protected final void addLegend() {
    if (chart == null) {
        throw new IllegalStateException("initChart() must be called first");
    }

    LegendTitle legend = new LegendTitle(chart.getPlot());
    legend.setItemFont(LEGEND_FONT);
    legend.setBorder(0, 0, 0, 0);
    legend.setBackgroundPaint(Color.WHITE);
    legend.setPosition(RectangleEdge.BOTTOM);

    RectangleInsets padding = new RectangleInsets(5, 5, 5, 5);
    legend.setItemLabelPadding(padding);

    chart.addLegend(legend);
}
项目:jeql    文件:BaseChart.java   
public void writeChart(String filename, int x, int y)
        throws Exception
    {   
        JFreeChart chart = createChart();
        if (param.backgroundPaint != null) chart.getPlot().setBackgroundPaint(param.backgroundPaint);
        //TODO: handle legends with series titles 
        chart.removeLegend();

//  plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
//  plot.setNoDataMessage("No data available");

        if (param.subtitle != null)
            chart.addSubtitle(new TextTitle(param.subtitle));

                if (param.showLegend)
                  chart.addLegend(new LegendTitle(chart.getPlot()));

        String fileExt = filenameExtension(filename);
        if (fileExt.equalsIgnoreCase("jpg") || fileExt.equalsIgnoreCase("jpeg"))
            ChartUtilities.saveChartAsJPEG(new File(filename), chart, x, y);        
        else
            ChartUtilities.saveChartAsPNG(new File(filename), chart, x, y);

    }
项目:buffer_bci    文件:JFreeChart.java   
/**
 * Returns the nth legend for a chart, or <code>null</code>.
 *
 * @param index  the legend index (zero-based).
 *
 * @return The legend (possibly <code>null</code>).
 *
 * @see #addLegend(LegendTitle)
 */
public LegendTitle getLegend(int index) {
    int seen = 0;
    Iterator iterator = this.subtitles.iterator();
    while (iterator.hasNext()) {
        Title subtitle = (Title) iterator.next();
        if (subtitle instanceof LegendTitle) {
            if (seen == index) {
                return (LegendTitle) subtitle;
            }
            else {
                seen++;
            }
        }
    }
    return null;
}
项目:buffer_bci    文件:JFreeChart.java   
/**
 * Returns the nth legend for a chart, or <code>null</code>.
 *
 * @param index  the legend index (zero-based).
 *
 * @return The legend (possibly <code>null</code>).
 *
 * @see #addLegend(LegendTitle)
 */
public LegendTitle getLegend(int index) {
    int seen = 0;
    Iterator iterator = this.subtitles.iterator();
    while (iterator.hasNext()) {
        Title subtitle = (Title) iterator.next();
        if (subtitle instanceof LegendTitle) {
            if (seen == index) {
                return (LegendTitle) subtitle;
            }
            else {
                seen++;
            }
        }
    }
    return null;
}
项目:proyecto-teoria-control-utn-frro    文件:JFreeChart.java   
/**
 * Returns the nth legend for a chart, or <code>null</code>.
 *
 * @param index  the legend index (zero-based).
 *
 * @return The legend (possibly <code>null</code>).
 *
 * @see #addLegend(LegendTitle)
 */
public LegendTitle getLegend(int index) {
    int seen = 0;
    Iterator iterator = this.subtitles.iterator();
    while (iterator.hasNext()) {
        Title subtitle = (Title) iterator.next();
        if (subtitle instanceof LegendTitle) {
            if (seen == index) {
                return (LegendTitle) subtitle;
            }
            else {
                seen++;
            }
        }
    }
    return null;
}
项目:ezScrum    文件:ScheduleReport.java   
private void setAttribute(JFreeChart chart) {
    // 圖案與文字的間隔
    LegendTitle legend = chart.getLegend();
    legend.setBorder(1, 1, 1, 1);

    CategoryPlot plot = chart.getCategoryPlot();
    // 設定WorkItem的屬性
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); // 字體角度
    domainAxis.setTickLabelFont(new Font("新細明體", Font.TRUETYPE_FONT, 12)); // 字體

    // 設定Date的屬性
    DateAxis da = (DateAxis) plot.getRangeAxis(0);
    setDateAxis(da);

    // 設定實體的顯示名稱
    CategoryItemRenderer render = plot.getRenderer(0);
    DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    CategoryItemLabelGenerator generator = new IntervalCategoryItemLabelGenerator(
            "{3} ~ {4}", format);
    render.setBaseItemLabelGenerator(generator);
    render.setBaseItemLabelPaint(Color.BLUE);
    render.setBaseItemLabelsVisible(true);
    render.setBaseItemLabelFont(new Font("黑體", Font.TRUETYPE_FONT, 8));
    render.setSeriesPaint(0, Color.RED);
}
项目:Memetic-Algorithm-for-TSP    文件:JFreeChart.java   
/**
 * Returns the nth legend for a chart, or <code>null</code>.
 *
 * @param index  the legend index (zero-based).
 *
 * @return The legend (possibly <code>null</code>).
 *
 * @see #addLegend(LegendTitle)
 */
public LegendTitle getLegend(int index) {
    int seen = 0;
    Iterator iterator = this.subtitles.iterator();
    while (iterator.hasNext()) {
        Title subtitle = (Title) iterator.next();
        if (subtitle instanceof LegendTitle) {
            if (seen == index) {
                return (LegendTitle) subtitle;
            }
            else {
                seen++;
            }
        }
    }
    return null;
}
项目:JRLib    文件:AbstractChart.java   
protected void formatChart() {
    format.getColors().reset();
    chart.setBackgroundPaint(format.getBackgroundColor());

    Plot plot = chart.getPlot();
    formatPlot(plot);

    if(plot instanceof CategoryPlot) {
        CategoryPlot cPlot = (CategoryPlot) plot;
        formatAxis(cPlot.getDomainAxis());
        formatAxis(cPlot.getRangeAxis());
    }

    LegendTitle legend = chart.getLegend();
    if(legend != null)
        formatLegend(legend);
}
项目:JRLib    文件:AbstractChart.java   
protected void formatChart() {
    format.getColors().reset();
    chart.setBackgroundPaint(format.getBackgroundColor());

    Plot plot = chart.getPlot();
    formatPlot(plot);

    if(plot instanceof CategoryPlot) {
        CategoryPlot cPlot = (CategoryPlot) plot;
        formatAxisColors(cPlot.getDomainAxis());
        formatAxisColors(cPlot.getRangeAxis());
    }

    LegendTitle legend = chart.getLegend();
    if(legend != null)
        formatLegend(legend);
}
项目:caintegrator    文件:JFreeChartIKMPlottermpl.java   
public static void createLegend(JFreeChart kmPlot, List<KMPlotPointSeriesSet> plotPointSeriesSetCollection) {
    LegendTitle legend = kmPlot.getLegend();
    LegendItemSource[] sources = new LegendItemSource[1];
    KMLegendItemSource legendSrc = new KMLegendItemSource();
    Comparator<KMPlotPointSeriesSet> nameComparator = new Comparator<KMPlotPointSeriesSet>() {
        public int compare(KMPlotPointSeriesSet series1, KMPlotPointSeriesSet series2) {
            return series1.getName().compareToIgnoreCase(series2.getName());
        }
    };
    Collections.sort(plotPointSeriesSetCollection, nameComparator);

    LegendItem item ;
    for (KMPlotPointSeriesSet plotPointSeries : plotPointSeriesSetCollection) {
        Color color = plotPointSeries.getColor();
        String title = plotPointSeries.getLegendTitle() + " (" + plotPointSeries.getGroupSize() + ")";
        item = new LegendItem(title, null, null, null, new Rectangle2D.Double(2,2,10,10), color);
        legendSrc.addLegendItem(item);
    }
    sources[0] = legendSrc;
    legend.setSources(sources);
}
项目:rapidminer    文件:JFreeChartPlotEngine.java   
/**
 * Creates {@link LegendTitle}s for all dimensions from the PlotConfiguration of this Plotter2D.
 * Expects that all {@link ValueSource} s in the provided PlotConfiguration use the same
 * {@link DimensionConfig} s.
 */
private List<LegendTitle> createLegendTitles() {
    List<LegendTitle> legendTitles = new LinkedList<LegendTitle>();
    LegendConfiguration legendConfiguration = plotInstance.getCurrentPlotConfigurationClone().getLegendConfiguration();

    LegendTitle legendTitle = new SmartLegendTitle(this, new FlowArrangement(HorizontalAlignment.CENTER,
            VerticalAlignment.CENTER, 30, 2), new ColumnArrangement(HorizontalAlignment.LEFT, VerticalAlignment.CENTER,
            0, 2));
    legendTitle.setItemPaint(legendConfiguration.getLegendFontColor());

    RectangleEdge position = legendConfiguration.getLegendPosition().getPosition();
    if (position == null) {
        return legendTitles;
    }
    legendTitle.setPosition(position);

    if (legendConfiguration.isShowLegendFrame()) {
        legendTitle.setFrame(new BlockBorder(legendConfiguration.getLegendFrameColor()));
    }
    ColoredBlockContainer wrapper = new ColoredBlockContainer(legendConfiguration.getLegendBackgroundColor());
    wrapper.add(legendTitle.getItemContainer());
    wrapper.setPadding(3, 3, 3, 3);
    legendTitle.setWrapper(wrapper);

    legendTitles.add(legendTitle);
    return legendTitles;
}