Sweet Home 3D 4.0

com.eteks.sweethome3d.model
Class HomePieceOfFurniture

java.lang.Object
  extended by com.eteks.sweethome3d.model.HomePieceOfFurniture
All Implemented Interfaces:
Elevatable, PieceOfFurniture, Selectable, Serializable, Cloneable
Direct Known Subclasses:
HomeDoorOrWindow, HomeFurnitureGroup, HomeLight

public class HomePieceOfFurniture
extends Object
implements PieceOfFurniture, Serializable, Selectable, Elevatable

A piece of furniture in home.

Author:
Emmanuel Puybaret
See Also:
Serialized Form

Nested Class Summary
static class HomePieceOfFurniture.Property
          The properties of a piece of furniture that may change.
static class HomePieceOfFurniture.SortableProperty
          The properties on which home furniture may be sorted.
 
Constructor Summary
HomePieceOfFurniture(PieceOfFurniture piece)
          Creates a home piece of furniture from an existing piece.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds the property change listener in parameter to this piece.
 HomePieceOfFurniture clone()
          Returns a clone of this piece.
 boolean containsPoint(float x, float y, float margin)
          Returns true if this piece contains the point at (x, y) with a given margin.
 float getAngle()
          Returns the angle in radians of this piece of furniture.
 String getCatalogId()
          Returns the catalog ID of this piece of furniture or null if it doesn't exist.
 Integer getColor()
          Returns the color of this piece of furniture.
 String getCurrency()
          Returns the price currency, noted with ISO 4217 code, or null if it has no price or default currency should be used.
 float getDepth()
          Returns the depth of this piece of furniture.
 String getDescription()
          Returns the description of this piece of furniture.
 float getElevation()
          Returns the elevation of the bottom of this piece of furniture on its level.
