Class LatexPreProcessor

    • Method Detail

      • runFig2DevInTex

        private void runFig2DevInTex​(File figFile,
                                     LatexDev dev)
                              throws BuildFailureException
        From figFile create pdf/eps-file containing graphics without text with special flag set. The output format depends on dev. The resulting file is included in some tex-file created by runFig2TexInclDev(File). Conversion is done by Settings.getFig2devCommand().

        Logging: FIXME: EEX01, EEX02, EEX03, WEX04, WEX05

        Parameters:
        figFile - the fig-file to be processed
        dev - represents the target: either a pdf-file or an eps-file.
        Throws:
        BuildFailureException - FIXME: TEX01,
      • buildArgumentsFig2PdfEps

        private String[] buildArgumentsFig2PdfEps​(String language,
                                                  String optionsGen,
                                                  String optionsPdfEps,
                                                  File figFile,
                                                  File grpFile)
        Returns an array of options of the form -L <language> <optionsGen> <optionsPdfEps> xxx.fig xxx.pdf/xxx.eps for invocation of Settings.getFig2devCommand() for creation of the pdf/eps-part of a fig-figure as done in runFig2DevInTex(File, LatexDev).
        Parameters:
        language - is the output language which is either pdftex or pstex
        optionsGen - the general options, applying to both the pdf/eps part and the tex part of the figure under consideration.
        optionsPdfEps - the options, specific for the pdf/eps part (which is the same) of the figure under consideration.
        figFile - the fig-file to be transformed.
        grpFile - the graphics file (pdf/eps-file) which is the result of the transformation.
      • runFig2TexInclDev

        private void runFig2TexInclDev​(File figFile)
                                throws BuildFailureException
        From figFile create tex-file containing text with special flag set and including a graphic file containing the rest of figFile. Inclusion is without file extension and so both possible results of runFig2DevInTex(File, LatexDev) can be included when compiling with latex. Conversion is done by Settings.getFig2devCommand().

        Logging: FIXME: warning EEX01, EEX02, EEX03, WEX04, WEX05

        Parameters:
        figFile - the fig-file to be processed
        Throws:
        BuildFailureException - FIXME: TEX01,
      • buildArgumentsFig2Ptx

        private String[] buildArgumentsFig2Ptx​(String optionsGen,
                                               String optionsPtx,
                                               File figFile,
                                               File ptxFile)
        Returns an array of options of the form -L <language> <optionsGen> <optionsPdfEps> -p xxx xxx.fig xxx.ptx for invocation of Settings.getFig2devCommand() for creation of the tex-part of a fig-figure as done in runFig2TexInclDev(File). Note that the option -p xxx specifies the name of the pdf/eps-file included in the result file ptxFile without suffix.
        Parameters:
        optionsGen - the general options, applying to both the pdf/eps part and the tex part of the figure under consideration.
        optionsPtx - the options, specific for the tex part of the figure under consideration (for the ptx-file).
        figFile - the fig-file to be transformed.
        ptxFile - the ptx-file which is the result of the transformation.
      • clearTargetPtxPdfEps

        private void clearTargetPtxPdfEps​(File grpFile)
        Deletes the files xxx.ptx, xxx.pdf and xxx.eps created from the graphic file grpFile of the form xxx.y.

        Logging: EFU05: Failed to delete file

        Parameters:
        grpFile - a graphic file.
      • runGnuplot2Dev

        private void runGnuplot2Dev​(File gpFile)
                             throws BuildFailureException
        Converts a gnuplot-file into a tex-file with ending ptx including a pdf-file or an eps-file also created. To that end, invokes runGnuplot2Dev(File, LatexDev) twice to create a pdf-file and an eps-file and to create the tex-file which can include both.

        Logging:

        • EEX01, EEX02, EEX03, WEX04, WEX05: if running the ptx/pdf-conversion built-in in gnuplot fails.
        Parameters:
        gpFile - the gp-file (gnuplot format) to be converted to pdf and ptx.
        Throws:
        BuildFailureException - TEX01 if invocation of the ptx/pdf-conversion built-in in gnuplot fails.
        See Also:
        processGraphicsSelectMain(File, DirNode)
      • runMetapost2mps

        private void runMetapost2mps​(File mpFile)
                              throws BuildFailureException
        Runs mpost on mp-files to generate mps-files.

        Logging:

        • WFU03: cannot close log file
        • EAP01: Running command failed. For details...
        • EAP02: Running command failed. No log file
        • WAP04: if log file is not readable.
        • EEX01, EEX02, EEX03, WEX04, WEX05: if running the mpost command failed.
        Parameters:
        mpFile - the metapost file to be processed.
        Throws:
        BuildFailureException - TEX01 if invocation of the mpost command failed.
        See Also:
        processGraphicsSelectMain(File, DirNode)
      • clearTargetMp

        private void clearTargetMp​(File mpFile)
        Deletes the graphic files created from the metapost-file mpFile.

        Logging:

        • WFU01: Cannot read directory ...
        • EFU05: Failed to delete file
        Parameters:
        mpFile - a metapost file.
      • runSvg2Dev

        private void runSvg2Dev​(File svgFile)
                         throws BuildFailureException
        Converts an svg-file into a tex-file with ending ptx including a pdf-file or an eps-file also created. To that end, invokes runSvg2Dev(File, LatexDev, boolean) twice to create a pdf-file and an eps-file and to create the tex-file which can include both.

        Logging:

        • EEX01, EEX02, EEX03, WEX04, WEX05: if running the ptx/pdf-conversion built-in in svg2dev fails.
        • EFU06 if moving a file fails.
        Parameters:
        svgFile - the svg-file to be converted to a pdf-file and a ptx-file.
        Throws:
        BuildFailureException - TEX01 if invocation of the ptx/pdf-conversion built-in in svg2dev fails.
        See Also:
        processGraphicsSelectMain(File, DirNode)
      • buildNullArguments

        protected static String[] buildNullArguments​(String options,
                                                     File file)
        Returns an array of strings, where the 0th entry is null and a placeholder for option -x or -m when used by runEbb(File) and for the export option when used by runSvg2Dev(File, LatexDev, boolean) then follow the options from options and finally comes the name of file.
      • clearTargetJpgPng

        private void clearTargetJpgPng​(File file)
        Deletes the graphic files created from the svg-file svgFile.

        Logging: EFU05: Failed to delete file

      • deleteIfExists

        private void deleteIfExists​(File file,
                                    String suffix)

        Logging: EFU05: Failed to delete file

      • isLatexMainFile

        private boolean isLatexMainFile​(File texFile)
        Returns whether texFile is a latex main file, provided it is readable. Otherwise logs a warning and returns false.

        Logging:

        • WFU03: cannot close
        • WPP02: tex file may be latex main file
          Parameters:
          texFile - the tex-file to decide on whether it is a latex main file.
          Returns:
          whether texFile is definitively a latex main file. If this is not readable, false.
        • addIfLatexMain

          private void addIfLatexMain​(File texFile,
                                      Collection<File> latexMainFiles)
          If the tex-file texFile is a latex main file, add it to latexMainFiles.

          Logging:

          • WFU03: cannot close
          • WPP02: tex file may be latex main file
            Parameters:
            texFile - the tex-file to be added to latexMainFiles if it is a latex main file.
            latexMainFiles - the collection of latex main files found so far.
          • clearTargetTexIfLatexMain

            private void clearTargetTexIfLatexMain​(File texFile)
            Deletes the files created from the tex-file texFile, if that is a latex main file.

            Logging:

            • WPP02: tex file may be latex main file
            • WFU01: Cannot read directory...
            • WFU03: cannot close tex file
            • EFU05: Failed to delete file
            Parameters:
            texFile - the tex-file of which the created files shall be deleted if it is a latex main file.
          • processGraphicsSelectMain

            Collection<File> processGraphicsSelectMain​(File dir,
                                                       DirNode node)
                                                throws BuildFailureException
            Detects files in the directory represented by texNode and in subdirectories recursively:
            • those which are in various graphic formats incompatible with LaTeX are converted into formats which can be inputted or included directly into a latex file.
            • returns the set of latex main files.

            Logging:

            • WFU03: cannot close
            • WPP02: tex file may be latex main file
            • WPP03: Skipped processing of files with suffixes ...
            • EEX01, EEX02, EEX03, WEX04, WEX05: if running graphic processors failed.
            • EFU06: if moving a file fails.
            Parameters:
            dir - represents the tex source directory or a subdirectory.
            node - a node associated with dir.
            Returns:
            the collection of latex main files.
            Throws:
            BuildFailureException - TEX01 invoking processGraphicsSelectMain(File, DirNode, Collection, Collection)
          • clearCreated

            void clearCreated​(File texDir)
            Deletes all created files in the directory represented by texDir tracing subdirectories recursively. For details of deletions within a single directory see clearCreated(File, DirNode).

            Logging:

            • WPP02: tex file may be latex main file
            • WFU01: Cannot read directory...
            • WFU03: cannot close tex file
            • EFU05: Failed to delete file
            Parameters:
            texDir - represents the tex source directory or a subdirectory.
          • clearCreated

            private void clearCreated​(File dir,
                                      DirNode node)
            Deletes all created files in the directory represented by node, recursively. In each directory, the sub-directories are not deleted themselves but cleaned recursively. The other files are cleaned, i.e. their targets are deleted in an ordering reverse to creation proceeding in the following steps:
            • First the targets of the latex main files are deleted, whereas the targets of the graphic (source) files are just scheduled for deletion. For details see LatexPreProcessor.SuffixHandler.clearTarget(File, LatexPreProcessor, Map). FIXME: what about deletion of a graphic source file in this course?
            • Then the graphic source files scheduled are un-scheduled if deleted by some latex main file.
            • Finally, the targets of the graphic souce files are deleted. FIXME: what if this results in deletion of a graphic source file?
            Then the files with handler If a file has a prefix without handler, (see LatexPreProcessor.SuffixHandler.getSuffix()) it is ignored. Else its target is cleared as described in LatexPreProcessor.SuffixHandler.clearTarget(File, LatexPreProcessor, Map).

            Logging:

            • WPP02: tex file may be latex main file
            • WFU01: Cannot read directory...
            • WFU03: cannot close tex file
            • EFU05: Failed to delete file
            Parameters:
            dir - represents the tex source directory or a subdirectory.
            node - a node associated with dir.