legend_t Derived Type

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

  • private subroutine legend_add_entry(this, label, color, linestyle, marker)

    Add entry following Open/Closed principle

    Arguments

    Type IntentOptional Attributes Name
    class(legend_t), intent(inout) :: this
    character(len=*), intent(in) :: label
    real(kind=wp), intent(in), dimension(3) :: color
    character(len=*), intent(in), optional :: linestyle
    character(len=*), intent(in), optional :: marker

procedure, public :: render => legend_render

  • public subroutine legend_render(this, backend)

    Render legend following Liskov Substitution Works with any backend that implements plot_context interface

    Arguments

    Type IntentOptional Attributes Name
    class(legend_t), intent(in) :: this
    class(plot_context), intent(inout) :: backend

procedure, public :: set_position => legend_set_position

  • private subroutine legend_set_position(this, location)

    Set legend position using string interface

    Arguments

    Type IntentOptional Attributes Name
    class(legend_t), intent(inout) :: this
    character(len=*), intent(in) :: location

procedure, public :: clear => legend_clear

  • private subroutine legend_clear(this)

    Clear all legend entries

    Arguments

    Type IntentOptional Attributes Name
    class(legend_t), intent(inout) :: this