Examples of HomePieceOfFurniture


Examples of com.eteks.sweethome3d.model.HomePieceOfFurniture

   * Tests furniture visible properties changes.
   */
  public void testFurnitureVisibleProperties() {
    // 1. Add the first piece of catalog first category to home
    FurnitureCategory firstCategory = this.preferences.getFurnitureCatalog().getCategories().get(0);
    HomePieceOfFurniture piece = new HomePieceOfFurniture(firstCategory.getFurniture().get(0));
    this.home.addPieceOfFurniture(piece);
    // Use centimeter as unit
    this.preferences.setUnit(LengthUnit.CENTIMETER);
    // Check displayed values in table
    assertFurnitureFirstRowEquals(this.furnitureTable, piece.getName(),
        piece.getWidth(), piece.getDepth(), piece.getHeight(), piece.isVisible());
   
    // 2. Make name property invisible
    runAction(HomePane.ActionType.DISPLAY_HOME_FURNITURE_NAME);
    // Check displayed values in table doesn't contain piece name
    assertFurnitureFirstRowEquals(this.furnitureTable,
        piece.getWidth(), piece.getDepth(), piece.getHeight(), piece.isVisible());

    // 3. Make y property visible
    runAction(HomePane.ActionType.DISPLAY_HOME_FURNITURE_Y);
    // Check displayed values in table contains piece ordinate after piece depth
    assertFurnitureFirstRowEquals(this.furnitureTable,
        piece.getWidth(), piece.getDepth(), piece.getHeight(), piece.getY(), piece.isVisible());

    // 4. Make name property visible again
    runAction(HomePane.ActionType.DISPLAY_HOME_FURNITURE_NAME);
    // Check displayed values in table contains piece name in first position
    assertFurnitureFirstRowEquals(this.furnitureTable, piece.getName(),
        piece.getWidth(), piece.getDepth(), piece.getHeight(), piece.getY(), piece.isVisible());
   
    // 5. Change visible properties order and list
    this.furnitureController.setFurnitureVisibleProperties(
        Arrays.asList(new HomePieceOfFurniture.SortableProperty [] {
            HomePieceOfFurniture.SortableProperty.MOVABLE,
            HomePieceOfFurniture.SortableProperty.NAME}));
    // Check displayed values in table contains piece name and visible properties
    assertFurnitureFirstRowEquals(this.furnitureTable, piece.isMovable(), piece.getName());

    // 6. Make visible property visible
    runAction(HomePane.ActionType.DISPLAY_HOME_FURNITURE_VISIBLE);
    // Check displayed values in table contains piece visible property after movable property
    assertFurnitureFirstRowEquals(this.furnitureTable,
        piece.isMovable(), piece.isVisible(), piece.getName());
  }
View Full Code Here

Examples of com.eteks.sweethome3d.model.HomePieceOfFurniture

        ((HomeDoorOrWindow)this.piece).setBoundToWall(this.doorOrWindowBoundToWall);
      }
      if (this.piece instanceof HomeFurnitureGroup) {
        List<HomePieceOfFurniture> groupFurniture = getGroupFurniture((HomeFurnitureGroup)this.piece);
        for (int i = 0; i < groupFurniture.size(); i++) {
          HomePieceOfFurniture groupPiece = groupFurniture.get(i);
          if (this.piece.isResizable()) {
            // Restore group furniture location and size because resizing a group isn't reversible
            groupPiece.setX(this.groupFurnitureX [i]);
            groupPiece.setY(this.groupFurnitureY [i]);
            groupPiece.setWidth(this.groupFurnitureWidth [i]);
            groupPiece.setDepth(this.groupFurnitureDepth [i]);
            groupPiece.setHeight(this.groupFurnitureHeight [i]);
          }
        }
      }
    }
View Full Code Here

