Improved code readability
[sixth-3d.git] / src / main / java / eu / svjatoslav / sixth / e3d / gui / textEditorComponent / Page.java
index c52fbd7..0f60618 100644 (file)
@@ -7,8 +7,14 @@ package eu.svjatoslav.sixth.e3d.gui.textEditorComponent;
 import java.util.ArrayList;
 import java.util.List;
 
+/**
+ * A page in a text editor.
+ */
 public class Page {
 
+    /**
+     * The text lines.
+     */
     public List<TextLine> rows = new ArrayList<>();
 
     public void ensureMaxTextLine(final int row) {
@@ -16,28 +22,58 @@ public class Page {
             rows.add(new TextLine());
     }
 
+    /**
+     * Returns the character at the specified location.
+     * If the location is out of bounds, returns a space.
+     *
+     * @return The character at the specified location.
+     */
     public char getChar(final int row, final int column) {
         if (rows.size() <= row)
             return ' ';
         return rows.get(row).getCharForLocation(column);
     }
 
+    /**
+     * Returns the specified line.
+     *
+     * @param row
+     *            The line number.
+     * @return The line.
+     */
     public TextLine getLine(final int row) {
         ensureMaxTextLine(row);
         return rows.get(row);
     }
 
+    /**
+     * Returns the length of the specified line.
+     *
+     * @param row
+     *            The line number.
+     * @return The length of the line.
+     */
     public int getLineLength(final int row) {
         if (rows.size() <= row)
             return 0;
         return rows.get(row).getLength();
     }
 
+    /**
+     * Returns the number of lines in the page.
+     *
+     * @return The number of lines in the page.
+     */
     public int getLinesCount() {
         pack();
         return rows.size();
     }
 
+    /**
+     * Returns the text of the page.
+     *
+     * @return The text of the page.
+     */
     public String getText() {
         pack();
 
@@ -58,6 +94,9 @@ public class Page {
         rows.add(row, textLine);
     }
 
+    /**
+     * Removes empty lines from the end of the page.
+     */
     private void pack() {
         int newLength = 0;
 
@@ -73,12 +112,26 @@ public class Page {
         rows = rows.subList(0, newLength);
     }
 
+    /**
+     * Removes the specified character from the page.
+     *
+     * @param row
+     *            The line number.
+     * @param col
+     *            The character number.
+     */
     public void removeCharacter(final int row, final int col) {
         if (rows.size() <= row)
             return;
         getLine(row).removeCharacter(col);
     }
 
+    /**
+     * Removes the specified line from the page.
+     *
+     * @param row
+     *            The line number.
+     */
     public void removeLine(final int row) {
         if (rows.size() <= row)
             return;