Package org.jfree.chart.title

Examples of org.jfree.chart.title.LegendTitle


     * the chart edges. 
     * @param position legend position, for example RectangleEdge.BOTTOM
     */
    public void setLegendPosition(RectangleEdge position) {
        if (m_chart != null) {
            LegendTitle legend = m_chart.getLegend();
            legend.setPosition(position);
        } else {
            throw new IllegalStateException("Can not set legend position before " +
                "the chart is drawn. Call jplot() method first!");
        }
    }
View Full Code Here


    if (isAntiAlias() == false)
    {
      chart.setAntiAlias(false);
    }

    final LegendTitle chLegend = chart.getLegend();
    if (chLegend != null)
    {
      final RectangleEdge loc = translateEdge(getLegendLocation().toLowerCase());
      if (loc != null)
      {
        chLegend.setPosition(loc);
      }
      if (getLegendFont() != null)
      {
        chLegend.setItemFont(Font.decode(getLegendFont()));
      }
      if (!isDrawLegendBorder())
      {
        chLegend.setBorder(BlockBorder.NONE);
      }
      if (getLegendBackgroundColor() != null)
      {
        chLegend.setBackgroundPaint(getLegendBackgroundColor());
      }
      if (getLegendTextColor() != null)
      {
        chLegend.setItemPaint(getLegendTextColor());
      }
    }

    final Plot plot = chart.getPlot();
    plot.setNoDataMessageFont(Font.decode(getLabelFont()));
View Full Code Here

      chart.removeLegend();
    }
    //if true format legend
    else
    {
      final LegendTitle chLegend = chart.getLegend();
      if (chLegend != null)
      {
        final RectangleEdge loc = translateEdge(legendLocation.toLowerCase());
        if (loc != null)
        {
          chLegend.setPosition(loc);
        }
        if (getLegendFont() != null)
        {
          chLegend.setItemFont(Font.decode(getLegendFont()));
        }
        if (!isDrawLegendBorder())
        {
          chLegend.setBorder(BlockBorder.NONE);
        }
        if (legendBackgroundColor != null)
        {
          chLegend.setBackgroundPaint(legendBackgroundColor);
        }
        if (legendTextColor != null)
        {
          chLegend.setItemPaint(legendTextColor);
        }
      }

    }
View Full Code Here

      {
         throw new RuntimeException("Unsupported mode :" + mode);
      }
     
     
      LegendTitle lt = new LegendTitle((GfrXYPlot) this);
      lt.setItemFont(new Font("Dialog", Font.PLAIN, 12));
      lt.setBackgroundPaint(new Color(200, 200, 255, 100));
      lt.setFrame(new BlockBorder(Color.white));
      lt.setPosition(RectangleEdge.BOTTOM);
      XYTitleAnnotation ta = new XYTitleAnnotation(dblX, dblY, lt, rec);

      ta.setMaxWidth(0.48);
      super.addAnnotation(ta);
   }
View Full Code Here

            TextTitle tt = (TextTitle) title;
            tt.setFont(this.largeFont);
            tt.setPaint(this.subtitlePaint);
        }
        else if (title instanceof LegendTitle) {
            LegendTitle lt = (LegendTitle) title;
            if (lt.getBackgroundPaint() != null) {
                lt.setBackgroundPaint(this.legendBackgroundPaint);
            }
            lt.setItemFont(this.regularFont);
            lt.setItemPaint(this.legendItemPaint);
            if (lt.getWrapper() != null) {
                applyToBlockContainer(lt.getWrapper());
            }
        }
        else if (title instanceof PaintScaleLegend) {
            PaintScaleLegend psl = (PaintScaleLegend) title;
            psl.setBackgroundPaint(this.legendBackgroundPaint);
View Full Code Here

        }

        if (chromeless || parameters.get("hideLegend") != null)
            chart.removeLegend();
        else {
            LegendTitle l = chart.getLegend();
            String legendFontSize = getSetting("legendFontSize");
            if (l != null && legendFontSize != null) try {
                float fontSize = Float.parseFloat(legendFontSize);
                l.setItemFont(l.getItemFont().deriveFont(fontSize));
            } catch (Exception lfe) {}
        }

        chart.getPlot().setNoDataMessage(resources.getString("No_Data_Message"));
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 bi = RenderingHelper.createImage(width, height);
      Graphics2D g = bi.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(bi);
      param.setQuality(1.0f, true);
View Full Code Here

    String titleStr = "ratings of selected elements";
    if (weighted)
      titleStr = "weighted " + titleStr;
    JFreeChart chart = new JFreeChart(titleStr, TextTitle.DEFAULT_FONT,
        plot, false);
    LegendTitle legend = new LegendTitle(plot);
    legend.setPosition(RectangleEdge.BOTTOM);
    chart.addSubtitle(legend);
    ChartUtilities.applyCurrentTheme(chart);
    return chart;

  }
View Full Code Here

    }
    }
    // 设置字体边缘清晰化
    chart.setTextAntiAlias(false);
    chart.getTitle().setFont(titleFont);
    LegendTitle legend = chart.getLegend();
    if (legend != null) {
      legend.setItemFont(labelFont);
    }
    // HARDCODE
    chart.getPlot().setNoDataMessage("No data available");
    // 输出图片
    if (alpha) {
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.