Class BasicBondGenerator
- java.lang.Object
-
- org.openscience.cdk.renderer.generators.BasicBondGenerator
-
- All Implemented Interfaces:
IGenerator<IAtomContainer>
- Direct Known Subclasses:
RingGenerator
public class BasicBondGenerator extends Object implements IGenerator<IAtomContainer>
Generator for elements from bonds. Only two-atom bonds are supported by this generator.- Source code:
- main
- Belongs to CDK module:
- renderbasic
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BasicBondGenerator.BondDistance
The gap between double and triple bond lines on the screen.static class
BasicBondGenerator.BondWidth
The width on screen of a bond.static class
BasicBondGenerator.DefaultBondColor
The color to draw bonds if not other color is given.static class
BasicBondGenerator.TowardsRingCenterProportion
The proportion to move in towards the ring center.static class
BasicBondGenerator.WedgeWidth
The width on screen of the fat end of a wedge bond.
-
Constructor Summary
Constructors Constructor Description BasicBondGenerator()
An empty constructor necessary for reflection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
bindsHydrogen(IBond bond)
Check to see if any of the atoms in this bond are hydrogen atoms.IRenderingElement
generate(IAtomContainer container, RendererModel model)
Converts aIChemObject
from the chemical data model into something that can be drawn in the chemical drawing.IRenderingElement
generate(IBond currentBond, RendererModel model)
Generate rendering element(s) for the current bond, including ring elements if this bond is part of a ring.IRenderingElement
generateBond(IBond bond, RendererModel model)
Generate stereo or bond elements for this bond.IRenderingElement
generateBondElement(IBond bond, IBond.Order type, RendererModel model)
Generate a LineElement or an ElementGroup of LineElements for this bond.IRenderingElement
generateBondElement(IBond bond, RendererModel model)
Generate rendering elements for a bond, without ring elements but considering the type of the bond (single, double, triple).LineElement
generateInnerElement(IBond bond, IRing ring, RendererModel model)
Make the inner ring bond, which is slightly shorter than the outer bond.IRenderingElement
generateRingElements(IBond bond, IRing ring, RendererModel model)
Generate ring elements, such as inner-ring bonds or ring stereo elements.Color
getColorForBond(IBond bond, RendererModel model)
Determine the color of a bond, returning either the default color, the override color or whatever is in the color hash for that bond.List<IGeneratorParameter<?>>
getParameters()
Returns the list ofIGeneratorParameter
for this particular generator.protected IRingSet
getRingSet(IAtomContainer atomContainer)
Determine the ring set for this atom container.double
getWidthForBond(IBond bond, RendererModel model)
Determine the width of a bond, returning either the width defined in the model, or the override width.void
setOverrideBondWidth(double bondWidth)
Set the width to use for all bonds, overriding any standard bond widths.void
setOverrideColor(Color color)
Set the color to use for all bonds, overriding the standard bond colors.
-
-
-
Field Detail
-
ringSet
protected IRingSet ringSet
Necessary for calculating inner-ring bond elements.
-
-
Method Detail
-
setOverrideColor
public void setOverrideColor(Color color)
Set the color to use for all bonds, overriding the standard bond colors.- Parameters:
color
- the override color
-
setOverrideBondWidth
public void setOverrideBondWidth(double bondWidth)
Set the width to use for all bonds, overriding any standard bond widths.- Parameters:
bondWidth
-
-
getRingSet
protected IRingSet getRingSet(IAtomContainer atomContainer)
Determine the ring set for this atom container.- Parameters:
atomContainer
- the atom container to find rings in.- Returns:
- the rings of the molecule
-
getColorForBond
public Color getColorForBond(IBond bond, RendererModel model)
Determine the color of a bond, returning either the default color, the override color or whatever is in the color hash for that bond.- Parameters:
bond
- the bond we are generating an element formodel
- the rendering model- Returns:
- the color to paint the bond
-
getWidthForBond
public double getWidthForBond(IBond bond, RendererModel model)
Determine the width of a bond, returning either the width defined in the model, or the override width. Note that this will be scaled to the space of the model.- Parameters:
bond
- the bond to determine the width formodel
- the renderer model- Returns:
- a double in chem-model space
-
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
-
generate
public IRenderingElement generate(IBond currentBond, RendererModel model)
Generate rendering element(s) for the current bond, including ring elements if this bond is part of a ring.- Parameters:
currentBond
- the bond to use when generating elementsmodel
- the renderer model- Returns:
- one or more rendering elements
-
generateBondElement
public IRenderingElement generateBondElement(IBond bond, RendererModel model)
Generate rendering elements for a bond, without ring elements but considering the type of the bond (single, double, triple).- Parameters:
bond
- the bond to use when generating elementsmodel
- the renderer model- Returns:
- one or more rendering elements
-
generateBondElement
public IRenderingElement generateBondElement(IBond bond, IBond.Order type, RendererModel model)
Generate a LineElement or an ElementGroup of LineElements for this bond. This version should be used if you want to override the type - for example, for ring double bonds.- Parameters:
bond
- the bond to generate fortype
- the type of the bond - single, double, etcmodel
- the renderer model- Returns:
- one or more rendering elements
-
generateRingElements
public IRenderingElement generateRingElements(IBond bond, IRing ring, RendererModel model)
Generate ring elements, such as inner-ring bonds or ring stereo elements.- Parameters:
bond
- the ring bond to use when generating elementsring
- the ring that the bond is inmodel
- the renderer model- Returns:
- one or more rendering elements
-
generateInnerElement
public LineElement generateInnerElement(IBond bond, IRing ring, RendererModel model)
Make the inner ring bond, which is slightly shorter than the outer bond.- Parameters:
bond
- the ring bondring
- the ring that the bond is inmodel
- the renderer model- Returns:
- the line element
-
bindsHydrogen
protected boolean bindsHydrogen(IBond bond)
Check to see if any of the atoms in this bond are hydrogen atoms.- Parameters:
bond
- the bond to check- Returns:
- true if any atom has an element symbol of "H"
-
generateBond
public IRenderingElement generateBond(IBond bond, RendererModel model)
Generate stereo or bond elements for this bond.- Parameters:
bond
- the bond to use when generating elementsmodel
- the renderer model- Returns:
- one or more rendering elements
-
getParameters
public List<IGeneratorParameter<?>> getParameters()
Returns the list ofIGeneratorParameter
for this particular generator.- Specified by:
getParameters
in interfaceIGenerator<IAtomContainer>
- Returns:
- a
List
ofIGeneratorParameter
s
-
-