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,8 +36,8 @@ 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;

View File

@ -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);

View File

@ -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);

View File

@ -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.
} }

View File

@ -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);
} }

View File

@ -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

View File

@ -78,8 +78,7 @@ 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) {

View File

@ -94,8 +94,7 @@ 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);

View File

@ -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

View File

@ -76,8 +76,7 @@ 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) {

View File

@ -603,14 +603,14 @@ 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);
} }
} }

View File

@ -76,8 +76,7 @@ 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;
} }

View File

@ -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();
} }

View File

@ -98,8 +98,8 @@ 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;
} }

View File

@ -26,8 +26,7 @@ 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;
} }

View File

@ -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 += " ";

View File

@ -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);

View File

@ -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;
} }
} }

View File

@ -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.");

View File

@ -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:");

View File

@ -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);
} }
} }

View File

@ -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;
} }

View File

@ -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);
} }
} }

View File

@ -410,8 +410,7 @@ 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() >=
@ -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) {

View File

@ -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;

View File

@ -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;
} }

View File

@ -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();
} }

View File

@ -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;
} }
} }

View File

@ -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();
} }

View File

@ -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);
} }

View File

@ -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) {

View File

@ -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");
} }

View File

@ -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;

View File

@ -78,8 +78,8 @@ 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));
} }
@ -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);
} }
} }

View File

@ -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;
} }

View File

@ -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++;
} }

View File

@ -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()) {