org.eclipse.birt.chart.util
Class ChartUtil

java.lang.Object
  extended byorg.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 boolean checkDoublePrecise(double dValue)
          Checks a double value is double precise.
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 int getQuadrant(double dAngle)
          Returns the quadrant (1-4) for given angle in degree.
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 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 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 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.


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.


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.


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 -

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


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