ModraUp Ruby API Documentation Ruby API Reference

Class: Layout::FormattedText

Inherits:
Layout::Entity show all

Overview

Formatted text. Font size, font type, color, and alignment are defined using Layout::Entity#style.

Examples:

Title

title = Layout::FormattedText.new("Ground-floor plan  1:100", Geom::Point2d.new(20.mm, 205.mm),
                                  Layout::FormattedText::ANCHOR_TYPE_TOP_LEFT)
s = title.style
s.font_size = 14
title.style = s

Constants # collapse

Layout::FormattedText::ANCHOR_TYPE_TOP_LEFT

The anchor is at the top left of the text.

Returns:

  • (Integer)

Examples:

Layout::FormattedText::ANCHOR_TYPE_TOP_LEFT
Layout::FormattedText::ANCHOR_TYPE_CENTER_LEFT

The anchor point is at the center left of the text.

Returns:

  • (Integer)

Examples:

Layout::FormattedText::ANCHOR_TYPE_CENTER_LEFT
Layout::FormattedText::ANCHOR_TYPE_BOTTOM_LEFT

The anchor is at the bottom left of the text.

Returns:

  • (Integer)

Examples:

Layout::FormattedText::ANCHOR_TYPE_BOTTOM_LEFT
Layout::FormattedText::ANCHOR_TYPE_TOP_RIGHT

The anchor is at the top right of the text.

Returns:

  • (Integer)

Examples:

Layout::FormattedText::ANCHOR_TYPE_TOP_RIGHT
Layout::FormattedText::ANCHOR_TYPE_CENTER_RIGHT

The anchor point is at the center right of the text.

Returns:

  • (Integer)

Examples:

Layout::FormattedText::ANCHOR_TYPE_CENTER_RIGHT
Layout::FormattedText::ANCHOR_TYPE_BOTTOM_RIGHT

The anchor is at the bottom right of the text.

Returns:

  • (Integer)

Examples:

Layout::FormattedText::ANCHOR_TYPE_BOTTOM_RIGHT
Layout::FormattedText::ANCHOR_TYPE_TOP_CENTER

The anchor point is at the top center of the text.

Returns:

  • (Integer)

Examples:

Layout::FormattedText::ANCHOR_TYPE_TOP_CENTER
Layout::FormattedText::ANCHOR_TYPE_CENTER_CENTER

The anchor point is at the center of the text.

Returns:

  • (Integer)

Examples:

Layout::FormattedText::ANCHOR_TYPE_CENTER_CENTER
Layout::FormattedText::ANCHOR_TYPE_BOTTOM_CENTER

The anchor point is at the bottom center of the text.

Returns:

  • (Integer)

Examples:

Layout::FormattedText::ANCHOR_TYPE_BOTTOM_CENTER

Class Method Summary # collapse

  • .new(text, point, anchor_type) ⇒ Layout::FormattedText
    Create text. Place the text box according to the content size when anchoring points are provided (layout the text box based on the content size, calculating the font size when adding to the document); place paragraphs aligned to the left, center, or right based on the anchoring points. When bounding boxes are provided, the text wraps within the box. The default font, size, and color are taken from the model's text settings.

Instance Method Summary # collapse

Inherited from Layout::Entity

Class Method Details

Layout::FormattedText.new(text, point, anchor_type) ⇒ Layout::FormattedTextLayout::FormattedText.new(text, bounds) ⇒ Layout::FormattedText

Create text. Place the text box according to the content size when anchoring points are provided (layout the text box based on the content size, calculating the font size when adding to the document); place paragraphs aligned to the left, center, or right based on the anchoring points. When bounding boxes are provided, the text wraps within the box. The default font, size, and color are taken from the model's text settings.

Parameters:

  • text (String)
  • point (Geom::Point2d) Anchor point, paper inches
  • anchor_type (Integer) ANCHOR_TYPE_*
  • bounds (Geom::Bounds2d) Label text box

Returns:

  • (Layout::FormattedText)

Raises:

  • [ArgumentError] Unknown anchor type

Examples:

Layout::FormattedText.new("Notes", Geom::Point2d.new(1, 1), Layout::FormattedText::ANCHOR_TYPE_TOP_LEFT)

Instance Method Details

text.plain_text ⇒ String

Content of the text.

Returns:

  • (String)

Examples:

Layout::FormattedText.new("Notes", Geom::Bounds2d.new(1, 1, 2, 1)).plain_text  #=> "Notes"

text.plain_text = string

Modify the text content, with one-step undo. The text box size remains unchanged.

Parameters:

  • string (String)

Returns:

  • (String)

Examples:

t = Layout::FormattedText.new("Notes", Geom::Bounds2d.new(1, 1, 2, 1))
t.plain_text = "Dimensions in millimeters"

text.display_text ⇒ String

The text to display (OpenSu does not have automatic text fields, same as #plain_text).

Returns:

  • (String)

Examples:

Layout::FormattedText.new("Notes", Geom::Bounds2d.new(1, 1, 2, 1)).display_text