Package org.jfree.chart.title

Examples of org.jfree.chart.title.LegendTitle


      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


    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

      jfreechart.addSubtitle(subtitle);
    }

    // Apply all of the legend formatting options
    LegendTitle legend = jfreechart.getLegend();

    if (legend != null)
    {
      legend.setVisible((chartSettings.getShowLegend() == null || chartSettings.getShowLegend()));
      if (legend.isVisible())
      {
        if(chartSettings.getLegendColor() != null)
        {
          legend.setItemPaint(chartSettings.getLegendColor());
        }
        if (chartSettings.getLegendBackgroundColor() != null)
        {
          legend.setBackgroundPaint(chartSettings.getLegendBackgroundColor());
        }
 
        if(chartSettings.getLegendFont() != null)
        {
          legend.setItemFont(JRFontUtil.getAwtFont(chartSettings.getLegendFont(), Locale.getDefault()));
        }
        legend.setPosition(getEdge(chartSettings.getLegendPosition(), RectangleEdge.BOTTOM));
      }
    }

    String renderType = chartSettings.getRenderType() == null ? defaultRenderType : chartSettings.getRenderType();
    Rectangle2D rectangle = new Rectangle2D.Double(0,0,element.getWidth(),element.getHeight());
View Full Code Here

      jfreeChart.addSubtitle(subtitle);
    }

    // Apply all of the legend formatting options
    LegendTitle legend = jfreeChart.getLegend();
    if (legend != null)
    {
      legend.setItemPaint(getChart().getLegendColor());

      if (getChart().getOwnLegendBackgroundColor() == null)// in a way, legend backcolor inheritance from chart is useless
      {
        legend.setBackgroundPaint(TRANSPARENT_PAINT);
      }
      else
      {
        legend.setBackgroundPaint(getChart().getLegendBackgroundColor());
      }

      legend.setItemFont(JRFontUtil.getAwtFont(getChart().getLegendFont(), getLocale()));
      legend.setPosition(getEdge(getChart().getLegendPositionValue(), RectangleEdge.BOTTOM));
    }
   
    configurePlot(jfreeChart.getPlot());
  }