static Comparator<HomePieceOfFurniture> getFurnitureComparator(HomePieceOfFurniture.SortableProperty property)
          Returns a comparator that compares furniture on a given property in ascending order.
 float getGroundElevation()
          Returns the elevation of the bottom of this piece of furniture from the ground according to the elevation of its level.
 float getHeight()
          Returns the height of this piece of furniture.
 Content getIcon()
          Returns the icon of this piece of furniture.
 Level getLevel()
          Returns the level which this piece belongs to.
 Content getModel()
          Returns the 3D model of this piece of furniture.
 HomeMaterial[] getModelMaterials()
          Returns the materials applied to the 3D model of this piece of furniture.
 float[][] getModelRotation()
          Returns the rotation 3 by 3 matrix of this piece of furniture that ensures its model is correctly oriented.
 String getName()
          Returns the name of this piece of furniture.
 float getNameAngle()
          Returns the angle in radians used to display the piece name.
 TextStyle getNameStyle()
          Returns the text style used to display piece name.
 float getNameXOffset()
          Returns the distance along x axis applied to piece abscissa to display piece name.
 float getNameYOffset()
          Returns the distance along y axis applied to piece ordinate to display piece name.
 Content getPlanIcon()
          Returns the icon of this piece of furniture displayed in plan or null.
 float[][] getPoints()
          Returns the points of each corner of a piece.
 BigDecimal getPrice()
          Returns the price of this piece of furniture or null.
 BigDecimal getPriceValueAddedTaxIncluded()
          Returns the price of this piece of furniture, Value Added Tax included.
 Float getShininess()
          Returns the shininess of this piece of furniture.
 String getStaircaseCutOutShape()
          Returns the shape used to cut out upper levels when they intersect with the piece like a staircase.
 HomeTexture getTexture()
          Returns the texture of this piece of furniture.
 BigDecimal getValueAddedTax()
          Returns the Value Added Tax applied to the price of this piece of furniture.
 BigDecimal getValueAddedTaxPercentage()
          Returns the Value Added Tax percentage applied to the price of this piece of furniture.
 float getWidth()
          Returns the width of this piece of furniture.
 float getX()
          Returns the abscissa of the center of this piece of furniture.
 float getY()
          Returns the ordinate of the center of this piece of furniture.
 boolean intersectsRectangle(float x0, float y0, float x1, float y1)
          Returns true if this piece intersects with the horizontal rectangle which opposite corners are at points (x0, y0) and (x1, y1).
 boolean isAtLevel(Level level)
          Returns true if this piece is visible at the given level.
 boolean isBackFaceShown()
          Returns true if the back face of the piece of furniture model should be displayed.
 boolean isBottomLeftPointAt(float x, float y, float margin)
          Returns true if the bottom left point of this piece is the point at (x, y) with a given margin, and if that point is closer to bottom left point than to top left and bottom right points.
 boolean isBottomRightPointAt(float x, float y, float margin)
          Returns true if the bottom right point of this piece is the point at (x, y) with a given margin, and if that point is closer to top left point than to top right and bottom left points.
 boolean isDeformable()
          Returns true if this piece is deformable.
 boolean isDoorOrWindow()
          Returns true if this piece of furniture is a door or a window.
 boolean isModelMirrored()
          Returns true if the model of this piece should be mirrored.
 boolean isMovable()
          Returns true if this piece of furniture is movable.
 boolean isNameCenterPointAt(float x, float y, float margin)
          Returns true if the center point at which is displayed the name of this piece is equal to the point at (x, y) with a given margin.
 boolean isNameVisible()
          Returns whether the name of this piece should be drawn or not.
 boolean isPointAt(float x, float y, float margin)
          Returns true if one of the corner of this piece is the point at (x, y) with a given margin.
 boolean isResizable()
          Returns true if this piece is resizable.
 boolean isTexturable()
          Returns false if this piece should always keep the same color or texture.
 boolean isTopLeftPointAt(float x, float y, float margin)
          Returns true if the top left point of this piece is the point at (x, y) with a given margin, and if that point is closer to top left point than to top right and bottom left points.
 boolean isTopRightPointAt(float x, float y, float margin)
          Returns true if the top right point of this piece is the point at (x, y) with a given margin, and if that point is closer to top right point than to top left and bottom right points.
 boolean isVisible()
          Returns true if this piece of furniture is visible.
 void move(float dx, float dy)
          Moves this piece of (dx, dy) units.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes the property change listener in parameter from this piece.
 void setAngle(float angle)
          Sets the angle of this piece.
 void setColor(Integer color)
          Sets the color of this piece of furniture.
 void setDepth(float depth)
          Sets the depth of this piece of furniture.
 void setDescription(String description)
          Sets the description of this piece of furniture.
 void setElevation(float elevation)
          Sets the elevation of this piece of furniture on its level.
 void setHeight(float height)
          Sets the height of this piece of furniture.
 void setLevel(Level level)
          Sets the level of this piece of furniture.
 void setModelMaterials(HomeMaterial[] modelMaterials)
          Sets the materials of the 3D model of this piece of furniture.
 void setModelMirrored(boolean modelMirrored)
          Sets whether the model of this piece of furniture is mirrored or not.
 void setMovable(boolean movable)
          Sets whether this piece is movable or not.
 void setName(String name)
          Sets the name of this piece of furniture.
 void setNameAngle(float nameAngle)
          Sets the angle in radians used to display the piece name.
 void setNameStyle(TextStyle nameStyle)
          Sets the text style used to display piece name.
 void setNameVisible(boolean nameVisible)
          Sets whether the name of this piece is visible or not.
 void setNameXOffset(float nameXOffset)
          Sets the distance along x axis applied to piece abscissa to display piece name.
 void setNameYOffset(float nameYOffset)
          Sets the distance along y axis applied to piece ordinate to display piece name.
 void setPrice(BigDecimal price)
          Sets the price of this piece of furniture.
 void setShininess(Float shininess)
          Sets the shininess of this piece of furniture or null if piece shininess is unchanged.
 void setTexture(HomeTexture texture)
          Sets the texture of this piece of furniture.
 void setVisible(boolean visible)
          Sets whether this piece of furniture is visible or not.
 void setWidth(float width)
          Sets the width of this piece of furniture.
 void setX(float x)
          Sets the abscissa of the center of this piece.
 void setY(float y)
          Sets the ordinate of the center of this piece.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HomePieceOfFurniture

public HomePieceOfFurniture(PieceOfFurniture piece)
Creates a home piece of furniture from an existing piece.

Parameters:
piece - the piece from which data are copied
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Adds the property change listener in parameter to this piece.


removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Removes the property change listener in parameter from this piece.


getCatalogId

public String getCatalogId()
Returns the catalog ID of this piece of furniture or null if it doesn't exist.


getName

public String getName()
Returns the name of this piece of furniture.

Specified by:
getName in interface PieceOfFurniture

