stormvogel.layout

Store and manage loading/saving of the layout file and the schema file.

The schema file may be used by the LayoutEditor to create an editor for this Layout. The Layout object also provides methods to manipulate the layout and the schema, such as setting node positions from a NetworkX layout.

Attributes

Classes

Layout

Store the layout and schema for a visualization.

Functions

DEFAULT()

EXPLORE()

SV()

LTS()

Module Contents

stormvogel.layout.PACKAGE_ROOT_DIR
class stormvogel.layout.Layout(path: str | None = None, path_relative: bool = True, layout_dict: dict | None = None)

Store the layout and schema for a visualization.

Upon creation, the layout and schema dicts are loaded from layouts/default.json and layouts/schema.json, unless specified otherwise. Load a custom layout file by setting either path or path_relative, or provide a custom layout dict instead.

Parameters:
  • path – Path to a custom layout file. Leave as None for the default layout.

  • path_relative – If True, stormvogel looks for a custom layout file relative to the current working directory.

  • layout_dict – If set, this dictionary is used as the layout instead of the file specified in path. Missing keys are filled from layouts/default.json.

default_dict: dict
load_schema() None

Load in the schema. Used for the layout editor. Stored as self.schema.

load(path: str | None = None, path_relative: bool = True) None

Load the layout and schema file at the specified path.

They are stored as layout and schema respectively.

Parameters:
  • path – Path to the layout file, or None for the default layout.

  • path_relative – If True, path is resolved relative to the current working directory.

add_active_group(group: str) None

Make a group active if it is not already.

The user can specify which groups of states can be edited separately. Such groups are referred to as active groups.

Parameters:

group – Name of the group to activate.

remove_active_group(group: str) None

Make a group inactive if it is not already.

Parameters:

group – Name of the group to deactivate.

set_possible_groups(groups: set[str]) None

Set the groups of states that the user can choose to make active.

These appear under edit_groups in the layout editor.

Parameters:

groups – Set of group names to make available.

save(path: str, path_relative: bool = True) None

Save this layout as a JSON file.

Parameters:
  • path – Path to the layout file. Must end in .json.

  • path_relative – If True, path is resolved relative to the current working directory.

Raises:
  • RuntimeError – If the filename does not end in .json.

  • OSError – If the file cannot be written.

set_value(path: list[str], value: Any) None

Set a value in the layout.

Also works if a key in the path does not exist.

Parameters:
  • path – List of keys forming the path to the value.

  • value – The value to set.

__str__() str
copy_settings() None

Copy some settings from one place in the layout to another place in the layout. They differ because visjs requires for them to be arranged a certain way which is not nice for an editor.

set_nx_pos(pos: dict, scale: float = 500) Self

Apply NetworkX layout positions to this layout and disable physics.

Parameters:
  • pos – Dictionary of node positions from a NetworkX graph.

  • scale – Scaling factor for the positions.

Returns:

This Layout instance, for chaining.

stormvogel.layout.DEFAULT()
stormvogel.layout.EXPLORE()
stormvogel.layout.SV()
stormvogel.layout.LTS()