Package org.openscience.cdk.interfaces

Examples of org.openscience.cdk.interfaces.IChemModel


        Graphics2D g2 = (Graphics2D) g;

        if (this.shouldPaintFromCache) {
            renderer.repaint(new AWTDrawVisitor(g2));
        } else {
            IChemModel chemModel = this.hub.getIChemModel();

            if (!isValidChemModel(chemModel))
                return;

            /*
 
View Full Code Here


                String mode = activeDrawModule.getDrawModeString();
                status = JCPMenuTextMaker.getInstance("applet").getText(mode);
            }
        } else if (position == 1) {
            // depict bruto formula
            IChemModel chemModel = hub.getIChemModel();
            IAtomContainerSet molecules = chemModel.getMoleculeSet();
            if (molecules != null && molecules.getAtomContainerCount() > 0) {
                Iterator<IAtomContainer> containers = ChemModelManipulator
                        .getAllAtomContainers(chemModel).iterator();
                int implicitHs = 0;
                while (containers.hasNext()) {
View Full Code Here

    public void actionPerformed(ActionEvent e) {
        logger.info("  type  ", type);
        logger.debug("  source ", e.getSource());
       
        JChemPaintRendererModel renderModel = jcpPanel.get2DHub().getRenderer().getRenderer2DModel();
        IChemModel chemModel = jcpPanel.getChemModel();
        Clipboard sysClip = jcpPanel.getToolkit().getSystemClipboard();

        if ("copy".equals(type)) {
            handleSystemClipboard(sysClip);
            IAtom atomInRange = null;
            IChemObject object = getSource(e);
            logger.debug("Source of call: ", object);
            if (object instanceof IAtom) {
                atomInRange = (IAtom) object;
            } else {
                atomInRange = renderModel.getHighlightedAtom();
            }
            if (atomInRange != null) {
                IAtomContainer tocopyclone =
                    atomInRange.getBuilder().newInstance(IAtomContainer.class);
                try {
          tocopyclone.addAtom((IAtom) atomInRange.clone());
        } catch (CloneNotSupportedException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
        }
                addToClipboard(sysClip, tocopyclone);
            }
            else if(renderModel.getHighlightedBond()!=null){
                IBond bond = renderModel.getHighlightedBond();
                if (bond != null) {
                    IAtomContainer tocopyclone =
                        bond.getBuilder().newInstance(IAtomContainer.class);
                    try {
                        tocopyclone.addAtom((IAtom) bond.getAtom(0).clone());
                        tocopyclone.addAtom((IAtom) bond.getAtom(1).clone());
                    } catch (CloneNotSupportedException e1) {
                        e1.printStackTrace();
                    }
                    tocopyclone.addBond(bond.getBuilder().newInstance(IBond.class,tocopyclone.getAtom(0), tocopyclone.getAtom(1), bond.getOrder()));
                    addToClipboard(sysClip, tocopyclone);
                }
            }else if(renderModel.getSelection().getConnectedAtomContainer()!=null){
              addToClipboard(sysClip,
                  renderModel.getSelection().getConnectedAtomContainer());
            }else{
        addToClipboard(sysClip, JChemPaintPanel.getAllAtomContainersInOne(chemModel));
            }
        } else if ("copyAsSmiles".equals(type)) {
            handleSystemClipboard(sysClip);
            try {
               
                final IAtomContainer selection = renderModel.getSelection().getConnectedAtomContainer();
               
                if(selection!=null){
                    final IChemObjectBuilder bldr = selection.getBuilder();
                    IChemModel selectionModel = bldr.newInstance(IChemModel.class);
                    selectionModel.setMoleculeSet(bldr.newInstance(IAtomContainerSet.class));
                    selectionModel.getMoleculeSet().addAtomContainer(selection);
                    sysClip.setContents(new SmilesSelection(CreateSmilesAction.getSmiles(selectionModel)), null);
                }else{
                    sysClip.setContents(new SmilesSelection(CreateSmilesAction.getSmiles(chemModel)),null);
                }
            } catch (Exception e1) {
View Full Code Here

     * @param url location
     * @return InChI instance
     * @throws CDKException InChI could not be generated
     */
    public static IChemModel readInChI(URL url) throws CDKException {
        IChemModel chemModel = new ChemModel();
        try {
            IAtomContainerSet moleculeSet = new AtomContainerSet();
            chemModel.setMoleculeSet(moleculeSet);

            BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
            String line;
            while ((line = in.readLine()) != null) {
                if (line.toLowerCase().startsWith("inchi=")) {
View Full Code Here

    }   

    protected void restoreModelToEmpty(){
        JPanelFixture jcppanel=applet.panel("appletframe");
        JChemPaintPanel panel = (JChemPaintPanel)jcppanel.target;
        IChemModel basic = DefaultChemObjectBuilder.getInstance().newInstance(IChemModel.class);
        basic.setMoleculeSet(basic.getBuilder().newInstance(IAtomContainerSet.class));
        basic.getMoleculeSet().addAtomContainer(
                basic.getBuilder().newInstance(IAtomContainer.class));
        panel.setChemModel(basic);
        panel.getRenderPanel().getRenderer().getRenderer2DModel().setZoomFactor(1);
        panel.getRenderPanel().getRenderer().getRenderer2DModel().setBondLength(10.4);
        panel.get2DHub().updateView();
    }
View Full Code Here

        JChemPaintPanel panel = (JChemPaintPanel)jcppanel.target;
        panel.get2DHub().getController2DModel().setAutoUpdateImplicitHydrogens(true);
        String filename = "data/basic.mol";
        InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
        MDLV2000Reader reader = new MDLV2000Reader(ins);
        IChemModel basic;
        try {
            basic = (IChemModel) reader.read(DefaultChemObjectBuilder.getInstance().newInstance(IChemModel.class));
            AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(basic.getMoleculeSet().getAtomContainer(0));
            CDKHydrogenAdder hAdder = CDKHydrogenAdder.getInstance(basic.getMoleculeSet().getAtomContainer(0)
                    .getBuilder());
            hAdder.addImplicitHydrogens(basic.getMoleculeSet().getAtomContainer(0));
            //valencies are set when doing atom typing, which we don't want in jcp
            for(int i=0;i<basic.getMoleculeSet().getAtomContainer(0).getAtomCount();i++){
                basic.getMoleculeSet().getAtomContainer(0).getAtom(i).setValency(null);
            }
            panel.setChemModel(basic);
            panel.getRenderPanel().getRenderer().getRenderer2DModel().setZoomFactor(1);

            panel.get2DHub().updateView();
View Full Code Here

     *@param  event  Description of the Parameter
     */
    public void actionPerformed(ActionEvent event)
    {

        IChemModel jcpm = jcpPanel.getChemModel();
        if (jcpm == null)
        {
            String error = GT.get("Nothing to save.");
            JOptionPane.showMessageDialog(jcpPanel, error,error,JOptionPane.WARNING_MESSAGE);
        } else
View Full Code Here

    protected void saveAs(ActionEvent event)
    {
        int ready=1;
        while(ready==1){
            IChemModel model = jcpPanel.getChemModel();

            JFileChooser chooser = new JFileChooser();
            chooser.setCurrentDirectory(jcpPanel.getCurrentWorkDirectory());
            chooser.setAcceptAllFileFilterUsed(false);
            JCPSaveFileFilter.addChoosableFileFilters(chooser);
View Full Code Here

public class JChemPaintEditorApplet extends JChemPaintAbstractApplet{
  public static final String GUI_APPLET="applet";
  public void init() {
    super.init();
    IChemModel chemModel = DefaultChemObjectBuilder.getInstance().newInstance(IChemModel.class);
    chemModel.setMoleculeSet(chemModel.getBuilder().newInstance(IAtomContainerSet.class));
    chemModel.getMoleculeSet().addAtomContainer(chemModel.getBuilder().newInstance(IAtomContainer.class));
    JChemPaintPanel p = new JChemPaintPanel(chemModel,GUI_APPLET,debug,this, this.blacklist);
    p.setName("appletframe");
    p.setShowInsertTextField(true);
    p.setShowStatusBar(false);
    setTheJcpp(p);
View Full Code Here

     *
     * @param fileURL
     */
    public void loadModelFromUrl(URL fileURL, AbstractJChemPaintPanel panel) {
        try {
            IChemModel chemModel = JChemPaint.readFromFileReader(fileURL,
                    fileURL.toString(), null, panel);
            theJcpp.setChemModel(chemModel);
        } catch (Exception exception) {
            theJcpp.announceError(exception);
        }
View Full Code Here

TOP

Related Classes of org.openscience.cdk.interfaces.IChemModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.