Skip to content

Commit 496f242

Browse files
committed
Removed add/removeListener() calls
Signed-off-by: maclean <gilleain.torrance@gmail.com>
1 parent 822189e commit 496f242

File tree

6 files changed

+0
-60
lines changed

6 files changed

+0
-60
lines changed

src/main/org/openscience/cdk/silent/AtomContainer.java

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -147,19 +147,15 @@ public AtomContainer(IAtomContainer container)
147147

148148
for (int f = 0; f < container.getAtomCount(); f++) {
149149
atoms[f] = container.getAtom(f);
150-
container.getAtom(f).addListener(this);
151150
}
152151
for (int f = 0; f < this.bondCount; f++) {
153152
bonds[f] = container.getBond(f);
154-
container.getBond(f).addListener(this);
155153
}
156154
for (int f = 0; f < this.lonePairCount; f++) {
157155
lonePairs[f] = container.getLonePair(f);
158-
container.getLonePair(f).addListener(this);
159156
}
160157
for (int f = 0; f < this.singleElectronCount; f++) {
161158
singleElectrons[f] = container.getSingleElectron(f);
162-
container.getSingleElectron(f).addListener(this);
163159
}
164160
}
165161

@@ -208,14 +204,7 @@ public Iterator<IStereoElement> iterator() {
208204
*@see #getAtom
209205
*/
210206
public void setAtoms(IAtom[] atoms) {
211-
// unregister this as listener with the old atoms
212-
for (IAtom atom : this.atoms)
213-
if (atom != null) atom.removeListener(this);
214-
215207
this.atoms = atoms;
216-
for (IAtom atom : atoms) {
217-
atom.addListener(this);
218-
}
219208
this.atomCount = atoms.length;
220209
}
221210

@@ -229,9 +218,6 @@ public void setAtoms(IAtom[] atoms) {
229218
public void setBonds(IBond[] bonds)
230219
{
231220
this.bonds = bonds;
232-
for (IBond bond : bonds) {
233-
bond.addListener(this);
234-
}
235221
this.bondCount = bonds.length;
236222
}
237223

@@ -263,7 +249,6 @@ public void setBonds(IBond[] bonds)
263249
*/
264250
public void setAtom(int number, IAtom atom)
265251
{
266-
atom.addListener(this);
267252
atoms[number] = atom;
268253
}
269254

@@ -1025,7 +1010,6 @@ public void addAtom(IAtom atom)
10251010
{
10261011
growAtomArray();
10271012
}
1028-
atom.addListener(this);
10291013
atoms[atomCount] = atom;
10301014
atomCount++;
10311015
}
@@ -1115,7 +1099,6 @@ public void remove(IAtomContainer atomContainer)
11151099
*/
11161100
public void removeAtom(int position)
11171101
{
1118-
atoms[position].removeListener(this);
11191102
for (int i = position; i < atomCount - 1; i++)
11201103
{
11211104
atoms[i] = atoms[i + 1];
@@ -1195,7 +1178,6 @@ public void removeBond(IBond bond)
11951178
public ILonePair removeLonePair(int position)
11961179
{
11971180
ILonePair lp = lonePairs[position];
1198-
lp.removeListener(this);
11991181
for (int i = position; i < lonePairCount - 1; i++)
12001182
{
12011183
lonePairs[i] = lonePairs[i + 1];
@@ -1224,7 +1206,6 @@ public void removeLonePair(ILonePair lonePair)
12241206
public ISingleElectron removeSingleElectron(int position)
12251207
{
12261208
ISingleElectron se = singleElectrons[position];
1227-
se.removeListener(this);
12281209
for (int i = position; i < singleElectronCount - 1; i++)
12291210
{
12301211
singleElectrons[i] = singleElectrons[i + 1];
@@ -1315,9 +1296,6 @@ public void removeAtomAndConnectedElectronContainers(IAtom atom)
13151296
*/
13161297
public void removeAllElements() {
13171298
removeAllElectronContainers();
1318-
for (int f = 0; f < getAtomCount(); f++) {
1319-
getAtom(f).removeListener(this);
1320-
}
13211299
atoms = new IAtom[growArraySize];
13221300
atomCount = 0;
13231301
}
@@ -1329,12 +1307,6 @@ public void removeAllElements() {
13291307
public void removeAllElectronContainers()
13301308
{
13311309
removeAllBonds();
1332-
for (int f = 0; f < getLonePairCount(); f++) {
1333-
getLonePair(f).removeListener(this);
1334-
}
1335-
for (int f = 0; f < getSingleElectronCount(); f++) {
1336-
getSingleElectron(f).removeListener(this);
1337-
}
13381310
lonePairs = new ILonePair[growArraySize];
13391311
singleElectrons = new ISingleElectron[growArraySize];
13401312
lonePairCount = 0;
@@ -1345,9 +1317,6 @@ public void removeAllElectronContainers()
13451317
* Removes all Bonds from this container.
13461318
*/
13471319
public void removeAllBonds() {
1348-
for (int f = 0; f < getBondCount(); f++) {
1349-
getBond(f).removeListener(this);
1350-
}
13511320
bonds = new IBond[growArraySize];
13521321
bondCount = 0;
13531322
}
@@ -1409,7 +1378,6 @@ public void addBond(int atom1, int atom2, IBond.Order order)
14091378
public void addLonePair(int atomID)
14101379
{
14111380
ILonePair lonePair = getBuilder().newInstance(ILonePair.class,atoms[atomID]);
1412-
lonePair.addListener(this);
14131381
addLonePair(lonePair);
14141382
/* no notifyChanged() here because addElectronContainer() does
14151383
it already */
@@ -1423,7 +1391,6 @@ public void addLonePair(int atomID)
14231391
public void addSingleElectron(int atomID)
14241392
{
14251393
ISingleElectron singleElectron = getBuilder().newInstance(ISingleElectron.class,atoms[atomID]);
1426-
singleElectron.addListener(this);
14271394
addSingleElectron(singleElectron);
14281395
/* no notifyChanged() here because addSingleElectron() does
14291396
it already */

src/main/org/openscience/cdk/silent/AtomContainerSet.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ public AtomContainerSet() {
7878
* @param atomContainer The atomContainer to be added to this container
7979
*/
8080
public void addAtomContainer(IAtomContainer atomContainer) {
81-
atomContainer.addListener(this);
8281
addAtomContainer(atomContainer, 1.0);
8382
/*
8483
* notifyChanged is called below
@@ -103,7 +102,6 @@ public void removeAtomContainer(IAtomContainer atomContainer) {
103102
public void removeAllAtomContainers() {
104103
for (int pos = atomContainerCount - 1; pos >= 0; pos--)
105104
{
106-
atomContainers[pos].removeListener(this);
107105
multipliers[pos] = 0.0;
108106
atomContainers[pos] = null;
109107
}
@@ -117,7 +115,6 @@ public void removeAllAtomContainers() {
117115
* @param pos The position of the AtomContainer to be removed from this container
118116
*/
119117
public void removeAtomContainer(int pos) {
120-
atomContainers[pos].removeListener(this);
121118
for (int i = pos; i < atomContainerCount - 1; i++) {
122119
atomContainers[i] = atomContainers[i + 1];
123120
multipliers[i] = multipliers[i + 1];
@@ -134,9 +131,7 @@ public void removeAtomContainer(int pos) {
134131
*/
135132
public void replaceAtomContainer(int position, IAtomContainer container) {
136133
IAtomContainer old = atomContainers[position];
137-
old.removeListener(this);
138134
atomContainers[position] = container;
139-
container.addListener(this);
140135
}
141136

142137
/**
@@ -213,7 +208,6 @@ public void addAtomContainer(IAtomContainer atomContainer, double multiplier) {
213208
if (atomContainerCount + 1 >= atomContainers.length) {
214209
growAtomContainerArray();
215210
}
216-
atomContainer.addListener(this);
217211
atomContainers[atomContainerCount] = atomContainer;
218212
multipliers[atomContainerCount] = multiplier;
219213
atomContainerCount++;

src/main/org/openscience/cdk/silent/ChemFile.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ public ChemFile()
8484
*/
8585
public void addChemSequence(IChemSequence chemSequence)
8686
{
87-
chemSequence.addListener(this);
8887
if (chemSequenceCount + 1 >= chemSequences.length)
8988
{
9089
growChemSequenceArray();
@@ -102,7 +101,6 @@ public void addChemSequence(IChemSequence chemSequence)
102101
*/
103102
public void removeChemSequence(int pos)
104103
{
105-
chemSequences[pos].removeListener(this);
106104
for (int i = pos; i < chemSequenceCount - 1; i++) {
107105
chemSequences[i] = chemSequences[i + 1];
108106
}

src/main/org/openscience/cdk/silent/ChemModel.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,7 @@ public IMoleculeSet getMoleculeSet()
9191
*/
9292
public void setMoleculeSet(IMoleculeSet setOfMolecules)
9393
{
94-
if (this.setOfMolecules != null)
95-
this.setOfMolecules.removeListener(this);
9694
this.setOfMolecules = setOfMolecules;
97-
if (this.setOfMolecules != null)
98-
this.setOfMolecules.addListener(this);
9995
}
10096

10197

@@ -121,11 +117,7 @@ public IRingSet getRingSet() {
121117
*/
122118
public void setRingSet(IRingSet ringSet)
123119
{
124-
if (this.ringSet != null)
125-
this.ringSet.removeListener(this);
126120
this.ringSet = ringSet;
127-
if (this.ringSet != null)
128-
this.ringSet.addListener(this);
129121
}
130122

131123
/**
@@ -147,11 +139,7 @@ public ICrystal getCrystal() {
147139
* @see #getCrystal
148140
*/
149141
public void setCrystal(ICrystal crystal) {
150-
if (this.crystal != null)
151-
this.crystal.removeListener(this);
152142
this.crystal = crystal;
153-
if (this.crystal != null)
154-
this.crystal.addListener(this);
155143
}
156144

157145
/**
@@ -173,11 +161,7 @@ public IReactionSet getReactionSet() {
173161
* @see #getReactionSet
174162
*/
175163
public void setReactionSet(IReactionSet sor) {
176-
if (this.setOfReactions != null)
177-
this.setOfReactions.removeListener(this);
178164
this.setOfReactions = sor;
179-
if (this.setOfReactions != null)
180-
this.setOfReactions.addListener(this);
181165
}
182166

183167
/**

src/main/org/openscience/cdk/silent/ChemSequence.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ public void addChemModel(IChemModel chemModel)
9595
}
9696
chemModels[chemModelCount] = chemModel;
9797
chemModelCount++;
98-
chemModel.addListener(this);
9998
}
10099

101100

@@ -105,7 +104,6 @@ public void addChemModel(IChemModel chemModel)
105104
* @param pos The position of the ChemModel to be removed.
106105
*/
107106
public void removeChemModel(int pos) {
108-
chemModels[pos].removeListener(this);
109107
for (int i = pos; i < chemModelCount - 1; i++) {
110108
chemModels[i] = chemModels[i + 1];
111109
}

src/main/org/openscience/cdk/silent/ReactionSet.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ public void addReaction(IReaction reaction) {
108108
* @param pos The position of the reaction to be removed.
109109
*/
110110
public void removeReaction(int pos) {
111-
reactions[pos].removeListener(this);
112111
for (int i = pos; i < reactionCount - 1; i++) {
113112
reactions[i] = reactions[i + 1];
114113
}

0 commit comments

Comments
 (0)