Package org.openscience.jchempaint.renderer

Examples of org.openscience.jchempaint.renderer.Renderer


            boolean isViewer, JChemPaintAbstractApplet applet)
            throws IOException {
        // setup the Renderer and the controller 'model'

        if (this.renderer == null) {
            this.renderer = new Renderer(makeGenerators(chemModel),
                    makeReactionGenerators(), new AWTFontManager());
            // any specific rendering settings defaults that overwrite user settings should go here
            //this.renderer.getRenderer2DModel().setShowEndCarbons(false);
            //this.renderer.getRenderer2DModel().setShowAromaticity(false);
        }
View Full Code Here


        applet.button("bondTool").click();
        applet.panel("renderpanel").robot.click(applet.panel("renderpanel").component(),new Point(100,100));
        applet.button("select").click();
    IAtomContainer ethane = panel.getChemModel().getMoleculeSet().getAtomContainer(0);
    Point2d p1 = ethane.getAtom(0).getPoint2d();
    Renderer r = panel.getRenderPanel().getRenderer();
    p1 = r.toScreenCoordinates(p1.x, p1.y);
      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 = r.getRenderer2DModel().getSelection();
        Assert.assertEquals(true, sel.contains(ethane.getAtom(0)));

    double d = r.getRenderer2DModel().getSelectionRadius() / r.getRenderer2DModel().getScale();
      panel.get2DHub().mouseClickedDown((int)(p1.x+d/2), (int)(p1.y+d/2));
        applet.panel("renderpanel").robot.waitForIdle();
      panel.get2DHub().mouseDrag((int)(p1.x+d/2), (int)(p1.y+d/2),(int)p1.x+100, (int)p1.y+100);
      panel.get2DHub().mouseClickedUp((int)p1.x+100, (int)p1.y+100);
        panel.get2DHub().updateView();
        applet.panel("renderpanel").robot.waitForIdle();
        sel = panel.getRenderPanel().getRenderer().getRenderer2DModel().getSelection();
        Point2d p2 = ethane.getAtom(0).getPoint2d();
        p2 = r.toScreenCoordinates(p2.x, p2.y);
        Assert.assertEquals((int)(p1.x+100), (int)p2.x);
    }
View Full Code Here

        // so we crank the lever manually
        JCPAction act = new JCPAction().getAction(panel, "org.openscience.jchempaint.action.ChangeModeAction@select");
        act.actionPerformed(null);
        applet.panel("renderpanel").robot.waitForIdle();
    IAtomContainer ethane = panel.getChemModel().getMoleculeSet().getAtomContainer(0);
    Renderer r = panel.getRenderPanel().getRenderer();
    Point2d atompos0=ethane.getAtom(0).getPoint2d();
    Point2d atompos1=ethane.getAtom(1).getPoint2d();
    atompos0 = r.toScreenCoordinates(atompos0.x, atompos0.y);
    atompos1 = r.toScreenCoordinates(atompos1.x, atompos1.y);
    panel.get2DHub().mouseClickedDown((int)atompos0.x, (int)atompos0.y);
    panel.get2DHub().updateView();
    applet.panel("renderpanel").robot.waitForIdle();
    panel.get2DHub().mouseClickedUp((int)atompos0.x, (int)atompos0.y);
    panel.get2DHub().updateView();
View Full Code Here

    }
        return null;
  }

  private void popupMenuForNearestChemObject(Point2d mouseCoords) {
      Renderer renderer = rendererPanel.getRenderer();
      JChemPaintRendererModel rendererModel = renderer.getRenderer2DModel();
    IChemObject objectInRange = rendererModel.getHighlightedAtom();
   
    if (objectInRange == null)
      objectInRange = rendererModel.getHighlightedBond();
   
    //look if we are in a reaction box
    IReactionSet reactionSet =
        rendererPanel.getChemModel().getReactionSet();
   
    if (objectInRange == null && reactionSet != null
                && reactionSet.getReactionCount() > 0) {
     
      for(int i=0;i<reactionSet.getReactionCount();i++){
        Rectangle reactionbounds =
            renderer.calculateDiagramBounds(reactionSet.getReaction(i));
        if (reactionbounds.contains(mouseCoords.x, mouseCoords.y))
          objectInRange = reactionSet.getReaction(i);
      }
    }
   
View Full Code Here

    Assert.assertEquals(2, atomCount);
        Assert.assertEquals(1, bondCount);
    Assert.assertEquals(4, implicitHCount);
   
        IAtomContainer ethylene = panel.getChemModel().getMoleculeSet().getAtomContainer(0);
    Renderer r = panel.getRenderPanel().getRenderer();
    Point2d atompos0=ethylene.getAtom(0).getPoint2d();
    Point2d atompos1=ethylene.getAtom(1).getPoint2d();
    Point2d bondpos = r.toScreenCoordinates((atompos0.x + atompos1.x)/2, (atompos0.y + atompos1.y)/2);
    panel.get2DHub().mouseClickedDown((int)bondpos.x, (int)bondpos.y);
    panel.get2DHub().updateView();
    applet.panel("renderpanel").robot.waitForIdle();
    panel.get2DHub().mouseClickedUp((int)bondpos.x, (int)bondpos.y);
    panel.get2DHub().updateView();
View Full Code Here

    private static String getMolSvg(IAtomContainer cdkmol, int width, int height) throws UnsupportedEncodingException, SVGGraphics2DIOException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        List<IGenerator> generators = new ArrayList<IGenerator>();
        generators.add(new BasicBondGenerator());
        generators.add(new BasicAtomGenerator());
        Renderer renderer = new Renderer(generators,new AWTFontManager(), false);
        RendererModel r2dm = renderer.getRenderer2DModel();
        r2dm.setDrawNumbers(false);
        r2dm.setBackColor(Color.LIGHT_GRAY);
        r2dm.setIsCompact(true);
        r2dm.setShowImplicitHydrogens(false);
        r2dm.setShowEndCarbons(false);
        int number=((int)Math.sqrt(cdkmol.getAtomCount()))+1;
        int moleculewidth = number*100;
        int moleculeheight = number*100;
        if(width>-1){
            moleculewidth=width;
            moleculeheight=height;
        }
        if(moleculeheight<200 || moleculewidth<200){
          r2dm.setIsCompact(true);
          r2dm.setBondDistance(3);
        }
        Rectangle drawArea = new Rectangle(moleculewidth, moleculeheight);
        renderer.setup(cdkmol, drawArea);
        DOMImplementation domImpl = GenericDOMImplementation.getDOMImplementation();
        Document document = domImpl.createDocument(null, "svg", null);
        SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
        svgGenerator.setBackground(Color.LIGHT_GRAY);
        svgGenerator.setColor(Color.LIGHT_GRAY);
        svgGenerator.fill(new Rectangle(0, 0, moleculewidth, moleculeheight));
        renderer.paintMolecule(cdkmol, new AWTDrawVisitor(svgGenerator), drawArea, false);
        boolean useCSS = false;
        baos = new ByteArrayOutputStream();
        Writer outwriter = new OutputStreamWriter(baos, "UTF-8");
        StringBuffer sb = new StringBuffer();
        svgGenerator.stream(outwriter, useCSS);
View Full Code Here

TOP

Related Classes of org.openscience.jchempaint.renderer.Renderer

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.