OpenSpace. ScreenBounds

Instances of this class represent bounding boxes.  Data stored as left, bottom, right, top floats.  All values are initialized to null, however, you should make sure you set them before using the bounds for anything.

Possible use case

bounds = new OpenSpace.ScreenBounds();
bounds.extend(new OpenSpace.ScreenPoint(40,50));
bounds.extend(new OpenSpace.ScreenPoint(50,60));
bounds.toBBOX(); // returns 40,50,50,60

Inherits

Summary
Instances of this class represent bounding boxes.
{Number} The spatial reference system
Construct a new Screen bounds object.
{String} String representation of bounds object.
{Array} array of left, top, right, bottom
{Float} The width of the bounds
{Float} The height of the bounds (bottom minus top).
{OpenSpace.ScreenSize} The size of the box.
{OpenSpace.ScreenPoint} The center of the bounds in pixel space.
Extend the bounds to include the point, lonlat, or bounds specified.
Alternative constructor that builds a new OpenLayers.Bounds from a parameter string
Alternative constructor that builds a new OpenLayers.Bounds from an array
Alternative constructor that builds a new OpenSpace.ScreenBounds from a size

Properties

srs

{Number} The spatial reference system

Constructor

OpenSpace. ScreenBounds

Construct a new Screen bounds object.

Parameters

left{Float} The left bounds of the box.  Note that for width calculations, this is assumed to be less than the right value.
top{Float} The top bounds of the box.  Note that for height calculations, this is assumed to be less than the bottom value.
right{Float} The right bounds.
bottom{Float} The bottom bounds.

Functions

toString

toString:function()

Returns

{String} String representation of bounds object.  (ex.<i>”left-top=(5,42) right-bottom=(10,45)”</i>)

toArray

toArray: function()

Returns

{Array} array of left, top, right, bottom

getWidth

getWidth:function()

Returns

{Float} The width of the bounds

getHeight

getHeight:function()

Returns

{Float} The height of the bounds (bottom minus top).

getSize

getSize:function()

Returns

{OpenSpace.ScreenSize} The size of the box.

getCenterPixel

getCenterPixel:function()

Returns

{OpenSpace.ScreenPoint} The center of the bounds in pixel space.

add

add:function(x,
y)

Parameters

x{Float}
y{Float}

Returns

{OpenSpace.ScreenBounds} A new bounds whose coordinates are the same as this, but shifted by the passed-in x and y values.

extend

extend:function(object)

Extend the bounds to include the point, lonlat, or bounds specified.  Note, this function assumes that left < right and bottom < top.

Parameters

object{Object} Can be LonLat, Point, or Bounds

containsPixel

containsPixel:function(px,
inclusive)

Parameters

px{OpenSpace.ScreenPoint}
inclusive{Boolean} Whether or not to include the border.  Default is true.

Returns

{Boolean} The passed-in pixel is within this bounds.

contains

contains:function(x,
y,
inclusive)

Parameters

x{Float}
y{Float}
inclusive{Boolean} Whether or not to include the border.  Default is true.

Returns

{Boolean} Whether or not the passed-in coordinates are within this bounds.

intersectsBounds

intersectsBounds:function(bounds,
inclusive)

Parameters

bounds{OpenSpace.ScreenBounds}
inclusive{<Boolean>} Whether or not to include the border.  Default is true.

Returns

{Boolean} The passed-in OpenLayers.Bounds object intersects this bounds.  Simple math just check if either contains the other, allowing for partial.

containsBounds

containsBounds:function(bounds,
partial,
inclusive)
bounds{OpenSpace.ScreenBounds}
partial{<Boolean>} If true, only part of passed-in bounds needs be within this bounds.  If false, the entire passed-in bounds must be within.  Default is false
inclusive{<Boolean>} Whether or not to include the border.  Default is true.

Returns

{Boolean} The passed-in bounds object is contained within this bounds.

determineQuadrant

determineQuadrant: function(px)

Parameters

px{OpenSpace.ScreenPoint}

Returns

{String} The quadrant (“br” “tr” “tl” “bl”) of the bounds in which the coordinate lies.

fromString

OpenSpace.ScreenBounds.fromString = function(str)

Alternative constructor that builds a new OpenLayers.Bounds from a parameter string

Parameters

str{String}Comma-separated bounds string.  (ex.  <i>”5,42,10,45”</i>)

Returns

{OpenLayers.Bounds} New bounds object built from the passed-in String.

fromArray

OpenSpace.ScreenBounds.fromArray = function(bbox)

Alternative constructor that builds a new OpenLayers.Bounds from an array

Parameters

bbox{Array(Float)} Array of bounds values (ex.  <i>[5,42,10,45]</i>)

Returns

{OpenSpace.ScreenBounds} New bounds object built from the passed-in Array.

fromSize

OpenSpace.ScreenBounds.fromSize = function(size)

Alternative constructor that builds a new OpenSpace.ScreenBounds from a size

Parameters

size{OpenSpace.ScreenSize}

Returns

{OpenSpace.ScreenBounds} New bounds object built from the passed-in size.

toString:function()
{String} String representation of bounds object.
toArray: function()
{Array} array of left, top, right, bottom
getWidth:function()
{Float} The width of the bounds
getHeight:function()
{Float} The height of the bounds (bottom minus top).
getSize:function()
{OpenSpace.ScreenSize} The size of the box.
Instances of this class represent a width/height pair
getCenterPixel:function()
{OpenSpace.ScreenPoint} The center of the bounds in pixel space.
This class represents a screen coordinate, in x and y coordinates
add:function(x,
y)
extend:function(object)
Extend the bounds to include the point, lonlat, or bounds specified.
containsPixel:function(px,
inclusive)
contains:function(x,
y,
inclusive)
intersectsBounds:function(bounds,
inclusive)
containsBounds:function(bounds,
partial,
inclusive)
determineQuadrant: function(px)
OpenSpace.ScreenBounds.fromString = function(str)
Alternative constructor that builds a new OpenLayers.Bounds from a parameter string
OpenSpace.ScreenBounds.fromArray = function(bbox)
Alternative constructor that builds a new OpenLayers.Bounds from an array
OpenSpace.ScreenBounds.fromSize = function(size)
Alternative constructor that builds a new OpenSpace.ScreenBounds from a size
Instances of this class represent bounding boxes.
Construct a new Screen bounds object.