From 724f0f3a9eaceb02cd024a54b2cbba0337d64b6d Mon Sep 17 00:00:00 2001 From: Bill Kuker Date: Fri, 17 Apr 2009 04:23:33 +0000 Subject: [PATCH] made the core xsection display size itself --- .../rocketry/motorsim/visual/GrainPanel.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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); -- 2.47.2