Exemple #1
0
 function arrow($im, $x1, $y1, $x2, $y2, $alength, $awidth, $color)
 {
     if ($alength > 1) {
         arrow($im, $x1, $y1, $x2, $y2, $alength - 1, $awidth - 1, $color);
     }
     $distance = sqrt(pow($x1 - $x2, 2) + pow($y1 - $y2, 2));
     $dx = $x2 + ($x1 - $x2) * $alength / $distance;
     $dy = $y2 + ($y1 - $y2) * $alength / $distance;
     $k = $awidth / $alength;
     $x2o = $x2 - $dx;
     $y2o = $dy - $y2;
     $x3 = $y2o * $k + $dx;
     $y3 = $x2o * $k + $dy;
     $x4 = $dx - $y2o * $k;
     $y4 = $dy - $x2o * $k;
     imageline($im, $x1, $y1, $dx, $dy, $color);
     imageline($im, $x3, $y3, $x4, $y4, $color);
     imageline($im, $x3, $y3, $x2, $y2, $color);
     imageline($im, $x2, $y2, $x4, $y4, $color);
 }
Exemple #2
0
    $angle = 0;
    $wordlengtharray = imagettfbbox($fontsize, 0, $font, $text);
    $wordlength = $wordlengtharray[4] - $wordlengtharray[6];
    $wordheigtharray = imagettfbbox($fontsize, 0, $font, $text);
    $wordheigth = $wordheightarray[7] - $wordheightarray[5];
    imagettftext($im, $fontsize, $angle, $x_cor - $wordlength / 2, $y_cor - $wordheigth / 2, $text_color, $font, $text);
    //	imagestring($im, 5, $x_cor-($width/2), $y_cor-($height/2), $text , $text_color);
}
//print arrows
$entries = $doc_complete->getElementsByTagName("Line");
foreach ($entries as $entry) {
    $start_x = intval($entry->getElementsByTagName("Graphics")->item(0)->getElementsByTagName("Point")->item(0)->getAttribute("x")) / 15;
    $start_y = intval($entry->getElementsByTagName("Graphics")->item(0)->getElementsByTagName("Point")->item(0)->getAttribute("y")) / 15;
    $stop_x = intval($entry->getElementsByTagName("Graphics")->item(0)->getElementsByTagName("Point")->item(1)->getAttribute("x")) / 15;
    $stop_y = intval($entry->getElementsByTagName("Graphics")->item(0)->getElementsByTagName("Point")->item(1)->getAttribute("y")) / 15;
    arrow($im, $start_x, $start_y, $stop_x, $stop_y, 3, 3, 1);
}
//Infobox
imagestring($im, 5, 500, 1, "Name: " . $doc_complete->getElementsByTagName("Pathway")->item(0)->getAttribute("Name"), $text_color);
imagestring($im, 5, 500, 15, "Author: " . $doc_complete->getElementsByTagName("Pathway")->item(0)->getAttribute("Author"), $text_color);
imagestring($im, 5, 500, 30, "Maintained by: " . $doc_complete->getElementsByTagName("Pathway")->item(0)->getAttribute("Maintained-By"), $text_color);
imagestring($im, 5, 500, 45, "Email: " . $doc_complete->getElementsByTagName("Pathway")->item(0)->getAttribute("Email"), $text_color);
imagestring($im, 5, 500, 60, "Availability: " . $doc_complete->getElementsByTagName("Pathway")->item(0)->getAttribute("Availability"), $text_color);
imagestring($im, 5, 500, 75, "Last Modified: " . $doc_complete->getElementsByTagName("Pathway")->item(0)->getAttribute("Last-Modified"), $text_color);
header("Content-type: image/png");
imagepng($im);
imagedestroy($im);
?>
 

