org.eclipse.birt.chart.util
Class ChartUtil

java.lang.Object
  extended by org.eclipse.birt.chart.util.ChartUtil

public class ChartUtil
extends java.lang.Object

Utility class for Charts.


Field Summary
static java.lang.String CHART_MAX_ROW
          The constant defined as the key in RuntimeContext or JVM arguments, to represent the value of chart max row number.
 
Constructor Summary
ChartUtil()
           
 
Method Summary
static double alignWithInt(double dValue, boolean bForced)
          Aligns a double value with a int value, if the differance between the two value is less than EPS, and if dValue is lager than 1E15, the maximum count of significant digit is set to 15
static boolean checkDoublePrecise(double dValue)
          Checks a double value is double precise.
static int compareVersion(java.lang.String va, java.lang.String vb)
          Compare version number, the format of version number should be X.X.X style.
static double computeHeightOfOrthogonalAxisTitle(ChartWithAxes cm, IDisplayServer xs)
          Computes the height of orthogonal axis title.
static Fill convertFill(Fill fill, double dValue, Fill fNegative)
          Converts Fill if possible.
static double convertPixelsToPoints(IDisplayServer idsSWT, double dOriginalHeight)
          Convert pixel value to points.
static int convertUnitTypeToCalendarConstant(ScaleUnitType unitType)
          Convers Scale unit type to ICU Calendar constant.
static java.lang.String createRegularRowExpression(java.lang.String expression, boolean hasOperation)
          Create a regular row expression for the matching operation.
static java.lang.String createValueSeriesRowFullExpression(java.lang.String expr, SeriesDefinition orthSD, SeriesDefinition categorySD)
          Create row full expression of value series.
static java.lang.String formatDouble(double value)
          Formats the double value with fixed precision.
static java.lang.Object[] getAggFunParameters(SeriesDefinition orthSD, SeriesDefinition baseSD)
          Returns value of aggregate function parameters.
static java.lang.String getAggregateFuncExpr(SeriesDefinition orthSD, SeriesDefinition baseSD)
          Returns aggregation function expression.
static java.lang.String getAggregateFunctionExpr(SeriesDefinition orthoSD, java.lang.String strBaseAggExp)
          Gets the aggregation function expression
static java.util.List<SeriesDefinition> getAllOrthogonalSeriesDefinitions(Chart chart)
          Return specified axis definitions or all series definitions.
static org.eclipse.emf.common.util.EList<SeriesDefinition> getBaseSeriesDefinitions(Chart chart)
          Returns all instances of SeriesDefinition on category of chart.
static java.lang.String[] getCategoryExpressions(Chart cm)
          Returns all category expressions of chart.
static java.lang.String getFullAggregateExpression(SeriesDefinition orthoSD, SeriesDefinition categorySD)
          Return full aggregate expression which includes aggregate func and aggregate parameters.
static java.lang.String getGroupingUnitName(SeriesGrouping grouping)
          Returns grouping unit name of series grouping.
static java.lang.String getNewSampleData(AxisType axisType, int index)
          Creates new sample data according to specified axis type.
static int getQuadrant(double dAngle)
          Returns the quadrant (1-4) for given angle in degree.
static java.lang.String[] getStringTokens(java.lang.String str)
           
static int getSupportedMaxRowCount(RunTimeContext rtc)
          Returns max row count that will be supported in charts.
static java.lang.String[] getSupportedOutputFormats()
          Gets all supported output formats.
static java.lang.String[] getValueSeriesExpressions(Chart cm)
          Returns all value expressions of chart.
static java.lang.String getValueSeriesFullExpression(java.lang.String valueExpr, SeriesDefinition orthoSD, SeriesDefinition categorySD)
          Returns full expression of value series.
static java.lang.String getValueSeriesRowFullExpression(java.lang.String valueExpr, SeriesDefinition orthoSD, SeriesDefinition categorySD)
          Returns row full expression of value series.
static java.lang.String[] getYOptoinalExpressions(Chart cm)
          Returns all Y optional expressions of chart.
static boolean intersects(Polygon pg1, Polygon pg2)
          Returns if two polygons intersect each other.
static boolean isColorTransparent(ColorDefinition cdef)
          Returns if the given color definition is totally transparent.
static boolean isMagicAggregate(java.lang.String aggFunc)
          The method checks if specified aggregate function is a magic aggregate, it means these aggregates operations will change data type.
