Class JFreeChartEngine


  • public class JFreeChartEngine
    extends Object
    • Constructor Detail

      • JFreeChartEngine

        public JFreeChartEngine()
    • Method Detail

      • saveChart

        public static void saveChart​(org.jfree.data.general.Dataset dataset,
                                     String title,
                                     String units,
                                     String fileName,
                                     int width,
                                     int height,
                                     int outputType,
                                     PrintWriter writer,
                                     org.pentaho.platform.api.engine.ILogger logger)
        Create an image file using dataset object. This method takes a dataset object, e.g. a DialWidgetDefinition, creates a JFreeChart object from it, and then creates an image file.
        Parameters:
        dataset - The
        title - The title of the chart
        units - The units of the chart value
        fileName - The path and file of the image to create
        width - The width of the image to create
        height - The height of the image to create
        outputType - The type of the image to create
        writer - A writer to writer the image map into
        logger - The logger to log any messages to
      • saveChart

        public static void saveChart​(org.jfree.data.general.Dataset dataset,
                                     String title,
                                     String units,
                                     String fileName,
                                     int width,
                                     int height,
                                     int outputType,
                                     PrintWriter writer,
                                     org.jfree.chart.ChartRenderingInfo info,
                                     org.pentaho.platform.api.engine.ILogger logger)
        Create an image file using dataset object. This method takes a dataset object, e.g. a DialWidgetDefinition, creates a JFreeChart object from it, and then creates an image file.
        Parameters:
        dataset - The
        title - The title of the chart
        units - The units of the chart value
        fileName - The path and file of the image to create
        width - The width of the image to create
        height - The height of the image to create
        outputType - The type of the image to create
        writer - A writer to writer the image map into
        logger - The logger to log any messages to
      • getChart

        public static org.jfree.chart.JFreeChart getChart​(org.jfree.data.general.Dataset dataset,
                                                          String title,
                                                          String units,
                                                          int width,
                                                          int height,
                                                          org.pentaho.platform.api.engine.ILogger logger)
        Create a chart-object using dataset object. This method takes a dataset object, e.g. a DialWidgetDefinition, and creates and returns a JFreeChart object from it.
        Parameters:
        dataset - The dataset
        title - The title of the chart
        units - The units of the chart value
        width - The width of the image to create
        height - The height of the image to create
        logger - The logger to log any messages to
        Returns:
        JFreeChart the generated chart object
      • getChartType

        public static int getChartType​(String typeStr)
        Parameters:
        typeStr - String name for chart
        Returns:
        int representing the chart string passed in; -1 if invalid chart name
        See Also:
        for valid chart name strings and integers
      • getChartTypeName

        public static String getChartTypeName​(int type)
        Parameters:
        type - int type for chart
        Returns:
        String representing the chart
        See Also:
        for valid chart name strings
      • getColor

        public static Color getColor​(String htmlColor)
        Creates a java.awt.Color object from an HTML color definition, eg #80dd3f
        Parameters:
        htmlColor - The color string
        Returns:
        A Color object
      • getTransparent

        public static Color getTransparent()
      • getPaint

        public static Paint getPaint​(org.dom4j.Node node,
                                     int width,
                                     int height,
                                     org.pentaho.platform.api.engine.IPentahoSession session)
        Creates a java.awt.Paint object from an XML node from the dial definition document
        Parameters:
        width - of the chart
        height - of the chart
        node - XML Node from the dial definition
        Returns:
        Paint object defined by the node
      • getFont

        public static Font getFont​(org.dom4j.Node fontNode)
        Creates a java.awt.TexturePaint object from an XML node from the dial definition document
        Parameters:
        XML - Node from the dial definition
        width - of the chart
        height - of the chart
        Returns:
        Paint object defined by the node / public static Paint getTexturePaint( Node node, int width, int height ) { if( node == null ) { return null; } int rectWidth=width; int rectHeight=height; int x=0; int y=0; // Get Image try{ Node imageNode = node.selectSingleNode( "background-image" ); //$NON-NLS-1$ if( imageNode != null ) { String imageName = imageNode.getText().toString(); String fileName = PentahoSystem.getApplicationContext().getSolutionPath( imageName ); int offset = fileName.lastIndexOf( "." ); //$NON-NLS-1$ String type = offset == -1 ? "jpg" : fileName.substring(offset + 1); //$NON-NLS-1$ BufferedImage image = new BufferedImage( width, height, BufferedImage.TYPE_INT_ARGB); ImageIO.write(image, type, new File( fileName )); Node rectangle= node.selectSingleNode("rectangle"); //$NON-NLS-1$ if( rectangle != null ) { Node tmpNode = rectangle.selectSingleNode("width"); //$NON-NLS-1$ if( tmpNode != null ) { rectWidth=Integer.parseInt(tmpNode.getText().toString().trim()); //$NON-NLS-1$ } tmpNode = rectangle.selectSingleNode("height"); //$NON-NLS-1$ if( tmpNode != null ) { rectHeight=Integer.parseInt(tmpNode.getText().toString().trim()); //$NON-NLS-1$ } tmpNode = rectangle.selectSingleNode("x"); //$NON-NLS-1$ if( tmpNode != null ) { x=Integer.parseInt(tmpNode.getText().toString().trim()); //$NON-NLS-1$ } tmpNode = rectangle.selectSingleNode("y"); //$NON-NLS-1$ if( tmpNode != null ) { y=Integer.parseInt(tmpNode.getText().toString().trim()); //$NON-NLS-1$ } } Rectangle2D rect = new Rectangle2D.Double(x,y,rectWidth,rectHeight); return new TexturePaint(image,rect); } }catch(Exception e){e.printStackTrace();} return null; }
      • getPaint

        public static Paint getPaint​(org.dom4j.Node node)
        Creates a java.awt.Paint object from an XML node from the dial definition document
        Parameters:
        node - XML Node from the chart definition
        Returns:
        Paint object defined by the node
      • getPaint

        public static Paint getPaint​(String htmlColor)
        Creates a java.awt.Paint object from an HTML color definition, eg #80ff3f
        Parameters:
        htmlColor - The color string
        Returns:
        Paint The Paint object for the requested color
      • getGradientPaint

        public static Paint getGradientPaint​(org.dom4j.Node gradientNode,
                                             int width,
                                             int height)
        Parameters:
        gradientNode - root node that hold gradient information
        Returns:
        a gradientPaint implementation of Paint
      • getTexturePaint

        public static Paint getTexturePaint​(org.dom4j.Node textureNode,
                                            int width,
                                            int height,
                                            org.pentaho.platform.api.engine.IPentahoSession session)
        Parameters:
        textureNode - root node that holds texture information
        Returns:
      • getLineStyleStroke

        public static Stroke getLineStyleStroke​(String lineStyle,
                                                float lineWidth)
      • getImage

        public static Image getImage​(org.dom4j.Node chartBackgroundImageNode,
                                     org.pentaho.platform.api.engine.IPentahoSession session)
        Parameters:
        chartBackgroundImageNode - - Node that contains a path to the images in its text element
        Returns:
        the image
      • getImage

        public static Image getImage​(String imageName,
                                     org.pentaho.platform.api.engine.IPentahoSession session)
        Parameters:
        imageName - String that contains a path to the image
        Returns:
        the image
      • isBarColumn

        public static boolean isBarColumn​(String[] barColumns,
                                          String columnName)
      • isLineColumn

        public static boolean isLineColumn​(String[] lineColumns,
                                           String columnName)