The Using Rules to Format Crosstabs sample application explores the use of
rules to specify custom formatting for a Crosstab. BIRules
can
setup a connection to Oracle OLAP (the source of the business data for the application)
and to the BI Beans Catalog (where object definitions, like crosstabs and graphs,
are saved).
The BIRules
class extends BIFrame
. BIRules
provides a menu with access to a simple connection dialog, which prompts a user
for security credentials. It then makes the two connections described above.
After the connection is established, a new crosstab can be created using the
New Crosstab file menu option or toolbar button.
After a new Crosstab is created, the rules menu options and toolbar buttons
are enabled. When the Crosstab is closed, these options are disabled.
The rules menu options and toolbar buttons can each be toggled on and off, so that the underlying rules can be added and removed from the Crosstab. The rules provided in the sample enable a user to:
Format values in the Sale Revenue measure as currency
Format a single databody cell with a border and font style
Format a metadata member with particular colors and font style
Format databody cells belonging to divisions in the Product layer with bold and italic font styles
Stoplight format Sales values greater than ten million in green
Stoplight format Sales values less than or equal to ten million in yellow
Stoplight format Sales values less than or equal to two million in red
These examples demonstrate:
How to create rules based on QDRs, values, and combinations of multiple criteria
How to create number formatting rules for the databody
How to create style rules for the databody and the headers
The relationship between the order of rules in a manager and rule precedence
The bulk of the code to manipulate the Crosstab's rules can be found in the following methods. These are the methods that are called when the user adds or removes a rule using the rules menu or toolbar buttons.
protected void applyCurrencyFormatting(boolean
bApply);
protected void applySingleCellFormatting(boolean bApply);
protected void applyHeaderFormatting(boolean bApply);
protected
void applyDivisionFormatting(boolean bApply);
protected void applyGreenStoplightFormatting(boolean
bApply);
protected void applyYellowStoplightFormatting(boolean
bApply);
protected void applyRedStoplightFormatting(boolean bApply);
protected void applyStoplightFormatting(boolean bApply, int ruleID,
ViewStyle viewStyle, NumberValueDiscriminator nvDisc);
In addition to the above methods, there are a few helper methods that the above
methods call. These helper methods facilitate maintaining order among Rules
within RuleBundles
and among RuleBundles
within Vectors
.
protected void
setDatabodyStyleRuleBundle(int id, RuleBundle bundle, Vector bundles);
protected
RuleBundle getDatabodyStyleRuleBundle(String name, Vector bundles);
protected
void removeDatabodyStyleRuleBundle(int id, String name, Vector bundles);
protected
void addDatabodyStyleRule(int ruleID, Rule rule, int ruleBundleID, RuleBundle
bundle);
protected boolean removeDatabodyStyleRule(int ruleID,
int ruleBundleID, RuleBundle bundle);
Copyright © 2004 Oracle Corporation. All Rights Reserved. |