Class JFreeChartEngine
- java.lang.Object
-
- org.pentaho.platform.uifoundation.chart.JFreeChartEngine
-
public class JFreeChartEngine extends Object
-
-
Field Summary
Fields Modifier and Type Field Description 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
protected static org.apache.commons.logging.Log
log
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
Constructors Constructor Description JFreeChartEngine()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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.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 #80dd3fstatic Font
getFont(org.dom4j.Node fontNode)
Creates a java.awt.TexturePaint object from an XML node from the dial definition documentstatic Paint
getGradientPaint(org.dom4j.Node gradientNode, int width, int height)
static Image
getImage(String imageName, org.pentaho.platform.api.engine.IPentahoSession session)
static Image
getImage(org.dom4j.Node chartBackgroundImageNode, org.pentaho.platform.api.engine.IPentahoSession session)
static Stroke
getLineStyleStroke(String lineStyle, float lineWidth)
static Paint
getPaint(String htmlColor)
Creates a java.awt.Paint object from an HTML color definition, eg #80ff3fstatic Paint
getPaint(org.dom4j.Node node)
Creates a java.awt.Paint object from an XML node from the dial definition documentstatic 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 documentstatic Paint
getTexturePaint(org.dom4j.Node textureNode, int width, int height, org.pentaho.platform.api.engine.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, org.pentaho.platform.api.engine.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, org.pentaho.platform.api.engine.ILogger logger)
Create an image file using dataset object.
-
-
-
Field Detail
-
log
protected static final org.apache.commons.logging.Log log
-
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
-
-
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
- Thetitle
- The title of the chartunits
- The units of the chart valuefileName
- The path and file of the image to createwidth
- The width of the image to createheight
- The height of the image to createoutputType
- The type of the image to createwriter
- A writer to writer the image map intologger
- 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
- Thetitle
- The title of the chartunits
- The units of the chart valuefileName
- The path and file of the image to createwidth
- The width of the image to createheight
- The height of the image to createoutputType
- The type of the image to createwriter
- A writer to writer the image map intologger
- 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 datasettitle
- The title of the chartunits
- The units of the chart valuewidth
- The width of the image to createheight
- The height of the image to createlogger
- 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 chartheight
- of the chartnode
- 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 definitionwidth
- of the chartheight
- 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:
-
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
-
-