From: Oktay D. <gl...@go...> - 2010-03-26 10:06:01
|
Thank yout very much.....After I changed the Selection all my Substructures are highlighted: with nice regards Oktay Degirmenci 2010/3/26 gilleain torrance <gil...@gm...> > Hi Oktay, > > I think I see the problem. The LassoSelection has no points in it, so > at this call: > > selection.select(chemModel) > > none of the atoms are selected. What you need instead is the > LogicalSelection, as in: > > LogicalSelection selection = new LogicalSelect(LogicalSelection.Type.ALL); > > which should then have all the points in your highlighted fragments. > > gilleain > > On Fri, Mar 26, 2010 at 9:18 AM, Oktay Degirmenci > <gl...@go...> wrote: > > Hi Stefan, > > > > First of all thanks a lot for your help. > > Now I added the necessary Generators, but there is still no effect. > > Is it possible that I forgot a configuration in the RendererModel. > > > > My Code below: > > > > private BufferedImage renderImage( > > final Dimension dimension, > > final ChemicalEntity chemicalEntity, > > final IAtomContainer highB, > > final HashMap coordinates) { > > BufferedImage image = createImage(dimension); > > > > > > List<IGenerator> generators = new ArrayList<IGenerator>(); > > > > generators.add(new BasicBondGenerator()); > > generators.add(new BasicAtomGenerator()); > > generators.add(new SelectAtomGenerator()); > > generators.add(new SelectBondGenerator()); > > > > > > Rectangle drawArea = new Rectangle(dimension); > > Renderer renderer = new Renderer(generators, new > AWTFontManager(),true); > > // renderer.setup(highB,drawArea); > > RendererModel r2dm = renderer.getRenderer2DModel(); > > // RendererModel r2dm = new RendererModel(true); > > > > r2dm.setSelectedPartColor(Color.GREEN); > > LassoSelection selection = new LassoSelection(); > > > > > > > > > > Molecule highBmol = new Molecule(highB); > > > > > > MoleculeSet highBSet = new MoleculeSet(); > > highBSet.addMolecule(highBmol); > > > > > > ChemModel chemModel = new ChemModel(); > > chemModel.setMoleculeSet(highBSet); > > > > selection.select(chemModel); > > r2dm.setSelection(selection); > > > > double z = getZoom();// * 2; > > int width = (int) (dimension.getWidth() * z); > > int height = (int) (dimension.getHeight() * z); > > > > Font font = new Font("Arial", Font.PLAIN, (int) (12 * 2 * z)); > > > > // r2dm.setBackgroundDimension(dimension); > > r2dm.setDrawNumbers(false); > > r2dm.setColorAtomsByType(true); > > r2dm.setShowAromaticity(false); > > r2dm.setZoomFactor(z); > > r2dm.setUseAntiAliasing(true); > > r2dm.setIsCompact(false); > > > > > > Color background = getBackgroundColor(chemicalEntity); > > r2dm.setBackColor(background); > > > > Graphics2D g2d = image.createGraphics(); > > > > g2d.setColor(background); > > g2d.fillRect(0, 0, width + 15, height + 15); > > g2d.setColor(Color.black); > > > > // r2dm.setRenderingCoordinates(coordinates); > > IMolecule molecule = chemicalEntity.getMolecule(); > > > > > > > > > > renderer.setup(molecule,drawArea); > > > > MoleculeSet moleculeSet = new MoleculeSet(); > > moleculeSet.addMolecule(molecule); > > renderer.paintMoleculeSet(moleculeSet,new > AWTDrawVisitor(g2d));//, > > g2d); > > > > > > return image; > > } > > > > > > nice regards > > > > 2010/3/25 Stefan Kuhn <ste...@eb...> > >> > >> Hi Oktay, > >> where your code says: > >> > List<IGenerator> generators = new ArrayList<IGenerator>(); > >> > generators.add(new BasicBondGenerator()); > >> > generators.add(new BasicAtomGenerator()); > >> you need to add the SelectAtomGenerator and SelectBondGenerator as well. > >> Without these, no selected elements will be highlighted. > >> As a general remark: It might be usefull for the renderer, even if it is > >> not > >> used in JCP, to be able to take a list of fragments which are then > >> highlighted in different colors (the colors should be configurable as > >> well). > >> It is a reasonable requirement to do such stuff. > >> Stefan > >> > >> On Thursday 25 March 2010 13:41:56 Oktay Degirmenci wrote: > >> > Hello > >> > > >> > my Name is Oktay Degirmenci and I'm joining the molwind-projekt. > >> > I have several Molecule wich are Substructures from the same mother > >> > > >> > I wanted to mark the ismorph parts und render the molecule with the > >> > highlighted Substructure. > >> > > >> > ChemicalEntity class is n class wich carries a molecule. > >> > > >> > My Code: > >> > > >> > > >> > private IAtomContainer markSubstructure( > >> > final ChemicalEntity chemicalEntity, > >> > final ChemicalEntity[] parents) > >> > throws CDKException { > >> > IMolecule molecule = chemicalEntity.getMolecule(); > >> > ArrayList atomIndex = new ArrayList(); > >> > > >> > for (int i = 0; i < parents.length; i++) { > >> > IMolecule parentMolecule = parents[i].getMolecule(); > >> > > >> > if (UniversalIsomorphismTester. > >> > isSubgraph( > >> > molecule, parentMolecule)) { > >> > > >> > List sMap = > >> > UniversalIsomorphismTester.getSubgraphAtomsMaps( molecule, > >> > parentMolecule); > >> > Iterator it = ((List) sMap.get(0)).iterator(); > >> > > >> > > >> > while (it.hasNext()) { > >> > RMap rm = (RMap) it.next(); > >> > > >> > > >> > Integer ai = Integer.valueOf(rm.getId1()); > >> > if (!atomIndex.contains(ai)) { > >> > atomIndex.add(ai); > >> > > >> > } > >> > } > >> > } > >> > > >> > } > >> > > >> > Integer[] ato = new Integer[atomIndex.size()]; > >> > ato = (Integer[]) atomIndex.toArray(ato); > >> > Atom[] atoms = new Atom[atomIndex.size()]; > >> > for(int k = 0;k<ato.length;k++){ > >> > atoms[k] =(Atom) molecule.getAtom(ato[k]); > >> > } > >> > > >> > > >> > IAtomContainer highB = > >> > DefaultChemObjectBuilder.getInstance().newAtomContainer(); > >> > highB.setAtoms(atoms); > >> > IBond bond; > >> > > >> > for (int i = 0; i < ato.length; i++) { > >> > > >> > for (int j = i + 1; j < ato.length; j++) { > >> > bond = molecule.getBond(molecule.getAtom(ato[i]), > >> > molecule.getAtom(ato[j])); > >> > if (bond != null) { > >> > highB.addBond(bond); > >> > > >> > } > >> > } > >> > } > >> > > >> > > >> > return highB; > >> > } > >> > > >> > > >> > > >> > > >> > > >> > Now I got a Method for rendering a the Input highB is the Substructure > >> > wich > >> > has to be highlighted: > >> > > >> > > >> > private BufferedImage renderImage( > >> > final Dimension dimension, > >> > final ChemicalEntity chemicalEntity, > >> > final IAtomContainer highB, > >> > final HashMap coordinates) { > >> > BufferedImage image = createImage(dimension); > >> > List<IGenerator> generators = new ArrayList<IGenerator>(); > >> > generators.add(new BasicBondGenerator()); > >> > generators.add(new BasicAtomGenerator()); > >> > > >> > Rectangle drawArea = new Rectangle(dimension); > >> > Renderer renderer = new Renderer(generators, new > >> > AWTFontManager(),true); // renderer.setup(highB,drawArea); > >> > // RendererModel r2dm = renderer.getRenderer2DModel(); > >> > RendererModel r2dm = new RendererModel(true); > >> > > >> > r2dm.setSelectedPartColor(Color.GREEN); > >> > LassoSelection selection = new LassoSelection(); > >> > > >> > > >> > > >> > > >> > Molecule highBmol = new Molecule(highB); > >> > > >> > > >> > MoleculeSet highBSet = new MoleculeSet(); > >> > highBSet.addMolecule(highBmol); > >> > > >> > > >> > ChemModel chemModel = new ChemModel(); > >> > chemModel.setMoleculeSet(highBSet); > >> > > >> > selection.select(chemModel); > >> > r2dm.setSelection(selection); > >> > > >> > double z = getZoom();// * 2; > >> > int width = (int) (dimension.getWidth() * z); > >> > int height = (int) (dimension.getHeight() * z); > >> > > >> > Font font = new Font("Arial", Font.PLAIN, (int) (12 * 2 * z)); > >> > > >> > // r2dm.setBackgroundDimension(dimension); > >> > r2dm.setDrawNumbers(false); > >> > r2dm.setColorAtomsByType(true); > >> > r2dm.setShowAromaticity(false); > >> > r2dm.setZoomFactor(z); > >> > r2dm.setUseAntiAliasing(true); > >> > r2dm.setIsCompact(false); > >> > > >> > > >> > Color background = getBackgroundColor(chemicalEntity); > >> > r2dm.setBackColor(background); > >> > > >> > Graphics2D g2d = image.createGraphics(); > >> > > >> > g2d.setColor(background); > >> > g2d.fillRect(0, 0, width + 15, height + 15); > >> > g2d.setColor(Color.black); > >> > > >> > // r2dm.setRenderingCoordinates(coordinates); > >> > IMolecule molecule = chemicalEntity.getMolecule(); > >> > > >> > > >> > > >> > > >> > renderer.setup(molecule,drawArea); > >> > > >> > MoleculeSet moleculeSet = new MoleculeSet(); > >> > moleculeSet.addMolecule(molecule); > >> > renderer.paintMoleculeSet(moleculeSet,new > >> > AWTDrawVisitor(g2d));//, > >> > g2d); > >> > > >> > > >> > return image; > >> > } > >> > > >> > > >> > wenn i run the methods....all i got are the rendered molecule without > >> > any > >> > hihlights > >> > >> > >> > >> -- > >> Stefan Kuhn B. Sc. M. A. > >> Software Engineer in the Chemoinformatics and Metabolism Team > >> European Bioinformatics Institute (EBI) > >> Wellcome Trust Genome Campus > >> Hinxton, Cambridge CB10 1SD UK > >> Phone +44 1223 49 2657 > >> Fax +44 (0)1223 494 468 > >> > >> > >> > ------------------------------------------------------------------------------ > >> Download Intel® Parallel Studio Eval > >> Try the new software tools for yourself. Speed compiling, find bugs > >> proactively, and fine-tune applications for parallel performance. > >> See why Intel Parallel Studio got high marks during beta. > >> http://p.sf.net/sfu/intel-sw-dev > >> _______________________________________________ > >> Cdk-jchempaint mailing list > >> Cdk...@li... > >> https://lists.sourceforge.net/lists/listinfo/cdk-jchempaint > > > > > > > ------------------------------------------------------------------------------ > > Download Intel® Parallel Studio Eval > > Try the new software tools for yourself. Speed compiling, find bugs > > proactively, and fine-tune applications for parallel performance. > > See why Intel Parallel Studio got high marks during beta. > > http://p.sf.net/sfu/intel-sw-dev > > _______________________________________________ > > Cdk-jchempaint mailing list > > Cdk...@li... > > https://lists.sourceforge.net/lists/listinfo/cdk-jchempaint > > > > > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Cdk-jchempaint mailing list > Cdk...@li... > https://lists.sourceforge.net/lists/listinfo/cdk-jchempaint > |