Package gov.nasa.worldwind.geom
Class Viewport
- java.lang.Object
-
- gov.nasa.worldwind.geom.Viewport
-
public class Viewport extends java.lang.Object
Rectangular region in a two-dimensional coordinate system expressed as an origin and dimensions extending from the origin.
-
-
Constructor Summary
Constructors Constructor Description Viewport()
Constructs an empty viewport width X, Y, width and height all zero.Viewport(int x, int y, int width, int height)
Constructs a viewport with a specified origin and dimensions.Viewport(Viewport viewport)
Constructs a viewport with the origin and dimensions of a specified viewport.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(int x, int y)
Indicates whether this viewport contains a specified point.boolean
equals(java.lang.Object o)
int
hashCode()
boolean
intersect(int x, int y, int width, int height)
Computes the intersection of this viewport and a specified viewport, storing the result in this viewport and returning whether or not the viewport intersect.boolean
intersect(Viewport viewport)
Computes the intersection of this viewport and a specified viewport, storing the result in this viewport and returning whether or not the viewport intersect.boolean
intersects(int x, int y, int width, int height)
Indicates whether this viewport intersects a specified viewport.boolean
intersects(Viewport viewport)
Indicates whether this viewport intersects a specified viewport.boolean
isEmpty()
Indicates whether or not this viewport is empty.Viewport
set(int x, int y, int width, int height)
Sets this viewport to the specified origin and dimensions.Viewport
set(Viewport viewport)
Sets this viewport to the origin and dimensions of a specified viewport.Viewport
setEmpty()
Sets this viewport to an empty viewport.java.lang.String
toString()
-
-
-
Constructor Detail
-
Viewport
public Viewport()
Constructs an empty viewport width X, Y, width and height all zero.
-
Viewport
public Viewport(int x, int y, int width, int height)
Constructs a viewport with a specified origin and dimensions.- Parameters:
x
- the X component of the viewport's lower left cornery
- the Y component of the viewport's lower left cornerwidth
- the viewport's widthheight
- the viewport's height
-
Viewport
public Viewport(Viewport viewport)
Constructs a viewport with the origin and dimensions of a specified viewport.- Parameters:
viewport
- the viewport specifying the values- Throws:
java.lang.IllegalArgumentException
- If the viewport is null
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
@NonNull public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
set
public Viewport set(int x, int y, int width, int height)
Sets this viewport to the specified origin and dimensions.- Parameters:
x
- the new X component of the viewport's lower left cornery
- the new Y component of the viewport's lower left cornerwidth
- the viewport's new widthheight
- the viewport's new height- Returns:
- this viewport set to the specified values
-
set
public Viewport set(Viewport viewport)
Sets this viewport to the origin and dimensions of a specified viewport.- Parameters:
viewport
- the viewport specifying the new values- Returns:
- this viewport with its origin and dimensions set to that of the specified viewport
- Throws:
java.lang.IllegalArgumentException
- If the viewport is null
-
setEmpty
public Viewport setEmpty()
Sets this viewport to an empty viewport.- Returns:
- this viewport with its width and height both set to zero
-
isEmpty
public boolean isEmpty()
Indicates whether or not this viewport is empty. An viewport is empty when either its width or its height are zero (or negative).- Returns:
- true if this viewport is empty, false otherwise
-
intersects
public boolean intersects(int x, int y, int width, int height)
Indicates whether this viewport intersects a specified viewport. Two viewport intersect when both overlap by a non-zero amount. An empty viewport never intersects another viewport.- Parameters:
x
- the X component of the viewport to test intersection withy
- the Y component of the viewport to test intersection withwidth
- the viewport width to test intersection withheight
- the viewport height to test intersection with- Returns:
- true if the specified viewport intersections this viewport, false otherwise
-
intersects
public boolean intersects(Viewport viewport)
Indicates whether this viewport intersects a specified viewport. Two viewport intersect when both overlap by a non-zero amount. An empty viewport never intersects another viewport.- Parameters:
viewport
- the viewport to test intersection with- Returns:
- true if the specified viewport intersections this viewport, false otherwise
- Throws:
java.lang.IllegalArgumentException
- If the viewport is null
-
intersect
public boolean intersect(int x, int y, int width, int height)
Computes the intersection of this viewport and a specified viewport, storing the result in this viewport and returning whether or not the viewport intersect. Two viewport intersect when both overlap by a non-zero amount. An empty viewport never intersects another viewport.
When there is no intersection, this returns false and leaves this viewport unchanged. To test for intersection without modifying this viewport, useintersects(int, int, int, int)
.- Parameters:
x
- the X component of the viewport to intersect withy
- the Y component of the viewport to intersect withwidth
- the viewport width to intersect withheight
- the viewport height to intersect with- Returns:
- this true if this viewport intersects the specified viewport, false otherwise
-
intersect
public boolean intersect(Viewport viewport)
Computes the intersection of this viewport and a specified viewport, storing the result in this viewport and returning whether or not the viewport intersect. Two viewport intersect when both overlap by a non-zero amount. An empty viewport never intersects another viewport.
When there is no intersection, this returns false and leaves this viewport unchanged. To test for intersection without modifying this viewport, useintersects(int, int, int, int)
.- Parameters:
viewport
- the viewport to intersect with- Returns:
- this true if this viewport intersects the specified viewport, false otherwise
- Throws:
java.lang.IllegalArgumentException
- If the viewport is null
-
contains
public boolean contains(int x, int y)
Indicates whether this viewport contains a specified point. An empty viewport never contains a point.- Parameters:
x
- the point's X componenty
- the point's Y component- Returns:
- true if this viewport contains the point, false otherwise
-
-