All Implemented Interfaces:
Serializable

public class ScaleControl extends Control
A control that displays a scale indicator on the map. The control can be displayed as a simple scale line or as a more detailed scale bar with segments.
See Also:
  • Constructor Details

    • ScaleControl

      public ScaleControl()
  • Method Details

    • getType

      public String getType()
      Description copied from class: AbstractConfigurationObject
      The unique type name of this class. Used by the client-side synchronization mechanism to determine which OpenLayers class to synchronize into.
      Specified by:
      getType in class AbstractConfigurationObject
    • getMinWidth

      public int getMinWidth()
      Returns the minimum width of the scale control in pixels.
      Returns:
      the minimum width in pixels
    • setMinWidth

      public void setMinWidth(int minWidth)
      Sets the minimum width of the scale control in pixels. Default value is 64.
      Parameters:
      minWidth - the minimum width in pixels
    • getMaxWidth

      public Integer getMaxWidth()
      Returns the maximum width of the scale control in pixels, or null if no maximum is set.
      Returns:
      the maximum width in pixels, or null
    • setMaxWidth

      public void setMaxWidth(Integer maxWidth)
      Sets the maximum width of the scale control in pixels. Set to null to remove the limit. Default value is null.
      Parameters:
      maxWidth - the maximum width in pixels, or null for no limit
    • getUnits

      public ScaleControl.Unit getUnits()
      Returns the units used for the scale control.
      Returns:
      the units
    • setUnits

      public void setUnits(ScaleControl.Unit units)
      Sets the units to use for the scale control. Default value is ScaleControl.Unit.METRIC.
      Parameters:
      units - the units, not null
      Throws:
      NullPointerException - if units is null
    • getDisplayMode

      public ScaleControl.DisplayMode getDisplayMode()
      Returns the display mode of the scale control.
      Returns:
      the display mode
    • setDisplayMode

      public void setDisplayMode(ScaleControl.DisplayMode displayMode)
      Sets the display mode of the scale control. Default value is ScaleControl.DisplayMode.LINE.
      Parameters:
      displayMode - the display mode, not null
      Throws:
      NullPointerException - if displayMode is null
    • getScaleBarSteps

      public int getScaleBarSteps()
      Returns the number of steps (segments) in the scale bar. This is only used when getDisplayMode() returns ScaleControl.DisplayMode.BAR.
      Returns:
      the number of scale bar steps
    • setScaleBarSteps

      public void setScaleBarSteps(int scaleBarSteps)
      Sets the number of steps (segments) for the scale bar. This is only used when setDisplayMode(DisplayMode) is set to ScaleControl.DisplayMode.BAR. Default value is 4.
      Parameters:
      scaleBarSteps - the number of scale bar steps
    • isScaleBarRatioVisible

      public boolean isScaleBarRatioVisible()
      Returns whether to show the ratio between the size of the scale and the real distance on the ground below the scale bar. This is only used when getDisplayMode() returns ScaleControl.DisplayMode.BAR.
      Returns:
      true if the ratio is shown below the scale bar
    • setScaleBarRatioVisible

      public void setScaleBarRatioVisible(boolean scaleBarRatioVisible)
      Sets whether to show the ratio between the size of the scale and the real distance on the ground below the scale bar. This is only used when setDisplayMode(DisplayMode) is set to ScaleControl.DisplayMode.BAR. Default value is false.
      Parameters:
      scaleBarRatioVisible - true to show the ratio below the scale bar