123456789_123456789_123456789_123456789_123456789_

Class: Layout::Label

Relationships
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Entity
Instance Chain:
self, Entity
Inherits: Layout::Entity

Overview

This is an interface to a label entity. A Label consists of a FormattedText and the label leader Path. A Label may be connected to another Entity via a ConnectionPoint.

Version:

  • LayOut 2018

Constant Summary

Class Method Summary

Instance Attribute Summary

Entity - Inherited

#locked=

The #locked= method sets the Entity as locked or unlocked.

#locked?

The #locked? method returns whether the Entity is locked or unlocked.

#on_shared_layer?

The #on_shared_layer? method returns whether or not the Entity is on a shared Layer.

#style

The #style method returns the Style of the Entity.

#style=

The #style= method sets the Style of the Entity.

#untransformed_bounds

The #untransformed_bounds method returns the untransformed bounds of the Entity.

#untransformed_bounds=

The #untransformed_bounds= method sets the untransformed bounds of the Entity.

Instance Method Summary

Entity - Inherited

#==

The #== method checks to see if the two Entitys are equal.

#bounds

The #bounds method returns the 2D rectangular bounds of the Entity.

#document

The #document method returns the Document that the Entity belongs to, or nil if it is not in a Document.

#drawing_bounds

The #drawing_bounds method returns the 2D rectangular drawing bounds of the Entity.

#group

The #group method returns the Group the Entity belongs to, or nil if it is not in a Group.

#layer_instance

The #layer_instance method returns the LayerInstance that the Entity is on, or nil if it is not associated with a LayerInstance.

#move_to_group

The #move_to_group method moves the Entity into a Group.

#move_to_layer

The #move_to_layer method moves the Entity to the given Layer.

#page

The #page method returns the Page that the Entity belongs to, or nil if it is on a shared Layer or not in a Document.

#transform!

The #transform! method transforms the Entity with a given ::Geom::Transformation2d.

#transformation

The #transformation method returns the explicit ::Geom::Transformation2d.

Constructor Details

.new(text, leader_type, target_point, bounds) ⇒ Label .new(text, leader_type, target_point, anchor_point, anchor_type) ⇒ Label

The #initialize method creates a new disconnected Label.

Examples:

text = "A label"
leader_type = Layout::Label::LEADER_LINE_TYPE_BEZIER
target_point = Geom::Point2d.new(1, 1)
bounds = Geom::Bounds2d.new(2, 1, 1, 1)
label_from_bounds = Layout::Label.new(text, leader_type, target_point,
  bounds)
anchor_point = Geom::Point2d.new(2, 2)
anchor_type = Layout::FormattedText::ANCHOR_TYPE_TOP_RIGHT
label_from_point = Layout::Label.new(text, leader_type, target_point,
  anchor_point, anchor_type)

Overloads:

  • .new(text, leader_type, target_point, bounds) ⇒ Label

    Parameters:

    • text (String)

      The label text

    • leader_type (Integer)

      The leader line type

    • target_point (Geom::Point2d)

      Where the label leader should point to

    • bounds (Geom::Bounds2d)
  • .new(text, leader_type, target_point, anchor_point, anchor_type) ⇒ Label

    Parameters:

    • text (String)

      The label text

    • leader_type (Integer)

      The leader line type

    • target_point (Geom::Point2d)

      Where the label leader should point to

    • anchor_point (Geom::Point2d)

      The anchor point for the label text’s position.

    • anchor_type (Integer)

      Defines which point of the label text is set by anchor_point.

Raises:

  • (ArgumentError)

    if anchor_type is not a valid anchor type

  • (ArgumentError)

    if leader_type is not a valid leader line type

  • (ArgumentError)

    if bounds is zero size

  • (ArgumentError)

    if plain_text is an empty string

Version:

  • LayOut 2018

Instance Attribute Details

#connection_typeInteger (rw)

The #connection_type method returns the type of the text connection for the Label.

The leader line type can be one of the following values:

