Sweet Home 3D 4.0

com.eteks.sweethome3d.model
Class UserPreferences

java.lang.Object
  extended by com.eteks.sweethome3d.model.UserPreferences
Direct Known Subclasses:
AppletUserPreferences, DefaultUserPreferences, FileUserPreferences

public abstract class UserPreferences
extends Object

User preferences.

Author:
Emmanuel Puybaret

Nested Class Summary
static class UserPreferences.Property
          The properties of user preferences that may change.
 
Field Summary
static String FURNITURE_LIBRARY_TYPE
           
static String LANGUAGE_LIBRARY_TYPE
           
static String TEXTURES_LIBRARY_TYPE
           
 
Constructor Summary
UserPreferences()
          Creates user preferences.
 
Method Summary
 void addAutoCompletionString(String property, String autoCompletionString)
          Adds the given string to the list of the strings used in auto completion of a property and notifies listeners of this change.
abstract  void addFurnitureLibrary(String furnitureLibraryLocation)
          Adds furnitureLibraryName to furniture catalog to make the furniture it contains available.
abstract  void addLanguageLibrary(String languageLibraryLocation)
          Adds the language library to make the languages it contains available to supported languages.
 void addPropertyChangeListener(UserPreferences.Property property, PropertyChangeListener listener)
          Adds the listener in parameter to these preferences.
abstract  void addTexturesLibrary(String texturesLibraryLocation)
          Adds the textures library at the given location to textures catalog to make the textures it contains available.
abstract  boolean furnitureLibraryExists(String furnitureLibraryLocation)
          Returns true if the furniture library at the given location exists.
 List<String> getAutoCompletedProperties()
          Returns the list of properties with auto completion strings.
 List<String> getAutoCompletionStrings(String property)
          Returns the strings that may be used for the auto completion of the given property.
 int getAutoSaveDelayForRecovery()
          Returns the delay between two automatic save operations of homes for recovery purpose.
 String getCurrency()
          Returns the default currency in use, noted with ISO 4217 code, or null if prices aren't used in application.
 String[] getDefaultSupportedLanguages()
          Returns the array of default available languages in Sweet Home 3D.
 TextStyle getDefaultTextStyle(Class<? extends Selectable> selectableClass)
          Returns the default text style of a class of selectable item.
 FurnitureCatalog getFurnitureCatalog()
          Returns the furniture catalog.
 String getLanguage()
          Returns the preferred language to display information, noted with an ISO 639 code that may be followed by an underscore and an ISO 3166 code.
 LengthUnit getLengthUnit()
          Returns the length unit currently in use.
abstract  List<Library> getLibraries()
          Returns the libraries available in user preferences.
 String getLocalizedString(Class<?> resourceClass, String resourceKey, Object... resourceParameters)
          Returns the string matching resourceKey in current language in the context of resourceClass.
 String getLocalizedString(String resourceFamily, String resourceKey, Object... resourceParameters)
          Returns the string matching resourceKey in current language for the given resource family.
 float getNewFloorThickness()
          Returns default thickness of the floor of new levels in home.
 float getNewWallHeight()
          Returns default wall height of new home walls.
 TextureImage getNewWallPattern()
          Returns the pattern used for new walls in plan or null if it's not set.
 float getNewWallThickness()
          Returns default thickness of new walls in home.
 PatternsCatalog getPatternsCatalog()
          Returns the patterns catalog available to fill plan areas.
 List<Integer> getRecentColors()
          Returns an unmodifiable list of the recent colors.
 List<String> getRecentHomes()
          Returns an unmodifiable list of the recent homes.
 int getRecentHomesMaxCount()
          Returns the maximum count of homes that should be proposed to the user.
 List<ClassLoader> getResourceClassLoaders()
          Returns the class loaders through which localized strings returned by getLocalizedString might be loaded.
 String[] getSupportedLanguages()
          Returns the array of available languages in Sweet Home 3D including languages in libraries.
 TexturesCatalog getTexturesCatalog()
          Returns the textures catalog.
 Long getUpdatesMinimumDate()
          Returns the minimum date of updates that may interest user.
 TextureImage getWallPattern()
          Returns the wall pattern in plan used by default.
 boolean isActionTipIgnored(String actionKey)
          Returns whether an action tip should be ignored or not.
 boolean isAerialViewCenteredOnSelectionEnabled()
          Returns whether aerial view should be centered on selection or not.
 boolean isCheckUpdatesEnabled()
          Returns true if updates should be checked.
 boolean isFurnitureCatalogViewedInTree()
          Returns true if the furniture catalog should be viewed in a tree.
 boolean isFurnitureViewedFromTop()
          Returns true if furniture should be viewed from its top in plan.
 boolean isGridVisible()
          Returns true if plan grid visible.
 boolean isLanguageEditable()
          Returns true if the language in preferences can be set.
 boolean isMagnetismEnabled()
          Returns true if magnetism is enabled.
 boolean isNavigationPanelVisible()
          Returns true if the navigation panel should be displayed.
 boolean isRoomFloorColoredOrTextured()
          Returns true if room floors should be rendered with color or texture in plan.
 boolean isRulersVisible()
          Returns true if rulers are visible.
