Text Attributes

Attribute Font

Text is drawn using Font objects constructed using the FontName, FontSize and FontStyle attributes. The AbstractChartNode.setFont(Font) method does not save the Font object, but sets these three attributes.

This arrangement allows one to specify font size and style at lower nodes and change the font face at the root node.

Multiline text strings are allowed. They are created by newline characters in the string that creates the text item.

Attribute FontName

FontName is a string-valued attribute that specifies the logical font name or a font face name. Its default value is SansSerif. Java, always defines the font names Dialog, DialogInput, Monospaced, Serif, SansSerif, and Symbol. Depending on the system, additional font names may be defined.

Attribute FontSize

FontSize is an integer-valued attribute that specifies the point size of the font. Its default value is 12.

Attribute FontStyle

FontStyle is an integer-valued attribute that specifies the font style. This can be a bitwise combination of Font.PLAIN, Font.BOLD and/or Font.ITALIC. Its default value is Font.PLAIN.

Samples

Following are sample fonts in styles plain, italic and bold. These may look different on different platforms.

Attribute TextColor

TextColor is a Color-valued attribute that specifies the color in which the text is drawn. Its default value is Color.black.

Attribute TextFormat

TextFormat is a Format-valued or a String-valued attribute that specifies how to format string objects

TextFormat can also be set using a String, which is used to generate a Format object when the attribute is accessed. The Format object is created using the value of locale in the chart node.

Some strings have special meanings (case is ignored in these strings):

      "Date(SHORT)" means use:
DateFormat.getDateInstance(SHORT, Locale)

      "Date(MEDIUM)" means use
DateFormat.getDateInstance(MEDIUM, Locale)

      "Date(LONG)" means use:
DateFormat.getDateInstance(LONG, Locale)

      "Currency" means use
NumberFormat.getCurrencyInstance(Locale)

      "Percent" means use:
NumberFormat.getPercentInstance(Locale)

If TextFormat has a string value that is not one of the above, then

new DecimalFormat (value, new DecimalFormatSymbols(Locale))

is used. For example, if its value is a String "0.00", then numbers will be formatted with exactly two digits after the decimal place. See DecimalFormat for a detailed description of these format patterns.

The default value of TextFormat is the value returned by the factory method NumberFormat.getInstance(Locale).

Attribute Title

Title is a Text-valued attribute that contains the title for a node. The class Text holds a string and its alignment and offset information.

The alignment of a Text object is the bitwise combination of one of

      TEXT_X_LEFT, TEXT_X_CENTER, TEXT_X_RIGHT, and one of

      TEXT_Y_BOTTOM, TEXT_Y_CENTER, TEXT_Y_TOP.

The offset moves the start of the text away from the reference point in the direction of the alignment. So if the alignment bit TEXT_X_LEFT is set and the offset is greater than zero then the text starts a distance further to the left than if the offset were zero. The distance moved is the value of offset times the default marker size. The offset is usually zero, but the Data node sets it to 2.0 for labeling data points.

A Text object is drawn relative to a reference point. The alignment specifies the position of the reference point on the box that contains the text. There are nine such possible positions. In the following samples, the reference point is marked with a square.

If the text is drawn at an angle, then the alignment is relative to the horizontally/vertically aligned bounding box of the text.



Visual Numerics - Developers of IMSL and PV-WAVE
http://www.vni.com/
PHONE: 713.784.3131
FAX:713.781.9260