static boolean isOutputFormatSupport(java.lang.String output)
          Checks current output format can be supported
static boolean isRightToLeftLocale(com.ibm.icu.util.ULocale lcl)
          Returns if specified locale uses right-to-left direction.
static boolean isShadowDefined(Label la)
          Returns if the given label has defined a shadow.
static boolean mathEqual(double v1, double v2)
          Returns if the given two double values are equal within a small precision.
static boolean mathGE(double lv, double rv)
          Returns if the given left double value is greater than or equals to the given right value within a small precision.
static boolean mathGT(double lv, double rv)
          Returns if the given left double value is greater than the given right value within a small precision.
static boolean mathLE(double lv, double rv)
          Returns if the given left double value is less than or equals to the given right value within a small precision.
static boolean mathLT(double lv, double rv)
          Returns if the given left double value is less than the given right value within a small precision.
static boolean mathNE(double v1, double v2)
          Returns if the given two double values are not equal within a small precision.
static void mergeFont(FontDefinition original, FontDefinition source)
          Merges two fonts to the original one from a source.
static void pruneInvisibleSeries(Chart cm)
          Remove all invisible SeriesDefinitions from the runtime chart model.
static java.lang.String stringValue(java.lang.Object value)
          Returns the string representation for given object.
static TextAlignment transposeAlignment(TextAlignment ta)
           
static Anchor transposeAnchor(Anchor an)
          Transposes the anchor
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHART_MAX_ROW

public static final java.lang.String CHART_MAX_ROW
The constant defined as the key in RuntimeContext or JVM arguments, to represent the value of chart max row number.

See Also:
Constant Field Values
Constructor Detail

ChartUtil

public ChartUtil()
Method Detail

isColorTransparent

public static final boolean isColorTransparent(ColorDefinition cdef)
Returns if the given color definition is totally transparent. e.g. transparency==0.

Parameters:
cdef -
Returns:
if the given color definition is totally transparent

isShadowDefined

public static final boolean isShadowDefined(Label la)
Returns if the given label has defined a shadow.

Parameters:
la -
Returns:
if the given label has defined a shadow.

mathEqual

public static final boolean mathEqual(double v1,
                                      double v2)
Returns if the given two double values are equal within a small precision.

Parameters:
v1 -
v2 -

mathNE

public static final boolean mathNE(double v1,
                                   double v2)
Returns if the given two double values are not equal within a small precision.

Parameters:
v1 -
v2 -

mathLT

public static final boolean mathLT(double lv,
                                   double rv)
Returns if the given left double value is less than the given right value within a small precision.

Parameters:
v1 -
v2 -

mathLE

public static final boolean mathLE(double lv,
                                   double rv)
Returns if the given left double value is less than or equals to the given right value within a small precision.

Parameters:
v1 -
v2 -

mathGT

public static final boolean mathGT(double lv,
                                   double rv)
Returns if the given left double value is greater than the given right value within a small precision.

Parameters:
v1 -
v2 -

mathGE

public static final boolean mathGE(double lv,
                                   double rv)
Returns if the given left double value is greater than or equals to the given right value within a small precision.

Parameters:
lv -
rv -

formatDouble

public static java.lang.String formatDouble(double value)
Formats the double value with fixed precision.


convertPixelsToPoints

public static final double convertPixelsToPoints(IDisplayServer idsSWT,
                                                 double dOriginalHeight)
Convert pixel value to points.

Parameters:
idsSWT -
dOriginalHeight -
Returns:
points value

getQuadrant

public static final int getQuadrant(double dAngle)
Returns the quadrant (1-4) for given angle in degree. Specially, -1 means Zero degree. -2 means 90 degree, -3 means 180 degree, -4 means 270 degree.

Parameters:
dAngle -
Returns:
quadrant

intersects

public static boolean intersects(Polygon pg1,
                                 Polygon pg2)
Returns if two polygons intersect each other.

Parameters:
pg1 -
pg2 -
Returns:
if two polygons intersect each other

mergeFont

public static void mergeFont(FontDefinition original,
                             FontDefinition source)
Merges two fonts to the original one from a source. The original one can not be null. ?Only consider inheritable properties.

Parameters:
original -
source -

stringValue

public static java.lang.String stringValue(java.lang.Object value)
Returns the string representation for given object. null for null object.

Parameters:
value -
Returns:
string value

convertFill