Examples of com.eteks.sweethome3d.model.HomePieceOfFurniture

    List<HomePieceOfFurniture> pieces = this.home.getFurniture();
    // Check home contains two selected pieces
    assertEquals("Home doesn't contain 2 pieces", 2, pieces.size());
    assertEquals("Home doesn't contain 2 selected items", 2, this.home.getSelectedItems().size());
    assertGroupActionsEnabled(true, false);
    HomePieceOfFurniture piece1 = pieces.get(0);
    HomePieceOfFurniture piece2 = pieces.get(1);
    piece2.move(100, 100);
    piece2.setElevation(100);
   
    // 2. Group selected furniture
    runAction(HomePane.ActionType.GROUP_FURNITURE);
    // Check home contains one selected piece that replaced added pieces
    pieces = this.home.getFurniture();
    assertEquals("Home doesn't contain 1 piece", 1, pieces.size());
    assertEquals("Home doesn't contain 1 selected item", 1, this.home.getSelectedItems().size());
    assertFalse("Home still contains first added piece", pieces.contains(piece1));
    assertFalse("Home still contains scond added piece", pieces.contains(piece2));
    assertGroupActionsEnabled(false, true);
    HomeFurnitureGroup group = (HomeFurnitureGroup)pieces.get(0);
    // Compare surrounding rectangles
    Rectangle2D piecesRectangle = getSurroundingRectangle(piece1);
    piecesRectangle.add(getSurroundingRectangle(piece2));
    Rectangle2D groupRectangle = getSurroundingRectangle(group);
    assertEquals("Surrounding rectangle is incorrect", piecesRectangle, groupRectangle);
    // Compare elevation and height
    assertEquals("Wrong elevation", Math.min(piece1.getElevation(), piece2.getElevation()), group.getElevation());
    assertEquals("Wrong height",
        Math.max(piece1.getElevation() + piece1.getHeight(), piece2.getElevation() + piece2.getHeight())
        - Math.min(piece1.getElevation(), piece2.getElevation()), group.getHeight());
   
    // 3. Rotate group
    float angle = (float)(Math.PI / 2);
    group.setAngle(angle);
    // Check pieces rotation
    assertEquals("Piece angle is wrong", angle, piece1.getAngle());
    assertEquals("Piece angle is wrong", angle, piece2.getAngle());
    assertEquals("Group angle is wrong", angle, group.getAngle());
    // Check surrounding rectangles
    Rectangle2D rotatedGroupRectangle = new GeneralPath(groupRectangle).createTransformedShape(
        AffineTransform.getRotateInstance(angle, groupRectangle.getCenterX(), groupRectangle.getCenterY())).getBounds2D();
    groupRectangle = getSurroundingRectangle(group);
    assertEquals("Surrounding rectangle is incorrect", rotatedGroupRectangle, groupRectangle);
    piecesRectangle = getSurroundingRectangle(piece1);
    piecesRectangle.add(getSurroundingRectangle(piece2));
    assertEquals("Surrounding rectangle is incorrect", piecesRectangle.getWidth(), groupRectangle.getWidth());
    assertEquals("Surrounding rectangle is incorrect", piecesRectangle.getHeight(), groupRectangle.getHeight());
   
    // 4. Undo / Redo
    assertActionsEnabled(true, true, true, false);
    runAction(HomePane.ActionType.UNDO);
    pieces = this.home.getFurniture();
    assertEquals("Home doesn't contain 2 pieces", 2, pieces.size());
    assertEquals("Home doesn't contain 2 selected items", 2, this.home.getSelectedItems().size());
    assertFalse("Home contains group", pieces.contains(group));
    assertGroupActionsEnabled(true, false);

    assertActionsEnabled(true, true, true, true);
    runAction(HomePane.ActionType.REDO);
    pieces = this.home.getFurniture();
    assertEquals("Home doesn't contain 1 piece", 1, pieces.size());
    assertEquals("Home doesn't contain 1 selected item", 1, this.home.getSelectedItems().size());
    assertTrue("Home doesn't contain group", pieces.contains(group));
    assertGroupActionsEnabled(false, true);
   
    // 5. Add one more piece to home
    catalogPieces = Arrays.asList(new CatalogPieceOfFurniture [] {firstCategory.getFurniture().get(0)});
    this.homeController.getFurnitureCatalogController().setSelectedFurniture(catalogPieces);
    runAction(HomePane.ActionType.ADD_HOME_FURNITURE);
    pieces = this.home.getFurniture();
    // Check home contains two pieces with one selected
    assertEquals("Home doesn't contain 2 pieces", 2, pieces.size());
    assertEquals("Home doesn't contain 1 selected item", 1, this.home.getSelectedItems().size());
    assertGroupActionsEnabled(false, false);
   
    // 6. Group it with the other group
    HomePieceOfFurniture piece3 = pieces.get(1);
    this.home.setSelectedItems(Arrays.asList(new Selectable [] {group, piece3}));
    assertEquals("Home doesn't contain 2 selected items", 2, this.home.getSelectedItems().size());
    assertGroupActionsEnabled(true, true);
    runAction(HomePane.ActionType.GROUP_FURNITURE);
    pieces = this.home.getFurniture();
View Full Code Here

Examples of com.eteks.sweethome3d.model.HomePieceOfFurniture

    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);
    assertEquals("Incorrect wall count", 1, home.getWalls().size());
    assertEquals("Incorrect furniture count", 1, home.getFurniture().size());

    // 3. Export home to OBJ file
    File dir = new File("Tmp@#");
View Full Code Here

