1 package net.sf.openrocket.rocketcomponent;
3 import net.sf.openrocket.util.Coordinate;
4 import net.sf.openrocket.util.MathUtil;
8 * A RingComponent that comes on top of another tube. It's defined by the inner
9 * radius and thickness. The inner radius can be automatic, in which case it
10 * takes the radius of the parent component.
12 * @author Sampo Niskanen <sampo.niskanen@iki.fi>
14 public class Sleeve extends RingComponent {
16 protected double innerRadius = 0;
17 protected double thickness = 0;
22 setInnerRadiusAutomatic(true);
29 public double getOuterRadius() {
30 return getInnerRadius() + thickness;
34 public void setOuterRadius(double r) {
35 if (MathUtil.equals(getOuterRadius(), r))
38 innerRadius = Math.max(r - thickness, 0);
41 fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
46 public double getInnerRadius() {
47 // Implement parent inner radius automation
48 if (isInnerRadiusAutomatic() && getParent() instanceof RadialParent) {
49 RocketComponent parent = getParent();
50 double pos1 = this.toRelative(Coordinate.NUL, parent)[0].x;
51 double pos2 = this.toRelative(new Coordinate(getLength()), parent)[0].x;
52 pos1 = MathUtil.clamp(pos1, 0, parent.getLength());
53 pos2 = MathUtil.clamp(pos2, 0, parent.getLength());
54 innerRadius = Math.max(((RadialParent) parent).getOuterRadius(pos1),
55 ((RadialParent) parent).getOuterRadius(pos2));
62 public void setInnerRadius(double r) {
64 if (MathUtil.equals(innerRadius, r))
67 fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
71 public double getThickness() {
76 public void setThickness(double t) {
78 if (MathUtil.equals(thickness, t))
81 fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE);
88 public void setInnerRadiusAutomatic(boolean auto) {
89 super.setOuterRadiusAutomatic(auto);
93 public String getComponentName() {
98 public boolean allowsChildren() {
103 public boolean isCompatible(Class<? extends RocketComponent> type) {