# AsciiArtSVGGenerator in Cocoon

0.9
Technical document

This document describes the AsciiArtSVGGenerator of Cocoon.

AsciiArtSVGGenerator

NAME | asciiart-svg
WHAT | The `AsciiArtSVGGenerator` component is used to serve ascii art text as SVGserve data.
TYPE | Generator, Sitemap Component
BLOCK | Block-Mail/Scratchpad
CLASS | org.apache.cocoon.generation.asciiart.AsciiArtSVGGenerator
SINCE | Cocoon 2.1
CACHEABLE | yes

Description

The `AsciiArtSVGGenerator` reads a plain ascii text document and generates SVG/XML SAX events.

Usage

The `AsciiArtSVGGenerator` can be used to serve figural information in a quick, and simple way.

The following snippet represents an ascii art which can be served by `AsciiArtSVGGenerator`

     +==============+
     |  Mail_Header |
     |  +========+  |
     |  | Body   |  |
     |  +==+==+==+  |
     |  |a |a |a |  |
     |  |1 |2 |3 |  |
     |  +==+==+==+  |
     +==============+

Storing this as `image/asciiart/mail.txt`, and using the matching snippet below, the mail ascii art can get embedded in your document as

    <p> Talking about mail ....</p>
    <figure alt="Mail Structure" src="image/asciiart/mail.png"/>

Sitemap pipeline examples

The snippet below matches URI of the format `image/asciiart/*.png`, and serves them from ascii art files from the directory `resources/asciiart/*.txt`.

    <map:match pattern="image/asciiart/*.png">
      <map:generate type="asciiart-svg"
        src="resources/asciiart/{1}.txt">
        <!-- option sitemap parameters -->
      </map:generate>
      <map:serialize type="svg2png"/>
    </map:match>

Sitemap component configuration example

The snippet below declares the `AsciiArtGenerator` in the sitmap components section.

    <map:generators...
      <map:generator name="asciiart-svg"
        src="org.apache.cocoon.generation.AsciiArtSVGGenerator"
        logger="sitemap.generator.asciiart-svg"
      />
        <!-- optional generator configuration -->
        ...
    </map:generators>
    ...

Configuration

The `AsciiArtGenerator` has no configurational options.

Setup

Setting up the `AsciiArtGenerator` is simply specifying the plain ascii text source.

Moreover following sitemap parameters are accepted

Parametername | Default | Comment
--- | --- | ---
line-attribute | stroke:black; stroke-width:1.5 | Style of generated SVG lines
text-attribute | font-size: 12; font-family:Times Roman; fill:blue; | Style of generated SVG text
x-grid | 10 | X Grid size
y-grid | 12 | Y Grid size

Effect on Object Model and Sitemap Parameters

The `AsciiArtGenerator` has no side effects on the objectModel, or other sitemap parameters.

Bugs/Caveats

The `AsciiArtGenerator` is a quick shot, and does not handle all characters visually consistently.

History

01-05-02: initial creation

See also

Read more information about SVG, and about SVG Serializer family.