1 package net.sf.openrocket.rocketcomponent;
3 import net.sf.openrocket.util.Coordinate;
6 public class CenteringRing extends RadiusRingComponent {
8 public CenteringRing() {
9 setOuterRadiusAutomatic(true);
10 setInnerRadiusAutomatic(true);
16 public double getInnerRadius() {
17 // Implement sibling inner radius automation
18 if (isInnerRadiusAutomatic()) {
20 // Component can be parentless if disattached from rocket
21 if (this.getParent() != null) {
22 for (RocketComponent sibling: this.getParent().getChildren()) {
23 if (!(sibling instanceof RadialParent)) // Excludes itself
26 double pos1 = this.toRelative(Coordinate.NUL, sibling)[0].x;
27 double pos2 = this.toRelative(new Coordinate(getLength()), sibling)[0].x;
28 if (pos2 < 0 || pos1 > sibling.getLength())
31 // TODO: CRITICAL: ClassCastException below:
32 innerRadius = Math.max(innerRadius, ((InnerTube)sibling).getOuterRadius());
34 innerRadius = Math.min(innerRadius, getOuterRadius());
38 return super.getInnerRadius();
43 public void setOuterRadiusAutomatic(boolean auto) {
44 super.setOuterRadiusAutomatic(auto);
48 public void setInnerRadiusAutomatic(boolean auto) {
49 super.setInnerRadiusAutomatic(auto);
53 public String getComponentName() {
54 return "Centering ring";
58 public boolean isCompatible(Class<? extends RocketComponent> type) {