Annotations

In this section:

Multiple instances of two objects are all that is required to create annotations. They are the label and box drawn behind it (if any). Both the label and box have attributes associated with them. These attributes can be set using methods in Perspective for Java that are available for other chart objects (for example, setTextString(), setFillColor(), and so on)


Top of page

x
Object IDs

The following object IDs are used to create annotations:

where:

index

Is a value in the range zero (0) to the maximum number of annotations set by setMaxNumAnnotations(int nMax). The default maximum number of annotations is 30.

Note that the title, subtitle and footnote objects have the same behavior as annotations. Their Object IDs are returned by the following methods:


Top of page

x
Enable Annotation

The setDisplay() method must be used to enable the annotation object:


Top of page

x
Define Annotation Label/String

The setTextString() method can be used to define an annotation's label/string:


Top of page

x
Set Annotation Text Color

The setFillColor() method can be used to define the color of the annotation label/string:

Note that all other fill types are also available for annotation labels (that is, gradient, texture, and so on).


Top of page

x
Set Annotation Font Size

The normal font size methods can be used to set the font size of an annotation label.

Example:

setFontSizeAbsolute(getAnnotation(0),true);
setFontSizeInPoints(getAnnotation(0),20);

Top of page

x
Set Annotation Location

The setRect() function can be used to specify the location of an annotation object.

Example:

setRect(getAnnotation(0),new Rectangle(-15340,11000,29850,1800)); 

Note: If you do not specify a location, the annotation text is drawn in the default location (the center of the chart) and may not be detectable. This is due to the fact that a rectangle is not internally stored for the annotation. Unless specified otherwise, it will use the default rectangle set by setRect(). It is recommended you store a rectangle location for each annotation.

Example:

setDisplay(getAnnotation(0), true); 
setTextString(getAnnotation(0), "This is a movable annotation"); 
setFillColor(getAnnotation(0), new Color(0,255,0));
setRect(getAnnotation(0),new Rectangle(-15340,11000,29850,1800)); 
setFontSizeAbsolute(getAnnotation(0),true);
setFontSizeInPoints(getAnnotation(0),20.0);

graph with annotation


Top of page

x
Enable Annotation Box

The setDisplay() method must be used to enable the annotation box object:


Top of page

x
Set Annotation Box Color

The setFillColor() method can be used to define the color of the annotation box:


Top of page

x
Enable/Disable Annotation Box Border Color

The setTransparentBorderColor() method can be used to enable/disable the border color around the annotation box:

See Beveled Borders for information about applying a border to an annotation box.

Example:

setDisplay(getAnnotation(0), true); 
setTextString(getAnnotation(0), "This is a movable annotation"); 
setFillColor(getAnnotation(0), new Color(0,255,0));
setRect(getAnnotation(0),new Rectangle(-15340,11000,29850,1800)); 
setFontSizeAbsolute(getAnnotation(0),true);
setFontSizeInPoints(getAnnotation(0),20.0);
setDisplay(getAnnotationBox(0), true); 
setFillColor(getAnnotationBox(0), new Color(0,0,255)); 
setTransparentBorderColor(getAnnotationBox(0), false); 

graph with annotation box border color


Top of page

x
Initial/Default Annotation Box Settings

The default maximum number of annotations is 30. For this first default set of annotations, the transparent fill color is set to true and border colors are omitted for the associated annotation box:


Top of page

x
Maximum Number of Annotations

The following methods can be used to get/set the maximum number of annotations:

where:

newValue

Is a value in the range 0...999.

For annotations in excess of the default (30), the setTransparentFillColor() and setTransparentBorderColor() methods should be used to set transparent fill and border colors for the associated annotation box as desired:


WebFOCUS