Package com.eteks.sweethome3d.model

Examples of com.eteks.sweethome3d.model.Wall


public class HomeFileRecorderTest extends TestCase {
  public void testWriteReadHome() throws RecorderException {
    // 1. Create an empty home
    Home home1 = new Home();
    // Add to home a wall and a piece of furniture
    Wall wall = new Wall(0, 10, 100, 80, 10);
    home1.addWall(wall);
    FurnitureCatalog catalog = new DefaultFurnitureCatalog();
    HomePieceOfFurniture piece = new HomePieceOfFurniture(
        catalog.getCategories().get(0).getFurniture().get(0));
    home1.addPieceOfFurniture(piece);
View Full Code Here


          this.movedPieceOfFurniture.setDepth(this.depthMovedPieceOfFurniture);
        }
        this.movedPieceOfFurniture.setElevation(this.elevationMovedPieceOfFurniture);
        this.movedPieceOfFurniture.move(x - getXLastMousePress(), y - getYLastMousePress());
        if (this.magnetismEnabled) {
          Wall magnetWall = adjustPieceOfFurnitureOnWallAt(this.movedPieceOfFurniture, x, y);
          if (magnetWall != null) {
            getView().setDimensionLinesFeedback(
                getDimensionLinesAlongWall(this.movedPieceOfFurniture, magnetWall));
          } else {
            getView().setDimensionLinesFeedback(null);
View Full Code Here

          this.draggedPieceOfFurniture.setDepth(this.depthDraggedPieceOfFurniture);
        }
        this.draggedPieceOfFurniture.setElevation(this.elevationDraggedPieceOfFurniture);
        this.draggedPieceOfFurniture.move(x, y);

        Wall magnetWall = adjustPieceOfFurnitureOnWallAt(this.draggedPieceOfFurniture, x, y);
        if (magnetWall != null) {
          getView().setDimensionLinesFeedback(
              getDimensionLinesAlongWall(this.draggedPieceOfFurniture, magnetWall));
        } else {
          getView().setDimensionLinesFeedback(null);
View Full Code Here

    protected Integer getWallAngleInDegrees(Wall wall) {
      return getWallAngleInDegrees(wall, wall.getStartPointToEndPointDistance());
    }

    private Integer getWallAngleInDegrees(Wall wall, float startPointToEndPointDistance) {
      Wall wallAtStart = wall.getWallAtStart();
      if (wallAtStart != null) {
        float wallAtStartSegmentDistance = wallAtStart.getStartPointToEndPointDistance();
        if (startPointToEndPointDistance != 0 && wallAtStartSegmentDistance != 0) {
          // Compute the angle between the wall and its wall at start
          float xWallVector = (wall.getXEnd() - wall.getXStart()) / startPointToEndPointDistance;
          float yWallVector = (wall.getYEnd() - wall.getYStart()) / startPointToEndPointDistance;
          float xWallAtStartVector = (wallAtStart.getXEnd() - wallAtStart.getXStart()) / wallAtStartSegmentDistance;
          float yWallAtStartVector = (wallAtStart.getYEnd() - wallAtStart.getYStart()) / wallAtStartSegmentDistance;
          if (wallAtStart.getWallAtStart() == wall) {
            // Reverse wall at start direction
            xWallAtStartVector = -xWallAtStartVector;
            yWallAtStartVector = -yWallAtStartVector;
          }
          int wallAngle = (int)Math.round(180 - Math.toDegrees(Math.atan2(
View Full Code Here

        } else {
          getView().setAngleFeedback(wall.getXArcCircleCenter(), wall.getYArcCircleCenter(),
              wall.getXEnd(), wall.getYEnd(), wall.getXStart(), wall.getYStart());
        }
      } else {
        Wall wallAtStart = wall.getWallAtStart();
        if (wallAtStart != null) {
          if (wallAtStart.getWallAtStart() == wall) {
            if (getWallAngleInDegrees(wall) > 0) {
              getView().setAngleFeedback(wall.getXStart(), wall.getYStart(),
                  wallAtStart.getXEnd(), wallAtStart.getYEnd(), wall.getXEnd(), wall.getYEnd());
            } else {
              getView().setAngleFeedback(wall.getXStart(), wall.getYStart(),
                  wall.getXEnd(), wall.getYEnd(), wallAtStart.getXEnd(), wallAtStart.getYEnd());
            }
          } else {
            if (getWallAngleInDegrees(wall) > 0) {
              getView().setAngleFeedback(wall.getXStart(), wall.getYStart(),
                  wallAtStart.getXStart(), wallAtStart.getYStart(),
                  wall.getXEnd(), wall.getYEnd());
            } else {
              getView().setAngleFeedback(wall.getXStart(), wall.getYStart(),
                  wall.getXEnd(), wall.getYEnd(),
                  wallAtStart.getXStart(), wallAtStart.getYStart());
            }
          }
        }
      }
    }
View Full Code Here

         
          largerRoomPoints [i] = computeIntersection(point1, point2, point3, point4);
        }

        // Create walls joining points of largerRoomPoints
        Wall lastWall = null;
        for (int i = 0; i < largerRoomPoints.length; i++) {
          float [] point     = largerRoomPoints [i];
          float [] nextPoint = largerRoomPoints [(i + 1) % roomPoints.length];
          Wall wall = createWall(point [0], point [1], nextPoint [0], nextPoint [1], null, lastWall);
          this.newWalls.add(wall);
          lastWall = wall;
        }
        joinNewWallEndToWall(lastWall, this.newWalls.get(0), null);
      }     
View Full Code Here

        }
      }
    }

