org.pentaho.platform.uifoundation.chart
Class JFreeChartEngine

java.lang.Object
  extended by org.pentaho.platform.uifoundation.chart.JFreeChartEngine

public class JFreeChartEngine
extends Object


Field Summary
static int AREA_CHART_TYPE
           
static int BAR_CHART_TYPE
           
static int BAR_LINE_CHART_TYPE
           
static int BUBBLE_CHART_TYPE
           
static int DIAL_CHART_TYPE
           
static int DIFFERENCE_CHART_TYPE
           
static int DOT_CHART_TYPE
           
static int LINE_CHART_TYPE
           
static int OUTPUT_CHART
           
static int OUTPUT_PNG
           
static int OUTPUT_PNG_BYTES
           
static int OUTPUT_SVG
           
static int PIE_CHART_TYPE
           
static int PIE_GRID_CHART_TYPE
           
static int STEP_AREA_CHART_TYPE
           
static int STEP_CHART_TYPE
           
static int THERMOMETER_CHART_TYPE
           
static int UNDEFINED_CHART_TYPE
           
 
Constructor Summary
JFreeChartEngine()
           
 
Method Summary
static org.jfree.chart.JFreeChart getChart(org.jfree.data.general.Dataset dataset, String title, String units, int width, int height, ILogger logger)
          Create a chart-object using dataset object.
static int getChartType(String typeStr)
           
static String getChartTypeName(int type)
           
static Color getColor(String htmlColor)
          Creates a java.awt.Color object from an HTML color definition, eg #80dd3f
static Font getFont(org.dom4j.Node fontNode)
          Creates a java.awt.TexturePaint object from an XML node from the dial definition document
static Paint getGradientPaint(org.dom4j.Node gradientNode, int width, int height)
           
static Image getImage(org.dom4j.Node chartBackgroundImageNode, IPentahoSession session)
           
static Image getImage(String imageName, IPentahoSession session)
           
static Stroke getLineStyleStroke(String lineStyle, float lineWidth)
           
static Paint getPaint(org.dom4j.Node node)
          Creates a java.awt.Paint object from an XML node from the dial definition document
static Paint getPaint(org.dom4j.Node node, int width, int height, IPentahoSession session)
          Creates a java.awt.Paint object from an XML node from the dial definition document
static Paint getPaint(String htmlColor)
          Creates a java.awt.Paint object from an HTML color definition, eg #80ff3f
static Paint getTexturePaint(org.dom4j.Node textureNode, int width, int height, IPentahoSession session)
           
static Color getTransparent()
           
static boolean isBarColumn(String[] barColumns, String columnName)
           
static boolean isLineColumn(String[] lineColumns, String columnName)
           
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, ILogger logger)
          Create an image file using dataset object.
static void saveChart(org.jfree.data.general.Dataset dataset, String title, String units, String fileName, int width, int height, int outputType, PrintWriter writer, ILogger logger)
          Create an image file using dataset object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OUTPUT_CHART

public static final int OUTPUT_CHART
See Also:
Constant Field Values

OUTPUT_PNG

public static final int OUTPUT_PNG
See Also:
Constant Field Values

OUTPUT_SVG

public static final int OUTPUT_SVG
See Also:
Constant Field Values

OUTPUT_PNG_BYTES

public static final int OUTPUT_PNG_BYTES
See Also:
Constant Field Values

UNDEFINED_CHART_TYPE

public static final int UNDEFINED_CHART_TYPE
See Also:
Constant Field Values

DIAL_CHART_TYPE

public static final int DIAL_CHART_TYPE
See Also:
Constant Field Values

THERMOMETER_CHART_TYPE

public static final int THERMOMETER_CHART_TYPE
See Also:
Constant Field Values

PIE_CHART_TYPE

public static final int PIE_CHART_TYPE
See Also:
Constant Field Values

PIE_GRID_CHART_TYPE

public static final int PIE_GRID_CHART_TYPE
See Also:
Constant Field Values

BAR_CHART_TYPE

public static final int BAR_CHART_TYPE
See Also:
Constant Field Values

LINE_CHART_TYPE

public static final int LINE_CHART_TYPE
See Also:
Constant Field Values

AREA_CHART_TYPE

public static final int AREA_CHART_TYPE
See Also:
Constant Field Values

STEP_CHART_TYPE

public static final int STEP_CHART_TYPE
See Also:
Constant Field Values

STEP_AREA_CHART_TYPE

public static final int STEP_AREA_CHART_TYPE
See Also:
Constant Field Values

DIFFERENCE_CHART_TYPE

public static final int DIFFERENCE_CHART_TYPE
See Also:
Constant Field Values

DOT_CHART_TYPE

public static final int DOT_CHART_TYPE
See Also:
Constant Field Values

BAR_LINE_CHART_TYPE

public static final int BAR_LINE_CHART_TYPE
See Also:
Constant Field Values

BUBBLE_CHART_TYPE

public static final int BUBBLE_CHART_TYPE
See Also:
Constant Field Values
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,
                             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,
                             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,
                                                  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,
                             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,
                                    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,
                             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,
                             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)