All Downloads are FREE. Search and download functionalities are using the official Maven repository.

signature.chemistry.MoleculeBuilder Maven / Gradle / Ivy

The newest version!
package signature.chemistry;

import signature.AbstractGraphBuilder;
import signature.ColoredTree;
import signature.chemistry.Molecule.BondOrder;

public class MoleculeBuilder extends AbstractGraphBuilder {
    
    private Molecule molecule;
    
    public MoleculeBuilder() {
        super();
    }

    @Override
    public void makeEdge(
            int vertexIndex1, int vertexIndex2, 
            String symbolA, String symbolB, String edgeLabel) {
        if (edgeLabel.equals("")) {
            this.molecule.addBond(vertexIndex1, vertexIndex2, BondOrder.SINGLE);
        } else if (edgeLabel.equals("=")) {
            this.molecule.addBond(vertexIndex1, vertexIndex2, BondOrder.DOUBLE);
        } else if (edgeLabel.equals("#")) {
            this.molecule.addBond(vertexIndex1, vertexIndex2, BondOrder.TRIPLE);
        }
        
    }

    @Override
    public void makeGraph() {
        this.molecule = new Molecule();
    }

    @Override
    public void makeVertex(String label) {
        this.molecule.addAtom(label);
    }
    
    public Molecule fromTree(ColoredTree tree) {
        super.makeFromColoredTree(tree);
        return this.molecule;
    }

    public Molecule getMolecule() {
        return this.molecule;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy