X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fnet%2Fsf%2Fopenrocket%2Frocketcomponent%2FExternalComponent.java;h=64c1a50ec095509c5348f648ace514f3677c253a;hb=da7a9ff299f7b1529f8ff9cba08e4be3f369937c;hp=ed543c12fe352eab0890e31d04817621afd87b05;hpb=c3014ac8d2eddb3a12c8df0570a3b42ac82db4b1;p=debian%2Fopenrocket diff --git a/src/net/sf/openrocket/rocketcomponent/ExternalComponent.java b/src/net/sf/openrocket/rocketcomponent/ExternalComponent.java index ed543c12..64c1a50e 100644 --- a/src/net/sf/openrocket/rocketcomponent/ExternalComponent.java +++ b/src/net/sf/openrocket/rocketcomponent/ExternalComponent.java @@ -1,13 +1,13 @@ package net.sf.openrocket.rocketcomponent; +import java.util.List; + import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.material.Material; import net.sf.openrocket.startup.Application; import net.sf.openrocket.unit.UnitGroup; import net.sf.openrocket.util.Prefs; -import java.util.List; - /** * Class of components with well-defined physical appearance and which have an effect on * aerodynamic simulation. They have material defined for them, and the mass of the component @@ -17,7 +17,7 @@ import java.util.List; */ public abstract class ExternalComponent extends RocketComponent { - + public enum Finish { //// Rough ROUGH("ExternalComponent.Rough", 500e-6), @@ -29,35 +29,35 @@ public abstract class ExternalComponent extends RocketComponent { SMOOTH("ExternalComponent.Smoothpaint", 20e-6), //// Polished POLISHED("ExternalComponent.Polished", 2e-6); - + + private static final Translator trans = Application.getTranslator(); private final String name; private final double roughnessSize; - + Finish(String name, double roughness) { this.name = name; this.roughnessSize = roughness; } - + public double getRoughnessSize() { return roughnessSize; } - + @Override public String toString() { - final Translator trans = Application.getTranslator(); return trans.get(name) + " (" + UnitGroup.UNITS_ROUGHNESS.toStringUnit(roughnessSize) + ")"; } } - - + + /** * The material of the component. */ protected Material material = null; - + protected Finish finish = Finish.NORMAL; - - + + /** * Constructor that sets the relative position of the component. @@ -66,13 +66,13 @@ public abstract class ExternalComponent extends RocketComponent { super(relativePosition); this.material = Prefs.getDefaultComponentMaterial(this.getClass(), Material.Type.BULK); } - + /** * Returns the volume of the component. This value is used in calculating the mass * of the object. */ public abstract double getComponentVolume(); - + /** * Calculates the mass of the component as the product of the volume and interior density. */ @@ -80,7 +80,7 @@ public abstract class ExternalComponent extends RocketComponent { public double getComponentMass() { return material.getDensity() * getComponentVolume(); } - + /** * ExternalComponent has aerodynamic effect, so return true. */ @@ -88,7 +88,7 @@ public abstract class ExternalComponent extends RocketComponent { public boolean isAerodynamic() { return true; } - + /** * ExternalComponent has effect on the mass, so return true. */ @@ -96,36 +96,36 @@ public abstract class ExternalComponent extends RocketComponent { public boolean isMassive() { return true; } - - + + public Material getMaterial() { return material; } - + public void setMaterial(Material mat) { if (mat.getType() != Material.Type.BULK) { throw new IllegalArgumentException("ExternalComponent requires a bulk material" + " type=" + mat.getType()); } - + if (material.equals(mat)) return; material = mat; fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE); } - + public Finish getFinish() { return finish; } - + public void setFinish(Finish finish) { if (this.finish == finish) return; this.finish = finish; fireComponentChangeEvent(ComponentChangeEvent.AERODYNAMIC_CHANGE); } - - + + @Override protected List copyFrom(RocketComponent c) { ExternalComponent src = (ExternalComponent) c; @@ -133,5 +133,5 @@ public abstract class ExternalComponent extends RocketComponent { this.material = src.material; return super.copyFrom(c); } - + }