Package org.eclipse.birt.chart.factory

# Class Generator

java.lang.Object
org.eclipse.birt.chart.factory.Generator

All Implemented Interfaces:
  `IGenerator`

public final class Generator extends Object implements IGenerator
Provides an entry point into building a chart for a given model. It is implemented as a singleton and does not maintain any state information hence allowing multi-threaded requests for a single generator instance.

## Method Summary

Modifier and Type
Method
Description
`void`
`bindData(ResultSet resultSet, Chart chart, RunTimeContext rtc)`
Binds a sql Resuset to a chart model.
`void`
`bindData(IDataRowExpressionEvaluator expressionEvaluator, IActionEvaluator iae, Chart chart, RunTimeContext rtc)`
Binds data to the chart model using a row expression evaluator.
`void`
`bindData(IDataRowExpressionEvaluator expressionEvaluator, Chart chart, RunTimeContext rtc)`
Binds data to the chart model using a row expression evaluator.
`GeneratedChartState`
`build(IDisplayServer ids, Chart cmRunTime, Bounds bo, RunTimeContext rtc)`
Builds and computes preferred sizes of various chart components offscreen using the provided display server.
`GeneratedChartState`
`build(IDisplayServer ids, Chart cmRunTime, Bounds bo, IExternalContext externalContext, RunTimeContext rtc)`
Builds and computes preferred sizes of various chart components offscreen using the provided display server.
`GeneratedChartState`
`build(IDisplayServer ids, Chart cmRunTime, Bounds bo, IExternalContext externalContext, RunTimeContext rtc, org.eclipse.birt.chart.style.IStyleProcessor externalProcessor)`
Builds and computes preferred sizes of various chart components offscreen using the provided display server.
`GeneratedChartState`
`build(IDisplayServer ids, Chart cmRunTime, org.mozilla.javascript.Scriptable scParent, Bounds bo, RunTimeContext rtc)`
Deprecated.
use `build(IDisplayServer, Chart, Bounds, IExternalContext, RunTimeContext)` instead.
`GeneratedChartState`
`build(IDisplayServer ids, Chart cmRunTime, org.mozilla.javascript.Scriptable scParent, Bounds bo, RunTimeContext rtc, org.eclipse.birt.chart.style.IStyleProcessor externalProcessor)`
Deprecated.
use `build(IDisplayServer, Chart, Bounds, IExternalContext, RunTimeContext, IStyleProcessor)` instead.
`List<String>`
`getRowExpressions(Chart cm)`
This retrieves all the data row related expressions stored in the chart model.
`List<String>`
`getRowExpressions(Chart cm, IActionEvaluator iae)`
This retrieves all the row expressions stored in the chart model.
`List<String>`
`getRowExpressions(Chart cm, IActionEvaluator iae, boolean needChangeValueExpr)`
This retrieves all the row expressions stored in the chart model.
`static Generator`
`instance()`
Returns a singleton instance of the chart generator.
`RunTimeContext`
`prepare(Chart model, IExternalContext externalContext, IScriptClassLoader iscl, com.ibm.icu.util.ULocale locale)`
Since v2, it must be called before build( ), and should only be called once per design model.
`RunTimeContext`
`prepare(Chart model, IExternalContext externalContext, IScriptClassLoader iscl, Locale locale)`
Deprecated.
use `prepare(Chart, IExternalContext, IScriptClassLoader, ULocale)` instead.
`void`
`prepareStyles(Chart model, org.eclipse.birt.chart.style.IStyleProcessor externalProcessor)`
Prepare all default styles for various StyledComponent.
`void`
`prepareStyles(Chart model, org.eclipse.birt.chart.style.IStyleProcessor externalProcessor, RunTimeContext rtc)`
Prepare all default styles for various StyledComponent.
`void`
`refresh(GeneratedChartState gcs)`
Performs a minimal rebuild of the chart if non-sizing attributes are altered or the dataset for any series has changed.
`void`
`render(IDeviceRenderer idr, GeneratedChartState gcs)`
Draws a previously built chart using the specified device renderer into a target output device.
`void`
`setDefaultBackground(ColorDefinition cd)`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### instance

public static Generator instance()
Returns a singleton instance of the chart generator.

Returns:
  A singleton instance for the chart generator.

### prepareStyles

public void prepareStyles(Chart model, org.eclipse.birt.chart.style.IStyleProcessor externalProcessor, RunTimeContext rtc)
Prepare all default styles for various StyledComponent.

Parameters:
  `model` -
  `externalProcessor` -
  `rtc` - runtime context.

### prepareStyles