setName

public void setName(String name)
Sets the name of this piece of furniture. Once this piece is updated, listeners added to this piece will receive a change notification.


isNameVisible

public boolean isNameVisible()
Returns whether the name of this piece should be drawn or not.


setNameVisible

public void setNameVisible(boolean nameVisible)
Sets whether the name of this piece is visible or not. Once this piece of furniture is updated, listeners added to this piece will receive a change notification.


getNameXOffset

public float getNameXOffset()
Returns the distance along x axis applied to piece abscissa to display piece name.


setNameXOffset

public void setNameXOffset(float nameXOffset)
Sets the distance along x axis applied to piece abscissa to display piece name. Once this piece is updated, listeners added to this piece will receive a change notification.


getNameYOffset

public float getNameYOffset()
Returns the distance along y axis applied to piece ordinate to display piece name.


setNameYOffset

public void setNameYOffset(float nameYOffset)
Sets the distance along y axis applied to piece ordinate to display piece name. Once this piece is updated, listeners added to this piece will receive a change notification.


getNameStyle

public TextStyle getNameStyle()
Returns the text style used to display piece name.


setNameStyle

public void setNameStyle(TextStyle nameStyle)
Sets the text style used to display piece name. Once this piece is updated, listeners added to this piece will receive a change notification.


getNameAngle

public float getNameAngle()
Returns the angle in radians used to display the piece name.

Since:
3.6

setNameAngle

public void setNameAngle(float nameAngle)
Sets the angle in radians used to display the piece name. Once this piece is updated, listeners added to this piece will receive a change notification.

Since:
3.6

getDescription

public String getDescription()
Returns the description of this piece of furniture. The returned value may be null.

Specified by:
getDescription in interface PieceOfFurniture

setDescription

public void setDescription(String description)
Sets the description of this piece of furniture. Once this piece is updated, listeners added to this piece will receive a change notification.


getDepth

public float getDepth()
Returns the depth of this piece of furniture.

Specified by:
getDepth in interface PieceOfFurniture

setDepth

public void setDepth(float depth)
Sets the depth of this piece of furniture. Once this piece is updated, listeners added to this piece will receive a change notification.

Throws:
IllegalStateException - if this piece of furniture isn't resizable

getHeight

public float getHeight()
Returns the height of this piece of furniture.

Specified by:
getHeight in interface PieceOfFurniture

setHeight

public void setHeight(float height)
Sets the height of this piece of furniture. Once this piece is updated, listeners added to this piece will receive a change notification.

Throws:
IllegalStateException - if this piece of furniture isn't resizable

getWidth

public float getWidth()
Returns the width of this piece of furniture.

Specified by:
getWidth in interface PieceOfFurniture

setWidth

public void setWidth(float width)
Sets the width of this piece of furniture. Once this piece is updated, listeners added to this piece will receive a change notification.

Throws:
IllegalStateException - if this piece of furniture isn't resizable

getElevation

public float getElevation()
Returns the elevation of the bottom of this piece of furniture on its level.

Specified by:
getElevation in interface PieceOfFurniture

getGroundElevation

public float getGroundElevation()
Returns the elevation of the bottom of this piece of furniture from the ground according to the elevation of its level.

Since:
3.4

setElevation

public void setElevation(float elevation)
Sets the elevation of this piece of furniture on its level. Once this piece is updated, listeners added to this piece will receive a change notification.


isMovable

public boolean isMovable()
Returns true if this piece of furniture is movable.

Specified by:
isMovable in interface PieceOfFurniture

setMovable

public void setMovable(boolean movable)
Sets whether this piece is movable or not.

Since:
3.0

isDoorOrWindow

public boolean isDoorOrWindow()
Returns true if this piece of furniture is a door or a window. As this method existed before HomeDoorOrWindow class, you shouldn't rely on the value returned by this method to guess if a piece is an instance of DoorOrWindow class.

Specified by:
isDoorOrWindow in interface PieceOfFurniture

getIcon

public Content getIcon()
Returns the icon of this piece of furniture.

Specified by:
getIcon in interface PieceOfFurniture

getPlanIcon

public Content getPlanIcon()
Returns the icon of this piece of furniture displayed in plan or null.

Specified by:
getPlanIcon in interface PieceOfFurniture
Since:
2.2

getModel

public Content getModel()
Returns the 3D model of this piece of furniture.

