capellambse.svg package¶
Export diagrams to .svg
files.
Submodules¶
capellambse.svg.decorations module¶
The decoration factories for svg elements.
- class capellambse.svg.decorations.DecoFactories¶
Bases:
dict
[str
,DecoFactory
]
- class capellambse.svg.decorations.DecoFactory¶
Bases:
object
DecoFactory(function: ‘cabc.Callable’, dependencies: ‘tuple[str, …]’)
- __init__(function, dependencies)¶
- capellambse.svg.decorations.feature_space = 24¶
Default margins/padding (top/bot and left/right) for feature text.
- capellambse.svg.decorations.icon_padding = 2¶
Default icon padding (left/right side).
- capellambse.svg.decorations.icon_size = 20¶
Default icon size.
- capellambse.svg.decorations.max_label_width = 1500¶
Maximum width for a label.
- capellambse.svg.decorations.min_symbol_width = 200¶
Minimum width (available horizontal space) for a symbol.
capellambse.svg.drawing module¶
Custom extensions to the svgwrite Drawing
object.
- capellambse.svg.drawing.DEBUG = False¶
Debug flag to render helping lines.
- class capellambse.svg.drawing.Drawing¶
Bases:
object
The main container that stores all svg elements.
- __init__(metadata, *, font_family="'Open Sans','Segoe UI',Arial,sans-serif", font_size=11, transparent_background=False)¶
- Parameters:
metadata (DiagramMetadata)
font_family (str)
font_size (int)
transparent_background (bool)
- draw_object(obj)¶
Draw an object into this drawing.
- save_as(filename=None, **kw)¶
Write the SVG to a file.
If
filename
wasn’t given the underlyingfilename
is taken.
- capellambse.svg.drawing.LABEL_ICON_PADDING = 2¶
Default padding between a label’s icon and text.
- class capellambse.svg.drawing.LabelBuilder¶
Bases:
object
Helper data-class for building labels.
- __init__(rect_width, rect_height, labels, group, labelstyle, class_=None, y_margin=0, text_anchor='start', icon=True, icon_size=20, alignment='center')¶
- class capellambse.svg.drawing.LinesData¶
Bases:
object
Helper data-tuple for rendering text-lines from labels.
- __init__(lines, line_height, text_height, margin, max_line_width, min_x=None)¶
- capellambse.svg.drawing.get_label_icon_position(builder, lines)¶
Calculate the icon’s position.
- Parameters:
builder (LabelBuilder)
lines (LinesData)
- Return type:
- capellambse.svg.drawing.get_label_position(builder, lines)¶
Calculate the label positions.
- Parameters:
builder (LabelBuilder)
lines (LinesData)
- Return type:
- capellambse.svg.drawing.render_hbounded_lines(builder, render_icon)¶
Return Lines data to render a label.
- Parameters:
builder (LabelBuilder)
render_icon (bool)
- Return type:
capellambse.svg.generate module¶
- class capellambse.svg.generate.DiagramMetadata¶
Bases:
object
Holds metadata about a diagram.
The metadata of a diagram includes the diagram-name,
(x, y)
position,(w, h)
size, the viewbox string and the diagram class, e.g.LogicalArchitectureBlank
.- __init__(pos, size, name, class_, **_kw)¶
- classmethod from_dict(data)¶
- Parameters:
data (DiagramMetadataDict)
- Return type:
- class capellambse.svg.generate.DiagramMetadataDict¶
Bases:
TypedDict
- contents: Sequence[ContentsDict]¶
- class capellambse.svg.generate.SVGDiagram¶
Bases:
object
An SVG diagram that can be drawn on and serialized.
SVG diagram object that takes the
metadata
of a diagram via theDiagramMetadata
and a list of objects that are dictionaries describing the components to be drawn on the diagram canvas of typeDrawing
.Example of expected json-file/string:
{ "name": "FA00 - Functional Architecture Example", "class": "LogicalArchitectureBlank", "x": 10, "y": 20, "width": 100, "height": 200, "contents": [ { "type": "box", "id": "_ZNVPYDHuEeqOg4absf8kjA", "class": "LogicalFunction", "x": 150, "y": 130, "width": 101, "height": 101, "label": "example label" } ] }
- __init__(metadata, objects, params=None)¶
- Parameters:
metadata (DiagramMetadata)
objects (Sequence[ContentsDict])
- Return type:
None
- draw_object(obj)¶
Draw the given
obj
on the underlayingDrawing
.- Parameters:
obj (ContentsDict)
- Return type:
None
- classmethod from_json(jsonstring)¶
Create an SVGDiagram from the given JSON string.
- Parameters:
jsonstring (str) – Json/dictionary in
str
format- Returns:
SVG diagram object
- Return type:
- classmethod from_json_path(path)¶
Create an SVGDiagram from the given JSON file.
- Parameters:
- Returns:
SVG diagram object
- Return type:
- save(filename=None, pretty=False, indent=2)¶
Write the underlying
Drawing
to an SVG file.
- save_drawing(*args, **kwargs)¶
- Return type:
None
capellambse.svg.helpers module¶
- capellambse.svg.helpers.check_for_horizontal_overflow(text, width, icon_padding, icon_size, alignment='center')¶
capellambse.svg.style module¶
Stylesheet generator for SVG diagrams.
capellambse.svg.symbols module¶
- capellambse.svg.symbols.and_control_node_symbol(id_='AndControlNodeSymbol')¶
- capellambse.svg.symbols.capability_symbol(id_='CapabilitySymbol')¶
- capellambse.svg.symbols.component_exchange_symbol(id_='ComponentExchangeSymbol')¶
- capellambse.svg.symbols.component_port_symbol(id_='ComponentPortSymbol')¶
- capellambse.svg.symbols.diamond_mark(id_='Diamond', **kw)¶
- capellambse.svg.symbols.entity_symbol(id_='EntitySymbol')¶
- capellambse.svg.symbols.error_symbol(id_='ErrorSymbol', **kw)¶
- capellambse.svg.symbols.filled_diamond_mark(id_='FilledDiamond', **kw)¶
- capellambse.svg.symbols.final_state_symbol(id_='FinalStateSymbol')¶
- capellambse.svg.symbols.fine_arrow_mark(id_='FineArrow', **kw)¶
- capellambse.svg.symbols.function_symbol(id_='FunctionSymbol', colors=('#6CB35B', '#ffffff'), gradient_url='green', label='F')¶
- capellambse.svg.symbols.functional_exchange_symbol(id_='FunctionalExchangeSymbol')¶
- capellambse.svg.symbols.generalization_mark(id_='Generalization', **kw)¶
- capellambse.svg.symbols.initial_pseudo_state_symbol(id_='InitialPseudoStateSymbol')¶
- capellambse.svg.symbols.iterate_control_node_symbol(id_='IterateControlNodeSymbol')¶
- capellambse.svg.symbols.logical_actor_symbol(id_='LogicalActorSymbol')¶
- capellambse.svg.symbols.logical_component_symbol(id_='LogicalComponentSymbol')¶
- capellambse.svg.symbols.logical_function_symbol(id_='LogicalFunctionSymbol')¶
- capellambse.svg.symbols.logical_human_actor_symbol(id_='LogicalHumanActorSymbol')¶
- capellambse.svg.symbols.logical_human_component_symbol(id_='LogicalHumanComponentSymbol')¶
- capellambse.svg.symbols.mission_symbol(id_='MissionSymbol')¶
- capellambse.svg.symbols.mode_symbol(id_='ModeSymbol')¶
- capellambse.svg.symbols.operational_activity_symbol(id_='OperationalActivitySymbol')¶
- capellambse.svg.symbols.operational_actor_box_symbol(id_='OperationalActorBoxSymbol')¶
- capellambse.svg.symbols.operational_actor_symbol(id_='OperationalActorSymbol')¶
- capellambse.svg.symbols.operational_capability_symbol(id_='OperationalCapabilitySymbol')¶
- capellambse.svg.symbols.operational_exchange_symbol(id_='OperationalExchangeSymbol')¶
- capellambse.svg.symbols.or_control_node_symbol(id_='OrControlNodeSymbol')¶
- capellambse.svg.symbols.physical_behavior_actor_symbol(id_='PhysicalBehaviorActorSymbol')¶
- capellambse.svg.symbols.physical_behavior_component_symbol(id_='PhysicalBehaviorComponentSymbol')¶
- capellambse.svg.symbols.physical_behavior_human_actor_symbol(id_='PhysicalBehaviorHumanActorSymbol')¶
- capellambse.svg.symbols.physical_behavior_human_component_symbol(id_='PhysicalBehaviorHumanComponentSymbol')¶
- capellambse.svg.symbols.physical_component_symbol(id_='PhysicalComponentSymbol')¶
- capellambse.svg.symbols.physical_function_symbol(id_='PhysicalFunctionSymbol')¶
- capellambse.svg.symbols.physical_link_symbol(id_='PhysicalLinkSymbol')¶
- capellambse.svg.symbols.physical_node_actor_symbol(id_='PhysicalNodeActorSymbol')¶
- capellambse.svg.symbols.physical_node_component_symbol(id_='PhysicalNodeComponentSymbol')¶
- capellambse.svg.symbols.physical_node_human_actor_symbol(id_='PhysicalNodeHumanActorSymbol')¶
- capellambse.svg.symbols.physical_node_human_component_symbol(id_='PhysicalNodeHumanComponentSymbol')¶
- capellambse.svg.symbols.representation_link_symbol(id_='RepresentationLinkSymbol')¶
- capellambse.svg.symbols.requirement_symbol(id_='RequirementSymbol')¶
- capellambse.svg.symbols.standalone_stick_figure_symbol(id_='StandaloneStickFigureSymbol')¶
- capellambse.svg.symbols.state_symbol(id_='StateSymbol')¶
- capellambse.svg.symbols.stick_figure_symbol(id_='StickFigureSymbol', transform=None, head_color='none', **kw)¶
Generate StickFigure svg symbol.
- capellambse.svg.symbols.system_actor_symbol(id_='SystemActorSymbol')¶
- capellambse.svg.symbols.system_component_symbol(id_='SystemComponentSymbol')¶
- capellambse.svg.symbols.system_function_symbol(id_='SystemFunctionSymbol')¶
- capellambse.svg.symbols.system_human_actor_symbol(id_='SystemHumanActorSymbol')¶
- capellambse.svg.symbols.terminate_pseudo_state_symbol(id_='TerminatePseudoStateSymbol', stroke='#000', stroke_width=0.165)¶