Merge pull request #798 from teyrana/fix/786/display-motor-mass
[fixes# 786] Updates config when drawing extras on 2D RocketFigure
This commit is contained in:
commit
334bd1d3db
@ -41,12 +41,12 @@ public class RocketInfo implements FigureElement {
|
||||
private final Caret cpCaret = new CPCaret(0,0);
|
||||
private final Caret cgCaret = new CGCaret(0,0);
|
||||
|
||||
private final FlightConfiguration configuration;
|
||||
private final UnitGroup stabilityUnits;
|
||||
|
||||
private FlightConfiguration configuration;
|
||||
private double cg = 0, cp = 0;
|
||||
private double length = 0, diameter = 0;
|
||||
private double mass = 0;
|
||||
private double massWithMotors = 0;
|
||||
private double aoa = Double.NaN;
|
||||
private double theta = Double.NaN;
|
||||
private double mach = Application.getPreferences().getDefaultMach();
|
||||
@ -111,11 +111,11 @@ public class RocketInfo implements FigureElement {
|
||||
public void setDiameter(double diameter) {
|
||||
this.diameter = diameter;
|
||||
}
|
||||
|
||||
public void setMass(double mass) {
|
||||
this.mass = mass;
|
||||
|
||||
public void setMassWithMotors(double mass) {
|
||||
this.massWithMotors = mass;
|
||||
}
|
||||
|
||||
|
||||
public void setMassWithoutMotors(double mass) {
|
||||
this.massWithoutMotors = mass;
|
||||
}
|
||||
@ -175,11 +175,10 @@ public class RocketInfo implements FigureElement {
|
||||
if( configuration.hasMotors() ) {
|
||||
//// Mass with motors
|
||||
massTextWithMotors = trans.get("RocketInfo.massWithMotors") + " ";
|
||||
massTextWithMotors += UnitGroup.UNITS_MASS.getDefaultUnit().toStringUnit(mass);
|
||||
massTextWithMotors += UnitGroup.UNITS_MASS.getDefaultUnit().toStringUnit(massWithMotors);
|
||||
GlyphVector massLineWithMotors = createText(massTextWithMotors);
|
||||
g2.drawGlyphVector(massLineWithMotors, x1, y1+3*line);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -254,8 +253,8 @@ public class RocketInfo implements FigureElement {
|
||||
*
|
||||
* @return the mass
|
||||
*/
|
||||
public double getMass() {
|
||||
return mass;
|
||||
public double getMassWithMotors() {
|
||||
return massWithMotors;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -265,8 +264,8 @@ public class RocketInfo implements FigureElement {
|
||||
*
|
||||
* @return the mass
|
||||
*/
|
||||
public String getMass(Unit u) {
|
||||
return u.toStringUnit(mass);
|
||||
public String getMassWithMotors(Unit u) {
|
||||
return u.toStringUnit(massWithMotors);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -450,5 +449,8 @@ public class RocketInfo implements FigureElement {
|
||||
float size=(float) (Application.getPreferences().getRocketInfoFontSize()-2.0);
|
||||
return (SMALLFONT.deriveFont(size)).createGlyphVector(g2.getFontRenderContext(), text);
|
||||
}
|
||||
|
||||
|
||||
public void setCurrentConfig(FlightConfiguration newConfig) {
|
||||
this.configuration = newConfig;
|
||||
}
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ public class DesignReport {
|
||||
} else {
|
||||
canvas.newlineShowText(MASS_EMPTY);
|
||||
}
|
||||
canvas.showText(text.getMass(UnitGroup.UNITS_MASS.getDefaultUnit()));
|
||||
canvas.showText(text.getMassWithMotors(UnitGroup.UNITS_MASS.getDefaultUnit()));
|
||||
|
||||
canvas.newlineShowText(STABILITY);
|
||||
canvas.showText(text.getStability());
|
||||
|
@ -573,6 +573,8 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
||||
FlightConditions conditions = new FlightConditions(curConfig);
|
||||
warnings.clear();
|
||||
|
||||
extraText.setCurrentConfig(curConfig);
|
||||
|
||||
if (!Double.isNaN(cpMach)) {
|
||||
conditions.setMach(cpMach);
|
||||
extraText.setMach(cpMach);
|
||||
@ -601,15 +603,13 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
||||
cp = aerodynamicCalculator.getWorstCP(curConfig, conditions, warnings);
|
||||
}
|
||||
extraText.setTheta(cpTheta);
|
||||
|
||||
cg = MassCalculator.calculateLaunch( curConfig).getCM();
|
||||
|
||||
if (cp.weight > MathUtil.EPSILON){
|
||||
cpx = cp.x;
|
||||
// map the 3D value into the 2D Display Panel
|
||||
cpy = cp.y * Math.cos(rotation) + cp.z*Math.sin(rotation);
|
||||
}
|
||||
|
||||
cg = MassCalculator.calculateLaunch( curConfig).getCM();
|
||||
if (cg.weight > MassCalculator.MIN_MASS){
|
||||
cgx = cg.x;
|
||||
// map the 3D value into the 2D Display Panel
|
||||
@ -636,7 +636,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change
|
||||
extraText.setCP(cpx);
|
||||
extraText.setLength(length);
|
||||
extraText.setDiameter(diameter);
|
||||
extraText.setMass(cg.weight);
|
||||
extraText.setMassWithMotors(cg.weight);
|
||||
extraText.setMassWithoutMotors( emptyInfo.getMass() );
|
||||
extraText.setWarnings(warnings);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user