Package org.openscience.cdk.renderer.elements

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


        return generate(selection, selectionColor, jcpModel);
    }
   
    protected IRenderingElement generate(IChemObjectSelection selection, Color selectionColor, JChemPaintRendererModel model){

        ElementGroup selectionElements = new ElementGroup();
        if(selection==null)
          return selectionElements;
        if (this.autoUpdateSelection || selection.isFilled()) {
            IAtomContainer selectedAC = selection.getConnectedAtomContainer();
           
            if (selectedAC != null) {
              super.setOverrideColor(selectionColor);
              super.setOverrideBondWidth(model.getSelectionRadius());
              selectionElements.add(super.generate(selectedAC, model));
            }
        }

        if (selection instanceof IncrementalSelection) {
      IncrementalSelection sel = (IncrementalSelection) selection;
      if (!sel.isFinished())
        selectionElements.add(sel.generate(selectionColor));
    }
        return selectionElements;
    }
View Full Code Here


    }

    public IRenderingElement generate(IAtomContainer ac, RendererModel model) {
        JChemPaintRendererModel jcpModel = (JChemPaintRendererModel) model;
        if(hub.getPhantomArrow()[0]==null || hub.getPhantomArrow()[1]==null)
            return new ElementGroup();
        else
            return new ArrowElement(hub.getPhantomArrow()[0].x,
                    hub.getPhantomArrow()[0].y,
                    hub.getPhantomArrow()[1].x,
                    hub.getPhantomArrow()[1].y,
View Full Code Here

    public MappingGenerator() {}

    public IRenderingElement generate(IReaction reaction, JChemPaintRendererModel model) {
    if(!model.getShowAtomAtomMapping())
      return null;
        ElementGroup elementGroup = new ElementGroup();
        Color mappingColor = model.getAtomAtomMappingLineColor();
        for (IMapping mapping : reaction.mappings()) {
            // XXX assume that there are only 2 endpoints!
            // XXX assume that the ChemObjects are actually IAtoms...
            IAtom endPointA = (IAtom) mapping.getChemObject(0);
            IAtom endPointB = (IAtom) mapping.getChemObject(1);
            Point2d pA = endPointA.getPoint2d();
            Point2d pB = endPointB.getPoint2d();
            elementGroup.add(
                    new LineElement(pA.x, pA.y, pB.x, pB.y, getWidthForMappingLine(model), mappingColor));
        }
        return elementGroup;
    }
View Full Code Here

          return null;
       
        double d = jcpModel.getBondLength() / jcpModel.getScale()/2;
        Rectangle2D totalBounds = Renderer.calculateBounds(ac);
       
        ElementGroup diagram = new ElementGroup();
        double minX = totalBounds.getMinX();
        double minY = totalBounds.getMinY();
        double maxX = totalBounds.getMaxX();
        double maxY = totalBounds.getMaxY();
        Color c = Color.GRAY;
        diagram.add(new TextElement(
                        (minX+maxX)/2, minY-d, (String)ac.getProperty(CDKConstants.TITLE), c,0.8));
        return diagram;
    }
View Full Code Here

  public IRenderingElement generate(IReaction reaction, JChemPaintRendererModel model) {
    if(!model.getShowReactionBoxes())
      return null;
      if (reaction.getProductCount() == 0)
        return new ElementGroup();
    DISTANCE = model.getBondLength() / model.getScale() / 2;
        Rectangle2D totalBounds = null;
        for (IAtomContainer molecule : reaction.getProducts().atomContainers()) {
            Rectangle2D bounds = Renderer.calculateBounds(molecule);
            if (totalBounds == null) {
                totalBounds = bounds;
            } else {
                totalBounds = totalBounds.createUnion(bounds);
            }
        }
        if (totalBounds == null) return null;
       
        ElementGroup diagram = new ElementGroup();
        diagram.add(new RectangleElement(totalBounds.getMinX()-DISTANCE,
                                    totalBounds.getMaxY()+DISTANCE,
                                    totalBounds.getMaxX()+DISTANCE,
                                    totalBounds.getMinY()-DISTANCE,
                                    model.getForeColor()));
        diagram.add(new TextElement((totalBounds.getMinX()+totalBounds.getMaxX())/2, totalBounds.getMinY()-DISTANCE, "Products", model.getForeColor()));
        return diagram;
  }
View Full Code Here

        IChemObjectSelection selection = jcpModel.getSelection();
        return generate(selection, selectionColor, jcpModel);
    }
   
    protected IRenderingElement generate(IChemObjectSelection selection, Color selectionColor, JChemPaintRendererModel model){
        ElementGroup selectionElements = new ElementGroup();

        if(selection==null)
            return selectionElements;
        if (this.autoUpdateSelection || selection.isFilled()) {
            double r = model.getSelectionRadius() / model.getScale();

            double d = 4 * r;
            IAtomContainer selectedAC = selection.getConnectedAtomContainer();
            if (selectedAC != null) {
                for (IAtom atom : selectedAC.atoms()) {
                    Point2d p = atom.getPoint2d();
                    IRenderingElement element;
                    element = new OvalElement(
                          p.x, p.y, d, false, selectionColor);
                    selectionElements.add(element);
                }
            }
        }
        return selectionElements;
    }
