Package chemaxon.util

Class ImageExportUtil


  • @PublicAPI
    public class ImageExportUtil
    extends Object
    Utility functions to create format parameter string for molecule export and for usage of .NET based EMF generator.
    Since:
    Marvin 5.2.1
    • Method Detail

      • createImageExporterParameter

        public static String createImageExporterParameter​(Properties settings,
                                                          String format,
                                                          MDocument doc)
        Creates the Image Exporter parameter String based on the values in the Properties object.
        Parameters:
        settings - see UserSettings or mergeProperties(UserSettings, MPropertyContainer, Rectangle)
        format - the format name used by MolExporter in the format string before the ":" sign
        doc - the MDocument from which the atom set information can be gathered.
        Returns:
        String formed as a proper ImageExporter parameter String
      • mergeProperties

        public static Properties mergeProperties​(UserSettings settings,
                                                 MPropertyContainer guiprops,
                                                 Rectangle r)
        Merge the properties of UserSettings with the GUI properties.
        If both has a value for a given key, the value stored in GUI properties will be used. The rectangle adds the width and height property to the returned Properties object, for image sizing.
        Parameters:
        settings - a UserSettings object
        guiprops - an MPropertyContainer object containing GUI properties
        r - the Rectangle which will determine the picture size in pixels.
        Returns:
        a Properties object merged from UserSettings and GUI properties, and extended with the size information. If any of the parameters are null, those values won't added to the result.
        See Also:
        MDocument.getGUIPropertyContainer(), MarvinPane.getUserSettings()
      • startEMFGenerator

        public static void startEMFGenerator()
        Starts the initialization of the .NET based EMF generator on a background thread. If the initialization has failed, disables the usage of the generator, in this case, the createEMF(String, String) method will return null.
      • disableNewEmfGenerator

        public static void disableNewEmfGenerator()
        Disables the new .NET based EMF generator.
      • createEMF

        public static byte[] createEMF​(String mrvSource,
                                       String exporterParamStr)
        Creates a .NET based EMF picture.
        Parameters:
        mrvSource - the molecule source
        exporterParamStr - the param string which should be applied to MolExporter.
        Returns:
        the EMF picture data as byte[]
      • generateEMFToFile

        public static boolean generateEMFToFile​(String mrvSource,
                                                String exporterParamStr,
                                                String fileName)
        Creates a new .NET based EMF picture and saves it to the given file.
        Parameters:
        mrvSource - the molecule source
        exporterParamStr - the param string which should be applied to MolExporter.
        fileName - the name of the file that should be saved.
        Returns:
        true on success, false otherwise
      • releaseNewEMFGenerator

        public static void releaseNewEMFGenerator()
        Releases and disposes native resources needed by the .NET based EMF generator. If the generator is under initialization, this method has to wait until the initialization is finished.