Class ComponentElement

java.lang.Object
chemaxon.marvin.space.ComponentElement

@PublicAPI public class ComponentElement extends Object
Class to identify parts of GraphicComponents mainly during selection.

Examples:

  • Identify an atom of a molecule
    ComponentElement pickedItem = new ComponentElement( this, COMPONENT_TYPE_ATOM, selectBuf.get(offset) );
  • Identify the whole molecule
    ComponentElement pickedItem = new ComponentElement( this, COMPONENT_TYPE_ENTIRE, 0 );
  • Getting the MolAtom from a ComponentElement
    ComponentElement item;
    if(item.getType() == COMPONENT_TYPE_ATOM) { chemaxon.struc.MolAtom mola = mol.getAtom( item.getIndex() ); }

Since:
Marvin 4.0.2
  • Constructor Details

    • ComponentElement

      public ComponentElement(GraphicComponent component, int atomicElementType, int atomicElementIndex)
      Creates a new instance of ComponentElement of a simple (not structured) GraphicComponent.
      Parameters:
      component - the GraphicComponent whose element is this ComponentElement of
      atomicElementType - identifies the type of the ComponentElement, which can be anything the GraphicComponent can identify
      atomicElementIndex - the internal index of the atomic element of the component having given type
    • ComponentElement

      public ComponentElement(GraphicComponent component, int atomicElementType, Integer atomicElementIndexObject)
      Creates a new instance of ComponentElement.
      Parameters:
      component - the GraphicComponent whose element is this ComponentElement of
      atomicElementType - identifies the type of the ComponentElement, which can be anything the GraphicComponent can identify
      atomicElementIndexObject - the internal index of the atomic element as an object
    • ComponentElement

      public ComponentElement(GraphicComponent component, int componentPartId, int atomicElementType, int atomicElementIndex)
      Creates a new instance of ComponentElement of a complex (structured) GraphicComponent.
      Parameters:
      component - the GraphicComponent whose element is this ComponentElement of
      componentPartId - identifies the specific part of the complex GraphicComponent
      atomicElementType - identifies the type of the ComponentElement, which can be anything the GraphicComponent can identify
      atomicElementIndex - the internal index of the atomic element of the component having given type
    • ComponentElement

      public ComponentElement(GraphicComponent component, int componentPartId, int atomicElementType, Integer atomicElementIndexObject)
      Creates a new instance of ComponentElement.
      Parameters:
      component - the GraphicComponent whose element is this ComponentElement of
      componentPartId - identifies the specific part of the complex GraphicComponent
      atomicElementType - identifies the type of the ComponentElement, which can be anything the GraphicComponent can identify
      atomicElementIndexObject - the internal index of the atomic element as an object
    • ComponentElement

      public ComponentElement(ComponentElement element)
      Copies the given ComponentElement.
      Parameters:
      element - to copy
  • Method Details

    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • isComponentPart

      public boolean isComponentPart()
      Returns true if the if the component is a structured component.
      Returns:
      is the component a part of a structured component
    • getComponentPartId

      public int getComponentPartId()
      In case of complex components the componentPartId identifies a part of the component.
      Returns:
      id of the part of a structured component
    • getElementType

      public int getElementType()
      Returns the type of the ComponentElement.
      Returns:
      identifier of an element type
    • getElementIndex

      public int getElementIndex()
      Returns the internal index of the ComponentElement in the GraphicComponent.
      Returns:
      internal index of the component
    • getCoordinates

      public void getCoordinates(float[] c)
      Returns the world coordinates of the ComponentElement.
      Parameters:
      c - allocated array where the coordinates will be put
    • setCoordinates

      public void setCoordinates(float[] c)
      Sets the coordinates of the ComponentElement. Note, that usually it is unnecessary to set the coordinates this way, because they will be got by GraphicComponent.getCoordinates(ComponentElement, float[]). Setting the coordinates explicitly prevents the calling of the above method.
    • getDescription

      public String getDescription()
      Returns the brief description of the ComponentElement, for example type of the atom.
      Returns:
      description of the component
    • setDescription

      public void setDescription(String d)
      Sets a brief description to the ComponentElement that will be returned by {#getDescription()}.
      Parameters:
      d - description String or null to get the description given by the component
    • isVisible

      public boolean isVisible()
      Returns true if the ComponentElement is visible in the component.
      Returns:
      is the component visible or not
    • getComponent

      public GraphicComponent getComponent()
      Returns the component which contains this ComponentElement.
      Returns:
      the component
    • getColor

      public Color getColor()
      Returns the color that is assigned to the ComponentElement. E.g. residue color of a residue label, cpk color of an atom, constant color of a component.
    • setColor

      public void setColor(Color c)
      Assignes a color to the CompnentElement.
    • toString

      public String toString()
      Returs the indices of the CompnentElement.
      Overrides:
      toString in class Object
      Returns:
      ComponentElement as String