Class ScreenLength

Object
org.mozilla.geckoview.ScreenLength

public class ScreenLength extends Object
ScreenLength is a class that represents a length on the screen using different units. The default unit is a pixel. However lengths may be also represented by a dimension of the visual viewport or of the full scroll size of the root document.
  • Field Details

    • PIXEL

      public static final int PIXEL
      Pixel units.
      See Also:
    • VISUAL_VIEWPORT_WIDTH

      public static final int VISUAL_VIEWPORT_WIDTH
      Units are in visual viewport width. If the visual viewport is 100 pixels wide, then a value of 2.0 would represent a length of 200 pixels.
      See Also:
    • VISUAL_VIEWPORT_HEIGHT

      public static final int VISUAL_VIEWPORT_HEIGHT
      Units are in visual viewport height. If the visual viewport is 100 pixels high, then a value of 2.0 would represent a length of 200 pixels.
      See Also:
    • DOCUMENT_WIDTH

      public static final int DOCUMENT_WIDTH
      Units represent the entire scrollable documents width. If the document is 1000 pixels wide then a value of 1.0 would represent 1000 pixels.
      See Also:
    • DOCUMENT_HEIGHT

      public static final int DOCUMENT_HEIGHT
      Units represent the entire scrollable documents height. If the document is 1000 pixels tall then a value of 1.0 would represent 1000 pixels.
      See Also:
  • Method Details

    • zero

      @NonNull @AnyThread public static ScreenLength zero()
      Create a ScreenLength of zero pixels length. Type is PIXEL.
      Returns:
      ScreenLength of zero length.
    • top

      @NonNull @AnyThread public static ScreenLength top()
      Create a ScreenLength of zero pixels length. Type is PIXEL. Can be used to scroll to the top of a page when used with PanZoomController.scrollTo()
      Returns:
      ScreenLength of zero length.
    • bottom

      @NonNull @AnyThread public static ScreenLength bottom()
      Create a ScreenLength of the documents height. Type is DOCUMENT_HEIGHT. Can be used to scroll to the bottom of a page when used with PanZoomController.scrollTo(ScreenLength, ScreenLength)
      Returns:
      ScreenLength of document height.
    • fromPixels

      @NonNull @AnyThread public static ScreenLength fromPixels(double value)
      Create a ScreenLength of a specific length. Type is PIXEL.
      Parameters:
      value - Pixel length.
      Returns:
      ScreenLength of document height.
    • fromVisualViewportWidth

      @NonNull @AnyThread public static ScreenLength fromVisualViewportWidth(double value)
      Create a ScreenLength that uses the visual viewport width as units. Type is VISUAL_VIEWPORT_WIDTH. Can be used with PanZoomController.scrollBy(ScreenLength, ScreenLength) to scroll a value of the width of visual viewport content.
      Parameters:
      value - Factor used to calculate length. A value of 2.0 would indicate a length twice as long as the length of the visual viewports width.
      Returns:
      ScreenLength of specifying a length of value * visual viewport width.
    • fromVisualViewportHeight

      @NonNull @AnyThread public static ScreenLength fromVisualViewportHeight(double value)
      Create a ScreenLength that uses the visual viewport width as units. Type is VISUAL_VIEWPORT_HEIGHT. Can be used with PanZoomController.scrollBy(ScreenLength, ScreenLength) to scroll a value of the height of visual viewport content.
      Parameters:
      value - Factor used to calculate length. A value of 2.0 would indicate a length twice as long as the length of the visual viewports height.
      Returns:
      ScreenLength of specifying a length of value * visual viewport width.
    • getValue

      @AnyThread public double getValue()
      Returns the scalar value used to calculate length. The units of the returned valued are defined by what is returned by getType()
      Returns:
      Scalar value of the length.
    • getType

      @AnyThread public int getType()
      Returns the unit type of the length The length can be one of the following: PIXEL, VISUAL_VIEWPORT_WIDTH, VISUAL_VIEWPORT_HEIGHT, DOCUMENT_WIDTH, DOCUMENT_HEIGHT
      Returns:
      Unit type of the length.