Articles
More
Links
This document describes site reconstruction need for converting simple ascii art text files to SVG/JPEG.
The ascii art is provided as simple text content. The AsciiArtGenerator reads this text files, builds internally a AsciiArtPad object. This object is used by the AsciiArtSVGGenerator to generate SVG. Finally the serializer svg2jpg - already available by Cocoon - is used to serialize the SVG content to JPEG.
The following figures shows the data flow of the ascii art processing components

An ascii art pad recognized following ascii characters
The figure above as ascii art text file, being the input of the above image.
| request
+--+------------+
| ascii.art.txt |
+--+------------+
|
| +----------------------+
| | AsciiArtSVGGenerator |
| +----------------------+
|
+--+------------+
| svg.xml |
+--+------------+
|
| +----------------------+
| | SVG2JPEGSerializer |
| +----------------------+
|
+--+------------+
| jpeg |
+--+------------+
| response
Adding the AsciiArtSVGGenerator is like adding any other Cocoon's generator.
First add the generator to generators section
<map:generator name="asciiart-svg"
src="org.apache.cocoon.generation.asciiart.\
AsciiArtSVGGenerator"
label="content"
logger="sitemap.generator.asciiart-svg"
/>
Moreover be sure that the svg2jpg serializer is defined
<map:serializer name="svg2jpeg"
src="org.apache.cocoon.serialization.SVGSerializer"
mime-type="image/jpeg">
<parameter name="quality" type="float" value="0.75"/>
</map:serializer>
Finally define under which condition the AsciiArtSVGGenerator shall be used
<map:match pattern="asciiart/*.jpg">
<map:generate type="asciiart-svg"
src="resources/asciiart/{1}.txt">
<map:parameter name="line-attribute"
value="stroke:black; stroke-width:1.5"/>
<map:parameter name="text-attribute"
value="font-size: 12;
font-family:Times Roman; fill:blue;"/>
</map:generate>
<map:serialize type="svg2jpeg"/>
</map:match>
The pipeline snippet above invokes the AsciiArtSVGGenerator
if a request of the form asciiart/*.jpg is requested. An
ascii text file from the context directory resources/asciiart
is feed in to the AsciiArtSVGGenerator, and serialized via
SVG to an JPEG image.
The sitemap parameter line-attribute, and text-attribute
are optional; you may want to use to adopt the SVG rendering to your
needs.
Hints
» Use Search to search all documents.
» Use Recreate Index to create the inital index.
This may be neccessary once at startup.
» Search and Recreate Index are available
at HTML Cocoon online deployment, only.
» Search and Recreate Index are not available
on WML online, WML offline, and HTML offline deployments.