Add dots to warning/error texts

This commit is contained in:
SiboVG 2023-03-27 22:44:55 +02:00
parent de8ab74b2d
commit 8c9a04b74e
7 changed files with 35 additions and 39 deletions

View File

@ -71,7 +71,7 @@ public class BasePartDTO {
setPartType(RASAeroCommonConstants.NOSE_CONE);
NoseCone noseCone = (NoseCone) component;
if (noseCone.isFlipped()) {
throw new RASAeroExportException("Nose cone may not be flipped");
throw new RASAeroExportException("Nose cone may not be flipped.");
}
setDiameter(((NoseCone) component).getAftRadius() * 2 * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_LENGTH);
} else if (component instanceof Transition) {
@ -83,11 +83,11 @@ public class BasePartDTO {
setPartType(RASAeroCommonConstants.BOOSTER);
AxialStage stage = (AxialStage) component;
if (stage.getChildCount() == 0 || !(stage.getChild(0) instanceof BodyTube)) {
throw new RASAeroExportException("First component of booster must be body tube");
throw new RASAeroExportException("First component of booster must be body tube.");
}
setDiameter(stage.getBoundingRadius() * 2 * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_LENGTH);
} else {
throw new RASAeroExportException("Unsupported component: " + component.getComponentName());
throw new RASAeroExportException("Unsupported component: ." + component.getComponentName());
}
setLength(component.getLength() * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_LENGTH);
@ -109,7 +109,7 @@ public class BasePartDTO {
public void setLength(Double length) throws RASAeroExportException {
if (MathUtil.equals(length, 0)) {
throw new RASAeroExportException(String.format("Length of '%s' must be greater than 0", component.getName()));
throw new RASAeroExportException(String.format("Length of '%s' must be greater than 0.", component.getName()));
}
this.length = length;
}
@ -120,7 +120,7 @@ public class BasePartDTO {
public void setDiameter(Double diameter) throws RASAeroExportException {
if (MathUtil.equals(diameter, 0)) {
throw new RASAeroExportException(String.format("Diameter of '%s' must be greater than 0", component.getName()));
throw new RASAeroExportException(String.format("Diameter of '%s' must be greater than 0.", component.getName()));
}
this.diameter = diameter;
}

View File

@ -79,7 +79,7 @@ public class BodyTubeDTO extends BasePartDTO implements BodyTubeDTOAdapter {
public void setLaunchLugDiameter(Double launchLugDiameter) throws RASAeroExportException {
if (MathUtil.equals(launchLugDiameter, 0)) {
throw new RASAeroExportException("Launch lug diameter can not be 0");
throw new RASAeroExportException("Launch lug diameter can not be 0.");
}
this.launchLugDiameter = launchLugDiameter;
}
@ -90,7 +90,7 @@ public class BodyTubeDTO extends BasePartDTO implements BodyTubeDTOAdapter {
public void setLaunchLugLength(Double launchLugLength) throws RASAeroExportException {
if (MathUtil.equals(launchLugLength, 0)) {
throw new RASAeroExportException("Launch lug length can not be 0");
throw new RASAeroExportException("Launch lug length can not be 0.");
}
this.launchLugLength = launchLugLength;
}
@ -101,7 +101,7 @@ public class BodyTubeDTO extends BasePartDTO implements BodyTubeDTOAdapter {
public void setRailGuideDiameter(Double railGuideDiameter) throws RASAeroExportException {
if (MathUtil.equals(railGuideDiameter, 0)) {
throw new RASAeroExportException("Rail button diameter can not be 0");
throw new RASAeroExportException("Rail button diameter can not be 0.");
}
this.railGuideDiameter = railGuideDiameter;
}
@ -112,7 +112,7 @@ public class BodyTubeDTO extends BasePartDTO implements BodyTubeDTOAdapter {
public void setRailGuideHeight(Double railGuideHeight) throws RASAeroExportException {
if (MathUtil.equals(railGuideHeight, 0)) {
throw new RASAeroExportException("Rail button height can not be 0");
throw new RASAeroExportException("Rail button height can not be 0.");
}
this.railGuideHeight = railGuideHeight;
}
@ -123,7 +123,7 @@ public class BodyTubeDTO extends BasePartDTO implements BodyTubeDTOAdapter {
public void setLaunchShoeArea(Double launchShoeArea) throws RASAeroExportException {
if (MathUtil.equals(launchShoeArea, 0)) {
throw new RASAeroExportException("Launch shoe area can not be 0");
throw new RASAeroExportException("Launch shoe area can not be 0.");
}
this.launchShoeArea = launchShoeArea;
}

View File

@ -18,11 +18,11 @@ public interface BodyTubeDTOAdapter {
setFin(new FinDTO((TrapezoidFinSet) child));
} else if (child instanceof LaunchLug) {
if (!MathUtil.equals(getRailGuideDiameter(), 0) || !MathUtil.equals(getRailGuideHeight(), 0)) { // only one check on diameter or length should be sufficient, but just to be safe
warnings.add(String.format("Already added a rail button, ignoring launch lug '%s'", child.getName()));
warnings.add(String.format("Already added a rail button, ignoring launch lug '%s'.", child.getName()));
continue;
}
if (!MathUtil.equals(getLaunchShoeArea(), 0)) {
warnings.add(String.format("Already added a launch shoe, ignoring launch lug '%s'", child.getName()));
warnings.add(String.format("Already added a launch shoe, ignoring launch lug '%s'.", child.getName()));
continue;
}
@ -38,11 +38,11 @@ public interface BodyTubeDTOAdapter {
}
} else if (child instanceof RailButton) {
if (!MathUtil.equals(getLaunchLugDiameter(), 0) || !MathUtil.equals(getLaunchLugLength(), 0)) { // only one check on diameter or length should be sufficient, but just to be safe
warnings.add(String.format("Already added a launch lug, ignoring rail button '%s'", child.getName()));
warnings.add(String.format("Already added a launch lug, ignoring rail button '%s'.", child.getName()));
continue;
}
if (!MathUtil.equals(getLaunchShoeArea(), 0)) {
warnings.add(String.format("Already added a launch shoe, ignoring rail button '%s'", child.getName()));
warnings.add(String.format("Already added a launch shoe, ignoring rail button '%s'.", child.getName()));
continue;
}
@ -51,7 +51,7 @@ public interface BodyTubeDTOAdapter {
setRailGuideHeight(button.getTotalHeight() * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_LENGTH);
if (button.getInstanceCount() != 2) {
warnings.add(String.format("Instance count of '%s' equals %d, defaulting to 2",
warnings.add(String.format("Instance count of '%s' equals %d, defaulting to 2.",
button.getName(), button.getInstanceCount()));
}
} else {

View File

@ -14,7 +14,6 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlElementRefs;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
@ -24,11 +23,8 @@ import net.sf.openrocket.rocketcomponent.SymmetricComponent;
import net.sf.openrocket.rocketcomponent.Transition;
import net.sf.openrocket.rocketcomponent.TrapezoidFinSet;
import net.sf.openrocket.rocketcomponent.position.AxialMethod;
import net.sf.openrocket.util.ArrayList;
import net.sf.openrocket.util.MathUtil;
import java.util.List;
@XmlRootElement(name = RASAeroCommonConstants.BOOSTER)
@XmlAccessorType(XmlAccessType.FIELD)
public class BoosterDTO implements BodyTubeDTOAdapter {
@ -105,43 +101,43 @@ public class BoosterDTO implements BodyTubeDTOAdapter {
int stageNr = rocket.getChildPosition(stage); // Use this instead of stage.getStageNumber() in case there are parallel stages in the design
if (stageNr != 1 && stageNr != 2) {
throw new RASAeroExportException(String.format("Invalid stage number '%d' for booster stage '%s'", stageNr, stage.getName()));
throw new RASAeroExportException(String.format("Invalid stage number '%d' for booster stage '%s'.", stageNr, stage.getName()));
}
if (stage.getChildCount() == 0) {
throw new RASAeroExportException(String.format("Stage '%s' can not be empty", stage.getName()));
throw new RASAeroExportException(String.format("Stage '%s' may not be empty.", stage.getName()));
}
RocketComponent firstChild = stage.getChild(0);
if (!(firstChild instanceof BodyTube) &&
!(firstChild instanceof Transition && !(firstChild instanceof NoseCone))) {
throw new RASAeroExportException(String.format("First component of stage '%s' must be a body tube or transition", stage.getName()));
throw new RASAeroExportException(String.format("First component of stage '%s' must be a body tube or transition.", stage.getName()));
}
final BodyTube firstTube;
if (firstChild instanceof Transition) {
if (stage.getChildCount() == 1 || !(stage.getChild(1) instanceof BodyTube)) {
throw new RASAeroExportException(
String.format("When the first component of stage '%s' is a transition, the second one must be a body tube",
String.format("When the first component of stage '%s' is a transition, the second one must be a body tube.",
stage.getName()));
}
Transition transition = (Transition) firstChild;
SymmetricComponent previousComponent = transition.getPreviousSymmetricComponent();
if (previousComponent == null) {
throw new RASAeroExportException(String.format("No previous component for '%s' in stage '%s'",
throw new RASAeroExportException(String.format("No previous component for '%s' in stage '%s'.",
firstChild.getName(), stage.getName()));
}
if (!MathUtil.equals(transition.getForeRadius(), previousComponent.getAftRadius())) {
throw new RASAeroExportException(
String.format("Transition '%s' in stage '%s' must have the same fore radius as the aft radius of its previous component '%s'",
String.format("Transition '%s' in stage '%s' must have the same fore radius as the aft radius of its previous component '%s'.",
transition.getName(), stage.getName(), previousComponent.getName()));
}
firstTube = (BodyTube) stage.getChild(1);
if (!MathUtil.equals(firstTube.getOuterRadius(), transition.getAftRadius())) {
throw new RASAeroExportException(
String.format("Radius of '%s' in stage '%s' must be the same as the aft radius of '%s",
String.format("Radius of '%s' in stage '%s' must be the same as the aft radius of '%s'.",
firstTube.getName(), stage.getName(), transition.getName()));
}
@ -150,13 +146,13 @@ public class BoosterDTO implements BodyTubeDTOAdapter {
setInsideDiameter(transition.getForeRadius() * 2 * RASAeroCommonConstants.OPENROCKET_TO_RASAERO_LENGTH);
if (stage.getChildCount() > 2) {
warnings.add(String.format("Stage '%s' can only contain a body tube and transition shoulder, ignoring other %d components",
warnings.add(String.format("Stage '%s' can only contain a body tube and transition shoulder, ignoring other %d components.",
stage.getName(), stage.getChildCount() - 2));
}
} else {
firstTube = (BodyTube) stage.getChild(0);
if (stage.getChildCount() > 1) {
warnings.add(String.format("Stage '%s' can only contain a body tube, ignoring other %d components",
warnings.add(String.format("Stage '%s' can only contain a body tube, ignoring other %d components.",
stage.getName(), stage.getChildCount() - 1));
}
}
@ -166,7 +162,7 @@ public class BoosterDTO implements BodyTubeDTOAdapter {
TrapezoidFinSet finSet = getFinSetFromBodyTube(firstTube);
if (finSet == null) {
throw new RASAeroExportException(
String.format("Body tube '%s' in stage '%s' must have a TrapezoidFinSet",
String.format("Body tube '%s' in stage '%s' must have a TrapezoidFinSet.",
firstTube.getName(), stage.getName()));
}
setFin(new FinDTO(finSet));
@ -201,7 +197,7 @@ public class BoosterDTO implements BodyTubeDTOAdapter {
public void setLength(Double length) {
if (MathUtil.equals(length, 0)) {
errors.add(String.format("Length of '%s' must be greater than 0", component.getName()));
errors.add(String.format("Length of '%s' must be greater than 0.", component.getName()));
return;
}
this.length = length;
@ -213,7 +209,7 @@ public class BoosterDTO implements BodyTubeDTOAdapter {
public void setDiameter(Double diameter) throws RASAeroExportException {
if (MathUtil.equals(diameter, 0)) {
throw new RASAeroExportException(String.format("Diameter of '%s' must be greater than 0", component.getName()));
throw new RASAeroExportException(String.format("Diameter of '%s' must be greater than 0.", component.getName()));
}
this.diameter = diameter;
}
@ -224,7 +220,7 @@ public class BoosterDTO implements BodyTubeDTOAdapter {
public void setInsideDiameter(Double insideDiameter) throws RASAeroExportException {
if (MathUtil.equals(insideDiameter, 0)) {
throw new RASAeroExportException(String.format("Inside diameter of '%s' must be greater than 0", component.getName()));
throw new RASAeroExportException(String.format("Inside diameter of '%s' must be greater than 0.", component.getName()));
}
this.insideDiameter = insideDiameter;
}

View File

@ -57,7 +57,7 @@ public class FinDTO {
int finCount = fin.getFinCount();
if (finCount < 3 || finCount > 8) {
throw new RASAeroExportException(
String.format("Fin set '%s' must have a fin count between 3 and 8", fin.getName()));
String.format("Fin set '%s' must have a fin count between 3 and 8.", fin.getName()));
}
setCount(fin.getFinCount());

View File

@ -82,17 +82,17 @@ public class RocketDesignDTO {
try {
RocketComponent component = sustainer.getChild(i);
if (i == 0 && !(component instanceof NoseCone)) {
errors.add("First component of the sustainer must be a nose cone");
errors.add("First component of the sustainer must be a nose cone.");
return;
} else if (i == 1 && !(component instanceof BodyTube)) {
errors.add("Second component of the sustainer must be a body tube");
errors.add("Second component of the sustainer must be a body tube.");
return;
}
if (component instanceof BodyTube) {
addExternalPart(new BodyTubeDTO((BodyTube) component, warnings, errors));
} else if (component instanceof NoseCone) {
if (i != 0) {
errors.add("A nose cone can only be the first component of the rocket");
errors.add("A nose cone can only be the first component of the rocket.");
return;
}
addExternalPart(new NoseConeDTO((NoseCone) component, warnings, errors));

View File

@ -36,16 +36,16 @@ public class TransitionDTO extends BasePartDTO {
super(transition, warnings, errors);
if (!transition.getShapeType().equals(Transition.Shape.CONICAL)) {
throw new RASAeroExportException("RASAero only supports conical transitions");
throw new RASAeroExportException("RASAero only supports conical transitions.");
}
SymmetricComponent previousComp = transition.getPreviousSymmetricComponent();
if (previousComp == null) {
throw new RASAeroExportException(String.format("Transition '%s' has no previous component", transition.getName()));
throw new RASAeroExportException(String.format("Transition '%s' has no previous component.", transition.getName()));
}
if (!MathUtil.equals(transition.getForeRadius(), previousComp.getAftRadius())) {
throw new RASAeroExportException(
String.format("Transition '%s' should have the same fore radius as the aft radius (%f) of its previous component, not (%f)",
String.format("Transition '%s' should have the same fore radius as the aft radius (%f) of its previous component, not %f.",
transition.getName(), previousComp.getAftRadius(), transition.getForeRadius()));
}