abstract  boolean languageLibraryExists(String languageLibraryLocation)
          Returns true if the language library at the given location exists.
 void removePropertyChangeListener(UserPreferences.Property property, PropertyChangeListener listener)
          Removes the listener in parameter from these preferences.
 void resetIgnoredActionTips()
          Resets the ignore flag of action tips.
 void setActionTipIgnored(String actionKey)
          Sets which action tip should be ignored.
 void setAerialViewCenteredOnSelectionEnabled(boolean aerialViewCenteredOnSelectionEnabled)
          Sets whether aerial view should be centered on selection or not.
 void setAutoCompletionStrings(String property, List<String> autoCompletionStrings)
          Sets the auto completion strings list of the given property and notifies listeners of this change.
 void setAutoSaveDelayForRecovery(int autoSaveDelayForRecovery)
          Sets the delay between two automatic save operations of homes for recovery purpose.
 void setCheckUpdatesEnabled(boolean updatesChecked)
          Sets whether updates should be checked or not.
protected  void setCurrency(String currency)
          Sets the default currency in use.
 void setFloorColoredOrTextured(boolean roomFloorColoredOrTextured)
          Sets whether room floors should be rendered with color or texture, and notifies listeners of this change.
protected  void setFurnitureCatalog(FurnitureCatalog catalog)
          Sets furniture catalog.
 void setFurnitureCatalogViewedInTree(boolean furnitureCatalogViewedInTree)
          Sets whether the furniture catalog should be viewed in a tree or a different way.
 void setFurnitureViewedFromTop(boolean furnitureViewedFromTop)
          Sets how furniture icon should be displayed in plan, and notifies listeners of this change.
 void setGridVisible(boolean gridVisible)
          Sets whether plan grid is visible or not, and notifies listeners of this change.
 void setLanguage(String language)
          If language can be changed, sets the preferred language to display information, changes current default locale accordingly and notifies listeners of this change.
 void setMagnetismEnabled(boolean magnetismEnabled)
          Sets whether magnetism is enabled or not, and notifies listeners of this change.
 void setNavigationPanelVisible(boolean navigationPanelVisible)
          Sets whether the navigation panel should be displayed or not.
 void setNewFloorThickness(float newFloorThickness)
          Sets default thickness of the floor of new levels in home, and notifies listeners of this change.
 void setNewWallHeight(float newWallHeight)
          Sets default wall height of new walls, and notifies listeners of this change.
 void setNewWallPattern(TextureImage newWallPattern)
          Sets how new walls should be displayed in plan, and notifies listeners of this change.
 void setNewWallThickness(float newWallThickness)
          Sets default thickness of new walls in home, and notifies listeners of this change.
