fortplot_legend_state Module

Legend state and factory functions

Single Responsibility: Legend type definitions and factory functions



Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: LEGEND_UPPER_LEFT = 1
integer, public, parameter :: LEGEND_UPPER_RIGHT = 2
integer, public, parameter :: LEGEND_LOWER_LEFT = 3
integer, public, parameter :: LEGEND_LOWER_RIGHT = 4
integer, public, parameter :: LEGEND_EAST = 5

Derived Types

type, public ::  legend_entry_t

Single Responsibility: Represents one legend entry

Components

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: label
real(kind=wp), public, dimension(3) :: color = [0.0_wp, 0.0_wp, 0.0_wp]
character(len=:), public, allocatable :: linestyle
character(len=:), public, allocatable :: marker

type, public ::  legend_t

Single Responsibility: Legend layout and rendering coordination

Components

Type Visibility Attributes Name Initial
type(legend_entry_t), public, allocatable :: entries(:)
integer, public :: position = LEGEND_UPPER_RIGHT
integer, public :: num_entries = 0
real(kind=wp), public :: x_offset = 10.0_wp
real(kind=wp), public :: y_offset = 10.0_wp
real(kind=wp), public :: entry_height = 20.0_wp
real(kind=wp), public :: line_length = 30.0_wp
real(kind=wp), public :: text_padding = 10.0_wp

Type-Bound Procedures

procedure, public :: add_entry => legend_add_entry
procedure, public :: set_position => legend_set_position
procedure, public :: clear => legend_clear

Functions

public function create_legend() result(legend)

Factory function following Dependency Inversion

Arguments

None

Return Value type(legend_t)