Layout::Label::CONNECTION_TYPE_NONE
Layout::Label::CONNECTION_TYPE_AUTO
Layout::Label::CONNECTION_TYPE_REVERSE_AUTO
Layout::Label::CONNECTION_TYPE_TOP_LEFT
Layout::Label::CONNECTION_TYPE_CENTER_LEFT
Layout::Label::CONNECTION_TYPE_BOTTOM_LEFT
Layout::Label::CONNECTION_TYPE_TOP_RIGHT
Layout::Label::CONNECTION_TYPE_CENTER_RIGHT
Layout::Label::CONNECTION_TYPE_BOTTOM_RIGHT

Examples:

text = "A label"
leader_type = Layout::Label::LEADER_LINE_TYPE_BEZIER
target_point = Geom::Point2d.new(1, 1)
bounds = Geom::Bounds2d.new(2, 1, 1, 1)
label_from_bounds = Layout::Label.new(text, leader_type, target_point,
  bounds)
text_connection_type = label_from_bounds.connection_type

Version:

  • LayOut 2018

#connection_type=(connection_type) (rw)

The #connection_type= method sets the type of the text connection for the Label.

The leader line type can be one of the following values:

Layout::Label::CONNECTION_TYPE_NONE
Layout::Label::CONNECTION_TYPE_AUTO
Layout::Label::CONNECTION_TYPE_REVERSE_AUTO
Layout::Label::CONNECTION_TYPE_TOP_LEFT
Layout::Label::CONNECTION_TYPE_CENTER_LEFT
Layout::Label::CONNECTION_TYPE_BOTTOM_LEFT
Layout::Label::CONNECTION_TYPE_TOP_RIGHT
Layout::Label::CONNECTION_TYPE_CENTER_RIGHT
Layout::Label::CONNECTION_TYPE_BOTTOM_RIGHT

Examples:

text = "A label"
leader_type = Layout::Label::LEADER_LINE_TYPE_BEZIER
target_point = Geom::Point2d.new(1, 1)
bounds = Geom::Bounds2d.new(2, 1, 1, 1)
label_from_bounds = Layout::Label.new(text, leader_type, target_point,
  bounds)
label_from_bounds.connection_type = Layout::Label::CONNECTION_TYPE_TOP_LEFT

Parameters:

  • connection_type (Integer)

Raises:

Version:

  • LayOut 2018

#leader_lineLayout::Path (rw)

The #leader_line method returns a copy of the leader line.

Examples:

text = "A label"
leader_type = Layout::Label::LEADER_LINE_TYPE_BEZIER
target_point = Geom::Point2d.new(1, 1)
bounds = Geom::Bounds2d.new(2, 1, 1, 1)
label_from_bounds = Layout::Label.new(text, leader_type, target_point,
  bounds)
leader = label_from_bounds.leader_line

Version:

  • LayOut 2018

#leader_line=(leader_path) (rw)

The #leader_line= method sets the leader line.

Examples:

text = "A label"
leader_type = Layout::Label::LEADER_LINE_TYPE_BEZIER
target_point = Geom::Point2d.new(1, 1)
bounds = Geom::Bounds2d.new(2, 1, 1, 1)
label_from_bounds = Layout::Label.new(text, leader_type, target_point,
  bounds)
path = Layout::Path.new(Geom::Point2d.new(1, 2), Geom::Point2d.new(2, 3))
label_from_bounds.leader_line = path

Parameters:

Raises:

Version:

  • LayOut 2018

#leader_line_typeInteger (rw)

The #leader_line_type method returns the type of the leader line for the Label.

The leader line type can be one of the following values:

Layout::Label::LEADER_LINE_TYPE_SINGLE_SEGMENT
Layout::Label::LEADER_LINE_TYPE_TWO_SEGMENT
Layout::Label::LEADER_LINE_TYPE_BEZIER
Layout::Label::LEADER_LINE_TYPE_UNKNOWN

Examples:

text = "A label"
leader_type = Layout::Label::LEADER_LINE_TYPE_BEZIER
target_point = Geom::Point2d.new(1, 1)
bounds = Geom::Bounds2d.new(2, 1, 1, 1)
label_from_bounds = Layout::Label.new(text, leader_type, target_point,
  bounds)
leader_type = label_from_bounds.leader_line_type

Version:

  • LayOut 2018

#leader_line_type=(leader_type) (rw)

The #leader_line_type= method sets the type of the leader line for the Label.

The leader line type can be one of the following values:

Layout::Label::LEADER_LINE_TYPE_SINGLE_SEGMENT
Layout::Label::LEADER_LINE_TYPE_TWO_SEGMENT
Layout::Label::LEADER_LINE_TYPE_BEZIER
Layout::Label::LEADER_LINE_TYPE_UNKNOWN

Examples:

text = "A label"
leader_type = Layout::Label::LEADER_LINE_TYPE_BEZIER
target_point = Geom::Point2d.new(1, 1)
bounds = Geom::Bounds2d.new(2, 1, 1, 1)
label_from_bounds = Layout::Label.new(text, leader_type, target_point,
  bounds)
label_from_bounds.leader_line_type = Layout::Label::LEADER_LINE_TYPE_BEZIER

Parameters:

  • leader_type (Integer)

Raises:

  • (LockedLayerError)

    if the Label is on a locked Layer

  • (LockedEntityError)

    if the Label is locked

  • (ArgumentError)

    if leader_type is Layout::Label::LEADER_LINE_TYPE_UNKNOWN or not a valid leader line type

Version:

  • LayOut 2018

#textLayout::FormattedText (rw)

The #text method returns a copy of the FormattedText of the Label.

Examples:

text = "A label"
leader_type = Layout::Label::LEADER_LINE_TYPE_BEZIER
target_point = Geom::Point2d.new(1, 1)
bounds = Geom::Bounds2d.new(2, 1, 1, 1)
label_from_bounds = Layout::Label.new(text, leader_type, target_point,
  bounds)
text = label_from_bounds.text

Version:

  • LayOut 2018

#text=(new_text) (rw)

The #text= method sets the FormattedText of the Label.

Examples:

text = "A label"
leader_type = Layout::Label::LEADER_LINE_TYPE_BEZIER
target_point = Geom::Point2d.new(1, 1)
bounds = Geom::Bounds2d.new(2, 1, 1, 1)
label_from_bounds = Layout::Label.new(text, leader_type, target_point,
  bounds)
anchor = Geom::Point2d.new(1, 1)
anchor_type = Layout::FormattedText::ANCHOR_TYPE_TOP_LEFT
text = Layout::FormattedText.new("Test", anchor, anchor_type)
label_from_bounds.text = text

Parameters:

Raises:

Version:

  • LayOut 2018

Instance Method Details

#connect(connection_point)

The #connect method connects the Label to the given ConnectionPoint. The leader line will be adjusted to point at the ConnectionPoint. The Label must be in the same Document as the ConnectionPoint. If both the Label and the ConnectionPoint‘s Entity are on non-shared Layers, they must be on the same Page.

Examples:

text = "A label"
leader_type = Layout::Label::LEADER_LINE_TYPE_BEZIER
target_point = Geom::Point2d.new(1, 1)
bounds = Geom::Bounds2d.new(2, 1, 1, 1)
label = Layout::Label.new(text, leader_type, target_point, bounds)
rect = Layout::Rectangle.new([4, 4, 4, 4])

doc = Layout::Document.new
doc.add_entity(label, doc.layers.first, doc.pages.first)
doc.add_entity(rect, doc.layers.first, doc.pages.first)

point = Geom::Point2d.new(4, 4)
# Create a Connection Point to a LayOut Entity in the Document
cp = Layout::ConnectionPoint.new(rect, point)
label.connect(cp)

Parameters:

Raises:

Version:

  • LayOut 2018

#disconnect

The #disconnect method disconnects the Label from its ConnectionPoint. The leader line will not be adjusted by disconnecting from a ConnectionPoint.

Examples:

doc = Layout::Document.open("C:/path/to/document.layout")
label = doc.pages.first.entities.first
label.disconnect

Raises:

Version:

  • LayOut 2018

#entitiesLayout::Entities #entities(page) ⇒ Layout::Entities

The #entities method returns the Entities that represent the Label in its exploded form.

Examples:

text = "A label"
leader_type = Layout::Label::LEADER_LINE_TYPE_BEZIER
target_point = Geom::Point2d.new(1, 1)
bounds = Geom::Bounds2d.new(2, 1, 1, 1)
label_from_bounds = Layout::Label.new(text, leader_type, target_point,
  bounds)
entities = label_from_bounds.entities

Overloads:

Raises:

  • (ArgumentError)

    if page does not belong to the same document as the

    Layout::Label

Version:

  • LayOut 2018