Search in sources :

Example 1 with GeomFactory

use of com.actelion.research.share.gui.editor.geom.GeomFactory in project openchemlib by Actelion.

the class AtomHighlightAction method showAtomQFDialog.

private boolean showAtomQFDialog(int atom) {
    GeomFactory factory = model.getGeomFactory();
    StereoMolecule mol = model.getMolecule();
    if (mol != null) {
        IAtomQueryFeaturesDialog dlg = factory.createAtomQueryFeatureDialog(/*new AtomQueryFeaturesDialog*/
        mol, atom);
        return dlg.doModalAt(lastHightlightPoint.getX(), lastHightlightPoint.getY()) == DialogResult.IDOK;
    }
    return false;
}
Also used : IAtomQueryFeaturesDialog(com.actelion.research.share.gui.editor.dialogs.IAtomQueryFeaturesDialog) GeomFactory(com.actelion.research.share.gui.editor.geom.GeomFactory) StereoMolecule(com.actelion.research.chem.StereoMolecule)

Example 2 with GeomFactory

use of com.actelion.research.share.gui.editor.geom.GeomFactory in project openchemlib by Actelion.

the class AtomMapAction method paint.

// private void assistedMap(int atom)
// {
// StereoMolecule mol = model.getSelectedMolecule();
// int freeMapNo = model.getNextMapNo();
// if (mol != null) {
// StereoMolecule source = model.getFragmentAt(firstPoint, false);
// StereoMolecule target = model.getFragmentAt(lastPoint, false);
// if (target != null && target != source) {
// int dest = mol.findAtom((int) lastPoint.getX(), (int) lastPoint.getY());
// if (dest != -1) {
// mol.setAtomMapNo(atom, freeMapNo, false);
// mol.setAtomMapNo(dest, freeMapNo, false);
// }
// model.tryAutoMapReaction();
// }
// }
// }
// 
@Override
public boolean paint(IDrawContext ctx) {
    boolean ok = false;
    ctx.save();
    if (model.isReaction()) {
        StereoMolecule mol = model.getMolecule();
        if (firstPoint != null && lastPoint != null) {
            StereoMolecule source = model.getFragmentAt(firstPoint, false);
            StereoMolecule target = model.getFragmentAt(lastPoint, false);
            if (target != null && target != source) {
                int theAtom = mol.findAtom((float) lastPoint.getX(), (float) lastPoint.getY());
                if (theAtom != -1)
                    drawAtomHighlight(ctx, mol, theAtom);
            }
            // ctx.setStroke(IColor.RED);
            GeomFactory builder = model.getGeomFactory();
            ctx.setStroke(builder.getMapToolColor());
            ctx.drawLine(firstPoint.getX(), firstPoint.getY(), lastPoint.getX(), lastPoint.getY());
        } else if (secondAtom != -1) {
            drawAtomHighlight(ctx, mol, secondAtom);
        }
    }
    ok = super.paint(ctx);
    ctx.restore();
    return ok;
}
Also used : GeomFactory(com.actelion.research.share.gui.editor.geom.GeomFactory) StereoMolecule(com.actelion.research.chem.StereoMolecule)

Example 3 with GeomFactory

use of com.actelion.research.share.gui.editor.geom.GeomFactory in project openchemlib by Actelion.

the class BondHighlightAction method showBondQFDialog.

private boolean showBondQFDialog(int bond) {
    StereoMolecule mol = model.getMolecule();
    if (mol != null) {
        GeomFactory factory = model.getGeomFactory();
        IBondQueryFeaturesDialog dlg = factory.createBondFeaturesDialog(/*new BondQueryFeaturesDialog(*/
        mol, bond);
        return dlg.doModalAt(lastHightlightPoint.getX(), lastHightlightPoint.getY()) == DialogResult.IDOK;
    }
    return false;
}
Also used : IBondQueryFeaturesDialog(com.actelion.research.share.gui.editor.dialogs.IBondQueryFeaturesDialog) GeomFactory(com.actelion.research.share.gui.editor.geom.GeomFactory) StereoMolecule(com.actelion.research.chem.StereoMolecule)

