chemaxon.util
Class ImageExportUtil

java.lang.Object
  extended by chemaxon.util.ImageExportUtil

public class ImageExportUtil
extends java.lang.Object

Utility functions to create format parameter string for molecule export and for usage of .NET based EMF generator.

Since:
Marvin 5.2.1
Version:
Marvin 5.3 11/25/2009
Author:
Istvan Fajth

Method Summary
static byte[] createEMF(java.lang.String mrvSource, java.lang.String exporterParamStr)
          Creates a .NET based EMF picture.
static java.lang.String createImageExporterParameter(java.util.Properties settings, java.lang.String format, MDocument doc)
          Creates the Image Exporter parameter String based on the values in the Properties object.
static void disableNewEmfGenerator()
          Disables the new .NET based EMF generator.
static boolean generateEMFToFile(java.lang.String mrvSource, java.lang.String exporterParamStr, java.lang.String fileName)
          Creates a new .NET based EMF picture and saves it to the given file.
static java.util.Properties mergeProperties(UserSettings settings, MPropertyContainer guiprops, java.awt.Rectangle r)
          Merge the properties of UserSettings with the GUI properties.
static void releaseNewEMFGenerator()
          Releases and disposes native resources needed by the .NET based EMF generator.
static void startEMFGenerator()
          Starts the initialization of the .NET based EMF generator on a background thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createImageExporterParameter

public static java.lang.String createImageExporterParameter(java.util.Properties settings,
                                                            java.lang.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 java.util.Properties mergeProperties(UserSettings settings,
                                                   MPropertyContainer guiprops,
                                                   java.awt.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(java.lang.String mrvSource,
                               java.lang.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(java.lang.String mrvSource,
                                        java.lang.String exporterParamStr,
                                        java.lang.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.