protected  void setPatternsCatalog(PatternsCatalog catalog)
          Sets the patterns available to fill plan areas.
 void setRecentColors(List<Integer> recentColors)
          Sets the recent colors list and notifies listeners of this change.
 void setRecentHomes(List<String> recentHomes)
          Sets the recent homes list and notifies listeners of this change.
 void setRulersVisible(boolean rulersVisible)
          Sets whether rulers are visible or not, and notifies listeners of this change.
protected  void setSupportedLanguages(String[] supportedLanguages)
          Returns the array of available languages in Sweet Home 3D.
protected  void setTexturesCatalog(TexturesCatalog catalog)
          Sets textures catalog.
 void setUnit(LengthUnit unit)
          Changes the unit currently in use, and notifies listeners of this change.
 void setUpdatesMinimumDate(Long updatesMinimumDate)
          Sets the minimum date of updates that may interest user, and notifies listeners of this change.
 void setWallPattern(TextureImage wallPattern)
          Sets how walls should be displayed in plan by default, and notifies listeners of this change.
abstract  boolean texturesLibraryExists(String texturesLibraryLocation)
          Returns true if the textures library at the given location exists.
abstract  void write()
          Writes user preferences.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FURNITURE_LIBRARY_TYPE

public static final String FURNITURE_LIBRARY_TYPE
See Also:
Constant Field Values

TEXTURES_LIBRARY_TYPE

public static final String TEXTURES_LIBRARY_TYPE
See Also:
Constant Field Values

LANGUAGE_LIBRARY_TYPE

public static final String LANGUAGE_LIBRARY_TYPE
See Also:
Constant Field Values
Constructor Detail

UserPreferences

public UserPreferences()
Creates user preferences.
Caution: during creation, the default locale will be updated if it doesn't belong to the supported ones.

Method Detail

write

public abstract void write()
                    throws RecorderException
Writes user preferences.

Throws:
RecorderException - if user preferences couldn'y be saved.

addPropertyChangeListener

public void addPropertyChangeListener(UserPreferences.Property property,
                                      PropertyChangeListener listener)
Adds the listener in parameter to these preferences.
Caution: a user preferences instance generally exists during all the application ; therefore you should take care of not bounding permanently listeners to this object (for example, do not create anonymous listeners on user preferences in classes depending on an edited home).


removePropertyChangeListener

public void removePropertyChangeListener(UserPreferences.Property property,
                                         PropertyChangeListener listener)
Removes the listener in parameter from these preferences.


getFurnitureCatalog

public FurnitureCatalog getFurnitureCatalog()
Returns the furniture catalog.


setFurnitureCatalog

protected void setFurnitureCatalog(FurnitureCatalog catalog)
Sets furniture catalog.


getTexturesCatalog

public TexturesCatalog getTexturesCatalog()
Returns the textures catalog.


setTexturesCatalog

protected void setTexturesCatalog(TexturesCatalog catalog)
Sets textures catalog.


getPatternsCatalog

public PatternsCatalog getPatternsCatalog()
Returns the patterns catalog available to fill plan areas.


setPatternsCatalog

protected void setPatternsCatalog(PatternsCatalog catalog)
Sets the patterns available to fill plan areas.


getLengthUnit

public LengthUnit getLengthUnit()
Returns the length unit currently in use.


setUnit

public void setUnit(LengthUnit unit)
Changes the unit currently in use, and notifies listeners of this change.

Parameters:
unit - one of the values of Unit.

getLanguage

public String getLanguage()
Returns the preferred language to display information, noted with an ISO 639 code that may be followed by an underscore and an ISO 3166 code.


setLanguage

public void setLanguage(String language)
If language can be changed, sets the preferred language to display information, changes current default locale accordingly and notifies listeners of this change.

Parameters:
language - an ISO 639 code that may be followed by an underscore and an ISO 3166 code (for example fr, de, it, en_US, zh_CN).

