1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Stu\Lib\Map\VisualPanel; |
6
|
|
|
|
7
|
|
|
use Stu\Lib\Map\VisualPanel\VisualPanelRow; |
8
|
|
|
use Stu\Module\Logging\LoggerUtilInterface; |
9
|
|
|
|
10
|
|
|
abstract class AbstractVisualPanel |
11
|
|
|
{ |
12
|
|
|
protected LoggerUtilInterface $loggerUtil; |
13
|
|
|
|
14
|
|
|
/** @var null|array<int, VisualPanelRow> */ |
15
|
|
|
private ?array $rows = null; |
16
|
|
|
|
17
|
|
|
/** @var null|array<int, VisualPanelRow> */ |
18
|
|
|
private ?array $extendedrows = null; |
19
|
|
|
|
20
|
|
|
/** @var null|array<array{value: int}> */ |
21
|
|
|
protected ?array $headRow = null; |
22
|
|
|
|
23
|
|
|
/** @var null|array<array{value: int}> */ |
24
|
|
|
protected ?array $extendedheadRow = null; |
25
|
|
|
|
26
|
|
|
private ?float $viewport = null; |
27
|
|
|
|
28
|
|
|
private ?string $viewportPerColumn = null; |
29
|
|
|
|
30
|
|
|
private ?string $viewportForFont = null; |
31
|
|
|
|
32
|
1 |
|
public function __construct( |
33
|
|
|
LoggerUtilInterface $loggerUtil |
34
|
|
|
) { |
35
|
1 |
|
$this->loggerUtil = $loggerUtil; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @return array<array{value: int}> |
40
|
|
|
*/ |
41
|
|
|
public abstract function getHeadRow(): array; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @return array<int, VisualPanelRow> |
45
|
|
|
*/ |
46
|
|
|
public function getRows(): array |
47
|
|
|
{ |
48
|
|
|
if ($this->rows === null) { |
49
|
|
|
$this->rows = $this->loadLSS(); |
50
|
|
|
} |
51
|
|
|
return $this->rows; |
|
|
|
|
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function getExtendedRows(): array |
55
|
|
|
{ |
56
|
|
|
if ($this->extendedrows === null) { |
57
|
|
|
$this->extendedrows = $this->loadExtendedLSS(); |
58
|
|
|
} |
59
|
|
|
return $this->extendedrows; |
|
|
|
|
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @return array<VisualPanelRow> |
65
|
|
|
*/ |
66
|
|
|
protected abstract function loadLSS(): array; |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return array<VisualPanelRow> |
70
|
|
|
*/ |
71
|
|
|
protected abstract function loadExtendedLSS(): array; |
72
|
|
|
|
73
|
|
|
protected abstract function getPanelViewportPercentage(): int; |
74
|
|
|
|
75
|
|
|
private function getViewport(): float |
76
|
|
|
{ |
77
|
|
|
if ($this->viewport === null) { |
78
|
|
|
$navPercentage = 100; |
79
|
|
|
$perColumn = $navPercentage / count($this->getHeadRow()); |
80
|
|
|
$this->viewport = min($perColumn, 1.7); |
81
|
|
|
} |
82
|
|
|
return $this->viewport; |
|
|
|
|
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function getViewportPerColumn(): string |
86
|
|
|
{ |
87
|
|
|
if ($this->viewportPerColumn === null) { |
88
|
|
|
$this->viewportPerColumn = number_format($this->getViewport(), 1); |
89
|
|
|
} |
90
|
|
|
return $this->viewportPerColumn; |
|
|
|
|
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function getViewportForFont(): string |
94
|
|
|
{ |
95
|
|
|
if ($this->viewportForFont === null) { |
96
|
|
|
$this->viewportForFont = number_format($this->getViewport() / 2, 1); |
97
|
|
|
} |
98
|
|
|
return $this->viewportForFont; |
|
|
|
|
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|