diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index d945dec90..df63ec5e2 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -69,6 +69,9 @@ RocketPanel.btn.Stages.Toggle.ttip = Toggle this button to activate/deactivate t RocketPanel.btn.Stages.NoChildren.ttip = This stage does not have child components and is therefore marked as inactive.
Add components to the stage to activate it. RocketPanel.ttip.Rotation = Change the rocket's roll rotation (only affects the rocket view) +RocketPanel.check.showWarnings = Show warnings +RocketPanel.check.showWarnings.ttip = Show/hide geometry warnings in the rocket design view. + ! BasicFrame BasicFrame.tab.Rocketdesign = Rocket design BasicFrame.tab.Flightconfig = Motors & Configuration @@ -1781,6 +1784,7 @@ RocketInfo.apogeeValue = N/A RocketInfo.Mach = (Mach RocketInfo.velocityValue = N/A RocketInfo.accelerationValue = N/A +RocketInfo.lbl.warnings = %d warning(s) ! FinSet FinSet.CrossSection.SQUARE = Square diff --git a/swing/src/net/sf/openrocket/gui/figureelements/RocketInfo.java b/swing/src/net/sf/openrocket/gui/figureelements/RocketInfo.java index bd0e37bd0..0e185251d 100644 --- a/swing/src/net/sf/openrocket/gui/figureelements/RocketInfo.java +++ b/swing/src/net/sf/openrocket/gui/figureelements/RocketInfo.java @@ -53,6 +53,7 @@ public class RocketInfo implements FigureElement { private double massWithoutMotors = 0; private WarningSet warnings = null; + private boolean showWarnings = true; private boolean calculatingData = false; private FlightData flightData = null; @@ -123,7 +124,15 @@ public class RocketInfo implements FigureElement { public void setWarnings(WarningSet warnings) { this.warnings = warnings.clone(); } - + + /** + * Set whether warnings should be shown. If false, the warnings are not shown. + * @param showWarnings whether to show warnings. + */ + public void setShowWarnings(boolean showWarnings) { + this.showWarnings = showWarnings; + } + public void setAOA(double aoa) { this.aoa = aoa; } @@ -329,25 +338,34 @@ public class RocketInfo implements FigureElement { if (warnings == null || warnings.isEmpty()) return; - GlyphVector[] texts = new GlyphVector[warnings.size()+1]; + final GlyphVector[] texts; double max = 0; - - //// Warning: - texts[0] = createText(trans.get("RocketInfo.Warning")); - int i=1; - for (Warning w: warnings) { - texts[i] = createText(w.toString()); - i++; - } - - for (GlyphVector v: texts) { - Rectangle2D rect = v.getVisualBounds(); - if (rect.getWidth() > max) - max = rect.getWidth(); + + if (showWarnings) { + texts = new GlyphVector[warnings.size()+1]; + + //// Warning: + texts[0] = createText(trans.get("RocketInfo.Warning")); + int i = 1; + for (Warning w : warnings) { + texts[i] = createText(w.toString()); + i++; + } + + for (GlyphVector v : texts) { + Rectangle2D rect = v.getVisualBounds(); + if (rect.getWidth() > max) + max = rect.getWidth(); + } + } else { + texts = new GlyphVector[1]; + texts[0] = createText(String.format(trans.get("RocketInfo.lbl.warnings"), warnings.size())); + Rectangle2D rect = texts[0].getVisualBounds(); + max = rect.getWidth(); } - float y = y2 - line * warnings.size(); + float y = y2 - line * (texts.length-1); g2.setColor(Color.RED); for (GlyphVector v: texts) { diff --git a/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java b/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java index aa7ef052e..e0bd87f1d 100644 --- a/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java +++ b/swing/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java @@ -9,6 +9,8 @@ import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.InputEvent; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.Arrays; @@ -133,6 +135,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change private final JPanel figureHolder; private JLabel infoMessage; + private JCheckBox showWarnings; private TreeSelectionModel selectionModel = null; @@ -423,11 +426,28 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change }); rotationSlider.setToolTipText(trans.get("RocketPanel.ttip.Rotation")); + // Bottom row + JPanel bottomRow = new JPanel(new MigLayout("fill, gapy 0, ins 0")); //// Click to select    Shift+click to select other    Double-click to edit    Click+drag to move infoMessage = new JLabel(trans.get("RocketPanel.lbl.infoMessage")); infoMessage.setFont(new Font("Sans Serif", Font.PLAIN, 9)); - add(infoMessage, "skip, span, gapleft 25, wrap"); + bottomRow.add(infoMessage); + + //// Show warnings + this.showWarnings = new JCheckBox(trans.get("RocketPanel.check.showWarnings")); + showWarnings.setSelected(true); + showWarnings.setToolTipText(trans.get("RocketPanel.check.showWarnings.ttip")); + bottomRow.add(showWarnings, "pushx, right"); + showWarnings.addItemListener(new ItemListener() { + @Override + public void itemStateChanged(ItemEvent e) { + updateExtras(); + updateFigures(); + } + }); + + add(bottomRow, "skip, growx, span, gapleft 25"); addExtras(); } @@ -782,6 +802,9 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change extraText.setMassWithMotors(cg.weight); extraText.setMassWithoutMotors( emptyInfo.getMass() ); extraText.setWarnings(warnings); + if (this.showWarnings != null) { + extraText.setShowWarnings(showWarnings.isSelected()); + } if (length > 0) { figure3d.setCG(cg);