Examples of Wall


Examples of com.eteks.sweethome3d.model.Wall

   * Attempts to move and resize <code>piece</code> depending on the wall under the
   * point (<code>x</code>, <code>y</code>) and returns that wall it it exists.
   * @see #adjustMagnetizedPieceOfFurniture(HomePieceOfFurniture, float, float)
   */
  private Wall adjustPieceOfFurnitureOnWallAt(HomePieceOfFurniture piece, float x, float y) {
    Wall wallAtPoint = null;
    // Search if point (x, y) is contained in home walls with no margin
    for (Wall wall : this.home.getWalls()) {
      if (wall.getArcExtent() == null
          && wall.containsPoint(x, y, 0)
          && wall.getStartPointToEndPointDistance() > 0) {
        wallAtPoint = wall;
        break;
      }
    }
    if (wallAtPoint == null) {
      float margin = PIXEL_MARGIN / getScale();
      // If not found search if point (x, y) is contained in home walls with a margin
      for (Wall wall : this.home.getWalls()) {
        if (wall.getArcExtent() == null
            && wall.containsPoint(x, y, margin)
            && wall.getStartPointToEndPointDistance() > 0) {
          wallAtPoint = wall;
          break;
        }
      }
    }

    if (wallAtPoint != null) {     
      double wallAngle = Math.atan2(wallAtPoint.getYEnd() - wallAtPoint.getYStart(),
          wallAtPoint.getXEnd() - wallAtPoint.getXStart());
      boolean magnetizedAtRight = wallAngle > -Math.PI / 2 && wallAngle <= Math.PI / 2;
      double cosAngle = Math.cos(wallAngle);
      double sinAngle = Math.sin(wallAngle);
      float [][] wallPoints = wallAtPoint.getPoints();
      double distanceToLeftSide = Line2D.ptLineDist(
          wallPoints [0][0], wallPoints [0][1], wallPoints [1][0], wallPoints [1][1], x, y);
      double distanceToRightSide = Line2D.ptLineDist(
          wallPoints [2][0], wallPoints [2][1], wallPoints [3][0], wallPoints [3][1], x, y);
     
      float [][] piecePoints = piece.getPoints();
      float pieceAngle = piece.getAngle();
      double distanceToPieceLeftSide = Line2D.ptLineDist(
          piecePoints [0][0], piecePoints [0][1], piecePoints [3][0], piecePoints [3][1], x, y);
      double distanceToPieceRightSide = Line2D.ptLineDist(
          piecePoints [1][0], piecePoints [1][1], piecePoints [2][0], piecePoints [2][1], x, y);
      double distanceToPieceSide = pieceAngle > (3 * Math.PI / 2 + 1E-6) || pieceAngle < (Math.PI / 2 + 1E-6)
          ? distanceToPieceLeftSide
          : distanceToPieceRightSide;
     
      double angle;
      double xPiece;
      double yPiece;
      float halfWidth = piece.getWidth() / 2;
      final float thicknessEpsilon = 0.0002f;
      if (piece.isDoorOrWindow()) {
        float wallDistance = thicknessEpsilon / 2;
        if (piece instanceof HomeDoorOrWindow) {
          HomeDoorOrWindow doorOrWindow = (HomeDoorOrWindow) piece;
          if (piece.isResizable()
              && isItemResizable(piece)) {
            piece.setDepth(thicknessEpsilon
                + wallAtPoint.getThickness() / doorOrWindow.getWallThickness());
          }
          wallDistance += piece.getDepth() * doorOrWindow.getWallDistance();          
        }
        float halfDepth = piece.getDepth() / 2;
        if (distanceToRightSide < distanceToLeftSide) {
View Full Code Here

Examples of com.eteks.sweethome3d.model.Wall

  protected Wall createWall(float xStart, float yStart,
                            float xEnd, float yEnd,
                            Wall wallStartAtStart,
                            Wall wallEndAtStart) {
    // Create a new wall
    Wall newWall = new Wall(xStart, yStart, xEnd, yEnd,
        this.preferences.getNewWallThickness(),
        this.preferences.getNewWallHeight());
    this.home.addWall(newWall);
    if (wallStartAtStart != null) {
      newWall.setWallAtStart(wallStartAtStart);
      wallStartAtStart.setWallAtStart(newWall);
    } else if (wallEndAtStart != null) {
      newWall.setWallAtStart(wallEndAtStart);
      wallEndAtStart.setWallAtEnd(newWall);
    }       
    return newWall;
  }
View Full Code Here

Examples of com.eteks.sweethome3d.model.Wall

  private Wall getResizedWallStartAt(float x, float y) {
    List<Selectable> selectedItems = this.home.getSelectedItems();
    if (selectedItems.size() == 1
        && selectedItems.get(0) instanceof Wall
        && isItemResizable(selectedItems.get(0))) {
      Wall wall = (Wall)selectedItems.get(0);
      float margin = PIXEL_MARGIN / getScale();
      if (wall.containsWallStartAt(x, y, margin)) {
        return wall;
      }
    }
    return null;
  }
View Full Code Here

Examples of com.eteks.sweethome3d.model.Wall

  private Wall getResizedWallEndAt(float x, float y) {
    List<Selectable> selectedItems = this.home.getSelectedItems();
    if (selectedItems.size() == 1
        && selectedItems.get(0) instanceof Wall
        && isItemResizable(selectedItems.get(0))) {
      Wall wall = (Wall)selectedItems.get(0);
      float margin = PIXEL_MARGIN / getScale();
      if (wall.containsWallEndAt(x, y, margin)) {
        return wall;
      }
    }
    return null;
  }
View Full Code Here

Examples of com.eteks.sweethome3d.model.Wall

   * Moves <code>items</code> of (<code>dx</code>, <code>dy</code>) units.
   */
  public void moveItems(List<? extends Selectable> items, float dx, float dy) {
    for (Selectable item : items) {
      if (item instanceof Wall) {
        Wall wall = (Wall)item;
        moveWallStartPoint(wall,
            wall.getXStart() + dx, wall.getYStart() + dy,
            !items.contains(wall.getWallAtStart()));
        moveWallEndPoint(wall,
            wall.getXEnd() + dx, wall.getYEnd() + dy,
            !items.contains(wall.getWallAtEnd()));
      } else {
        item.move(dx, dy);
      }
    }
  }
View Full Code Here

Examples of com.eteks.sweethome3d.model.Wall

                                  boolean moveWallAtStart) {   
    float oldXStart = wall.getXStart();
    float oldYStart = wall.getYStart();
    wall.setXStart(xStart);
    wall.setYStart(yStart);
    Wall wallAtStart = wall.getWallAtStart();
    // If wall is joined to a wall at its start
    // and this wall doesn't belong to the list of moved walls
    if (wallAtStart != null && moveWallAtStart) {
      // Move the wall start point or end point
      if (wallAtStart.getWallAtStart() == wall
          && (wallAtStart.getWallAtEnd() != wall
              || (wallAtStart.getXStart() == oldXStart
                  && wallAtStart.getYStart() == oldYStart))) {
        wallAtStart.setXStart(xStart);
        wallAtStart.setYStart(yStart);
      } else if (wallAtStart.getWallAtEnd() == wall
                 && (wallAtStart.getWallAtStart() != wall
                     || (wallAtStart.getXEnd() == oldXStart
                         && wallAtStart.getYEnd() == oldYStart))) {
        wallAtStart.setXEnd(xStart);
        wallAtStart.setYEnd(yStart);
      }
    }
  }
View Full Code Here

Examples of com.eteks.sweethome3d.model.Wall

                                boolean moveWallAtEnd) {
    float oldXEnd = wall.getXEnd();
    float oldYEnd = wall.getYEnd();
    wall.setXEnd(xEnd);
    wall.setYEnd(yEnd);
    Wall wallAtEnd = wall.getWallAtEnd();
    // If wall is joined to a wall at its end 
    // and this wall doesn't belong to the list of moved walls
    if (wallAtEnd != null && moveWallAtEnd) {
      // Move the wall start point or end point
      if (wallAtEnd.getWallAtStart() == wall
          && (wallAtEnd.getWallAtEnd() != wall
              || (wallAtEnd.getXStart() == oldXEnd
                  && wallAtEnd.getYStart() == oldYEnd))) {
        wallAtEnd.setXStart(xEnd);
        wallAtEnd.setYStart(yEnd);
      } else if (wallAtEnd.getWallAtEnd() == wall
                 && (wallAtEnd.getWallAtStart() != wall
                     || (wallAtEnd.getXEnd() == oldXEnd
                         && wallAtEnd.getYEnd() == oldYEnd))) {
        wallAtEnd.setXEnd(xEnd);
        wallAtEnd.setYEnd(yEnd);
      }
    }
  }
View Full Code Here

Examples of com.eteks.sweethome3d.model.Wall

   * them to other walls if necessary.
   */
  private void doAddWalls(JoinedWall [] joinedWalls, boolean basePlanLocked) {
    // First add all walls to home
    for (JoinedWall joinedNewWall : joinedWalls) {
      Wall wall = joinedNewWall.getWall();
      this.home.addWall(wall);
    }
    this.home.setBasePlanLocked(basePlanLocked);
   
    // Then join them to each other if necessary
    for (JoinedWall joinedNewWall : joinedWalls) {
      Wall wall = joinedNewWall.getWall();
      Wall wallAtStart = joinedNewWall.getWallAtStart();
      if (wallAtStart != null) {
        wall.setWallAtStart(wallAtStart);
        if (joinedNewWall.isJoinedAtEndOfWallAtStart()) {
          wallAtStart.setWallAtEnd(wall);
        } else if (joinedNewWall.isJoinedAtStartOfWallAtStart()) {
          wallAtStart.setWallAtStart(wall);
        }
      }
      Wall wallAtEnd = joinedNewWall.getWallAtEnd();
      if (wallAtEnd != null) {
        wall.setWallAtEnd(wallAtEnd);
        if (joinedNewWall.isJoinedAtStartOfWallAtEnd()) {
          wallAtEnd.setWallAtStart(wall);
        } else if (joinedNewWall.isJoinedAtEndOfWallAtEnd()) {
          wallAtEnd.setWallAtEnd(wall);
        }
      }
    }     
  }
View Full Code Here

Examples of com.eteks.sweethome3d.model.Wall

    tester.actionClick(planComponent, 30, 30);
    tester.actionClick(planComponent, 270, 31);
    tester.actionClick(planComponent, 269, 170);
    tester.actionClick(planComponent, 30, 171, InputEvent.BUTTON1_MASK, 2);
    // Check 3 walls were created at (20, 20), (500, 20), (500, 300) and (20, 300) coordinates
    Wall wall1 = orderedWalls.get(0);
    assertCoordinatesEqualWallPoints(20, 20, 500, 20, wall1);
    Wall wall2 = orderedWalls.get(1);
    assertCoordinatesEqualWallPoints(500, 20, 500, 300, wall2);
    Wall wall3 = orderedWalls.get(2);
    assertCoordinatesEqualWallPoints(500, 300, 20, 300, wall3);
    // Check the thickness and the height of first wall
    assertEquals("Wrong wall tickness", frame.preferences.getNewWallThickness(), wall1.getThickness());
    assertEquals("Wrong wall height", frame.preferences.getNewWallHeight(), wall1.getHeight());
    assertEquals("Wrong wall height at end", null, wall1.getHeightAtEnd());
    // Check they are joined to each other end point
    assertWallsAreJoined(null, wall1, wall2);
    assertWallsAreJoined(wall1, wall2, wall3);
    assertWallsAreJoined(wall2, wall3, null);
    // Check they are selected
    assertSelectionContains(frame.home, wall1, wall2, wall3);

    // 3. Click at (30, 170), then double click at (50, 50) with Shift key depressed
    tester.actionClick(planComponent, 30, 170);
    tester.actionKeyPress(KeyEvent.VK_SHIFT);
    tester.actionClick(planComponent, 50, 50, InputEvent.BUTTON1_MASK, 2);
    tester.actionKeyRelease(KeyEvent.VK_SHIFT);
    // Check a forth wall was created at (20, 300), (60, 60) coordinates
    Wall wall4 = orderedWalls.get(orderedWalls.size() - 1);
    assertCoordinatesEqualWallPoints(20, 300, 60, 60, wall4);
    assertSelectionContains(frame.home, wall4);
    assertWallsAreJoined(wall3, wall4, null);
   
    // 4. Use SELECTION mode
    tester.click(frame.modeButton);
    // Check current mode is SELECTION
    assertEquals("Current mode isn't " + PlanController.Mode.SELECTION,
        PlanController.Mode.SELECTION, frame.planController.getMode());
    // Give focus to plan component
    tester.actionFocus(planComponent);
    // Press the delete key
    tester.actionKeyStroke(KeyEvent.VK_DELETE);
    // Check plan contains only the first three walls
    assertHomeContains(frame.home, wall1, wall2, wall3);
   
    // 5. Use WALL_CREATION mode
    tester.click(frame.modeButton);  
    //  Click at (31, 29), then double click at (30, 170)
    tester.actionClick(planComponent, 31, 29);
    tester.actionClick(planComponent, 30, 170, InputEvent.BUTTON1_MASK, 2);
    // Check a new forth wall was created at (20, 20), (20, 300) coordinates
    wall4 = orderedWalls.get(orderedWalls.size() - 1);
    assertCoordinatesEqualWallPoints(20, 20, 20, 300, wall4);
    // Check its end points are joined to the first and third wall
    assertWallsAreJoined(wall1, wall4, wall3);
   
    // 6. Use SELECTION mode
    tester.click(frame.modeButton);
    // Drag and drop cursor from (200, 100) to (300, 180)
    tester.actionMousePress(planComponent,
        new ComponentLocation(new Point(200, 100)));
    tester.actionMouseMove(planComponent,
        new ComponentLocation(new Point(300, 180)));
    tester.actionMouseRelease();
    // Check the selected walls are the second and third ones
    assertSelectionContains(frame.home, wall2, wall3);

    // 7. Press twice right arrow key    
    tester.actionKeyStroke(KeyEvent.VK_RIGHT);
    tester.actionKeyStroke(KeyEvent.VK_RIGHT);
    // Check the 4 walls coordinates are (20, 20), (504, 20), (504, 300), (24, 300)
    assertCoordinatesEqualWallPoints(20, 20, 504, 20, wall1);
    assertCoordinatesEqualWallPoints(504, 20, 504, 300, wall2);
    assertCoordinatesEqualWallPoints(504, 300, 24, 300, wall3);
    assertCoordinatesEqualWallPoints(20, 20, 24, 300, wall4);

    // 8. Click at (272, 40) with Shift key depressed
    tester.actionKeyPress(KeyEvent.VK_SHIFT);
    tester.actionClick(planComponent, 272, 40);
    tester.actionKeyRelease(KeyEvent.VK_SHIFT);
    // Check the second wall was removed from selection
    assertSelectionContains(frame.home, wall3);

     // 9. Drag cursor from (50, 30) to (50, 50)
    tester.actionMousePress(planComponent,
        new ComponentLocation(new Point(50, 30)));
    tester.actionMouseMove(planComponent,
        new ComponentLocation(new Point(50, 50)));
    // Check first wall is selected and that it moved
    assertSelectionContains(frame.home, wall1);
    assertCoordinatesEqualWallPoints(20, 60, 504, 60, wall1);
    // Lose focus
    tester.actionKeyStroke(KeyEvent.VK_TAB);
    // Check the wall didn't move at end
    assertCoordinatesEqualWallPoints(20, 20, 504, 20, wall1);

    // 10. Click 6 times on undo button
    for (int i = 0; i < 6; i++) {
      tester.invokeAndWait(new Runnable() {
          public void run() {
            frame.undoButton.doClick();
          }
        });
    }
    // Check home doesn't contain any wall
    assertHomeContains(frame.home);
   
    // 11. Click 6 times on redo button
    for (int i = 0; i < 6; i++) {
      tester.invokeAndWait(new Runnable() {
          public void run() {
            frame.redoButton.doClick();
          }
        });
    }
    // Check plan contains the four wall
    assertHomeContains(frame.home, wall1, wall2, wall3, wall4);
    //  Check they are joined to each other end point
    assertWallsAreJoined(wall4, wall1, wall2);
    assertWallsAreJoined(wall1, wall2, wall3);
    assertWallsAreJoined(wall2, wall3, wall4);
    assertWallsAreJoined(wall1, wall4, wall3);
    // Check the second and the third wall are selected
    assertSelectionContains(frame.home, wall2, wall3);
   
    // 12. Reverse directions of selected walls
    float xStartWall2 = wall2.getXStart();
    float yStartWall2 = wall2.getYStart();
    float xStartWall3 = wall3.getXStart();
    float yStartWall3 = wall3.getYStart();
    float xEndWall3 = wall3.getXEnd();
    float yEndWall3 = wall3.getYEnd();
    tester.invokeAndWait(new Runnable() {
        public void run() {
          frame.reverseDirectionButton.doClick();
        }
      });
    // Check the second and the third wall are still selected
    assertSelectionContains(frame.home, wall2, wall3);
    // Check wall2 and wall3 were reserved
    assertCoordinatesEqualWallPoints(xStartWall3, yStartWall3, xStartWall2, yStartWall2, wall2);
    assertCoordinatesEqualWallPoints(xEndWall3, yEndWall3, xStartWall3, yStartWall3, wall3);
    assertWallsAreJoined(wall3, wall2, wall1);
    assertWallsAreJoined(wall4, wall3, wall2);
   
    // 13. Select first wall
    tester.actionClick(planComponent, 100, 100); // Give focus first
    tester.actionClick(planComponent, 40, 30);
    // Drag cursor from (30, 30) to (50, 50) with shift key pressed
    tester.actionMousePress(planComponent,
        new ComponentLocation(new Point(30, 30)));
    tester.actionMouseMove(planComponent,
        new ComponentLocation(new Point(50, 50)));
    tester.actionKeyPress(KeyEvent.VK_SHIFT);
    tester.waitForIdle();
    tester.actionMouseRelease();
    tester.actionKeyRelease(KeyEvent.VK_SHIFT);
    // Check wall start point moved to (60, 60)
    assertCoordinatesEqualWallPoints(60, 60, 504, 20, wall1);
    assertCoordinatesEqualWallPoints(60, 60, 24, 300, wall4);
   
    // 14. Select first wall
    tester.actionClick(planComponent, 60, 50);
    assertSelectionContains(frame.home, wall1);
    // Split first wall in two walls
    tester.click(frame.splitButton);
    Wall wall5 = orderedWalls.get(orderedWalls.size() - 2);
    Wall wall6 = orderedWalls.get(orderedWalls.size() - 1);
    assertSelectionContains(frame.home, wall5);
    assertCoordinatesEqualWallPoints(60, 60, 282, 40, wall5);
    assertCoordinatesEqualWallPoints(282, 40, 504, 20, wall6);
    assertWallsAreJoined(wall4, wall5, wall6);
    assertWallsAreJoined(wall5, wall6, wall2);
View Full Code Here

Examples of com.eteks.sweethome3d.model.Wall

    tester.actionKeyString("5 ");
    tester.actionKeyStroke(KeyEvent.VK_ENTER);
    tester.actionKeyStroke(KeyEvent.VK_ESCAPE);
    // Check created walls
    assertEquals("Wrong walls count", 3, frame.home.getWalls().size());
    Wall wall1 = orderedWalls.get(0);
    assertCoordinatesEqualWallPoints(10, 21, 210, 21, wall1);
    Wall wall2 = orderedWalls.get(1);
    assertCoordinatesEqualWallPoints(210, 21, 210, 221, wall2);
    assertEquals("Wrong wall thickness", wall1.getThickness(), wall2.getThickness());
    Wall wall3 = orderedWalls.get(2);
    assertCoordinatesEqualWallPoints(210, 221, 410, 221, wall3);
    assertEquals("Wrong wall thickness",
        Float.parseFloat(String.valueOf(wall1.getThickness()) + "5"), wall3.getThickness());
    assertWallsAreJoined(wall1, wall2, wall3);
    assertSelectionContains(frame.home, wall1, wall2, wall3);
   
    // 3. Mix mouse and keyboard to create other walls
    tester.actionClick(planComponent, 300, 200);
    tester.actionMouseMove(planComponent,
        new ComponentLocation(new Point(310, 200)));
    tester.actionKeyStroke(KeyEvent.VK_ENTER);
    // Enter the length and the angle of the wall
    tester.actionKeyString("100");
    tester.actionKeyStroke(KeyEvent.VK_TAB);
    tester.actionKeyString("315");
    tester.actionKeyStroke(KeyEvent.VK_ENTER);
    // Create 3 walls with same length
    Thread.sleep(500);
    tester.actionKeyStroke(KeyEvent.VK_ENTER);
    Thread.sleep(500);
    tester.actionKeyStroke(KeyEvent.VK_ENTER);
    // Take control with mouse
    tester.actionMouseMove(planComponent,
        new ComponentLocation(new Point(200, 200)));
    tester.actionKeyPress(KeyEvent.VK_SHIFT);
    Wall wall7 = orderedWalls.get(7);
    assertCoordinatesEqualWallPoints(wall7.getXStart(), wall7.getYStart(),
        planComponent.convertXPixelToModel(200),
        planComponent.convertYPixelToModel(200), wall7);
    tester.waitForIdle();
    tester.actionKeyRelease(KeyEvent.VK_SHIFT);
    // Take control again with keyboard and close the walls square
    tester.actionKeyStroke(KeyEvent.VK_ENTER);
    tester.actionKeyString("100");
    tester.actionKeyStroke(KeyEvent.VK_TAB);
    tester.actionKeyString("90");
    tester.actionKeyStroke(KeyEvent.VK_ENTER);
    // Check created walls
    assertEquals("Wrong walls count", 7, frame.home.getWalls().size());
    Wall wall4 = orderedWalls.get(4);
    Wall wall5 = orderedWalls.get(5);
    Wall wall6 = orderedWalls.get(6);
    assertSelectionContains(frame.home, wall4, wall5, wall6, wall7);
    assertWallsAreJoined(wall6, wall7, wall4);
   
    // 4. Create a dimension line with keyboard
    frame.planController.setMode(PlanController.Mode.DIMENSION_LINE_CREATION);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.