Class BasicAtomGenerator
- java.lang.Object
-
- org.openscience.cdk.renderer.generators.BasicAtomGenerator
-
- All Implemented Interfaces:
IGenerator<IAtomContainer>
- Direct Known Subclasses:
AtomMassGenerator
,ExtendedAtomGenerator
public class BasicAtomGenerator extends Object implements IGenerator<IAtomContainer>
Generates basicIRenderingElement
s for atoms in an atom container.- Source code:
- main
- Belongs to CDK module:
- renderbasic
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BasicAtomGenerator.AtomColor
Class to hold the color by which atom labels are drawn.static class
BasicAtomGenerator.AtomColorer
IAtomColorer
used to draw elements.static class
BasicAtomGenerator.AtomRadius
Magic number with unknown units that defines the radius around an atom, e.g.static class
BasicAtomGenerator.ColorByType
Boolean property that triggers atoms to be colored by type when set to true.static class
BasicAtomGenerator.CompactAtom
Boolean parameters that will cause atoms to be drawn as filled shapes when set to true.static class
BasicAtomGenerator.CompactShape
Shape to be used when drawing atoms in compact mode, as defined by theBasicAtomGenerator.CompactAtom
parameter.static class
BasicAtomGenerator.KekuleStructure
Determines whether structures should be drawn as Kekule structures, thus giving each carbon element explicitly, instead of not displaying the element symbol.static class
BasicAtomGenerator.Shape
When atoms are selected or in compact mode, they will be covered by a shape determined by this enumeration.static class
BasicAtomGenerator.ShowEndCarbons
Boolean parameters that will show carbons with only one (non-hydrogen) neighbor to be drawn with an element symbol.static class
BasicAtomGenerator.ShowExplicitHydrogens
Boolean property that triggers explicit hydrogens to be drawn if set to true.
-
Constructor Summary
Constructors Constructor Description BasicAtomGenerator()
An empty constructor necessary for reflection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
canDraw(IAtom atom, IAtomContainer container, RendererModel model)
Checks an atom to see if it should be drawn.IRenderingElement
generate(IAtomContainer atomContainer, IAtom atom, RendererModel model)
Generate the rendering element(s) for a particular atom.IRenderingElement
generate(IAtomContainer container, RendererModel model)
Converts aIChemObject
from the chemical data model into something that can be drawn in the chemical drawing.IRenderingElement
generateCompactElement(IAtom atom, RendererModel model)
Generate a compact element for an atom, such as a circle or a square, rather than text element.AtomSymbolElement
generateElement(IAtom atom, int alignment, RendererModel model)
Generate an atom symbol element.protected Color
getAtomColor(IAtom atom, RendererModel model)
Returns the drawing color of the given atom.List<IGeneratorParameter<?>>
getParameters()
Returns the list ofIGeneratorParameter
for this particular generator.protected boolean
hasCoordinates(IAtom atom)
Checks an atom to see if it has 2D coordinates.protected boolean
invisibleCarbon(IAtom atom, IAtomContainer atomContainer, RendererModel model)
Checks an atom to see if it is an 'invisible carbon' - that is, it is: a) a carbon atom and b) this carbon should not be shown.protected boolean
invisibleHydrogen(IAtom atom, RendererModel model)
Checks an atom to see if it is an 'invisible hydrogen' - that is, it is a) an (explicit) hydrogen, and b) explicit hydrogens are set to off.protected boolean
isHydrogen(IAtom atom)
Determines if the atom is a hydrogen.protected boolean
showCarbon(IAtom carbonAtom, IAtomContainer container, RendererModel model)
Checks a carbon atom to see if it should be shown.
-
-
-
Method Detail
-
generate
public IRenderingElement generate(IAtomContainer container, RendererModel model)
Converts aIChemObject
from the chemical data model into something that can be drawn in the chemical drawing.- Specified by:
generate
in interfaceIGenerator<IAtomContainer>
- Parameters:
container
- the chemical entity to be depictedmodel
- the rendering parameters- Returns:
- a drawable chemical depiction component
-
hasCoordinates
protected boolean hasCoordinates(IAtom atom)
Checks an atom to see if it has 2D coordinates.- Parameters:
atom
- the atom to check- Returns:
- true if the atom is not null, and it has non-null coordinates
-
isHydrogen
protected boolean isHydrogen(IAtom atom)
Determines if the atom is a hydrogen.- Parameters:
atom
-IAtom
to be tested- Returns:
- true, if the atom is a hydrogen, and false, otherwise.
-
invisibleHydrogen
protected boolean invisibleHydrogen(IAtom atom, RendererModel model)
Checks an atom to see if it is an 'invisible hydrogen' - that is, it is a) an (explicit) hydrogen, and b) explicit hydrogens are set to off.- Parameters:
atom
- the atom to checkmodel
- the renderer model- Returns:
- true if this atom should not be shown
-
invisibleCarbon
protected boolean invisibleCarbon(IAtom atom, IAtomContainer atomContainer, RendererModel model)
Checks an atom to see if it is an 'invisible carbon' - that is, it is: a) a carbon atom and b) this carbon should not be shown.- Parameters:
atom
- the atom to checkatomContainer
- the atom container the atom is part ofmodel
- the renderer model- Returns:
- true if this atom should not be shown
-
canDraw
protected boolean canDraw(IAtom atom, IAtomContainer container, RendererModel model)
Checks an atom to see if it should be drawn. There are three reasons not to draw an atom - a) no coordinates, b) an invisible hydrogen or c) an invisible carbon.- Parameters:
atom
- the atom to checkcontainer
- the atom container the atom is part ofmodel
- the renderer model- Returns:
- true if the atom should be drawn
-
generate
public IRenderingElement generate(IAtomContainer atomContainer, IAtom atom, RendererModel model)
Generate the rendering element(s) for a particular atom.- Parameters:
atomContainer
- the atom container that the atom is fromatom
- the atom to generate the rendering element formodel
- the renderer model- Returns:
- a rendering element, or group of elements
-
generateCompactElement
public IRenderingElement generateCompactElement(IAtom atom, RendererModel model)
Generate a compact element for an atom, such as a circle or a square, rather than text element.- Parameters:
atom
- the atom to generate the compact element formodel
- the renderer model- Returns:
- a compact rendering element
-
generateElement
public AtomSymbolElement generateElement(IAtom atom, int alignment, RendererModel model)
Generate an atom symbol element.- Parameters:
atom
- the atom to usealignment
- the alignment of the atom's labelmodel
- the renderer model- Returns:
- an atom symbol element
-
showCarbon
protected boolean showCarbon(IAtom carbonAtom, IAtomContainer container, RendererModel model)
Checks a carbon atom to see if it should be shown.- Parameters:
carbonAtom
- the carbon atom to checkcontainer
- the atom containermodel
- the renderer model- Returns:
- true if the carbon should be shown
-
getAtomColor
protected Color getAtomColor(IAtom atom, RendererModel model)
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.
-
getParameters
public List<IGeneratorParameter<?>> getParameters()
Returns the list ofIGeneratorParameter
for this particular generator.- Specified by:
getParameters
in interfaceIGenerator<IAtomContainer>
- Returns:
- a
List
ofIGeneratorParameter
s
-
-