first guess modulgrafik has to be improved

This commit is contained in:
Harald Bamberger
2024-09-25 17:32:45 +02:00
parent ff539568c2
commit 6bbc09442c
2 changed files with 81 additions and 9 deletions
@@ -11,10 +11,15 @@ class ModulgrafikTest extends JOB_Controller
const DEFAULT_XOFFSET = 40;
const DEFAULT_YOFFSET = 30;
const DEFAULT_WIDTH = 160;
const DEFAULT_SEMESTER_LABEL_WIDTH = 80;
const DEFAULT_ECTS_WIDTH = 40;
const DEFAULT_HEIGHT = 50;
const DEFAULT_SPACING = 40;
const DEFAULT_FONTSIZE = 8;
protected $curx;
protected $cury;
public function __construct()
{
parent::__construct();
@@ -101,6 +106,7 @@ EOSQL;
}
}
echo "<!--\n\n";
foreach($semester as $sem => $mods)
{
echo $sem . ". Semester: \n";
@@ -111,18 +117,14 @@ EOSQL;
printchilds($mod->childs, $level . "\t");
}
}
exit();
echo "-->\n\n";
if(count($errors) === 0) {
$this->DrawIoLib->renderFileStart();
foreach($roots AS &$root)
{
$this->maxxoffset = self::DEFAULT_XOFFSET;
$this->DrawIoLib->renderDiagramStart($studienplan_id, 'Modulgrafik');
$this->renderSemester($semster);
$this->DrawIoLib->renderDiagramEnd();
}
$this->maxxoffset = self::DEFAULT_XOFFSET;
$this->DrawIoLib->renderDiagramStart($studienplan_id, 'Modulgrafik');
$this->renderSemester($semester);
$this->DrawIoLib->renderDiagramEnd();
$this->DrawIoLib->renderFileEnd();
}
else
@@ -138,4 +140,30 @@ EOSQL;
echo "Keine LVs gefunden.\n";
}
}
protected function renderSemester($semester)
{
$cury = self::DEFAULT_YOFFSET;
foreach($semester as $sem => $mods)
{
$curx = self::DEFAULT_XOFFSET;
$id = uniqid();
$ects = 30; //TODO calc
$this->DrawIoLib->renderSemesterLabel($id, $sem, $ects, self::DEFAULT_XOFFSET, $cury, self::DEFAULT_SEMESTER_LABEL_WIDTH, self::DEFAULT_HEIGHT);
$curx += self::DEFAULT_SEMESTER_LABEL_WIDTH + self::DEFAULT_SPACING;
$maxmodulheight = 0;
foreach($mods as $mod)
{
$modid = uniqid();
$size = $this->DrawIoLib->renderModulList($modid, $mod, $curx, $cury, self::DEFAULT_ECTS_WIDTH, self::DEFAULT_HEIGHT);
$curx += $size->width + self::DEFAULT_SPACING;
if( $size->height > $maxmodulheight)
{
$maxmodulheight = $size->height;
}
}
$cury += $maxmodulheight + self::DEFAULT_SPACING;
}
}
}
+44
View File
@@ -108,4 +108,48 @@ EDGEPOINTS;
EDGE;
}
public function renderSemesterLabel($id, $sem, $ects, $x, $y, $width, $height)
{
echo <<<EOTEXT
<mxCell id="{$id}" value="&lt;b&gt;{$sem}. Semester&lt;br&gt;&lt;/b&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;background-color: initial;&quot;&gt;{$ects} ECTS&lt;/span&gt;&lt;/div&gt;" style="text;html=1;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="{$x}" y="{$y}" width="{$width}" height="{$height}" as="geometry" />
</mxCell>
EOTEXT;
}
public function renderModulList($listid, $mod, $x, $y, $ects_width, $lv_height)
{
$width = ceil($mod->ects * $ects_width);
$height = (count($mod->childs) + 1) * $lv_height;
$modul_ects = (int) $mod->ects;
echo <<<EOLIST
<mxCell id="{$listid}" value="{$mod->bezeichnung} ({$modul_ects})" style="swimlane;fontStyle=0;childLayout=stackLayout;horizontal=1;startSize={$lv_height};horizontalStack=0;resizeParent=1;resizeParentMax=0;resizeLast=0;collapsible=0;marginBottom=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="{$x}" y="{$y}" width="{$width}" height="{$height}" as="geometry">
<mxRectangle x="{$x}" y="{$y}" width="{$width}" height="{$height}" as="alternateBounds" />
</mxGeometry>
</mxCell>
EOLIST;
$childnumber = 0;
foreach ($mod->childs as $child)
{
$childnumber++;
$childid = uniqid();
$childheight = $childnumber * $lv_height;
$child_ects = (int) $child->ects;
echo <<<EOLISTITEM
<mxCell id="{$childid}" value="{$child->bezeichnung} ({$child_ects})" style="text;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;spacingLeft=4;spacingRight=4;overflow=hidden;points=[[0,0.5],[1,0.5]];portConstraint=eastwest;rotatable=0;whiteSpace=wrap;html=1;" vertex="1" parent="{$listid}">
<mxGeometry y="{$childheight}" width="{$width}" height="{$lv_height}" as="geometry" />
</mxCell>
EOLISTITEM;
}
return (object) array(
'width' => $width,
'height' => $height
);
}
}