View Full Code Here

   
    public LonePairGenerator() {}

    public IRenderingElement generate(IAtomContainer ac, RendererModel model) {
        JChemPaintRendererModel jcpModel = (JChemPaintRendererModel) model;
        ElementGroup group = new ElementGroup();
       
        // TODO : put into RendererModel
        final double SCREEN_RADIUS = 1.0;
        // separation between centers
        final double SCREEN_SEPARATION = 2.5;  
        final Color RADICAL_COLOR = Color.BLACK;
       
        // XXX : is this the best option?
        final double ATOM_RADIUS = jcpModel.getAtomRadius();
       
        double scale = jcpModel.getScale();
        double modelAtomRadius = ATOM_RADIUS / scale;
        double modelPointRadius = SCREEN_RADIUS / scale;
        double modelSeparation = SCREEN_SEPARATION / scale;
        for (ILonePair lp : ac.lonePairs()) {
            IAtom atom = lp.getAtom();
            Point2d p = atom.getPoint2d();
            int align = GeometryTools.getBestAlignmentForLabelXY(ac, atom);
            double rx = p.x;
            double ry = p.y;
            double dx = 0;
            double dy = 0;
            if (align == 1) {
                rx += modelAtomRadius;
                dy += modelSeparation;
            } else if (align == -1) {
                rx -= modelAtomRadius;
                dy += modelSeparation;
            } else if (align == 2) {
                ry -= modelAtomRadius;
                dx += modelSeparation;
            } else if (align == -2) {
                ry += modelAtomRadius;
                dx += modelSeparation;
            }
            group.add(
                    new OvalElement(rx + dx, ry + dy,
                            modelPointRadius, true, RADICAL_COLOR));
            group.add(
                    new OvalElement(rx - dx, ry - dy,
                            modelPointRadius, true, RADICAL_COLOR));
        }
        return group;
    }
View Full Code Here

            Color hColor = jcpModel.getHoverOverColor();
            Point2d p = bond.get2DCenter();
            boolean filled = jcpModel.getHighlightShapeFilled();
            return new OvalElement(p.x, p.y, r, filled, hColor);
        }
        return new ElementGroup();
    }
View Full Code Here

  public IRenderingElement generate(IReaction reaction, JChemPaintRendererModel model) {
    if (!model.getShowReactionBoxes())
      return null;
      if (reaction.getReactantCount() == 0)
        return new ElementGroup();
     
    double d = model.getBondLength() / model.getScale()/2;
        Rectangle2D totalBounds = Renderer.calculateBounds(reaction.getReactants());
       
        ElementGroup diagram = new ElementGroup();
        double minX = totalBounds.getMinX();
        double minY = totalBounds.getMinY();
        double maxX = totalBounds.getMaxX();
        double maxY = totalBounds.getMaxY();
        Color c = model.getForeColor();
        diagram.add(new RectangleElement(
                        minX - d, maxY + d, maxX + d, minY - d, c));
        diagram.add(new TextElement(
                        (minX+maxX)/2, minY-d, "Reactants", c));
        return diagram;
  }
View Full Code Here

   
    public RadicalGenerator() {}

    public IRenderingElement generate(IAtomContainer ac, RendererModel model) {
        JChemPaintRendererModel jcpModel = (JChemPaintRendererModel) model;
        ElementGroup group = new ElementGroup();
       
        // TODO : put into RendererModel
        final double SCREEN_RADIUS = 2.0;
        final Color RADICAL_COLOR = Color.BLACK;
       
        // XXX : is this the best option?
        final double ATOM_RADIUS = jcpModel.getAtomRadius() / jcpModel.getScale();
       
        double modelRadius = SCREEN_RADIUS / jcpModel.getScale();
        Map<IAtom,Integer> singleElectronsPerAtom = new HashMap<IAtom, Integer>();
        for (ISingleElectron e : ac.singleElectrons()) {
            IAtom atom = e.getAtom();
            if(singleElectronsPerAtom.get(atom)==null)
                singleElectronsPerAtom.put(atom,0);
            Point2d p = atom.getPoint2d();
            int align = GeometryTools.getBestAlignmentForLabelXY(ac, atom);
            double rx = p.x;
            double ry = p.y;
            if (align == 1) {
                rx += ATOM_RADIUS+singleElectronsPerAtom.get(atom)*ATOM_RADIUS;
            } else if (align == -1) {
                rx -= ATOM_RADIUS+singleElectronsPerAtom.get(atom)*ATOM_RADIUS;
            } else if (align == 2) {
                ry -= ATOM_RADIUS;
            } else if (align == -2) {
                ry += ATOM_RADIUS;
            }
            singleElectronsPerAtom.put(atom, singleElectronsPerAtom.get(atom)+1);
            group.add(
                    new OvalElement(rx, ry, modelRadius, true, RADICAL_COLOR));
        }
        return group;
    }
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.