123456789_123456789_123456789_123456789_123456789_

Class: Layout::Table

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

Overview

A Table is a series of rows and columns that holds data.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 4, 4)
rows = 4
columns = 4
table = Layout::Table.new(bounds, rows, columns)
doc = Layout::Document.open("C:/path/to/document.layout")
doc.add_entity(table, doc.layers.first, doc.pages.first)
anchor_type = Layout::FormattedText::ANCHOR_TYPE_TOP_LEFT
start_point = Geom::Point2d.new(1, 1)
text = Layout::FormattedText.new("Hello LayOut", start_point, anchor_type)
table[1, 1].data = text

Version:

  • LayOut 2018

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(bounds, rows, columns) ⇒ Table

The #initialize method creates a Table with a specified size, and a specified number of rows and columns.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 4, 4)
rows = 4
columns = 4
table = Layout::Table.new(bounds, rows, columns)

Parameters:

Raises:

  • (ArgumentError)

    if rows is less than 1

  • (ArgumentError)

    if columns is less than 1

  • (ArgumentError)

    if bounds is zero size

Version:

  • LayOut 2018

Instance Method Details

#[](row_index, column_index) ⇒ Layout::TableCell

The #[] method returns the TableCell at the specified row and column.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 4, 4)
rows = 4
columns = 4
table = Layout::Table.new(bounds, rows, columns)
cell = table[1, 2]

Parameters:

  • row_index (Integer)
  • column_index (Integer)

Raises:

  • (IndexError)

    if row_index or column_index are not a valid indices for the Table

Version:

  • LayOut 2018

#dimensionsArray(Integer, Integer)

The #dimensions method returns the number of rows and columns in a Table.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 4, 4)
rows = 4
columns = 4
table = Layout::Table.new(bounds, rows, columns)
r, c = table.dimensions

Returns:

  • (Array(Integer, Integer))

    The first value is the number of rows; the second, the number of columns.

Version:

  • LayOut 2018

#each {|cell| ... }

The #each method iterates in column major order through all of the cells in the Table.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 4, 4)
rows = 4
columns = 4
table = Layout::Table.new(bounds, rows, columns)
table.each { |cell|
  puts cell.data.plain_text
}

Yield Parameters:

Version:

  • LayOut 2018

#entitiesLayout::Entities

The #entities method creates and returns the Entities that represent the Table in its exploded form.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 4, 4)
rows = 4
columns = 4
table = Layout::Table.new(bounds, rows, columns)
entities = table.entities

Version:

  • LayOut 2018

#get_column(index) ⇒ Layout::TableColumn

The #get_column method returns the TableColumn at the specified index.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 4, 4)
rows = 4
columns = 4
table = Layout::Table.new(bounds, rows, columns)
table_column = table.get_column(2)

Parameters:

  • index (Integer)

Raises:

  • (IndexError)

    if index is not a valid index for the Table

Version:

  • LayOut 2018

#get_row(index) ⇒ Layout::TableRow

The #get_row method returns the TableRow at the specified index.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 4, 4)
rows = 4
columns = 4
table = Layout::Table.new(bounds, rows, columns)
table_row = table.get_row(2)

Parameters:

  • index (Integer)

Raises:

  • (IndexError)

    if index is not a valid index for the Table

Version:

  • LayOut 2018

#insert_column(index)

The #insert_column method inserts a new column at the specified index.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 4, 4)
rows = 4
columns = 4
table = Layout::Table.new(bounds, rows, columns)
table.insert_column(2)

Parameters:

  • index (Integer)

Raises:

Version:

  • LayOut 2018

#insert_row(index)

The #insert_row method inserts a new row at the specified index.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 4, 4)
rows = 4
columns = 4
table = Layout::Table.new(bounds, rows, columns)
table.insert_row(2)

Parameters:

  • index (Integer)

Raises:

Version:

  • LayOut 2018

#merge(start_row, start_column, end_row, end_column)

The #merge method merges a range of cells within a Table. Only cells which are not already merged can be merged.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 4, 4)
rows = 4
columns = 4
table = Layout::Table.new(bounds, rows, columns)
table.merge(1, 1, 2, 2)

Parameters:

  • start_row (Integer)
  • start_column (Integer)
  • end_row (Integer)
  • end_column (Integer)

Raises:

  • (IndexError)

    if the passed in indices are not a valid for the Table

  • (LockedLayerError)

    if the Table is on a locked Layer

  • (LockedEntityError)

    if the Table is locked

  • (ArgumentError)

    if the specified range of cells only spans a single cell

  • (ArgumentError)

    if the specified range of cells contains a merged cell

Version:

  • LayOut 2018

#remove_column(index)

The #remove_column method removes the column at the specified index.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 4, 4)
rows = 4
columns = 4
table = Layout::Table.new(bounds, rows, columns)
table.remove_column(2)

Parameters:

  • index (Integer)

Raises:

Version:

  • LayOut 2018

#remove_row(index)

The #remove_row method removes the row at the specified index.

Examples:

bounds = Geom::Bounds2d.new(1, 1, 4, 4)
rows = 4
columns = 4
table = Layout::Table.new(bounds, rows, columns)
table.remove_row(2)

Parameters:

  • index (Integer)

Raises:

Version:

  • LayOut 2018