public final class DepictionGenerator extends Object
with...() methods.
DepictionGenerator dg = new DepictionGenerator().withSize(512, 512)
.withAtomColors();
for (IAtomContainer mol : mols) {
dg.depict(mol).writeTo("~/mol.png");
}
new DepictionGenerator().depict(mol)
.writeTo("~/mol.png");
The intermediate Depiction object can write to many different formats
through a variety of API calls.
Depiction depiction = new DepictionGenerator().depict(mol);
// quick use, format determined by name by path
depiction.writeTo("~/mol.png");
depiction.writeTo("~/mol.svg");
depiction.writeTo("~/mol.pdf");
depiction.writeTo("~/mol.jpg");
// manually specify the format
depiction.writeTo(Depiction.SVG_FMT, "~/mol");
// convert to a Java buffered image
BufferedImage img = depiction.toImg();
// get the SVG XML string
String svg = depiction.toSvgStr();
| Modifier and Type | Field and Description |
|---|---|
static double |
AUTOMATIC
Magic value for indicating automatic parameters.
|
static double |
DEFAULT_MM_MARGIN
Default margin for vector graphics formats.
|
static double |
DEFAULT_PX_MARGIN
Default margin for raster graphics formats.
|
| Constructor and Description |
|---|
DepictionGenerator()
Create a depiction generator using the standard sans-serif
system font.
|
DepictionGenerator(Font font)
Create a depiction generator that will render atom
labels using the specified AWT font.
|
| Modifier and Type | Method and Description |
|---|---|
Depiction |
depict(IAtomContainer mol)
Depict a single molecule.
|
Depiction |
depict(IReaction rxn)
Depict a reaction.
|
Depiction |
depict(Iterable<IAtomContainer> mols)
Depict a set of molecules, they will be depicted in a grid.
|
Depiction |
depict(Iterable<IAtomContainer> mols,
int nrow,
int ncol)
Depict a set of molecules, they will be depicted in a grid with the
specified number of rows and columns.
|
DepictionGenerator |
withAnnotationColor(Color color)
Set the color annotations (e.g.
|
DepictionGenerator |
withAnnotationScale(double scale)
Set the size of annotations relative to atom symbols.
|
DepictionGenerator |
withAromaticDisplay()
When aromaticity is set on bonds, display this in the diagram.
|
DepictionGenerator |
withAtomColors()
Color atom symbols using typical colors, oxygens are red, nitrogens are
blue, etc.
|
DepictionGenerator |
withAtomColors(IAtomColorer colorer)
Color atom symbols using provided colorer.
|
DepictionGenerator |
withAtomMapHighlight()
Adds to the highlight the coloring of reaction atom-maps.
|
DepictionGenerator |
withAtomMapHighlight(Color[] colors)
Adds to the highlight the coloring of reaction atom-maps.
|
DepictionGenerator |
withAtomMapNumbers()
Display atom-atom mapping numbers on a reaction.
|
DepictionGenerator |
withAtomNumbers()
Display atom numbers on the molecule or reaction.
|
DepictionGenerator |
withAtomValues()
Display atom values on the molecule or reaction.
|
DepictionGenerator |
withBackgroundColor(Color color)
Change the background color.
|
DepictionGenerator |
withCarbonSymbols()
Display atom symbols for all atoms in the molecule.
|
DepictionGenerator |
withDeuteriumSymbol(boolean v)
Indicate whether 2H should be rendered as 'D'.
|
DepictionGenerator |
withFillToFit()
Resize depictions to fill all available space (only if a size is specified).
|
DepictionGenerator |
withHighlight(Iterable<? extends IChemObject> chemObjs,
Color color)
Highlight the provided set of atoms and bonds in the depiction in the
specified color.
|
DepictionGenerator |
withMappedRxnAlign(boolean val)
Specifies that reactions with atom-atom mappings should have their reactants/product
coordinates aligned.
|
DepictionGenerator |
withMargin(double m)
Specify a desired size of margin.
|
DepictionGenerator |
withMolTitle()
Display a molecule title with each depiction.
|
DepictionGenerator |
withOuterGlowHighlight()
Highlights are shown as an outer glow around the atom symbols and bonds
rather than recoloring.
|
DepictionGenerator |
withOuterGlowHighlight(double width)
Highlights are shown as an outer glow around the atom symbols and bonds
rather than recoloring.
|
DepictionGenerator |
withPadding(double p)
Specify a desired size of padding for molecule sets and reactions.
|
<T extends IGeneratorParameter<S>,S,U extends S> |
withParam(Class<T> key,
U value)
Low-level option method to set a rendering model parameter.
|
DepictionGenerator |
withRxnTitle()
Display a reaction title with the depiction.
|
DepictionGenerator |
withSize(double w,
double h)
Specify a desired size of depiction.
|
DepictionGenerator |
withTerminalCarbons()
Display atom symbols for terminal carbons (i.e.
|
DepictionGenerator |
withTitleColor(Color color)
Set the color titles will appear in.
|
DepictionGenerator |
withTitleScale(double scale)
Set the size of titles compared to atom symbols.
|
DepictionGenerator |
withZoom(double zoom)
Specify a desired zoom factor - this changes the base size of a
depiction and is used for uniformly making depictions bigger.
|
public static double AUTOMATIC
public static double DEFAULT_MM_MARGIN
public static double DEFAULT_PX_MARGIN
public DepictionGenerator()
public DepictionGenerator(Font font)
font - the font to use to displaypublic Depiction depict(IAtomContainer mol) throws CDKException
mol - moleculeCDKException - a depiction could not be generatedpublic Depiction depict(Iterable<IAtomContainer> mols) throws CDKException
mols - moleculesCDKException - a depiction could not be generateddepict(Iterable, int, int)public Depiction depict(Iterable<IAtomContainer> mols, int nrow, int ncol) throws CDKException
mols - moleculesnrow - number of rowsncol - number of columnsCDKException - a depiction could not be generatedpublic Depiction depict(IReaction rxn) throws CDKException
rxn - reaction instanceCDKException - a depiction could not be generatedpublic DepictionGenerator withAtomColors()
StandardGenerator.AtomColor,
StandardGenerator.Highlighting,
StandardGenerator.HighlightStyle,
CDK2DAtomColorspublic DepictionGenerator withAtomColors(IAtomColorer colorer)
StandardGenerator.AtomColor,
StandardGenerator.Highlighting,
StandardGenerator.HighlightStyle,
CDK2DAtomColors,
UniColorpublic DepictionGenerator withBackgroundColor(Color color)
color - background colorBasicSceneGenerator.BackgroundColorpublic DepictionGenerator withOuterGlowHighlight()
StandardGenerator.Highlighting,
StandardGenerator.HighlightStylepublic DepictionGenerator withOuterGlowHighlight(double width)
width - width of the outer glow relative to the bond strokeStandardGenerator.Highlighting,
StandardGenerator.HighlightStylepublic DepictionGenerator withAtomNumbers()
withAtomMapNumbers(),
StandardGenerator.ANNOTATION_LABELpublic DepictionGenerator withAtomValues()
atom.setProperty(CDKConstants.COMMENT, myValueToBeDisplayedNextToAtom);
Note: A depiction can not have both atom numbers and atom maps visible
(but this can be achieved by manually setting the annotation).withAtomMapNumbers(),
StandardGenerator.ANNOTATION_LABELpublic DepictionGenerator withAtomMapNumbers()
CDKConstants.ATOM_ATOM_MAPPING.
Note: A depiction can not have both atom numbers and atom
maps visible (but this can be achieved by manually setting
the annotation).withAtomNumbers(),
CDKConstants.ATOM_ATOM_MAPPING,
StandardGenerator.ANNOTATION_LABELpublic DepictionGenerator withAtomMapHighlight()
withAtomMapNumbers(),
withAtomMapHighlight()public DepictionGenerator withAtomMapHighlight(Color[] colors)
colors - array of colorswithAtomMapNumbers(),
withAtomMapHighlight()public DepictionGenerator withMolTitle()
CDKConstants.TITLE
property. For reactions only the main components have their
title displayed.BasicSceneGenerator.ShowMoleculeTitlepublic DepictionGenerator withRxnTitle()
CDKConstants.TITLE
property on the IReaction instance.BasicSceneGenerator.ShowReactionTitlepublic DepictionGenerator withMappedRxnAlign(boolean val)
val - setting valuepublic DepictionGenerator withAnnotationColor(Color color)
color - the color of annotationsStandardGenerator.AnnotationColorpublic DepictionGenerator withAnnotationScale(double scale)
scale - the scale of annotationsStandardGenerator.AnnotationFontScalepublic DepictionGenerator withTitleColor(Color color)
color - the color of titlesRendererModel.TitleColorpublic DepictionGenerator withTitleScale(double scale)
scale - the scale of titlesRendererModel.TitleFontScalepublic DepictionGenerator withTerminalCarbons()
StandardGenerator.Visibilitypublic DepictionGenerator withCarbonSymbols()
StandardGenerator.Visibilitypublic DepictionGenerator withHighlight(Iterable<? extends IChemObject> chemObjs, Color color)
depict(IAtomContainer)).chemObjs - set of atoms and bondscolor - the color to highlightStandardGenerator.HIGHLIGHT_COLORpublic DepictionGenerator withSize(double w, double h)
withFillToFit() option.
Currently the size must either both be precisely specified (e.g. 256x256) or
automatic (e.g. AUTOMATICxAUTOMATIC) you cannot for example
specify a fixed height and automatic width.w - max widthh - max heightwithFillToFit()public DepictionGenerator withMargin(double m)
m - marginBasicSceneGenerator.Marginpublic DepictionGenerator withPadding(double p)
p - paddingRendererModel.Paddingpublic DepictionGenerator withZoom(double zoom)
withFillToFit().
The zoom is a scaling factor, specifying a zoom of 2 is double size,
0.5 half size, etc.zoom - zoom factorBasicSceneGenerator.ZoomFactorpublic DepictionGenerator withFillToFit()
BasicSceneGenerator.FitToScreenpublic DepictionGenerator withAromaticDisplay()
StandardGenerator.DelocalisedDonutsBondDisplay.StandardGenerator.ForceDelocalisedBondDisplay,
StandardGenerator.DelocalisedDonutsBondDisplaypublic DepictionGenerator withDeuteriumSymbol(boolean v)
v - the valuepublic <T extends IGeneratorParameter<S>,S,U extends S> DepictionGenerator withParam(Class<T> key, U value)
T - option key typeU - option value typekey - option keyvalue - option valueCopyright © 2022. All rights reserved.