Use enhanced switch
This commit is contained in:
parent
4952320030
commit
aebb8b87d2
@ -93,50 +93,29 @@ class FunctionToken extends CalculationToken {
|
|||||||
* The actual function application on a double
|
* The actual function application on a double
|
||||||
*/
|
*/
|
||||||
private double applyFunction(double x){
|
private double applyFunction(double x){
|
||||||
switch (function) {
|
return switch (function) {
|
||||||
case ABS:
|
case ABS -> Math.abs(x);
|
||||||
return Math.abs(x);
|
case ACOS -> Math.acos(x);
|
||||||
case ACOS:
|
case ASIN -> Math.asin(x);
|
||||||
return Math.acos(x);
|
case ATAN -> Math.atan(x);
|
||||||
case ASIN:
|
case CBRT -> Math.cbrt(x);
|
||||||
return Math.asin(x);
|
case CEIL -> Math.ceil(x);
|
||||||
case ATAN:
|
case COS -> Math.cos(x);
|
||||||
return Math.atan(x);
|
case COSH -> Math.cosh(x);
|
||||||
case CBRT:
|
case EXP -> Math.exp(x);
|
||||||
return Math.cbrt(x);
|
case EXPM1 -> Math.expm1(x);
|
||||||
case CEIL:
|
case FLOOR -> Math.floor(x);
|
||||||
return Math.ceil(x);
|
case ROUND -> Math.round(x);
|
||||||
case COS:
|
case RANDOM -> Math.random() * x;
|
||||||
return Math.cos(x);
|
case LOG -> Math.log(x);
|
||||||
case COSH:
|
case LOG10 -> Math.log10(x);
|
||||||
return Math.cosh(x);
|
case SIN -> Math.sin(x);
|
||||||
case EXP:
|
case SINH -> Math.sinh(x);
|
||||||
return Math.exp(x);
|
case SQRT -> Math.sqrt(x);
|
||||||
case EXPM1:
|
case TAN -> Math.tan(x);
|
||||||
return Math.expm1(x);
|
case TANH -> Math.tanh(x);
|
||||||
case FLOOR:
|
default -> Double.NaN; // should not happen ;)
|
||||||
return Math.floor(x);
|
};
|
||||||
case ROUND:
|
|
||||||
return Math.round(x);
|
|
||||||
case RANDOM:
|
|
||||||
return Math.random()*x;
|
|
||||||
case LOG:
|
|
||||||
return Math.log(x);
|
|
||||||
case LOG10:
|
|
||||||
return Math.log10(x);
|
|
||||||
case SIN:
|
|
||||||
return Math.sin(x);
|
|
||||||
case SINH:
|
|
||||||
return Math.sinh(x);
|
|
||||||
case SQRT:
|
|
||||||
return Math.sqrt(x);
|
|
||||||
case TAN:
|
|
||||||
return Math.tan(x);
|
|
||||||
case TANH:
|
|
||||||
return Math.tanh(x);
|
|
||||||
default:
|
|
||||||
return Double.NaN; // should not happen ;)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,24 +50,16 @@ class OperatorToken extends CalculationToken {
|
|||||||
* @return the corresponding {@link Operation}
|
* @return the corresponding {@link Operation}
|
||||||
*/
|
*/
|
||||||
static Operation getOperation(char c) {
|
static Operation getOperation(char c) {
|
||||||
switch (c) {
|
return switch (c) {
|
||||||
case '+':
|
case '+' -> Operation.ADDITION;
|
||||||
return Operation.ADDITION;
|
case '-' -> Operation.SUBTRACTION;
|
||||||
case '-':
|
case '*' -> Operation.MULTIPLICATION;
|
||||||
return Operation.SUBTRACTION;
|
case '/' -> Operation.DIVISION;
|
||||||
case '*':
|
case '^' -> Operation.EXPONENTIATION;
|
||||||
return Operation.MULTIPLICATION;
|
case '#' -> Operation.UNARY_MINUS;
|
||||||
case '/':
|
case '%' -> Operation.MODULO;
|
||||||
return Operation.DIVISION;
|
default -> null;
|
||||||
case '^':
|
};
|
||||||
return Operation.EXPONENTIATION;
|
|
||||||
case '#':
|
|
||||||
return Operation.UNARY_MINUS;
|
|
||||||
case '%':
|
|
||||||
return Operation.MODULO;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isOperator(char c) {
|
static boolean isOperator(char c) {
|
||||||
@ -133,26 +125,17 @@ class OperatorToken extends CalculationToken {
|
|||||||
|
|
||||||
//System.out.println("Applying "+operation.toString()+" to values starting "+values[0]);
|
//System.out.println("Applying "+operation.toString()+" to values starting "+values[0]);
|
||||||
|
|
||||||
switch (operation) {
|
return switch (operation) {
|
||||||
case ADDITION:
|
case ADDITION -> values[0] + values[1];
|
||||||
return values[0] + values[1];
|
case SUBTRACTION -> values[0] - values[1];
|
||||||
case SUBTRACTION:
|
case MULTIPLICATION -> values[0] * values[1];
|
||||||
return values[0] - values[1];
|
case EXPONENTIATION -> Math.pow(values[0], values[1]);
|
||||||
case MULTIPLICATION:
|
case DIVISION -> values[0] / values[1];
|
||||||
return values[0] * values[1];
|
case UNARY_MINUS -> -values[0];
|
||||||
case EXPONENTIATION:
|
case UNARY_PLUS -> values[0];
|
||||||
return Math.pow(values[0], values[1]);
|
case MODULO -> values[0] % values[1];
|
||||||
case DIVISION:
|
default -> 0;
|
||||||
return values[0] / values[1];
|
};
|
||||||
case UNARY_MINUS:
|
|
||||||
return -values[0];
|
|
||||||
case UNARY_PLUS:
|
|
||||||
return values[0];
|
|
||||||
case MODULO:
|
|
||||||
return values[0] % values[1];
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -165,20 +148,11 @@ class OperatorToken extends CalculationToken {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int getOperandCount() {
|
int getOperandCount() {
|
||||||
switch (operation) {
|
return switch (operation) {
|
||||||
case ADDITION:
|
case ADDITION, SUBTRACTION, MULTIPLICATION, DIVISION, EXPONENTIATION, MODULO -> 2;
|
||||||
case SUBTRACTION:
|
case UNARY_MINUS, UNARY_PLUS -> 1;
|
||||||
case MULTIPLICATION:
|
default -> 0;
|
||||||
case DIVISION:
|
};
|
||||||
case EXPONENTIATION:
|
|
||||||
case MODULO:
|
|
||||||
return 2;
|
|
||||||
case UNARY_MINUS:
|
|
||||||
case UNARY_PLUS:
|
|
||||||
return 1;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,12 +51,10 @@ public class SystemInfo {
|
|||||||
* otherwise
|
* otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean isConfined() {
|
public static boolean isConfined() {
|
||||||
switch (getPlatform()) {
|
return switch (getPlatform()) {
|
||||||
case UNIX:
|
case UNIX -> (System.getenv("SNAP_VERSION") != null);
|
||||||
return (System.getenv("SNAP_VERSION") != null);
|
default -> false;
|
||||||
default:
|
};
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -203,16 +203,12 @@ public class Databases {
|
|||||||
* @return the database of the type given
|
* @return the database of the type given
|
||||||
*/
|
*/
|
||||||
private static Database<Material> getDatabase(Material.Type type){
|
private static Database<Material> getDatabase(Material.Type type){
|
||||||
switch (type) {
|
return switch (type) {
|
||||||
case BULK:
|
case BULK -> BULK_MATERIAL;
|
||||||
return BULK_MATERIAL;
|
case SURFACE -> SURFACE_MATERIAL;
|
||||||
case SURFACE:
|
case LINE -> LINE_MATERIAL;
|
||||||
return SURFACE_MATERIAL;
|
default -> throw new IllegalArgumentException("Illegal material type: " + type);
|
||||||
case LINE:
|
};
|
||||||
return LINE_MATERIAL;
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("Illegal material type: " + type);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,16 +14,12 @@ public final class TipShapeCode {
|
|||||||
* @return a CrossSection instance
|
* @return a CrossSection instance
|
||||||
*/
|
*/
|
||||||
public static FinSet.CrossSection convertTipShapeCode(int tipShape) {
|
public static FinSet.CrossSection convertTipShapeCode(int tipShape) {
|
||||||
switch (tipShape) {
|
return switch (tipShape) {
|
||||||
case 0:
|
case 0 -> FinSet.CrossSection.SQUARE;
|
||||||
return FinSet.CrossSection.SQUARE;
|
case 1 -> FinSet.CrossSection.ROUNDED;
|
||||||
case 1:
|
case 2 -> FinSet.CrossSection.AIRFOIL;
|
||||||
return FinSet.CrossSection.ROUNDED;
|
default -> FinSet.CrossSection.SQUARE;
|
||||||
case 2:
|
};
|
||||||
return FinSet.CrossSection.AIRFOIL;
|
|
||||||
default:
|
|
||||||
return FinSet.CrossSection.SQUARE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int convertTipShapeCode(FinSet.CrossSection cs) {
|
public static int convertTipShapeCode(FinSet.CrossSection cs) {
|
||||||
|
@ -33,17 +33,12 @@ public class FinSetSaver extends ExternalComponentSaver {
|
|||||||
// anymore
|
// anymore
|
||||||
String offset = "center";
|
String offset = "center";
|
||||||
double offsetVal = fins.getTabOffset();
|
double offsetVal = fins.getTabOffset();
|
||||||
switch (fins.getTabOffsetMethod()) {
|
offset = switch (fins.getTabOffsetMethod()) {
|
||||||
case TOP:
|
case TOP -> "front";
|
||||||
offset = "front";
|
case BOTTOM -> "end";
|
||||||
break;
|
case MIDDLE -> "center";
|
||||||
case BOTTOM:
|
default -> offset;
|
||||||
offset = "end";
|
};
|
||||||
break;
|
|
||||||
case MIDDLE:
|
|
||||||
offset = "center";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
elements.add("<tabposition relativeto=\"" + offset + "\">" +
|
elements.add("<tabposition relativeto=\"" + offset + "\">" +
|
||||||
offsetVal + "</tabposition>");
|
offsetVal + "</tabposition>");
|
||||||
elements.add("<tabposition relativeto=\"" +
|
elements.add("<tabposition relativeto=\"" +
|
||||||
|
@ -436,16 +436,12 @@ class FinSetHandler extends AbstractElementHandler {
|
|||||||
* @return a CrossSection instance
|
* @return a CrossSection instance
|
||||||
*/
|
*/
|
||||||
public static FinSet.CrossSection convertTipShapeCode(int tipShape) {
|
public static FinSet.CrossSection convertTipShapeCode(int tipShape) {
|
||||||
switch (tipShape) {
|
return switch (tipShape) {
|
||||||
case 0:
|
case 0 -> FinSet.CrossSection.SQUARE;
|
||||||
return FinSet.CrossSection.SQUARE;
|
case 1 -> FinSet.CrossSection.ROUNDED;
|
||||||
case 1:
|
case 2 -> FinSet.CrossSection.AIRFOIL;
|
||||||
return FinSet.CrossSection.ROUNDED;
|
default -> FinSet.CrossSection.SQUARE;
|
||||||
case 2:
|
};
|
||||||
return FinSet.CrossSection.AIRFOIL;
|
|
||||||
default:
|
|
||||||
return FinSet.CrossSection.SQUARE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int convertTipShapeCode(FinSet.CrossSection cs) {
|
public static int convertTipShapeCode(FinSet.CrossSection cs) {
|
||||||
|
@ -191,22 +191,13 @@ public abstract class Material implements Comparable<Material> {
|
|||||||
* @return the new material
|
* @return the new material
|
||||||
*/
|
*/
|
||||||
public static Material newMaterial(Type type, String name, double density, boolean userDefined) {
|
public static Material newMaterial(Type type, String name, double density, boolean userDefined) {
|
||||||
switch (type) {
|
return switch (type) {
|
||||||
case LINE:
|
case LINE -> new Line(name, density, userDefined);
|
||||||
return new Material.Line(name, density, userDefined);
|
case SURFACE -> new Surface(name, density, userDefined);
|
||||||
|
case BULK -> new Bulk(name, density, userDefined);
|
||||||
case SURFACE:
|
case CUSTOM -> new Custom(name, density, userDefined);
|
||||||
return new Material.Surface(name, density, userDefined);
|
default -> throw new IllegalArgumentException("Unknown material type: " + type);
|
||||||
|
};
|
||||||
case BULK:
|
|
||||||
return new Material.Bulk(name, density, userDefined);
|
|
||||||
|
|
||||||
case CUSTOM:
|
|
||||||
return new Material.Custom(name, density, userDefined);
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("Unknown material type: " + type);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toStorableString() {
|
public String toStorableString() {
|
||||||
@ -248,19 +239,12 @@ public abstract class Material implements Comparable<Material> {
|
|||||||
throw new IllegalArgumentException("Illegal material string: " + str, e);
|
throw new IllegalArgumentException("Illegal material string: " + str, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
return switch (type) {
|
||||||
case BULK:
|
case BULK -> new Bulk(name, density, userDefined);
|
||||||
return new Material.Bulk(name, density, userDefined);
|
case SURFACE -> new Surface(name, density, userDefined);
|
||||||
|
case LINE -> new Line(name, density, userDefined);
|
||||||
case SURFACE:
|
default -> throw new IllegalArgumentException("Illegal material string: " + str);
|
||||||
return new Material.Surface(name, density, userDefined);
|
};
|
||||||
|
|
||||||
case LINE:
|
|
||||||
return new Material.Line(name, density, userDefined);
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("Illegal material string: " + str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -46,16 +46,12 @@ public class MaterialHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Material getMaterial(Material material) {
|
public Material getMaterial(Material material) {
|
||||||
switch (material.getType()) {
|
return switch (material.getType()) {
|
||||||
case BULK:
|
case BULK -> getBulkMaterial((Material.Bulk) material);
|
||||||
return getBulkMaterial((Material.Bulk) material);
|
case SURFACE -> getSurfaceMaterial((Material.Surface) material, null);
|
||||||
case SURFACE:
|
case LINE -> getLineMaterial((Material.Line) material);
|
||||||
return getSurfaceMaterial((Material.Surface) material, null);
|
default -> null;
|
||||||
case LINE:
|
};
|
||||||
return getLineMaterial((Material.Line) material);
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Material.Bulk getBulkMaterial(Material.Bulk material) {
|
public Material.Bulk getBulkMaterial(Material.Bulk material) {
|
||||||
|
@ -218,31 +218,19 @@ public class OpenRocketComponentSaver {
|
|||||||
* for the preset type
|
* for the preset type
|
||||||
*/
|
*/
|
||||||
private static BaseComponentDTO toComponentDTO(ComponentPreset thePreset) {
|
private static BaseComponentDTO toComponentDTO(ComponentPreset thePreset) {
|
||||||
switch (thePreset.getType()) {
|
return switch (thePreset.getType()) {
|
||||||
case BODY_TUBE:
|
case BODY_TUBE -> new BodyTubeDTO(thePreset);
|
||||||
return new BodyTubeDTO(thePreset);
|
case TUBE_COUPLER -> new TubeCouplerDTO(thePreset);
|
||||||
case TUBE_COUPLER:
|
case NOSE_CONE -> new NoseConeDTO(thePreset);
|
||||||
return new TubeCouplerDTO(thePreset);
|
case TRANSITION -> new TransitionDTO(thePreset);
|
||||||
case NOSE_CONE:
|
case BULK_HEAD -> new BulkHeadDTO(thePreset);
|
||||||
return new NoseConeDTO(thePreset);
|
case CENTERING_RING -> new CenteringRingDTO(thePreset);
|
||||||
case TRANSITION:
|
case ENGINE_BLOCK -> new EngineBlockDTO(thePreset);
|
||||||
return new TransitionDTO(thePreset);
|
case LAUNCH_LUG -> new LaunchLugDTO(thePreset);
|
||||||
case BULK_HEAD:
|
case RAIL_BUTTON -> new RailButtonDTO(thePreset);
|
||||||
return new BulkHeadDTO(thePreset);
|
case STREAMER -> new StreamerDTO(thePreset);
|
||||||
case CENTERING_RING:
|
case PARACHUTE -> new ParachuteDTO(thePreset);
|
||||||
return new CenteringRingDTO(thePreset);
|
};
|
||||||
case ENGINE_BLOCK:
|
|
||||||
return new EngineBlockDTO(thePreset);
|
|
||||||
case LAUNCH_LUG:
|
|
||||||
return new LaunchLugDTO(thePreset);
|
|
||||||
case RAIL_BUTTON:
|
|
||||||
return new RailButtonDTO(thePreset);
|
|
||||||
case STREAMER:
|
|
||||||
return new StreamerDTO(thePreset);
|
|
||||||
case PARACHUTE:
|
|
||||||
return new ParachuteDTO(thePreset);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,20 +84,14 @@ public class GraalJSScriptEngineFactory implements ScriptEngineFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Object getParameter(String key) {
|
public Object getParameter(String key) {
|
||||||
switch (key) {
|
return switch (key) {
|
||||||
case "javax.script.name":
|
case "javax.script.name" -> "javascript";
|
||||||
return "javascript";
|
case "javax.script.engine" -> this.getEngineName();
|
||||||
case "javax.script.engine":
|
case "javax.script.engine_version" -> this.getEngineVersion();
|
||||||
return this.getEngineName();
|
case "javax.script.language" -> this.getLanguageName();
|
||||||
case "javax.script.engine_version":
|
case "javax.script.language_version" -> this.getLanguageVersion();
|
||||||
return this.getEngineVersion();
|
default -> null;
|
||||||
case "javax.script.language":
|
};
|
||||||
return this.getLanguageName();
|
|
||||||
case "javax.script.language_version":
|
|
||||||
return this.getLanguageVersion();
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProgram(final String... statements) {
|
public String getProgram(final String... statements) {
|
||||||
|
@ -881,15 +881,12 @@ public abstract class Preferences implements ChangeSource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
return switch (type) {
|
||||||
case LINE:
|
case LINE -> StaticFieldHolder.DEFAULT_LINE_MATERIAL;
|
||||||
return StaticFieldHolder.DEFAULT_LINE_MATERIAL;
|
case SURFACE -> StaticFieldHolder.DEFAULT_SURFACE_MATERIAL;
|
||||||
case SURFACE:
|
case BULK -> StaticFieldHolder.DEFAULT_BULK_MATERIAL;
|
||||||
return StaticFieldHolder.DEFAULT_SURFACE_MATERIAL;
|
default -> throw new IllegalArgumentException("Unknown material type: " + type);
|
||||||
case BULK:
|
};
|
||||||
return StaticFieldHolder.DEFAULT_BULK_MATERIAL;
|
|
||||||
}
|
|
||||||
throw new IllegalArgumentException("Unknown material type: " + type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -96,21 +96,12 @@ public class SerializeThrustcurveMotors {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Motor.Type type;
|
final Motor.Type type = switch (mi.getType()) {
|
||||||
switch (mi.getType()) {
|
case "SU" -> Motor.Type.SINGLE;
|
||||||
case "SU":
|
case "reload" -> Motor.Type.RELOAD;
|
||||||
type = Motor.Type.SINGLE;
|
case "hybrid" -> Motor.Type.HYBRID;
|
||||||
break;
|
default -> Motor.Type.UNKNOWN;
|
||||||
case "reload":
|
};
|
||||||
type = Motor.Type.RELOAD;
|
|
||||||
break;
|
|
||||||
case "hybrid":
|
|
||||||
type = Motor.Type.HYBRID;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
type = Motor.Type.UNKNOWN;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println(message);
|
System.out.println(message);
|
||||||
|
|
||||||
|
@ -23,14 +23,11 @@ public class TestFileIterator {
|
|||||||
@Override
|
@Override
|
||||||
protected Pair<File, InputStream> findNext() {
|
protected Pair<File, InputStream> findNext() {
|
||||||
count++;
|
count++;
|
||||||
switch (count) {
|
return switch (count) {
|
||||||
case 1:
|
case 1 -> one;
|
||||||
return one;
|
case 2 -> two;
|
||||||
case 2:
|
default -> null;
|
||||||
return two;
|
};
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -100,11 +100,9 @@ public class FlightEventsTest extends BaseTestCase {
|
|||||||
|
|
||||||
// events whose time is too variable to check are given a time of 1200
|
// events whose time is too variable to check are given a time of 1200
|
||||||
for (int b = 0; b < 2; b++) {
|
for (int b = 0; b < 2; b++) {
|
||||||
FlightEvent[] expectedEvents;
|
FlightEvent[] expectedEvents = switch (b) {
|
||||||
switch (b) {
|
|
||||||
// Sustainer
|
// Sustainer
|
||||||
case 0:
|
case 0 -> new FlightEvent[]{
|
||||||
expectedEvents = new FlightEvent[] {
|
|
||||||
new FlightEvent(FlightEvent.Type.LAUNCH, 0.0, rocket),
|
new FlightEvent(FlightEvent.Type.LAUNCH, 0.0, rocket),
|
||||||
new FlightEvent(FlightEvent.Type.IGNITION, 0.0, sideBoosterBodies),
|
new FlightEvent(FlightEvent.Type.IGNITION, 0.0, sideBoosterBodies),
|
||||||
new FlightEvent(FlightEvent.Type.IGNITION, 0.01, centerBoosterBody),
|
new FlightEvent(FlightEvent.Type.IGNITION, 0.01, centerBoosterBody),
|
||||||
@ -124,11 +122,9 @@ public class FlightEventsTest extends BaseTestCase {
|
|||||||
new FlightEvent(FlightEvent.Type.GROUND_HIT, 83.27, null),
|
new FlightEvent(FlightEvent.Type.GROUND_HIT, 83.27, null),
|
||||||
new FlightEvent(FlightEvent.Type.SIMULATION_END, 83.27, null)
|
new FlightEvent(FlightEvent.Type.SIMULATION_END, 83.27, null)
|
||||||
};
|
};
|
||||||
break;
|
|
||||||
|
|
||||||
// Center Booster
|
// Center Booster
|
||||||
case 1:
|
case 1 -> new FlightEvent[]{
|
||||||
expectedEvents = new FlightEvent[] {
|
|
||||||
new FlightEvent(FlightEvent.Type.IGNITION, 0.01, centerBoosterBody),
|
new FlightEvent(FlightEvent.Type.IGNITION, 0.01, centerBoosterBody),
|
||||||
new FlightEvent(FlightEvent.Type.BURNOUT, 2.01, centerBoosterBody),
|
new FlightEvent(FlightEvent.Type.BURNOUT, 2.01, centerBoosterBody),
|
||||||
new FlightEvent(FlightEvent.Type.EJECTION_CHARGE, 2.01, centerBooster),
|
new FlightEvent(FlightEvent.Type.EJECTION_CHARGE, 2.01, centerBooster),
|
||||||
@ -138,11 +134,9 @@ public class FlightEventsTest extends BaseTestCase {
|
|||||||
new FlightEvent(FlightEvent.Type.GROUND_HIT, 9.0, null),
|
new FlightEvent(FlightEvent.Type.GROUND_HIT, 9.0, null),
|
||||||
new FlightEvent(FlightEvent.Type.SIMULATION_END, 9.0, null)
|
new FlightEvent(FlightEvent.Type.SIMULATION_END, 9.0, null)
|
||||||
};
|
};
|
||||||
break;
|
|
||||||
|
|
||||||
// Side Boosters
|
// Side Boosters
|
||||||
case 2:
|
case 2 -> new FlightEvent[]{
|
||||||
expectedEvents = new FlightEvent[] {
|
|
||||||
new FlightEvent(FlightEvent.Type.IGNITION, 0.0, sideBoosterBodies),
|
new FlightEvent(FlightEvent.Type.IGNITION, 0.0, sideBoosterBodies),
|
||||||
new FlightEvent(FlightEvent.Type.BURNOUT, 0.85, sideBoosterBodies),
|
new FlightEvent(FlightEvent.Type.BURNOUT, 0.85, sideBoosterBodies),
|
||||||
new FlightEvent(FlightEvent.Type.EJECTION_CHARGE, 0.85, sideBoosters),
|
new FlightEvent(FlightEvent.Type.EJECTION_CHARGE, 0.85, sideBoosters),
|
||||||
@ -152,11 +146,8 @@ public class FlightEventsTest extends BaseTestCase {
|
|||||||
new FlightEvent(FlightEvent.Type.GROUND_HIT, 1.21, null),
|
new FlightEvent(FlightEvent.Type.GROUND_HIT, 1.21, null),
|
||||||
new FlightEvent(FlightEvent.Type.SIMULATION_END, 1.21, null)
|
new FlightEvent(FlightEvent.Type.SIMULATION_END, 1.21, null)
|
||||||
};
|
};
|
||||||
break;
|
default -> throw new IllegalStateException("Invalid branch number " + b);
|
||||||
|
};
|
||||||
default:
|
|
||||||
throw new IllegalStateException("Invalid branch number " + b);
|
|
||||||
}
|
|
||||||
|
|
||||||
checkEvents(expectedEvents, sim, b);
|
checkEvents(expectedEvents, sim, b);
|
||||||
}
|
}
|
||||||
|
@ -89,25 +89,25 @@ public class RocketConfig extends RocketComponentConfig {
|
|||||||
public void keyTyped(KeyEvent e) {
|
public void keyTyped(KeyEvent e) {
|
||||||
String text = componentNameField.getText() + e.getKeyChar();
|
String text = componentNameField.getText() + e.getKeyChar();
|
||||||
String msg = null;
|
String msg = null;
|
||||||
String title = null;
|
String title = switch (text) {
|
||||||
switch (text) {
|
case "SA-508" -> {
|
||||||
case "SA-508":
|
|
||||||
msg = "Houston, we have a problem.\n\nJust kidding, have fun building your 'Apollo 13' rocket!";
|
msg = "Houston, we have a problem.\n\nJust kidding, have fun building your 'Apollo 13' rocket!";
|
||||||
title = "Oh oh...";
|
yield "Oh oh...";
|
||||||
break;
|
|
||||||
case "SA-506":
|
|
||||||
msg = "One small step for a rocket, one giant leap for rocketkind.";
|
|
||||||
title = "Or was that not the quote?";
|
|
||||||
break;
|
|
||||||
case "Vega":
|
|
||||||
msg = "Viva las Vega!";
|
|
||||||
title = "Vega, Ready for Launch and Laughs!";
|
|
||||||
break;
|
|
||||||
case "Ariane 5":
|
|
||||||
msg = "Non, je ne regrette rien\u2026 except for that one overflow error\u2026";
|
|
||||||
title = "Happens to the best of us";
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
case "SA-506" -> {
|
||||||
|
msg = "One small step for a rocket, one giant leap for rocketkind.";
|
||||||
|
yield "Or was that not the quote?";
|
||||||
|
}
|
||||||
|
case "Vega" -> {
|
||||||
|
msg = "Viva las Vega!";
|
||||||
|
yield "Vega, Ready for Launch and Laughs!";
|
||||||
|
}
|
||||||
|
case "Ariane 5" -> {
|
||||||
|
msg = "Non, je ne regrette rien\u2026 except for that one overflow error\u2026";
|
||||||
|
yield "Happens to the best of us";
|
||||||
|
}
|
||||||
|
default -> null;
|
||||||
|
};
|
||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
JOptionPane optionPane = new JOptionPane(msg, JOptionPane.INFORMATION_MESSAGE);
|
JOptionPane optionPane = new JOptionPane(msg, JOptionPane.INFORMATION_MESSAGE);
|
||||||
JDialog dialog = optionPane.createDialog(RocketConfig.this, title);
|
JDialog dialog = optionPane.createDialog(RocketConfig.this, title);
|
||||||
|
@ -60,30 +60,20 @@ class MotorMountTableModel extends AbstractTableModel implements ComponentChange
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getColumnClass(int column) {
|
public Class<?> getColumnClass(int column) {
|
||||||
switch (column) {
|
return switch (column) {
|
||||||
case 0:
|
case 0 -> Boolean.class;
|
||||||
return Boolean.class;
|
case 1 -> String.class;
|
||||||
|
default -> throw new IndexOutOfBoundsException("column=" + column);
|
||||||
case 1:
|
};
|
||||||
return String.class;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new IndexOutOfBoundsException("column=" + column);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValueAt(int row, int column) {
|
public Object getValueAt(int row, int column) {
|
||||||
switch (column) {
|
return switch (column) {
|
||||||
case 0:
|
case 0 -> Boolean.valueOf(potentialMounts.get(row).isMotorMount());
|
||||||
return Boolean.valueOf(potentialMounts.get(row).isMotorMount());
|
case 1 -> potentialMounts.get(row).toString();
|
||||||
|
default -> throw new IndexOutOfBoundsException("column=" + column);
|
||||||
case 1:
|
};
|
||||||
return potentialMounts.get(row).toString();
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new IndexOutOfBoundsException("column=" + column);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1346,35 +1346,25 @@ public class GeneralOptimizationDialog extends JDialog {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getColumnName(int column) {
|
public String getColumnName(int column) {
|
||||||
switch (column) {
|
return switch (column) {
|
||||||
case PARAMETER:
|
case PARAMETER -> trans.get("table.col.parameter");
|
||||||
return trans.get("table.col.parameter");
|
case CURRENT -> trans.get("table.col.current");
|
||||||
case CURRENT:
|
case MIN -> trans.get("table.col.min");
|
||||||
return trans.get("table.col.current");
|
case MAX -> trans.get("table.col.max");
|
||||||
case MIN:
|
default -> throw new IndexOutOfBoundsException("column=" + column);
|
||||||
return trans.get("table.col.min");
|
};
|
||||||
case MAX:
|
|
||||||
return trans.get("table.col.max");
|
|
||||||
default:
|
|
||||||
throw new IndexOutOfBoundsException("column=" + column);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getColumnClass(int column) {
|
public Class<?> getColumnClass(int column) {
|
||||||
switch (column) {
|
return switch (column) {
|
||||||
case PARAMETER:
|
case PARAMETER -> String.class;
|
||||||
return String.class;
|
case CURRENT -> Double.class;
|
||||||
case CURRENT:
|
case MIN -> Double.class;
|
||||||
return Double.class;
|
case MAX -> Double.class;
|
||||||
case MIN:
|
default -> throw new IndexOutOfBoundsException("column=" + column);
|
||||||
return Double.class;
|
};
|
||||||
case MAX:
|
|
||||||
return Double.class;
|
|
||||||
default:
|
|
||||||
throw new IndexOutOfBoundsException("column=" + column);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1438,18 +1428,13 @@ public class GeneralOptimizationDialog extends JDialog {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCellEditable(int row, int column) {
|
public boolean isCellEditable(int row, int column) {
|
||||||
switch (column) {
|
return switch (column) {
|
||||||
case PARAMETER:
|
case PARAMETER -> false;
|
||||||
return false;
|
case CURRENT -> false;
|
||||||
case CURRENT:
|
case MIN -> true;
|
||||||
return false;
|
case MAX -> true;
|
||||||
case MIN:
|
default -> throw new IndexOutOfBoundsException("column=" + column);
|
||||||
return true;
|
};
|
||||||
case MAX:
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
throw new IndexOutOfBoundsException("column=" + column);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -80,19 +80,12 @@ public class MaterialEditPanel extends JPanel {
|
|||||||
public Object getValueAt(int row) {
|
public Object getValueAt(int row) {
|
||||||
Material m = getMaterial(row);
|
Material m = getMaterial(row);
|
||||||
double d = m.getDensity();
|
double d = m.getDensity();
|
||||||
switch (m.getType()) {
|
return switch (m.getType()) {
|
||||||
case LINE:
|
case LINE -> UnitGroup.UNITS_DENSITY_LINE.toValue(d);
|
||||||
return UnitGroup.UNITS_DENSITY_LINE.toValue(d);
|
case SURFACE -> UnitGroup.UNITS_DENSITY_SURFACE.toValue(d);
|
||||||
|
case BULK -> UnitGroup.UNITS_DENSITY_BULK.toValue(d);
|
||||||
case SURFACE:
|
default -> throw new IllegalStateException("Material type " + m.getType());
|
||||||
return UnitGroup.UNITS_DENSITY_SURFACE.toValue(d);
|
};
|
||||||
|
|
||||||
case BULK:
|
|
||||||
return UnitGroup.UNITS_DENSITY_BULK.toValue(d);
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new IllegalStateException("Material type " + m.getType());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -274,19 +267,12 @@ public class MaterialEditPanel extends JPanel {
|
|||||||
|
|
||||||
|
|
||||||
private Database<Material> getDatabase(Material m) {
|
private Database<Material> getDatabase(Material m) {
|
||||||
switch (m.getType()) {
|
return switch (m.getType()) {
|
||||||
case BULK:
|
case BULK -> Databases.BULK_MATERIAL;
|
||||||
return Databases.BULK_MATERIAL;
|
case SURFACE -> Databases.SURFACE_MATERIAL;
|
||||||
|
case LINE -> Databases.LINE_MATERIAL;
|
||||||
case SURFACE:
|
default -> throw new IllegalArgumentException("Material type invalid, m=" + m);
|
||||||
return Databases.SURFACE_MATERIAL;
|
};
|
||||||
|
|
||||||
case LINE:
|
|
||||||
return Databases.LINE_MATERIAL;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new IllegalArgumentException("Material type invalid, m=" + m);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -174,16 +174,11 @@ public abstract class PreferencesPanel extends JPanel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getElementAt(int index) {
|
public Object getElementAt(int index) {
|
||||||
switch (index) {
|
return switch (index) {
|
||||||
case 0:
|
case 0 -> def ? trueDesc : falseDesc;
|
||||||
return def ? trueDesc : falseDesc;
|
case 1 -> def ? falseDesc : trueDesc;
|
||||||
|
default -> throw new IndexOutOfBoundsException("Boolean asked for index=" + index);
|
||||||
case 1:
|
};
|
||||||
return def ? falseDesc : trueDesc;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new IndexOutOfBoundsException("Boolean asked for index=" + index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -130,20 +130,14 @@ public class FigureRenderer extends RocketRenderer {
|
|||||||
|
|
||||||
private static int getShine(RocketComponent c) {
|
private static int getShine(RocketComponent c) {
|
||||||
if (c instanceof ExternalComponent) {
|
if (c instanceof ExternalComponent) {
|
||||||
switch (((ExternalComponent) c).getFinish()) {
|
return switch (((ExternalComponent) c).getFinish()) {
|
||||||
case ROUGH:
|
case ROUGH -> 10;
|
||||||
return 10;
|
case UNFINISHED -> 30;
|
||||||
case UNFINISHED:
|
case NORMAL -> 40;
|
||||||
return 30;
|
case SMOOTH -> 80;
|
||||||
case NORMAL:
|
case POLISHED -> 128;
|
||||||
return 40;
|
default -> 100;
|
||||||
case SMOOTH:
|
};
|
||||||
return 80;
|
|
||||||
case POLISHED:
|
|
||||||
return 128;
|
|
||||||
default:
|
|
||||||
return 100;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return 20;
|
return 20;
|
||||||
}
|
}
|
||||||
|
@ -221,18 +221,13 @@ public class RealisticRenderer extends RocketRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int toEdgeMode(Decal.EdgeMode m) {
|
private int toEdgeMode(Decal.EdgeMode m) {
|
||||||
switch (m) {
|
return switch (m) {
|
||||||
case REPEAT:
|
case REPEAT -> GL.GL_REPEAT;
|
||||||
return GL.GL_REPEAT;
|
case MIRROR -> GL.GL_MIRRORED_REPEAT;
|
||||||
case MIRROR:
|
case CLAMP -> GL.GL_CLAMP_TO_EDGE;
|
||||||
return GL.GL_MIRRORED_REPEAT;
|
case STICKER -> GL2.GL_CLAMP_TO_BORDER;
|
||||||
case CLAMP:
|
default -> GL.GL_CLAMP_TO_EDGE;
|
||||||
return GL.GL_CLAMP_TO_EDGE;
|
};
|
||||||
case STICKER:
|
|
||||||
return GL2.GL_CLAMP_TO_BORDER;
|
|
||||||
default:
|
|
||||||
return GL.GL_CLAMP_TO_EDGE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void convertColor(ORColor color, float[] out) {
|
protected static void convertColor(ORColor color, float[] out) {
|
||||||
|
@ -705,18 +705,11 @@ public class RocketFigure3d extends JPanel implements GLEventListener {
|
|||||||
// the renderer accordingly. There is certainly a better way to do this.
|
// the renderer accordingly. There is certainly a better way to do this.
|
||||||
|
|
||||||
|
|
||||||
final RocketRenderer newRR;
|
final RocketRenderer newRR = switch (t) {
|
||||||
|
case TYPE_FINISHED -> new RealisticRenderer(document);
|
||||||
switch (t) {
|
case TYPE_UNFINISHED -> new UnfinishedRenderer(document);
|
||||||
case TYPE_FINISHED:
|
default -> new FigureRenderer();
|
||||||
newRR = new RealisticRenderer(document);
|
};
|
||||||
break;
|
|
||||||
case TYPE_UNFINISHED:
|
|
||||||
newRR = new UnfinishedRenderer(document);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
newRR = new FigureRenderer();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (canvas instanceof GLCanvas && !((GLCanvas) canvas).isRealized()) {
|
if (canvas instanceof GLCanvas && !((GLCanvas) canvas).isRealized()) {
|
||||||
rr = newRR;
|
rr = newRR;
|
||||||
|
@ -556,20 +556,21 @@ public class ComponentAddButtons extends JPanel implements Scrollable {
|
|||||||
pos = askPosition();
|
pos = askPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (pos) {
|
return switch (pos) {
|
||||||
case 0:
|
case 0 ->
|
||||||
// Cancel
|
// Cancel
|
||||||
return null;
|
null;
|
||||||
case 1:
|
case 1 ->
|
||||||
// Insert after current position
|
// Insert after current position
|
||||||
return new Pair<>(parent, parent.getChildPosition(c) + 1);
|
new Pair<>(parent, parent.getChildPosition(c) + 1);
|
||||||
case 2:
|
case 2 ->
|
||||||
// Insert at the end of the parent
|
// Insert at the end of the parent
|
||||||
return new Pair<>(parent, null);
|
new Pair<>(parent, null);
|
||||||
default:
|
default -> {
|
||||||
Application.getExceptionHandler().handleErrorCondition("ERROR: Bad position type: " + pos);
|
Application.getExceptionHandler().handleErrorCondition("ERROR: Bad position type: " + pos);
|
||||||
return null;
|
yield null;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private int askPosition() {
|
private int askPosition() {
|
||||||
@ -680,20 +681,21 @@ public class ComponentAddButtons extends JPanel implements Scrollable {
|
|||||||
pos = askPosition();
|
pos = askPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (pos) {
|
return switch (pos) {
|
||||||
case 0:
|
case 0 ->
|
||||||
// Cancel
|
// Cancel
|
||||||
return null;
|
null;
|
||||||
case 1:
|
case 1 ->
|
||||||
// Insert after current stage
|
// Insert after current stage
|
||||||
return new Pair<>(document.getRocket(), document.getRocket().getChildPosition(parentStage) + 1);
|
new Pair<>(document.getRocket(), document.getRocket().getChildPosition(parentStage) + 1);
|
||||||
case 2:
|
case 2 ->
|
||||||
// Insert at the end
|
// Insert at the end
|
||||||
return new Pair<>(document.getRocket(), null);
|
new Pair<>(document.getRocket(), null);
|
||||||
default:
|
default -> {
|
||||||
Application.getExceptionHandler().handleErrorCondition("ERROR: Bad position type: " + pos);
|
Application.getExceptionHandler().handleErrorCondition("ERROR: Bad position type: " + pos);
|
||||||
return null;
|
yield null;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private int askPosition() {
|
private int askPosition() {
|
||||||
|
@ -126,18 +126,12 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
|||||||
@Override
|
@Override
|
||||||
public void stateChanged(ChangeEvent e) {
|
public void stateChanged(ChangeEvent e) {
|
||||||
// Trigger a selection of the motor/recovery/configuration item
|
// Trigger a selection of the motor/recovery/configuration item
|
||||||
FlightConfigurablePanel<?> panel = null;
|
FlightConfigurablePanel<?> panel = switch (tabs.getSelectedIndex()) {
|
||||||
switch (tabs.getSelectedIndex()) {
|
case MOTOR_TAB_INDEX -> motorConfigurationPanel;
|
||||||
case MOTOR_TAB_INDEX:
|
case RECOVERY_TAB_INDEX -> recoveryConfigurationPanel;
|
||||||
panel = motorConfigurationPanel;
|
case SEPARATION_TAB_INDEX -> separationConfigurationPanel;
|
||||||
break;
|
default -> null;
|
||||||
case RECOVERY_TAB_INDEX:
|
};
|
||||||
panel = recoveryConfigurationPanel;
|
|
||||||
break;
|
|
||||||
case SEPARATION_TAB_INDEX:
|
|
||||||
panel = separationConfigurationPanel;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the panel selection, focus, and button state
|
// Update the panel selection, focus, and button state
|
||||||
if (panel == null) return;
|
if (panel == null) return;
|
||||||
@ -360,16 +354,12 @@ public class FlightConfigurationPanel extends JPanel implements StateChangeListe
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<FlightConfigurationId> getSelectedConfigurationIds() {
|
private List<FlightConfigurationId> getSelectedConfigurationIds() {
|
||||||
switch (tabs.getSelectedIndex()) {
|
return switch (tabs.getSelectedIndex()) {
|
||||||
case MOTOR_TAB_INDEX:
|
case MOTOR_TAB_INDEX -> this.motorConfigurationPanel.getSelectedConfigurationIds();
|
||||||
return this.motorConfigurationPanel.getSelectedConfigurationIds();
|
case RECOVERY_TAB_INDEX -> this.recoveryConfigurationPanel.getSelectedConfigurationIds();
|
||||||
case RECOVERY_TAB_INDEX:
|
case SEPARATION_TAB_INDEX -> this.separationConfigurationPanel.getSelectedConfigurationIds();
|
||||||
return this.recoveryConfigurationPanel.getSelectedConfigurationIds();
|
default -> null;
|
||||||
case SEPARATION_TAB_INDEX:
|
};
|
||||||
return this.separationConfigurationPanel.getSelectedConfigurationIds();
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelectedComponent(RocketComponent component) {
|
public void setSelectedComponent(RocketComponent component) {
|
||||||
|
@ -477,19 +477,11 @@ public class RocketFigure extends AbstractScaleFigure {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the shapes
|
// Get the shapes
|
||||||
RocketComponentShapes[] returnValue;
|
RocketComponentShapes[] returnValue = switch (viewType) {
|
||||||
switch (viewType) {
|
case SideView, TopView -> RocketComponentShapeProvider.getShapesSide(component, transformation);
|
||||||
case SideView:
|
case BackView -> RocketComponentShapeProvider.getShapesBack(component, transformation);
|
||||||
case TopView:
|
default -> throw new BugException("Unknown figure type = " + viewType);
|
||||||
returnValue = RocketComponentShapeProvider.getShapesSide(component, transformation);
|
};
|
||||||
break;
|
|
||||||
case BackView:
|
|
||||||
returnValue = RocketComponentShapeProvider.getShapesBack(component, transformation);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new BugException("Unknown figure type = " + viewType);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (color != null) {
|
if (color != null) {
|
||||||
for (RocketComponentShapes rcs : returnValue) {
|
for (RocketComponentShapes rcs : returnValue) {
|
||||||
|
@ -361,51 +361,38 @@ public class SimulationExportPanel extends JPanel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getColumnName(int column) {
|
public String getColumnName(int column) {
|
||||||
switch (column) {
|
return switch (column) {
|
||||||
case SELECTED:
|
case SELECTED -> "";
|
||||||
return "";
|
case NAME ->
|
||||||
case NAME:
|
|
||||||
//// Variable
|
//// Variable
|
||||||
return trans.get("SimExpPan.Col.Variable");
|
trans.get("SimExpPan.Col.Variable");
|
||||||
case UNIT:
|
case UNIT ->
|
||||||
//// Unit
|
//// Unit
|
||||||
return trans.get("SimExpPan.Col.Unit");
|
trans.get("SimExpPan.Col.Unit");
|
||||||
default:
|
default -> throw new IndexOutOfBoundsException("column=" + column);
|
||||||
throw new IndexOutOfBoundsException("column=" + column);
|
};
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getColumnClass(int column) {
|
public Class<?> getColumnClass(int column) {
|
||||||
switch (column) {
|
return switch (column) {
|
||||||
case SELECTED:
|
case SELECTED -> Boolean.class;
|
||||||
return Boolean.class;
|
case NAME -> FlightDataType.class;
|
||||||
case NAME:
|
case UNIT -> Unit.class;
|
||||||
return FlightDataType.class;
|
default -> throw new IndexOutOfBoundsException("column=" + column);
|
||||||
case UNIT:
|
};
|
||||||
return Unit.class;
|
|
||||||
default:
|
|
||||||
throw new IndexOutOfBoundsException("column=" + column);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValueAt(int row, int column) {
|
public Object getValueAt(int row, int column) {
|
||||||
|
|
||||||
switch (column) {
|
return switch (column) {
|
||||||
case SELECTED:
|
case SELECTED -> selected[row];
|
||||||
return selected[row];
|
case NAME -> types[row];
|
||||||
|
case UNIT -> units[row];
|
||||||
case NAME:
|
default -> throw new IndexOutOfBoundsException("column=" + column);
|
||||||
return types[row];
|
};
|
||||||
|
|
||||||
case UNIT:
|
|
||||||
return units[row];
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new IndexOutOfBoundsException("column=" + column);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -434,19 +421,12 @@ public class SimulationExportPanel extends JPanel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCellEditable(int row, int column) {
|
public boolean isCellEditable(int row, int column) {
|
||||||
switch (column) {
|
return switch (column) {
|
||||||
case SELECTED:
|
case SELECTED -> true;
|
||||||
return true;
|
case NAME -> false;
|
||||||
|
case UNIT -> types[row].getUnitGroup().getUnitCount() > 1;
|
||||||
case NAME:
|
default -> throw new IndexOutOfBoundsException("column=" + column);
|
||||||
return false;
|
};
|
||||||
|
|
||||||
case UNIT:
|
|
||||||
return types[row].getUnitGroup().getUnitCount() > 1;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new IndexOutOfBoundsException("column=" + column);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectAll() {
|
public void selectAll() {
|
||||||
|
@ -604,30 +604,20 @@ public class SimulationPlotPanel extends JPanel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getColumnClass(int column) {
|
public Class<?> getColumnClass(int column) {
|
||||||
switch (column) {
|
return switch (column) {
|
||||||
case 0:
|
case 0 -> Boolean.class;
|
||||||
return Boolean.class;
|
case 1 -> String.class;
|
||||||
|
default -> throw new IndexOutOfBoundsException("column=" + column);
|
||||||
case 1:
|
};
|
||||||
return String.class;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new IndexOutOfBoundsException("column=" + column);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValueAt(int row, int column) {
|
public Object getValueAt(int row, int column) {
|
||||||
switch (column) {
|
return switch (column) {
|
||||||
case 0:
|
case 0 -> Boolean.valueOf(configuration.isEventActive(eventTypes[row]));
|
||||||
return Boolean.valueOf(configuration.isEventActive(eventTypes[row]));
|
case 1 -> eventTypes[row].toString();
|
||||||
|
default -> throw new IndexOutOfBoundsException("column=" + column);
|
||||||
case 1:
|
};
|
||||||
return eventTypes[row].toString();
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new IndexOutOfBoundsException("column=" + column);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -39,20 +39,14 @@ public class LogbackBufferLoggerAdaptor extends AppenderBase<ILoggingEvent> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private LogLevel toORLevel(Level l) {
|
private LogLevel toORLevel(Level l) {
|
||||||
switch (l.toInt()) {
|
return switch (l.toInt()) {
|
||||||
case Level.TRACE_INT:
|
case Level.TRACE_INT -> LogLevel.VBOSE;
|
||||||
return LogLevel.VBOSE;
|
case Level.DEBUG_INT -> LogLevel.DEBUG;
|
||||||
case Level.DEBUG_INT:
|
case Level.INFO_INT -> LogLevel.INFO;
|
||||||
return LogLevel.DEBUG;
|
case Level.WARN_INT -> LogLevel.WARN;
|
||||||
case Level.INFO_INT:
|
case Level.ERROR_INT -> LogLevel.ERROR;
|
||||||
return LogLevel.INFO;
|
default -> LogLevel.ERROR;
|
||||||
case Level.WARN_INT:
|
};
|
||||||
return LogLevel.WARN;
|
|
||||||
case Level.ERROR_INT:
|
|
||||||
return LogLevel.ERROR;
|
|
||||||
default:
|
|
||||||
return LogLevel.ERROR;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private LogLine toLogLine(ILoggingEvent e) {
|
private LogLine toLogLine(ILoggingEvent e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user