0

I have a JavaFX application in NetBeans 8.2 for which I want to generate a Javadoc. I commented every single method like described by the official Oracle site. When I then proceed to generating the Javadoc every "normal" class is described perfectly without any errors, except the controller class, which is invoked by the FXML-File on startup.

enter image description here

As you can see, the only method being described is the initialize method, even though I commented every method in the class.

Here is the class whose Javadoc isn't generated properly:

/**
 * This is the controller class of the application.
 * 
 * @author Equiphract
 */
public class Percolation implements Initializable {
    //This is the canvas where all the stuff is drawn.
    @FXML
    private Canvas canvas;


    //GraphicsContext used for drawing.
    private GraphicsContext gc;
    //Grid object which holds grid data.
    private Grid grid;
    //gridSize defines the amount of nodes in the grid (gridSize*gridSize).
    private int gridSize;
    //canvasWidth defines the width of the canvas, which must be the same as defined in GUI_FXML.fxml.
    private double canvasWidth;
    //canvasHeight defines the height of the canvas, which must be the same as defined in GUI_FXML.fxml.
    private double canvasHeight;
    //horizontalStep is the result of canvasWidth/gridSize; this length is used to draw the grid lines and adjust the size of the circles
    private double horizontalStep;
    //verticalStep is the result of canvasHeight/gridSize; this length is used to draw the grid lines and adjust the size of the circles
    private double verticalStep;

    /**
     * Initialises all class variables.
     * The Parameter gridSize must at least hold the value 1; If its value is lower it will be set to 1.
     * 
     * @param gridSize defines the amount of nodes in the grid (gridSize*gridSize)
     */
    private void initialiseVariables(int gridSize){
        this.gc = canvas.getGraphicsContext2D();
        if(gridSize <= 0){
            this.gridSize = 1;
        }else{
            this.gridSize = gridSize;
        }
        this.grid = new Grid(this.gridSize, GridType.SQUARE);
        this.canvasWidth = canvas.getWidth();
        this.canvasHeight = canvas.getHeight();
        this.horizontalStep = this.canvasWidth/this.gridSize;
        this.verticalStep = this.canvasHeight/this.gridSize;
    }

    /**
     * Creates the grid based on the class variable gridSize.
     */
    private void setup(){
        for(int y = 0; y < this.gridSize; y++){
            for(int x = 0; x < this.gridSize; x++){
                this.grid.getNodeArray()[y][x] = new Node(x, y);
            }
        }
    }

    /**
     * Iterates over every node in the grid and decides by a certain chance if the node should be set.
     * 
     * @param chance chance by which a node will be set (float between 0 and 1)
     * @param grid the grid
     */
    private void setRandomNode(float chance, Node[][] grid){
        Random r = new Random();

        float random;
        int counter = 0;
        for (Node[] nodes : grid) {
            for (Node node : nodes) {
                random = r.nextFloat();
                if(random <= chance){
                    node.setSet(true);
                }
                System.out.println("Random: " + random + " | Node: (" + node.getX() + "|" + node.getY() + ") | isSet: " + node.isSet());
                counter++;
            }
        }
        System.out.println("Count: " + counter);
    }

    /**
     * Draws the grid on the canvas.
     */
    private void drawGrid(){   
        for(int i = 0; i < this.gridSize + 1; i++){
            this.gc.strokeLine(0, 0 + this.verticalStep*i, this.canvasWidth, 0 + this.verticalStep*i);
        }
        for(int i = 0; i < this.gridSize + 1; i++){
            this.gc.strokeLine(0 + this.horizontalStep*i, this.canvasHeight, 0 + this.horizontalStep*i, 0);
        }
    }

    /**
     * Iterates over every node in the grid and draws a circle at its respective position in the grid if the node is set.
     * 
     * @param grid the grid
     */
    private void fillGrid(Node[][] grid){
        double diameter = ((this.horizontalStep + this.verticalStep)/2)*0.5;
        for (Node[] nodes : grid) {
            for (Node node : nodes) {
                if(node.isSet()){
                    drawCircle((this.horizontalStep/2) + node.getX()*this.horizontalStep, (this.verticalStep/2) + node.getY()*this.verticalStep, diameter, diameter);
                }
            }
        }
    }

    /**
     * Draws a circle on the canvas.
     * 
     * @param x x position
     * @param y y position
     * @param width width of the circle
     * @param height height of the circle
     */
    private void drawCircle(double x, double y, double width, double height){
        this.gc.fillOval(x - width/2, y - height/2, width, height);
    }

    @Override
    public void initialize(URL url, ResourceBundle rb) {
        initialiseVariables(10);
        setup();
        drawGrid();
        setRandomNode(0.592746f, this.grid.getNodeArray());
        fillGrid(this.grid.getNodeArray());
    }    
}
Wilson Vargas
  • 2,841
  • 1
  • 19
  • 28
Equiphract
  • 107
  • 1
  • 11
  • 2
    The `initialize()` method is the only non-private method in the class. Private methods are not part of the API, so are not documented by default. – James_D Oct 23 '17 at 16:38
  • If you want to include private methods in the Javadocs (though it is not clear why you would do so), in Netbeans open the properties dialog for your project; under "Build" choose "Documenting", and check the "Include Private and Package Private Members". – James_D Oct 23 '17 at 16:50
  • My god I didn't even think of the access modifiers... it's so obvious now that you pointed it out :D thanks – Equiphract Oct 23 '17 at 17:10

0 Answers0