Chemistry-Artificial-Graphics

 view release on metacpan or  search on metacpan

lib/Chemistry/Artificial/Graphics.pm  view on Meta::CPAN

 orient="270">
 <path d="M0,0 L10,5 L0,10 z"/>
</marker>


</defs>'."\n";
print svgfile $function2;
close (svgfile);
}

=item $graph->write_circle(x, y, id, color, smilestring, child, formula,
reaction, reaction_type, atommap, elembefore)

This function writes a component in the graph.

	The properties:
	* id: This is an unique id for one component in the graph.
	* cx: X position.

This function should be called from the inside of the module, not being 
recomended to call it from an external applicattion.

=cut

sub write_circle
{	
my $self = shift;
my ($x,$y,$id,$color,$smilestring,$child,$formula,$reaction,$reaction_type,
$atommap,$elembefore)=@_;
open (svgfile,">>$self->{file}") or die("Couldn't open File\n");
print svgfile '<circle id="c'. $id .'" onclick="showContentAndRelatives(evt)" 
cx="'. $x. '" cy="' .$y. '" r="20" stroke="'.$color.'" 
smilestring="'. $smilestring .'" child="'. $child.'" formula="'. $formula.'" 
reaction="'. $reaction.'" reactiontype="'. 
$reaction_type.'" atommap="'. $atommap.'" elembefore="'. $elembefore.'"  
style="fill:url(#mygradient1)" stroke-with="1"/>' ."\n";
close (svgfile);
}

=item $graph->write_text(text, x, y, id)

Function used to write a text line in the SVG.

lib/Chemistry/Artificial/Graphics.pm  view on Meta::CPAN

   group.appendChild(textsmiles)
   //Create a text child
   y = y+10;
   var childtext=document.createElementNS(svgNS,"text");
   childtext.setAttribute("x",x);	childtext.setAttribute("y",y);
   childtext.setAttribute("id","ch"+level);
   childtext.setAttribute("style","text-anchor:right;font-size:12;font-family:Arial;fill:blue");
   childstring = circle.getAttribute("child");	
   childtext.appendChild(document.createTextNode("Child Number: "+childstring));
   group.appendChild(childtext);
   //Create a text formula
   y = y+10;
   var ftext=document.createElementNS(svgNS,"text");
   ftext.setAttribute("x",x);ftext.setAttribute("y",y);
   ftext.setAttribute("id","f"+level);
   ftext.setAttribute("style","text-anchor:right;font-size:12;font-family:Arial;fill:blue");
   formulastring = circle.getAttribute("formula");	
   ftext.appendChild(document.createTextNode("Formula: "+formulastring));
   group.appendChild(ftext);
   //Create a text reaction
   y = y+10;
   var rtext=document.createElementNS(svgNS,"text");
   rtext.setAttribute("x",x);rtext.setAttribute("y",y);
   rtext.setAttribute("id","r"+level);
   rtext.setAttribute("style","text-anchor:right;font-size:12;font-family:Arial;fill:blue");
   reactionstring = circle.getAttribute("reaction");
   rtypestring = circle.getAttribute("reactiontype");	
   rtext.appendChild(document.createTextNode("Reaction: "+reactionstring +"("+rtypestring+")"));	

lib/Chemistry/Artificial/Graphics.pm  view on Meta::CPAN

=cut

sub write_bottom_static
{	
my $self=shift;
open (svgfile,">>$self->{file}") or die("Couldn't open File\n");
print svgfile "</svg>\n";
close (svgfile);
}

=item $graph->write_circle_static(x, y, id, color, smilestring, child, formula,
reaction, reaction_type, atommap, elembefore)

This function writes a component in the graph.

	The properties:
	* id: This is an unique id for one component in the graph.
	* cx: X position.

This function should be called from the inside of the module, not being 
recomended to call it from an external applicattion.

=cut

sub write_circle_static
{	
my $self = shift;
my ($x,$y,$id,$color,$smilestring,$child,$formula,$reaction,$reaction_type,
$atommap,$elembefore)=@_;
open (svgfile,">>$self->{file}") or die("Couldn't open File\n");
print svgfile '<circle id="c'. $id .'" cx="'. $x. '" cy="' .$y. '" r="20" 
stroke="'.$color.'" smilestring="'. $smilestring .'" child="'. $child.'"
 formula="'. $formula.'" reaction="'. $reaction.'" reactiontype="'. 
$reaction_type.'" atommap="'. $atommap.'" elembefore="'. $elembefore.'"  
style="fill:url(#mygradient1)" stroke-with="1"/>' ."\n";
close (svgfile);
}

=item $graph->recursive_ch_static(x, y, root)

Represents a SVG static file with the solution in the solution graphic table.

How does it works:



( run in 0.762 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )