class ImageGeneratorClass(object): (source)
Known subclasses: zim.plugins.diagrameditor.DiagramGenerator
, zim.plugins.ditaaeditor.DitaaGenerator
, zim.plugins.equationeditor.EquationGenerator
, zim.plugins.gnu_r_ploteditor.GNURPlotGenerator
, zim.plugins.gnuplot_ploteditor.GnuplotGenerator
, zim.plugins.scoreeditor.ScoreGenerator
, zim.plugins.sequencediagrameditor.SequenceDiagramGenerator
Base class for image generators. A plugin defining an ImageGeneratorObjectType
should also define a sub-class of this class to do the actual work.
The generator does the actual work to generate an image from text. It does this in a temporary folder and must not try to directly modify the page or store anything in the attachements folder. The reason is that the user can still press "cancel" after the generator has run. The model takes care of storing the image and the text in the right place.
Since the content of the image can depent on the notebook location, a generator object is specific for a notebook page.
Method | __init__ |
Undocumented |
Method | check_user_input |
Check user input before generating image |
Method | cleanup |
Cleanup any temporary files that were created by this generator. Including log files and image files. |
Method | filter_source |
Filter contents of script file before displaying in textarea |
Method | generate_image |
Generate an image for a user input |
Method | get_default_text |
Provides a template or starting point for the user to begin editing. |
Instance Variable | notebook |
Undocumented |
Instance Variable | page |
Undocumented |
Instance Variable | plugin |
Undocumented |
zim.plugins.diagrameditor.DiagramGenerator
, zim.plugins.ditaaeditor.DitaaGenerator
, zim.plugins.equationeditor.EquationGenerator
, zim.plugins.gnu_r_ploteditor.GNURPlotGenerator
, zim.plugins.gnuplot_ploteditor.GnuplotGenerator
, zim.plugins.scoreeditor.ScoreGenerator
, zim.plugins.sequencediagrameditor.SequenceDiagramGenerator
Undocumented
zim.plugins.scoreeditor.ScoreGenerator
Check user input before generating image
This method is used to post-process user input before generating image and writing the user input into the script file.
Parameters | |
text | the source text as string - raw user input |
Returns | |
string used for generate_image, also the string written to script file. | |
Unknown Field: implementation | |
Not mandatory to be implemented by a subclass. It defaults to user input. |
zim.plugins.diagrameditor.DiagramGenerator
, zim.plugins.ditaaeditor.DitaaGenerator
, zim.plugins.equationeditor.EquationGenerator
, zim.plugins.gnu_r_ploteditor.GNURPlotGenerator
, zim.plugins.gnuplot_ploteditor.GnuplotGenerator
, zim.plugins.scoreeditor.ScoreGenerator
, zim.plugins.sequencediagrameditor.SequenceDiagramGenerator
Unknown Field: implementation | |
should be implemented by subclasses |
Filter contents of script file before displaying in textarea
This method is used to pre-process contents of script file before displaying in textarea.
Parameters | |
text | the contents of script file |
Returns | |
string used to display for user input. | |
Unknown Field: implementation | |
Not mandatory to be implemented by a subclass. It defaults to script file contents. |
zim.plugins.diagrameditor.DiagramGenerator
, zim.plugins.ditaaeditor.DitaaGenerator
, zim.plugins.equationeditor.EquationGenerator
, zim.plugins.gnu_r_ploteditor.GNURPlotGenerator
, zim.plugins.gnuplot_ploteditor.GnuplotGenerator
, zim.plugins.scoreeditor.ScoreGenerator
, zim.plugins.sequencediagrameditor.SequenceDiagramGenerator
Generate an image for a user input
This is the method that does the actual work to generate an image out of input text. Typically it will write the text to a temporary file using a template and then call an external program (e.g. latex) to create an image out of that source file. The result should be an image file and optionally a log file.
When the external program failed preferably this method should still return a log file, so the user can check the details of why the creation failed.
Parameters | |
text | the source text as string - raw user input |
Returns | |
a 2-tuple of the image file and the log file as File objects. If no image file was created the first element should be None, if no log file is created second element should be None. | |
Raises | |
Error | this method is allowed to raise errors like ApplicationError when running a command failed. |
Unknown Field: implementation | |
must be implemented by subclasses |