From: Bill Kuker Date: Fri, 17 Apr 2009 04:23:33 +0000 (+0000) Subject: made the core xsection display size itself X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=724f0f3a9eaceb02cd024a54b2cbba0337d64b6d;p=sw%2Fmotorsim made the core xsection display size itself --- diff --git a/src/com/billkuker/rocketry/motorsim/visual/GrainPanel.java b/src/com/billkuker/rocketry/motorsim/visual/GrainPanel.java index 5ba279f..6fa3b34 100644 --- a/src/com/billkuker/rocketry/motorsim/visual/GrainPanel.java +++ b/src/com/billkuker/rocketry/motorsim/visual/GrainPanel.java @@ -116,8 +116,19 @@ public class GrainPanel extends JPanel { private static final long serialVersionUID = 1L; Grain grain; public XC(Grain g){ - setMinimumSize(new Dimension(440,250)); grain = g; + java.awt.geom.Area unburnt = grain.getSideView(Amount.valueOf(0, SI.MILLIMETER)); + + Rectangle bounds = unburnt.getBounds(); + double max = bounds.getWidth(); + if ( bounds.getHeight() > max ) + max = bounds.getHeight(); + int w = (int)(bounds.getWidth() * 200.0 / max); + if ( w < 40 ) + w = 40; + + setMinimumSize(new Dimension(240+w,250)); + } public void paint(Graphics g){ super.paint(g);