isLanguageEditable

public boolean isLanguageEditable()
Returns true if the language in preferences can be set.

Returns:
true except if user.language System property isn't writable.
Since:
3.4

getDefaultSupportedLanguages

public String[] getDefaultSupportedLanguages()
Returns the array of default available languages in Sweet Home 3D.


getSupportedLanguages

public String[] getSupportedLanguages()
Returns the array of available languages in Sweet Home 3D including languages in libraries.

Since:
3.4

setSupportedLanguages

protected void setSupportedLanguages(String[] supportedLanguages)
Returns the array of available languages in Sweet Home 3D.

Since:
3.4

getLocalizedString

public String getLocalizedString(Class<?> resourceClass,
                                 String resourceKey,
                                 Object... resourceParameters)
Returns the string matching resourceKey in current language in the context of resourceClass. If resourceParameters isn't empty the string is considered as a format string, and the returned string will be formatted with these parameters. This implementation searches first the key in a properties file named as resourceClass, then if this file doesn't exist, it searches the key prefixed by resourceClass name and a dot in a package.properties file in the folder matching the package of resourceClass.

Throws:
IllegalArgumentException - if no string for the given key can be found

getLocalizedString

public String getLocalizedString(String resourceFamily,
                                 String resourceKey,
                                 Object... resourceParameters)
Returns the string matching resourceKey in current language for the given resource family. resourceFamily should match the absolute path of a .properties resource family, shouldn't start by a slash and may contain dots '.' or slash '/' as folder separators. If resourceParameters isn't empty the string is considered as a format string, and the returned string will be formatted with these parameters. This implementation searches the key in a properties file named as resourceFamily.

Throws:
IllegalArgumentException - if no string for the given key can be found
Since:
2.3

getResourceClassLoaders

public List<ClassLoader> getResourceClassLoaders()
Returns the class loaders through which localized strings returned by getLocalizedString might be loaded.

Since:
2.3

getCurrency

public String getCurrency()
Returns the default currency in use, noted with ISO 4217 code, or null if prices aren't used in application.


setCurrency

protected void setCurrency(String currency)
Sets the default currency in use.


isFurnitureCatalogViewedInTree

public boolean isFurnitureCatalogViewedInTree()
Returns true if the furniture catalog should be viewed in a tree.

Since:
2.3

setFurnitureCatalogViewedInTree

public void setFurnitureCatalogViewedInTree(boolean furnitureCatalogViewedInTree)
Sets whether the furniture catalog should be viewed in a tree or a different way.

Since:
2.3

isNavigationPanelVisible

public boolean isNavigationPanelVisible()
Returns true if the navigation panel should be displayed.

Since:
2.3

setNavigationPanelVisible

public void setNavigationPanelVisible(boolean navigationPanelVisible)
Sets whether the navigation panel should be displayed or not.

Since:
2.3

setAerialViewCenteredOnSelectionEnabled

public void setAerialViewCenteredOnSelectionEnabled(boolean aerialViewCenteredOnSelectionEnabled)
Sets whether aerial view should be centered on selection or not.

Since:
4.0

isAerialViewCenteredOnSelectionEnabled

public boolean isAerialViewCenteredOnSelectionEnabled()
Returns whether aerial view should be centered on selection or not.

Since:
4.0

isMagnetismEnabled

public boolean isMagnetismEnabled()
Returns true if magnetism is enabled.

Returns:
true by default.

setMagnetismEnabled

public void setMagnetismEnabled(boolean magnetismEnabled)
Sets whether magnetism is enabled or not, and notifies listeners of this change.

Parameters:
magnetismEnabled - true if magnetism is enabled, false otherwise.

isRulersVisible

public boolean isRulersVisible()
Returns true if rulers are visible.

Returns:
true by default.

setRulersVisible

public void setRulersVisible(boolean rulersVisible)
Sets whether rulers are visible or not, and notifies listeners of this change.

