setDeformable(true);
setTexturable(true);
setProportional(false);
} else {
// Search the common properties among selected furniture
HomePieceOfFurniture firstPiece = selectedFurniture.get(0);
Content icon = firstPiece.getIcon();
if (icon != null) {
for (int i = 1; i < selectedFurniture.size(); i++) {
if (!icon.equals(selectedFurniture.get(i).getIcon())) {
icon = null;
break;
}
}
}
setIcon(icon);
String name = firstPiece.getName();
if (name != null) {
for (int i = 1; i < selectedFurniture.size(); i++) {
if (!name.equals(selectedFurniture.get(i).getName())) {
name = null;
break;
}
}
}
setName(name);
Boolean nameVisible = firstPiece.isNameVisible();
for (int i = 1; i < selectedFurniture.size(); i++) {
if (nameVisible != selectedFurniture.get(i).isNameVisible()) {
nameVisible = null;
break;
}
}
setNameVisible(nameVisible);
Float angle = firstPiece.getAngle();
for (int i = 1; i < selectedFurniture.size(); i++) {
if (angle.floatValue() != selectedFurniture.get(i).getAngle()) {
angle = null;
break;
}
}
if (angle == null) {
setAngleInDegrees(null);
} else {
setAngleInDegrees((int)(Math.round(Math.toDegrees(angle)) + 360) % 360);
}
Float x = firstPiece.getX();
for (int i = 1; i < selectedFurniture.size(); i++) {
if (x.floatValue() != selectedFurniture.get(i).getX()) {
x = null;
break;
}
}
setX(x);
Float y = firstPiece.getY();
for (int i = 1; i < selectedFurniture.size(); i++) {
if (y.floatValue() != selectedFurniture.get(i).getY()) {
y = null;
break;
}
}
setY(y);
Float elevation = firstPiece.getElevation();
for (int i = 1; i < selectedFurniture.size(); i++) {
if (elevation.floatValue() != selectedFurniture.get(i).getElevation()) {
elevation = null;
break;
}
}
setElevation(elevation);
boolean basePlanItemEditable = !firstPiece.isDoorOrWindow();
for (int i = 1; !basePlanItemEditable && i < selectedFurniture.size(); i++) {
if (!selectedFurniture.get(i).isDoorOrWindow()) {
basePlanItemEditable = true;
}
}
this.basePlanItemEditable = basePlanItemEditable;
Boolean basePlanItem = !firstPiece.isMovable();
for (int i = 1; i < selectedFurniture.size(); i++) {
if (basePlanItem.booleanValue() != !selectedFurniture.get(i).isMovable()) {
basePlanItem = null;
break;
}
}
setBasePlanItem(basePlanItem);
Float width = firstPiece.getWidth();
for (int i = 1; i < selectedFurniture.size(); i++) {
if (width.floatValue() != selectedFurniture.get(i).getWidth()) {
width = null;
break;
}
}
setWidth(width, false);
Float depth = firstPiece.getDepth();
for (int i = 1; i < selectedFurniture.size(); i++) {
if (depth.floatValue() != selectedFurniture.get(i).getDepth()) {
depth = null;
break;
}
}
setDepth(depth, false);
Float height = firstPiece.getHeight();
for (int i = 1; i < selectedFurniture.size(); i++) {
if (height.floatValue() != selectedFurniture.get(i).getHeight()) {
height = null;
break;
}
}
setHeight(height, false);
Integer color = firstPiece.getColor();
if (color != null) {
for (int i = 1; i < selectedFurniture.size(); i++) {
if (!color.equals(selectedFurniture.get(i).getColor())) {
color = null;
break;
}
}
}
setColor(color);
HomeTexture firstPieceTexture = firstPiece.getTexture();
HomeTexture texture = firstPieceTexture;
if (texture != null) {
for (int i = 1; i < selectedFurniture.size(); i++) {
if (!texture.equals(selectedFurniture.get(i).getTexture())) {
texture = null;
break;
}
}
}
if (textureController != null) {
// Texture management available since version 2.3 only
textureController.setTexture(texture);
}
boolean defaultColorsAndTextures = true;
for (int i = 0; i < selectedFurniture.size(); i++) {
HomePieceOfFurniture piece = selectedFurniture.get(i);
if (piece.getColor() != null
|| piece.getTexture() != null) {
defaultColorsAndTextures = false;
break;
}
}
if (color != null) {
setPaint(FurniturePaint.COLORED);
} else if (texture != null) {
setPaint(FurniturePaint.TEXTURED);
} else if (defaultColorsAndTextures) {
setPaint(FurniturePaint.DEFAULT);
} else {
setPaint(null);
}
Float firstPieceShininess = firstPiece.getShininess();
FurnitureShininess shininess = firstPieceShininess == null
? FurnitureShininess.DEFAULT
: (firstPieceShininess.floatValue() == 0
? FurnitureShininess.MATT
: FurnitureShininess.SHINY);
for (int i = 1; i < selectedFurniture.size(); i++) {
HomePieceOfFurniture piece = selectedFurniture.get(i);
if (firstPieceShininess != piece.getShininess()
|| (firstPieceShininess != null && !firstPieceShininess.equals(piece.getShininess()))) {
shininess = null;
break;
}
}
setShininess(shininess);