Specified by:
getModel in interface PieceOfFurniture

setModelMaterials

public void setModelMaterials(HomeMaterial[] modelMaterials)
Sets the materials of the 3D model of this piece of furniture. Once this piece is updated, listeners added to this piece will receive a change notification.

Parameters:
modelMaterials - the materials of the 3D model or null if they shouldn't be changed
Throws:
IllegalStateException - if this piece of furniture isn't texturable

getModelMaterials

public HomeMaterial[] getModelMaterials()
Returns the materials applied to the 3D model of this piece of furniture.

Returns:
the materials of the 3D model or null if the individual materials of the 3D model are not modified.
Since:
4.0

getColor

public Integer getColor()
Returns the color of this piece of furniture.

Specified by:
getColor in interface PieceOfFurniture
Returns:
the color of the piece as RGB code or null if piece color is unchanged.

setColor

public void setColor(Integer color)
Sets the color of this piece of furniture. Once this piece is updated, listeners added to this piece will receive a change notification.

Parameters:
color - the color of this piece of furniture or null if piece color is the default one
Throws:
IllegalStateException - if this piece of furniture isn't texturable

getTexture

public HomeTexture getTexture()
Returns the texture of this piece of furniture.

Returns:
the texture of the piece or null if piece texture is unchanged.
Since:
2.3

setTexture

public void setTexture(HomeTexture texture)
Sets the texture of this piece of furniture. Once this piece is updated, listeners added to this piece will receive a change notification.

Parameters:
texture - the texture of this piece of furniture or null if piece texture is the default one
Throws:
IllegalStateException - if this piece of furniture isn't texturable
Since:
2.3

getShininess

public Float getShininess()
Returns the shininess of this piece of furniture.

Returns:
a value between 0 (matt) and 1 (very shiny) or null if piece shininess is unchanged.
Since:
3.0

setShininess

public void setShininess(Float shininess)
Sets the shininess of this piece of furniture or null if piece shininess is unchanged. Once this piece is updated, listeners added to this piece will receive a change notification.

Throws:
IllegalStateException - if this piece of furniture isn't texturable
Since:
3.0

isResizable

public boolean isResizable()
Returns true if this piece is resizable.

Specified by:
isResizable in interface PieceOfFurniture

isDeformable

public boolean isDeformable()
Returns true if this piece is deformable.

Specified by:
isDeformable in interface PieceOfFurniture
Since:
3.0

isTexturable

public boolean isTexturable()
Returns false if this piece should always keep the same color or texture.

Specified by:
isTexturable in interface PieceOfFurniture
Since:
3.0

getPrice

public BigDecimal getPrice()
Returns the price of this piece of furniture or null.

Specified by:
getPrice in interface PieceOfFurniture

setPrice

public void setPrice(BigDecimal price)
Sets the price of this piece of furniture. Once this piece is updated, listeners added to this piece will receive a change notification.

Since:
4.0

getValueAddedTaxPercentage

public BigDecimal getValueAddedTaxPercentage()
Returns the Value Added Tax percentage applied to the price of this piece of furniture.

Specified by:
getValueAddedTaxPercentage in interface PieceOfFurniture

getValueAddedTax

public BigDecimal getValueAddedTax()
Returns the Value Added Tax applied to the price of this piece of furniture.


getPriceValueAddedTaxIncluded

public BigDecimal getPriceValueAddedTaxIncluded()
Returns the price of this piece of furniture, Value Added Tax included.


getCurrency

public String getCurrency()
Returns the price currency, noted with ISO 4217 code, or null if it has no price or default currency should be used.

Specified by:
getCurrency in interface PieceOfFurniture
Since:
3.4

isVisible

public boolean isVisible()
Returns true if this piece of furniture is visible.


setVisible

public void setVisible(boolean visible)
Sets whether this piece of furniture is visible or not. Once this piece is updated, listeners added to this piece will receive a change notification.


getX

public float getX()
Returns the abscissa of the center of this piece of furniture.


setX

public void setX(float x)
Sets the abscissa of the center of this piece. Once this piece is updated, listeners added to this piece will receive a change notification.


getY

public float getY()
Returns the ordinate of the center of this piece of furniture.


setY

public void setY(float y)
Sets the ordinate of the center of this piece. Once this piece is updated, listeners added to this piece will receive a change notification.


getAngle

