Package org.openscience.cdk.renderer.elements

Examples of org.openscience.cdk.renderer.elements.ElementGroup


      return null;
    double d = model.getBondLength() / model.getScale();
    Rectangle2D totalBounds = Renderer.calculateBounds(reaction);
        if (totalBounds == null) return null;
       
        ElementGroup diagram = new ElementGroup();
        diagram.add(new RectangleElement(totalBounds.getMinX()-d,
                                    totalBounds.getMaxY()+d,
                                    totalBounds.getMaxX()+d,
                                    totalBounds.getMinY()-d,
                                    model.getForeColor()));
        if (reaction.getID() != null) {
          diagram.add(new TextElement((totalBounds.getMinX()
                                      +totalBounds.getMaxX())/2,
                                      totalBounds.getMinY()-d,
                                      reaction.getID(),
                                      model.getForeColor()));
        }
View Full Code Here


            boolean filled = jcpModel.getHighlightShapeFilled();
            Color highlightColor = jcpModel.getHoverOverColor();
            return new OvalElement(p.x, p.y, radius, filled, highlightColor);
        }
       
        return new ElementGroup();
    }
View Full Code Here

    }

    //ToDO find a better place for this
    jcpModel.setShowMoleculeTitle(true);

    ElementGroup diagram = new ElementGroup();

    boolean acDetachedFromRGroup=true;

    if (ac==rGroupQuery.getRootStructure()) {
View Full Code Here

        }
        return diagram;
    }

    private IRenderingElement generateDiagram(IReaction reaction) {
        ElementGroup diagram = new ElementGroup();

        for (IReactionGenerator generator : this.reactionGenerators) {
            diagram.add(generator.generate(reaction, rendererModel));
        }

        diagram.add(generateDiagram(reaction.getReactants()));
        diagram.add(generateDiagram(reaction.getProducts()));

        return diagram;
    }
View Full Code Here

        return diagram;
    }

    private IRenderingElement generateDiagram(IAtomContainerSet moleculeSet) {
        ElementGroup diagram = new ElementGroup();
        for (int i = 0; i < moleculeSet.getAtomContainerCount(); i++) {
            IAtomContainer ac = moleculeSet.getAtomContainer(i);
            for (IGenerator generator : this.generators) {
                diagram.add(generator.generate(ac, this.rendererModel));
            }
        }
        return diagram;
    }
View Full Code Here

    public MergeAtomsGenerator() {}

    @Override
    public IRenderingElement generate(IAtomContainer ac, RendererModel model) {
        JChemPaintRendererModel jcpModel = (JChemPaintRendererModel) model;
      ElementGroup selectionElements = new ElementGroup();
      double radius = jcpModel.getHighlightDistance() / jcpModel.getScale();
      radius /= 2.0;
      for(IAtom atom : model.getMerge().keySet()){
        Point2d p1 = atom.getPoint2d();
        Point2d p2 = model.getMerge().get( atom ).getPoint2d();

            // the element size has to be scaled to model space
            // so that it can be scaled back to screen space...
        PathBuilder pb = new PathBuilder();
        pb.color( jcpModel.getHoverOverColor() );

        Vector2d vec = new Vector2d();
        vec.sub( p2, p1 );

        Vector2d per = GeometryTools.calculatePerpendicularUnitVector( p1, p2 );
        per.scale( radius );
        Vector2d per2 = new Vector2d();
        per2.scale( -1 ,per);

        Vector2d v1= new Vector2d(vec);
        Vector2d v2= new Vector2d();

        v1.normalize();
        v1.scale( radius );
        v2.scale( -1, v1 );

        Point2d f1 = new Point2d();
        Point2d f2 = new Point2d();
        Point2d f3 = new Point2d();
        Point2d s1 = new Point2d();
        Point2d s2 = new Point2d();
        Point2d s3 = new Point2d();

        f1.add( p1, per );
        f2.add( p1 , v2 );
        f3.add( p1, per2 );

        s1.add(p2, per2);
        s2.add(p2, v1);
        s3.add( p2, per );


        pb.moveTo(f1).quadTo( f2,f3 ).lineTo( s1 ).quadTo( s2, s3 ).close();

        selectionElements.add(pb.createPath());

        }

        return selectionElements;
    }
View Full Code Here

    @Override
    public IRenderingElement generate(IAtomContainer ac, RendererModel model) {
        JChemPaintRendererModel jcpModel = (JChemPaintRendererModel) model;
        if(model.getExternalSelectedPart()==null)
            return new ElementGroup();
        Color selectionColor = jcpModel.getExternalHighlightColor();
        IChemObjectSelection selection = new AtomContainerSelection(model.getExternalSelectedPart());
        return generate(selection, selectionColor, jcpModel);
    }
View Full Code Here

    @Override
    public IRenderingElement generate(IAtomContainer ac, RendererModel model) {
        JChemPaintRendererModel jcpModel = (JChemPaintRendererModel) model;
        if(model.getExternalSelectedPart()==null)
            return new ElementGroup();
        Color selectionColor = jcpModel.getExternalHighlightColor();
        IChemObjectSelection selection = new AtomContainerSelection(model.getExternalSelectedPart());
        return generate(selection, selectionColor, jcpModel);
    }
View Full Code Here

  public AtomNumberGenerator() {}

  public IRenderingElement generate(IAtomContainer ac, RendererModel model) {
        JChemPaintRendererModel jcpModel = (JChemPaintRendererModel) model;
    ElementGroup numbers = new ElementGroup();
    if (!jcpModel.drawNumbers()) return numbers;

    int number = 1;
    for (IAtom atom : ac.atoms()) {
      Point2d p = atom.getPoint2d();
      numbers.add(
          new TextElement(
              p.x, p.y, String.valueOf(number), Color.BLACK));
      number++;
    }
    return numbers;
View Full Code Here

public class BoundsGenerator implements IReactionGenerator {
   
    public BoundsGenerator() {}
   
    public IRenderingElement generate(IReaction reaction, JChemPaintRendererModel model) {
        ElementGroup elementGroup = new ElementGroup();
        IAtomContainerSet reactants = reaction.getReactants();
        if (reactants != null) {
            elementGroup.add(this.generate(reactants, model));
        }
       
        IAtomContainerSet products = reaction.getProducts();
        if (products != null) {
            elementGroup.add(this.generate(products, model));
        }
       
        return elementGroup;
    }
View Full Code Here

TOP

Related Classes of org.openscience.cdk.renderer.elements.ElementGroup

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.