ArrowHead
The ArrowHead class encapsulates the arrow head at the end of a Curve in a Reaction. It provides methods to retrieve and modify the arrow head’s identifier, bounding box position and size, and any underlying geometric shapes and styling.
After loading a model and retrieving a Curve in a Reaction, you can:
Obtain the ArrowHead instance via
Curve.get_arrow_head().Inspect or update its position, size, shapes, and styling.
import sbmlnetwork as sn
# Load the SBML model
net = sn.load("my_model.xml")
# Get reaction id
reaction_id = net.get_reaction_ids()[0]
arrow_head = None
# Find the first species that is a product of the reaction
for species in net.get_species_list():
if species.get_role(reaction_id) == "product":
arrow_head = species.get_arrow_heads()[0]
break
# Inspect identifier and position
print("ID:", arrow_head.get_id())
print("Position:", arrow_head.get_relative_position())
Core Methods
Identification
- get_id()
Return the unique identifier of the arrow head (start or end), or None if not defined.
- Return type:
str or None
Position
- get_relative_position()
Get the (x, y) coordinates of the arrow head’s bounding box.
- Returns:
A 2-tuple of floats representing (x, y).
- Return type:
tuple[float, float]
- set_relative_position(relative_position)
Set the (x, y) coordinates of the arrow head’s bounding box.
- Parameters:
relative_position (tuple[float, float]) – A 2-tuple of floats representing the new (x, y).
- Returns:
True if the operation succeeded, False otherwise.
- Return type:
bool
Size
- get_size()
Get the (width, height) of the arrow head’s bounding box.
- Returns:
A 2-tuple of floats representing (width, height).
- Return type:
tuple[float, float]
- set_size(size)
Set the (width, height) of the arrow head’s bounding box.
- Parameters:
size (tuple[float, float]) – A 2-tuple of floats representing the new (width, height).
- Returns:
True if the operation succeeded, False otherwise.
- Return type:
bool
Shapes
- add_shape(shape_type)
Add a new geometric shape of the given type to this arrow head.
- Parameters:
shape_type (str) – One of the valid geometric shape type names.
- Returns:
The newly created
ShapeBaseinstance, or None if creation failed.- Return type:
ShapeBase or None
- remove_shape(shape)
Remove the specified shape from this arrow head.
- Parameters:
shape (ShapeBase) – The
ShapeBaseto remove.- Returns:
True if removal succeeded, False otherwise.
- Return type:
bool
- get_shape()
Retrieve the first geometric shape attached to this arrow head.
- Returns:
A
ShapeBaseor None if no shapes are present.- Return type:
ShapeBase or None
- get_shapes_list()
Return a list of all geometric shapes attached to this arrow head.
- Returns:
A
ShapeListcontaining all shapes.- Return type:
ShapeList
- get_shape_type()
Get the types of all attached geometric shapes.
- Returns:
A list of shape type names.
- Return type:
list[str]
Styling
- get_border_color()
Get the border color(s) of all attached shapes.
- Returns:
A list of color values.
- Return type:
list[str]
- set_border_color(border_color)
Set the border color for all attached shapes.
- Parameters:
border_color (str) – A color string (e.g., “#RRGGBB”).
- Returns:
True if the operation succeeded, False otherwise.
- Return type:
bool
- get_border_thickness()
Get the border thickness(es) of all attached shapes.
- Returns:
A list of floats.
- Return type:
list[float]
- set_border_thickness(thickness)
Set the border thickness for all attached shapes.
- Parameters:
thickness (float) – The new border thickness.
- Returns:
True if the operation succeeded, False otherwise.
- Return type:
bool
- get_fill_color()
Get the fill color(s) of all attached shapes.
- Returns:
A list of color values.
- Return type:
list[str]
- set_fill_color(fill_color)
Set the fill color for all attached shapes.
- Parameters:
fill_color (str or tuple or list) – A color string or RGB tuple/list.
- Returns:
True if the operation succeeded, False otherwise.
- Return type:
bool
Movement
- move_relative_position_to(relative_position)
Alias for
set_relative_position().- Parameters:
relative_position (tuple[float, float]) – A 2-tuple of floats representing the new (x, y).
- Returns:
True if the operation succeeded, False otherwise.
- Return type:
bool
- move_relative_position_by(delta)
Move the arrow head by the specified (dx, dy) offset.
- Parameters:
delta (tuple[float, float]) – A 2-tuple of floats representing (dx, dy).
- Returns:
True if the operation succeeded, False otherwise.
- Return type:
bool
Information
- property info
Human-readable summary of glyph state for debugging.
- Return type:
str
- get_info()
Generate the info string.
Example workflow
import sbmlnetwork as sn
# Load the SBML model
net = sn.load("my_model.xml")
# Get an arrow head from the first reaction
curves = net.get_reactions_list()[0].get_curves_list()
arrow_head = None
for curve in curves:
if curve.get_arrow_head() is not None:
arrow_head = curve.get_arrow_head()
break
# Inspect identifier and position
print("ID:", arrow_head.get_id())
print("Position:", arrow_head.get_relative_position())
# Resize and restyle
arrow_head.set_size((10.0, 8.0))
arrow_head.set_fill_color("#333333")
arrow_head.set_border_color("#000000")