Package org.jfree.chart.title

Examples of org.jfree.chart.title.LegendTitle


        plot.setRangeAxis(1, _valueAxis2);
        plot.mapDatasetToRangeAxis(1, 1);

        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
        if (_showLegend) {
            chart.addLegend(new LegendTitle(plot)); // TODO test change
        }

        return chart;
    }
View Full Code Here


     */
    public void setShowLegend(boolean show) {
        _showLegend = show;
        if (_chart != null) {
            if (show) {
                _chart.addLegend(new LegendTitle(_chart.getPlot()));
            } else {
//                _chart.setLegend(null); // TODO test change
                _chart.removeLegend();
            }
        }
View Full Code Here

        plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
        plot.setOrientation(PlotOrientation.HORIZONTAL);
        JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
        if (_showLegend) {
            chart.addLegend(new LegendTitle(plot)); // TODO test change
        }

        return chart;
    }
View Full Code Here

    public void setShowLegend(boolean show) {
        _showLegend = show;
        if (_chart != null) {
            if (show) {
                for (JFreeChart chart : _chart) {
                    chart.addLegend(new LegendTitle(chart.getPlot())); // TODO test change
                }
            } else {
                for (JFreeChart chart : _chart) {
                    chart.removeLegend();
                }
View Full Code Here

    JFreeChart jfreechart = ChartFactory.createLineChart(chartTitle,
        rowName, colName, categoryDataset, PlotOrientation.VERTICAL,
        true, false, // tooltips
        false); // URLs

    LegendTitle legend = jfreechart.getLegend();

    legend.setItemFont(new Font("Dotum", Font.BOLD, 16));

    CategoryPlot plot = (CategoryPlot) jfreechart.getPlot();

    LineAndShapeRenderer render = (LineAndShapeRenderer) plot.getRenderer();
    render.setSeriesPaint(0, Color.RED);
View Full Code Here

  //gets first legend in the list
  public static LegendTitle getLegend(JFreeChart chart)
  {
    //i need to find the legend now.
    LegendTitle legend = null;
    List subTitles = chart.getSubtitles();
    Iterator iter = subTitles.iterator();
    while (iter.hasNext())
    {
      Object o = iter.next();
View Full Code Here

  private static RenderedImage renderLegend(ChartImage cd, Object c) throws CewolfException {
    try {
        JFreeChart chart = (JFreeChart) c;
      final int width = cd.getWidth();
      final int height = cd.getHeight();
      LegendTitle legend = getLegend(chart);
      boolean haslegend = true;
     
      // with JFreeChart v0.9.20, the only way to get a valid legend,
      // is either to retrieve it from the chart or to assign a new
      // one to the chart. In the case where the chart has no legend,
      // a new one must be assigned, but just for rendering. After, we
      // have to reset the legend to null in the chart.
      if (null == legend) {
        haslegend = false;
        legend = new LegendTitle(chart.getPlot());  
      }
      legend.setPosition(RectangleEdge.BOTTOM);
      BufferedImage bimage = ImageHelper.createImage(width, height);
      Graphics2D g = bimage.createGraphics();
      g.setColor(Color.white);
      g.fillRect(0, 0, width, height);
      legend.arrange(g,new RectangleConstraint(width,height));
       legend.draw(g, new Rectangle(width, height));
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
      JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bimage);
      param.setQuality(1.0f, true);
      encoder.encode(bimage, param);
View Full Code Here

 
    //gets first legend in the list
    public LegendTitle getLegend()
    {
      //i need to find the legend now.
      LegendTitle legend = null;
      List subTitles = chart.getSubtitles();
      Iterator iter = subTitles.iterator();
      while (iter.hasNext())
      {
        Object o = iter.next();
View Full Code Here

                chart.setBackgroundPaint(paint);
            }
            if (showLegend)
            {

                LegendTitle legend = this.getLegend();
                switch (legendAnchor)
                {
                    case ANCHOR_NORTH :
                        legend.setPosition(RectangleEdge.TOP);
                        break;
                    case ANCHOR_WEST :
                      legend.setPosition(RectangleEdge.RIGHT);
                        break;
                    case ANCHOR_EAST :
                      legend.setPosition(RectangleEdge.LEFT);
                        break;
                    default :
                      legend.setPosition(RectangleEdge.BOTTOM);
                }
            }
            else
            {
              this.removeLegend();
View Full Code Here

    /*LabelBlock titleBlock = new LabelBlock("Legend Items:",
        new Font("SansSerif", Font.BOLD, 12));
    titleBlock.setPadding(5, 5, 5, 5);
    wrapper.add(titleBlock, RectangleEdge.TOP);*/

    LegendTitle legend = new LegendTitle(chart.getPlot());
    BlockContainer items = legend.getItemContainer();
    if(styleLegend!=null && styleLegend.getFont()!=null){
      legend.setItemFont(new Font(styleLegend.getFontName(), Font.BOLD, styleLegend.getSize()));
    }
   
    items.setPadding(2, 5, 5, 2);
    wrapper.add(items);
    legend.setWrapper(wrapper);

    if(legendPosition.equalsIgnoreCase("bottom")) legend.setPosition(RectangleEdge.BOTTOM);
    else if(legendPosition.equalsIgnoreCase("left")) legend.setPosition(RectangleEdge.LEFT);
    else if(legendPosition.equalsIgnoreCase("right")) legend.setPosition(RectangleEdge.RIGHT);
    else if(legendPosition.equalsIgnoreCase("top")) legend.setPosition(RectangleEdge.TOP);
    else legend.setPosition(RectangleEdge.BOTTOM);
   
    legend.setHorizontalAlignment(HorizontalAlignment.CENTER);
    chart.addSubtitle(legend);
   
    }
View Full Code Here

TOP

Related Classes of org.jfree.chart.title.LegendTitle

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.