    private void createNextWall() {
      Wall previousWall = this.wallEndAtStart != null
          ? this.wallEndAtStart
          : this.wallStartAtStart;
      // Create a new wall with an angle equal to previous wall angle - 90�
      double previousWallAngle = Math.PI - Math.atan2(previousWall.getYStart() - previousWall.getYEnd(),
          previousWall.getXStart() - previousWall.getXEnd());
      previousWallAngle -=  Math.PI / 2;
      float previousWallSegmentDistance = previousWall.getStartPointToEndPointDistance();
      this.xLastEnd = (float)(this.xStart + previousWallSegmentDistance * Math.cos(previousWallAngle));
      this.yLastEnd = (float)(this.yStart - previousWallSegmentDistance * Math.sin(previousWallAngle));
      this.newWall = createWall(this.xStart, this.yStart,
          this.xLastEnd, this.yLastEnd, this.wallStartAtStart, previousWall);
      this.newWall.setThickness(previousWall.getThickness());         
      this.newWalls.add(this.newWall);
      this.lastWallCreationTime = System.currentTimeMillis();
      deselectAll();
    }
View Full Code Here

    this.home.addPieceOfFurniture(firstPiece);
    HomePieceOfFurniture secondPiece = new HomePieceOfFurniture(firstCategory.getFurniture().get(1));
    secondPiece.setAngle(15);
    this.home.addPieceOfFurniture(secondPiece);
    // Add a wall to home
    this.home.addWall(new Wall(0, 0, 100, 0, 7));
   
    PlanController planController = this.homeController.getPlanController();
    float scale = planController.getScale();
   
    // 1. Zoom in
View Full Code Here

    Home home = new Home();
    HomeController homeController =
        new HomeController(home, preferences, viewFactory);
   
    // 2. Add to home a wall and a piece of furniture
    home.addWall(new Wall(0, 0, 0, 1000, 10));
    HomePieceOfFurniture piece = new HomePieceOfFurniture(
        preferences.getFurnitureCatalog().getCategory(0).getPieceOfFurniture(0));
    home.addPieceOfFurniture(piece);
    piece.setX(500);
    piece.setY(500);
View Full Code Here

        }
      }
    });
   
    // Create 2 walls
    Wall wall1 = new Wall(0, 0, 100, 0, 0);
    Wall wall2 = new Wall(100, 0, 100, 100, 0);
    // Add them to home
    home.addWall(wall1);
    home.addWall(wall2);
    // Check they were added and that wall listener received a notification for each wall
    assertWallCollectionContains(home.getWalls(), wall1, wall2);
    assertWallCollectionContains(addedWalls, wall1, wall2);
   
    // Join end point of first wall to start point of second wall
    wall1.setWallAtEnd(wall2);
    // Check wall1 end wall is wall2 and that wall listener received 1 notification
    assertSame("Wall not joined", wall2, wall1.getWallAtEnd());
    assertWallCollectionContains(updatedWalls, wall1);

    // Join start point of second wall to end point of first wall
    updatedWalls.clear();
    wall2.setWallAtStart(wall1);
    // Check wall2 start wall is wall1 and that wall listener received 1 notification
    assertSame("Wall not joined", wall1, wall2.getWallAtStart());
    assertWallCollectionContains(updatedWalls, wall2);
   
    // Move end point of second wall
    updatedWalls.clear();
    wall2.setXEnd(60);
    wall2.setYEnd(100);
    // Check wall2 end position and that wall listener received 1 notifications
    assertEquals("Incorrect abscissa", 60f, wall2.getXEnd());
    assertEquals("Incorrect ordinate", 100f, wall2.getYEnd());
    assertWallCollectionContains(updatedWalls, wall2);

    // Move point shared by the two walls
    updatedWalls.clear();
    wall2.setXStart(60);
    wall2.setYStart(0);
    // Check wall2 start point position
    assertEquals("Incorrect abscissa", 60f, wall2.getXStart());
    assertEquals("Incorrect ordinate", 0f, wall2.getYStart());
    // Check that wall listener received 2 notifications
    assertWallCollectionContains(updatedWalls, wall2);

    updatedWalls.clear();
    wall1.setXEnd(60);
    wall1.setYEnd(0);
    // Check wall1 end point position
    assertEquals("Incorrect abscissa", 60f, wall1.getXEnd());
    assertEquals("Incorrect ordinate", 0f, wall1.getYEnd());
    // Check that wall listener received 2 notifications
    assertWallCollectionContains(updatedWalls, wall1);
   
    // Detach second wall from first wall
    updatedWalls.clear();
    wall2.setWallAtStart(null);
    // Check wall2 and wall1 are not joined and that wall listener received 2 notifications
    assertSame("Wall joined", null, wall1.getWallAtEnd());
    assertSame("Wall joined", null, wall2.getWallAtStart());
    assertWallCollectionContains(updatedWalls, wall1, wall2);
   
    // Delete second wall
    home.deleteWall(wall2);
    // Check it was removed and that wall listener received a notification
View Full Code Here

TOP

Related Classes of com.eteks.sweethome3d.model.Wall

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.