| 1 | |||||||||||
| 2 | package App::Asciio::stripes::stripes ; | ||||||||||
| 3 | |||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 3 | ▶ | use List::Util qw(max) ; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 3 | ▶ | use App::Asciio::String ; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | #--------------------------------------------------------------------------- | ||||||||||
| 11 | |||||||||||
| 12 | sub new | ||||||||||
| 13 | 0 | ▶ | { | ||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 14 | 0 | my ($class, $element_definition) = @_ ; | |||||||||
| 15 | |||||||||||
| 16 | 0 | my @stripes ; | |||||||||
| 17 | |||||||||||
| 18 | 0 | my ($total_width, $total_height) = (0, 0) ; | |||||||||
| 19 | 0 | my ($min_x, $min_y, $max_x, $max_y) = (0, 0, 0, 0) ; | |||||||||
| 20 | |||||||||||
| 21 | 0 | for my $stripe (@{$element_definition->{STRIPES}}) | |||||||||
| 22 | { | ||||||||||
| 23 | 0 | my $text = $stripe->{TEXT} ; | |||||||||
| 24 | |||||||||||
| 25 | 0 | my $width = max( map{ unicode_length($_) } split("\n", $text)) ; | |||||||||
| 26 | |||||||||||
| 27 | 0 | my $height = ($text =~ tr[\n][\n]) + 1 ; | |||||||||
| 28 | |||||||||||
| 29 | push @stripes, | ||||||||||
| 30 | { | ||||||||||
| 31 | TEXT => $text, | ||||||||||
| 32 | X_OFFSET => $stripe->{X_OFFSET}, | ||||||||||
| 33 | Y_OFFSET => $stripe->{Y_OFFSET}, | ||||||||||
| 34 | 0 | WIDTH => $width, | |||||||||
| 35 | HEIGHT => $height , | ||||||||||
| 36 | } ; | ||||||||||
| 37 | |||||||||||
| 38 | 0 | ($total_width) = max($total_width, $stripe->{X_OFFSET} + $width) ; | |||||||||
| 39 | 0 | ($total_height) = max($total_height, $stripe->{Y_OFFSET} + $height) ; | |||||||||
| 40 | |||||||||||
| 41 | 0 | ($min_x, $max_x) = minmax($min_x, $max_x, $stripe->{X_OFFSET}, $stripe->{X_OFFSET} + $width) ; | |||||||||
| 42 | 0 | ($min_y, $max_y) = minmax($min_y, $max_y, $stripe->{Y_OFFSET}, $stripe->{Y_OFFSET} + $height) ; | |||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 0 | return bless | |||||||||
| 46 | { | ||||||||||
| 47 | STRIPES => \@stripes, | ||||||||||
| 48 | EXTENTS => [$min_x, $max_x, $min_y, $max_y], | ||||||||||
| 49 | WIDTH => $total_width, | ||||||||||
| 50 | HEIGHT => $total_height, | ||||||||||
| 51 | }, __PACKAGE__ ; | ||||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | #--------------------------------------------------------------------------- | ||||||||||
| 55 | |||||||||||
| 56 | 265 | ▶ | sub get_stripes { my ($self) = @_ ; return $self->{STRIPES} ; } | ||||||||
|
Subroutine
get_stripes: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 57 | |||||||||||
| 58 | #----------------------------------------------------------------------------- | ||||||||||
| 59 | |||||||||||
| 60 | 0 | ▶ | sub get_size { my ($self) = @_ ; return($self->{WIDTH}, $self->{HEIGHT}) ; } | ||||||||
|
Subroutine
get_size: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 61 | |||||||||||
| 62 | #----------------------------------------------------------------------------- | ||||||||||
| 63 | |||||||||||
| 64 | 0 | ▶ | sub get_extents { my ($self) = @_ ; return($self->{EXTENTS}) ; } | ||||||||
|
Subroutine
get_extents: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 65 | |||||||||||
| 66 | #----------------------------------------------------------------------------- | ||||||||||
| 67 | |||||||||||
| 68 | 0 | ▶ | sub resize { my ($self, $reference_x, $reference_y, $new_x, $new_y) = @_ ; return(0, 0, $self->{WIDTH}, $self->{HEIGHT}) ; } | ||||||||
|
Subroutine
resize: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 69 | |||||||||||
| 70 | #----------------------------------------------------------------------------- | ||||||||||
| 71 | |||||||||||
| 72 | 0 | ▶ | sub get_action_menu_entries { ; } | ||||||||
|
Subroutine
get_action_menu_entries: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 73 | |||||||||||
| 74 | #----------------------------------------------------------------------------- | ||||||||||
| 75 | |||||||||||
| 76 | 0 | ▶ | sub get_selection_action { 'move' ; } | ||||||||
|
Subroutine
get_selection_action: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 77 | |||||||||||
| 78 | #----------------------------------------------------------------------------- | ||||||||||
| 79 | |||||||||||
| 80 | 0 | ▶ | sub get_colors { my ($self) = @_ ; return $self->{COLORS}{BACKGROUND}, $self->{COLORS}{FOREGROUND} ; } | ||||||||
|
Subroutine
get_colors: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 81 | |||||||||||
| 82 | #----------------------------------------------------------------------------- | ||||||||||
| 83 | |||||||||||
| 84 | 0 | ▶ | sub set_background_color { my ($self, $background_color) = @_ ; $self->{COLORS}{BACKGROUND} = $background_color ; } | ||||||||
|
Subroutine
set_background_color: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 85 | |||||||||||
| 86 | #----------------------------------------------------------------------------- | ||||||||||
| 87 | |||||||||||
| 88 | 0 | ▶ | sub set_foreground_color { my ($self, $foreground_color) = @_ ; $self->{COLORS}{FOREGROUND} = $foreground_color ; } | ||||||||
|
Subroutine
set_foreground_color: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 89 | |||||||||||
| 90 | #----------------------------------------------------------------------------- | ||||||||||
| 91 | |||||||||||
| 92 | sub set_colors | ||||||||||
| 93 | 0 | ▶ | { | ||||||||
|
Subroutine
set_colors: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 94 | 0 | my ($self, $background_color, $foreground_color) = @_ ; | |||||||||
| 95 | |||||||||||
| 96 | 0 | $self->{COLORS}{BACKGROUND} = $background_color ; | |||||||||
| 97 | 0 | $self->{COLORS}{FOREGROUND} = $foreground_color ; | |||||||||
| 98 | } | ||||||||||
| 99 | |||||||||||
| 100 | #----------------------------------------------------------------------------- | ||||||||||
| 101 | |||||||||||
| 102 | 0 | ▶ | sub get_text { ; } | ||||||||
|
Subroutine
get_text: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 103 | |||||||||||
| 104 | #----------------------------------------------------------------------------- | ||||||||||
| 105 | |||||||||||
| 106 | 0 | ▶ | sub set_text { ; } | ||||||||
|
Subroutine
set_text: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 107 | |||||||||||
| 108 | #----------------------------------------------------------------------------- | ||||||||||
| 109 | |||||||||||
| 110 | 0 | ▶ | sub edit { ; } | ||||||||
|
Subroutine
edit: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 111 | |||||||||||
| 112 | #----------------------------------------------------------------------------- | ||||||||||
| 113 | |||||||||||
| 114 | 0 | ▶ | sub match_connector { ; } | ||||||||
|
Subroutine
match_connector: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 115 | |||||||||||
| 116 | #----------------------------------------------------------------------------- | ||||||||||
| 117 | |||||||||||
| 118 | 0 | ▶ | sub get_connector_points { ; } | ||||||||
|
Subroutine
get_connector_points: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 119 | |||||||||||
| 120 | 0 | ▶ | sub get_connection_points { ; } | ||||||||
|
Subroutine
get_connection_points: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 121 | |||||||||||
| 122 | 0 | ▶ | sub get_extra_points { ; } | ||||||||
|
Subroutine
get_extra_points: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 123 | |||||||||||
| 124 | #----------------------------------------------------------------------------- | ||||||||||
| 125 | |||||||||||
| 126 | 0 | ▶ | sub get_named_connection { ; } | ||||||||
|
Subroutine
get_named_connection: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 127 | |||||||||||
| 128 | #----------------------------------------------------------------------------- | ||||||||||
| 129 | |||||||||||
| 130 | 0 | ▶ | sub move_connector { ; } | ||||||||
|
Subroutine
move_connector: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 131 | |||||||||||
| 132 | #----------------------------------------------------------------------------- | ||||||||||
| 133 | |||||||||||
| 134 | 0 | ▶ | sub allow_border_connection { ; } | ||||||||
|
Subroutine
allow_border_connection: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 135 | |||||||||||
| 136 | 0 | ▶ | sub is_border_connection_allowed { 0 } | ||||||||
|
Subroutine
is_border_connection_allowed: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 137 | |||||||||||
| 138 | #----------------------------------------------------------------------------- | ||||||||||
| 139 | |||||||||||
| 140 | 169 | ▶ | sub is_autoconnect_enabled { my ($self) = @_ ; return ! $self->{AUTOCONNECT_DISABLED} ; } | ||||||||
|
Subroutine
is_autoconnect_enabled: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 141 | |||||||||||
| 142 | 0 | ▶ | sub enable_autoconnect { my ($self, $enable) = @_ ; $self->{AUTOCONNECT_DISABLED} = !$enable ; } | ||||||||
|
Subroutine
enable_autoconnect: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 143 | |||||||||||
| 144 | #----------------------------------------------------------------------------- | ||||||||||
| 145 | |||||||||||
| 146 | 0 | ▶ | sub is_optimize_enabled { my ($self) = @_ ; return ! $self->{OPTIMIZE_DISABLED} ; } | ||||||||
|
Subroutine
is_optimize_enabled: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 147 | |||||||||||
| 148 | 0 | ▶ | sub enable_optimize { my ($self, $enable) = @_ ; $self->{OPTIMIZE_DISABLED} = !$enable ; } | ||||||||
|
Subroutine
enable_optimize: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 149 | |||||||||||
| 150 | #----------------------------------------------------------------------------- | ||||||||||
| 151 | |||||||||||
| 152 | sub set | ||||||||||
| 153 | 457 | ▶ | { | ||||||||
|
Subroutine
set: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 154 | # set fields in the hash | ||||||||||
| 155 | |||||||||||
| 156 | 457 | my ($self, %key_values) = @_ ; | |||||||||
| 157 | |||||||||||
| 158 | 457 | ▶ | while (my ($key, $value) = each %key_values) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 159 | { | ||||||||||
| 160 | 3153 | $self->{$key} = ${value} ; | |||||||||
| 161 | } | ||||||||||
| 162 | |||||||||||
| 163 | 457 | delete $self->{CACHE}; | |||||||||
| 164 | } | ||||||||||
| 165 | |||||||||||
| 166 | #----------------------------------------------------------------------------- | ||||||||||
| 167 | |||||||||||
| 168 | 3 | 1 ; | |||||||||