Search in sources :

Example 6 with IDrawingObject

use of com.actelion.research.share.gui.editor.chem.IDrawingObject in project openchemlib by Actelion.

the class Model method cleanReaction.

/*
    public void resizeReaction(Dimension os, Dimension ns)
    {
        Reaction rxn = getReaction(false);
        double offsetx = ns.getWidth() - os.getWidth();
        double offsety = ns.getHeight() - os.getHeight();
        double scale;

        if (Math.abs(offsetx) > Math.abs(offsety)) {
            scale = ns.getHeight() / os.getHeight();
        } else {
            scale = ns.getWidth() / os.getWidth();

        }
        ChemistryHelper.transformReaction(rxn, offsetx, offsety, scale);
        setValue(rxn);

    }
*/
public void cleanReaction(boolean cleanAll) {
    Reaction reaction = getReaction();
    // System.out.printf("cleanreaction %s\n",reaction.getReactants());
    Dimension dim = getDisplaySize();
    double w = dim.getWidth();
    double h = dim.getHeight();
    double width = w / 5;
    if (w > 0 && h > 0) {
        // new Arrow(mx , my, dx,20);
        IDrawingObject arrow = getDrawingObjects().get(0);
        arrow.setRect((float) (0.5f * w), (float) (0.5f * h), (float) (0.5f * .16 * w), 20);
        arrowPos = new Point2D.Double((0.5f * w), (0.5f * h));
        mMode = MODE_MULTIPLE_FRAGMENTS;
        if (cleanAll)
            cleanupCoordinates(true, true);
        ChemistryHelper.scaleInto(reaction, 0, 0, dim.getWidth(), dim.getHeight(), width);
        setValue(reaction);
    }
}
Also used : Point2D(java.awt.geom.Point2D) IDrawingObject(com.actelion.research.share.gui.editor.chem.IDrawingObject) Reaction(com.actelion.research.chem.reaction.Reaction)

Aggregations

IDrawingObject (com.actelion.research.share.gui.editor.chem.IDrawingObject)6 StereoMolecule (com.actelion.research.chem.StereoMolecule)2 Point2D (java.awt.geom.Point2D)2 Rectangle2D (java.awt.geom.Rectangle2D)2 Reaction (com.actelion.research.chem.reaction.Reaction)1