• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java RendererModel类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.openscience.cdk.renderer.RendererModel的典型用法代码示例。如果您正苦于以下问题:Java RendererModel类的具体用法?Java RendererModel怎么用?Java RendererModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

RendererModel类属于org.openscience.cdk.renderer包,在下文中一共展示了RendererModel类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: generateImage

点赞 2

import org.openscience.cdk.renderer.RendererModel; //导入依赖的package包/类
/**
 * draw image and return it as RenderedImage
 * 
 * @param structure
 * @return
 * @throws CDKException
 */
public RenderedImage generateImage(final IAtomContainer structure) {
	Image image = new BufferedImage(this.imageWidth, this.imageHeight, BufferedImage.TYPE_INT_ARGB);
	Graphics2D g2 = (Graphics2D) image.getGraphics();
	g2.setColor(new Color(1.0f, 1.0f, 1.0f, 0.0f));
	g2.fillRect(0, 0, this.imageWidth, this.imageHeight);
	try {
		IAtomContainer moleculeToDraw = AtomContainerManipulator.removeHydrogens(structure);

		Rectangle drawArea = new Rectangle(this.imageWidth, this.imageHeight);

		AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(moleculeToDraw);
		for(int i = 0; i < moleculeToDraw.getAtomCount(); i++) 
			moleculeToDraw.getAtom(i).setProperty(StandardGenerator.ANNOTATION_LABEL, i + "");
		for(int i = 0; i < moleculeToDraw.getBondCount(); i++) 
			moleculeToDraw.getBond(i).setProperty(StandardGenerator.ANNOTATION_LABEL, i + "");
		
		StructureDiagramGenerator sdg = new StructureDiagramGenerator();
           sdg.setMolecule(moleculeToDraw);
           sdg.generateCoordinates();
		this.renderer.setup(sdg.getMolecule(), drawArea);
		RendererModel rendererModel = this.renderer.getRenderer2DModel();
		rendererModel.set(StandardGenerator.Visibility.class, SymbolVisibility.iupacRecommendations());
   		rendererModel.set(StandardGenerator.AtomColor.class, new CDK2DAtomColors()); 
   		rendererModel.set(StandardGenerator.AnnotationColor.class, new Color(0x455FFF));
   		rendererModel.set(StandardGenerator.StrokeRatio.class, this.strokeRatio);
		Rectangle2D bounds = new Rectangle2D.Double(0, 0, this.imageWidth, this.imageHeight);
		
		this.renderer.paint(sdg.getMolecule(), new AWTDrawVisitor(g2), bounds, true);

	} catch (Exception e) {
		return (RenderedImage) image;
	}
	return (RenderedImage) image;
}
 

开发者ID:c-ruttkies,
项目名称:MetFragRelaunched,
代码行数:42,
代码来源:AnnotatedStandardSingleStructureImageGenerator.java

示例2: generateImage

点赞 2

import org.openscience.cdk.renderer.RendererModel; //导入依赖的package包/类
/**
 * draw image and return it as RenderedImage
 * 
 * @param structure
 * @return
 * @throws CDKException
 */
public RenderedImage generateImage(final IAtomContainer structure) {
	Image image = new BufferedImage(this.imageWidth, this.imageHeight, BufferedImage.TYPE_INT_ARGB);
	Graphics2D g2 = (Graphics2D) image.getGraphics();
	g2.setColor(this.backgroundColor);
	g2.fillRect(0, 0, this.imageWidth, this.imageHeight);
	try {
		IAtomContainer moleculeToDraw = AtomContainerManipulator.removeHydrogens(structure);

		Rectangle drawArea = new Rectangle(this.imageWidth, this.imageHeight);

		AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(moleculeToDraw);
		StructureDiagramGenerator sdg = new StructureDiagramGenerator();
           sdg.setMolecule(moleculeToDraw);
           sdg.generateCoordinates();
		this.renderer.setup(sdg.getMolecule(), drawArea);
		RendererModel rendererModel = this.renderer.getRenderer2DModel();
		rendererModel.set(StandardGenerator.Visibility.class, SymbolVisibility.iupacRecommendations());
   		rendererModel.set(StandardGenerator.AtomColor.class, new CDK2DAtomColors());
   		rendererModel.set(StandardGenerator.StrokeRatio.class, this.strokeRatio);
		Rectangle2D bounds = new Rectangle2D.Double(0, 0, this.imageWidth, this.imageHeight);
		
		this.renderer.paint(sdg.getMolecule(), new AWTDrawVisitor(g2), bounds, true);

	} catch (Exception e) {
		return (RenderedImage) image;
	}
	return (RenderedImage) image;
}
 

开发者ID:c-ruttkies,
项目名称:MetFragRelaunched,
代码行数:36,
代码来源:StandardSingleStructureImageGenerator.java

示例3: Structure2DComponent

点赞 2

import org.openscience.cdk.renderer.RendererModel; //导入依赖的package包/类
public Structure2DComponent(String structure) throws CDKException,
    IOException {

// Create a silend CDK builder
IChemObjectBuilder builder = SilentChemObjectBuilder.getInstance();

// Create a new molecule instance
molecule = builder.newInstance(IAtomContainer.class);

// Load the structure into the molecule
MDLV2000Reader molReader = new MDLV2000Reader(new StringReader(
	structure));
molReader.read(molecule);
molReader.close();

// Suppress the hydrogens
AtomContainerManipulator.suppressHydrogens(molecule);

// If the model has no coordinates, let's generate them
if (!GeometryUtil.has2DCoordinates(molecule)) {
    StructureDiagramGenerator sdg = new StructureDiagramGenerator();
    sdg.setMolecule(molecule, false);
    sdg.generateCoordinates();
}

// Generators make the image elements
Font font = new Font("Verdana", Font.PLAIN, 14);
List<IGenerator<IAtomContainer>> generators = new ArrayList<IGenerator<IAtomContainer>>();
generators.add(new BasicSceneGenerator());
generators.add(new StandardGenerator(font));

// Renderer needs to have a toolkit-specific font manager
renderer = new AtomContainerRenderer(generators, new AWTFontManager());

// Set default atom colors for the renderer
RendererModel rendererModel = renderer.getRenderer2DModel();
rendererModel.set(StandardGenerator.AtomColor.class,
	new CDK2DAtomColors());

   }
 

开发者ID:mzmine,
项目名称:mzmine2,
代码行数:41,
代码来源:Structure2DComponent.java

示例4: getAtomColor

点赞 2

import org.openscience.cdk.renderer.RendererModel; //导入依赖的package包/类
/**
   * Returns the drawing color of the given atom. An atom is colored as
   * highlighted if highlighted. The atom is color marked if in a
   * substructure. If not, the color from the CDK2DAtomColor is used (if
   * selected). Otherwise, the atom is colored black.
   */
  @TestMethod("getAtomColorTest")
protected Color getAtomColor(IAtom atom, RendererModel model) {
    Color atomColor = model.get(AtomColor.class);
    if ((Boolean)model.get(ColorByType.class)) {
        atomColor = ((IAtomColorer)model.get(AtomColorer.class)).getAtomColor(atom);
      }
      return atomColor;
  }
 

开发者ID:yoann-dufresne,
项目名称:Smiles2Monomers,
代码行数:15,
代码来源:ColoredAtomGenerator.java

示例5: Depiction

点赞 2

import org.openscience.cdk.renderer.RendererModel; //导入依赖的package包/类
Depiction(IRenderingElement primitives, IAtomContainer container, RendererModel params) {
    this.primitives = primitives;
    this.container = container;
    this.parameters = params;
    this.scale = params.get(BasicSceneGenerator.Scale.class);
    this.margin = params.get(BasicSceneGenerator.Margin.class);
    this.diagramBounds = getBounds(primitives, container);
}
 

开发者ID:johnmay,
项目名称:efficient-bits,
代码行数:9,
代码来源:Depiction.java

示例6: SetDepiction

点赞 2

import org.openscience.cdk.renderer.RendererModel; //导入依赖的package包/类
SetDepiction(List<IRenderingElement> diagrams, List<IAtomContainer> containers, RendererModel params) {

        this.diagrams = diagrams;
        this.containers = containers;
        this.bounds = new ArrayList<Rectangle2D>();
        for (int i = 0; i < diagrams.size(); i++)
            bounds.add(getBounds(diagrams.get(i), containers.get(i)));
        this.parameters = params;
        this.scale = params.get(BasicSceneGenerator.Scale.class);
        this.margin = params.get(BasicSceneGenerator.Margin.class);
        setLayout(Layout.Horizontal);
    }
 

开发者ID:johnmay,
项目名称:efficient-bits,
代码行数:13,
代码来源:SetDepiction.java

示例7: generateImage

点赞 2

import org.openscience.cdk.renderer.RendererModel; //导入依赖的package包/类
public RenderedImage generateImage(final DefaultBitArrayFragment structure) {
	Image image = new BufferedImage(this.imageWidth, this.imageHeight, BufferedImage.TYPE_INT_ARGB);
	try {
		IAtomContainer molecule = new AtomContainer(structure.getPrecursor().getStructureAsIAtomContainer());
		StructureDiagramGenerator sdg = new StructureDiagramGenerator();
		sdg.setMolecule(molecule);
		sdg.generateCoordinates();

		Rectangle drawArea = new Rectangle(this.imageWidth, this.imageHeight);

		IAtomContainer moleculeToDraw = sdg.getMolecule();
		this.renderer.setup(sdg.getMolecule(), drawArea);

		RendererModel rendererModel = this.renderer.getRenderer2DModel();
		//rendererModel.set(StandardGenerator.Visibility.class, SelectionVisibility.iupacRecommendations());
		//rendererModel.set(StandardGenerator.AtomColor.class, new CDK2DAtomColors());
		rendererModel.set(StandardGenerator.Highlighting.class, StandardGenerator.HighlightStyle.OuterGlow);
   		rendererModel.set(StandardGenerator.StrokeRatio.class, this.strokeRatio);

		BitArray atoms = structure.getAtomsBitArray();
		for (int i = 0; i < atoms.getSize(); i++) {
			if(atoms.get(i)) moleculeToDraw.getAtom(i).setProperty(StandardGenerator.HIGHLIGHT_COLOR, new Color(0x98F08E));
			else moleculeToDraw.getAtom(i).removeProperty(StandardGenerator.HIGHLIGHT_COLOR);
		}

		BitArray bonds = structure.getBondsBitArray();
		for (int i = 0; i < bonds.getSize(); i++) {
			if(bonds.get(i)) moleculeToDraw.getBond(i).setProperty(StandardGenerator.HIGHLIGHT_COLOR, new Color(0x98F08E));
			else moleculeToDraw.getBond(i).removeProperty(StandardGenerator.HIGHLIGHT_COLOR);
		}

		Rectangle2D bounds = new Rectangle2D.Double(0, 0, this.imageWidth, this.imageHeight);
		
		Graphics2D g2 = (Graphics2D) image.getGraphics();
		g2.setColor(new Color(1.0f, 1.0f, 1.0f, 0.0f));
		g2.fillRect(0, 0, this.imageWidth, this.imageHeight);
		this.renderer.paint(moleculeToDraw, new AWTDrawVisitor(g2), bounds, true);
	} catch (Exception e) {
		return (RenderedImage) image;
	}
	return (RenderedImage) image;
}
 

开发者ID:c-ruttkies,
项目名称:MetFragRelaunched,
代码行数:43,
代码来源:HighlightSubStructureImageGenerator.java

示例8: DepictionGenerator

点赞 2

import org.openscience.cdk.renderer.RendererModel; //导入依赖的package包/类
DepictionGenerator(List<IGenerator<IAtomContainer>> generators) {
    this.generators = generators;
    this.parameters = new RendererModel();
    for (IGenerator<IAtomContainer> generator : generators)
        parameters.registerParameters(generator);
}
 

开发者ID:johnmay,
项目名称:efficient-bits,
代码行数:7,
代码来源:DepictionGenerator.java

示例9: getRendererModel2D

点赞 2

import org.openscience.cdk.renderer.RendererModel; //导入依赖的package包/类
RendererModel getRendererModel2D() {
    return parameters;
}
 

开发者ID:johnmay,
项目名称:efficient-bits,
代码行数:4,
代码来源:DepictionGenerator.java

示例10: invisibleCarbon

点赞 2

import org.openscience.cdk.renderer.RendererModel; //导入依赖的package包/类
public boolean invisibleCarbon(IAtom atom, IAtomContainer container, RendererModel model)
{
    return (isCarbon(atom) && !shouldShowCarbons);
}
 

开发者ID:dhmay,
项目名称:msInspect,
代码行数:5,
代码来源:MoleculeRenderer2D.java

示例11: invisibleHydrogen

点赞 2

import org.openscience.cdk.renderer.RendererModel; //导入依赖的package包/类
public boolean invisibleHydrogen(IAtom atom, RendererModel model)
{
    return (isHydrogen(atom) && !shouldShowHydrogens);
}
 

开发者ID:dhmay,
项目名称:msInspect,
代码行数:5,
代码来源:MoleculeRenderer2D.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)