Chemical Data Processing Library Python API - Version 1.2.0
|
A graphics primitive representing a block of styled text. More...
Public Member Functions | |
None | __init__ () |
Construct an empty text block primitive at position (0, 0). | |
None | __init__ (TextBlockPrimitive2D prim) |
Initializes a copy of the TextBlockPrimitive2D instance prim. More... | |
TextBlockPrimitive2D | assign (TextBlockPrimitive2D prim) |
Replaces the current state of self with a copy of the state of the TextBlockPrimitive2D instance prim. More... | |
None | setText (str text) |
Specifies the block's text content. More... | |
None | clearText () |
Clears the block's text content. | |
str | getText () |
Returns the block's text content. More... | |
bool | hasText () |
Tells whether the text block has any visible text (includes whitespace). More... | |
None | setPosition (Math.Vector2D pos) |
Sets the position of the text block in 2D space. More... | |
None | setPosition (float x, float y) |
Sets the position of the text block to (x, y). More... | |
Math.Vector2D | getPosition () |
Returns the position of the text block. More... | |
None | setPen (Pen pen) |
Sets the pen defining the default text color. More... | |
Pen | getPen () |
Returns the pen defining the default text color. More... | |
None | setFont (Font font) |
Sets the font used for text rendering. More... | |
Font | getFont () |
Returns the font used for text rendering. More... | |
None | setAlignment (int alignment) |
Specifies the way lines should be horizontally aligned. More... | |
int | getAlignment () |
Returns the active horizontal text alignment specification. More... | |
None | setLineSpacing (float spacing) |
Sets the line spacing value. More... | |
float | getLineSpacing () |
Returns the active line spacing value. More... | |
None | layout (FontMetrics font_metrics) |
Performs a layout of the text for the currently specified font using the provided Vis.FontMetrics instance font_metrics. More... | |
Public Member Functions inherited from CDPL.Vis.GraphicsPrimitive2D | |
int | getObjectID () |
Returns the numeric identifier (ID) of the wrapped C++ class instance. More... | |
None | render (Renderer2D renderer) |
Visualizes the graphics primitive by means of the Renderer2D instance renderer. More... | |
None | getBounds (Rectangle2D bounds, FontMetrics font_metrics=0) |
Calculates the bounds of the graphics primitive. More... | |
GraphicsPrimitive2D | clone () |
Creates a dynamically allocated copy of the graphics primitive. More... | |
Properties | |
text = property(getText, setText) | |
position = property(getPosition, setPosition) | |
pen = property(getPen, setPen) | |
font = property(getFont, setFont) | |
alignment = property(getAlignment, setAlignment) | |
lineSpacing = property(getLineSpacing, setLineSpacing) | |
Properties inherited from CDPL.Vis.GraphicsPrimitive2D | |
objectID = property(getObjectID) | |
A graphics primitive representing a block of styled text.
Class TextBlockPrimitive2D
is smiliar to Vis.TextLabelPrimitive2D but way more versatile. TextBlockPrimitive2D
can store/render text that spans multiple lines with configurable line spacing (see setLineSpacing()) and alignment (see setAlignment()), and supports changing text color and various attributes like font weight and slant for individual text portions. Furthermore, text fragments can be rendered sub/super-scripted, under- and overlined as well as striked out. This is achieved by using an XML-based syntax where a portion of text to be rendered in a particular style is enclosed in specific start and end tags. More information on the syntax, the supported styling tags and their meaning can be found in the documentation of the method setText().
None CDPL.Vis.TextBlockPrimitive2D.__init__ | ( | TextBlockPrimitive2D | prim | ) |
Initializes a copy of the TextBlockPrimitive2D instance prim.
prim | The TextBlockPrimitive2D instance to copy. |
TextBlockPrimitive2D CDPL.Vis.TextBlockPrimitive2D.assign | ( | TextBlockPrimitive2D | prim | ) |
Replaces the current state of self with a copy of the state of the TextBlockPrimitive2D instance prim.
prim | The TextBlockPrimitive2D instance to copy. |
None CDPL.Vis.TextBlockPrimitive2D.setText | ( | str | text | ) |
Specifies the block's text content.
Color, font attributes and style of individual text fragments can be controlled by enclosing the concerned piece of text in specific XML tags. The following tags are supported:
Tag | Effect/Description |
---|---|
Line break | |
Boldfaced text | |
Italicized text | |
<o> | Overlined text |
Underlined text | |
Newline characters
are regarded and interpreted as such. Tab characters
\t
are replaced by a single whitespace character. Any other special characters are deleted. The supported tags listed above are all optional. Plain ASCII text will thus be rendered using the set font (see setFont()) and color (see setPen()).
text | The text content of the block. |
Base.ValueError | if XML parsing of the specified text failed. |
str CDPL.Vis.TextBlockPrimitive2D.getText | ( | ) |
Returns the block's text content.
bool CDPL.Vis.TextBlockPrimitive2D.hasText | ( | ) |
Tells whether the text block has any visible text (includes whitespace).
True
if there is any visible text and False
otherwise. None CDPL.Vis.TextBlockPrimitive2D.setPosition | ( | Math.Vector2D | pos | ) |
Sets the position of the text block in 2D space.
The position specifies the upper-left corner of the text block's bounding box.
pos | Theposition of the text block. |
None CDPL.Vis.TextBlockPrimitive2D.setPosition | ( | float | x, |
float | y | ||
) |
Sets the position of the text block to (x, y).
The position specifies the upper-left corner of the text block's bounding box.
x | The x-position of the text block. |
y | The y-position of the baseline. |
Math.Vector2D CDPL.Vis.TextBlockPrimitive2D.getPosition | ( | ) |
Returns the position of the text block.
None CDPL.Vis.TextBlockPrimitive2D.setPen | ( | Pen | pen | ) |
Sets the pen defining the default text color.
pen | The pen defining the default text color. |
Pen CDPL.Vis.TextBlockPrimitive2D.getPen | ( | ) |
Returns the pen defining the default text color.
None CDPL.Vis.TextBlockPrimitive2D.setFont | ( | Font | font | ) |
Sets the font used for text rendering.
font | The font used for text rendering. |
Font CDPL.Vis.TextBlockPrimitive2D.getFont | ( | ) |
Returns the font used for text rendering.
None CDPL.Vis.TextBlockPrimitive2D.setAlignment | ( | int | alignment | ) |
Specifies the way lines should be horizontally aligned.
Possible horizontal alignment values are defined in namespace Vis.Alignment.
alignment | The horizontal text alignment specification. |
int CDPL.Vis.TextBlockPrimitive2D.getAlignment | ( | ) |
Returns the active horizontal text alignment specification.
Possible horizontal alignment values are defined in namespace Vis.Alignment.
None CDPL.Vis.TextBlockPrimitive2D.setLineSpacing | ( | float | spacing | ) |
Sets the line spacing value.
The final base line spacing is the product of the specified line spacing and the font height returned by the method Vis.FontMetrics.getHeight() for the set font.
spacing | The desired line spacing. |
float CDPL.Vis.TextBlockPrimitive2D.getLineSpacing | ( | ) |
Returns the active line spacing value.
None CDPL.Vis.TextBlockPrimitive2D.layout | ( | FontMetrics | font_metrics | ) |
Performs a layout of the text for the currently specified font using the provided Vis.FontMetrics instance font_metrics.
font_metrics | An instance of a class implementing the Vis.FontMetrics interface. |