Exemple #3
0
function arrow($im, $x1, $y1, $x2, $y2, $alength, $awidth, $color)
{
    $distance = sqrt(pow($x1 - $x2, 2) + pow($y1 - $y2, 2));
    if ($distance == 0) {
        $distance = 1;
    }
    $dx = $x2 + ($x1 - $x2) * $alength / $distance;
    $dy = $y2 + ($y1 - $y2) * $alength / $distance;
    $k = $awidth / $alength;
    $x2o = $x2 - $dx;
    $y2o = $dy - $y2;
    $x3 = $y2o * $k + $dx;
    $y3 = $x2o * $k + $dy;
    $x4 = $dx - $y2o * $k;
    $y4 = $dy - $x2o * $k;
    imageline($im, $x1, $y1, $dx, $dy, $color);
    imageline($im, $x3, $y3, $x4, $y4, $color);
    imageline($im, $x3, $y3, $x2, $y2, $color);
    imageline($im, $x2, $y2, $x4, $y4, $color);
}
foreach ($_SESSION['query']['data'] as $moteid => $moteinfo) {
    if (isset($_SESSION['query']['data'][$moteid][$lastResponseTime])) {
        $value = $_SESSION['query']['data'][$moteid][$lastResponseTime][$name];
        if (isset($motelist[$value])) {
            arrow($im, $motelist[$moteid]['x'] * $cellWidth + imagefontwidth($fontNum) * strlen("{$value}") / 2, $motelist[$moteid]['y'] * $cellHeight + $cellHeight / 2, $motelist[$value]['x'] * $cellWidth + imagefontwidth($fontNum) * strlen("{$value}") / 2, $motelist[$value]['y'] * $cellHeight + $cellHeight / 2, 10, 2, $black);
        }
    }
    imagestring($im, $fontNum, $motelist[$moteid]['x'] * (imagefontwidth($fontNum) * ($maxValueLen + 1)), $motelist[$moteid]['y'] * imagefontheight($fontNum), $moteid, $black);
    //  print "$moteid (" . $motelist[$moteid]['x'] . "," . $motelist[$moteid]['y'] . ")" . ": " . $_SESSION['query']['data'][$moteid][$lastResponseTime][$name] . " <br>";
}
imagepng($im);
Exemple #4
0
    $x3 = $y2o * $k + $dx;
    $y3 = $x2o * $k + $dy;
    $x4 = $dx - $y2o * $k;
    $y4 = $dy - $x2o * $k;
    $blue = imagecolorallocate($im, 0, 0, 255);
    imageline($im, $x1, $y1, $dx, $dy, $color);
    // draw a polygon
    $values = array($x3, $y3, $x4, $y4, $x2, $y2);
    imagefilledpolygon($im, $values, 3, 3);
}
$im = @imagecreate(1000, 500) or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 255, 255, 255);
$text_color = imagecolorallocate($im, 233, 14, 91);
$endx = 500;
$endy = 200;
$tan = $endy / $endx;
//imagestring($im, 10,10, 5,  rad2deg(atan($tan)), $text_color);
imagestring($im, 15, 15, 5, 5 / cos(atan($tan)), $text_color);
$point2_x = $endx + $tan * 5;
$point2_y = $endy - 5;
$point3_x = $endx - $tan * 5;
$point3_y = $endy + 5;
arrow($im, 0, 0, 500, 200, 3, 3, 3);
header("Content-type: image/png");
imagepng($im);
imagedestroy($im);
?>
 


Exemple #5
0
$deel_factor = 10;
$doc_complete = new DOMDocument();
$doc_complete->load('Hs_Fatty_Acid_Beta_Oxidation_1_BiGCaT.gpml');
$entry1 = $doc_complete->getElementsByTagName("Graphics");
$boardwidth = intval($entry1->item(0)->getAttribute("BoardWidth")) / $deel_factor;
$boardheight = intval($entry1->item(0)->getAttribute("BoardHeight")) / $deel_factor * 4;
$svg = fopen('test.svg', 'w+');
fwrite($svg, "<?xml version=\"1.0\" standalone=\"no\"?>\n\r\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 20001102//EN\"\n\r\n\t\"http://www.w3.org/TR/2000/CR-SVG-20001102/DTD/svg-20001102.dtd\" >\r\n<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\r\nversion=\"1.0\" width=\"{$boardheight}\" height=\"{$boardheight}\">\n\n");
//print arrows
$entries = $doc_complete->getElementsByTagName("Line");
foreach ($entries as $entry) {
    $start_x = intval($entry->getElementsByTagName("Graphics")->item(0)->getElementsByTagName("Point")->item(0)->getAttribute("x")) / $deel_factor;
    $start_y = intval($entry->getElementsByTagName("Graphics")->item(0)->getElementsByTagName("Point")->item(0)->getAttribute("y")) / $deel_factor;
    $stop_x = intval($entry->getElementsByTagName("Graphics")->item(0)->getElementsByTagName("Point")->item(1)->getAttribute("x")) / $deel_factor;
    $stop_y = intval($entry->getElementsByTagName("Graphics")->item(0)->getElementsByTagName("Point")->item(1)->getAttribute("y")) / $deel_factor;
    arrow($svg, $start_x, $start_y, $stop_x, $stop_y, 3, 3, 1);
}
//GeneProducts
$entries = $doc_complete->getElementsByTagName("GeneProduct");
foreach ($entries as $entry) {
    $y_cor = intval($entry->getElementsByTagName("Graphics")->item(0)->getAttribute("CenterY")) / $deel_factor;
    $x_cor = intval($entry->getElementsByTagName("Graphics")->item(0)->getAttribute("CenterX")) / $deel_factor;
    $width = intval($entry->getElementsByTagName("Graphics")->item(0)->getAttribute("Width")) / $deel_factor;
    $height = intval($entry->getElementsByTagName("Graphics")->item(0)->getAttribute("Height")) / $deel_factor;
    $x_cor = $x_cor - $width / 2;
    $y_cor = $y_cor - $height / 2;
    fwrite($svg, "<rect x=\"{$x_cor}\" y=\"{$y_cor}\" style=\"fill:rgb(255,255,255);stroke-width:1;\r\n\tstroke:rgb(0,0,0)\" width=\"{$width}\" height=\"{$height}\"/>\n\n");
    $y_cor = intval($entry->getElementsByTagName("Graphics")->item(0)->getAttribute("CenterY")) / $deel_factor;
    $x_cor = intval($entry->getElementsByTagName("Graphics")->item(0)->getAttribute("CenterX")) / $deel_factor;
    $font = "Century.ttf";
    $fontsize = 12;