Sum up mass of subcomponent and put in component tree tooltip.

This commit is contained in:
Craig Earls 2014-12-13 16:45:49 -07:00
parent f0609029e8
commit 77cfa2bdf2
2 changed files with 17 additions and 1 deletions

View File

@ -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.
*

View File

@ -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() ) {