Class DisplayModel

java.lang.Object
org.mapsforge.map.model.common.Observable
org.mapsforge.map.model.DisplayModel
All Implemented Interfaces:
ObservableInterface
Direct Known Subclasses:
FixedTileSizeDisplayModel

public class DisplayModel extends Observable
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 Details

    • symbolScale

      public static float symbolScale
      The 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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • 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

      public ThemeCallback 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()
      Overrides:
      hashCode in class Object
    • 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

      public void setThemeCallback(ThemeCallback themeCallback)
      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.