Common Element Properties
All elements share a basic set of properties, including foreground, background, font, alignment, visibility, etc. The following sections explain how to use these properties.
Color Property
Color properties (foreground/text and background/fill) are frequently used to highlight a text or textbox element. The simplest way to specify a color property is to assign a string containing one of the constants from the java.awt.Color class: black, blue, cyan, darkGray, gray, green, lightGray, magenta, orange, pink, red, white, and yellow.
foreground = 'red';
Since color is a Java type, the class name must be fully qualified. You can also specify a color as java.awt.Color object, an integer (e.g., hexadecimal) representing the RGB value of a color, an array of RGB values, or a JSON object.
foreground = java.awt.Color.red;
background = 0xFF00FF;
// RRGGBB foreground = [255, 255, 0];
foreground = {r:255,g:255,b:0};
Alternatively, you can create a color object by calling the constructor with the the 'new' operator. foreground = new java.awt.Color(0.5, 1, 0); Note that the parameters to the color constructor have type float. Because JavaScript treats all numbers as float by default, you have to explicitly convert them to integer if you want to specify the RGB values in the range of 0-255. The default float parameters pass the RGB value in the range of 0-1, where 1 is equivalent to 255 in the integer version.
|
View a 2-minute demonstration of InetSoft's easy, agile, and robust BI software. |
Font Property
You can specify the font property with a string containing the font name, style, and size, separated by dashes, or by creating a java.awt.Font object.
font = 'Verdana-BOLD-12';
font = new java.awt.Font('Verdana', java.awt.Font.BOLD, 12);
The name of the font can be a TrueType font name, or a logical font name. Logical font names are not recommended, however, because the logical font may be replaced by a different font in the runtime environment. There are three font styles, Font.PLAIN, Font.BOLD and Font.ITALIC. The styles can be combined with a bitwise OR.
font = new java.awt.Font('Verdana', java.awt.Font.BOLD |
java.awt.Font.ITALIC, 12);
The final parameter specifies the size of the font. Style Intelligence provides an extended font that supports additional styles:
Table 2. Font Styles
Font Style
|
Description
|
Underline
|
Draw an underline below the text. The line style
can be any one of the Style Intelligence Line
Styles.
|
Strikethrough
|
Draw a line through the text in the middle.
|
Superscript
|
Draw the text at the upper corner of the previous
text.
|
Subscript
|
Draw the text at the lower corner of the previous
text.
|
SMALLCAPS
|
Draw all letters in capital letter, but draw the
lowercase letters in a smaller size.
|
Allcaps
|
Convert all letters to uppercase.
|
Shadow
|
Draw the text with a shadow effect.
|
To create an extended font, you must use the fully qualified name of inetsoft.report.StyleFont class.
font = new inetsoft.report.StyleFont('Verdana',
java.awt.Font.BOLD | inetsoft.report.StyleFont.UNDERLINE, 12,
StyleReport.THIN_LINE);
The final parameter specifies the line style used to draw the underline.