Example 4 with GeomFactory

use of com.actelion.research.share.gui.editor.geom.GeomFactory in project openchemlib by Actelion.

the class ArrowAction method onMouseMove.

@Override
public boolean onMouseMove(IMouseEvent ev, boolean drag) {
    if (drag) {
        GeomFactory factory = model.getGeomFactory();
        last = new Point2D.Double(ev.getX(), ev.getY());
        java.awt.geom.Rectangle2D r = new java.awt.geom.Rectangle2D.Double((int) Math.min(last.getX(), origin.getX()), (int) last.getY(), (int) Math.abs(last.getX() - origin.getX()), 0);
        // IRectangle2D r = builder.createRectangle(
        // (int) Math.min(last.getX(), origin.getX()),
        // (int) last.getY(),
        // (int) Math.abs(last.getX() - origin.getX()),
        // 2);
        arrow = factory.createArrow(r);
        return true;
    }
    // To change body of implemented methods use File | Settings | File Templates.
    return false;
}
Also used : Point2D(java.awt.geom.Point2D) GeomFactory(com.actelion.research.share.gui.editor.geom.GeomFactory)

Example 5 with GeomFactory

use of com.actelion.research.share.gui.editor.geom.GeomFactory in project openchemlib by Actelion.

the class AtomHighlightAction method handleCharacter.

private boolean handleCharacter(StereoMolecule mol, int theAtom, IKeyEvent evt) {
    GeomFactory factory = model.getGeomFactory();
    StringBuilder keyStrokeBuffer = model.getKeyStrokeBuffer();
    boolean isFirst = (keyStrokeBuffer.length() == 0);
    String code = evt.getText();
    char c = code != null && code.length() > 0 ? code.charAt(0) : 0;
    if (evt.getCode().equals(factory.getDeleteKey())) {
        if (theAtom != -1) {
            mol.deleteAtom(theAtom);
            setHighlightAtom(mol, -1);
            return true;
        } else {
            if (mol.deleteSelectedAtoms()) {
                return true;
            }
        }
    } else if (!isFirst && evt.getCode().equals(factory.getEscapeKey())) {
        keyStrokeBuffer.setLength(0);
        return true;
    } else if (!isFirst && evt.getCode().equals(factory.getBackSpaceKey())) {
        keyStrokeBuffer.setLength(keyStrokeBuffer.length() - 1);
        return true;
    } else if (evt.getCode().equals(factory.getEnterKey())) {
        expandAtomKeyStrokes(mol, theAtom, keyStrokeBuffer.toString());
        keyStrokeBuffer.setLength(0);
        return true;
    } else if (isFirst && c > 48 && c <= 57) {
        addChain(mol, theAtom, c - 47);
        return true;
    } else if ((c > 48 && c <= 57) || (c >= 65 && c <= 90) || (c >= 97 && c <= 122) || (c >= 48 && c <= 57) || (c == '-')) {
        keyStrokeBuffer.append(c);
        return true;
    }
    return false;
}
Also used : GeomFactory(com.actelion.research.share.gui.editor.geom.GeomFactory)

Aggregations

GeomFactory (com.actelion.research.share.gui.editor.geom.GeomFactory)9 StereoMolecule (com.actelion.research.chem.StereoMolecule)7 IAtomPropertiesDialog (com.actelion.research.share.gui.editor.dialogs.IAtomPropertiesDialog)1 IAtomQueryFeaturesDialog (com.actelion.research.share.gui.editor.dialogs.IAtomQueryFeaturesDialog)1 IBondQueryFeaturesDialog (com.actelion.research.share.gui.editor.dialogs.IBondQueryFeaturesDialog)1 Point2D (java.awt.geom.Point2D)1