Parameters:
rulersVisible - true if rulers are visible, false otherwise.

isGridVisible

public boolean isGridVisible()
Returns true if plan grid visible.

Returns:
true by default.

setGridVisible

public void setGridVisible(boolean gridVisible)
Sets whether plan grid is visible or not, and notifies listeners of this change.

Parameters:
gridVisible - true if grid is visible, false otherwise.

isFurnitureViewedFromTop

public boolean isFurnitureViewedFromTop()
Returns true if furniture should be viewed from its top in plan.

Since:
2.0

setFurnitureViewedFromTop

public void setFurnitureViewedFromTop(boolean furnitureViewedFromTop)
Sets how furniture icon should be displayed in plan, and notifies listeners of this change.

Parameters:
furnitureViewedFromTop - if true the furniture should be viewed from its top.
Since:
2.0

isRoomFloorColoredOrTextured

public boolean isRoomFloorColoredOrTextured()
Returns true if room floors should be rendered with color or texture in plan.

Returns:
false by default.
Since:
2.0

setFloorColoredOrTextured

public void setFloorColoredOrTextured(boolean roomFloorColoredOrTextured)
Sets whether room floors should be rendered with color or texture, and notifies listeners of this change.

Parameters:
roomFloorColoredOrTextured - true if floor color or texture is used, false otherwise.
Since:
2.0

getWallPattern

public TextureImage getWallPattern()
Returns the wall pattern in plan used by default.

Since:
2.0

setWallPattern

public void setWallPattern(TextureImage wallPattern)
Sets how walls should be displayed in plan by default, and notifies listeners of this change.

Since:
2.0

getNewWallPattern

public TextureImage getNewWallPattern()
Returns the pattern used for new walls in plan or null if it's not set.

Since:
4.0

setNewWallPattern

public void setNewWallPattern(TextureImage newWallPattern)
Sets how new walls should be displayed in plan, and notifies listeners of this change.

Since:
4.0

getNewWallThickness

public float getNewWallThickness()
Returns default thickness of new walls in home.


setNewWallThickness

public void setNewWallThickness(float newWallThickness)
Sets default thickness of new walls in home, and notifies listeners of this change.


getNewWallHeight

public float getNewWallHeight()
Returns default wall height of new home walls.


setNewWallHeight

public void setNewWallHeight(float newWallHeight)
Sets default wall height of new walls, and notifies listeners of this change.


getNewFloorThickness

public float getNewFloorThickness()
Returns default thickness of the floor of new levels in home.

Since:
3.4

setNewFloorThickness

public void setNewFloorThickness(float newFloorThickness)
Sets default thickness of the floor of new levels in home, and notifies listeners of this change.

Since:
3.4

isCheckUpdatesEnabled

public boolean isCheckUpdatesEnabled()
Returns true if updates should be checked.

Since:
4.0

setCheckUpdatesEnabled

public void setCheckUpdatesEnabled(boolean updatesChecked)
Sets whether updates should be checked or not.

Since:
4.0

getUpdatesMinimumDate

public Long getUpdatesMinimumDate()
Returns the minimum date of updates that may interest user.

Returns:
the date expressed in millis second since the epoch or null if not defined.
Since:
4.0

setUpdatesMinimumDate

public void setUpdatesMinimumDate(Long updatesMinimumDate)
Sets the minimum date of updates that may interest user, and notifies listeners of this change.

Since:
4.0

getAutoSaveDelayForRecovery

public int getAutoSaveDelayForRecovery()
Returns the delay between two automatic save operations of homes for recovery purpose.

Returns:
a delay in milliseconds or 0 to disable auto save.
Since:
3.0

setAutoSaveDelayForRecovery

public void setAutoSaveDelayForRecovery(int autoSaveDelayForRecovery)
Sets the delay between two automatic save operations of homes for recovery purpose.

Since:
3.0

getRecentHomes

