1 package net.sf.openrocket.rocketcomponent;
3 import net.sf.openrocket.preset.ComponentPreset;
4 import net.sf.openrocket.preset.ComponentPreset.Type;
5 import net.sf.openrocket.util.Coordinate;
8 public class CenteringRing extends RadiusRingComponent {
10 public CenteringRing() {
11 setOuterRadiusAutomatic(true);
12 setInnerRadiusAutomatic(true);
18 public double getInnerRadius() {
19 // Implement sibling inner radius automation
20 if (isInnerRadiusAutomatic()) {
22 // Component can be parentless if disattached from rocket
23 if (this.getParent() != null) {
24 for (RocketComponent sibling : this.getParent().getChildren()) {
26 * Only InnerTubes are considered when determining the automatic
27 * inner radius (for now).
29 if (!(sibling instanceof InnerTube)) // Excludes itself
32 double pos1 = this.toRelative(Coordinate.NUL, sibling)[0].x;
33 double pos2 = this.toRelative(new Coordinate(getLength()), sibling)[0].x;
34 if (pos2 < 0 || pos1 > sibling.getLength())
37 innerRadius = Math.max(innerRadius, ((InnerTube) sibling).getOuterRadius());
39 innerRadius = Math.min(innerRadius, getOuterRadius());
43 return super.getInnerRadius();
48 public void setOuterRadiusAutomatic(boolean auto) {
49 super.setOuterRadiusAutomatic(auto);
53 public void setInnerRadiusAutomatic(boolean auto) {
54 super.setInnerRadiusAutomatic(auto);
58 public String getComponentName() {
59 return "Centering ring";
63 public boolean allowsChildren() {
68 public boolean isCompatible(Class<? extends RocketComponent> type) {
73 public Type getPresetType() {
74 return ComponentPreset.Type.CENTERING_RING;