public static Fill convertFill(Fill fill,
                               double dValue,
                               Fill fNegative)
Converts Fill if possible. If Fill is MultipleFill type, convert to positive/negative Color according to the value. If not MultipleFill type, return original fill for positive value, or negative fill for negative value.

Parameters:
fill - Fill to convert
dValue - numeric value
fNegative - Fill for negative value. Useless for positive value or MultipleFill

transposeAnchor

public static Anchor transposeAnchor(Anchor an)
                              throws java.lang.IllegalArgumentException
Transposes the anchor

Parameters:
an - anchor
Throws:
java.lang.IllegalArgumentException

transposeAlignment

public static TextAlignment transposeAlignment(TextAlignment ta)

convertUnitTypeToCalendarConstant

public static int convertUnitTypeToCalendarConstant(ScaleUnitType unitType)
Convers Scale unit type to ICU Calendar constant.

Parameters:
unitType - Scale unit type
Returns:
Calendar constant or -1 if not found

getSupportedMaxRowCount

public static int getSupportedMaxRowCount(RunTimeContext rtc)
Returns max row count that will be supported in charts. Users can set it in JVM argument "CHART_MAX_ROW" or RuntimeContext. Default value is 10000.

Returns:
max row count that will be supported in charts.
Since:
2.2.0

getSupportedOutputFormats

public static java.lang.String[] getSupportedOutputFormats()
                                                    throws ChartException
Gets all supported output formats.

Returns:
string array of output formats
Throws:
ChartException
Since:
2.2

isOutputFormatSupport

public static boolean isOutputFormatSupport(java.lang.String output)
                                     throws ChartException
Checks current output format can be supported

Parameters:
output - current output format
Returns:
can be supported or not
Throws:
ChartException
Since:
2.2

isRightToLeftLocale

public static boolean isRightToLeftLocale(com.ibm.icu.util.ULocale lcl)
Returns if specified locale uses right-to-left direction. See ISO codes at http://www.unicode.org/unicode/onlinedat/languages.html RTL languages are Hebrew, Arabic, Urdu, Farsi (Persian), Yiddish

Parameters:
lcl - locale to check direction
Returns:
if specified locale uses right-to-left direction
Since:
2.2

checkDoublePrecise

public static boolean checkDoublePrecise(double dValue)
Checks a double value is double precise. If value is 2.1, then return true; if value is 2.1000000001 or 2.099999999999, then return false.

Parameters:
dValue -
Returns:

computeHeightOfOrthogonalAxisTitle

public static double computeHeightOfOrthogonalAxisTitle(ChartWithAxes cm,
                                                        IDisplayServer xs)
Computes the height of orthogonal axis title. Orthogonal axis is Y axis in non-transposed direction or X axis in transpose direction. Current algorithm of Axis layout is to use Axis Scale width for category axis title, and to use the chart height except chart title section for orthogonal axis title.

Parameters:
cm - chart model
xs - display server to compute pixel
Returns:
height of orthogonal axis title in form of pixels

getGroupingUnitName

public static java.lang.String getGroupingUnitName(SeriesGrouping grouping)
Returns grouping unit name of series grouping.

Parameters:
grouping -
Returns:
Since:
BIRT 2.3

createValueSeriesRowFullExpression

public static java.lang.String createValueSeriesRowFullExpression(java.lang.String expr,
                                                                  SeriesDefinition orthSD,
                                                                  SeriesDefinition categorySD)
                                                           throws ChartException
Create row full expression of value series.

Parameters:
expr -
orthSD -
categorySD -
Returns:
Throws:
ChartException
Since:
2.3

getValueSeriesFullExpression

public static java.lang.String getValueSeriesFullExpression(java.lang.String valueExpr,
                                                            SeriesDefinition orthoSD,
                                                            SeriesDefinition categorySD)
                                                     throws ChartException
Returns full expression of value series.

Parameters:
valueExpr -
orthoSD -
categorySD -
Returns:
Throws:
ChartException
Since:
2.3

getValueSeriesRowFullExpression

public static java.lang.String getValueSeriesRowFullExpression(java.lang.String valueExpr,
                                                               SeriesDefinition orthoSD,
                                                               SeriesDefinition categorySD)
                                                        throws ChartException
Returns row full expression of value series.

Parameters:
valueExpr -
orthoSD -
categorySD -
Returns:
Throws:
ChartException
Since:
2.3