public List<String> getRecentHomes()
Returns an unmodifiable list of the recent homes.


setRecentHomes

public void setRecentHomes(List<String> recentHomes)
Sets the recent homes list and notifies listeners of this change.


getRecentHomesMaxCount

public int getRecentHomesMaxCount()
Returns the maximum count of homes that should be proposed to the user.


setActionTipIgnored

public void setActionTipIgnored(String actionKey)
Sets which action tip should be ignored.
This method should be overridden to store the ignore information. By default it just notifies listeners of this change.


isActionTipIgnored

public boolean isActionTipIgnored(String actionKey)
Returns whether an action tip should be ignored or not.
This method should be overridden to return the the display information stored in setActionTipDisplayed. By default it returns true.


resetIgnoredActionTips

public void resetIgnoredActionTips()
Resets the ignore flag of action tips.
This method should be overridden to clear all the display flags. By default it just notifies listeners of this change.


getDefaultTextStyle

public TextStyle getDefaultTextStyle(Class<? extends Selectable> selectableClass)
Returns the default text style of a class of selectable item.


getAutoCompletionStrings

public List<String> getAutoCompletionStrings(String property)
Returns the strings that may be used for the auto completion of the given property.

Since:
3.4

addAutoCompletionString

public void addAutoCompletionString(String property,
                                    String autoCompletionString)
Adds the given string to the list of the strings used in auto completion of a property and notifies listeners of this change.

Since:
3.4

setAutoCompletionStrings

public void setAutoCompletionStrings(String property,
                                     List<String> autoCompletionStrings)
Sets the auto completion strings list of the given property and notifies listeners of this change.

Since:
3.4

getAutoCompletedProperties

public List<String> getAutoCompletedProperties()
Returns the list of properties with auto completion strings.

Since:
3.4

getRecentColors

public List<Integer> getRecentColors()
Returns an unmodifiable list of the recent colors.

Since:
4.0

setRecentColors

public void setRecentColors(List<Integer> recentColors)
Sets the recent colors list and notifies listeners of this change.

Since:
4.0

addLanguageLibrary

public abstract void addLanguageLibrary(String languageLibraryLocation)
                                 throws RecorderException
Adds the language library to make the languages it contains available to supported languages.

Parameters:
languageLibraryLocation - the location where the library can be found.
Throws:
RecorderException
Since:
2.3

languageLibraryExists

public abstract boolean languageLibraryExists(String languageLibraryLocation)
                                       throws RecorderException
Returns true if the language library at the given location exists.

Parameters:
languageLibraryLocation - the name of the resource to check
Throws:
RecorderException
Since:
2.3

addFurnitureLibrary

public abstract void addFurnitureLibrary(String furnitureLibraryLocation)
                                  throws RecorderException
Adds furnitureLibraryName to furniture catalog to make the furniture it contains available.

Parameters:
furnitureLibraryLocation - the location where the library can be found.
Throws:
RecorderException

furnitureLibraryExists

public abstract boolean furnitureLibraryExists(String furnitureLibraryLocation)
                                        throws RecorderException
Returns true if the furniture library at the given location exists.

Parameters:
furnitureLibraryLocation - the name of the resource to check
Throws:
RecorderException

addTexturesLibrary

public abstract void addTexturesLibrary(String texturesLibraryLocation)
                                 throws RecorderException
Adds the textures library at the given location to textures catalog to make the textures it contains available.

Parameters:
texturesLibraryLocation - the location where the library can be found.
Throws:
RecorderException
Since:
2.3

texturesLibraryExists

public abstract boolean texturesLibraryExists(String texturesLibraryLocation)
                                       throws RecorderException
Returns true if the textures library at the given location exists.

Parameters:
texturesLibraryLocation - the name of the resource to check
Throws:
RecorderException
Since:
2.3

getLibraries

public abstract List<Library> getLibraries()
Returns the libraries available in user preferences.

Since:
4.0

Sweet Home 3D 4.0

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