Merge pull request #2010 from SiboVG/issue-1999-try2
[#1999] Add checkbox to show/hide warnings
This commit is contained in:
		
						commit
						11ad263efb
					
				| @ -69,6 +69,9 @@ RocketPanel.btn.Stages.Toggle.ttip = Toggle this button to activate/deactivate t | |||||||
| RocketPanel.btn.Stages.NoChildren.ttip = <html>This stage does not have child components and is therefore marked as inactive.<br>Add components to the stage to activate it.</html> | RocketPanel.btn.Stages.NoChildren.ttip = <html>This stage does not have child components and is therefore marked as inactive.<br>Add components to the stage to activate it.</html> | ||||||
| RocketPanel.ttip.Rotation = Change the rocket's roll rotation (only affects the rocket view) | 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 | ||||||
| BasicFrame.tab.Rocketdesign = Rocket design | BasicFrame.tab.Rocketdesign = Rocket design | ||||||
| BasicFrame.tab.Flightconfig = Motors & Configuration | BasicFrame.tab.Flightconfig = Motors & Configuration | ||||||
| @ -1781,6 +1784,7 @@ RocketInfo.apogeeValue = N/A | |||||||
| RocketInfo.Mach = (Mach | RocketInfo.Mach = (Mach | ||||||
| RocketInfo.velocityValue = N/A | RocketInfo.velocityValue = N/A | ||||||
| RocketInfo.accelerationValue = N/A | RocketInfo.accelerationValue = N/A | ||||||
|  | RocketInfo.lbl.warnings = %d warning(s) | ||||||
| 
 | 
 | ||||||
| ! FinSet | ! FinSet | ||||||
| FinSet.CrossSection.SQUARE = Square | FinSet.CrossSection.SQUARE = Square | ||||||
|  | |||||||
| @ -53,6 +53,7 @@ public class RocketInfo implements FigureElement { | |||||||
| 	private double massWithoutMotors = 0; | 	private double massWithoutMotors = 0; | ||||||
| 	 | 	 | ||||||
| 	private WarningSet warnings = null; | 	private WarningSet warnings = null; | ||||||
|  | 	private boolean showWarnings = true; | ||||||
| 	 | 	 | ||||||
| 	private boolean calculatingData = false; | 	private boolean calculatingData = false; | ||||||
| 	private FlightData flightData = null; | 	private FlightData flightData = null; | ||||||
| @ -124,6 +125,14 @@ public class RocketInfo implements FigureElement { | |||||||
| 		this.warnings = warnings.clone(); | 		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) { | 	public void setAOA(double aoa) { | ||||||
| 		this.aoa = aoa; | 		this.aoa = aoa; | ||||||
| 	} | 	} | ||||||
| @ -329,25 +338,34 @@ public class RocketInfo implements FigureElement { | |||||||
| 		if (warnings == null || warnings.isEmpty()) | 		if (warnings == null || warnings.isEmpty()) | ||||||
| 			return; | 			return; | ||||||
| 		 | 		 | ||||||
| 		GlyphVector[] texts = new GlyphVector[warnings.size()+1]; | 		final GlyphVector[] texts; | ||||||
| 		double max = 0; | 		double max = 0; | ||||||
| 
 | 
 | ||||||
| 		//// Warning: | 		if (showWarnings) { | ||||||
| 		texts[0] = createText(trans.get("RocketInfo.Warning")); | 			texts = new GlyphVector[warnings.size()+1]; | ||||||
| 		int i=1; |  | ||||||
| 		for (Warning w: warnings) { |  | ||||||
| 			texts[i] = createText(w.toString()); |  | ||||||
| 			i++; |  | ||||||
| 		} |  | ||||||
| 
 | 
 | ||||||
| 		for (GlyphVector v: texts) { | 			//// Warning: | ||||||
| 			Rectangle2D rect = v.getVisualBounds(); | 			texts[0] = createText(trans.get("RocketInfo.Warning")); | ||||||
| 			if (rect.getWidth() > max) | 			int i = 1; | ||||||
| 				max = rect.getWidth(); | 			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); | 		g2.setColor(Color.RED); | ||||||
| 
 | 
 | ||||||
| 		for (GlyphVector v: texts) { | 		for (GlyphVector v: texts) { | ||||||
|  | |||||||
| @ -9,6 +9,8 @@ import java.awt.Point; | |||||||
| import java.awt.event.ActionEvent; | import java.awt.event.ActionEvent; | ||||||
| import java.awt.event.ActionListener; | import java.awt.event.ActionListener; | ||||||
| import java.awt.event.InputEvent; | import java.awt.event.InputEvent; | ||||||
|  | import java.awt.event.ItemEvent; | ||||||
|  | import java.awt.event.ItemListener; | ||||||
| import java.awt.event.MouseEvent; | import java.awt.event.MouseEvent; | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
| import java.util.Arrays; | import java.util.Arrays; | ||||||
| @ -133,6 +135,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change | |||||||
| 	private final JPanel figureHolder; | 	private final JPanel figureHolder; | ||||||
| 
 | 
 | ||||||
| 	private JLabel infoMessage; | 	private JLabel infoMessage; | ||||||
|  | 	private JCheckBox showWarnings; | ||||||
| 
 | 
 | ||||||
| 	private TreeSelectionModel selectionModel = null; | 	private TreeSelectionModel selectionModel = null; | ||||||
| 
 | 
 | ||||||
| @ -423,11 +426,28 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change | |||||||
| 		}); | 		}); | ||||||
| 		rotationSlider.setToolTipText(trans.get("RocketPanel.ttip.Rotation")); | 		rotationSlider.setToolTipText(trans.get("RocketPanel.ttip.Rotation")); | ||||||
| 
 | 
 | ||||||
|  | 		// Bottom row | ||||||
|  | 		JPanel bottomRow = new JPanel(new MigLayout("fill, gapy 0, ins 0")); | ||||||
| 
 | 
 | ||||||
| 		//// <html>Click to select    Shift+click to select other    Double-click to edit    Click+drag to move | 		//// <html>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 = new JLabel(trans.get("RocketPanel.lbl.infoMessage")); | ||||||
| 		infoMessage.setFont(new Font("Sans Serif", Font.PLAIN, 9)); | 		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(); | 		addExtras(); | ||||||
| 	} | 	} | ||||||
| @ -782,6 +802,9 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change | |||||||
| 		extraText.setMassWithMotors(cg.weight); | 		extraText.setMassWithMotors(cg.weight); | ||||||
| 		extraText.setMassWithoutMotors( emptyInfo.getMass() ); | 		extraText.setMassWithoutMotors( emptyInfo.getMass() ); | ||||||
| 		extraText.setWarnings(warnings); | 		extraText.setWarnings(warnings); | ||||||
|  | 		if (this.showWarnings != null) { | ||||||
|  | 			extraText.setShowWarnings(showWarnings.isSelected()); | ||||||
|  | 		} | ||||||
| 
 | 
 | ||||||
| 		if (length > 0) { | 		if (length > 0) { | ||||||
| 			figure3d.setCG(cg); | 			figure3d.setCG(cg); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user