[#1999] Add checkbox to show/hide warnings
This commit is contained in:
		
							parent
							
								
									a7e094311b
								
							
						
					
					
						commit
						b718c5a0e1
					
				| @ -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.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 | ||||
|  | ||||
| @ -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) { | ||||
|  | ||||
| @ -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")); | ||||
| 
 | ||||
| 		//// <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.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); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user