Core
momapy.core
Core dataclasses for maps, models, and layouts.
Modules:
| Name | Description |
|---|---|
elements |
Base element classes for maps. |
fonts |
Font file lookup using uharfbuzz for metadata reading. |
layout |
Layout element hierarchy: all visual element classes. |
map |
Top-level Map class. |
mapping |
Layout-model mapping classes. |
model |
Abstract model base class. |
Classes:
| Name | Description |
|---|---|
Arc |
Base class for arcs |
DoubleHeadedArc |
Base class for double-headed arcs. A double-headed arc is formed of a path and two arrowheads, on at the beginning of the path and one at its end |
GroupLayout |
Base class for group layouts. A group layout is a layout element grouping other layout elements. |
Layout |
Class for layouts |
LayoutElement |
Abstract base class for layout elements |
LayoutModelMapping |
Mapping between model elements and layout elements. |
LayoutModelMappingBuilder |
|
Map |
Class for maps |
MapElement |
Base class for map elements |
Model |
Base class for models |
ModelElement |
Base class for model elements |
Node |
Class for nodes. A node is a layout element with a |
Shape |
Class for basic shapes. The shape is the most simple layout element. |
SingleHeadedArc |
Base class for single-headed arcs. A single-headed arc is formed of a path and a unique arrowhead at its end |
TextLayout |
Class for text layouts |
Functions:
| Name | Description |
|---|---|
find_font |
Find the best matching font file path. |
Arc
dataclass
Arc(*, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, end_shorten: float = 0.0, fill: NoneValueType | Color | None = None, filter: NoneValueType | Filter | None = None, path_fill: NoneValueType | Color | None = None, path_filter: NoneValueType | Filter | None = None, path_stroke: NoneValueType | Color | None = None, path_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, path_stroke_dashoffset: NoneValueType | float | None = None, path_stroke_width: float | None = None, path_transform: NoneValueType | tuple[Transformation] | None = None, stroke: NoneValueType | Color | None = None, stroke_dasharray: NoneValueType | tuple[float] | None = None, stroke_dashoffset: NoneValueType | float | None = None, stroke_width: NoneValueType | float | None = None, segments: tuple[Segment | QuadraticBezierCurve | CubicBezierCurve | EllipticalArc] = tuple(), source: LayoutElement | None = None, start_shorten: float = 0.0, target: LayoutElement | None = None, transform: NoneValueType | tuple[Transformation] | None = None)
Bases: GroupLayout
Base class for arcs
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_
|
str
|
The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element |
'697870df-ebf4-43b8-9539-4ca64efd426b'
|
layout_elements
|
tuple[LayoutElement]
|
The sub-layout elements of the group layout. These are part of the children of the group layout |
<dynamic>
|
group_fill
|
NoneValueType | Color | None
|
The fill color of the group layout |
None
|
group_fill_rule
|
FillRule | None
|
The fill rule of the group layout |
None
|
group_filter
|
NoneValueType | Filter | None
|
The filter of the group layout |
None
|
group_font_family
|
str | None
|
The font family of the group layout |
None
|
group_font_size
|
float | None
|
The font size of the group layout |
None
|
group_font_style
|
FontStyle | None
|
The font style of the group layout |
None
|
group_font_weight
|
FontWeight | float | None
|
The font weight of the group layout |
None
|
group_stroke
|
NoneValueType | Color | None
|
The stroke color of the group layout |
None
|
group_stroke_dasharray
|
NoneValueType | tuple[float, ...] | None
|
The stroke dasharray of the group layout |
None
|
group_stroke_dashoffset
|
NoneValueType | float | None
|
The stroke dashoffset of the group layout |
None
|
group_stroke_width
|
NoneValueType | float | None
|
The stroke width of the group layout |
None
|
group_text_anchor
|
TextAnchor | None
|
The text anchor of the group layout |
None
|
group_transform
|
NoneValueType | tuple[Transformation] | None
|
The transform of the group layout |
None
|
end_shorten
|
float
|
The length the end of the arc will be shorten by |
0.0
|
fill
|
NoneValueType | Color | None
|
The fill color of the arc |
None
|
filter
|
NoneValueType | Filter | None
|
The fill filter of the arc |
None
|
path_fill
|
NoneValueType | Color | None
|
The path fill color of the arc |
None
|
path_filter
|
NoneValueType | Filter | None
|
The path filter of the arc |
None
|
path_stroke
|
NoneValueType | Color | None
|
The path stroke color of the arc |
None
|
path_stroke_dasharray
|
NoneValueType | tuple[float, ...] | None
|
The path stroke dasharray of the arc |
None
|
path_stroke_dashoffset
|
NoneValueType | float | None
|
The path stroke dashoffset of the arc |
None
|
path_stroke_width
|
float | None
|
The path stroke width of the arc |
None
|
path_transform
|
NoneValueType | tuple[Transformation] | None
|
The path transform of the arc |
None
|
stroke
|
NoneValueType | Color | None
|
The stroke color of the arc |
None
|
stroke_dasharray
|
NoneValueType | tuple[float] | None
|
The stroke dasharray of the arc |
None
|
stroke_dashoffset
|
NoneValueType | float | None
|
The stroke dashoffset of the arc |
None
|
stroke_width
|
NoneValueType | float | None
|
The stroke width of the arc |
None
|
segments
|
tuple[Segment | QuadraticBezierCurve | CubicBezierCurve | EllipticalArc]
|
The path segments of the arc |
<dynamic>
|
source
|
LayoutElement | None
|
The source of the arc |
None
|
start_shorten
|
float
|
The length the start of the arc will be shorten by |
0.0
|
target
|
LayoutElement | None
|
The target of the arc |
None
|
transform
|
NoneValueType | tuple[Transformation] | None
|
The transform of the arc |
None
|
Methods:
| Name | Description |
|---|---|
anchor_point |
Return an anchor point of the layout element |
bbox |
Compute and return the bounding box of the group layout element |
childless |
Return a copy of the arc with no children |
children |
Return the children of the group layout. |
contains |
Return |
descendants |
Return the descendants of the layout element |
drawing_elements |
Return the drawing elements of the group layout. |
end_point |
Return the ending point of the arc |
equals |
Return |
flattened |
Return a list containing copy of the layout element with no children and all its descendants with no children |
fraction |
Return the position and angle on the arc at a given fraction (of the total arc length) |
length |
Return the total length of the arc path |
own_bbox |
Compute and return the bounding box of the self drawing element of the group layout |
own_children |
Return the self children of the arc |
own_drawing_elements |
Return the self drawing elements of the group layout |
own_to_geometry |
Return a list of geometry primitives from the self drawing elements. |
points |
Return the points of the arc path |
start_point |
Return the starting point of the arc |
to_geometry |
Return a list of geometry primitives from the drawing elements. |
anchor_point
anchor_point(anchor_name: str) -> Point
bbox
bbox() -> Bbox
Compute and return the bounding box of the group layout element
Source code in src/momapy/core/layout.py
childless
children
children() -> list[LayoutElement]
Return the children of the group layout.
These are the self children of the group layout (returned by the own_children method) and the other children of the group layout (given by the layout_elements attribute)
Source code in src/momapy/core/layout.py
contains
contains(other: LayoutElement) -> bool
Return true if another layout element is a descendant of the layout element, false otherwise
drawing_elements
drawing_elements() -> list[DrawingElement]
Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
Source code in src/momapy/core/layout.py
end_point
end_point() -> Point
equals
equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool
Return true if the layout element is equal to another layout element, false otherwise
Source code in src/momapy/core/elements.py
flattened
flattened() -> list[LayoutElement]
Return a list containing copy of the layout element with no children and all its descendants with no children
Source code in src/momapy/core/elements.py
fraction
fraction(fraction: float) -> tuple[Point, float]
Return the position and angle on the arc at a given fraction (of the total arc length)
Source code in src/momapy/core/layout.py
length
own_bbox
own_bbox() -> Bbox
Compute and return the bounding box of the self drawing element of the group layout
Source code in src/momapy/core/layout.py
own_children
own_children() -> list[LayoutElement]
own_drawing_elements
abstractmethod
own_drawing_elements() -> list[DrawingElement]
own_to_geometry
own_to_geometry() -> list[Segment | QuadraticBezierCurve | CubicBezierCurve | EllipticalArc]
Return a list of geometry primitives from the self drawing elements.
Source code in src/momapy/core/layout.py
points
points() -> list[Point]
start_point
start_point() -> Point
to_geometry
to_geometry() -> list[Segment | QuadraticBezierCurve | CubicBezierCurve | EllipticalArc]
Return a list of geometry primitives from the drawing elements.
Source code in src/momapy/core/elements.py
DoubleHeadedArc
dataclass
DoubleHeadedArc(*, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, end_shorten: float = 0.0, fill: NoneValueType | Color | None = None, filter: NoneValueType | Filter | None = None, path_fill: NoneValueType | Color | None = None, path_filter: NoneValueType | Filter | None = None, path_stroke: NoneValueType | Color | None = None, path_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, path_stroke_dashoffset: NoneValueType | float | None = None, path_stroke_width: float | None = None, path_transform: NoneValueType | tuple[Transformation] | None = None, stroke: NoneValueType | Color | None = None, stroke_dasharray: NoneValueType | tuple[float] | None = None, stroke_dashoffset: NoneValueType | float | None = None, stroke_width: NoneValueType | float | None = None, segments: tuple[Segment | QuadraticBezierCurve | CubicBezierCurve | EllipticalArc] = tuple(), source: LayoutElement | None = None, start_shorten: float = 0.0, target: LayoutElement | None = None, transform: NoneValueType | tuple[Transformation] | None = None, end_arrowhead_fill: NoneValueType | Color | None = None, end_arrowhead_filter: NoneValueType | Filter | None = None, end_arrowhead_stroke: NoneValueType | Color | None = None, end_arrowhead_stroke_dasharray: tuple[float, ...] | None = None, end_arrowhead_stroke_dashoffset: float | None = None, end_arrowhead_stroke_width: float | None = None, end_arrowhead_transform: NoneValueType | tuple[Transformation] | None = None, start_arrowhead_fill: NoneValueType | Color | None = None, start_arrowhead_filter: NoneValueType | Filter | None = None, start_arrowhead_stroke: NoneValueType | Color | None = None, start_arrowhead_stroke_dasharray: tuple[float, ...] | None = None, start_arrowhead_stroke_dashoffset: float | None = None, start_arrowhead_stroke_width: float | None = None, start_arrowhead_transform: NoneValueType | tuple[Transformation] | None = None)
Bases: Arc
Base class for double-headed arcs. A double-headed arc is formed of a path and two arrowheads, on at the beginning of the path and one at its end
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_
|
str
|
The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element |
'112eea99-2692-45f1-a796-61ddda62f08d'
|
layout_elements
|
tuple[LayoutElement]
|
The sub-layout elements of the group layout. These are part of the children of the group layout |
<dynamic>
|
group_fill
|
NoneValueType | Color | None
|
The fill color of the group layout |
None
|
group_fill_rule
|
FillRule | None
|
The fill rule of the group layout |
None
|
group_filter
|
NoneValueType | Filter | None
|
The filter of the group layout |
None
|
group_font_family
|
str | None
|
The font family of the group layout |
None
|
group_font_size
|
float | None
|
The font size of the group layout |
None
|
group_font_style
|
FontStyle | None
|
The font style of the group layout |
None
|
group_font_weight
|
FontWeight | float | None
|
The font weight of the group layout |
None
|
group_stroke
|
NoneValueType | Color | None
|
The stroke color of the group layout |
None
|
group_stroke_dasharray
|
NoneValueType | tuple[float, ...] | None
|
The stroke dasharray of the group layout |
None
|
group_stroke_dashoffset
|
NoneValueType | float | None
|
The stroke dashoffset of the group layout |
None
|
group_stroke_width
|
NoneValueType | float | None
|
The stroke width of the group layout |
None
|
group_text_anchor
|
TextAnchor | None
|
The text anchor of the group layout |
None
|
group_transform
|
NoneValueType | tuple[Transformation] | None
|
The transform of the group layout |
None
|
end_shorten
|
float
|
The length the end of the arc will be shorten by |
0.0
|
fill
|
NoneValueType | Color | None
|
The fill color of the arc |
None
|
filter
|
NoneValueType | Filter | None
|
The fill filter of the arc |
None
|
path_fill
|
NoneValueType | Color | None
|
The path fill color of the arc |
None
|
path_filter
|
NoneValueType | Filter | None
|
The path filter of the arc |
None
|
path_stroke
|
NoneValueType | Color | None
|
The path stroke color of the arc |
None
|
path_stroke_dasharray
|
NoneValueType | tuple[float, ...] | None
|
The path stroke dasharray of the arc |
None
|
path_stroke_dashoffset
|
NoneValueType | float | None
|
The path stroke dashoffset of the arc |
None
|
path_stroke_width
|
float | None
|
The path stroke width of the arc |
None
|
path_transform
|
NoneValueType | tuple[Transformation] | None
|
The path transform of the arc |
None
|
stroke
|
NoneValueType | Color | None
|
The stroke color of the arc |
None
|
stroke_dasharray
|
NoneValueType | tuple[float] | None
|
The stroke dasharray of the arc |
None
|
stroke_dashoffset
|
NoneValueType | float | None
|
The stroke dashoffset of the arc |
None
|
stroke_width
|
NoneValueType | float | None
|
The stroke width of the arc |
None
|
segments
|
tuple[Segment | QuadraticBezierCurve | CubicBezierCurve | EllipticalArc]
|
The path segments of the arc |
<dynamic>
|
source
|
LayoutElement | None
|
The source of the arc |
None
|
start_shorten
|
float
|
The length the start of the arc will be shorten by |
0.0
|
target
|
LayoutElement | None
|
The target of the arc |
None
|
transform
|
NoneValueType | tuple[Transformation] | None
|
The transform of the arc |
None
|
end_arrowhead_fill
|
NoneValueType | Color | None
|
The end arrowhead fill color of the arc |
None
|
end_arrowhead_filter
|
NoneValueType | Filter | None
|
The end arrowhead filter of the arc |
None
|
end_arrowhead_stroke
|
NoneValueType | Color | None
|
The end arrowhead stroke color of the arc |
None
|
end_arrowhead_stroke_dasharray
|
tuple[float, ...] | None
|
The end arrowhead stroke dasharray of the arc |
None
|
end_arrowhead_stroke_dashoffset
|
float | None
|
The end arrowhead stroke dashoffset of the arc |
None
|
end_arrowhead_stroke_width
|
float | None
|
The end arrowhead stroke width of the arc |
None
|
end_arrowhead_transform
|
NoneValueType | tuple[Transformation] | None
|
The end arrowhead transform of the arc |
None
|
start_arrowhead_fill
|
NoneValueType | Color | None
|
The start arrowhead fill color of the arc |
None
|
start_arrowhead_filter
|
NoneValueType | Filter | None
|
The start arrowhead filter of the arc |
None
|
start_arrowhead_stroke
|
NoneValueType | Color | None
|
The start arrowhead stroke color of the arc |
None
|
start_arrowhead_stroke_dasharray
|
tuple[float, ...] | None
|
The start arrowhead stroke dasharray of the arc |
None
|
start_arrowhead_stroke_dashoffset
|
float | None
|
The start arrowhead stroke dashoffset of the arc |
None
|
start_arrowhead_stroke_width
|
float | None
|
The start arrowhead stroke width of the arc |
None
|
start_arrowhead_transform
|
NoneValueType | tuple[Transformation] | None
|
The start arrowhead transform of the arc |
None
|
Methods:
| Name | Description |
|---|---|
anchor_point |
Return an anchor point of the layout element |
bbox |
Compute and return the bounding box of the group layout element |
childless |
Return a copy of the arc with no children |
children |
Return the children of the group layout. |
contains |
Return |
descendants |
Return the descendants of the layout element |
drawing_elements |
Return the drawing elements of the group layout. |
end_arrowhead_base |
Return the base anchor point of the double-headed arc end arrowhead |
end_arrowhead_bbox |
Return the bounding box of the double-headed arc start arrowhead |
end_arrowhead_border |
Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point. |
end_arrowhead_length |
Return the length of the double-headed arc end arrowhead |
end_arrowhead_tip |
Return the tip anchor point of the double-headed arc end arrowhead |
end_point |
Return the ending point of the arc |
equals |
Return |
flattened |
Return a list containing copy of the layout element with no children and all its descendants with no children |
fraction |
Return the position and angle on the arc at a given fraction (of the total arc length) |
length |
Return the total length of the arc path |
own_bbox |
Compute and return the bounding box of the self drawing element of the group layout |
own_children |
Return the self children of the arc |
own_drawing_elements |
Return the self drawing elements of the double-headed arc. These include the drawing elements of the arc path, the start arrowhead, and the end arrowhead |
own_to_geometry |
Return a list of geometry primitives from the self drawing elements. |
path_drawing_elements |
Return the drawing elements of the double-headed arc path |
points |
Return the points of the arc path |
start_arrowhead_base |
Return the base anchor point of the double-headed arc start arrowhead |
start_arrowhead_bbox |
Return the bounding box of the double-headed arc start arrowhead |
start_arrowhead_border |
Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point. |
start_arrowhead_drawing_elements |
Return the drawing elements of the double-headed arc start arrowhead |
start_arrowhead_length |
Return the length of the double-headed arc start arrowhead |
start_arrowhead_tip |
Return the tip anchor point of the double-headed arc start arrowhead |
start_point |
Return the starting point of the arc |
to_geometry |
Return a list of geometry primitives from the drawing elements. |
anchor_point
anchor_point(anchor_name: str) -> Point
bbox
bbox() -> Bbox
Compute and return the bounding box of the group layout element
Source code in src/momapy/core/layout.py
childless
children
children() -> list[LayoutElement]
Return the children of the group layout.
These are the self children of the group layout (returned by the own_children method) and the other children of the group layout (given by the layout_elements attribute)
Source code in src/momapy/core/layout.py
contains
contains(other: LayoutElement) -> bool
Return true if another layout element is a descendant of the layout element, false otherwise
drawing_elements
drawing_elements() -> list[DrawingElement]
Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
Source code in src/momapy/core/layout.py
end_arrowhead_base
end_arrowhead_base() -> Point
Return the base anchor point of the double-headed arc end arrowhead
Source code in src/momapy/core/layout.py
end_arrowhead_bbox
Return the bounding box of the double-headed arc start arrowhead
end_arrowhead_border
Return the point at the intersection of the drawing elements of the double-headed arc end arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned
Source code in src/momapy/core/layout.py
end_arrowhead_length
Return the length of the double-headed arc end arrowhead
Source code in src/momapy/core/layout.py
end_arrowhead_tip
end_arrowhead_tip() -> Point
Return the tip anchor point of the double-headed arc end arrowhead
Source code in src/momapy/core/layout.py
end_point
end_point() -> Point
equals
equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool
Return true if the layout element is equal to another layout element, false otherwise
Source code in src/momapy/core/elements.py
flattened
flattened() -> list[LayoutElement]
Return a list containing copy of the layout element with no children and all its descendants with no children
Source code in src/momapy/core/elements.py
fraction
fraction(fraction: float) -> tuple[Point, float]
Return the position and angle on the arc at a given fraction (of the total arc length)
Source code in src/momapy/core/layout.py
length
own_bbox
own_bbox() -> Bbox
Compute and return the bounding box of the self drawing element of the group layout
Source code in src/momapy/core/layout.py
own_children
own_children() -> list[LayoutElement]
own_drawing_elements
own_drawing_elements() -> list[DrawingElement]
Return the self drawing elements of the double-headed arc. These include the drawing elements of the arc path, the start arrowhead, and the end arrowhead
Source code in src/momapy/core/layout.py
own_to_geometry
own_to_geometry() -> list[Segment | QuadraticBezierCurve | CubicBezierCurve | EllipticalArc]
Return a list of geometry primitives from the self drawing elements.
Source code in src/momapy/core/layout.py
path_drawing_elements
path_drawing_elements() -> list[Path]
Return the drawing elements of the double-headed arc path
Source code in src/momapy/core/layout.py
points
points() -> list[Point]
start_arrowhead_base
start_arrowhead_base() -> Point
Return the base anchor point of the double-headed arc start arrowhead
Source code in src/momapy/core/layout.py
start_arrowhead_bbox
start_arrowhead_bbox() -> Bbox
Return the bounding box of the double-headed arc start arrowhead
start_arrowhead_border
start_arrowhead_border(point) -> Point
Return the point at the intersection of the drawing elements of the double-headed arc start arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned
Source code in src/momapy/core/layout.py
start_arrowhead_drawing_elements
start_arrowhead_drawing_elements() -> list[DrawingElement]
Return the drawing elements of the double-headed arc start arrowhead
Source code in src/momapy/core/layout.py
start_arrowhead_length
Return the length of the double-headed arc start arrowhead
Source code in src/momapy/core/layout.py
start_arrowhead_tip
start_arrowhead_tip() -> Point
Return the tip anchor point of the double-headed arc start arrowhead
Source code in src/momapy/core/layout.py
start_point
start_point() -> Point
to_geometry
to_geometry() -> list[Segment | QuadraticBezierCurve | CubicBezierCurve | EllipticalArc]
Return a list of geometry primitives from the drawing elements.
Source code in src/momapy/core/elements.py
GroupLayout
dataclass
GroupLayout(*, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None)
Bases: LayoutElement
Base class for group layouts. A group layout is a layout element grouping other layout elements. It has its own drawing elements and set of children (called self drawing elements and self children, respectively). The drawing elements of a group layout is a group drawing element formed of its self drawing elements and those of its children
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_
|
str
|
The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element |
'97a0ce59-5d75-4339-954f-f97723a3e6ee'
|
layout_elements
|
tuple[LayoutElement]
|
The sub-layout elements of the group layout. These are part of the children of the group layout |
<dynamic>
|
group_fill
|
NoneValueType | Color | None
|
The fill color of the group layout |
None
|
group_fill_rule
|
FillRule | None
|
The fill rule of the group layout |
None
|
group_filter
|
NoneValueType | Filter | None
|
The filter of the group layout |
None
|
group_font_family
|
str | None
|
The font family of the group layout |
None
|
group_font_size
|
float | None
|
The font size of the group layout |
None
|
group_font_style
|
FontStyle | None
|
The font style of the group layout |
None
|
group_font_weight
|
FontWeight | float | None
|
The font weight of the group layout |
None
|
group_stroke
|
NoneValueType | Color | None
|
The stroke color of the group layout |
None
|
group_stroke_dasharray
|
NoneValueType | tuple[float, ...] | None
|
The stroke dasharray of the group layout |
None
|
group_stroke_dashoffset
|
NoneValueType | float | None
|
The stroke dashoffset of the group layout |
None
|
group_stroke_width
|
NoneValueType | float | None
|
The stroke width of the group layout |
None
|
group_text_anchor
|
TextAnchor | None
|
The text anchor of the group layout |
None
|
group_transform
|
NoneValueType | tuple[Transformation] | None
|
The transform of the group layout |
None
|
Methods:
| Name | Description |
|---|---|
anchor_point |
Return an anchor point of the layout element |
bbox |
Compute and return the bounding box of the group layout element |
childless |
Return a copy of the layout element with no children |
children |
Return the children of the group layout. |
contains |
Return |
descendants |
Return the descendants of the layout element |
drawing_elements |
Return the drawing elements of the group layout. |
equals |
Return |
flattened |
Return a list containing copy of the layout element with no children and all its descendants with no children |
own_bbox |
Compute and return the bounding box of the self drawing element of the group layout |
own_children |
Return the self children of the group layout |
own_drawing_elements |
Return the self drawing elements of the group layout |
own_to_geometry |
Return a list of geometry primitives from the self drawing elements. |
to_geometry |
Return a list of geometry primitives from the drawing elements. |
anchor_point
anchor_point(anchor_name: str) -> Point
bbox
bbox() -> Bbox
Compute and return the bounding box of the group layout element
Source code in src/momapy/core/layout.py
childless
abstractmethod
children
children() -> list[LayoutElement]
Return the children of the group layout.
These are the self children of the group layout (returned by the own_children method) and the other children of the group layout (given by the layout_elements attribute)
Source code in src/momapy/core/layout.py
contains
contains(other: LayoutElement) -> bool
Return true if another layout element is a descendant of the layout element, false otherwise
drawing_elements
drawing_elements() -> list[DrawingElement]
Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
Source code in src/momapy/core/layout.py
equals
equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool
Return true if the layout element is equal to another layout element, false otherwise
Source code in src/momapy/core/elements.py
flattened
flattened() -> list[LayoutElement]
Return a list containing copy of the layout element with no children and all its descendants with no children
Source code in src/momapy/core/elements.py
own_bbox
own_bbox() -> Bbox
Compute and return the bounding box of the self drawing element of the group layout
Source code in src/momapy/core/layout.py
own_children
abstractmethod
own_children() -> list[LayoutElement]
own_drawing_elements
abstractmethod
own_drawing_elements() -> list[DrawingElement]
own_to_geometry
own_to_geometry() -> list[Segment | QuadraticBezierCurve | CubicBezierCurve | EllipticalArc]
Return a list of geometry primitives from the self drawing elements.
Source code in src/momapy/core/layout.py
to_geometry
to_geometry() -> list[Segment | QuadraticBezierCurve | CubicBezierCurve | EllipticalArc]
Return a list of geometry primitives from the drawing elements.
Source code in src/momapy/core/elements.py
Layout
dataclass
Layout(*, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, fill: NoneValueType | Color | None = NoneValue, filter: NoneValueType | Filter | None = None, height: float, label: TextLayout | None = None, position: Point, stroke: NoneValueType | Color | None = None, stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, stroke_dashoffset: NoneValueType | float | None = None, stroke_width: NoneValueType | float | None = None, transform: NoneValueType | tuple[Transformation] | None = None, width: float)
Bases: Node
Class for layouts
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_
|
str
|
The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element |
'28bcd2eb-196e-49fe-b148-373a7236e56f'
|
layout_elements
|
tuple[LayoutElement]
|
The sub-layout elements of the group layout. These are part of the children of the group layout |
<dynamic>
|
group_fill
|
NoneValueType | Color | None
|
The fill color of the group layout |
None
|
group_fill_rule
|
FillRule | None
|
The fill rule of the group layout |
None
|
group_filter
|
NoneValueType | Filter | None
|
The filter of the group layout |
None
|
group_font_family
|
str | None
|
The font family of the group layout |
None
|
group_font_size
|
float | None
|
The font size of the group layout |
None
|
group_font_style
|
FontStyle | None
|
The font style of the group layout |
None
|
group_font_weight
|
FontWeight | float | None
|
The font weight of the group layout |
None
|
group_stroke
|
NoneValueType | Color | None
|
The stroke color of the group layout |
None
|
group_stroke_dasharray
|
NoneValueType | tuple[float, ...] | None
|
The stroke dasharray of the group layout |
None
|
group_stroke_dashoffset
|
NoneValueType | float | None
|
The stroke dashoffset of the group layout |
None
|
group_stroke_width
|
NoneValueType | float | None
|
The stroke width of the group layout |
None
|
group_text_anchor
|
TextAnchor | None
|
The text anchor of the group layout |
None
|
group_transform
|
NoneValueType | tuple[Transformation] | None
|
The transform of the group layout |
None
|
fill
|
NoneValueType | Color | None
|
The fill color of the node |
<momapy.drawing.NoneValueType object at 0x7fbe12e88d70>
|
filter
|
NoneValueType | Filter | None
|
The filter of the node |
None
|
height
|
float
|
The height of the node |
required |
label
|
TextLayout | None
|
The label of the node |
None
|
position
|
Point
|
The position of the node |
required |
stroke
|
NoneValueType | Color | None
|
The stroke color of the node |
None
|
stroke_dasharray
|
NoneValueType | tuple[float, ...] | None
|
The stroke dasharray of the node |
None
|
stroke_dashoffset
|
NoneValueType | float | None
|
The stroke dashoffset of the node |
None
|
stroke_width
|
NoneValueType | float | None
|
The stroke width of the node |
None
|
transform
|
NoneValueType | tuple[Transformation] | None
|
The transform of the node |
None
|
width
|
float
|
The width width of the node |
required |
Methods:
| Name | Description |
|---|---|
anchor_point |
Return an anchor point of the layout element |
angle |
Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal. |
bbox |
Compute and return the bounding box of the group layout element |
border |
Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. |
center |
Return the center anchor of the node |
childless |
Return a copy of the node with no children |
children |
Return the children of the group layout. |
contains |
Return |
descendants |
Return the descendants of the layout element |
drawing_elements |
Return the drawing elements of the group layout. |
east |
Return the east anchor of the node |
east_north_east |
Return the east north east anchor of the node |
east_south_east |
Return the east south east west anchor of the node |
equals |
Return |
flattened |
Return a list containing copy of the layout element with no children and all its descendants with no children |
is_sublayout |
Return |
label_center |
Return the label center anchor of the node |
north |
Return the north anchor of the node |
north_east |
Return the north east anchor of the node |
north_north_east |
Return the north north east anchor of the node |
north_north_west |
Return the north north west anchor of the node |
north_west |
Return the north west anchor of the node |
own_angle |
Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal. |
own_bbox |
Compute and return the bounding box of the self drawing element of the group layout |
own_border |
Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. |
own_children |
Return the self children of the node. A node has unique child that is its label |
own_drawing_elements |
Return the node's own drawing elements |
own_to_geometry |
Return a list of geometry primitives from the self drawing elements. |
size |
Return the size of the node |
south |
Return the south anchor of the node |
south_east |
Return the south east anchor of the node |
south_south_east |
Return the south south east anchor of the node |
south_south_west |
Return the south south west anchor of the node |
south_west |
Return the south west anchor of the node |
to_geometry |
Return a list of geometry primitives from the drawing elements. |
west |
Return the west anchor of the node |
west_north_west |
Return the west north west anchor of the node |
west_south_west |
Return the west south west anchor of the node |
Attributes:
| Name | Type | Description |
|---|---|---|
x |
float
|
Return the x coordinate of the node |
y |
float
|
Return the y coordinate of the node |
anchor_point
anchor_point(anchor_name: str) -> Point
angle
angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point | None
Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.
Source code in src/momapy/core/layout.py
bbox
bbox() -> Bbox
Compute and return the bounding box of the group layout element
Source code in src/momapy/core/layout.py
border
Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned
Source code in src/momapy/core/layout.py
center
center() -> Point
childless
children
children() -> list[LayoutElement]
Return the children of the group layout.
These are the self children of the group layout (returned by the own_children method) and the other children of the group layout (given by the layout_elements attribute)
Source code in src/momapy/core/layout.py
contains
contains(other: LayoutElement) -> bool
Return true if another layout element is a descendant of the layout element, false otherwise
drawing_elements
drawing_elements() -> list[DrawingElement]
Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
Source code in src/momapy/core/layout.py
east
east() -> Point
east_north_east
east_north_east() -> Point
Return the east north east anchor of the node
Source code in src/momapy/core/layout.py
east_south_east
east_south_east() -> Point
Return the east south east west anchor of the node
Source code in src/momapy/core/layout.py
equals
equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool
Return true if the layout element is equal to another layout element, false otherwise
Source code in src/momapy/core/elements.py
flattened
flattened() -> list[LayoutElement]
Return a list containing copy of the layout element with no children and all its descendants with no children
Source code in src/momapy/core/elements.py
is_sublayout
Return true if another given layout is a sublayout of the layout, false otherwise
Source code in src/momapy/core/layout.py
label_center
label_center() -> Point
north
north() -> Point
north_east
north_east() -> Point
Return the north east anchor of the node
Source code in src/momapy/core/layout.py
north_north_east
north_north_east() -> Point
Return the north north east anchor of the node
Source code in src/momapy/core/layout.py
north_north_west
north_north_west() -> Point
Return the north north west anchor of the node
Source code in src/momapy/core/layout.py
north_west
north_west() -> Point
Return the north west anchor of the node
Source code in src/momapy/core/layout.py
own_angle
own_angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point | None
Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.
Source code in src/momapy/core/layout.py
own_bbox
own_bbox() -> Bbox
Compute and return the bounding box of the self drawing element of the group layout
Source code in src/momapy/core/layout.py
own_border
Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned
Source code in src/momapy/core/layout.py
own_children
own_children() -> list[LayoutElement]
Return the self children of the node. A node has unique child that is its label
own_drawing_elements
own_drawing_elements() -> list[DrawingElement]
Return the node's own drawing elements
Source code in src/momapy/core/layout.py
own_to_geometry
own_to_geometry() -> list[Segment | QuadraticBezierCurve | CubicBezierCurve | EllipticalArc]
Return a list of geometry primitives from the self drawing elements.
Source code in src/momapy/core/layout.py
size
south
south() -> Point
south_east
south_east() -> Point
Return the south east anchor of the node
Source code in src/momapy/core/layout.py
south_south_east
south_south_east() -> Point
Return the south south east anchor of the node
Source code in src/momapy/core/layout.py
south_south_west
south_south_west() -> Point
Return the south south west anchor of the node
Source code in src/momapy/core/layout.py
south_west
south_west() -> Point
Return the south west anchor of the node
Source code in src/momapy/core/layout.py
to_geometry
to_geometry() -> list[Segment | QuadraticBezierCurve | CubicBezierCurve | EllipticalArc]
Return a list of geometry primitives from the drawing elements.
Source code in src/momapy/core/elements.py
west
west() -> Point
west_north_west
west_north_west() -> Point
Return the west north west anchor of the node
Source code in src/momapy/core/layout.py
west_south_west
west_south_west() -> Point
Return the west south west anchor of the node
Source code in src/momapy/core/layout.py
LayoutElement
dataclass
Bases: MapElement, ABC
Abstract base class for layout elements
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_
|
str
|
The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element |
'a18cc865-fe31-49d6-9136-08626a9b79f9'
|
Methods:
| Name | Description |
|---|---|
anchor_point |
Return an anchor point of the layout element |
bbox |
Compute and return the bounding box of the layout element |
childless |
Return a copy of the layout element with no children |
children |
Return the children of the layout element |
contains |
Return |
descendants |
Return the descendants of the layout element |
drawing_elements |
Return the drawing elements of the layout element |
equals |
Return |
flattened |
Return a list containing copy of the layout element with no children and all its descendants with no children |
to_geometry |
Return a list of geometry primitives from the drawing elements. |
anchor_point
anchor_point(anchor_name: str) -> Point
bbox
abstractmethod
bbox() -> Bbox
childless
abstractmethod
children
abstractmethod
children() -> list[LayoutElement]
contains
contains(other: LayoutElement) -> bool
Return true if another layout element is a descendant of the layout element, false otherwise
drawing_elements
abstractmethod
drawing_elements() -> list[DrawingElement]
equals
equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool
Return true if the layout element is equal to another layout element, false otherwise
Source code in src/momapy/core/elements.py
flattened
flattened() -> list[LayoutElement]
Return a list containing copy of the layout element with no children and all its descendants with no children
Source code in src/momapy/core/elements.py
to_geometry
to_geometry() -> list[Segment | QuadraticBezierCurve | CubicBezierCurve | EllipticalArc]
Return a list of geometry primitives from the drawing elements.
Source code in src/momapy/core/elements.py
LayoutModelMapping
Bases: FrozenIdentitySurjectionDict
Mapping between model elements and layout elements.
A Map can draw the same model element several times, so the relation between layouts and model elements is a many-to-one mapping whose keys are layout elements and whose values are model elements. Two kinds of keys are used:
- Singleton key — a single LayoutElement that represents a model element on its own (a macromolecule glyph, a compartment, a state variable, a modulation arc when no cluster is needed).
- Frozenset key — a
frozensetof several layout elements that jointly represent one model element. Used whenever a model concept is drawn as a cluster of shapes: a process and its participant arcs and target layouts, a logical operator and its input arcs and targets, a modulation arc with its source and target clusters, a tag or terminal with its reference arcs.
When the key is a frozenset, it is useful to designate one of the
layouts as the anchor — the element that stands for the cluster
on its own. The anchor is typically the "central" layout (the
process glyph for a process, the operator glyph for a logical
operator, the modulation arc for a modulation, the tag glyph for a
tag). Anchors are registered through the anchor argument of
add_mapping. Once registered,
get_mapping resolves the anchor back to the model element
stored under the frozenset key, and other composite keys can
reference the cluster by its anchor rather than by the whole
frozenset.
See the SBGN-PD, SBGN-AF, and CellDesigner module documentation for the per-model-element catalogue of key shapes and anchors.
Methods:
| Name | Description |
|---|---|
__reduce__ |
Pickle hook that preserves |
__setstate__ |
Restore |
get_child_layout_elements |
Return the layout elements representing |
get_mapping |
Return the model element or layout elements mapped to |
is_submapping |
Return |
Attributes:
| Name | Type | Description |
|---|---|---|
inverse |
dict[int, set]
|
Get the identity-based inverse mapping. |
Source code in src/momapy/core/mapping.py
__reduce__
Pickle hook that preserves _singleton_to_key across round-trips.
The inherited frozendict.__reduce__ only serialises the dict
contents, which drops the anchor table added by this subclass.
Source code in src/momapy/core/mapping.py
__setstate__
Restore _singleton_to_key after __reduce__-driven unpickle.
get_child_layout_elements
get_child_layout_elements(child_model_element: ModelElement, parent_model_element: ModelElement) -> list[LayoutElement]
Return the layout elements representing child_model_element under parent_model_element.
Computes the intersection of two sets:
S1: layouts that belong underparent_model_element— the children of each container layout mapped to the parent, plus the members of each frozenset key mapped to the parent.S2: layouts that representchild_model_element— each singleton layout mapped to the child, plus the anchors of each frozenset key mapped to the child.
The inverse is identity-keyed, so two content-equal but id-distinct model instances are not aliased: layouts under one parent do not cross-pollute the result for the sibling instance.
Source code in src/momapy/core/mapping.py
get_mapping
get_mapping(map_element: MapElement) -> ModelElement | list[LayoutElement]
Return the model element or layout elements mapped to map_element.
Lookup order:
1. Direct key: map_element is a singleton or frozenset key in the
mapping; returns the associated model element directly.
2. Inverse: map_element is a model element; returns the list of
layout elements (or frozenset keys) whose stored model value
is map_element by object identity. Two content-equal
but id-distinct model instances are not aliased.
3. Anchor fallback: map_element was registered as the anchor of a
frozenset key via the anchor argument of add_mapping;
returns the model element stored under that frozenset key.
Returns None when no match is found.
Source code in src/momapy/core/mapping.py
inverse
property
Get the identity-based inverse mapping.
Returns:
| Type | Description |
|---|---|
dict[int, set]
|
A dict mapping |
dict[int, set]
|
to that value by identity. |
is_submapping
Return true if the mapping is a submapping of another LayoutModelMapping, false otherwise
LayoutModelMappingBuilder
Bases: IdentitySurjectionDict, Builder
Methods:
| Name | Description |
|---|---|
__reduce__ |
Pickle hook that preserves |
__setstate__ |
Restore |
add_mapping |
Add a layout-element to model-element entry to the mapping. |
build |
Build and return an object from the builder. |
from_object |
Create a builder from an existing object. |
get_child_layout_elements |
Return the layout elements representing |
Attributes:
| Name | Type | Description |
|---|---|---|
inverse |
dict[int, set]
|
Get the identity-based inverse mapping. |
Source code in src/momapy/core/mapping.py
__reduce__
Pickle hook that preserves _singleton_to_key across round-trips.
The default dict-subclass pickle emits SETITEMS before BUILD, so
IdentitySurjectionDict.__setitem__ fires before
_identity_inverse exists and crashes. Routing through
__init__ fixes both that and the _singleton_to_key loss.
Source code in src/momapy/core/mapping.py
__setstate__
add_mapping
add_mapping(layout_element: LayoutElement, model_element: ModelElement, replace: bool = False, anchor: LayoutElement | None = None)
Add a layout-element to model-element entry to the mapping.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layout_element
|
LayoutElement
|
The layout element (or frozenset of layout elements) to use as the key. |
required |
model_element
|
ModelElement
|
The model element to associate with the layout element. |
required |
replace
|
bool
|
When |
False
|
anchor
|
LayoutElement | None
|
When |
None
|
Source code in src/momapy/core/mapping.py
build
Build and return an object from the builder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
builder_to_object
|
dict[int, Any] | None
|
Optional cache mapping builder ids to built objects for handling circular references. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
The constructed object of type |
Source code in src/momapy/core/mapping.py
from_object
classmethod
from_object(obj, omit_keys: bool = True, object_to_builder: dict[int, Builder] | None = None) -> Self
Create a builder from an existing object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to convert to a builder. |
required |
omit_keys
|
bool
|
Whether to skip converting dictionary keys to builders. Defaults to True. |
True
|
object_to_builder
|
dict[int, Builder] | None
|
Optional cache mapping object ids to builders for handling circular references. |
None
|
Returns:
| Type | Description |
|---|---|
Self
|
A builder instance representing the input object. |
Source code in src/momapy/core/mapping.py
get_child_layout_elements
get_child_layout_elements(child_model_element: ModelElement, parent_model_element: ModelElement) -> list[LayoutElement]
Return the layout elements representing child_model_element under parent_model_element.
Source code in src/momapy/core/mapping.py
Map
dataclass
Map(*, id_: str = make_uuid4_as_str(), model: Model | None = None, layout: Layout | None = None, layout_model_mapping: LayoutModelMapping | None = None)
Bases: MapElement
Class for maps
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_
|
str
|
The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element |
'b0a31a10-4b1a-4dab-9160-b70fb21d075a'
|
model
|
Model | None
|
The model of the map |
None
|
layout
|
Layout | None
|
The layout of the map |
None
|
layout_model_mapping
|
LayoutModelMapping | None
|
The layout model mapping of the map |
None
|
Methods:
| Name | Description |
|---|---|
get_mapping |
Return the layout elements mapped to the given model element |
is_submap |
Return |
get_mapping
get_mapping(map_element: MapElement)
is_submap
Return true if another given map is a submap of the Map, false otherwise
Source code in src/momapy/core/map.py
MapElement
dataclass
Base class for map elements
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_
|
str
|
The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element |
'cb134d4d-f556-48e2-b362-440180782390'
|
Model
dataclass
Bases: MapElement
Base class for models
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_
|
str
|
The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element |
'a1fb88ae-d800-46d3-899f-5510aa576d98'
|
Methods:
| Name | Description |
|---|---|
descendants |
Return every |
descendants
descendants() -> list[ModelElement]
Return every ModelElement reachable from this Model.
Walks scalar ModelElement fields and frozenset/tuple
containers of the Model, deduplicating by object identity.
The Model itself is not a ModelElement and is not included.
Returns:
| Type | Description |
|---|---|
list[ModelElement]
|
The list of reachable |
list[ModelElement]
|
order. |
Source code in src/momapy/core/model.py
ModelElement
dataclass
Bases: MapElement
Base class for model elements
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_
|
str
|
The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element |
'e0040bf3-43fd-44c1-91bb-0f17fb584b6e'
|
Methods:
| Name | Description |
|---|---|
descendants |
Return every |
descendants
descendants() -> list[ModelElement]
Return every ModelElement reachable from self, excluding self.
Walks scalar ModelElement fields and frozenset/tuple
containers, deduplicating by object identity.
Returns:
| Type | Description |
|---|---|
list[ModelElement]
|
The list of reachable |
list[ModelElement]
|
order, without |
Source code in src/momapy/core/elements.py
Node
dataclass
Node(*, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, fill: NoneValueType | Color | None = None, filter: NoneValueType | Filter | None = None, height: float, label: TextLayout | None = None, position: Point, stroke: NoneValueType | Color | None = None, stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, stroke_dashoffset: NoneValueType | float | None = None, stroke_width: NoneValueType | float | None = None, transform: NoneValueType | tuple[Transformation] | None = None, width: float)
Bases: GroupLayout
Class for nodes. A node is a layout element with a position, a width, a height and an optional label.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_
|
str
|
The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element |
'725d6642-f0a4-46bb-9ce4-ae60c8544d8c'
|
layout_elements
|
tuple[LayoutElement]
|
The sub-layout elements of the group layout. These are part of the children of the group layout |
<dynamic>
|
group_fill
|
NoneValueType | Color | None
|
The fill color of the group layout |
None
|
group_fill_rule
|
FillRule | None
|
The fill rule of the group layout |
None
|
group_filter
|
NoneValueType | Filter | None
|
The filter of the group layout |
None
|
group_font_family
|
str | None
|
The font family of the group layout |
None
|
group_font_size
|
float | None
|
The font size of the group layout |
None
|
group_font_style
|
FontStyle | None
|
The font style of the group layout |
None
|
group_font_weight
|
FontWeight | float | None
|
The font weight of the group layout |
None
|
group_stroke
|
NoneValueType | Color | None
|
The stroke color of the group layout |
None
|
group_stroke_dasharray
|
NoneValueType | tuple[float, ...] | None
|
The stroke dasharray of the group layout |
None
|
group_stroke_dashoffset
|
NoneValueType | float | None
|
The stroke dashoffset of the group layout |
None
|
group_stroke_width
|
NoneValueType | float | None
|
The stroke width of the group layout |
None
|
group_text_anchor
|
TextAnchor | None
|
The text anchor of the group layout |
None
|
group_transform
|
NoneValueType | tuple[Transformation] | None
|
The transform of the group layout |
None
|
fill
|
NoneValueType | Color | None
|
The fill color of the node |
None
|
filter
|
NoneValueType | Filter | None
|
The filter of the node |
None
|
height
|
float
|
The height of the node |
required |
label
|
TextLayout | None
|
The label of the node |
None
|
position
|
Point
|
The position of the node |
required |
stroke
|
NoneValueType | Color | None
|
The stroke color of the node |
None
|
stroke_dasharray
|
NoneValueType | tuple[float, ...] | None
|
The stroke dasharray of the node |
None
|
stroke_dashoffset
|
NoneValueType | float | None
|
The stroke dashoffset of the node |
None
|
stroke_width
|
NoneValueType | float | None
|
The stroke width of the node |
None
|
transform
|
NoneValueType | tuple[Transformation] | None
|
The transform of the node |
None
|
width
|
float
|
The width width of the node |
required |
Methods:
| Name | Description |
|---|---|
anchor_point |
Return an anchor point of the layout element |
angle |
Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal. |
bbox |
Compute and return the bounding box of the group layout element |
border |
Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. |
center |
Return the center anchor of the node |
childless |
Return a copy of the node with no children |
children |
Return the children of the group layout. |
contains |
Return |
descendants |
Return the descendants of the layout element |
drawing_elements |
Return the drawing elements of the group layout. |
east |
Return the east anchor of the node |
east_north_east |
Return the east north east anchor of the node |
east_south_east |
Return the east south east west anchor of the node |
equals |
Return |
flattened |
Return a list containing copy of the layout element with no children and all its descendants with no children |
label_center |
Return the label center anchor of the node |
north |
Return the north anchor of the node |
north_east |
Return the north east anchor of the node |
north_north_east |
Return the north north east anchor of the node |
north_north_west |
Return the north north west anchor of the node |
north_west |
Return the north west anchor of the node |
own_angle |
Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal. |
own_bbox |
Compute and return the bounding box of the self drawing element of the group layout |
own_border |
Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. |
own_children |
Return the self children of the node. A node has unique child that is its label |
own_drawing_elements |
Return the node's own drawing elements |
own_to_geometry |
Return a list of geometry primitives from the self drawing elements. |
size |
Return the size of the node |
south |
Return the south anchor of the node |
south_east |
Return the south east anchor of the node |
south_south_east |
Return the south south east anchor of the node |
south_south_west |
Return the south south west anchor of the node |
south_west |
Return the south west anchor of the node |
to_geometry |
Return a list of geometry primitives from the drawing elements. |
west |
Return the west anchor of the node |
west_north_west |
Return the west north west anchor of the node |
west_south_west |
Return the west south west anchor of the node |
Attributes:
| Name | Type | Description |
|---|---|---|
x |
float
|
Return the x coordinate of the node |
y |
float
|
Return the y coordinate of the node |
anchor_point
anchor_point(anchor_name: str) -> Point
angle
angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point | None
Return the point on the border of the node that intersects the drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.
Source code in src/momapy/core/layout.py
bbox
bbox() -> Bbox
Compute and return the bounding box of the group layout element
Source code in src/momapy/core/layout.py
border
Return the point on the border of the node that intersects the drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned
Source code in src/momapy/core/layout.py
center
center() -> Point
childless
children
children() -> list[LayoutElement]
Return the children of the group layout.
These are the self children of the group layout (returned by the own_children method) and the other children of the group layout (given by the layout_elements attribute)
Source code in src/momapy/core/layout.py
contains
contains(other: LayoutElement) -> bool
Return true if another layout element is a descendant of the layout element, false otherwise
drawing_elements
drawing_elements() -> list[DrawingElement]
Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
Source code in src/momapy/core/layout.py
east
east() -> Point
east_north_east
east_north_east() -> Point
Return the east north east anchor of the node
Source code in src/momapy/core/layout.py
east_south_east
east_south_east() -> Point
Return the east south east west anchor of the node
Source code in src/momapy/core/layout.py
equals
equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool
Return true if the layout element is equal to another layout element, false otherwise
Source code in src/momapy/core/elements.py
flattened
flattened() -> list[LayoutElement]
Return a list containing copy of the layout element with no children and all its descendants with no children
Source code in src/momapy/core/elements.py
label_center
label_center() -> Point
north
north() -> Point
north_east
north_east() -> Point
Return the north east anchor of the node
Source code in src/momapy/core/layout.py
north_north_east
north_north_east() -> Point
Return the north north east anchor of the node
Source code in src/momapy/core/layout.py
north_north_west
north_north_west() -> Point
Return the north north west anchor of the node
Source code in src/momapy/core/layout.py
north_west
north_west() -> Point
Return the north west anchor of the node
Source code in src/momapy/core/layout.py
own_angle
own_angle(angle: float, unit: Literal['degrees', 'radians'] = 'degrees') -> Point | None
Return the point on the border of the node that intersects the self drawing elements of the node with the line passing through the center anchor point of the node and at a given angle from the horizontal.
Source code in src/momapy/core/layout.py
own_bbox
own_bbox() -> Bbox
Compute and return the bounding box of the self drawing element of the group layout
Source code in src/momapy/core/layout.py
own_border
Return the point on the border of the node that intersects the self drawing elements of the node with the line formed of the center anchor point of the node and the given point. When there are multiple intersection points, the one closest to the given point is returned
Source code in src/momapy/core/layout.py
own_children
own_children() -> list[LayoutElement]
Return the self children of the node. A node has unique child that is its label
own_drawing_elements
own_drawing_elements() -> list[DrawingElement]
Return the node's own drawing elements
Source code in src/momapy/core/layout.py
own_to_geometry
own_to_geometry() -> list[Segment | QuadraticBezierCurve | CubicBezierCurve | EllipticalArc]
Return a list of geometry primitives from the self drawing elements.
Source code in src/momapy/core/layout.py
size
south
south() -> Point
south_east
south_east() -> Point
Return the south east anchor of the node
Source code in src/momapy/core/layout.py
south_south_east
south_south_east() -> Point
Return the south south east anchor of the node
Source code in src/momapy/core/layout.py
south_south_west
south_south_west() -> Point
Return the south south west anchor of the node
Source code in src/momapy/core/layout.py
south_west
south_west() -> Point
Return the south west anchor of the node
Source code in src/momapy/core/layout.py
to_geometry
to_geometry() -> list[Segment | QuadraticBezierCurve | CubicBezierCurve | EllipticalArc]
Return a list of geometry primitives from the drawing elements.
Source code in src/momapy/core/elements.py
west
west() -> Point
west_north_west
west_north_west() -> Point
Return the west north west anchor of the node
Source code in src/momapy/core/layout.py
west_south_west
west_south_west() -> Point
Return the west south west anchor of the node
Source code in src/momapy/core/layout.py
Shape
dataclass
Bases: LayoutElement
Class for basic shapes. The shape is the most simple layout element. It has no children.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_
|
str
|
The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element |
'b9242375-8b1a-4757-ade6-ee885fadfaf6'
|
Methods:
| Name | Description |
|---|---|
anchor_point |
Return an anchor point of the layout element |
bbox |
Compute and return the bounding box of the shape |
childless |
Return a copy of the shape with no children. |
children |
Return the children of the shape. |
contains |
Return |
descendants |
Return the descendants of the layout element |
drawing_elements |
Return the drawing elements of the layout element |
equals |
Return |
flattened |
Return a list containing copy of the layout element with no children and all its descendants with no children |
to_geometry |
Return a list of geometry primitives from the drawing elements. |
anchor_point
anchor_point(anchor_name: str) -> Point
bbox
bbox() -> Bbox
Compute and return the bounding box of the shape
Source code in src/momapy/core/layout.py
childless
Return a copy of the shape with no children. A shape has no children, so return a copy of the shape
children
children() -> list[LayoutElement]
contains
contains(other: LayoutElement) -> bool
Return true if another layout element is a descendant of the layout element, false otherwise
drawing_elements
abstractmethod
drawing_elements() -> list[DrawingElement]
equals
equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool
Return true if the layout element is equal to another layout element, false otherwise
Source code in src/momapy/core/elements.py
flattened
flattened() -> list[LayoutElement]
Return a list containing copy of the layout element with no children and all its descendants with no children
Source code in src/momapy/core/elements.py
to_geometry
to_geometry() -> list[Segment | QuadraticBezierCurve | CubicBezierCurve | EllipticalArc]
Return a list of geometry primitives from the drawing elements.
Source code in src/momapy/core/elements.py
SingleHeadedArc
dataclass
SingleHeadedArc(*, id_: str = make_uuid4_as_str(), layout_elements: tuple[LayoutElement] = tuple(), group_fill: NoneValueType | Color | None = None, group_fill_rule: FillRule | None = None, group_filter: NoneValueType | Filter | None = None, group_font_family: str | None = None, group_font_size: float | None = None, group_font_style: FontStyle | None = None, group_font_weight: FontWeight | float | None = None, group_stroke: NoneValueType | Color | None = None, group_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, group_stroke_dashoffset: NoneValueType | float | None = None, group_stroke_width: NoneValueType | float | None = None, group_text_anchor: TextAnchor | None = None, group_transform: NoneValueType | tuple[Transformation] | None = None, end_shorten: float = 0.0, fill: NoneValueType | Color | None = None, filter: NoneValueType | Filter | None = None, path_fill: NoneValueType | Color | None = None, path_filter: NoneValueType | Filter | None = None, path_stroke: NoneValueType | Color | None = None, path_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, path_stroke_dashoffset: NoneValueType | float | None = None, path_stroke_width: float | None = None, path_transform: NoneValueType | tuple[Transformation] | None = None, stroke: NoneValueType | Color | None = None, stroke_dasharray: NoneValueType | tuple[float] | None = None, stroke_dashoffset: NoneValueType | float | None = None, stroke_width: NoneValueType | float | None = None, segments: tuple[Segment | QuadraticBezierCurve | CubicBezierCurve | EllipticalArc] = tuple(), source: LayoutElement | None = None, start_shorten: float = 0.0, target: LayoutElement | None = None, transform: NoneValueType | tuple[Transformation] | None = None, arrowhead_fill: NoneValueType | Color | None = None, arrowhead_filter: NoneValueType | Filter | None = None, arrowhead_stroke: NoneValueType | Color | None = None, arrowhead_stroke_dasharray: NoneValueType | tuple[float, ...] | None = None, arrowhead_stroke_dashoffset: NoneValueType | float | None = None, arrowhead_stroke_width: NoneValueType | float | None = None, arrowhead_transform: NoneValueType | tuple[Transformation] | None = None)
Bases: Arc
Base class for single-headed arcs. A single-headed arc is formed of a path and a unique arrowhead at its end
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_
|
str
|
The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element |
'5c839cff-38d9-4c7f-a4a9-4a61adf4e2d4'
|
layout_elements
|
tuple[LayoutElement]
|
The sub-layout elements of the group layout. These are part of the children of the group layout |
<dynamic>
|
group_fill
|
NoneValueType | Color | None
|
The fill color of the group layout |
None
|
group_fill_rule
|
FillRule | None
|
The fill rule of the group layout |
None
|
group_filter
|
NoneValueType | Filter | None
|
The filter of the group layout |
None
|
group_font_family
|
str | None
|
The font family of the group layout |
None
|
group_font_size
|
float | None
|
The font size of the group layout |
None
|
group_font_style
|
FontStyle | None
|
The font style of the group layout |
None
|
group_font_weight
|
FontWeight | float | None
|
The font weight of the group layout |
None
|
group_stroke
|
NoneValueType | Color | None
|
The stroke color of the group layout |
None
|
group_stroke_dasharray
|
NoneValueType | tuple[float, ...] | None
|
The stroke dasharray of the group layout |
None
|
group_stroke_dashoffset
|
NoneValueType | float | None
|
The stroke dashoffset of the group layout |
None
|
group_stroke_width
|
NoneValueType | float | None
|
The stroke width of the group layout |
None
|
group_text_anchor
|
TextAnchor | None
|
The text anchor of the group layout |
None
|
group_transform
|
NoneValueType | tuple[Transformation] | None
|
The transform of the group layout |
None
|
end_shorten
|
float
|
The length the end of the arc will be shorten by |
0.0
|
fill
|
NoneValueType | Color | None
|
The fill color of the arc |
None
|
filter
|
NoneValueType | Filter | None
|
The fill filter of the arc |
None
|
path_fill
|
NoneValueType | Color | None
|
The path fill color of the arc |
None
|
path_filter
|
NoneValueType | Filter | None
|
The path filter of the arc |
None
|
path_stroke
|
NoneValueType | Color | None
|
The path stroke color of the arc |
None
|
path_stroke_dasharray
|
NoneValueType | tuple[float, ...] | None
|
The path stroke dasharray of the arc |
None
|
path_stroke_dashoffset
|
NoneValueType | float | None
|
The path stroke dashoffset of the arc |
None
|
path_stroke_width
|
float | None
|
The path stroke width of the arc |
None
|
path_transform
|
NoneValueType | tuple[Transformation] | None
|
The path transform of the arc |
None
|
stroke
|
NoneValueType | Color | None
|
The stroke color of the arc |
None
|
stroke_dasharray
|
NoneValueType | tuple[float] | None
|
The stroke dasharray of the arc |
None
|
stroke_dashoffset
|
NoneValueType | float | None
|
The stroke dashoffset of the arc |
None
|
stroke_width
|
NoneValueType | float | None
|
The stroke width of the arc |
None
|
segments
|
tuple[Segment | QuadraticBezierCurve | CubicBezierCurve | EllipticalArc]
|
The path segments of the arc |
<dynamic>
|
source
|
LayoutElement | None
|
The source of the arc |
None
|
start_shorten
|
float
|
The length the start of the arc will be shorten by |
0.0
|
target
|
LayoutElement | None
|
The target of the arc |
None
|
transform
|
NoneValueType | tuple[Transformation] | None
|
The transform of the arc |
None
|
arrowhead_fill
|
NoneValueType | Color | None
|
The arrowhead fill color of the arc |
None
|
arrowhead_filter
|
NoneValueType | Filter | None
|
The arrowhead filter of the arc |
None
|
arrowhead_stroke
|
NoneValueType | Color | None
|
The arrowhead stroke color of the arc |
None
|
arrowhead_stroke_dasharray
|
NoneValueType | tuple[float, ...] | None
|
The arrowhead stroke dasharray of the arc |
None
|
arrowhead_stroke_dashoffset
|
NoneValueType | float | None
|
The arrowhead stroke dashoffset of the arc |
None
|
arrowhead_stroke_width
|
NoneValueType | float | None
|
The arrowhead stroke width of the arc |
None
|
arrowhead_transform
|
NoneValueType | tuple[Transformation] | None
|
The arrowhead transform of the arc |
None
|
Methods:
| Name | Description |
|---|---|
anchor_point |
Return an anchor point of the layout element |
arrowhead_base |
Return the arrowhead base anchor point of the single-headed arc |
arrowhead_bbox |
Return the bounding box of the single-headed arc arrowhead |
arrowhead_border |
Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. |
arrowhead_drawing_elements |
Return the drawing elements of the single-headed arc arrowhead |
arrowhead_length |
Return the length of the single-headed arc arrowhead |
arrowhead_tip |
Return the arrowhead tip anchor point of the single-headed arc |
bbox |
Compute and return the bounding box of the group layout element |
childless |
Return a copy of the arc with no children |
children |
Return the children of the group layout. |
contains |
Return |
descendants |
Return the descendants of the layout element |
drawing_elements |
Return the drawing elements of the group layout. |
end_point |
Return the ending point of the arc |
equals |
Return |
flattened |
Return a list containing copy of the layout element with no children and all its descendants with no children |
fraction |
Return the position and angle on the arc at a given fraction (of the total arc length) |
length |
Return the total length of the arc path |
own_bbox |
Compute and return the bounding box of the self drawing element of the group layout |
own_children |
Return the self children of the arc |
own_drawing_elements |
Return the self drawing elements of the single-headed arc |
own_to_geometry |
Return a list of geometry primitives from the self drawing elements. |
path_drawing_elements |
Return the drawing elements of the single-headed arc path |
points |
Return the points of the arc path |
start_point |
Return the starting point of the arc |
to_geometry |
Return a list of geometry primitives from the drawing elements. |
anchor_point
anchor_point(anchor_name: str) -> Point
arrowhead_base
arrowhead_base() -> Point
Return the arrowhead base anchor point of the single-headed arc
Source code in src/momapy/core/layout.py
arrowhead_border
arrowhead_border(point) -> Point
Return the point at the intersection of the drawing elements of the single-headed arc arrowhead and the line going through the center of these drawing elements and the given point. When there are multiple intersection points, the one closest to the given point is returned
Source code in src/momapy/core/layout.py
arrowhead_drawing_elements
arrowhead_drawing_elements() -> list[DrawingElement]
Return the drawing elements of the single-headed arc arrowhead
Source code in src/momapy/core/layout.py
arrowhead_length
Return the length of the single-headed arc arrowhead
Source code in src/momapy/core/layout.py
arrowhead_tip
arrowhead_tip() -> Point
Return the arrowhead tip anchor point of the single-headed arc
Source code in src/momapy/core/layout.py
bbox
bbox() -> Bbox
Compute and return the bounding box of the group layout element
Source code in src/momapy/core/layout.py
childless
children
children() -> list[LayoutElement]
Return the children of the group layout.
These are the self children of the group layout (returned by the own_children method) and the other children of the group layout (given by the layout_elements attribute)
Source code in src/momapy/core/layout.py
contains
contains(other: LayoutElement) -> bool
Return true if another layout element is a descendant of the layout element, false otherwise
drawing_elements
drawing_elements() -> list[DrawingElement]
Return the drawing elements of the group layout. The returned drawing elements are a group drawing element formed of the self drawing elements of the group layout and the drawing elements of its children
Source code in src/momapy/core/layout.py
end_point
end_point() -> Point
equals
equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool
Return true if the layout element is equal to another layout element, false otherwise
Source code in src/momapy/core/elements.py
flattened
flattened() -> list[LayoutElement]
Return a list containing copy of the layout element with no children and all its descendants with no children
Source code in src/momapy/core/elements.py
fraction
fraction(fraction: float) -> tuple[Point, float]
Return the position and angle on the arc at a given fraction (of the total arc length)
Source code in src/momapy/core/layout.py
length
own_bbox
own_bbox() -> Bbox
Compute and return the bounding box of the self drawing element of the group layout
Source code in src/momapy/core/layout.py
own_children
own_children() -> list[LayoutElement]
own_drawing_elements
own_drawing_elements() -> list[DrawingElement]
Return the self drawing elements of the single-headed arc
Source code in src/momapy/core/layout.py
own_to_geometry
own_to_geometry() -> list[Segment | QuadraticBezierCurve | CubicBezierCurve | EllipticalArc]
Return a list of geometry primitives from the self drawing elements.
Source code in src/momapy/core/layout.py
path_drawing_elements
path_drawing_elements() -> list[Path]
Return the drawing elements of the single-headed arc path
Source code in src/momapy/core/layout.py
points
points() -> list[Point]
start_point
start_point() -> Point
to_geometry
to_geometry() -> list[Segment | QuadraticBezierCurve | CubicBezierCurve | EllipticalArc]
Return a list of geometry primitives from the drawing elements.
Source code in src/momapy/core/elements.py
TextLayout
dataclass
TextLayout(*, id_: str = make_uuid4_as_str(), text: str, font_family: str = get_initial_value('font_family'), font_size: float = get_initial_value('font_size'), font_style: FontStyle = get_initial_value('font_style'), font_weight: FontWeight | int = get_initial_value('font_weight'), position: Point, width: float | None = None, height: float | None = None, horizontal_alignment: HAlignment = LEFT, vertical_alignment: VAlignment = TOP, justify: bool = False, fill: NoneValueType | Color | None = None, filter: NoneValueType | Filter | None = None, stroke: NoneValueType | Color | None = None, stroke_dasharray: NoneValueType | tuple[float] | None = None, stroke_dashoffset: NoneValueType | float | None = None, stroke_width: float | None = None, text_anchor: TextAnchor | None = None, transform: NoneValueType | tuple[Transformation] | None = None)
Bases: LayoutElement
Class for text layouts
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id_
|
str
|
The id of the map element. This id is purely for the user to keep track of the element, it does not need to be unique and is not part of the identity of the element, i.e., it is not considered when testing for equality between two map elements or when hashing the map element |
'bd399309-f621-4e92-a75c-319087b70f06'
|
text
|
str
|
The text of the text layout |
required |
font_family
|
str
|
The font family of the text layout |
'DejaVu Sans'
|
font_size
|
float
|
The font size of the text layout |
16.0
|
font_style
|
FontStyle
|
The font style of the text layout |
<FontStyle.NORMAL: 0>
|
font_weight
|
FontWeight | int
|
The font weight of the text layout |
<FontWeight.NORMAL: 0>
|
position
|
Point
|
The position of the text layout |
required |
width
|
float | None
|
The width of the text layout |
None
|
height
|
float | None
|
The height of the text layout |
None
|
horizontal_alignment
|
HAlignment
|
The horizontal alignment of the text layout |
<HAlignment.LEFT: 1>
|
vertical_alignment
|
VAlignment
|
The vertical alignment of the text layout |
<VAlignment.TOP: 1>
|
justify
|
bool
|
Whether to justify the text or not |
False
|
fill
|
NoneValueType | Color | None
|
The text fill color of the text layout |
None
|
filter
|
NoneValueType | Filter | None
|
The filter of the text layout |
None
|
stroke
|
NoneValueType | Color | None
|
The text stroke color of the text layout |
None
|
stroke_dasharray
|
NoneValueType | tuple[float] | None
|
The text stroke dasharray of the text layout |
None
|
stroke_dashoffset
|
NoneValueType | float | None
|
The text stroke dashoffset of the text layout |
None
|
stroke_width
|
float | None
|
The text stroke width of the text layout |
None
|
text_anchor
|
TextAnchor | None
|
The text anchor of the text layout |
None
|
transform
|
NoneValueType | tuple[Transformation] | None
|
The transform of the text layout |
None
|
Methods:
| Name | Description |
|---|---|
anchor_point |
Return an anchor point of the layout element |
bbox |
Compute and return the bounding box of the layout element |
childless |
Return a copy of the text layout with no children. |
children |
Return the children of the text layout. |
contains |
Return |
descendants |
Return the descendants of the layout element |
drawing_elements |
Return the drawing elements of the text layout |
east |
Return the east anchor of the text layout |
east_north_east |
Return the east north east anchor of the text layout |
east_south_east |
Return the east south east anchor of the text layout |
equals |
Return |
flattened |
Return a list containing copy of the layout element with no children and all its descendants with no children |
north |
Return the north anchor of the text layout |
north_east |
Return the north east anchor of the text layout |
north_north_east |
Return the north north east anchor of the text layout |
north_north_west |
Return the north north west anchor of the text layout |
north_west |
Return the north west anchor of the text layout |
south |
Return the south anchor of the text layout |
south_east |
Return the south east anchor of the text layout |
south_south_east |
Return the south south east anchor of the text layout |
south_south_west |
Return the south south west anchor of the text layout |
south_west |
Return the south west anchor of the text layout |
to_geometry |
Return a list of geometry primitives from the drawing elements. |
west |
Return the west anchor of the text layout |
west_north_west |
Return the west north west anchor of the text layout |
west_south_west |
Return the west south west anchor of the text layout |
Attributes:
| Name | Type | Description |
|---|---|---|
x |
float
|
Return the y coordinate of the text layout |
y |
float
|
Return the y coordinate of the text layout |
anchor_point
anchor_point(anchor_name: str) -> Point
bbox
bbox() -> Bbox
Compute and return the bounding box of the layout element
Source code in src/momapy/core/layout.py
childless
Return a copy of the text layout with no children. The text layout has no children, so return a copy of the text layout
children
children() -> list[LayoutElement]
Return the children of the text layout. The text layout has no children, so return an empty list
contains
contains(other: LayoutElement) -> bool
Return true if another layout element is a descendant of the layout element, false otherwise
drawing_elements
drawing_elements() -> list[DrawingElement]
Return the drawing elements of the text layout
Source code in src/momapy/core/layout.py
east
east() -> Point
east_north_east
east_north_east() -> Point
east_south_east
east_south_east() -> Point
equals
equals(other: LayoutElement, flattened: bool = False, unordered: bool = False) -> bool
Return true if the layout element is equal to another layout element, false otherwise
Source code in src/momapy/core/elements.py
flattened
flattened() -> list[LayoutElement]
Return a list containing copy of the layout element with no children and all its descendants with no children
Source code in src/momapy/core/elements.py
north
north() -> Point
north_east
north_east() -> Point
north_north_east
north_north_east() -> Point
north_north_west
north_north_west() -> Point
north_west
north_west() -> Point
south
south() -> Point
south_east
south_east() -> Point
south_south_east
south_south_east() -> Point
south_south_west
south_south_west() -> Point
south_west
south_west() -> Point
to_geometry
to_geometry() -> list[Segment | QuadraticBezierCurve | CubicBezierCurve | EllipticalArc]
Return a list of geometry primitives from the drawing elements.
Source code in src/momapy/core/elements.py
west
west() -> Point
west_north_west
west_north_west() -> Point
west_south_west
west_south_west() -> Point
find_font
find_font(family: str, weight: FontWeight | int, style: FontStyle) -> str | None
Find the best matching font file path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
family
|
str
|
Font family name. |
required |
weight
|
FontWeight | int
|
Font weight as FontWeight enum or int (100-900). |
required |
style
|
FontStyle
|
Font style. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
Path to the best matching font file, or None if no fonts found. |