Examples of com.eteks.sweethome3d.model.HomePieceOfFurniture

        itemsWithText.add(label);
        TextStyle oldTextStyle = getItemTextStyle(label, label.getStyle());
        oldTextStyles.add(oldTextStyle);
        textStyles.add(oldTextStyle.deriveBoldStyle(selectionBoldStyle));
      } else if (item instanceof HomePieceOfFurniture) {
        HomePieceOfFurniture piece = (HomePieceOfFurniture)item;
        if (piece.isVisible()) {
          itemsWithText.add(piece);
          TextStyle oldNameStyle = getItemTextStyle(piece, piece.getNameStyle());
          oldTextStyles.add(oldNameStyle);
          textStyles.add(oldNameStyle.deriveBoldStyle(selectionBoldStyle));
        }
      } else if (item instanceof Room) {
        final Room room = (Room)item;
View Full Code Here

Examples of com.eteks.sweethome3d.model.HomePieceOfFurniture

        itemsWithText.add(label);
        TextStyle oldTextStyle = getItemTextStyle(label, label.getStyle());
        oldTextStyles.add(oldTextStyle);
        textStyles.add(oldTextStyle.deriveItalicStyle(selectionItalicStyle));
      } else if (item instanceof HomePieceOfFurniture) {
        HomePieceOfFurniture piece = (HomePieceOfFurniture)item;
        if (piece.isVisible()) {
          itemsWithText.add(piece);
          TextStyle oldNameStyle = getItemTextStyle(piece, piece.getNameStyle());
          oldTextStyles.add(oldNameStyle);
          textStyles.add(oldNameStyle.deriveItalicStyle(selectionItalicStyle));
        }
      } else if (item instanceof Room) {
        final Room room = (Room)item;
View Full Code Here

Examples of com.eteks.sweethome3d.model.HomePieceOfFurniture

        itemsWithText.add(label);
        TextStyle oldLabelStyle = getItemTextStyle(item, label.getStyle());
        oldTextStyles.add(oldLabelStyle);
        textStyles.add(oldLabelStyle.deriveStyle(Math.round(oldLabelStyle.getFontSize() * factor)));
      } else if (item instanceof HomePieceOfFurniture) {
        HomePieceOfFurniture piece = (HomePieceOfFurniture)item;
        if (piece.isVisible()) {
          itemsWithText.add(piece);
          TextStyle oldNameStyle = getItemTextStyle(piece, piece.getNameStyle());
          oldTextStyles.add(oldNameStyle);
          textStyles.add(oldNameStyle.deriveStyle(Math.round(oldNameStyle.getFontSize() * factor)));
        }
      } else if (item instanceof Room) {
        final Room room = (Room)item;
View Full Code Here

Examples of com.eteks.sweethome3d.model.HomePieceOfFurniture

    int styleIndex = 0;
    for (Selectable item : items) {
      if (item instanceof Label) {
        ((Label)item).setStyle(styles [styleIndex++]);
      } else if (item instanceof HomePieceOfFurniture) {
        HomePieceOfFurniture piece = (HomePieceOfFurniture)item;
        if (piece.isVisible()) {
          piece.setNameStyle(styles [styleIndex++]);
        }
      } else if (item instanceof Room) {
        final Room room = (Room)item;
        room.setNameStyle(styles [styleIndex++]);
        room.setAreaStyle(styles [styleIndex++]);
View Full Code Here

Examples of com.eteks.sweethome3d.model.HomePieceOfFurniture

  private HomePieceOfFurniture adjustPieceOfFurnitureElevationAt(HomePieceOfFurniture piece) {
    // Search if another piece at floor level contains the given piece to elevate it at its height
    if (!piece.isDoorOrWindow()
        && piece.getElevation() == 0) {
      float [][] piecePoints = piece.getPoints();
      HomePieceOfFurniture highestSurroundingPiece = null;
      float highestElevation = Float.MIN_VALUE;
      for (HomePieceOfFurniture homePiece : this.home.getFurniture()) {
        if (homePiece != piece
            && !homePiece.isDoorOrWindow()
            && homePiece.isVisible()) {
View Full Code Here

Examples of com.eteks.sweethome3d.model.HomePieceOfFurniture

    }   
   
    List<HomePieceOfFurniture> furniture = this.home.getFurniture();
    // Search in home furniture in reverse order to give priority to last drawn piece
    // at highest elevation in case it covers an other piece
    HomePieceOfFurniture foundPiece = null;
    for (int i = furniture.size() - 1; i >= 0; i--) {
      HomePieceOfFurniture piece = furniture.get(i);
      if ((!basePlanLocked
            || !isItemPartOfBasePlan(piece))
          && piece.isVisible()) {
        if (piece.containsPoint(x, y, margin)) {
          items.add(piece);
          if (foundPiece == null
              || piece.getElevation() > foundPiece.getElevation()) {
            foundPiece = piece;
          }
        } else if (foundPiece == null) {
          // Search if piece name contains point in case it is drawn outside of the piece
          String pieceName = piece.getName();
          if (pieceName != null
              && piece.isNameVisible()
              && isItemTextAt(piece, pieceName, piece.getNameStyle(),
                  piece.getX() + piece.getNameXOffset(),
                  piece.getY() + piece.getNameYOffset(), x, y, textMargin)) {
            items.add(piece);
            foundPiece = piece;
          }
        }
      }
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.