Use enhanced for-loops

This commit is contained in:
SiboVG 2024-08-09 05:20:27 +02:00
parent 7678a1226f
commit fd3f2e167c
37 changed files with 199 additions and 213 deletions

View File

@ -36,9 +36,9 @@ public class Example {
}
double subtotal = 0;
for (int i = 0; i < vals.length; i++ ){
subtotal += vals[i];
}
for (double val : vals) {
subtotal += val;
}
subtotal = scale * subtotal / vals.length;
return new Variable("double MEAN result, ", subtotal);

View File

@ -547,8 +547,8 @@ public class FinSetCalc extends RocketComponentCalc {
double x = 1.0;
double val = 0;
for (int i = 0; i < poly.length; i++) {
val += poly[i] * x;
for (double v : poly) {
val += v * x;
x *= m;
}
// logger.debug("val = {}", val);

View File

@ -229,8 +229,8 @@ public class TubeFinSetCalc extends TubeCalc {
double x = 1.0;
double val = 0;
for (int i = 0; i < poly.length; i++) {
val += poly[i] * x;
for (double v : poly) {
val += v * x;
x *= m;
}
// log.debug("val = {}", val);

View File

@ -87,8 +87,9 @@ public class ComponentPresetDatabase extends Database<ComponentPreset> implement
for (ComponentPreset preset : list) {
ComponentPreset.Type presetType = preset.get(ComponentPreset.TYPE);
typeLoop: for (int i = 0; i < type.length; i++) {
if (presetType.equals(type[i])) {
typeLoop:
for (ComponentPreset.Type value : type) {
if (presetType.equals(value)) {
result.add(preset);
break typeLoop; // from inner loop.
}

View File

@ -114,13 +114,13 @@ public class RASPMotorLoader extends AbstractMotorLoader {
} else {
buf = split(pieces[3], "[-,]+");
for (int i = 0; i < buf.length; i++) {
if (buf[i].equalsIgnoreCase("P") ||
buf[i].equalsIgnoreCase("plugged")) {
for (String s : buf) {
if (s.equalsIgnoreCase("P") ||
s.equalsIgnoreCase("plugged")) {
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
double d = Double.parseDouble(buf[i]);
double d = Double.parseDouble(s);
if (d < 99)
delays.add(d);
}

View File

@ -480,8 +480,8 @@ public class OpenRocketSaver extends RocketSaver {
// Retrieve the data from the branch
List<List<Double>> data = new ArrayList<>(types.length);
for (int i = 0; i < types.length; i++) {
data.add(branch.get(types[i]));
for (FlightDataType type : types) {
data.add(branch.get(type));
}
// Build the <databranch> tag

View File

@ -78,32 +78,31 @@ public class AbstractTransitionDTO extends BasePartDTO implements AttachablePart
setWallThickness(nc.getThickness() * RockSimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
List<RocketComponent> children = nc.getChildren();
for (int i = 0; i < children.size(); i++) {
RocketComponent rocketComponents = children.get(i);
if (rocketComponents instanceof InnerTube) {
addAttachedPart(new InnerBodyTubeDTO((InnerTube) rocketComponents, this));
} else if (rocketComponents instanceof BodyTube) {
addAttachedPart(new BodyTubeDTO((BodyTube) rocketComponents));
} else if (rocketComponents instanceof Transition) {
addAttachedPart(new TransitionDTO((Transition) rocketComponents));
} else if (rocketComponents instanceof EngineBlock) {
addAttachedPart(new EngineBlockDTO((EngineBlock) rocketComponents));
} else if (rocketComponents instanceof TubeCoupler) {
addAttachedPart(new TubeCouplerDTO((TubeCoupler) rocketComponents, this));
} else if (rocketComponents instanceof CenteringRing) {
addAttachedPart(new CenteringRingDTO((CenteringRing) rocketComponents));
} else if (rocketComponents instanceof Bulkhead) {
addAttachedPart(new BulkheadDTO((Bulkhead) rocketComponents));
} else if (rocketComponents instanceof Parachute) {
addAttachedPart(new ParachuteDTO((Parachute) rocketComponents));
} else if (rocketComponents instanceof MassObject) {
addAttachedPart(new MassObjectDTO((MassObject) rocketComponents));
} else if (rocketComponents instanceof FreeformFinSet) {
addAttachedPart(new CustomFinSetDTO((FreeformFinSet) rocketComponents));
} else if (rocketComponents instanceof FinSet) {
addAttachedPart(new FinSetDTO((FinSet) rocketComponents));
}
}
for (RocketComponent rocketComponents : children) {
if (rocketComponents instanceof InnerTube) {
addAttachedPart(new InnerBodyTubeDTO((InnerTube) rocketComponents, this));
} else if (rocketComponents instanceof BodyTube) {
addAttachedPart(new BodyTubeDTO((BodyTube) rocketComponents));
} else if (rocketComponents instanceof Transition) {
addAttachedPart(new TransitionDTO((Transition) rocketComponents));
} else if (rocketComponents instanceof EngineBlock) {
addAttachedPart(new EngineBlockDTO((EngineBlock) rocketComponents));
} else if (rocketComponents instanceof TubeCoupler) {
addAttachedPart(new TubeCouplerDTO((TubeCoupler) rocketComponents, this));
} else if (rocketComponents instanceof CenteringRing) {
addAttachedPart(new CenteringRingDTO((CenteringRing) rocketComponents));
} else if (rocketComponents instanceof Bulkhead) {
addAttachedPart(new BulkheadDTO((Bulkhead) rocketComponents));
} else if (rocketComponents instanceof Parachute) {
addAttachedPart(new ParachuteDTO((Parachute) rocketComponents));
} else if (rocketComponents instanceof MassObject) {
addAttachedPart(new MassObjectDTO((MassObject) rocketComponents));
} else if (rocketComponents instanceof FreeformFinSet) {
addAttachedPart(new CustomFinSetDTO((FreeformFinSet) rocketComponents));
} else if (rocketComponents instanceof FinSet) {
addAttachedPart(new FinSetDTO((FinSet) rocketComponents));
}
}
}
public int getShapeCode() {

View File

@ -94,51 +94,50 @@ public class BodyTubeDTO extends BasePartDTO implements AttachableParts {
setMotorMount(theORBodyTube.isMotorMount());
List<RocketComponent> children = theORBodyTube.getChildren();
for (int i = 0; i < children.size(); i++) {
RocketComponent rocketComponent = children.get(i);
if (rocketComponent instanceof InnerTube) {
final InnerTube innerTube = (InnerTube) rocketComponent;
final InnerBodyTubeDTO innerBodyTubeDTO = new InnerBodyTubeDTO(innerTube, this);
//Only add the inner tube if it is NOT a cluster.
if (innerTube.getInstanceCount() == 1) {
addAttachedPart(innerBodyTubeDTO);
}
} else if (rocketComponent instanceof BodyTube) {
addAttachedPart(new BodyTubeDTO((BodyTube) rocketComponent));
} else if (rocketComponent instanceof Transition) {
addAttachedPart(new TransitionDTO((Transition) rocketComponent));
} else if (rocketComponent instanceof EngineBlock) {
addAttachedPart(new EngineBlockDTO((EngineBlock) rocketComponent));
} else if (rocketComponent instanceof TubeCoupler) {
addAttachedPart(new TubeCouplerDTO((TubeCoupler) rocketComponent, this));
} else if (rocketComponent instanceof CenteringRing) {
addAttachedPart(new CenteringRingDTO((CenteringRing) rocketComponent));
} else if (rocketComponent instanceof Bulkhead) {
addAttachedPart(new BulkheadDTO((Bulkhead) rocketComponent));
} else if (rocketComponent instanceof LaunchLug) {
addAttachedPart(new LaunchLugDTO((LaunchLug) rocketComponent));
} else if (rocketComponent instanceof Streamer) {
addAttachedPart(new StreamerDTO((Streamer) rocketComponent));
} else if (rocketComponent instanceof Parachute) {
addAttachedPart(new ParachuteDTO((Parachute) rocketComponent));
} else if (rocketComponent instanceof MassObject) {
addAttachedPart(new MassObjectDTO((MassObject) rocketComponent));
} else if (rocketComponent instanceof FreeformFinSet) {
addAttachedPart(new CustomFinSetDTO((FreeformFinSet) rocketComponent));
} else if (rocketComponent instanceof FinSet) {
addAttachedPart(new FinSetDTO((FinSet) rocketComponent));
} else if (rocketComponent instanceof TubeFinSet) {
addAttachedPart(new TubeFinSetDTO((TubeFinSet) rocketComponent));
} else if (rocketComponent instanceof PodSet) {
for (PodSetDTO podSetDTO : PodSetDTO.generatePodSetDTOs((PodSet) rocketComponent)) {
addAttachedPart(podSetDTO);
}
} else if (rocketComponent instanceof ParallelStage) {
for (ParallelStageDTO parallelStageDTO : ParallelStageDTO.generateParallelStageDTOs((ParallelStage) rocketComponent)) {
addAttachedPart(parallelStageDTO);
}
}
}
for (RocketComponent rocketComponent : children) {
if (rocketComponent instanceof InnerTube) {
final InnerTube innerTube = (InnerTube) rocketComponent;
final InnerBodyTubeDTO innerBodyTubeDTO = new InnerBodyTubeDTO(innerTube, this);
//Only add the inner tube if it is NOT a cluster.
if (innerTube.getInstanceCount() == 1) {
addAttachedPart(innerBodyTubeDTO);
}
} else if (rocketComponent instanceof BodyTube) {
addAttachedPart(new BodyTubeDTO((BodyTube) rocketComponent));
} else if (rocketComponent instanceof Transition) {
addAttachedPart(new TransitionDTO((Transition) rocketComponent));
} else if (rocketComponent instanceof EngineBlock) {
addAttachedPart(new EngineBlockDTO((EngineBlock) rocketComponent));
} else if (rocketComponent instanceof TubeCoupler) {
addAttachedPart(new TubeCouplerDTO((TubeCoupler) rocketComponent, this));
} else if (rocketComponent instanceof CenteringRing) {
addAttachedPart(new CenteringRingDTO((CenteringRing) rocketComponent));
} else if (rocketComponent instanceof Bulkhead) {
addAttachedPart(new BulkheadDTO((Bulkhead) rocketComponent));
} else if (rocketComponent instanceof LaunchLug) {
addAttachedPart(new LaunchLugDTO((LaunchLug) rocketComponent));
} else if (rocketComponent instanceof Streamer) {
addAttachedPart(new StreamerDTO((Streamer) rocketComponent));
} else if (rocketComponent instanceof Parachute) {
addAttachedPart(new ParachuteDTO((Parachute) rocketComponent));
} else if (rocketComponent instanceof MassObject) {
addAttachedPart(new MassObjectDTO((MassObject) rocketComponent));
} else if (rocketComponent instanceof FreeformFinSet) {
addAttachedPart(new CustomFinSetDTO((FreeformFinSet) rocketComponent));
} else if (rocketComponent instanceof FinSet) {
addAttachedPart(new FinSetDTO((FinSet) rocketComponent));
} else if (rocketComponent instanceof TubeFinSet) {
addAttachedPart(new TubeFinSetDTO((TubeFinSet) rocketComponent));
} else if (rocketComponent instanceof PodSet) {
for (PodSetDTO podSetDTO : PodSetDTO.generatePodSetDTOs((PodSet) rocketComponent)) {
addAttachedPart(podSetDTO);
}
} else if (rocketComponent instanceof ParallelStage) {
for (ParallelStageDTO parallelStageDTO : ParallelStageDTO.generateParallelStageDTOs((ParallelStage) rocketComponent)) {
addAttachedPart(parallelStageDTO);
}
}
}
}
public double getOD() {

View File

@ -58,8 +58,7 @@ public class InnerBodyTubeDTO extends BodyTubeDTO implements AttachableParts {
setRadialLoc(bt.getRadialPosition() * RockSimCommonConstants.ROCKSIM_TO_OPENROCKET_LENGTH);
List<RocketComponent> children = bt.getChildren();
for (int i = 0; i < children.size(); i++) {
RocketComponent rocketComponents = children.get(i);
for (RocketComponent rocketComponents : children) {
if (rocketComponents instanceof InnerTube) {
final InnerTube innerTube = (InnerTube) rocketComponents;
// Only if the inner tube is NOT a cluster, then create the corresponding

View File

@ -76,16 +76,15 @@ public class StageDTO {
}
List<RocketComponent> children = theORStage.getChildren();
for (int i = 0; i < children.size(); i++) {
RocketComponent rocketComponents = children.get(i);
if (rocketComponents instanceof NoseCone) {
addExternalPart(toNoseConeDTO((NoseCone) rocketComponents));
} else if (rocketComponents instanceof BodyTube) {
addExternalPart(toBodyTubeDTO((BodyTube) rocketComponents));
} else if (rocketComponents instanceof Transition) {
addExternalPart(toTransitionDTO((Transition) rocketComponents));
}
}
for (RocketComponent rocketComponents : children) {
if (rocketComponents instanceof NoseCone) {
addExternalPart(toNoseConeDTO((NoseCone) rocketComponents));
} else if (rocketComponents instanceof BodyTube) {
addExternalPart(toBodyTubeDTO((BodyTube) rocketComponents));
} else if (rocketComponents instanceof Transition) {
addExternalPart(toTransitionDTO((Transition) rocketComponents));
}
}
}
public List<BasePartDTO> getExternalPart() {

View File

@ -603,17 +603,17 @@ public final class DefaultObj implements Obj {
if (indices == null) {
return;
}
for (int i = 0; i < indices.length; i++) {
if (indices[i] < 0) {
throw new IllegalArgumentException(
name + " index is negative: " + indices[i]);
}
if (indices[i] >= max) {
throw new IllegalArgumentException(
name + " index is " + indices[i] +
", but must be smaller than " + max);
}
}
for (int index : indices) {
if (index < 0) {
throw new IllegalArgumentException(
name + " index is negative: " + index);
}
if (index >= max) {
throw new IllegalArgumentException(
name + " index is " + index +
", but must be smaller than " + max);
}
}
}
/**

View File

@ -76,12 +76,11 @@ public enum RockSimComponentFileType {
*/
public static RockSimComponentFileType determineType(String[] headers) {
RockSimComponentFileType[] types = values();
for (int i = 0; i < types.length; i++) {
RockSimComponentFileType type = types[i];
if (Arrays.equals(headers, type.columns)) {
return type;
}
}
for (RockSimComponentFileType type : types) {
if (Arrays.equals(headers, type.columns)) {
return type;
}
}
return null;
}
}

View File

@ -186,8 +186,7 @@ public abstract class BaseComponentDTO {
if (dto == null) {
return null;
}
for (int i = 0; i < materialList.size(); i++) {
MaterialDTO materialDTO = materialList.get(i);
for (MaterialDTO materialDTO : materialList) {
if (materialDTO.getType().name().equals(dto.type) && materialDTO.getName().equals(dto.material)) {
return materialDTO.asMaterial();
}

View File

@ -98,9 +98,9 @@ public class OpenRocketComponentDTO {
public List<ComponentPreset> asComponentPresets() throws InvalidComponentPresetException {
List<ComponentPreset> result = new ArrayList<>(components.size());
for (int i = 0; i < components.size(); i++) {
result.add(components.get(i).asComponentPreset(getLegacy(), materials));
}
for (BaseComponentDTO component : components) {
result.add(component.asComponentPreset(getLegacy(), materials));
}
return result;
}

View File

@ -26,12 +26,11 @@ public enum ShapeDTO {
public static ShapeDTO asDTO(Transition.Shape targetShape) {
ShapeDTO[] values = values();
for (int i = 0; i < values.length; i++) {
ShapeDTO value = values[i];
if (value.corollary.equals(targetShape)) {
return value;
}
}
for (ShapeDTO value : values) {
if (value.corollary.equals(targetShape)) {
return value;
}
}
return ELLIPSOID; // default
}

View File

@ -208,15 +208,15 @@ public class GeneralUnit extends Unit {
private static void printTicks(double start, double end, double minor, double major) {
Tick[] ticks = Unit.NOUNIT.getTicks(start, end, minor, major);
String str = "Ticks for ("+start+","+end+","+minor+","+major+"):";
for (int i=0; i<ticks.length; i++) {
str += " "+ticks[i].value;
if (ticks[i].major) {
if (ticks[i].notable)
for (Tick tick : ticks) {
str += " " + tick.value;
if (tick.major) {
if (tick.notable)
str += "*";
else
str += "o";
} else {
if (ticks[i].notable)
if (tick.notable)
str += "_";
else
str += " ";

View File

@ -634,9 +634,9 @@ public class UnitGroup {
}
public Unit getUnit(String name) throws IllegalArgumentException {
for (int i = 0; i < units.size(); i++) {
if (units.get(i).getUnit().equals(name)) {
return units.get(i);
for (Unit unit : units) {
if (unit.getUnit().equals(name)) {
return unit;
}
}
throw new IllegalArgumentException("name=" + name);

View File

@ -32,9 +32,9 @@ public class ArrayUtils {
*/
public static double mean(double[] vals) {
double subtotal = 0;
for (int i = 0; i < vals.length; i++) {
if (!Double.isNaN(vals[i])) {
subtotal += vals[i];
for (double val : vals) {
if (!Double.isNaN(val)) {
subtotal += val;
}
}
subtotal = subtotal / vals.length;
@ -70,9 +70,9 @@ public class ArrayUtils {
double mu = mean(vals);
double sumsq = 0.0;
double temp = 0;
for (int i = 0; i < vals.length; i++) {
if (!Double.isNaN(vals[i])) {
temp = (mu - vals[i]);
for (double val : vals) {
if (!Double.isNaN(val)) {
temp = (mu - val);
sumsq += temp * temp;
}
}

View File

@ -57,8 +57,8 @@ public class PolyInterpolator {
*/
public PolyInterpolator(double[]... points) {
int myCount = 0;
for (int i = 0; i < points.length; i++) {
myCount += points[i].length;
for (double[] point : points) {
myCount += point.length;
}
if (myCount == 0) {
throw new IllegalArgumentException("No interpolation points defined.");

View File

@ -69,8 +69,8 @@ public class QuaternionMultiply {
}
System.out.println("Multiplying:");
for (int i = 0; i < values.length; i++) {
print(values[i]);
for (Value[] value : values) {
print(value);
}
System.out.println("Result:");

View File

@ -108,9 +108,9 @@ public class TestFlightData {
}
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.setValue(dataType, values[i]);
branch.setValue(dataType, value);
}
}

View File

@ -67,8 +67,8 @@ public class PolyInterpolatorTest {
/* x=1.10 */ 1.5999999999999837
};
double x = 0.6;
for (int i = 0; i < answer0.length; i++) {
assertEquals(PolyInterpolator.eval(x, r0), answer0[i], 0.00001, "r0 different at x=" + x);
for (double v : answer0) {
assertEquals(PolyInterpolator.eval(x, r0), v, 0.00001, "r0 different at x=" + x);
x += 0.01;
}
}
@ -133,8 +133,8 @@ public class PolyInterpolatorTest {
/* x=1.10 */ 1.5999999999999686
};
double x = 0.6;
for (int i = 0; i < answer1.length; i++) {
assertEquals(PolyInterpolator.eval(x, r1), answer1[i], 0.00001, "r1 different at x=" + x);
for (double v : answer1) {
assertEquals(PolyInterpolator.eval(x, r1), v, 0.00001, "r1 different at x=" + x);
x += 0.01;
}
}
@ -199,8 +199,8 @@ public class PolyInterpolatorTest {
};
double x = 0.6;
for (int i = 0; i < answer2.length; i++) {
assertEquals(PolyInterpolator.eval(x, r2), answer2[i], 0.00001, "r2 different at x=" + x);
for (double v : answer2) {
assertEquals(PolyInterpolator.eval(x, r2), v, 0.00001, "r2 different at x=" + x);
x += 0.01;
}

View File

@ -567,8 +567,8 @@ public class DoubleModel implements StateChangeListener, ChangeSource, Invalidat
oldValue, newValue);
oldValue = newValue;
Object[] l = propertyChangeListeners.toArray();
for (int i = 0; i < l.length; i++) {
((PropertyChangeListener) l[i]).propertyChange(event);
for (Object o : l) {
((PropertyChangeListener) o).propertyChange(event);
}
}

View File

@ -410,12 +410,11 @@ public abstract class FinSetConfig extends RocketComponentConfig {
}
});
for (int i = 0; i < rings.size(); i++) {
CenteringRing centeringRing = rings.get(i);
for (CenteringRing centeringRing : rings) {
//Handle centering rings that overlap or are adjacent by synthetically merging them into one virtual ring.
if (!positionsFromTop.isEmpty() &&
positionsFromTop.get(positionsFromTop.size() - 1).bottomSidePositionFromTop() >=
centeringRing.getAxialOffset(AxialMethod.TOP)) {
centeringRing.getAxialOffset(AxialMethod.TOP)) {
SortableRing adjacent = positionsFromTop.get(positionsFromTop.size() - 1);
adjacent.merge(centeringRing, relativeTo);
} else {
@ -423,8 +422,7 @@ public abstract class FinSetConfig extends RocketComponentConfig {
}
}
for (int i = 0; i < positionsFromTop.size(); i++) {
SortableRing sortableRing = positionsFromTop.get(i);
for (SortableRing sortableRing : positionsFromTop) {
if (top == null) {
top = sortableRing;
} else if (sortableRing.bottomSidePositionFromTop() <= finPositionFromTop) {

View File

@ -566,8 +566,7 @@ public class ThrustCurveMotorSelectionPanel extends JPanel implements MotorSelec
List<ThrustCurveMotor> motors = selectedMotorSet.getMotors();
if (hideSimilarBox.isSelected() && selectedMotor != null) {
List<ThrustCurveMotor> filtered = new ArrayList<>(motors.size());
for (int i = 0; i < motors.size(); i++) {
ThrustCurveMotor m = motors.get(i);
for (ThrustCurveMotor m : motors) {
if (m.equals(selectedMotor)) {
filtered.add(m);
continue;

View File

@ -42,9 +42,9 @@ public class XTableColumnModel extends DefaultTableColumnModel {
int noInvisibleColumns = allTableColumns.size();
int visibleIndex = 0;
for (int invisibleIndex = 0; invisibleIndex < noInvisibleColumns; ++invisibleIndex) {
for (TableColumn allTableColumn : allTableColumns) {
TableColumn visibleColumn = (visibleIndex < noVisibleColumns ? (TableColumn) tableColumns.get(visibleIndex) : null);
TableColumn testColumn = allTableColumns.get(invisibleIndex);
TableColumn testColumn = allTableColumn;
if (testColumn == 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
*/
public TableColumn getColumnByModelIndex(int modelColumnIndex) {
for (int columnIndex = 0; columnIndex < allTableColumns.size(); ++columnIndex) {
TableColumn column = allTableColumns.get(columnIndex);
for (TableColumn column : allTableColumns) {
if (column.getModelIndex() == modelColumnIndex) {
return column;
}

View File

@ -222,9 +222,9 @@ public abstract class RocketRenderer {
Coordinate[] position = ((RocketComponent) mount).toAbsolute(new Coordinate(((RocketComponent) mount)
.getLength() + mount.getMotorOverhang() - length));
for (int i = 0; i < position.length; i++) {
for (Coordinate coordinate : position) {
gl.glPushMatrix();
gl.glTranslated(position[i].x, position[i].y, position[i].z);
gl.glTranslated(coordinate.x, coordinate.y, coordinate.z);
renderMotor(gl, motor);
gl.glPopMatrix();
}

View File

@ -276,8 +276,8 @@ public class PhotoFrame extends JFrame {
@Override
public boolean isDataFlavorSupported(DataFlavor flavor) {
DataFlavor[] flavors = getTransferDataFlavors();
for (int i = 0; i < flavors.length; i++) {
if (flavor.equals(flavors[i])) {
for (DataFlavor dataFlavor : flavors) {
if (flavor.equals(dataFlavor)) {
return true;
}
}

View File

@ -564,10 +564,10 @@ public class PhotoPanel extends JPanel implements GLEventListener {
.toAbsolute(new Coordinate(((RocketComponent) mount)
.getLength() + mount.getMotorOverhang() - length));
for (int i = 0; i < position.length; i++) {
for (Coordinate coordinate : position) {
gl.glPushMatrix();
gl.glTranslated(position[i].x + motor.getLength(),
position[i].y, position[i].z);
gl.glTranslated(coordinate.x + motor.getLength(),
coordinate.y, coordinate.z);
FlameRenderer.drawExhaust(gl, p, motor);
gl.glPopMatrix();
}

View File

@ -277,9 +277,9 @@ public class ComponentAddButtons extends JPanel implements Scrollable {
Dimension d = viewport.getExtentSize();
for (int row = 0; row < buttons.length; row++) {
for (ComponentButton[] button : buttons) {
w = 0;
for (int col = 0; col < buttons[row].length; col++) {
for (int col = 0; col < button.length; col++) {
w += GAP + width;
String param = BUTTONPARAM + ",width " + width + "!,height " + height + "!";
@ -287,9 +287,9 @@ public class ComponentAddButtons extends JPanel implements Scrollable {
param = param + ",newline";
w = GAP + width;
}
if (col == buttons[row].length - 1)
if (col == button.length - 1)
param = param + ",wrap";
layout.setComponentConstraints(buttons[row][col], param);
layout.setComponentConstraints(button[col], param);
}
}
revalidate();
@ -408,8 +408,7 @@ public class ComponentAddButtons extends JPanel implements Scrollable {
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
Component[] c = getComponents();
for (int i = 0; i < c.length; i++)
c[i].setEnabled(enabled);
for (Component component : c) component.setEnabled(enabled);
}

View File

@ -114,8 +114,7 @@ public class ComponentTreeModel implements TreeModel, ComponentChangeListener {
// Send structure change event
TreeModelEvent e = new TreeModelEvent(this, path);
Object[] l = listeners.toArray();
for (int i = 0; i < l.length; i++)
((TreeModelListener) l[i]).treeStructureChanged(e);
for (Object o : l) ((TreeModelListener) o).treeStructureChanged(e);
// Re-expand the paths
for (UUID id : expanded) {

View File

@ -2293,8 +2293,7 @@ public class PresetEditorDialog extends JDialog implements ItemListener {
StringBuilder stringBuilder = new StringBuilder();
List<String> invalids = e.getErrors();
stringBuilder.append(baseMsg).append("\n");
for (int i = 0; i < invalids.size(); i++) {
String s = invalids.get(i);
for (String s : invalids) {
stringBuilder.append(s).append("\n");
}

View File

@ -577,8 +577,7 @@ public class DesignReport {
private FlightData findSimulation(final FlightConfigurationId motorId, List<Simulation> simulations) {
// Perform flight simulation
FlightData flight = null;
for (int i = 0; i < simulations.size(); i++) {
Simulation simulation = simulations.get(i);
for (Simulation simulation : simulations) {
if (Utils.equals(simulation.getId(), motorId)) {
flight = simulation.getSimulatedData();
break;

View File

@ -78,10 +78,10 @@ public class RocketPrintTree extends JTree {
}
List<OpenRocketPrintable> unstaged = OpenRocketPrintable.getUnstaged();
for (int i = 0; i < unstaged.size(); i++) {
toAddTo.add(new CheckBoxNode(unstaged.get(i).getDescription(),
INITIAL_CHECKBOX_SELECTED));
}
for (OpenRocketPrintable openRocketPrintable : unstaged) {
toAddTo.add(new CheckBoxNode(openRocketPrintable.getDescription(),
INITIAL_CHECKBOX_SELECTED));
}
RocketPrintTree tree = new RocketPrintTree(root);
@ -247,8 +247,8 @@ class NamedVector extends Vector<CheckBoxNode> {
public NamedVector(String theName, CheckBoxNode elements[]) {
name = theName;
for (int i = 0, n = elements.length; i < n; i++) {
add(elements[i]);
for (CheckBoxNode element : elements) {
add(element);
}
}

View File

@ -277,8 +277,8 @@ public class RocketFigure extends AbstractScaleFigure {
boolean selected = false;
// Check if component is in the selection
for (int j = 0; j < selection.length; j++) {
if (c == selection[j]) {
for (RocketComponent rocketComponent : selection) {
if (c == rocketComponent) {
selected = true;
break;
}

View File

@ -287,8 +287,8 @@ public class SimulationExportPanel extends JPanel {
int n = 0;
String str;
for (int i = 0; i < selected.length; i++) {
if (selected[i])
for (boolean b : selected) {
if (b)
n++;
}

View File

@ -40,13 +40,13 @@ public class SerializePresets extends BasicApplication {
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) {
throw new RuntimeException("Can't find " + args[i] + " directory");
throw new RuntimeException("Can't find " + arg + " directory");
}
while (iterator.hasNext()) {