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