public void prepareStyles(Chart model, org.eclipse.birt.chart.style.IStyleProcessor externalProcessor)
Prepare all default styles for various StyledComponent.

Parameters:
  `model` -
  `externalProcessor` -

### getRowExpressions

public List<String> getRowExpressions(Chart cm) throws ChartException
This retrieves all the data row related expressions stored in the chart model. This is useful to prepare a specific query for the chart.

Parameters:
  `cm` - The Chart model
Returns:
  All row expressions in a list of String instances.
Throws:
  `ChartException`
Since:
  2.0

### getRowExpressions

public List<String> getRowExpressions(Chart cm, IActionEvaluator iae, boolean needChangeValueExpr) throws ChartException
This retrieves all the row expressions stored in the chart model. This is useful to prepare a specific query for the chart. If the given IActionEvaluator is not null, then it will also search available expressions within the action.

Parameters:
  `cm` - The Chart model
  `iae` - An IActionEvaluator instance
Returns:
  All row expressions in a list of String instances.
Throws:
  `ChartException`
Since:
  2.3

### getRowExpressions

public List<String> getRowExpressions(Chart cm, IActionEvaluator iae) throws ChartException
This retrieves all the row expressions stored in the chart model. This is useful to prepare a specific query for the chart. If the given IActionEvaluator is not null, then it will also search available expressions within the action.

Parameters:
  `cm` - The Chart model
  `iae` - An IActionEvaluator instance
Returns:
  All row expressions in a list of String instances.
Throws:
  `ChartException`
Since:
  2.0

### bindData

public void bindData(ResultSet resultSet, Chart chart, RunTimeContext rtc) throws ChartException
Binds a sql Resuset to a chart model. This is based on the assumption the column names of the resultset match exactly the data query definitions and other expressions set inside the chart model.

Specified by:
  `bindData` in interface `IGenerator`
Parameters:
  `resultSet` - A sql resultset that contains the data. The following methods of the interface need to be implemented: first(), next(), getObject(String), close()
  `chart` - The chart model to bind the data to
  `rtc` - The runtime context
Throws:
  `ChartException`
Since:
  2.0

### bindData

public void bindData(IDataRowExpressionEvaluator expressionEvaluator, Chart chart, RunTimeContext rtc) throws ChartException
Binds data to the chart model using a row expression evaluator. The evaluator provides the ability to evaluate the expressions set in the chart on a row context.

Specified by:
  `bindData` in interface `IGenerator`
Parameters:
  `expressionEvaluator` - The data row expression evaluator implementation
  `chart` - The chart model
  `rtc` - The runtime context
Throws:
  `ChartException`
Since:
  2.0

### bindData

public void bindData(IDataRowExpressionEvaluator expressionEvaluator, IActionEvaluator iae, Chart chart, RunTimeContext rtc) throws ChartException
Binds data to the chart model using a row expression evaluator. The evaluator provides the ability to evaluate the expressions set in the chart on a row context.If the given IActionEvaluator is not null, then it will also search available expressions within the action and bind it as the user dataSets.

Specified by:
  `bindData` in interface `IGenerator`
Parameters:
  `expressionEvaluator` - The data row expression evaluator implementation
  `iae` - An IActionEvaluator instance.
  `chart` - The chart model
  `rtc` - The runtime context
Throws:
  `ChartException`
Since:
  2.0

### prepare

@Deprecated public RunTimeContext prepare(Chart model, IExternalContext externalContext, IScriptClassLoader iscl, Locale locale) throws ChartException
Deprecated.
use `prepare(Chart, IExternalContext, IScriptClassLoader, ULocale)` instead.
Since v2, it must be called before build( ), and should only be called once per design model.

Parameters:
  `model` - Chart design model
  `externalContext` - External Context
  `locale` - Locale
Returns:
  a runtime context used by build( )
Throws:
  `ChartException`

### prepare

public RunTimeContext prepare(Chart model, IExternalContext externalContext, IScriptClassLoader iscl, com.ibm.icu.util.ULocale locale) throws ChartException
Since v2, it must be called before build( ), and should only be called once per design model.

Specified by:
  `prepare` in interface `IGenerator`
Parameters:
  `model` - Chart design model
  `externalContext` - External Context
  `locale` - Locale
Returns:
  a runtime context used by build( )
Throws:
  `ChartException`
Since:
  2.1

### build

@Deprecated public GeneratedChartState build(IDisplayServer ids, Chart cmRunTime, org.mozilla.javascript.Scriptable scParent, Bounds bo, RunTimeContext rtc) throws ChartException
Deprecated.
use `build(IDisplayServer, Chart, Bounds, IExternalContext, RunTimeContext)` instead.
Builds and computes preferred sizes of various chart components offscreen using the provided display server.

