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
  • Field Details

    • ringSet

      protected IRingSet ringSet
      Necessary for calculating inner-ring bond elements.
  • Constructor Details

    • BasicBondGenerator

      public BasicBondGenerator()
      An empty constructor necessary for reflection.
  • Method Details

    • 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 for
      model - 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 for
      model - the renderer model
      Returns:
      a double in chem-model space
    • generate

      public IRenderingElement generate(IAtomContainer container, RendererModel model)
      Converts a IChemObject from the chemical data model into something that can be drawn in the chemical drawing.
      Specified by:
      generate in interface IGenerator<IAtomContainer>
      Parameters:
      container - the chemical entity to be depicted
      model - 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 elements
      model - 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 elements
      model - 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 for
      type - the type of the bond - single, double, etc
      model - 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 elements
      ring - the ring that the bond is in
      model - 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 bond
      ring - the ring that the bond is in
      model - 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 elements
      model - the renderer model
      Returns:
      one or more rendering elements
    • getParameters

      public List<IGeneratorParameter<?>> getParameters()
      Returns the list of IGeneratorParameter for this particular generator.
      Specified by:
      getParameters in interface IGenerator<IAtomContainer>
      Returns:
      a List of IGeneratorParameters