Sum up mass of subcomponent and put in component tree tooltip.
This commit is contained in:
parent
f0609029e8
commit
77cfa2bdf2
@ -1121,6 +1121,19 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
||||
return getComponentMass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the mass of this component and all of its subcomponents.
|
||||
*/
|
||||
public final double getSectionMass() {
|
||||
Double massSubtotal = getMass();
|
||||
mutex.verify();
|
||||
for (RocketComponent rc : children) {
|
||||
massSubtotal += rc.getSectionMass();
|
||||
}
|
||||
|
||||
return massSubtotal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the (possibly overridden) center of gravity and mass.
|
||||
*
|
||||
|
@ -69,7 +69,10 @@ public class ComponentTreeRenderer extends DefaultTreeCellRenderer {
|
||||
|
||||
sb.append("<b>").append(c.getName()).append("</b>");
|
||||
if (c.isMassive() || c.isMassOverridden() ) {
|
||||
sb.append(" (").append(UnitGroup.UNITS_MASS.toStringUnit(c.getMass())).append(")");
|
||||
sb.append(" (").append(UnitGroup.UNITS_MASS.toStringUnit(c.getMass())).append(" of ");
|
||||
sb.append(UnitGroup.UNITS_MASS.toStringUnit(c.getSectionMass())).append( " total)");
|
||||
} else {
|
||||
sb.append(" (").append(UnitGroup.UNITS_MASS.toStringUnit(c.getSectionMass())).append( " total)");
|
||||
}
|
||||
|
||||
if ( c.isMassOverridden() ) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user