[fix] SymmetricComponent.get{Next|Prev}SymmetricComponent simply retrieves next symmetric *sibling*.
This commit is contained in:
parent
8288de651f
commit
3e3b5dc655
@ -1631,8 +1631,25 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final RocketComponent getNextComponent() {
|
||||||
|
checkState();
|
||||||
|
if (getChildCount() > 0)
|
||||||
|
return getChild(0);
|
||||||
|
|
||||||
|
RocketComponent current = this;
|
||||||
|
RocketComponent nextParent = this.parent;
|
||||||
|
|
||||||
|
while (nextParent != null) {
|
||||||
|
int pos = nextParent.getChildPosition(current);
|
||||||
|
if (pos < nextParent.getChildCount() - 1)
|
||||||
|
return nextParent.getChild(pos + 1);
|
||||||
|
|
||||||
|
current = nextParent;
|
||||||
|
nextParent = current.parent;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Move these methods elsewhere (used only in SymmetricComponent)
|
|
||||||
public final RocketComponent getPreviousComponent() {
|
public final RocketComponent getPreviousComponent() {
|
||||||
checkState();
|
checkState();
|
||||||
this.checkComponentStructure();
|
this.checkComponentStructure();
|
||||||
@ -1663,27 +1680,6 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Move these methods elsewhere (used only in SymmetricComponent)
|
|
||||||
public final RocketComponent getNextComponent() {
|
|
||||||
checkState();
|
|
||||||
if (getChildCount() > 0)
|
|
||||||
return getChild(0);
|
|
||||||
|
|
||||||
RocketComponent current = this;
|
|
||||||
RocketComponent nextParent = this.parent;
|
|
||||||
|
|
||||||
while (nextParent != null) {
|
|
||||||
int pos = nextParent.getChildPosition(current);
|
|
||||||
if (pos < nextParent.getChildCount() - 1)
|
|
||||||
return nextParent.getChild(pos + 1);
|
|
||||||
|
|
||||||
current = nextParent;
|
|
||||||
nextParent = current.parent;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/////////// Event handling //////////
|
/////////// Event handling //////////
|
||||||
//
|
//
|
||||||
// Listener lists are provided by the root Rocket component,
|
// Listener lists are provided by the root Rocket component,
|
||||||
|
@ -566,17 +566,17 @@ public abstract class SymmetricComponent extends BodyComponent implements Radial
|
|||||||
* @return the previous SymmetricComponent, or null.
|
* @return the previous SymmetricComponent, or null.
|
||||||
*/
|
*/
|
||||||
public final SymmetricComponent getPreviousSymmetricComponent() {
|
public final SymmetricComponent getPreviousSymmetricComponent() {
|
||||||
RocketComponent c;
|
if(null == this.parent) {
|
||||||
for (c = this.getPreviousComponent(); c != null; c = c.getPreviousComponent()) {
|
|
||||||
if (c instanceof PodSet) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (c instanceof SymmetricComponent) {
|
|
||||||
return (SymmetricComponent) c;
|
int pos = parent.getChildPosition(this);
|
||||||
}
|
while( 0 < pos ) {
|
||||||
if (!(c instanceof AxialStage) &&
|
--pos;
|
||||||
(c.axialMethod == AxialMethod.AFTER)) {
|
final RocketComponent comp = parent.getChild(pos);
|
||||||
return null; // Bad component type as "parent"
|
|
||||||
|
if (comp instanceof SymmetricComponent) {
|
||||||
|
return (SymmetricComponent) comp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -588,17 +588,19 @@ public abstract class SymmetricComponent extends BodyComponent implements Radial
|
|||||||
* @return the next SymmetricComponent, or null.
|
* @return the next SymmetricComponent, or null.
|
||||||
*/
|
*/
|
||||||
public final SymmetricComponent getNextSymmetricComponent() {
|
public final SymmetricComponent getNextSymmetricComponent() {
|
||||||
RocketComponent c;
|
if(null == this.parent) {
|
||||||
for (c = this.getNextComponent(); c != null; c = c.getNextComponent()) {
|
|
||||||
if (c instanceof PodSet) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (c instanceof SymmetricComponent) {
|
|
||||||
return (SymmetricComponent) c;
|
int pos = parent.getChildPosition(this);
|
||||||
|
++pos;
|
||||||
|
while( pos < parent.getChildCount() ) {
|
||||||
|
final RocketComponent comp = parent.getChild(pos);
|
||||||
|
++pos;
|
||||||
|
|
||||||
|
if (comp instanceof SymmetricComponent) {
|
||||||
|
return (SymmetricComponent) comp;
|
||||||
}
|
}
|
||||||
if (!(c instanceof AxialStage) &&
|
|
||||||
(c.axialMethod == AxialMethod.AFTER))
|
|
||||||
return null; // Bad component type as "parent"
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user