Use enhanced for-loops
This commit is contained in:
parent
7678a1226f
commit
fd3f2e167c
@ -36,9 +36,9 @@ public class Example {
|
|||||||
}
|
}
|
||||||
|
|
||||||
double subtotal = 0;
|
double subtotal = 0;
|
||||||
for (int i = 0; i < vals.length; i++ ){
|
for (double val : vals) {
|
||||||
subtotal += vals[i];
|
subtotal += val;
|
||||||
}
|
}
|
||||||
|
|
||||||
subtotal = scale * subtotal / vals.length;
|
subtotal = scale * subtotal / vals.length;
|
||||||
return new Variable("double MEAN result, ", subtotal);
|
return new Variable("double MEAN result, ", subtotal);
|
||||||
|
@ -547,8 +547,8 @@ public class FinSetCalc extends RocketComponentCalc {
|
|||||||
double x = 1.0;
|
double x = 1.0;
|
||||||
double val = 0;
|
double val = 0;
|
||||||
|
|
||||||
for (int i = 0; i < poly.length; i++) {
|
for (double v : poly) {
|
||||||
val += poly[i] * x;
|
val += v * x;
|
||||||
x *= m;
|
x *= m;
|
||||||
}
|
}
|
||||||
// logger.debug("val = {}", val);
|
// logger.debug("val = {}", val);
|
||||||
|
@ -229,8 +229,8 @@ public class TubeFinSetCalc extends TubeCalc {
|
|||||||
double x = 1.0;
|
double x = 1.0;
|
||||||
double val = 0;
|
double val = 0;
|
||||||
|
|
||||||
for (int i = 0; i < poly.length; i++) {
|
for (double v : poly) {
|
||||||
val += poly[i] * x;
|
val += v * x;
|
||||||
x *= m;
|
x *= m;
|
||||||
}
|
}
|
||||||
// log.debug("val = {}", val);
|
// log.debug("val = {}", val);
|
||||||
|
@ -87,8 +87,9 @@ public class ComponentPresetDatabase extends Database<ComponentPreset> implement
|
|||||||
|
|
||||||
for (ComponentPreset preset : list) {
|
for (ComponentPreset preset : list) {
|
||||||
ComponentPreset.Type presetType = preset.get(ComponentPreset.TYPE);
|
ComponentPreset.Type presetType = preset.get(ComponentPreset.TYPE);
|
||||||
typeLoop: for (int i = 0; i < type.length; i++) {
|
typeLoop:
|
||||||
if (presetType.equals(type[i])) {
|
for (ComponentPreset.Type value : type) {
|
||||||
|
if (presetType.equals(value)) {
|
||||||
result.add(preset);
|
result.add(preset);
|
||||||
break typeLoop; // from inner loop.
|
break typeLoop; // from inner loop.
|
||||||
}
|
}
|
||||||
|
@ -114,13 +114,13 @@ public class RASPMotorLoader extends AbstractMotorLoader {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
buf = split(pieces[3], "[-,]+");
|
buf = split(pieces[3], "[-,]+");
|
||||||
for (int i = 0; i < buf.length; i++) {
|
for (String s : buf) {
|
||||||
if (buf[i].equalsIgnoreCase("P") ||
|
if (s.equalsIgnoreCase("P") ||
|
||||||
buf[i].equalsIgnoreCase("plugged")) {
|
s.equalsIgnoreCase("plugged")) {
|
||||||
delays.add(Motor.PLUGGED_DELAY);
|
delays.add(Motor.PLUGGED_DELAY);
|
||||||
} else if (buf[i].matches("[0-9]+")) {
|
} else if (s.matches("[0-9]+")) {
|
||||||
// Many RASP files have "100" as an only delay
|
// Many RASP files have "100" as an only delay
|
||||||
double d = Double.parseDouble(buf[i]);
|
double d = Double.parseDouble(s);
|
||||||
if (d < 99)
|
if (d < 99)
|
||||||
delays.add(d);
|
delays.add(d);
|
||||||
}
|
}
|
||||||
|
@ -480,8 +480,8 @@ public class OpenRocketSaver extends RocketSaver {
|
|||||||
|
|
||||||
// Retrieve the data from the branch
|
// Retrieve the data from the branch
|
||||||
List<List<Double>> data = new ArrayList<>(types.length);
|
List<List<Double>> data = new ArrayList<>(types.length);
|
||||||
for (int i = 0; i < types.length; i++) {
|
for (FlightDataType type : types) {
|
||||||
data.add(branch.get(types[i]));
|
data.add(branch.get(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the <databranch> tag
|
// Build the <databranch> tag
|
||||||
|
@ -78,32 +78,31 @@ public class AbstractTransitionDTO extends BasePartDTO implements AttachablePart
|
|||||||
setWallThickness(nc.getThickness() * RockSimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
|
setWallThickness(nc.getThickness() * RockSimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
|
||||||
|
|
||||||
List<RocketComponent> children = nc.getChildren();
|
List<RocketComponent> children = nc.getChildren();
|
||||||
for (int i = 0; i < children.size(); i++) {
|
for (RocketComponent rocketComponents : children) {
|
||||||
RocketComponent rocketComponents = children.get(i);
|
if (rocketComponents instanceof InnerTube) {
|
||||||
if (rocketComponents instanceof InnerTube) {
|
addAttachedPart(new InnerBodyTubeDTO((InnerTube) rocketComponents, this));
|
||||||
addAttachedPart(new InnerBodyTubeDTO((InnerTube) rocketComponents, this));
|
} else if (rocketComponents instanceof BodyTube) {
|
||||||
} else if (rocketComponents instanceof BodyTube) {
|
addAttachedPart(new BodyTubeDTO((BodyTube) rocketComponents));
|
||||||
addAttachedPart(new BodyTubeDTO((BodyTube) rocketComponents));
|
} else if (rocketComponents instanceof Transition) {
|
||||||
} else if (rocketComponents instanceof Transition) {
|
addAttachedPart(new TransitionDTO((Transition) rocketComponents));
|
||||||
addAttachedPart(new TransitionDTO((Transition) rocketComponents));
|
} else if (rocketComponents instanceof EngineBlock) {
|
||||||
} else if (rocketComponents instanceof EngineBlock) {
|
addAttachedPart(new EngineBlockDTO((EngineBlock) rocketComponents));
|
||||||
addAttachedPart(new EngineBlockDTO((EngineBlock) rocketComponents));
|
} else if (rocketComponents instanceof TubeCoupler) {
|
||||||
} else if (rocketComponents instanceof TubeCoupler) {
|
addAttachedPart(new TubeCouplerDTO((TubeCoupler) rocketComponents, this));
|
||||||
addAttachedPart(new TubeCouplerDTO((TubeCoupler) rocketComponents, this));
|
} else if (rocketComponents instanceof CenteringRing) {
|
||||||
} else if (rocketComponents instanceof CenteringRing) {
|
addAttachedPart(new CenteringRingDTO((CenteringRing) rocketComponents));
|
||||||
addAttachedPart(new CenteringRingDTO((CenteringRing) rocketComponents));
|
} else if (rocketComponents instanceof Bulkhead) {
|
||||||
} else if (rocketComponents instanceof Bulkhead) {
|
addAttachedPart(new BulkheadDTO((Bulkhead) rocketComponents));
|
||||||
addAttachedPart(new BulkheadDTO((Bulkhead) rocketComponents));
|
} else if (rocketComponents instanceof Parachute) {
|
||||||
} else if (rocketComponents instanceof Parachute) {
|
addAttachedPart(new ParachuteDTO((Parachute) rocketComponents));
|
||||||
addAttachedPart(new ParachuteDTO((Parachute) rocketComponents));
|
} else if (rocketComponents instanceof MassObject) {
|
||||||
} else if (rocketComponents instanceof MassObject) {
|
addAttachedPart(new MassObjectDTO((MassObject) rocketComponents));
|
||||||
addAttachedPart(new MassObjectDTO((MassObject) rocketComponents));
|
} else if (rocketComponents instanceof FreeformFinSet) {
|
||||||
} else if (rocketComponents instanceof FreeformFinSet) {
|
addAttachedPart(new CustomFinSetDTO((FreeformFinSet) rocketComponents));
|
||||||
addAttachedPart(new CustomFinSetDTO((FreeformFinSet) rocketComponents));
|
} else if (rocketComponents instanceof FinSet) {
|
||||||
} else if (rocketComponents instanceof FinSet) {
|
addAttachedPart(new FinSetDTO((FinSet) rocketComponents));
|
||||||
addAttachedPart(new FinSetDTO((FinSet) rocketComponents));
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getShapeCode() {
|
public int getShapeCode() {
|
||||||
|
@ -94,51 +94,50 @@ public class BodyTubeDTO extends BasePartDTO implements AttachableParts {
|
|||||||
setMotorMount(theORBodyTube.isMotorMount());
|
setMotorMount(theORBodyTube.isMotorMount());
|
||||||
|
|
||||||
List<RocketComponent> children = theORBodyTube.getChildren();
|
List<RocketComponent> children = theORBodyTube.getChildren();
|
||||||
for (int i = 0; i < children.size(); i++) {
|
for (RocketComponent rocketComponent : children) {
|
||||||
RocketComponent rocketComponent = children.get(i);
|
if (rocketComponent instanceof InnerTube) {
|
||||||
if (rocketComponent instanceof InnerTube) {
|
final InnerTube innerTube = (InnerTube) rocketComponent;
|
||||||
final InnerTube innerTube = (InnerTube) rocketComponent;
|
final InnerBodyTubeDTO innerBodyTubeDTO = new InnerBodyTubeDTO(innerTube, this);
|
||||||
final InnerBodyTubeDTO innerBodyTubeDTO = new InnerBodyTubeDTO(innerTube, this);
|
//Only add the inner tube if it is NOT a cluster.
|
||||||
//Only add the inner tube if it is NOT a cluster.
|
if (innerTube.getInstanceCount() == 1) {
|
||||||
if (innerTube.getInstanceCount() == 1) {
|
addAttachedPart(innerBodyTubeDTO);
|
||||||
addAttachedPart(innerBodyTubeDTO);
|
}
|
||||||
}
|
} else if (rocketComponent instanceof BodyTube) {
|
||||||
} else if (rocketComponent instanceof BodyTube) {
|
addAttachedPart(new BodyTubeDTO((BodyTube) rocketComponent));
|
||||||
addAttachedPart(new BodyTubeDTO((BodyTube) rocketComponent));
|
} else if (rocketComponent instanceof Transition) {
|
||||||
} else if (rocketComponent instanceof Transition) {
|
addAttachedPart(new TransitionDTO((Transition) rocketComponent));
|
||||||
addAttachedPart(new TransitionDTO((Transition) rocketComponent));
|
} else if (rocketComponent instanceof EngineBlock) {
|
||||||
} else if (rocketComponent instanceof EngineBlock) {
|
addAttachedPart(new EngineBlockDTO((EngineBlock) rocketComponent));
|
||||||
addAttachedPart(new EngineBlockDTO((EngineBlock) rocketComponent));
|
} else if (rocketComponent instanceof TubeCoupler) {
|
||||||
} else if (rocketComponent instanceof TubeCoupler) {
|
addAttachedPart(new TubeCouplerDTO((TubeCoupler) rocketComponent, this));
|
||||||
addAttachedPart(new TubeCouplerDTO((TubeCoupler) rocketComponent, this));
|
} else if (rocketComponent instanceof CenteringRing) {
|
||||||
} else if (rocketComponent instanceof CenteringRing) {
|
addAttachedPart(new CenteringRingDTO((CenteringRing) rocketComponent));
|
||||||
addAttachedPart(new CenteringRingDTO((CenteringRing) rocketComponent));
|
} else if (rocketComponent instanceof Bulkhead) {
|
||||||
} else if (rocketComponent instanceof Bulkhead) {
|
addAttachedPart(new BulkheadDTO((Bulkhead) rocketComponent));
|
||||||
addAttachedPart(new BulkheadDTO((Bulkhead) rocketComponent));
|
} else if (rocketComponent instanceof LaunchLug) {
|
||||||
} else if (rocketComponent instanceof LaunchLug) {
|
addAttachedPart(new LaunchLugDTO((LaunchLug) rocketComponent));
|
||||||
addAttachedPart(new LaunchLugDTO((LaunchLug) rocketComponent));
|
} else if (rocketComponent instanceof Streamer) {
|
||||||
} else if (rocketComponent instanceof Streamer) {
|
addAttachedPart(new StreamerDTO((Streamer) rocketComponent));
|
||||||
addAttachedPart(new StreamerDTO((Streamer) rocketComponent));
|
} else if (rocketComponent instanceof Parachute) {
|
||||||
} else if (rocketComponent instanceof Parachute) {
|
addAttachedPart(new ParachuteDTO((Parachute) rocketComponent));
|
||||||
addAttachedPart(new ParachuteDTO((Parachute) rocketComponent));
|
} else if (rocketComponent instanceof MassObject) {
|
||||||
} else if (rocketComponent instanceof MassObject) {
|
addAttachedPart(new MassObjectDTO((MassObject) rocketComponent));
|
||||||
addAttachedPart(new MassObjectDTO((MassObject) rocketComponent));
|
} else if (rocketComponent instanceof FreeformFinSet) {
|
||||||
} else if (rocketComponent instanceof FreeformFinSet) {
|
addAttachedPart(new CustomFinSetDTO((FreeformFinSet) rocketComponent));
|
||||||
addAttachedPart(new CustomFinSetDTO((FreeformFinSet) rocketComponent));
|
} else if (rocketComponent instanceof FinSet) {
|
||||||
} else if (rocketComponent instanceof FinSet) {
|
addAttachedPart(new FinSetDTO((FinSet) rocketComponent));
|
||||||
addAttachedPart(new FinSetDTO((FinSet) rocketComponent));
|
} else if (rocketComponent instanceof TubeFinSet) {
|
||||||
} else if (rocketComponent instanceof TubeFinSet) {
|
addAttachedPart(new TubeFinSetDTO((TubeFinSet) rocketComponent));
|
||||||
addAttachedPart(new TubeFinSetDTO((TubeFinSet) rocketComponent));
|
} else if (rocketComponent instanceof PodSet) {
|
||||||
} else if (rocketComponent instanceof PodSet) {
|
for (PodSetDTO podSetDTO : PodSetDTO.generatePodSetDTOs((PodSet) rocketComponent)) {
|
||||||
for (PodSetDTO podSetDTO : PodSetDTO.generatePodSetDTOs((PodSet) rocketComponent)) {
|
addAttachedPart(podSetDTO);
|
||||||
addAttachedPart(podSetDTO);
|
}
|
||||||
}
|
} else if (rocketComponent instanceof ParallelStage) {
|
||||||
} else if (rocketComponent instanceof ParallelStage) {
|
for (ParallelStageDTO parallelStageDTO : ParallelStageDTO.generateParallelStageDTOs((ParallelStage) rocketComponent)) {
|
||||||
for (ParallelStageDTO parallelStageDTO : ParallelStageDTO.generateParallelStageDTOs((ParallelStage) rocketComponent)) {
|
addAttachedPart(parallelStageDTO);
|
||||||
addAttachedPart(parallelStageDTO);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getOD() {
|
public double getOD() {
|
||||||
|
@ -58,8 +58,7 @@ public class InnerBodyTubeDTO extends BodyTubeDTO implements AttachableParts {
|
|||||||
setRadialLoc(bt.getRadialPosition() * RockSimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
|
setRadialLoc(bt.getRadialPosition() * RockSimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
|
||||||
|
|
||||||
List<RocketComponent> children = bt.getChildren();
|
List<RocketComponent> children = bt.getChildren();
|
||||||
for (int i = 0; i < children.size(); i++) {
|
for (RocketComponent rocketComponents : children) {
|
||||||
RocketComponent rocketComponents = children.get(i);
|
|
||||||
if (rocketComponents instanceof InnerTube) {
|
if (rocketComponents instanceof InnerTube) {
|
||||||
final InnerTube innerTube = (InnerTube) rocketComponents;
|
final InnerTube innerTube = (InnerTube) rocketComponents;
|
||||||
// Only if the inner tube is NOT a cluster, then create the corresponding
|
// Only if the inner tube is NOT a cluster, then create the corresponding
|
||||||
|
@ -76,16 +76,15 @@ public class StageDTO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<RocketComponent> children = theORStage.getChildren();
|
List<RocketComponent> children = theORStage.getChildren();
|
||||||
for (int i = 0; i < children.size(); i++) {
|
for (RocketComponent rocketComponents : children) {
|
||||||
RocketComponent rocketComponents = children.get(i);
|
if (rocketComponents instanceof NoseCone) {
|
||||||
if (rocketComponents instanceof NoseCone) {
|
addExternalPart(toNoseConeDTO((NoseCone) rocketComponents));
|
||||||
addExternalPart(toNoseConeDTO((NoseCone) rocketComponents));
|
} else if (rocketComponents instanceof BodyTube) {
|
||||||
} else if (rocketComponents instanceof BodyTube) {
|
addExternalPart(toBodyTubeDTO((BodyTube) rocketComponents));
|
||||||
addExternalPart(toBodyTubeDTO((BodyTube) rocketComponents));
|
} else if (rocketComponents instanceof Transition) {
|
||||||
} else if (rocketComponents instanceof Transition) {
|
addExternalPart(toTransitionDTO((Transition) rocketComponents));
|
||||||
addExternalPart(toTransitionDTO((Transition) rocketComponents));
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<BasePartDTO> getExternalPart() {
|
public List<BasePartDTO> getExternalPart() {
|
||||||
|
@ -603,17 +603,17 @@ public final class DefaultObj implements Obj {
|
|||||||
if (indices == null) {
|
if (indices == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < indices.length; i++) {
|
for (int index : indices) {
|
||||||
if (indices[i] < 0) {
|
if (index < 0) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
name + " index is negative: " + indices[i]);
|
name + " index is negative: " + index);
|
||||||
}
|
}
|
||||||
if (indices[i] >= max) {
|
if (index >= max) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
name + " index is " + indices[i] +
|
name + " index is " + index +
|
||||||
", but must be smaller than " + max);
|
", but must be smaller than " + max);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,12 +76,11 @@ public enum RockSimComponentFileType {
|
|||||||
*/
|
*/
|
||||||
public static RockSimComponentFileType determineType(String[] headers) {
|
public static RockSimComponentFileType determineType(String[] headers) {
|
||||||
RockSimComponentFileType[] types = values();
|
RockSimComponentFileType[] types = values();
|
||||||
for (int i = 0; i < types.length; i++) {
|
for (RockSimComponentFileType type : types) {
|
||||||
RockSimComponentFileType type = types[i];
|
if (Arrays.equals(headers, type.columns)) {
|
||||||
if (Arrays.equals(headers, type.columns)) {
|
return type;
|
||||||
return type;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -186,8 +186,7 @@ public abstract class BaseComponentDTO {
|
|||||||
if (dto == null) {
|
if (dto == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
for (int i = 0; i < materialList.size(); i++) {
|
for (MaterialDTO materialDTO : materialList) {
|
||||||
MaterialDTO materialDTO = materialList.get(i);
|
|
||||||
if (materialDTO.getType().name().equals(dto.type) && materialDTO.getName().equals(dto.material)) {
|
if (materialDTO.getType().name().equals(dto.type) && materialDTO.getName().equals(dto.material)) {
|
||||||
return materialDTO.asMaterial();
|
return materialDTO.asMaterial();
|
||||||
}
|
}
|
||||||
|
@ -98,9 +98,9 @@ public class OpenRocketComponentDTO {
|
|||||||
|
|
||||||
public List<ComponentPreset> asComponentPresets() throws InvalidComponentPresetException {
|
public List<ComponentPreset> asComponentPresets() throws InvalidComponentPresetException {
|
||||||
List<ComponentPreset> result = new ArrayList<>(components.size());
|
List<ComponentPreset> result = new ArrayList<>(components.size());
|
||||||
for (int i = 0; i < components.size(); i++) {
|
for (BaseComponentDTO component : components) {
|
||||||
result.add(components.get(i).asComponentPreset(getLegacy(), materials));
|
result.add(component.asComponentPreset(getLegacy(), materials));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,12 +26,11 @@ public enum ShapeDTO {
|
|||||||
|
|
||||||
public static ShapeDTO asDTO(Transition.Shape targetShape) {
|
public static ShapeDTO asDTO(Transition.Shape targetShape) {
|
||||||
ShapeDTO[] values = values();
|
ShapeDTO[] values = values();
|
||||||
for (int i = 0; i < values.length; i++) {
|
for (ShapeDTO value : values) {
|
||||||
ShapeDTO value = values[i];
|
if (value.corollary.equals(targetShape)) {
|
||||||
if (value.corollary.equals(targetShape)) {
|
return value;
|
||||||
return value;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return ELLIPSOID; // default
|
return ELLIPSOID; // default
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,15 +208,15 @@ public class GeneralUnit extends Unit {
|
|||||||
private static void printTicks(double start, double end, double minor, double major) {
|
private static void printTicks(double start, double end, double minor, double major) {
|
||||||
Tick[] ticks = Unit.NOUNIT.getTicks(start, end, minor, major);
|
Tick[] ticks = Unit.NOUNIT.getTicks(start, end, minor, major);
|
||||||
String str = "Ticks for ("+start+","+end+","+minor+","+major+"):";
|
String str = "Ticks for ("+start+","+end+","+minor+","+major+"):";
|
||||||
for (int i=0; i<ticks.length; i++) {
|
for (Tick tick : ticks) {
|
||||||
str += " "+ticks[i].value;
|
str += " " + tick.value;
|
||||||
if (ticks[i].major) {
|
if (tick.major) {
|
||||||
if (ticks[i].notable)
|
if (tick.notable)
|
||||||
str += "*";
|
str += "*";
|
||||||
else
|
else
|
||||||
str += "o";
|
str += "o";
|
||||||
} else {
|
} else {
|
||||||
if (ticks[i].notable)
|
if (tick.notable)
|
||||||
str += "_";
|
str += "_";
|
||||||
else
|
else
|
||||||
str += " ";
|
str += " ";
|
||||||
|
@ -634,9 +634,9 @@ public class UnitGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Unit getUnit(String name) throws IllegalArgumentException {
|
public Unit getUnit(String name) throws IllegalArgumentException {
|
||||||
for (int i = 0; i < units.size(); i++) {
|
for (Unit unit : units) {
|
||||||
if (units.get(i).getUnit().equals(name)) {
|
if (unit.getUnit().equals(name)) {
|
||||||
return units.get(i);
|
return unit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException("name=" + name);
|
throw new IllegalArgumentException("name=" + name);
|
||||||
|
@ -32,9 +32,9 @@ public class ArrayUtils {
|
|||||||
*/
|
*/
|
||||||
public static double mean(double[] vals) {
|
public static double mean(double[] vals) {
|
||||||
double subtotal = 0;
|
double subtotal = 0;
|
||||||
for (int i = 0; i < vals.length; i++) {
|
for (double val : vals) {
|
||||||
if (!Double.isNaN(vals[i])) {
|
if (!Double.isNaN(val)) {
|
||||||
subtotal += vals[i];
|
subtotal += val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
subtotal = subtotal / vals.length;
|
subtotal = subtotal / vals.length;
|
||||||
@ -70,9 +70,9 @@ public class ArrayUtils {
|
|||||||
double mu = mean(vals);
|
double mu = mean(vals);
|
||||||
double sumsq = 0.0;
|
double sumsq = 0.0;
|
||||||
double temp = 0;
|
double temp = 0;
|
||||||
for (int i = 0; i < vals.length; i++) {
|
for (double val : vals) {
|
||||||
if (!Double.isNaN(vals[i])) {
|
if (!Double.isNaN(val)) {
|
||||||
temp = (mu - vals[i]);
|
temp = (mu - val);
|
||||||
sumsq += temp * temp;
|
sumsq += temp * temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,8 +57,8 @@ public class PolyInterpolator {
|
|||||||
*/
|
*/
|
||||||
public PolyInterpolator(double[]... points) {
|
public PolyInterpolator(double[]... points) {
|
||||||
int myCount = 0;
|
int myCount = 0;
|
||||||
for (int i = 0; i < points.length; i++) {
|
for (double[] point : points) {
|
||||||
myCount += points[i].length;
|
myCount += point.length;
|
||||||
}
|
}
|
||||||
if (myCount == 0) {
|
if (myCount == 0) {
|
||||||
throw new IllegalArgumentException("No interpolation points defined.");
|
throw new IllegalArgumentException("No interpolation points defined.");
|
||||||
|
@ -69,8 +69,8 @@ public class QuaternionMultiply {
|
|||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Multiplying:");
|
System.out.println("Multiplying:");
|
||||||
for (int i = 0; i < values.length; i++) {
|
for (Value[] value : values) {
|
||||||
print(values[i]);
|
print(value);
|
||||||
}
|
}
|
||||||
System.out.println("Result:");
|
System.out.println("Result:");
|
||||||
|
|
||||||
|
@ -108,9 +108,9 @@ public class TestFlightData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addDataPoints(final FlightDataBranch branch, final FlightDataType dataType, final double[] values) {
|
private void addDataPoints(final FlightDataBranch branch, final FlightDataType dataType, final double[] values) {
|
||||||
for (int i = 0; i < values.length; i++) {
|
for (double value : values) {
|
||||||
branch.addPoint();
|
branch.addPoint();
|
||||||
branch.setValue(dataType, values[i]);
|
branch.setValue(dataType, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,8 +67,8 @@ public class PolyInterpolatorTest {
|
|||||||
/* x=1.10 */ 1.5999999999999837
|
/* x=1.10 */ 1.5999999999999837
|
||||||
};
|
};
|
||||||
double x = 0.6;
|
double x = 0.6;
|
||||||
for (int i = 0; i < answer0.length; i++) {
|
for (double v : answer0) {
|
||||||
assertEquals(PolyInterpolator.eval(x, r0), answer0[i], 0.00001, "r0 different at x=" + x);
|
assertEquals(PolyInterpolator.eval(x, r0), v, 0.00001, "r0 different at x=" + x);
|
||||||
x += 0.01;
|
x += 0.01;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,8 +133,8 @@ public class PolyInterpolatorTest {
|
|||||||
/* x=1.10 */ 1.5999999999999686
|
/* x=1.10 */ 1.5999999999999686
|
||||||
};
|
};
|
||||||
double x = 0.6;
|
double x = 0.6;
|
||||||
for (int i = 0; i < answer1.length; i++) {
|
for (double v : answer1) {
|
||||||
assertEquals(PolyInterpolator.eval(x, r1), answer1[i], 0.00001, "r1 different at x=" + x);
|
assertEquals(PolyInterpolator.eval(x, r1), v, 0.00001, "r1 different at x=" + x);
|
||||||
x += 0.01;
|
x += 0.01;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -199,8 +199,8 @@ public class PolyInterpolatorTest {
|
|||||||
};
|
};
|
||||||
|
|
||||||
double x = 0.6;
|
double x = 0.6;
|
||||||
for (int i = 0; i < answer2.length; i++) {
|
for (double v : answer2) {
|
||||||
assertEquals(PolyInterpolator.eval(x, r2), answer2[i], 0.00001, "r2 different at x=" + x);
|
assertEquals(PolyInterpolator.eval(x, r2), v, 0.00001, "r2 different at x=" + x);
|
||||||
x += 0.01;
|
x += 0.01;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -567,8 +567,8 @@ public class DoubleModel implements StateChangeListener, ChangeSource, Invalidat
|
|||||||
oldValue, newValue);
|
oldValue, newValue);
|
||||||
oldValue = newValue;
|
oldValue = newValue;
|
||||||
Object[] l = propertyChangeListeners.toArray();
|
Object[] l = propertyChangeListeners.toArray();
|
||||||
for (int i = 0; i < l.length; i++) {
|
for (Object o : l) {
|
||||||
((PropertyChangeListener) l[i]).propertyChange(event);
|
((PropertyChangeListener) o).propertyChange(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,12 +410,11 @@ public abstract class FinSetConfig extends RocketComponentConfig {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
for (int i = 0; i < rings.size(); i++) {
|
for (CenteringRing centeringRing : rings) {
|
||||||
CenteringRing centeringRing = rings.get(i);
|
|
||||||
//Handle centering rings that overlap or are adjacent by synthetically merging them into one virtual ring.
|
//Handle centering rings that overlap or are adjacent by synthetically merging them into one virtual ring.
|
||||||
if (!positionsFromTop.isEmpty() &&
|
if (!positionsFromTop.isEmpty() &&
|
||||||
positionsFromTop.get(positionsFromTop.size() - 1).bottomSidePositionFromTop() >=
|
positionsFromTop.get(positionsFromTop.size() - 1).bottomSidePositionFromTop() >=
|
||||||
centeringRing.getAxialOffset(AxialMethod.TOP)) {
|
centeringRing.getAxialOffset(AxialMethod.TOP)) {
|
||||||
SortableRing adjacent = positionsFromTop.get(positionsFromTop.size() - 1);
|
SortableRing adjacent = positionsFromTop.get(positionsFromTop.size() - 1);
|
||||||
adjacent.merge(centeringRing, relativeTo);
|
adjacent.merge(centeringRing, relativeTo);
|
||||||
} else {
|
} else {
|
||||||
@ -423,8 +422,7 @@ public abstract class FinSetConfig extends RocketComponentConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < positionsFromTop.size(); i++) {
|
for (SortableRing sortableRing : positionsFromTop) {
|
||||||
SortableRing sortableRing = positionsFromTop.get(i);
|
|
||||||
if (top == null) {
|
if (top == null) {
|
||||||
top = sortableRing;
|
top = sortableRing;
|
||||||
} else if (sortableRing.bottomSidePositionFromTop() <= finPositionFromTop) {
|
} else if (sortableRing.bottomSidePositionFromTop() <= finPositionFromTop) {
|
||||||
|
@ -566,8 +566,7 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec
|
|||||||
List<ThrustCurveMotor> motors = selectedMotorSet.getMotors();
|
List<ThrustCurveMotor> motors = selectedMotorSet.getMotors();
|
||||||
if (hideSimilarBox.isSelected() && selectedMotor != null) {
|
if (hideSimilarBox.isSelected() && selectedMotor != null) {
|
||||||
List<ThrustCurveMotor> filtered = new ArrayList<>(motors.size());
|
List<ThrustCurveMotor> filtered = new ArrayList<>(motors.size());
|
||||||
for (int i = 0; i < motors.size(); i++) {
|
for (ThrustCurveMotor m : motors) {
|
||||||
ThrustCurveMotor m = motors.get(i);
|
|
||||||
if (m.equals(selectedMotor)) {
|
if (m.equals(selectedMotor)) {
|
||||||
filtered.add(m);
|
filtered.add(m);
|
||||||
continue;
|
continue;
|
||||||
|
@ -42,9 +42,9 @@ public class XTableColumnModel extends DefaultTableColumnModel {
|
|||||||
int noInvisibleColumns = allTableColumns.size();
|
int noInvisibleColumns = allTableColumns.size();
|
||||||
int visibleIndex = 0;
|
int visibleIndex = 0;
|
||||||
|
|
||||||
for (int invisibleIndex = 0; invisibleIndex < noInvisibleColumns; ++invisibleIndex) {
|
for (TableColumn allTableColumn : allTableColumns) {
|
||||||
TableColumn visibleColumn = (visibleIndex < noVisibleColumns ? (TableColumn) tableColumns.get(visibleIndex) : null);
|
TableColumn visibleColumn = (visibleIndex < noVisibleColumns ? (TableColumn) tableColumns.get(visibleIndex) : null);
|
||||||
TableColumn testColumn = allTableColumns.get(invisibleIndex);
|
TableColumn testColumn = allTableColumn;
|
||||||
|
|
||||||
if (testColumn == column) {
|
if (testColumn == column) {
|
||||||
if (visibleColumn != column) {
|
if (visibleColumn != column) {
|
||||||
@ -90,8 +90,7 @@ public class XTableColumnModel extends DefaultTableColumnModel {
|
|||||||
* @return table column object or null if no such column in this column model
|
* @return table column object or null if no such column in this column model
|
||||||
*/
|
*/
|
||||||
public TableColumn getColumnByModelIndex(int modelColumnIndex) {
|
public TableColumn getColumnByModelIndex(int modelColumnIndex) {
|
||||||
for (int columnIndex = 0; columnIndex < allTableColumns.size(); ++columnIndex) {
|
for (TableColumn column : allTableColumns) {
|
||||||
TableColumn column = allTableColumns.get(columnIndex);
|
|
||||||
if (column.getModelIndex() == modelColumnIndex) {
|
if (column.getModelIndex() == modelColumnIndex) {
|
||||||
return column;
|
return column;
|
||||||
}
|
}
|
||||||
|
@ -222,9 +222,9 @@ public abstract class RocketRenderer {
|
|||||||
Coordinate[] position = ((RocketComponent) mount).toAbsolute(new Coordinate(((RocketComponent) mount)
|
Coordinate[] position = ((RocketComponent) mount).toAbsolute(new Coordinate(((RocketComponent) mount)
|
||||||
.getLength() + mount.getMotorOverhang() - length));
|
.getLength() + mount.getMotorOverhang() - length));
|
||||||
|
|
||||||
for (int i = 0; i < position.length; i++) {
|
for (Coordinate coordinate : position) {
|
||||||
gl.glPushMatrix();
|
gl.glPushMatrix();
|
||||||
gl.glTranslated(position[i].x, position[i].y, position[i].z);
|
gl.glTranslated(coordinate.x, coordinate.y, coordinate.z);
|
||||||
renderMotor(gl, motor);
|
renderMotor(gl, motor);
|
||||||
gl.glPopMatrix();
|
gl.glPopMatrix();
|
||||||
}
|
}
|
||||||
|
@ -276,8 +276,8 @@ public class PhotoFrame extends JFrame {
|
|||||||
@Override
|
@Override
|
||||||
public boolean isDataFlavorSupported(DataFlavor flavor) {
|
public boolean isDataFlavorSupported(DataFlavor flavor) {
|
||||||
DataFlavor[] flavors = getTransferDataFlavors();
|
DataFlavor[] flavors = getTransferDataFlavors();
|
||||||
for (int i = 0; i < flavors.length; i++) {
|
for (DataFlavor dataFlavor : flavors) {
|
||||||
if (flavor.equals(flavors[i])) {
|
if (flavor.equals(dataFlavor)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -564,10 +564,10 @@ public class PhotoPanel extends JPanel implements GLEventListener {
|
|||||||
.toAbsolute(new Coordinate(((RocketComponent) mount)
|
.toAbsolute(new Coordinate(((RocketComponent) mount)
|
||||||
.getLength() + mount.getMotorOverhang() - length));
|
.getLength() + mount.getMotorOverhang() - length));
|
||||||
|
|
||||||
for (int i = 0; i < position.length; i++) {
|
for (Coordinate coordinate : position) {
|
||||||
gl.glPushMatrix();
|
gl.glPushMatrix();
|
||||||
gl.glTranslated(position[i].x + motor.getLength(),
|
gl.glTranslated(coordinate.x + motor.getLength(),
|
||||||
position[i].y, position[i].z);
|
coordinate.y, coordinate.z);
|
||||||
FlameRenderer.drawExhaust(gl, p, motor);
|
FlameRenderer.drawExhaust(gl, p, motor);
|
||||||
gl.glPopMatrix();
|
gl.glPopMatrix();
|
||||||
}
|
}
|
||||||
|
@ -277,9 +277,9 @@ public class ComponentAddButtons extends JPanel implements Scrollable {
|
|||||||
|
|
||||||
Dimension d = viewport.getExtentSize();
|
Dimension d = viewport.getExtentSize();
|
||||||
|
|
||||||
for (int row = 0; row < buttons.length; row++) {
|
for (ComponentButton[] button : buttons) {
|
||||||
w = 0;
|
w = 0;
|
||||||
for (int col = 0; col < buttons[row].length; col++) {
|
for (int col = 0; col < button.length; col++) {
|
||||||
w += GAP + width;
|
w += GAP + width;
|
||||||
String param = BUTTONPARAM + ",width " + width + "!,height " + height + "!";
|
String param = BUTTONPARAM + ",width " + width + "!,height " + height + "!";
|
||||||
|
|
||||||
@ -287,9 +287,9 @@ public class ComponentAddButtons extends JPanel implements Scrollable {
|
|||||||
param = param + ",newline";
|
param = param + ",newline";
|
||||||
w = GAP + width;
|
w = GAP + width;
|
||||||
}
|
}
|
||||||
if (col == buttons[row].length - 1)
|
if (col == button.length - 1)
|
||||||
param = param + ",wrap";
|
param = param + ",wrap";
|
||||||
layout.setComponentConstraints(buttons[row][col], param);
|
layout.setComponentConstraints(button[col], param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
revalidate();
|
revalidate();
|
||||||
@ -408,8 +408,7 @@ public class ComponentAddButtons extends JPanel implements Scrollable {
|
|||||||
public void setEnabled(boolean enabled) {
|
public void setEnabled(boolean enabled) {
|
||||||
super.setEnabled(enabled);
|
super.setEnabled(enabled);
|
||||||
Component[] c = getComponents();
|
Component[] c = getComponents();
|
||||||
for (int i = 0; i < c.length; i++)
|
for (Component component : c) component.setEnabled(enabled);
|
||||||
c[i].setEnabled(enabled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,8 +114,7 @@ public class ComponentTreeModel implements TreeModel, ComponentChangeListener {
|
|||||||
// Send structure change event
|
// Send structure change event
|
||||||
TreeModelEvent e = new TreeModelEvent(this, path);
|
TreeModelEvent e = new TreeModelEvent(this, path);
|
||||||
Object[] l = listeners.toArray();
|
Object[] l = listeners.toArray();
|
||||||
for (int i = 0; i < l.length; i++)
|
for (Object o : l) ((TreeModelListener) o).treeStructureChanged(e);
|
||||||
((TreeModelListener) l[i]).treeStructureChanged(e);
|
|
||||||
|
|
||||||
// Re-expand the paths
|
// Re-expand the paths
|
||||||
for (UUID id : expanded) {
|
for (UUID id : expanded) {
|
||||||
|
@ -2293,8 +2293,7 @@ public class PresetEditorDialog extends JDialog implements ItemListener {
|
|||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
List<String> invalids = e.getErrors();
|
List<String> invalids = e.getErrors();
|
||||||
stringBuilder.append(baseMsg).append("\n");
|
stringBuilder.append(baseMsg).append("\n");
|
||||||
for (int i = 0; i < invalids.size(); i++) {
|
for (String s : invalids) {
|
||||||
String s = invalids.get(i);
|
|
||||||
stringBuilder.append(s).append("\n");
|
stringBuilder.append(s).append("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -577,8 +577,7 @@ public class DesignReport {
|
|||||||
private FlightData findSimulation(final FlightConfigurationId motorId, List<Simulation> simulations) {
|
private FlightData findSimulation(final FlightConfigurationId motorId, List<Simulation> simulations) {
|
||||||
// Perform flight simulation
|
// Perform flight simulation
|
||||||
FlightData flight = null;
|
FlightData flight = null;
|
||||||
for (int i = 0; i < simulations.size(); i++) {
|
for (Simulation simulation : simulations) {
|
||||||
Simulation simulation = simulations.get(i);
|
|
||||||
if (Utils.equals(simulation.getId(), motorId)) {
|
if (Utils.equals(simulation.getId(), motorId)) {
|
||||||
flight = simulation.getSimulatedData();
|
flight = simulation.getSimulatedData();
|
||||||
break;
|
break;
|
||||||
|
@ -78,10 +78,10 @@ public class RocketPrintTree extends JTree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<OpenRocketPrintable> unstaged = OpenRocketPrintable.getUnstaged();
|
List<OpenRocketPrintable> unstaged = OpenRocketPrintable.getUnstaged();
|
||||||
for (int i = 0; i < unstaged.size(); i++) {
|
for (OpenRocketPrintable openRocketPrintable : unstaged) {
|
||||||
toAddTo.add(new CheckBoxNode(unstaged.get(i).getDescription(),
|
toAddTo.add(new CheckBoxNode(openRocketPrintable.getDescription(),
|
||||||
INITIAL_CHECKBOX_SELECTED));
|
INITIAL_CHECKBOX_SELECTED));
|
||||||
}
|
}
|
||||||
|
|
||||||
RocketPrintTree tree = new RocketPrintTree(root);
|
RocketPrintTree tree = new RocketPrintTree(root);
|
||||||
|
|
||||||
@ -247,8 +247,8 @@ class NamedVector extends Vector<CheckBoxNode> {
|
|||||||
|
|
||||||
public NamedVector(String theName, CheckBoxNode elements[]) {
|
public NamedVector(String theName, CheckBoxNode elements[]) {
|
||||||
name = theName;
|
name = theName;
|
||||||
for (int i = 0, n = elements.length; i < n; i++) {
|
for (CheckBoxNode element : elements) {
|
||||||
add(elements[i]);
|
add(element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,8 +277,8 @@ public class RocketFigure extends AbstractScaleFigure {
|
|||||||
boolean selected = false;
|
boolean selected = false;
|
||||||
|
|
||||||
// Check if component is in the selection
|
// Check if component is in the selection
|
||||||
for (int j = 0; j < selection.length; j++) {
|
for (RocketComponent rocketComponent : selection) {
|
||||||
if (c == selection[j]) {
|
if (c == rocketComponent) {
|
||||||
selected = true;
|
selected = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -287,8 +287,8 @@ public class SimulationExportPanel extends JPanel {
|
|||||||
int n = 0;
|
int n = 0;
|
||||||
String str;
|
String str;
|
||||||
|
|
||||||
for (int i = 0; i < selected.length; i++) {
|
for (boolean b : selected) {
|
||||||
if (selected[i])
|
if (b)
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,13 +40,13 @@ public class SerializePresets extends BasicApplication {
|
|||||||
|
|
||||||
ComponentPresetDatabase componentPresetDao = new ComponentPresetDatabase();
|
ComponentPresetDatabase componentPresetDao = new ComponentPresetDatabase();
|
||||||
|
|
||||||
for (int i = 0; i < args.length; i++) {
|
for (String arg : args) {
|
||||||
|
|
||||||
System.err.println("Processing .orc files in directory " + args[i]);
|
System.err.println("Processing .orc files in directory " + arg);
|
||||||
|
|
||||||
FileIterator iterator = DirectoryIterator.findDirectory(args[i], new SimpleFileFilter("", false, "orc"));
|
FileIterator iterator = DirectoryIterator.findDirectory(arg, new SimpleFileFilter("", false, "orc"));
|
||||||
if (iterator == null) {
|
if (iterator == null) {
|
||||||
throw new RuntimeException("Can't find " + args[i] + " directory");
|
throw new RuntimeException("Can't find " + arg + " directory");
|
||||||
}
|
}
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user