Merge pull request #728 from teyrana/fix/723-scaling
[Fixes #723] Fix scaling crashes in some circumstances
This commit is contained in:
commit
908cd3e619
@ -179,8 +179,7 @@ public abstract class RingComponent extends StructuralComponent implements Coaxi
|
|||||||
if (1 == instanceCount ) {
|
if (1 == instanceCount ) {
|
||||||
cg = new Coordinate( length/2, 0, 0, instanceMass );
|
cg = new Coordinate( length/2, 0, 0, instanceMass );
|
||||||
}else{
|
}else{
|
||||||
Coordinate offsets[] = getInstanceOffsets();
|
for( Coordinate c : getInstanceOffsets() ) {
|
||||||
for( Coordinate c : offsets) {
|
|
||||||
c = c.setWeight( instanceMass );
|
c = c.setWeight( instanceMass );
|
||||||
cg = cg.average(c);
|
cg = cg.average(c);
|
||||||
}
|
}
|
||||||
|
@ -1930,7 +1930,7 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
|
|||||||
|
|
||||||
protected static final double ringMass(double outerRadius, double innerRadius,
|
protected static final double ringMass(double outerRadius, double innerRadius,
|
||||||
double length, double density) {
|
double length, double density) {
|
||||||
return Math.PI * (MathUtil.pow2(outerRadius) - MathUtil.pow2(innerRadius)) *
|
return Math.PI * Math.max(MathUtil.pow2(outerRadius) - MathUtil.pow2(innerRadius),0) *
|
||||||
length * density;
|
length * density;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,7 +392,11 @@ public class ScaleDialog extends JDialog {
|
|||||||
scale.addActionListener(new ActionListener() {
|
scale.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
|
final Rocket rocket = document.getRocket();
|
||||||
|
rocket.enableEvents(false);
|
||||||
doScale();
|
doScale();
|
||||||
|
rocket.enableEvents(true);
|
||||||
|
|
||||||
ScaleDialog.this.document.getRocket().fireComponentChangeEvent( ComponentChangeEvent.AEROMASS_CHANGE);
|
ScaleDialog.this.document.getRocket().fireComponentChangeEvent( ComponentChangeEvent.AEROMASS_CHANGE);
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ public abstract class AbstractScaleFigure extends JPanel {
|
|||||||
* Updates the figure shapes and figure size.
|
* Updates the figure shapes and figure size.
|
||||||
*/
|
*/
|
||||||
public void updateFigure() {
|
public void updateFigure() {
|
||||||
log.trace(String.format("____ Updating %s to: %g user scale, %g overall scale", this.getClass().getSimpleName(), this.getAbsoluteScale(), this.scale));
|
log.trace(String.format("____ Updating %s to: %g user scale, %g overall scale", this.getClass().getSimpleName(), this.userScale, this.scale));
|
||||||
|
|
||||||
updateSubjectDimensions();
|
updateSubjectDimensions();
|
||||||
updateCanvasSize();
|
updateCanvasSize();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user