Class MarkedElement

java.lang.Object
org.openscience.cdk.renderer.elements.MarkedElement
All Implemented Interfaces:
IRenderingElement

public final class MarkedElement extends Object implements IRenderingElement
A marked element adds meta-data (id and tags) to a CDK rendering element (or group of elements). The id should be unique per depiction. The primary use case it to be able to set the 'id' and 'class' attributes in SVG. To set the mol, atom, or bond id set a String property to ID_KEY. Similarly, the CLASS_KEY can be used to set the classes.

 IAtomContainer mol;
 atom.setProperty(MarkedElement.ID_KEY, "my_atm_id");
 atom.setProperty(MarkedElement.CLASS_KEY, "h_donor");
 atom.setProperty(MarkedElement.CLASS_KEY, "h_acceptor");
 
  • Field Details

    • ID_KEY

      public static final String ID_KEY
    • CLASS_KEY

      public static final String CLASS_KEY
  • Method Details

    • getId

      public String getId()
      Access the id of the element.
      Returns:
      id, null if none
    • getClasses

      public List<String> getClasses()
      Access the classes of the element.
      Returns:
      id, empty if none
    • accept

      public void accept(IRenderingVisitor visitor)
      Converts this TextElement into widget specific objects.
      Specified by:
      accept in interface IRenderingElement
      Parameters:
      visitor - Toolkit specific widget factory.
    • element

      public IRenderingElement element()
      Access the element of which the id and classes apply.
      Returns:
      rendering element
    • markup

      public static MarkedElement markup(IRenderingElement elem, String... classes)
      Markup a rendering element with the specified classes.
      Parameters:
      elem - rendering element
      classes - classes
      Returns:
      the marked element
    • markupMol

      public static MarkedElement markupMol(IRenderingElement elem, IAtomContainer mol)
      Markup a molecule with the class 'mol' and optionally the ids/classes from it's properties.
      Parameters:
      elem - rendering element
      mol - molecule
      Returns:
      the marked element
    • markupAtom

      public static MarkedElement markupAtom(IRenderingElement elem, IAtom atom)
      Markup a atom with the class 'atom' and optionally the ids/classes from it's properties.
      Parameters:
      elem - rendering element
      atom - atom
      Returns:
      the marked element
    • markupBond

      public static MarkedElement markupBond(IRenderingElement elem, IBond bond)
      Markup a bond with the class 'bond' and optionally the ids/classes from it's properties.
      Parameters:
      elem - rendering element
      bond - bond
      Returns:
      the marked element