Package net.sf.jasperreports.components.charts

Examples of net.sf.jasperreports.components.charts.ChartSettings


  {
    SpiderChartComponent chartComponent = (SpiderChartComponent) component;
   
    verifyEvaluation(verifier, chartComponent);
   
    ChartSettings chartSettings = chartComponent.getChartSettings();
    if (chartSettings == null)
    {
      verifier.addBrokenRule("No chart settings for spider chart", chartComponent);
    }
   
View Full Code Here


    if (spiderChartComponent.getEvaluationTime() == EvaluationTimeEnum.GROUP)
    {
      writer.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_evaluationGroup, spiderChartComponent.getEvaluationGroup());
    }
   
    ChartSettings chartSettings = spiderChartComponent.getChartSettings();
    writeChart(chartSettings, writer, reportWriter, componentNamespace);
   
    SpiderDataset dataset = (SpiderDataset)spiderChartComponent.getDataset();
    writeSpiderDataSet(dataset, writer, reportWriter, componentNamespace);
   
View Full Code Here

      String defaultRenderType,
      String datasetType
      )
  {
    SpiderChartComponent chartComponent = (SpiderChartComponent) element.getComponent();
    ChartSettings chartSettings = chartComponent.getChartSettings();
    SpiderPlot plot = (SpiderPlot)chartComponent.getPlot();
   
    DefaultCategoryDataset dataset = null;
    StandardCategoryItemLabelGenerator labelGenerator = null;
   
    if(FILL_DATASET.equals(datasetType))
    {
      dataset = ((FillSpiderDataset)spiderchartBean.getDataset()).getCustomDataset();
      labelGenerator = ((FillSpiderDataset)spiderchartBean.getDataset()).getLabelGenerator();
    }
    else
    {
      dataset = getSampleDataset();
      labelGenerator = new StandardCategoryItemLabelGenerator();
    }
   
    SpiderWebPlot spiderWebPlot = new SpiderWebPlot(dataset);

        if(plot.getAxisLineColor() != null)
        {
          spiderWebPlot.setAxisLinePaint(plot.getAxisLineColor());
        }
        if(plot.getAxisLineWidth() != null)
        {
          spiderWebPlot.setAxisLineStroke(new BasicStroke(plot.getAxisLineWidth()));
        }
        if(plot.getBackcolor() != null)
        {
          spiderWebPlot.setBackgroundPaint(plot.getBackcolor());
        }
        if(plot.getBackgroundAlpha() != null)
        {
          spiderWebPlot.setBackgroundAlpha(plot.getBackgroundAlpha());
        }
        if(plot.getForegroundAlpha() != null)
        {
          spiderWebPlot.setForegroundAlpha(plot.getForegroundAlpha());
        }
        if(plot.getHeadPercent() != null)
        {
          spiderWebPlot.setHeadPercent(plot.getHeadPercent());
        }
        if(plot.getInteriorGap() != null)
        {
          spiderWebPlot.setInteriorGap(plot.getInteriorGap());
        }
        if(plot.getLabelColor() != null)
        {
          spiderWebPlot.setLabelPaint(plot.getLabelColor());
        }
        if(plot.getLabelFont() != null)
        {
          spiderWebPlot.setLabelFont(JRFontUtil.getAwtFont(plot.getLabelFont(), Locale.getDefault()));
        }
        if(plot.getLabelGap() != null)
        {
          spiderWebPlot.setAxisLabelGap(plot.getLabelGap());
        }
        if(spiderchartBean.getMaxValue() != null)
        {
          spiderWebPlot.setMaxValue(spiderchartBean.getMaxValue());
        }
        if(plot.getRotation() != null)
        {
          spiderWebPlot.setDirection(plot.getRotation().getRotation());
        }
        if(plot.getStartAngle() != null)
        {
          spiderWebPlot.setStartAngle(plot.getStartAngle());
        }
        if(plot.getTableOrder() != null)
        {
          spiderWebPlot.setDataExtractOrder(plot.getTableOrder().getOrder());
        }
        if(plot.getWebFilled() != null)
        {
          spiderWebPlot.setWebFilled(plot.getWebFilled());
        }

        spiderWebPlot.setToolTipGenerator(new StandardCategoryToolTipGenerator());
        spiderWebPlot.setLabelGenerator(labelGenerator);
       
        Font titleFont = chartSettings.getTitleFont() != null
          ? JRFontUtil.getAwtFont(chartSettings.getTitleFont(), Locale.getDefault())
          : TextTitle.DEFAULT_FONT;
      
        String titleText = spiderchartBean.getTitleText();
       
        JFreeChart jfreechart = new JFreeChart(titleText, titleFont, spiderWebPlot, true);

    Color backcolor = chartSettings.getBackcolor() != null ? chartSettings.getBackcolor() : element.getBackcolor();
        if(backcolor != null)
    {
      jfreechart.setBackgroundPaint(backcolor);
    }
   
    RectangleEdge titleEdge = getEdge(chartSettings.getTitlePosition(), RectangleEdge.TOP);
   
    if (titleText != null)
    {
      TextTitle title = jfreechart.getTitle();
      title.setText(titleText);
      if(chartSettings.getTitleColor() != null)
      {
        title.setPaint(chartSettings.getTitleColor());
      }
     
      title.setFont(titleFont);
      title.setPosition(titleEdge);
      jfreechart.setTitle(title);
    }

        String subtitleText = spiderchartBean.getSubtitleText();
    if (subtitleText != null)
    {
      TextTitle subtitle = new TextTitle(subtitleText);
      subtitle.setText(subtitleText);
      if(chartSettings.getSubtitleColor() != null)
      {
        subtitle.setPaint(chartSettings.getSubtitleColor());
      }

      if(chartSettings.getSubtitleColor() != null)
      {
            Font subtitleFont = chartSettings.getSubtitleFont() != null
            ? JRFontUtil.getAwtFont(chartSettings.getSubtitleFont(), Locale.getDefault())
            : TextTitle.DEFAULT_FONT;
        subtitle.setFont(subtitleFont);
      }
     
      subtitle.setPosition(titleEdge);

      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());
   
    if (chartCustomizer != null)
    {
      chartCustomizer.customize(jfreechart, chartComponent);
View Full Code Here

    if (chartComponent == null)
    {
      return null;
    }
    JRBasePrintImage printImage = new JRBasePrintImage(reportConverter.getDefaultStyleProvider());
    ChartSettings chartSettings = chartComponent.getChartSettings();

    reportConverter.copyBaseAttributes(element, printImage);
   
    //TODO: spiderchart box
//    printImage.copyBox(element.getLineBox());
   
    printImage.setAnchorName(JRExpressionUtil.getExpressionText(chartSettings.getAnchorNameExpression()));
    printImage.setBookmarkLevel(chartSettings.getBookmarkLevel());
    printImage.setLinkType(chartSettings.getLinkType());
    printImage.setOnErrorType(OnErrorTypeEnum.ICON);
    printImage.setScaleImage(ScaleImageEnum.CLIP);
    SpiderChartSharedBean spiderchartBean = new SpiderChartSharedBean(
        chartSettings.getRenderType(),
        SpiderChartRendererEvaluator.SAMPLE_MAXVALUE,
        JRExpressionUtil.getExpressionText(chartSettings.getTitleExpression()),
        JRExpressionUtil.getExpressionText(chartSettings.getSubtitleExpression()),
        null,
        null
        );
   
    printImage.setRenderer(SpiderChartRendererEvaluator.evaluateRenderer(
View Full Code Here

TOP

Related Classes of net.sf.jasperreports.components.charts.ChartSettings

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.