Package org.openscience.cdk.renderer.selection

Examples of org.openscience.cdk.renderer.selection.IChemObjectSelection


      panel.get2DHub().mouseClickedDown((int)p1.x, (int)p1.y);
        applet.panel("renderpanel").robot.waitForIdle();
      panel.get2DHub().mouseClickedUp((int)p1.x, (int)p1.y);
        panel.get2DHub().updateView();
        applet.panel("renderpanel").robot.waitForIdle();
        IChemObjectSelection sel = panel.getRenderPanel().getRenderer().getRenderer2DModel().getSelection();
        Assert.assertEquals(true, sel.contains(ethane.getAtom(0)));
        applet.menuItem("formalCharge").requireEnabled();

        Point2d p2 = ethane.getAtom(1).getPoint2d();
    p2 = panel.getRenderPanel().getRenderer().toScreenCoordinates(p2.x, p2.y);
      panel.get2DHub().mouseClickedDown((int)p2.x, (int)p2.y);
        applet.panel("renderpanel").robot.waitForIdle();
      panel.get2DHub().mouseClickedUp((int)p2.x, (int)p2.y);
        panel.get2DHub().updateView();
        applet.panel("renderpanel").robot.waitForIdle();
        sel = panel.getRenderPanel().getRenderer().getRenderer2DModel().getSelection();
        Assert.assertEquals(true, sel.contains(ethane.getAtom(1)));
        applet.menuItem("formalCharge").requireEnabled();
    }
View Full Code Here


                jcpPanel.get2DHub().zap();
                jcpPanel.get2DHub().updateView();
                jcpPanel.getRenderPanel().getRenderer().getRenderer2DModel()
                        .setZoomFactor(1);

                IChemObjectSelection selection = new LogicalSelection(
                        LogicalSelection.Type.NONE);
                jcpPanel.getRenderPanel().getRenderer().getRenderer2DModel()
                        .setSelection(selection);

            }
View Full Code Here

        theJcpp.get2DHub().zap();
        theJcpp.get2DHub().updateView();
        theJcpp.getRenderPanel().getRenderer().getRenderer2DModel()
                .setZoomFactor(1);

        IChemObjectSelection selection = new LogicalSelection(
                LogicalSelection.Type.NONE);
        theJcpp.getRenderPanel().getRenderer().getRenderer2DModel()
                .setSelection(selection);
    }
