Package com.eteks.sweethome3d.model

Examples of com.eteks.sweethome3d.model.FurnitureCatalog


                pieceWidth, pieceDepth, pieceHeight, pieceElevation, pieceMovable,
                pieceModelRotation, pieceCreator, pieceResizable, pieceDeformable, piece.isTexturable(),
                piecePrice, pieceValueAddedTaxPercentage);
          }
        }
        new FurnitureCatalog() { }.add(pieceCategory, piece);
        this.furnitureLibrary.addPieceOfFurniture(piece, index);
        Set<String> supportedLanguages = new HashSet<String>(this.furnitureLibrary.getSupportedLanguages());
        supportedLanguages.add(this.furnitureLanguageController.getFurnitureLangauge());
        for (String language : supportedLanguages) {
          if (!FurnitureLibrary.DEFAULT_LANGUAGE.equals(language)) {
View Full Code Here


    CatalogPieceOfFurniture piece = new CatalogPieceOfFurniture(key,
        modelName, null, iconContent, null, modelContent,
        size.x, size.z, size.y, 0f, true, null, this.preferences.getDefaultCreator(), true, null, null);
    FurnitureCategory defaultCategory = new FurnitureCategory(
        this.preferences.getLocalizedString(ImportFurnitureTaskPanel.class, "defaultCategory"));
    new FurnitureCatalog() { }.add(defaultCategory , piece);
    return piece;
  }
View Full Code Here

            }
            CatalogPieceOfFurniture piece = super.readPieceOfFurniture(resource, index, furnitureCatalogUrl, furnitureResourcesUrlBase);
            if (piece != null) {
              // Set furniture category through dummy catalog
              FurnitureCategory category = super.readFurnitureCategory(resource, index);
              new FurnitureCatalog() { }.add(category, piece);
              furniture.add(piece);
            }
            return piece;
          }
         
View Full Code Here

    // 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);
   
    // 2. Record home in a file named test.sh3d in current directory
    HomeRecorder recorder = new HomeFileRecorder();
    String testFile = new File("test.sh3d").getAbsolutePath();
View Full Code Here

    UserPreferences preferences = new DefaultUserPreferences();
    // Check the current unit isn't centimeter
    LengthUnit currentUnit = preferences.getLengthUnit();
    assertFalse("Unit is in centimeter", currentUnit == LengthUnit.CENTIMETER);
    // Get furniture catalog
    FurnitureCatalog catalog = preferences.getFurnitureCatalog();
   
    // 2. Create a home that contains furniture matching catalog furniture
    List<HomePieceOfFurniture> homeFurniture = createHomeFurnitureFromCatalog(catalog);
    Home home = new Home(homeFurniture);
    // Check catalog furniture count equals home furniture count
View Full Code Here

