1 /* $RCSfile$ 2 * $Author: hansonr $ 3 * $Date: 2016-02-04 21:46:46 -0600 (Thu, 04 Feb 2016) $ 4 * $Revision: 20945 $ 5 * 6 * Copyright (C) 2005 The Jmol Development Team 7 * 8 * Contact: jmol-developers@lists.sf.net 9 * 10 * This library is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Lesser General Public 12 * License as published by the Free Software Foundation; either 13 * version 2.1 of the License, or (at your option) any later version. 14 * 15 * This library is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * Lesser General Public License for more details. 19 * 20 * You should have received a copy of the GNU Lesser General Public 21 * License along with this library; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 23 */ 24 25 package org.jmol.smiles; 26 27 import java.util.Hashtable; 28 29 import javajs.util.Lst; 30 31 import javajs.util.BS; 32 import org.jmol.util.Edge; 33 34 /** 35 * Ring of (tentatively) aromatic nodes and edges 36 */ 37 38 class SmilesRing extends BS { 39 40 SmilesRingSet set; 41 Lst<Edge> edges; 42 BS bsEdgesToCheck; 43 boolean isOK; 44 int n; 45 SmilesRing(int n, BS atoms, Lst<Edge> edges, boolean isOK)46 SmilesRing(int n, BS atoms, Lst<Edge> edges, boolean isOK) { 47 this.or(atoms); 48 this.edges = edges; 49 this.isOK = isOK; 50 this.n = n; 51 } 52 addEdges(Hashtable<String, SmilesRingSet> htEdgeMap)53 void addEdges(Hashtable<String, SmilesRingSet> htEdgeMap) { 54 for (int i = edges.size(); --i >= 0;) 55 htEdgeMap.put(getKey(edges.get(i)), set); 56 } 57 getSetByEdge(Edge edge, Hashtable<String, SmilesRingSet> htEdgeMap)58 static SmilesRingSet getSetByEdge(Edge edge, 59 Hashtable<String, SmilesRingSet> htEdgeMap) { 60 return htEdgeMap.get(getKey(edge)); 61 } 62 getKey(Edge e)63 private static String getKey(Edge e) { 64 int i = e.getAtomIndex1(); 65 int j = e.getAtomIndex2(); 66 return (i < j ? i + "_" + j : j + "_" + i); 67 } 68 69 } 70