// Similar to the completeWall() method above except resizes wall instead public boolean completeRoof(float x, float y) { WallModel wall = isOnWall(x, y); if (currentRoof != null && tempRoof != null) { // Check if the mouse was on a wall when released if (wall != null) { // Check if the user drew a horizontal roof and mouse was released on a horizontal wall if (wall.getWidth() < wall.getHeight() && currentRoof.getOrientation() == 'h') { if (x > tempRoof.getStartPositionX()) { currentRoof.setWidth( (wall.getStartPositionX() + wall.getWidth() + currentRoof.getOverhang()) - currentRoof.getStartPositionX()); } else { float difference = currentRoof.getStartPositionX(); currentRoof.setStartPositionX(wall.getStartPositionX() - currentRoof.getOverhang()); difference -= currentRoof.getStartPositionX(); currentRoof.setWidth(currentRoof.getWidth() + difference); } } else { // else if the the user drew a vertical wall and released it on a horizontal wall // adjust the starting Y position and height if (y > tempRoof.getStartPositionY()) { currentRoof.setBreath( (wall.getStartPositionY() + wall.getHeight() + currentRoof.getOverhang()) - currentRoof.getStartPositionY()); } else { float difference = currentRoof.getStartPositionY(); currentRoof.setStartPositionY(wall.getStartPositionY() - currentRoof.getOverhang()); difference -= currentRoof.getStartPositionY(); currentRoof.setBreath(currentRoof.getBreath() + difference); } } currentRoof = null; tempRoof = null; // return true so that the geometry model can be updated in the WireFrameDisplay class return true; } } currentRoof = null; tempRoof = null; return false; }
// Manipulate the width and height of the roof public void drawRoof(float px, float py, float cx, float cy) { float startX, startY, width, breath; startX = startY = width = breath = 0; float x = cx - px; float y = cy - py; if (currentRoof != null) { if (currentRoof.getOrientation() == 'h') { if (x > 0) { // Adjust Width (Right) currentRoof.setStartPositionX(tempRoof.getStartPositionX()); width = (cx - px + (currentRoof.getOverhang() * 2)); } else { // Adjust Starting X (Left) currentRoof.setStartPositionY(tempRoof.getStartPositionY()); startX = (tempRoof.getStartPositionX() - px + cx + currentRoof.getOverhang()); currentRoof.setStartPositionX(startX); width = ((currentRoof.getOverhang() * 2) + px - cx); } currentRoof.setWidth(width); } else { if (y > 0) { // Adjust Height (Down) currentRoof.setStartPositionY(tempRoof.getStartPositionY()); breath = (cy - py + (currentRoof.getOverhang() * 2)); } else { // Adjust Starting Y (Up) currentRoof.setStartPositionX(tempRoof.getStartPositionX()); startY = (tempRoof.getStartPositionY() - py + cy + currentRoof.getOverhang()); currentRoof.setStartPositionY(startY); breath = ((currentRoof.getOverhang() * 2) + py - cy); } currentRoof.setBreath(breath); } } }