/*
 * File: Pyramid.java
 * Name: 
 * Section Leader: 
 * ------------------
 * This file is the starter file for the Pyramid problem.
 * It includes definitions of the constants that match the
 * sample run in the assignment, but you should make sure
 * that changing these values causes the generated display
 * to change accordingly.
 */

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.stage.Stage;

public class Pyramid extends Application {

/** Width of each brick in pixels */
	private static final int BRICK_WIDTH = 30;

/** Width of each brick in pixels */
	private static final int BRICK_HEIGHT = 12;

/** Number of bricks in the base of the pyramid */
	private static final int BRICKS_IN_BASE = 14;
	
	@Override
    public void start(Stage primaryStage) {
        Group root = new Group();
        Canvas canvas = new Canvas(calcCanvasWidth(), calcCanvasHeight());
        GraphicsContext gc = canvas.getGraphicsContext2D();
        
        drawPyramid(gc);
        
        root.getChildren().add(canvas);
        primaryStage.setScene(new Scene(root));
        primaryStage.show();
    }
	
	public static void main(String[] args) {
        launch(args);
    }
	
	private int calcCanvasHeight() {
		return (Double.valueOf(BRICKS_IN_BASE * BRICK_HEIGHT * 1.5)).intValue();
	}
	
	private int calcCanvasWidth() {
		return (Double.valueOf(BRICKS_IN_BASE * BRICK_WIDTH * 1.5)).intValue();
	}
	
	private void drawPyramid(GraphicsContext gc) {
		for (int i = 0; i < BRICKS_IN_BASE; i++) {
			drawRow(gc, i);
		}
	}
	
	private void drawRow(GraphicsContext gc, int row) {
		int bricksInRow = BRICKS_IN_BASE - row;
		int y = calcCanvasHeight() - BRICK_HEIGHT * (row + 1);
		
		for (int i = 0; i < bricksInRow; i++) {
			int x = (calcCanvasWidth() - BRICK_WIDTH * bricksInRow) / 2 + BRICK_WIDTH * i;
			
			drawBrick(gc, x, y);
		}
	}
	
	private void drawBrick(GraphicsContext gc, int x, int y) {
		gc.strokeRect(x, y, BRICK_WIDTH, BRICK_HEIGHT);
	}
}


@@ -1309,35 +1309,38 @@
    %7D%0A%09%0A%09private 
-int
+double
  calcCanvasHeigh
@@ -1354,32 +1354,16 @@
 %09return 
-(Double.valueOf(
 BRICKS_I
@@ -1385,37 +1385,24 @@
 HEIGHT * 1.5
-)).intValue()
 ;%0A%09%7D%0A%09%0A%09priv
@@ -1405,19 +1405,22 @@
 private 
-int
+double
  calcCan
@@ -1445,24 +1445,8 @@
 urn 
-(Double.valueOf(
 BRIC
@@ -1479,21 +1479,8 @@
  1.5
-)).intValue()
 ;%0A%09%7D
@@ -1700,19 +1700,22 @@
  row;%0A%09%09
-int
+double
  y = cal
@@ -1806,19 +1806,22 @@
 +) %7B%0A%09%09%09
-int
+double
  x = (ca
@@ -1973,18 +1973,24 @@
 gc, 
-int x, int
+double x, double
  y) 

Simplify by using double where possible