예제 #1
0
  /**
   * Hide the atoms and bonds of a contracted abbreviation. If the abbreviations is attached we
   * remap the attachment symbol to display the name. If there are no attachments the symbol we be
   * added later ({@see #generateSgroups}).
   *
   * @param container molecule
   * @param sgroup abbreviation group display shortcut
   */
  private static void contractAbbreviation(
      IAtomContainer container, Map<IAtom, String> symbolRemap, Sgroup sgroup) {

    final Set<IBond> crossing = sgroup.getBonds();
    final Set<IAtom> atoms = sgroup.getAtoms();

    // only do 0,1 attachments for now
    if (crossing.size() > 1) return;

    for (IAtom atom : atoms) {
      StandardGenerator.hide(atom);
    }
    for (IBond bond : container.bonds()) {
      if (atoms.contains(bond.getAtom(0)) || atoms.contains(bond.getAtom(1)))
        StandardGenerator.hide(bond);
    }
    for (IBond bond : crossing) {
      StandardGenerator.unhide(bond);
      IAtom a1 = bond.getAtom(0);
      IAtom a2 = bond.getAtom(1);
      StandardGenerator.unhide(a1);
      if (atoms.contains(a1)) symbolRemap.put(a1, sgroup.getSubscript());
      StandardGenerator.unhide(a2);
      if (atoms.contains(a2)) symbolRemap.put(a2, sgroup.getSubscript());
    }
  }
예제 #2
0
  /**
   * Hide the repeated atoms and bonds of a multiple group. We hide al atoms that belong to the
   * group unless they are defined in the parent atom list. Any bond to those atoms that is not a
   * crossing bond or one connecting atoms in the parent list is hidden.
   *
   * @param container molecule
   * @param sgroup multiple group display shortcut
   */
  private static void hideMultipleParts(IAtomContainer container, Sgroup sgroup) {

    final Set<IBond> crossing = sgroup.getBonds();
    final Set<IAtom> atoms = sgroup.getAtoms();
    final Set<IAtom> parentAtoms = sgroup.getValue(SgroupKey.CtabParentAtomList);

    for (IBond bond : container.bonds()) {
      if (parentAtoms.contains(bond.getAtom(0)) && parentAtoms.contains(bond.getAtom(1))) continue;
      if (atoms.contains(bond.getAtom(0)) || atoms.contains(bond.getAtom(1)))
        StandardGenerator.hide(bond);
    }
    for (IAtom atom : atoms) {
      if (!parentAtoms.contains(atom)) StandardGenerator.hide(atom);
    }
    for (IBond bond : crossing) {
      StandardGenerator.unhide(bond);
    }
  }
예제 #3
0
 private TextOutline makeText(
     String subscriptSuffix, Point2d b1p2, Vector2d b1pvec, double labelScale) {
   return StandardGenerator.generateAnnotation(
           b1p2, subscriptSuffix, VecmathUtil.negate(b1pvec), 1, labelScale, font, null)
       .resize(1 / scale, 1 / scale);
 }