在Netbeans中为JavaFX生成的Javadoc不完整

时间:2017-10-23 16:35:19

标签: java javafx javadoc fxml

我在NetBeans 8.2中有一个JavaFX应用程序,我想为其生成一个Javadoc。我评论了official Oracle site描述的每一种方法。当我继续生成Javadoc时,每个“普通”类都被完美地描述而没有任何错误,除了控制器类,它在启动时由FXML-File调用。

enter image description here

正如您所看到的,正在描述的唯一方法是initialize方法,即使我评论了类中的每个方法。

以下是未正确生成Javadoc的类:

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

0 个答案:

没有答案