Package org.pentaho.chart.plugin.api

Examples of org.pentaho.chart.plugin.api.IOutput


      IChartLinkGenerator chartLinkGenerator =
          contentLinkingTemplate == null ? null : new ChartLinkGenerator( contentLinkingTemplate );
      IChartDataModel chartDataModel =
          ChartBeanFactory.createChartDataModel( data, scalingFactor, convertNullsToZero, valueColumn, seriesColumn,
            categoryColumn, chartModel );
      IOutput output = ChartBeanFactory.createChart( chartModel, chartDataModel, chartLinkGenerator );
      // Wrap output as necessary
      if ( OpenFlashChartPlugin.PLUGIN_ID.equals( chartEngine ) ) {
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        output.persistChart( outputStream, getOutputType(), chartWidth, chartHeight );

        String persistedChart = new String( outputStream.toByteArray(), "utf-8" ); //$NON-NLS-1$

        IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext();
        String flashContent =
            ChartBeansGeneratorUtil.mergeOpenFlashChartHtmlTemplate( persistedChart.replaceAll( "\"", "\\\\\"" ),
              //$NON-NLS-1$ //$NON-NLS-2$
              requestContext.getContextPath() + this.getSwfPath() + "/" + getSwfName() ); //$NON-NLS-1$

        is = new ByteArrayInputStream( flashContent.getBytes( "utf-8" ) ); //$NON-NLS-1$
      } else if ( JFreeChartPlugin.PLUGIN_ID.equals( chartEngine ) ) {
        if ( "html".equals( outputType ) || ( chartLinkGenerator != null ) ) { //$NON-NLS-1$
          File imageFile =
              PentahoSystem.getApplicationContext().createTempFile( PentahoSessionHolder.getSession(),
                "tmp_chart_", ".png", false ); //$NON-NLS-1$
          FileOutputStream outputStream = new FileOutputStream( imageFile );
          output.persistChart( outputStream, OutputTypes.FILE_TYPE_PNG, chartWidth, chartHeight );

          String imageMapName = null;
          String imageMap = null;
          if ( chartLinkGenerator != null ) {
            imageMapName = imageFile.getName().substring( 0, imageFile.getName().indexOf( '.' ) );
            imageMap = ( (JFreeChartOutput) output ).getMap( imageMapName );
          }
          String jFreeChartHtml =
              ChartBeansGeneratorUtil.mergeJFreeChartHtmlTemplate( imageFile, imageMap, imageMapName, chartWidth,
                chartHeight, PentahoRequestContextHolder.getRequestContext().getContextPath() );
          is = new ByteArrayInputStream( jFreeChartHtml.getBytes( "utf-8" ) ); //$NON-NLS-1$
        } else {
          ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
          output.persistChart( outputStream, getOutputType(), chartWidth, chartHeight );
          is = new ByteArrayInputStream( outputStream.toByteArray() );
        }
      }

      int val = 0;
View Full Code Here

TOP

Related Classes of org.pentaho.chart.plugin.api.IOutput

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.