public float getAngle()
Returns the angle in radians of this piece of furniture.


setAngle

public void setAngle(float angle)
Sets the angle of this piece. Once this piece is updated, listeners added to this piece will receive a change notification.


isModelMirrored

public boolean isModelMirrored()
Returns true if the model of this piece should be mirrored.


setModelMirrored

public void setModelMirrored(boolean modelMirrored)
Sets whether the model of this piece of furniture is mirrored or not. Once this piece is updated, listeners added to this piece will receive a change notification.

Throws:
IllegalStateException - if this piece of furniture isn't resizable

getModelRotation

public float[][] getModelRotation()
Returns the rotation 3 by 3 matrix of this piece of furniture that ensures its model is correctly oriented.

Specified by:
getModelRotation in interface PieceOfFurniture

getStaircaseCutOutShape

public String getStaircaseCutOutShape()
Returns the shape used to cut out upper levels when they intersect with the piece like a staircase.

Specified by:
getStaircaseCutOutShape in interface PieceOfFurniture
Since:
3.4

isBackFaceShown

public boolean isBackFaceShown()
Returns true if the back face of the piece of furniture model should be displayed.

Specified by:
isBackFaceShown in interface PieceOfFurniture

getLevel

public Level getLevel()
Returns the level which this piece belongs to.

Specified by:
getLevel in interface Elevatable
Since:
3.4

setLevel

public void setLevel(Level level)
Sets the level of this piece of furniture. Once this piece is updated, listeners added to this piece will receive a change notification.

Since:
3.4

isAtLevel

public boolean isAtLevel(Level level)
Returns true if this piece is visible at the given level.

Specified by:
isAtLevel in interface Elevatable
Since:
3.4

getPoints

public float[][] getPoints()
Returns the points of each corner of a piece.

Specified by:
getPoints in interface Selectable
Returns:
an array of the 4 (x,y) coordinates of the piece corners.

intersectsRectangle

public boolean intersectsRectangle(float x0,
                                   float y0,
                                   float x1,
                                   float y1)
Returns true if this piece intersects with the horizontal rectangle which opposite corners are at points (x0, y0) and (x1, y1).

Specified by:
intersectsRectangle in interface Selectable

containsPoint

public boolean containsPoint(float x,
                             float y,
                             float margin)
Returns true if this piece contains the point at (x, y) with a given margin.

Specified by:
containsPoint in interface Selectable

isPointAt

public boolean isPointAt(float x,
                         float y,
                         float margin)
Returns true if one of the corner of this piece is the point at (x, y) with a given margin.


isTopLeftPointAt

public boolean isTopLeftPointAt(float x,
                                float y,
                                float margin)
Returns true if the top left point of this piece is the point at (x, y) with a given margin, and if that point is closer to top left point than to top right and bottom left points.


isTopRightPointAt

public boolean isTopRightPointAt(float x,
                                 float y,
                                 float margin)
Returns true if the top right point of this piece is the point at (x, y) with a given margin, and if that point is closer to top right point than to top left and bottom right points.


isBottomLeftPointAt

public boolean isBottomLeftPointAt(float x,
                                   float y,
                                   float margin)
Returns true if the bottom left point of this piece is the point at (x, y) with a given margin, and if that point is closer to bottom left point than to top left and bottom right points.


isBottomRightPointAt

public boolean isBottomRightPointAt(float x,
                                    float y,
                                    float margin)
Returns true if the bottom right point of this piece is the point at (x, y) with a given margin, and if that point is closer to top left point than to top right and bottom left points.


isNameCenterPointAt

public boolean isNameCenterPointAt(float x,
                                   float y,
                                   float margin)
Returns true if the center point at which is displayed the name of this piece is equal to the point at (x, y) with a given margin.


move

public void move(float dx,
                 float dy)
Moves this piece of (dx, dy) units.

Specified by:
move in interface Selectable

clone

public HomePieceOfFurniture clone()
Returns a clone of this piece.

Specified by:
clone in interface Selectable
Overrides:
clone in class Object

getFurnitureComparator

public static Comparator<HomePieceOfFurniture> getFurnitureComparator(HomePieceOfFurniture.SortableProperty property)
Returns a comparator that compares furniture on a given property in ascending order.


Sweet Home 3D 4.0

© Copyrights 2006-2013 eTeks - All rights reserved
Distributed under GNU General Public License