+
+# Host visualization
+ my($max_Y)= 0;
+
+ my($index_fill)=0;
+ my($width_of_one_letter)=80;
+ my($min_x_for_host)=-400 - $max_string_length*$width_of_one_letter;
+ my($host_text_x)= $min_x_for_host + 200;
+
+ foreach $cat (keys %$Cat) {
+ next unless (defined($$Cat{$cat}{Y_min_host}) && defined($$Cat{$cat}{Y_max_host}));
+ my($line) = new XFig ('polyline');
+
+ $line->{'depth'} = 150;
+ $line->{'subtype'} = 1; # line
+ $line->{'points'} = [ [$min_x_for_host, $$Cat{$cat}{Y_min_host}*$grid_Y_size],
+ [$max_date*$grid_X_size+150, $$Cat{$cat}{Y_min_host}*$grid_Y_size],
+ [$max_date*$grid_X_size+150, $$Cat{$cat}{Y_max_host}*$grid_Y_size],
+ [$min_x_for_host, $$Cat{$cat}{Y_max_host}*$grid_Y_size] ];
+ $line->{'areafill'} = 4+3*($index_fill % 2);
+ $line->{'fillcolor'} = 0;
+ $line->{'thickness'} = 0;
+ $index_fill++;
+ $fig->add ($line);
+
+ my($text) = new XFig ('text');
+ $text->{'text'} = "$$Cat{$cat}{name}";
+ $text->{'angle'} = 3.14159265/2;
+ $text->{'x'} = $host_text_x;
+ $text->{'y'} = ($$Cat{$cat}{Y_min_host}+$$Cat{$cat}{Y_max_host})/2*$grid_Y_size;
+ $text->{'subtype'} = 1;
+ $text->{'font_size'} = 30;
+ $fig->add ($text);
+
+ if ($max_Y<$$Cat{$cat}{Y_max_host}) {
+ $max_Y = $$Cat{$cat}{Y_max_host};
+ }
+ }
+
+# Legend:
+ my($i)=1;
+ my($color);
+ foreach $color (@color_list) {
+ my($min_x)=0;
+ my($min_Y)=($max_Y+1)*$grid_Y_size;
+ my($width)=1700;
+ my($height)=$grid_Y_size;
+
+ my($line) = new XFig ('polyline');
+
+ $line->{'depth'} = 50;
+ $line->{'subtype'} = 1; # line
+ $line->{'points'} = [ [$min_x,$min_Y + ($i-1)*$height ],
+ [$min_x + $width,$min_Y + ($i-1)*$height],
+ [$min_x + $width,$min_Y+$height + ($i-1)*$height],
+ [$min_x,$min_Y+$height + ($i-1)*$height],
+ [$min_x,$min_Y+ ($i-1)*$height]];
+ $line->{'areafill'} = 20;
+ $line->{'fillcolor'} = $color;
+ $fig->add ($line);
+
+ my($text) = new XFig ('text');
+
+ if ($color==$color_suspended) {
+ $text->{'text'} = "Suspended";
+ }
+ if ($color==$color_compute) {
+ $text->{'text'} = "Computing";
+ }
+ if ($color==$color_wait_for_recpt) {
+ $text->{'text'} = "Waiting for reception";
+ }
+ if ($color==$color_communicate) {
+ $text->{'text'} = "Communicating";
+ }
+
+ $text->{'y'} = $min_Y + ($i-0.5)*$height +68;
+ $text->{'x'} = 50;
+ $text->{'subtype'} = 0;
+ $fig->add ($text);
+ $i++;
+ }
+
+# Time axis
+ my($line) = new XFig ('polyline');
+ $line->{'depth'} = 0;
+ $line->{'subtype'} = 1; # line
+ $line->{'points'} = [ [0,0],[$max_date * $grid_X_size+150,0] ];
+ $line->{'forwardarrow'} = ['1', '1', '1.00', '60.00', '120.00'];
+ $fig->add ($line);
+
+ my($digits)=POSIX::floor(log($max_date)/log(10));
+ my($exponent) = 10**$digits;
+ my($mantissa)= $max_date / $exponent;
+ my($incr);
+ if ($mantissa<2) {
+ $incr = $exponent/10;
+ } elsif ($mantissa<5) {
+ $incr = $exponent/4;
+ } else {
+ $incr = $exponent/2;
+ }
+
+ print "$max_date $digits $exponent $mantissa $incr\n";
+ my($x);
+ for($x=0; $x < $max_date; $x += $incr) {
+ print "$x\n";
+ $line = new XFig ('polyline');
+ $line->{'depth'} = 0;
+ $line->{'subtype'} = 1; # line
+ $line->{'points'} = [ [$x * $grid_X_size,0],[$x * $grid_X_size, -100] ];
+ $line->{'forwardarrow'} = 0;
+ $fig->add ($line);
+
+ my($text) = new XFig ('text');
+ $text->{'text'} = "$x";
+ $text->{'y'} = -200;
+ $text->{'x'} = $x * $grid_X_size;
+ $text->{'subtype'} = 1;
+ $fig->add ($text);
+ }
+
+# Empty line so that the text of the time axis can be seen on the pdf
+ $line = new XFig ('polyline');
+ $line->{'depth'} = 999;
+ $line->{'subtype'} = 1; # line
+ $line->{'thickness'} = 0;
+ $line->{'points'} = [ [0,0],[0, -400] ];
+ $fig->add ($line);