Re: Room size in java code

by anandunadkat » Fri Jan 18, 2013 9:31 am

Thank you so much for you help. I really do appreciate it. I will just paste a screenshot so you know what i am trying to get here.

User clicks on the option
Image

WIndow will pop up asking for measurements
Image

Image

And then a template will come up.
Image

as you can see from the screenshot, that it allows you to add railings as well. I have created a new object but it will not show up. below is code for one of them.

Code: Select all

	public static void addRightAngleRail(Home home,
			UserPreferences preferences, Float houseLength, Float houseBreadth) {
		HomePieceOfFurniture furniture;
		furniture =createFurniture(preferences,7 , 2, houseLength,houseBreadth-100);
		furniture.setColor(-255);
		furniture.setAngle(1.57f);
		home.addPieceOfFurniture(furniture);
	}
code for adding a room according to the measurements is here

Code: Select all

public class ExecuteCommand {
	
	public static void drawHouse(Home home, UserPreferences preferences, float houseLength, float houseBreadth){

		float xRef = 10;
		float yRef = 10;
		float wallThickness = 10;
		
		float wall_1_X1Start = xRef;
		float wall_1_Y1Start = yRef;
		float wall_1_X2End = xRef + houseLength;
		float wall_1_Y2End = yRef;
		
		float wall_2_X1Start = xRef + houseLength;
		float wall_2_Y1Start = yRef;
		float wall_2_X2End = xRef + houseLength;
		float wall_2_Y2End = yRef + houseBreadth;
		
		float wall_3_X1Start = xRef + houseLength;
		float wall_3_Y1Start = yRef + houseBreadth;
		float wall_3_X2End = xRef;
		float wall_3_Y2End = yRef + houseBreadth;
		
		float wall_4_X1Start = xRef;
		float wall_4_Y1Start = yRef + houseBreadth;
		float wall_4_X2End = xRef;
		float wall_4_Y2End = yRef;
		
		Wall wall_1 = new Wall(wall_1_X1Start, wall_1_Y1Start, wall_1_X2End, wall_1_Y2End,wallThickness);
		Wall wall_2 = new Wall(wall_2_X1Start, wall_2_Y1Start, wall_2_X2End, wall_2_Y2End,wallThickness);
		Wall wall_3 = new Wall(wall_3_X1Start, wall_3_Y1Start, wall_3_X2End, wall_3_Y2End,wallThickness);
		Wall wall_4 = new Wall(wall_4_X1Start, wall_4_Y1Start, wall_4_X2End, wall_4_Y2End,wallThickness); 
		
		//TextureImage firstTexture = preferences.getTexturesCatalog().getCategories().get(2).getTexture(6);
		TextureImage firstTexture = getdefaultHouseWallTexture(preferences);
		
		wall_1.setLeftSideTexture(new HomeTexture(firstTexture));
		wall_2.setLeftSideTexture(new HomeTexture(firstTexture));
		wall_3.setLeftSideTexture(new HomeTexture(firstTexture));
		wall_4.setLeftSideTexture(new HomeTexture(firstTexture));
	
		home.addWall(wall_1);
		home.addWall(wall_2);
		home.addWall(wall_3);
		home.addWall(wall_4);
So now i want to add a new furniture library so users can access those furniture without importing. And i want to arrange those object properly as you can see that they are not. Please help!!!