Package org.mozilla.geckoview
Class ScreenLength
Object
org.mozilla.geckoview.ScreenLength
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.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Units represent the entire scrollable documents height.static final int
Units represent the entire scrollable documents width.static final int
Pixel units.static final int
Units are in visual viewport height.static final int
Units are in visual viewport width. -
Method Summary
Modifier and TypeMethodDescriptionstatic ScreenLength
bottom()
Create a ScreenLength of the documents height.static ScreenLength
fromPixels
(double value) Create a ScreenLength of a specific length.static ScreenLength
fromVisualViewportHeight
(double value) Create a ScreenLength that uses the visual viewport width as units.static ScreenLength
fromVisualViewportWidth
(double value) Create a ScreenLength that uses the visual viewport width as units.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
double
getValue()
Returns the scalar value used to calculate length.static ScreenLength
top()
Create a ScreenLength of zero pixels length.static ScreenLength
zero()
Create a ScreenLength of zero pixels length.
-
Field Details
-
PIXEL
public static final int PIXELPixel units.- See Also:
-
VISUAL_VIEWPORT_WIDTH
public static final int VISUAL_VIEWPORT_WIDTHUnits 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_HEIGHTUnits 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_WIDTHUnits 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_HEIGHTUnits 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
Create a ScreenLength of zero pixels length. Type isPIXEL
.- Returns:
- ScreenLength of zero length.
-
top
Create a ScreenLength of zero pixels length. Type isPIXEL
. Can be used to scroll to the top of a page when used with PanZoomController.scrollTo()- Returns:
- ScreenLength of zero length.
-
bottom
Create a ScreenLength of the documents height. Type isDOCUMENT_HEIGHT
. Can be used to scroll to the bottom of a page when used withPanZoomController.scrollTo(ScreenLength, ScreenLength)
- Returns:
- ScreenLength of document height.
-
fromPixels
Create a ScreenLength of a specific length. Type isPIXEL
.- Parameters:
value
- Pixel length.- Returns:
- ScreenLength of document height.
-
fromVisualViewportWidth
Create a ScreenLength that uses the visual viewport width as units. Type isVISUAL_VIEWPORT_WIDTH
. Can be used withPanZoomController.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
Create a ScreenLength that uses the visual viewport width as units. Type isVISUAL_VIEWPORT_HEIGHT
. Can be used withPanZoomController.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 bygetType()
- 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.
-