View Full Code Here

  }
 
  protected void setChartLegend(JFreeChart jfreeChart)
  {
    //The legend visibility is already taken into account in the jfreeChart object's constructor
    LegendTitle legend = jfreeChart.getLegend();
    if (legend != null)
    {
      LegendSettings legendSettings = getLegendSettings();
      JRBaseFont font = new JRBaseFont();
      JRFontUtil.copyNonNullOwnProperties(legendSettings.getFont(), font);
      JRFontUtil.copyNonNullOwnProperties(getChart().getLegendFont(), font);
      font = new JRBaseFont(getChart(), font);
      legend.setItemFont(JRFontUtil.getAwtFont(font, getLocale()));

      Paint forePaint = getChart().getOwnLegendColor();
      if (forePaint == null && legendSettings.getForegroundPaint() != null)
      {
        forePaint = legendSettings.getForegroundPaint().getPaint();
      }
      if (forePaint == null)
      {
        forePaint = getChart().getLegendColor();
      }
      if (forePaint != null)
        legend.setItemPaint(forePaint);

      Paint backPaint = getChart().getOwnLegendBackgroundColor();
      if (backPaint == null && legendSettings.getBackgroundPaint() != null)
      {
        backPaint = legendSettings.getBackgroundPaint().getPaint();
      }
      if (backPaint == null)
      {
        backPaint = getChart().getLegendBackgroundColor();
      }
      if (backPaint != null)
        legend.setBackgroundPaint(backPaint);

      BlockFrame blockFrame = legendSettings.getBlockFrame();
      if(blockFrame != null)
        legend.setFrame(blockFrame);
     
      HorizontalAlignment hAlign = legendSettings.getHorizontalAlignment();
      if(hAlign != null)
        legend.setHorizontalAlignment(hAlign);
     
      VerticalAlignment vAlign = legendSettings.getVerticalAlignment();
      if(vAlign != null)
        legend.setVerticalAlignment(vAlign);
     
      RectangleInsets padding = legendSettings.getPadding();
      if(padding != null)
        legend.setPadding(padding);

      legend.setPosition(
        getEdge(
          getChart().getLegendPositionValue(),
          getEdge(
            legendSettings.getPositionValue() ,
            RectangleEdge.BOTTOM
View Full Code Here

  protected void setChartLegend(JFreeChart jfreeChart, Integer baseFontSize)
  {

    //The legend visibility is already taken into account in the jfreeChart object's constructor
   
    LegendTitle legend = jfreeChart.getLegend();
    if (legend != null)
    {
      Font themeLegendFont = getFont((JRFont)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_FONT), getChart().getLegendFont(), baseFontSize);
      legend.setItemFont(themeLegendFont);

      Color legendForecolor = getChart().getOwnLegendColor() != null ?
          getChart().getOwnLegendColor() :
          (getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_FORECOLOR) != null ?
              (Color)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_FORECOLOR) :
              getChart().getLegendColor());
      if(legendForecolor != null)
        legend.setItemPaint(legendForecolor);

      Color legendBackcolor = getChart().getOwnLegendBackgroundColor() != null ?
          getChart().getOwnLegendBackgroundColor() :
          (getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_BACKCOLOR) != null ?
              (Color)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_BACKCOLOR) :
              getChart().getLegendBackgroundColor());
      if(legendBackcolor != null)
        legend.setBackgroundPaint(legendBackcolor);
     
      BlockFrame frame = (BlockFrame)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_FRAME);
      if(frame != null)
        legend.setFrame(frame);
     
      HorizontalAlignment defaultLegendHAlignment = (HorizontalAlignment)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_HORIZONTAL_ALIGNMENT);
      if(defaultLegendHAlignment != null)
        legend.setHorizontalAlignment(defaultLegendHAlignment);
     
      VerticalAlignment defaultLegendVAlignment = (VerticalAlignment)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_VERTICAL_ALIGNMENT);
      if(defaultLegendVAlignment != null)
        legend.setVerticalAlignment(defaultLegendVAlignment);
     
      RectangleInsets defaultLegendPadding = (RectangleInsets)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_PADDING);
      RectangleInsets legendPadding = legend.getPadding() != null ? legend.getPadding() : defaultLegendPadding;
      if(legendPadding != null)
        legend.setPadding(legendPadding);

      RectangleEdge defaultLegendPosition = (RectangleEdge)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.LEGEND_POSITION);
      if(getEdge(getChart().getLegendPositionValue(), defaultLegendPosition) != null)
        legend.setPosition(getEdge(getChart().getLegendPositionValue(), defaultLegendPosition));
     
    }
  }
View Full Code Here

                new Rectangle2D.Double(-6.0, -3.0, 12.0, 6.0), Color.green));
        items.add(new LegendItem("Some degree permissible", null, null, null,
                new Rectangle2D.Double(-6.0, -3.0, 12.0, 6.0), Color.red));
        plot.setFixedLegendItems(items);
        plot.setInsets(new RectangleInsets(5, 5, 5, 20));
        LegendTitle legend = new LegendTitle(plot);
        legend.setPosition(RectangleEdge.BOTTOM);
        chart.addSubtitle(legend);
       
        plot.setBackgroundPaint(Color.lightGray);
        plot.setDomainGridlinePaint(Color.white);
        plot.setDomainGridlinesVisible(true);
View Full Code Here

      if (subtitle instanceof TextTitle) {
        ((TextTitle) subtitle).setFont(WidgetUtils.FONT_NORMAL);
      }
    }

    LegendTitle legend = chart.getLegend();
    if (legend != null) {
      legend.setItemFont(WidgetUtils.FONT_SMALL);
    }

    // transparent background
    chart.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST);
    chart.setBorderVisible(false);
View Full Code Here

      return
    }
    final XYPlot plot = createPlot(problem, shipments, solution);
    JFreeChart chart = new JFreeChart(title, plot);
   
    LegendTitle legend = createLegend(routes, shipments, plot);
    chart.removeLegend();
    chart.addLegend(legend);
   
    save(chart,pngFile);
   
View Full Code Here

        }
        return lic;
      }
    };
   
    LegendTitle legend = new LegendTitle(lis);
    legend.setPosition(RectangleEdge.BOTTOM);
    return 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.