View Full Code Here

        super(chemModelRelay);
    }

  private IAtom getClosestSelAtom(Point2d worldCoord) {
    IAtom closestAtom = null;
    IChemObjectSelection sel = chemModelRelay.getRenderer().getRenderer2DModel().getSelection();
    double closestDistanceSQ = Double.MAX_VALUE;

    for (IAtom atom : sel.elements(IAtom.class)) {
      if (atom.getPoint2d() != null) {
        double distanceSQ = atom.getPoint2d().distanceSquared(
            worldCoord);
        if (distanceSQ < closestDistanceSQ) {
          closestAtom = atom;
View Full Code Here

    return closestAtom;
  }
 
  private IBond getClosestSelBond(Point2d worldCoord) {
    IBond closestBond = null;
    IChemObjectSelection sel = chemModelRelay.getRenderer().getRenderer2DModel().getSelection();
    double closestDistanceSQ = Double.MAX_VALUE;

    for (IBond bond : sel.elements(IBond.class)) {
      if (bond.get2DCenter() != null) {
        double distanceSQ = bond.get2DCenter().distanceSquared(
            worldCoord);
        if (distanceSQ < closestDistanceSQ) {
          closestBond = bond;
View Full Code Here

   
    public void mouseDrag(Point2d from, Point2d to) {
        Rectangle2D bounds=null;
        boolean inSelectionCircle = false;
        JChemPaintRendererModel model = chemModelRelay.getRenderer().getRenderer2DModel();
        IChemObjectSelection sel = model.getSelection();
        if (sel == null) return;
        double d = model.getSelectionRadius() / model.getScale();
        IAtom closestAtom = null;
        IBond closestBond = null;
        IAtom highlitAtom = model.getHighlightedAtom();
        IBond highlitBond = model.getHighlightedBond();
        if(from.equals(startPoint)) {
          LogicalSelection lsel = null;
          boolean isAllSelected = false;
            if (sel.getClass().isAssignableFrom(LogicalSelection.class)) {
              lsel = (LogicalSelection)sel;
                isAllSelected = lsel.getType() == LogicalSelection.Type.ALL
                && sel.isFilled();
          }
          if (!isAllSelected && sel != null && sel.isFilled()) {
              bounds = BoundsCalculator.calculateBounds(sel.getConnectedAtomContainer());
              closestAtom = getClosestSelAtom(startPoint);
              closestBond = getClosestSelBond(startPoint);
          }
            inSelectionCircle = (closestAtom != null && closestAtom.getPoint2d().distance(startPoint) < 4*d)
                  || (closestBond != null && closestBond.get2DCenter().distance(startPoint) < 4*d)
 
View Full Code Here

            IBond closestBond = chemModelRelay.getClosestBond(p);
            IChemObject singleSelection = getHighlighted( p,
                    closestAtom,
                    closestBond );

            IChemObjectSelection curSel = chemModelRelay.getRenderer().getRenderer2DModel().getSelection();
            IChemObjectSelection sel = null;
            if (shiftPressed && curSel != null && curSel.isFilled()) {
                IAtomContainer container = new AtomContainer(curSel.getConnectedAtomContainer());               
                if (singleSelection instanceof IAtom) {
                    IAtom atom = (IAtom) singleSelection;
                    if (!container.contains(atom))  container.addAtom(atom);
View Full Code Here

                JChemPaintRendererModel rModel =
                                                        chemModelRelay.getRenderer().getRenderer2DModel();
                IAtom atom = chemModelRelay.getClosestAtom(worldCoord);
                IBond bond = chemModelRelay.getClosestBond(worldCoord);

                IChemObjectSelection localSelection = rModel.getSelection();
                IChemObject chemObject = getHighlighted(worldCoord, atom, bond);

                if (localSelection==null || !localSelection.contains(chemObject)) {
                        if (chemObject != null) {
                                localSelection = new SingleSelection<IChemObject>(chemObject);
                        } else {
                                //if clicked inside a square comprising the selection, keep it, otherwise void it
                                Double upperX = null, lowerX = null, upperY = null, lowerY = null;
                                IAtomContainer selectedAtoms=null;
                                if(localSelection!=null)
                                    selectedAtoms = localSelection.getConnectedAtomContainer();
                                if(selectedAtoms!=null) {
                                    for (int i = 0; i < selectedAtoms.getAtomCount(); i++) {
                                        if (upperX == null) {
                                            upperX = lowerX = selectedAtoms.getAtom(i).getPoint2d().x;
                                            upperY = lowerY = selectedAtoms.getAtom(i).getPoint2d().y;
                                        } else {
                                            double currX = selectedAtoms.getAtom(i).getPoint2d().x;
                                            if (currX > upperX)
                                                upperX = currX;
                                            if (currX < lowerX)
                                                lowerX = currX;
                                            double currY = selectedAtoms.getAtom(i).getPoint2d().y;
                                            if (currY > upperY)
                                                upperY = currY;
                                            if (currY < lowerY)
                                                lowerY = currY;
                                        }
                                    }
                                }
                                if (upperX!=null && upperY!=null) {
                                    if (!(worldCoord.x>=lowerX &&
                                          worldCoord.y>=lowerY &&
                                          worldCoord.x<=upperX &&
                                          worldCoord.y<=upperY)
                                    )
                                    localSelection = AbstractSelection.EMPTY_SELECTION;
                                }
                                else
                                    localSelection = AbstractSelection.EMPTY_SELECTION;
                        }
                }
                setSelection(localSelection);
                return localSelection.getConnectedAtomContainer();
        }
View Full Code Here

TOP

Related Classes of org.openscience.cdk.renderer.selection.IChemObjectSelection

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.