public static function path2array_paquet($_path, $lg1, $lg2, $mesure) { $array_lg = array($lg1, $lg2); sort($array_lg); $data = Tool_files::file_load($_path); $f = Tool_files::csv2array_line($data, "\n"); $array_paquet = array(); $tmp = array(); $flag_vu = false; foreach ($f as $line) { if (mb_eregi("[:alnum:]", $line)) { $tmp[] = trim($line); } elseif (len($tmp) > 0) { list($dist, $rep) = mb_split(" : ", $tmp[0]); list($score, $l1, $l2) = mb_split(" ", $rep); $score = trim($score); $dist = trim($dist); $l1 = trim($l1); $l2 = trim($l2); if ($dist == $mesure) { if ($l1 == $lg2 and $l2 == $lg1 or $lg1 == $l1 and $lg2 == $l2) { $flag_vu = true; list($str1, $rep1) = self::line2str_rep($tmp[1]); list($str2, $rep2) = self::line2str_rep($tmp[2]); $array_paquet[] = array('score' => $score, $l1 => $rep1, $l2 => $rep2, "str_{$l1}" => $str1, "str_{$l2}" => $str2); } } elseif ($flag_vu) { break; } $tmp = array(); } } return $array_paquet; }
} } } // print_r($array_corres); $margin_left = 10; $margin_top = 10; $x1 = $margin_top + 30; $y1 = 0 + $margin_left; $lg = 1000; $ecart = 300; $x2 = $x1 + $ecart; $y2 = $y1; $line1 = Tool_svg::space($y1, $x1, $lg); $line2 = Tool_svg::space($y2, $x2, $lg); //$inter1 = Tool_svg::inter($y1,$x1,$lg,$margin_left,$borne_min,$borne_max); $inter1 = Tool_svg::inter($y1, $x1, $lg, $margin_left, $borne_min, $borne_max); $inter2 = Tool_svg::inter($y2, $x2, $lg, $margin_left, 0, 1); $links = ""; $val_max = max($array_corres); foreach ($array_corres as $k2 => $nb_occ) { if ($val_max == 0) { $val = $ecart; } else { $val = $ecart - $nb_occ / $val_max * $ecart + $x1; } $links .= Tool_svg::barre($y1, $x1, $y2, $x2, $lg, $margin_left, $k2, $val); } $out_svg = "<svg version=\"1.1\"\n baseProfile=\"full\"\n xmlns=\"http://www.w3.org/2000/svg\">\n\n {$line1}\n {$line2}\n\n {$inter1}\n {$inter2}\n\n {$links}\n</svg>\n"; Tool_files::file_write($out_file, $out_svg); } //print $out_svg;