[refactor] adjusted variable names in SymmetricComponent.get{Prev|Next}SymmetricComponent to be more obvious

This commit is contained in:
Daniel_M_Williams 2020-08-14 18:16:13 -04:00
parent db79511184
commit bbf9c4d8a4

View File

@ -584,27 +584,27 @@ public abstract class SymmetricComponent extends BodyComponent implements BoxBou
final ComponentAssembly assembly = this.getAssembly(); final ComponentAssembly assembly = this.getAssembly();
// might be: (a) Rocket -- for Centerline/Axial stages // might be: (a) Rocket -- for Centerline/Axial stages
// (b) BodyTube -- for Parallel Stages & PodSets // (b) BodyTube -- for Parallel Stages & PodSets
final RocketComponent assemblyParent = assembly.getParent(); final RocketComponent grandParent = assembly.getParent();
// note: this is not guaranteed to _contain_ a stage... but that we're _searching_ for one. // note: this is not guaranteed to _contain_ a stage... but that we're _searching_ for one.
int assemblyIndex = assemblyParent.getChildPosition(assembly); // position of stage w/in parent int searchParentIndex = grandParent.getChildPosition(assembly); // position of stage w/in parent
int symmetricIndex = this.parent.getChildPosition(this)-1; // guess at index of previous stage int searchSiblingIndex = this.parent.getChildPosition(this)-1; // guess at index of previous stage
while( 0 <= assemblyIndex ) { while( 0 <= searchParentIndex ) {
final RocketComponent searchAssembly = assemblyParent.getChild(assemblyIndex); final RocketComponent searchParent = grandParent.getChild(searchParentIndex);
if(searchAssembly instanceof ComponentAssembly){ if(searchParent instanceof ComponentAssembly){
while (0 <= symmetricIndex) { while (0 <= searchSiblingIndex) {
final RocketComponent previousSymmetric = searchAssembly.getChild(symmetricIndex); final RocketComponent searchSibling = searchParent.getChild(searchSiblingIndex);
if (previousSymmetric instanceof SymmetricComponent) { if (searchSibling instanceof SymmetricComponent) {
return (SymmetricComponent) previousSymmetric; return (SymmetricComponent) searchSibling;
} }
--symmetricIndex; --searchSiblingIndex;
} }
} }
--assemblyIndex; --searchParentIndex;
symmetricIndex = searchAssembly.getChildCount() - 1; searchSiblingIndex = searchParent.getChildCount() - 1;
} }
return null; return null;
} }
@ -622,27 +622,27 @@ public abstract class SymmetricComponent extends BodyComponent implements BoxBou
final ComponentAssembly assembly = this.getAssembly(); final ComponentAssembly assembly = this.getAssembly();
// might be: (a) Rocket -- for centerline stages // might be: (a) Rocket -- for centerline stages
// (b) BodyTube -- for Parallel Stages // (b) BodyTube -- for Parallel Stages
final RocketComponent assemblyParent = assembly.getParent(); final RocketComponent grandParent = assembly.getParent();
// note: this is not guaranteed to _contain_ a stage... but that we're _searching_ for one. // note: this is not guaranteed to _contain_ a stage... but that we're _searching_ for one.
int assemblyIndex = assemblyParent.getChildPosition(assembly); int searchParentIndex = grandParent.getChildPosition(assembly);
int symmetricIndex = this.parent.getChildPosition(this) + 1; int searchSiblingIndex = this.parent.getChildPosition(this) + 1;
while(assemblyIndex < assemblyParent.getChildCount()) { while(searchParentIndex < grandParent.getChildCount()) {
final RocketComponent searchAssembly = assemblyParent.getChild(assemblyIndex); final RocketComponent searchParent = grandParent.getChild(searchParentIndex);
if(searchAssembly instanceof ComponentAssembly){ if(searchParent instanceof ComponentAssembly){
while (symmetricIndex < searchAssembly.getChildCount()) { while (searchSiblingIndex < searchParent.getChildCount()) {
final RocketComponent nextSymmetric = searchAssembly.getChild(symmetricIndex); final RocketComponent searchSibling = searchParent.getChild(searchSiblingIndex);
if (nextSymmetric instanceof SymmetricComponent) { if (searchSibling instanceof SymmetricComponent) {
return (SymmetricComponent) nextSymmetric; return (SymmetricComponent) searchSibling;
} }
++symmetricIndex; ++searchSiblingIndex;
} }
} }
++assemblyIndex; ++searchParentIndex;
symmetricIndex = searchAssembly.getChildCount() - 1; searchSiblingIndex = searchParent.getChildCount() - 1;
} }
return null; return null;
} }