getFullAggregateExpression

public static java.lang.String getFullAggregateExpression(SeriesDefinition orthoSD,
                                                          SeriesDefinition categorySD)
                                                   throws ChartException
Return full aggregate expression which includes aggregate func and aggregate parameters.

Parameters:
orthoSD -
categorySD -
Returns:
Throws:
ChartException
Since:
2.3

getAggFunParameters

public static java.lang.Object[] getAggFunParameters(SeriesDefinition orthSD,
                                                     SeriesDefinition baseSD)
Returns value of aggregate function parameters.

Parameters:
orthSD -
baseSD -
Returns:
Since:
2.3

getAggregateFunctionExpr

public static java.lang.String getAggregateFunctionExpr(SeriesDefinition orthoSD,
                                                        java.lang.String strBaseAggExp)
                                                 throws ChartException
Gets the aggregation function expression

Parameters:
orthoSD -
strBaseAggExp -
Throws:
ChartException
Since:
BIRT 2.3

getAggregateFuncExpr

public static java.lang.String getAggregateFuncExpr(SeriesDefinition orthSD,
                                                    SeriesDefinition baseSD)
                                             throws ChartException
Returns aggregation function expression.

Parameters:
orthSD -
baseSD -
Returns:
Throws:
ChartException
Since:
BIRT 2.3

isMagicAggregate

public static boolean isMagicAggregate(java.lang.String aggFunc)
The method checks if specified aggregate function is a magic aggregate, it means these aggregates operations will change data type.

Now the magic aggregates in chart include Count, DistinctCount, Top, TopPercent, Bottom, BottomPercent, Rank and PercentRank.

Parameters:
aggFunc -
Returns:
Since:
BIRT 2.3

pruneInvisibleSeries

public static void pruneInvisibleSeries(Chart cm)
Remove all invisible SeriesDefinitions from the runtime chart model.

Parameters:
cm - (will be changed)
Since:
2.3

alignWithInt

public static double alignWithInt(double dValue,
                                  boolean bForced)
Aligns a double value with a int value, if the differance between the two value is less than EPS, and if dValue is lager than 1E15, the maximum count of significant digit is set to 15

Parameters:
dValue -
bForce -
Returns:

getBaseSeriesDefinitions

public static org.eclipse.emf.common.util.EList<SeriesDefinition> getBaseSeriesDefinitions(Chart chart)
Returns all instances of SeriesDefinition on category of chart.

Parameters:
chart - chart model object.
Returns:
a list of instances of SeriesDefinition.
Since:
2.3

getAllOrthogonalSeriesDefinitions

public static java.util.List<SeriesDefinition> getAllOrthogonalSeriesDefinitions(Chart chart)
Return specified axis definitions or all series definitions. Remember return type is ArrayList, not EList, no event is fired when adding or removing an element.

Parameters:
chart - chart
Returns:
specified axis definitions or all series definitions
Since:
2.3

createRegularRowExpression

public static java.lang.String createRegularRowExpression(java.lang.String expression,
                                                          boolean hasOperation)
Create a regular row expression for the matching operation.

Parameters:
expression - specified expression.
hasOperation - indicate if the expression will include operations.
Returns:
a regular row expression
Since:
2.3

getValueSeriesExpressions

public static java.lang.String[] getValueSeriesExpressions(Chart cm)
Returns all value expressions of chart.

Parameters:
cm -
Returns:
Since:
2.3

getYOptoinalExpressions

public static java.lang.String[] getYOptoinalExpressions(Chart cm)
Returns all Y optional expressions of chart.

Parameters:
cm -
Returns:
Since:
2.3

getCategoryExpressions

public static java.lang.String[] getCategoryExpressions(Chart cm)
Returns all category expressions of chart.

Parameters:
cm -
Returns:
Since:
2.3

compareVersion

public static int compareVersion(java.lang.String va,
                                 java.lang.String vb)
Compare version number, the format of version number should be X.X.X style.

Parameters:
va - version number 1.
vb - version number 2.
Since:
2.3

getStringTokens

public static java.lang.String[] getStringTokens(java.lang.String str)

getNewSampleData

public static java.lang.String getNewSampleData(AxisType axisType,
                                                int index)
Creates new sample data according to specified axis type.

Parameters:
axisType - axis type
index - sample data index


Copyright © 2005-2008 Actuate Corp. All rights reserved.