commsfwtools/commstools/svg/relations.pl
branchRCL_3
changeset 29 9644881fedd0
parent 0 dfb7c4ff071f
equal deleted inserted replaced
28:9ddb1d67ebaf 29:9644881fedd0
   152 
   152 
   153 # minor aesthetic adjustments to the spacing between the end of a Tab line and its Labels
   153 # minor aesthetic adjustments to the spacing between the end of a Tab line and its Labels
   154 my $tabToFontAdjustTopY = 2;
   154 my $tabToFontAdjustTopY = 2;
   155 my $tabToFontAdjustBottomY = 1;
   155 my $tabToFontAdjustBottomY = 1;
   156 my $tabLineLengthY = 5;
   156 my $tabLineLengthY = 5;
   157 
   157 my $outputPath = "";		# output path as specified by "-o <path>" argument
   158 our($opt_x,$opt_v,$opt_V);
   158 our($opt_x,$opt_v,$opt_V, $opt_o);
   159 Getopts("x:vV");
   159 Getopts("x:vVo:");
       
   160 
       
   161 $outputPath = processPathArgument($opt_o);
       
   162 
   160 readRelationshipFile();
   163 readRelationshipFile();
   161 
   164 
   162 print "Reading sequences\n" if ($opt_V);
   165 print "Reading sequences\n" if ($opt_V);
   163 readSequences();
   166 readSequences();
   164 #printGroupRanges();
   167 #printGroupRanges();
   223 outputDocFooter();
   226 outputDocFooter();
   224 closeOutputFile();
   227 closeOutputFile();
   225 outputRelationsHTMLEmbedder($width, $height);
   228 outputRelationsHTMLEmbedder($width, $height);
   226 
   229 
   227 sub createOutputFile()
   230 sub createOutputFile()
   228 	{
   231 {
   229 		open SVG, ">relations.svg" || die "Cannot open relations.svg for writing\n";
   232 	# Have already created the directory $outputPath, just create the "html" subdirectory
   230 	}
   233 	my $path = $outputPath . "html";
       
   234 	if (! -d $path) {
       
   235 		mkdir $path;
       
   236 	}
       
   237 	$path .= "/relations.svg";
       
   238 	open SVG, ">$path" || die "Cannot open $path for writing\n";
       
   239 }
   231 
   240 
   232 sub closeOutputFile()
   241 sub closeOutputFile()
   233 	{
   242 	{
   234 		close SVG;
   243 		close SVG;
   235 	}
   244 	}
   833 	}
   842 	}
   834 
   843 
   835 sub outputRelationsHTMLEmbedder($$)
   844 sub outputRelationsHTMLEmbedder($$)
   836 	{
   845 	{
   837 	my ($width,$height) = @_;
   846 	my ($width,$height) = @_;
   838 	open HTML, ">relations.html" || die "Cannot open relations.html for writing\n";
   847 	# Should have already created $outputPath/html directory.
       
   848 	my $path = $outputPath . "html/relations.html";
       
   849 	open HTML, ">$path" || die "Cannot open $path for writing\n";
   839 	print HTML qq{<html>\n<body onLoad="resize()">\n};
   850 	print HTML qq{<html>\n<body onLoad="resize()">\n};
   840 	print HTML qq{<embed src="relations.svg" width="$width" height="$height" type="image/svg+xml" pluginspage="http://www.adobe.com/svg/viewer/install/" name="embedder">\n};
   851 	print HTML qq{<embed src="relations.svg" width="$width" height="$height" type="image/svg+xml" pluginspage="http://www.adobe.com/svg/viewer/install/" name="embedder">\n};
   841 	print HTML qq{<input type="button" value="Animate..." onclick="popupAnimate()">\n};
   852 	print HTML qq{<input type="button" value="Animate..." onclick="popupAnimate()">\n};
   842 	print HTML qq{<script type="text/javascript">\n};
   853 	print HTML qq{<script type="text/javascript">\n};
   843 	print HTML "var relationsWidth = $width;\n";
   854 	print HTML "var relationsWidth = $width;\n";
   873 #
   884 #
   874 # Output the "animate.html" file that creates the animate "control panel" popup
   885 # Output the "animate.html" file that creates the animate "control panel" popup
   875 #
   886 #
   876 sub outputAnimateHTML()
   887 sub outputAnimateHTML()
   877 {
   888 {
   878 	open HTML, ">animate.html" || die "Cannot open animate.html for writing\n";
   889 	# Should have already created $outputPath directory, create html/ subdirectory.
       
   890 	my $path = $outputPath . "html";
       
   891 	if (! -d $path) {
       
   892 		mkdir $path;
       
   893 	}
       
   894 	$path .= "/animate.html";
       
   895 	open HTML, ">$path" || die "Cannot open $path for writing\n";
   879 #################################
   896 #################################
   880 #  Begin Interpolated Text...   #
   897 #  Begin Interpolated Text...   #
   881 #################################
   898 #################################
   882 	print HTML<<'EOT'
   899 	print HTML<<'EOT'
   883 <html>
   900 <html>
  2094 
  2111 
  2095 sub AnimateSequencerPart2()
  2112 sub AnimateSequencerPart2()
  2096 {
  2113 {
  2097 	print SVG ");\n\n";
  2114 	print SVG ");\n\n";
  2098 }
  2115 }
       
  2116 
       
  2117 sub processPathArgument($)
       
  2118 {
       
  2119 	my $path = $_[0];
       
  2120 	if ($path) {
       
  2121 		# ensure "/" at the end
       
  2122 		if ($path !~ /\/$/) {
       
  2123 			$path .= "/";
       
  2124 		}
       
  2125 		mkdirp($path);
       
  2126 		return $path;
       
  2127 	} else {
       
  2128 		return "";
       
  2129 	}
       
  2130 }
       
  2131 
       
  2132 sub mkdirp($) 
       
  2133 { 
       
  2134     my $dirName = @_[0]; 
       
  2135     if ($dirName =~ m/^(.*)\//i) { 
       
  2136         if ($1 ne "") { 
       
  2137             mkdirp($1); 
       
  2138         } 
       
  2139     }
       
  2140 	if (! -d $dirName) {
       
  2141 		mkdir($dirName); 
       
  2142 	}
       
  2143 }