Skip to content

Commit 371a475

Browse files
committed
-added documentation
1 parent 2b3c780 commit 371a475

File tree

6 files changed

+52
-11
lines changed

6 files changed

+52
-11
lines changed

.idea/dictionaries/Vladislav.xml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/java/stl/threebodysimulation/CanvasPanelFXMLController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ protected Void call() throws Exception {
536536
long leftoverTime = FRAMETIME - (System.currentTimeMillis() - taskTime);
537537
if (leftoverTime > 0) {
538538
// Wait until next frame.
539-
// TODO: This lags behind by around 1/30th of a second every loop, fix!
539+
540540
//noinspection BusyWait
541541
Thread.sleep(leftoverTime);
542542
}

src/main/java/stl/threebodysimulation/CanvasWrapper.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import javafx.scene.text.Font;
77
import javafx.scene.transform.Rotate;
88

9-
// TODO documentation
10-
119
/**
1210
* A wrapper that manages the graphics of a canvas UI object.
1311
*/
@@ -275,6 +273,7 @@ private void printHorizontalGridlines(double interval) {
275273
gridGC.setStroke(Color.DARKGRAY);
276274
}
277275

276+
// Draws the vertical gridlines on the canvas
278277
double relativeCurrentGridline = returnRelativePosition(new double[]{0, currentGridline})[1];
279278
gridGC.strokeLine(-20, relativeCurrentGridline, 850, relativeCurrentGridline);
280279
gridGC.fillText(String.format("%g", currentGridline), 10, relativeCurrentGridline - 10);
@@ -289,10 +288,13 @@ private void printHorizontalGridlines(double interval) {
289288
* @return The grid interval.
290289
*/
291290
private double calculateGridInterval() {
291+
292+
// Calculates the grid interval coefficient for determining the actual interval
292293
double rawGridInterval = 100 * particleScale;
293294
double base = Math.pow(10, Math.floor(Math.log10(rawGridInterval)));
294295
double coefficient = rawGridInterval / base;
295296

297+
// Determines the interval based on the coefficient
296298
if (coefficient <= 1.75) {
297299
return 1.0 * base;
298300
} else if (coefficient <= 4) {
@@ -438,7 +440,7 @@ void updateCanvas() {
438440
oldCanvasPos[i][0] = canvasPos[0];
439441
oldCanvasPos[i][1] = canvasPos[1];
440442

441-
// Conditionally draws the off-canvas position indicator TODO not displaying
443+
// Conditionally draws the off-canvas position indicator
442444
if ((canvasPos[0] < 0 || canvasPos[0] > 800) || (canvasPos[1] < 0 || canvasPos[1] > 720)) {
443445
double[] indicatorArgs = findIndicatorArguments(canvasPos);
444446
drawRotatedText(particlesGC, "^", indicatorArgs[0], indicatorArgs[1], indicatorArgs[2]);
@@ -492,9 +494,10 @@ void clearCanvas() {
492494
*/
493495
private double[] findIndicatorArguments(double[] canvasPos) {
494496

495-
final int OFFSET = 17; // Offset: artifically center indicators.
497+
final int OFFSET = 17; // Offset: artificially center indicators.
496498
final int LOCK = 25; // Prevents indicators from drifting past corners.
497499

500+
// Declares the cases for drawing the indicators.
498501
final double[] UPPER_LEFT = {315, 20, 50};
499502
final double[] UPPER_RIGHT = {45, 750, 20};
500503
final double[] LOWER_LEFT = {225, 50, 700};

src/main/java/stl/threebodysimulation/DefaultSavePreviewFXMLController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ void setSettings(SimulationSettings settings) {
140140
}
141141
});
142142

143-
// Everything has 2 decimal places. TODO: Make sure things fit!
143+
// Everything has 2 decimal places.
144144
timeskipLabel.setText(String.format("%.2f", settings.getSkip()));
145145
speedLabel.setText(String.format("%.2f", settings.getSpeed()));
146146
Particle[] particles = settings.getParticles();

src/main/java/stl/threebodysimulation/SavesPanelFXMLController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public void refreshSaves(String searchPrompt) {
162162
if (!(searchPrompt.equals("") || filename.toLowerCase().contains(searchPrompt.toLowerCase()))) {
163163
continue;
164164
}
165-
// TODO Documentation
165+
166166
// Reads a file and saves it as a node.
167167
ArrayList<String> serializedForm = new ArrayList<>();
168168

src/main/java/stl/threebodysimulation/UserManualFXMLController.java

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,40 @@
66
import javafx.scene.text.Font;
77
import javafx.scene.text.FontWeight;
88
import javafx.scene.text.Text;
9-
import javafx.scene.text.TextAlignment;
109
import javafx.scene.text.TextFlow;
1110

1211
import java.net.URL;
1312
import java.util.ResourceBundle;
1413

15-
// TODO documentation
16-
14+
/**
15+
* A controller for the user manual popup.
16+
*/
1717
public class UserManualFXMLController implements Initializable {
1818

19+
/**
20+
* The manual tab UI object in the user manual.
21+
*/
1922
@FXML
2023
TextFlow manualTextFlow;
2124

25+
/**
26+
* The credits tab UI object in the user manual.
27+
*/
2228
@FXML
2329
TextFlow creditsTextFlow;
2430

31+
/**
32+
* Constructor, for use by the FXML loader.
33+
*/
2534
public UserManualFXMLController() {
2635
}
2736

37+
/**
38+
* Method that generates formatted heading text.
39+
*
40+
* @param s String to be formatted.
41+
* @return Formatted string.
42+
*/
2843
private Text generateHeadingText(String s) {
2944
Text text = new Text();
3045
text.setFont(Font.font("System", FontWeight.BOLD, 20));
@@ -34,6 +49,12 @@ private Text generateHeadingText(String s) {
3449
return text;
3550
}
3651

52+
/**
53+
* Method that generates formatted body text.
54+
*
55+
* @param s String to be formatted.
56+
* @return Formatted string.
57+
*/
3758
private Text generateBodyText(String s) {
3859
Text text = new Text();
3960
text.setFont(Font.font("System", FontWeight.NORMAL, 16));
@@ -42,17 +63,28 @@ private Text generateBodyText(String s) {
4263
return text;
4364
}
4465

66+
/**
67+
* Method that generates a formatted line of space.
68+
*
69+
* @return Line of space.
70+
*/
4571
private Text generateSpace() {
4672
Text text = new Text();
4773
text.setFont(Font.font("System", 4));
4874
text.setText("\n");
4975
return text;
5076
}
5177

78+
/**
79+
* Main method for printing text on the user manual UI object.
80+
*
81+
* @param url Unused.
82+
* @param resourceBundle Unused.
83+
*/
5284
@Override
5385
public void initialize(URL url, ResourceBundle resourceBundle) {
54-
// Displays the text
5586

87+
// Displays the text
5688
Text[] manualTexts = new Text[] {
5789
generateHeadingText("HOW TO RUN A SIMULATION:\n"),
5890
generateSpace(),
@@ -97,6 +129,7 @@ public void initialize(URL url, ResourceBundle resourceBundle) {
97129
" - Ikonli for UI icons\n\n")
98130
};
99131

132+
// Outputs the text onto the each UI tab
100133
for (Text text : manualTexts) {
101134
manualTextFlow.getChildren().add(text);
102135
}

0 commit comments

Comments
 (0)