Package atessera.templ
Class MetapostTemplate
java.lang.Object
atessera.templ.MetapostTemplate
Velocity template for generating MetaPost figure source.
This class populates the metapost.vm template with the figure
drawing commands, producing a compilable MetaPost source file. The
resulting source can be compiled with
Metapost.
Typical usage:
MetapostTemplate t = new MetapostTemplate(factory);
t.setText(metapostCommands);
List<String> mpSource = t.renderToStringList();
- See Also:
-
BaseMetapost
-
Constructor Summary
ConstructorsConstructorDescriptionMetapostTemplate(EngineFactory engineFactory) Constructs a new MetaPost template. -
Method Summary
Modifier and TypeMethodDescriptionvoidMerges the context into the template and writes the result to the given writer.Renders the template and returns the result split into lines.Sets the MetaPost drawing commands.
-
Constructor Details
-
MetapostTemplate
Constructs a new MetaPost template.- Parameters:
engineFactory- the factory for obtaining a Velocity engine; must not benull- Throws:
org.apache.velocity.exception.ResourceNotFoundException- ifmetapost.vmcannot be loaded
-
-
Method Details
-
setText
Sets the MetaPost drawing commands.- Parameters:
text- the MetaPost source lines; may benullor empty- Returns:
- this template (for fluent chaining)
-
render
Merges the context into the template and writes the result to the given writer.- Parameters:
wr- the writer to receive the rendered output; must not benull
-
renderToStringList
Renders the template and returns the result split into lines.- Returns:
- the rendered output as a list of lines (trailing empty lines are preserved)
-