Parameters:
  `ids` - A display server using which the chart may be built.
  `cmRunTime` - The runtime chart model (bound to a dataset).
  `scParent` - A parent script handler that may be attached to the existing chart model script handler.
  `bo` - The bounds associated with the chart being built.
  `rtc` - Encapsulates the runtime environment for the build process.
Returns:
  An instance of a generated chart state that encapsulates built chart information that may be subsequently rendered.
Throws:
  `ChartException`

### build

@Deprecated public GeneratedChartState build(IDisplayServer ids, Chart cmRunTime, org.mozilla.javascript.Scriptable scParent, Bounds bo, RunTimeContext rtc, org.eclipse.birt.chart.style.IStyleProcessor externalProcessor) throws ChartException
Deprecated.
use `build(IDisplayServer, Chart, Bounds, IExternalContext, RunTimeContext, IStyleProcessor)` instead.
Builds and computes preferred sizes of various chart components offscreen using the provided display server.

Parameters:
  `ids` - A display server using which the chart may be built.
  `cmRunTime` - The runtime chart model (bound to a dataset).
  `scParent` - A parent script handler that may be attached to the existing chart model script handler.
  `bo` - The bounds associated with the chart being built.
  `rtc` - Encapsulates the runtime environment for the build process.
  `externalProcessor` - An external style processor. If this is null, an implicit processor will be used.
Returns:
  An instance of a generated chart state that encapsulates built chart information that may be subsequently rendered.
Throws:
  `ChartException`

### build

public GeneratedChartState build(IDisplayServer ids, Chart cmRunTime, Bounds bo, RunTimeContext rtc) throws ChartException
Builds and computes preferred sizes of various chart components offscreen using the provided display server.

Parameters:
  `ids` - A display server using which the chart may be built.
  `cmRunTime` - The runtime chart model (bound to a dataset).
  `bo` - The bounds associated with the chart being built.
  `rtc` - Encapsulates the runtime environment for the build process.
Returns:
  An instance of a generated chart state that encapsulates built chart information that may be subsequently rendered.
Throws:
  `ChartException`
Since:
  2.2

### build

public GeneratedChartState build(IDisplayServer ids, Chart cmRunTime, Bounds bo, IExternalContext externalContext, RunTimeContext rtc) throws ChartException
Builds and computes preferred sizes of various chart components offscreen using the provided display server.

Specified by:
  `build` in interface `IGenerator`
Parameters:
  `ids` - A display server using which the chart may be built.
  `cmRunTime` - The runtime chart model (bound to a dataset).
  `externalContext` - An external context object.
  `bo` - The bounds associated with the chart being built.
  `rtc` - Encapsulates the runtime environment for the build process.
Returns:
  An instance of a generated chart state that encapsulates built chart information that may be subsequently rendered.
Throws:
  `ChartException`

### build

public GeneratedChartState build(IDisplayServer ids, Chart cmRunTime, Bounds bo, IExternalContext externalContext, RunTimeContext rtc, org.eclipse.birt.chart.style.IStyleProcessor externalProcessor) throws ChartException
Builds and computes preferred sizes of various chart components offscreen using the provided display server.

Specified by:
  `build` in interface `IGenerator`
Parameters:
  `ids` - A display server using which the chart may be built.
  `cmRunTime` - The run time chart model (bound to a dataset).
  `externalContext` - An external context object.
  `bo` - The bounds associated with the chart being built.
  `rtc` - Encapsulates the runtime environment for the build process.
  `externalProcessor` - An external style processor. If it's null, an implicit processor will be used.
Returns:
  An instance of a generated chart state that encapsulates built chart information that may be subsequently rendered.
Throws:
  `ChartException`

### refresh

public void refresh(GeneratedChartState gcs) throws ChartException
Performs a minimal rebuild of the chart if non-sizing attributes are altered or the dataset for any series has changed. However, if sizing attribute changes occur that affects the relative position of the various chart subcomponents, a re-build is required.

Specified by:
  `refresh` in interface `IGenerator`
Parameters:
  `gcs` - A previously built chart encapsulated in a transient structure.
Throws:
  `ChartException`

### render

public void render(IDeviceRenderer idr, GeneratedChartState gcs) throws ChartException
Draws a previously built chart using the specified device renderer into a target output device.

Specified by:
  `render` in interface `IGenerator`
Parameters:
  `idr` - A device renderer that determines the target context on which the chart will be rendered.
  `gcs` - A previously built chart that needs to be rendered.
Throws:
  `ChartException`

### setDefaultBackground

public void setDefaultBackground(ColorDefinition cd)