function print_class(Class_Prog $class, $assoc) { $class->with('children,parents,members,methods,package'); $id = $this->class_id($class->id_class); $ns = $this->package_id($class->id_package); $pecialization = ""; foreach ($class->children as $child) { $pecialization .= " " . $this->generalization_id($class->id_class, $child->id_class); } $generalization = ""; foreach ($class->parents as $parent) { $generalization .= " " . $this->generalization_id($parent->id_class, $class->id_class); } $this->open_uml_element($class->type == 'interface' ? 'Interface' : 'Class', $id, $class->name, $ns, array('specialization' => $pecialization, 'generalization' => $generalization, 'isActive' => "false", 'isAbstract' => $class->type == 'class' ? 'false' : 'true')); $this->open_uml_simple_element('Classifier.feature'); foreach ($class->members as $attribute) { $this->attribute($attribute, $assoc); } foreach ($class->methods as $method) { $this->method($method); } $this->close_element(); $this->close_element(); foreach ($class->parents as $parent) { $idg = $this->generalization_id($parent->id_class, $class->id_class); $this->uml_empty_element('Generalization', $idg, "", $ns, array('child' => $id, 'parent' => $this->class_id($parent->id_class))); } }
function display_class(Class_Prog $class, TableCreator $table_creator) { $txt = ""; if (!$class->library) { $id = $class->full_name(); $name = $class->full_name(" :: "); $txt .= $table_creator->anchor($id, '') . "\n"; $txt .= $table_creator->title(4, $name, $class->name); $txt .= $table_creator->begin_desc_list(); $txt .= $table_creator->desc_list_item('Descrizione', $class->description); if (strlen(trim($class->usage)) > 0) { $txt .= $table_creator->desc_list_item('Utilizzo', $class->usage); } $class->with('children', 'parents'); if (count($class->parents)) { $inh_txt = ''; $inh_txt .= "\\vspace{-7mm}\n"; $inh_txt .= $table_creator->begin_list(); foreach ($class->parents as $par) { if (!$par->library) { $inh_txt .= $table_creator->list_item($table_creator->link($par->full_name(), $par->full_name(" :: "))); } else { $inh_txt .= $table_creator->list_item($par->full_name()); } } $inh_txt .= $table_creator->end_list(); $txt .= $table_creator->desc_list_item('Classi ereditate', $inh_txt); } if (count($class->children)) { $inh_txt = ''; $inh_txt .= "\\vspace{-7mm}\n"; $inh_txt .= $table_creator->begin_list(); foreach ($class->children as $par) { $inh_txt .= $table_creator->list_item($table_creator->link($par->full_name(), $par->full_name(" :: "))); } $inh_txt .= $table_creator->end_list(); $txt .= $table_creator->desc_list_item('Classi figlie', $inh_txt); } $ass = Association::model()->findAll('class_from = :idc or class_to = :idc', array(':idc' => $class->id_class)); if (count($ass)) { $rel = ''; $rel .= "\\vspace{-7mm}\n"; $rel .= $table_creator->begin_desc_list(); foreach ($ass as $ss) { if ($ss->class_to != $class->id_class) { $par = $ss->with('classTo')->classTo; $ass_dir = "uscente"; } else { if ($ss->class_from != $class->id_class) { $par = $ss->with('classFrom')->classFrom; $ass_dir = "entrante"; } else { continue; } } $ss->with('attribute'); if (!$par->library) { $acn = $par->full_name(); if (strlen($acn) > 60) { $acn = substr($acn, strlen($acn) - 60); $acn = "..." . substr($acn, strpos($acn, "::") + 2); } $ass_name = $table_creator->link($par->full_name(), $acn); } else { $ass_name = $par->full_name(); } $ass_txt = "Relazione {$ass_dir}, " . lcfirst($ss->attribute->description); $rel .= $table_creator->desc_list_item($ass_name, $ass_txt); } $rel .= $table_creator->end_desc_list(); $txt .= $table_creator->desc_list_item('Relazioni con altre classi', $rel); } } $txt .= $table_creator->end_desc_list(); $txt .= "\n\\vspace{0.5cm}\n"; return $txt; }
function display_class(Class_Prog $class, TableCreator $table_creator) { $string = ""; $id = $class->full_name(); $string .= $table_creator->anchor($id, '') . "\n"; $string .= $table_creator->title(3, $class->name . " ({$class->type})"); $string .= "\n \\begin{figure}[H]\n \\centering\n \\scalegraphics{img/classi/{$class->name}}\n \\caption{Classe {$class->name}}\\label{fig:{$id}} \n \\end{figure}\n "; $string .= "\\begin{description}\n \\item[Descrizione] \\hfill \\\\\n "; $string .= $class->description; $string .= "\n \\item[Utilizzo] \\hfill \\\\\n "; $string .= $class->usage; $class->with('children', 'parents'); if (count($class->parents)) { $string .= "\n\t \\item[Classi ereditate] \\hfill\n "; $string .= $table_creator->begin_list(); foreach ($class->parents as $par) { if (!$par->library) { $string .= $table_creator->list_item($table_creator->link($par->full_name(), $par->full_name(" :: "))); } else { $string .= $table_creator->list_item($par->full_name()); } } $string .= $table_creator->end_list(); } if (count($class->children)) { $string .= "\n\t \\item[Ereditata da] \\hfill\n "; $string .= $table_creator->begin_list(); foreach ($class->children as $par) { $string .= $table_creator->list_item($table_creator->link($par->full_name(), $par->full_name(" :: "))); } $string .= $table_creator->end_list(); } if (!empty($class->attributes0)) { $string .= "\n\t \\item[Attributi] \\hfill\n\t \\begin{description}\n\t "; //$string .= $table_creator->begin_desc_list(); foreach ($class->attributes0 as $attribute) { $string .= display_attribute($attribute, $table_creator); } //$string .= $table_creator->end_desc_list(); $string .= "\n\t \\end{description}\n "; } if (!empty($class->methods)) { $string .= "\n\t \\item[Metodi] \\hfill\n\t \\begin{description}\n "; //$string .= $table_creator->begin_desc_list(); foreach ($class->methods as $meth) { $string .= display_method($meth, $table_creator); } //$string .= $table_creator->end_desc_list(); $string .= "\n\t \\end{description}\n "; } $string .= "\n \\end{description}\n "; return $string; }