*/
public class CatalogTreeTest extends TestCase {
  public void testCatalogTreeCreation() {
    // 1. Create a furniture catalog read from English locale resources
    Locale.setDefault(Locale.US);
    FurnitureCatalog catalog = new DefaultFurnitureCatalog();

    // Get the name of the first category
    List<FurnitureCategory> categories = catalog.getCategories();
    FurnitureCategory firstCategory = categories.get(0);
    String firstCategoryEnglishName = firstCategory.getName();
    // Get the name of the first piece of furniture
    List<CatalogPieceOfFurniture> categoryFurniture = firstCategory.getFurniture();
    CatalogPieceOfFurniture firstPiece = categoryFurniture.get(0);
    String firstPieceEnglishName = firstPiece.getName();
   
    // 2. Read the furniture catalog from French locale resources
    Locale.setDefault(Locale.FRENCH);
    catalog = new DefaultFurnitureCatalog();
    // Get the french names of the first category and its first piece of furniture
    firstCategory = catalog.getCategories().get(0);
    String firstCategoryFrenchName = firstCategory.getName();
    firstPiece = firstCategory.getFurniture().get(0);
    String firstPieceFrenchName = firstPiece.getName();
    // Check categories and furniture names in English and French locale are different
    assertFalse("Same name for first category",
View Full Code Here

      }
     
      public void collectionChanged(CollectionEvent<CatalogPieceOfFurniture> ev) {
        // If catalog tree model was garbage collected, remove this listener from catalog
        CatalogTreeModel catalogTreeModel = this.catalogTreeModel.get();
        FurnitureCatalog catalog = (FurnitureCatalog)ev.getSource();
        if (catalogTreeModel == null) {
          catalog.removeFurnitureListener(this);
        } else {
          CatalogPieceOfFurniture piece = ev.getItem();
          switch (ev.getType()) {
            case ADD :
              if (piece.getCategory().getFurnitureCount() == 1) {
                // Fire nodes inserted for new category
                catalogTreeModel.fireTreeNodesInserted(new TreeModelEvent(catalogTreeModel,
                    new Object [] {catalog},
                    new int [] {Collections.binarySearch(catalog.getCategories(), piece.getCategory())},
                    new Object [] {piece.getCategory()}));
              } else {
                // Fire nodes inserted for new piece
                catalogTreeModel.fireTreeNodesInserted(new TreeModelEvent(catalogTreeModel,
                    new Object [] {catalog, piece.getCategory()},
                    new int [] {ev.getIndex()},
                    new Object [] {piece}));
              }
              break;
            case DELETE :
              if (piece.getCategory().getFurnitureCount() == 0) {
                // Fire nodes removed for deleted category
                catalogTreeModel.fireTreeNodesRemoved(new TreeModelEvent(catalogTreeModel,
                    new Object [] {catalog},
                    new int [] {-(Collections.binarySearch(catalog.getCategories(), piece.getCategory()) + 1)},
                    new Object [] {piece.getCategory()}));
              } else {
                // Fire nodes removed for deleted piece
                catalogTreeModel.fireTreeNodesRemoved(new TreeModelEvent(catalogTreeModel,
                    new Object [] {catalog, piece.getCategory()},
View Full Code Here

    }
   
    public void collectionChanged(CollectionEvent<CatalogPieceOfFurniture> ev) {
      // If panel was garbage collected, remove this listener from catalog
      FurnitureCatalogListPanel furnitureCatalogPanel = this.furnitureCatalogPanel.get();
      FurnitureCatalog catalog = (FurnitureCatalog)ev.getSource();
      if (furnitureCatalogPanel == null) {
        catalog.removeFurnitureListener(this);
      } else {
        DefaultComboBoxModel model =
            (DefaultComboBoxModel)furnitureCatalogPanel.categoryFilterComboBox.getModel();
        FurnitureCategory category = ev.getItem().getCategory();
        List<FurnitureCategory> categories = catalog.getCategories();
        if (!categories.contains(category)) {
          model.removeElement(category);
          furnitureCatalogPanel.categoryFilterComboBox.setSelectedIndex(0);
        } else if (model.getIndexOf(category) == -1) {
          model.insertElementAt(category, categories.indexOf(category) + 1);
View Full Code Here

      }
     
      public void collectionChanged(CollectionEvent<CatalogPieceOfFurniture> ev) {
        // If catalog tree model was garbage collected, remove this listener from catalog
        CatalogListModel catalogTreeModel = this.catalogListModel.get();
        FurnitureCatalog catalog = (FurnitureCatalog)ev.getSource();
        if (catalogTreeModel == null) {
          catalog.removeFurnitureListener(this);
        } else {
          catalogTreeModel.updateFurnitureList();
        }
      }
View Full Code Here

  /**
   * Reloads furniture and textures default catalogs.
   */
  private void updateDefaultCatalogs() {
    // Delete default pieces of current furniture catalog         
    FurnitureCatalog furnitureCatalog = getFurnitureCatalog();
    for (FurnitureCategory category : furnitureCatalog.getCategories()) {
      for (CatalogPieceOfFurniture piece : category.getFurniture()) {
        if (!piece.isModifiable()) {
          furnitureCatalog.delete(piece);
        }
      }
    }
    // Add default pieces that don't have homonym among user catalog
    FurnitureCatalog defaultFurnitureCatalog =
        new DefaultFurnitureCatalog(this.pluginFurnitureCatalogURLs, this.furnitureResourcesUrlBase);
    for (FurnitureCategory category : defaultFurnitureCatalog.getCategories()) {
      for (CatalogPieceOfFurniture piece : category.getFurniture()) {
        try {
          furnitureCatalog.add(category, piece);
        } catch (IllegalHomonymException ex) {
          // Ignore pieces that have the same name as an existing piece
View Full Code Here

TOP

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

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.