Interface IDocumentWriter


@PublicAPI public interface IDocumentWriter
The IDocumentWriter interface gives the functionality to write/update documents with Chemical Structures.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Adds the molecule structure to the end of the document without it's properties
    void
    addStructure(IMoleculeData molecule, ISettings settings)
    Adds the molecule structure to the the document with the given settings without properties
    void
    Adds the molecule structure and all corresponding properties to the document with the give settings
    void
    Adds the array of molecule structures and their corresponding properties to the end of the document.
    void
    addStructures(IMoleculeData[] molecules, ISettings settings)
    Adds the array of molecule structures and their corresponding properties to the location given in the settings.
    void
    addStructures(IMoleculeData[] molecules, ISettings settings, int structurePerPage)
    Adds the array of molecule structures and their corresponding properties to the document with the give settings
    Adds the table custom table to the and of the Document
    void
    Closes the office Document stream.
    createTableModel(int rowCount, int columnCount)
    Creates a custom table for the structure data
    Returns the next writable position at the end of the Document
    void
    load(InputStream stream, int structurePerPage)
    Loads the molecule structure(s) and their corresponding properties from the given input stream into the end of the document.
    void
    load(InputStream stream, ISettings settings, int structurePerPage)
    Loads the molecule structure(s) and their corresponding properties from the given input stream into the location given in the settings.
    void
    load(String filePath, int structurePerPage)
    Loads the molecule structure(s) and their corresponding properties from the given file into the end of the document.
    void
    load(String filePath, ISettings settings, int structurePerPage)
    Loads the molecule structure(s) and their corresponding properties from the given file into the document to the location given in the settings.
  • Method Details

    • addStructure

      void addStructure(IMoleculeData molecule) throws MolFormatException, IOException
      Adds the molecule structure to the end of the document without it's properties

      The following is one example of the use of the addStructure. The code:

       IDocumentWriter writer = DocumentHandlerFactory.createDocumentWriter(DocumentType.PPT, testFile.getPath());
       MoleculeData moleculeData = new MoleculeData("c1ccccc1", "smiles", "CD-001");
       writer.addStructure(moleculeData);
       
      Parameters:
      molecule - - IMoleculeData what should be written to the end of the edited document
      Throws:
      MolFormatException
      IOException
    • addStructure

      void addStructure(IMoleculeData molecule, ISettings settings) throws MolFormatException, IOException
      Adds the molecule structure to the the document with the given settings without properties

      The following is one example how to use the addStructure. The code:

       IDocumentWriter writer = DocumentHandlerFactory.createDocumentWriter(DocumentType.PPT, testFile.getPath());
       JpegExporter exporter = JpegExporter.builder().aromatization(AromatizationMethod.AROMATIZATION_GENERAL)
               .hydrogenize(HydrogenizeOption.EXPLICITIZE).showValenceError().build();
       ISettings settings = new ReportSettings(new Location(0, 0, 1), exporter);
       settings.setDefaultStructureCellHeight(200);
       settings.setDefaultStructureCellWidth(200);
       IMoleculeData moleculeData = new MoleculeData("c1ccccc1", "smiles", "CD-001");
       writer.addStructure(moleculeData, settings);
       writer.close();
       
      Parameters:
      molecule - - IMoleculeData what should be added to the edited document
      settings - - Composite object what describes the location where the structure should be inserted and the options for structure rendering
      Throws:
      MolFormatException
      IOException
    • addStructureAndProperties

      void addStructureAndProperties(IMoleculeData molecule, ISettings settings) throws MolFormatException, IOException
      Adds the molecule structure and all corresponding properties to the document with the give settings

      The following is one example how to use the addStructureAndProperties. The code:

       IDocumentWriter writer = DocumentHandlerFactory.createDocumentWriter(DocumentType.PPT, testFile.getPath());
       JpegExporter exporter = JpegExporter.builder().aromatization(AromatizationMethod.AROMATIZATION_GENERAL)
               .hydrogenize(HydrogenizeOption.EXPLICITIZE).showValenceError().build();
       ISettings settings = new ReportSettings(new Location(0, 0, 1), exporter);
       settings.setDefaultStructureCellHeight(200);
       settings.setDefaultStructureCellWidth(200);
       IMoleculeData moleculeData = new MoleculeData("c1ccccc1", "smiles", "CD-001");
       moleculeData.getMolecule().setProperty("TestProp", "CD-001_TestPropValue");
       moleculeData.getMolecule().setProperty("TestProp2", "CD-001_TestPropValue2");
       writer.addStructureAndProperties(moleculeData, settings);
       writer.close();
       
      Parameters:
      molecule - - IMoleculeData what should be added to the edited document
      settings - - Composite object what describes the location where the structure should be inserted and the options for structure rendering
      Throws:
      MolFormatException
      IOException
    • addStructures

      void addStructures(IMoleculeData[] molecules, ISettings settings, int structurePerPage) throws MolFormatException, IOException
      Adds the array of molecule structures and their corresponding properties to the document with the give settings

      The following is one example how to use the addStructures. The code:

       IDocumentWriter writer = DocumentHandlerFactory.createDocumentWriter(DocumentType.PPT, testFile.getPath());
       JpegExporter exporter = JpegExporter.builder().aromatization(AromatizationMethod.AROMATIZATION_GENERAL)
               .hydrogenize(HydrogenizeOption.EXPLICITIZE).showValenceError().build();
       ISettings settings = new ReportSettings(new Location(0, 0, 1), exporter);
       settings.setDefaultStructureCellHeight(200);
       settings.setDefaultStructureCellWidth(200);
       MoleculeData moleculeData = new MoleculeData("c1ccccc1", "smiles", "CD-001");
       moleculeData.getMolecule().setProperty("TestProp", "CD-001_TestPropValue");
       moleculeData.getMolecule().setProperty("TestProp2", "CD-001_TestPropValue2");
       moleculeData.getMolecule().setProperty("TestProp3", "CD-001_TestPropValue3");
       MoleculeData moleculeData2 = new MoleculeData("c1ccccccc1", "smiles", "CD-002");
       moleculeData2.getMolecule().setProperty("TestProp", "CD-002_TestPropValue");
       moleculeData2.getMolecule().setProperty("TestProp2", "CD-002_TestPropValue2");
       writer.addStructures(new IMoleculeData[] { moleculeData, moleculeData2 }, settings, 5);
       writer.close();
       
      Parameters:
      molecules - - Array of IMoleculeData what should be added to the edited document
      settings - - Composite object what describes the location where the structures should be inserted and the options for structure rendering
      structurePerPage - - Defines how many structure should be written to a single page.
      • 1: Every page will contain 1 structure and the table of it's properties
      • 2, ...: the structures will be displayed in tables together with their data. The tables will have 2,... number of rows per page.
      Throws:
      MolFormatException
      IOException
    • addStructures

      void addStructures(IMoleculeData[] molecules) throws MolFormatException, IOException
      Adds the array of molecule structures and their corresponding properties to the end of the document. 1 structure and it's property table per page. The structures are rendered with the default rendering settings.

      The following is one example how to use the addStructures. The code:

       IDocumentWriter writer = DocumentHandlerFactory.createDocumentWriter(DocumentType.PPT, testFile.getPath());
       MoleculeData moleculeData = new MoleculeData("c1ccccc1", "smiles", "CD-001");
       moleculeData.getMolecule().setProperty("TestProp", "CD-001_TestPropValue");
       moleculeData.getMolecule().setProperty("TestProp2", "CD-001_TestPropValue2");
       moleculeData.getMolecule().setProperty("TestProp3", "CD-001_TestPropValue3");
       MoleculeData moleculeData2 = new MoleculeData("c1ccccccc1", "smiles", "CD-002");
       moleculeData2.getMolecule().setProperty("TestProp", "CD-002_TestPropValue");
       moleculeData2.getMolecule().setProperty("TestProp2", "CD-002_TestPropValue2");
       writer.addStructures(new IMoleculeData[] { moleculeData, moleculeData2 });
       writer.close();
       
      Parameters:
      molecules - - Array of IMoleculeData what should be added to the edited document
      Throws:
      MolFormatException
      IOException
    • addStructures

      void addStructures(IMoleculeData[] molecules, ISettings settings) throws MolFormatException, IOException
      Adds the array of molecule structures and their corresponding properties to the location given in the settings. 1 structure and it's property table per page. The structures are rendered based on the settings given as parameter.

      The following is one example how to use the addStructures. The code:

       JpegExporter exporter = JpegExporter.builder().aromatization(AromatizationMethod.AROMATIZATION_GENERAL)
               .hydrogenize(HydrogenizeOption.EXPLICITIZE).showValenceError().build();
       ISettings settings = new ReportSettings(new Location(0, 0, 1), exporter);
       settings.setDefaultStructureCellHeight(200);
       settings.setDefaultStructureCellWidth(200);
       IDocumentWriter writer = DocumentHandlerFactory.createDocumentWriter(DocumentType.PPT, testFile.getPath());
       MoleculeData moleculeData = new MoleculeData("c1ccccc1", "smiles", "CD-001");
       moleculeData.getMolecule().setProperty("TestProp", "CD-001_TestPropValue");
       moleculeData.getMolecule().setProperty("TestProp2", "CD-001_TestPropValue2");
       moleculeData.getMolecule().setProperty("TestProp3", "CD-001_TestPropValue3");
       MoleculeData moleculeData2 = new MoleculeData("c1ccccccc1", "smiles", "CD-002");
       moleculeData2.getMolecule().setProperty("TestProp", "CD-002_TestPropValue");
       moleculeData2.getMolecule().setProperty("TestProp2", "CD-002_TestPropValue2");
       writer.addStructures(new IMoleculeData[] { moleculeData, moleculeData2 }, settings);
       writer.close();
       
      Parameters:
      molecules - - Array of IMoleculeData what should be added to the edited document
      settings - - Composite object what describes the location where the structure should be inserted and the options for structure rendering
      Throws:
      MolFormatException
      IOException
    • load

      void load(String filePath, int structurePerPage) throws IOException
      Loads the molecule structure(s) and their corresponding properties from the given file into the end of the document. The structures will be rendered with default rendering settings.

      The following is one example how to use the load. The code:

       IDocumentWriter writer = DocumentHandlerFactory.createDocumentWriter(DocumentType.PPT, testFile.getPath());
       writer.load("TestFiles/ShortSDF.sdf", 8);
       writer.close();
       
      Parameters:
      filePath - - The path of the file from where the structures will be loaded
      structurePerPage - - Defines how many structure should be written to a single page.
      • 1: Every page will contain 1 structure and the table of it's properties
      • 2, ...: the structures will be displayed in tables together with their data. The tables will have 2,... number of rows per page.
      Throws:
      IOException
    • load

      void load(String filePath, ISettings settings, int structurePerPage) throws IOException
      Loads the molecule structure(s) and their corresponding properties from the given file into the document to the location given in the settings. The structures will be rendered as it is given in the settings.

      The following is one example how to use the load. The code:

       IDocumentWriter writer = DocumentHandlerFactory.createDocumentWriter(DocumentType.PPT, testFile.getPath());
       writer.load("TestFiles/ShortSDF.sdf", 8);
       writer.close();
       
      Parameters:
      filePath - - The path of the file from where the structures will be loaded
      settings - : - Composite object what describes the location where the structures should be inserted and the options for structure rendering
      structurePerPage - - Defines how many structure should be written to a single page.
      • 1: Every page will contain 1 structure and the table of it's properties
      • 2, ...: the structures will be displayed in tables together with their data. The tables will have 2,... number of rows per page.
      Throws:
      IOException
    • load

      void load(InputStream stream, int structurePerPage) throws IOException
      Loads the molecule structure(s) and their corresponding properties from the given input stream into the end of the document. The structures will be rendered with default rendering settings.

      The following is one example how to use the load. The code:

       IDocumentWriter writer = DocumentHandlerFactory.createDocumentWriter(DocumentType.PPT, testFile.getPath());
       writer.load(this.getClass().getResourceAsStream("TestFiles/ShortSDF.sdf"), 8);
       writer.close();
       
      Parameters:
      stream - - The input stream from where the structures will be loaded
      structurePerPage - - Defines how many structure should be written to a single page.
      • 1: Every page will contain 1 structure and the table of it's properties
      • 2, ...: the structures will be displayed in tables together with their data. The tables will have 2,... number of rows per page.
      Throws:
      IOException
    • load

      void load(InputStream stream, ISettings settings, int structurePerPage) throws IOException
      Loads the molecule structure(s) and their corresponding properties from the given input stream into the location given in the settings. The structures will be rendered as it is given in the settings.

      The following is one example how to use the load. The code:

       IDocumentWriter writer = DocumentHandlerFactory.createDocumentWriter(DocumentType.PPT, testFile.getPath());
       writer.load(this.getClass().getResourceAsStream("TestFiles/ShortSDF.sdf"), 8);
       writer.close();
       
      Parameters:
      stream - - The input stream from where the structures will be loaded
      settings - : - Composite object what describes the location where the structures should be inserted and the options for structure rendering
      structurePerPage - - Defines how many structure should be written to a single page.
      • 1: Every page will contain 1 structure and the table of it's properties
      • 2, ...: the structures will be displayed in tables together with their data. The tables will have 2,... number of rows per page.
      Throws:
      IOException
    • createTableModel

      ITableModel createTableModel(int rowCount, int columnCount)
      Creates a custom table for the structure data

      The following is one example how to use the createTableModel. The code:

       writer = DocumentHandlerFactory.createDocumentWriter(DocumentType.PPT,
       testFile.getPath());
       

      ITableModel model = writer.createTableModel(2, 2); ITableCell cell = model.getItem(0, 0); cell.getData().Assign(new MoleculeData("C=C", "smiles", "CD-001")); cell.getFormat().setWidth(100); cell.getFormat().setHeight(100); cell.getFormat().setBackColor(Color.GREEN); cell.getFormat().setAlignment(FontAlignment.BottomCenter); ITableCell cell2 = model.getItem(0, 1); cell2.getData().Assign("Test1"); cell2.getFormat().setForeColor(Color.YELLOW); cell2.getFormat().setBackColor(Color.ORANGE); cell2.getFormat().setAlignment(FontAlignment.BottomRight); ITableCell cell3 = model.getItem(1, 0); cell3.getData().Assign("Test2"); cell3.getFormat().setForeColor(Color.GREEN); cell3.getFormat().setBackColor(Color.RED); cell3.getFormat().setAlignment(FontAlignment.BottomLeft); ITableCell cell4 = model.getItem(1, 1); cell4.getData().Assign(new MoleculeData("C=C", "smiles", "CD-002")); cell4.getFormat().setWidth(100); cell4.getFormat().setHeight(100); cell4.getFormat().setBackColor(Color.GREEN); cell4.getFormat().setAlignment(FontAlignment.BottomCenter); writer.addTable(model);

      writer.close();

      Parameters:
      rowCount - - The number of rows in the custom table
      columnCount - - The number of columns in the custom table
      Returns:
      ITableModel
    • addTable

      Location addTable(ITableModel table) throws IOException
      Adds the table custom table to the and of the Document

      The following is one example how to use the addTable. The code:

       writer = DocumentHandlerFactory.createDocumentWriter(DocumentType.PPT,
       testFile.getPath());
       

      ITableModel model = writer.createTableModel(2, 2); ITableCell cell = model.getItem(0, 0); cell.getData().Assign(new MoleculeData("C=C", "smiles", "CD-001")); cell.getFormat().setWidth(100); cell.getFormat().setHeight(100); cell.getFormat().setBackColor(Color.GREEN); cell.getFormat().setAlignment(FontAlignment.BottomCenter); ITableCell cell2 = model.getItem(0, 1); cell2.getData().Assign("Test1"); cell2.getFormat().setForeColor(Color.YELLOW); cell2.getFormat().setBackColor(Color.ORANGE); cell2.getFormat().setAlignment(FontAlignment.BottomRight); ITableCell cell3 = model.getItem(1, 0); cell3.getData().Assign("Test2"); cell3.getFormat().setForeColor(Color.GREEN); cell3.getFormat().setBackColor(Color.RED); cell3.getFormat().setAlignment(FontAlignment.BottomLeft); ITableCell cell4 = model.getItem(1, 1); cell4.getData().Assign(new MoleculeData("C=C", "smiles", "CD-002")); cell4.getFormat().setWidth(100); cell4.getFormat().setHeight(100); cell4.getFormat().setBackColor(Color.GREEN); cell4.getFormat().setAlignment(FontAlignment.BottomCenter); writer.addTable(model);

      writer.close();

      Parameters:
      table - - The table what will be added to the Document
      Returns:
      The location of the added table
      Throws:
      IOException
    • getAppendLocation

      Location getAppendLocation() throws IOException
      Returns the next writable position at the end of the Document
      Returns:
      Location object
      Throws:
      IOException
    • close

      void close() throws IOException
      Closes the office Document stream.
      Throws:
      IOException