Package org.mapsforge.map.model
Class DisplayModel
java.lang.Object
org.mapsforge.map.model.common.Observable
org.mapsforge.map.model.DisplayModel
- All Implemented Interfaces:
ObservableInterface
- Direct Known Subclasses:
FixedTileSizeDisplayModel
Encapsulates the display characteristics for a MapView, such as tile size and background color. The size of map tiles
is used to adapt to devices with differing pixel densities and users with different preferences: The larger the tile,
the larger everything is rendered, the effect is one of effectively stretching everything. The default device
dependent scale factor is determined at the GraphicFactory level, while the DisplayModel allows further adaptation to
cater for user needs or application development (maybe a small map and large map, or to prevent upscaling for
downloaded tiles that do not scale well).
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanintReturns the background color.static floatGet the default scale factor for all newly created DisplayModels.static floatReturns the device scale factor.org.mapsforge.core.graphics.FilterColor filtering in map rendering.intReturns the maximum width of text beyond which the text is broken into lines.floatReturns the overall scale factor.Theme callback.intWidth and height of a map tile in pixel after system and user scaling is applied.intGets the tile size multiple.floatReturns the user scale factor.inthashCode()voidsetBackgroundColor(int color) Set the background color.static voidsetDefaultUserScaleFactor(float scaleFactor) Set the default scale factor for all newly created DisplayModels, so can be used to apply user settings from a device.static voidsetDeviceScaleFactor(float scaleFactor) Set the device scale factor.voidsetFilter(org.mapsforge.core.graphics.Filter filter) Color filtering in map rendering.voidsetFixedTileSize(int tileSize) Forces the tile size to a fixed valuevoidsetMaxTextWidthFactor(float maxTextWidthFactor) Sets the factor to compute the maxTextWidthvoidsetThemeCallback(ThemeCallback themeCallback) Theme callback.voidsetTileSizeMultiple(int multiple) Clamps the tile size to a multiple of the supplied value.voidsetUserScaleFactor(float scaleFactor) Set the user scale factor.Methods inherited from class org.mapsforge.map.model.common.Observable
addObserver, notifyObservers, removeObserver
-
Field Details
-
symbolScale
public static float symbolScaleThe symbol scale.
-
-
Constructor Details
-
DisplayModel
public DisplayModel()
-
-
Method Details
-
getDefaultUserScaleFactor
public static float getDefaultUserScaleFactor()Get the default scale factor for all newly created DisplayModels.- Returns:
- the default scale factor to be applied to all new DisplayModels.
-
getDeviceScaleFactor
public static float getDeviceScaleFactor()Returns the device scale factor.- Returns:
- the device scale factor.
-
setDefaultUserScaleFactor
public static void setDefaultUserScaleFactor(float scaleFactor) Set the default scale factor for all newly created DisplayModels, so can be used to apply user settings from a device.- Parameters:
scaleFactor- the default scale factor to be applied to all new DisplayModels.
-
setDeviceScaleFactor
public static void setDeviceScaleFactor(float scaleFactor) Set the device scale factor.- Parameters:
scaleFactor- the device scale factor.
-
equals
-
getBackgroundColor
public int getBackgroundColor()Returns the background color.- Returns:
- the background color.
-
getFilter
public org.mapsforge.core.graphics.Filter getFilter()Color filtering in map rendering. -
getMaxTextWidth
public int getMaxTextWidth()Returns the maximum width of text beyond which the text is broken into lines.- Returns:
- the maximum text width
-
getScaleFactor
public float getScaleFactor()Returns the overall scale factor.- Returns:
- the combined device/user scale factor.
-
getThemeCallback
Theme callback. -
getTileSize
public int getTileSize()Width and height of a map tile in pixel after system and user scaling is applied. -
getTileSizeMultiple
public int getTileSizeMultiple()Gets the tile size multiple. -
getUserScaleFactor
public float getUserScaleFactor()Returns the user scale factor.- Returns:
- the user scale factor.
-
hashCode
public int hashCode() -
setBackgroundColor
public void setBackgroundColor(int color) Set the background color.- Parameters:
color- the color to use.
-
setFilter
public void setFilter(org.mapsforge.core.graphics.Filter filter) Color filtering in map rendering. -
setFixedTileSize
public void setFixedTileSize(int tileSize) Forces the tile size to a fixed value- Parameters:
tileSize- the fixed tile size to use if != 0, if 0 the tile size will be calculated
-
setMaxTextWidthFactor
public void setMaxTextWidthFactor(float maxTextWidthFactor) Sets the factor to compute the maxTextWidth- Parameters:
maxTextWidthFactor- to compute maxTextWidth
-
setThemeCallback
Theme callback. -
setTileSizeMultiple
public void setTileSizeMultiple(int multiple) Clamps the tile size to a multiple of the supplied value. The default value of tileSizeMultiple will be overwritten with this call. The default value should be good enough for most applications and setting this value should rarely be required. Applications that allow external renderthemes might negatively impact their layout as area fills may depend on the default value being used.- Parameters:
multiple- tile size multiple
-
setUserScaleFactor
public void setUserScaleFactor(float scaleFactor) Set the user scale factor.- Parameters:
scaleFactor- the user scale factor to use.
-