public class Viewport
extends java.lang.Object
implements android.os.Parcelable
| Modifier and Type | Field and Description |
|---|---|
float |
bottom |
static android.os.Parcelable.Creator<Viewport> |
CREATOR |
float |
left |
float |
right |
float |
top |
| Constructor and Description |
|---|
Viewport()
Create a new empty Viewport.
|
Viewport(float left,
float top,
float right,
float bottom)
Create a new viewport with the specified coordinates.
|
Viewport(Viewport v)
Create a new viewport, initialized with the values in the specified viewport (which is left unmodified).
|
| Modifier and Type | Method and Description |
|---|---|
float |
centerX() |
float |
centerY() |
boolean |
contains(float x,
float y)
Returns true if (x,y) is inside the viewport.
|
boolean |
contains(float left,
float top,
float right,
float bottom)
Returns true iff the 4 specified sides of a viewport are inside or equal to this viewport.
|
boolean |
contains(Viewport v)
Returns true iff the specified viewport r is inside or equal to this viewport.
|
int |
describeContents()
Parcelable interface methods
|
boolean |
equals(java.lang.Object obj) |
int |
hashCode() |
float |
height() |
void |
inset(float dx,
float dy)
Inset the viewport by (dx,dy).
|
boolean |
intersect(float left,
float top,
float right,
float bottom)
If the viewport specified by left,top,right,bottom intersects this viewport, return true and set this viewport to
that intersection, otherwise return false and do not change this viewport.
|
boolean |
intersect(Viewport v)
If the specified viewport intersects this viewport, return true and set this viewport to that intersection,
otherwise return false and do not change this viewport.
|
boolean |
isEmpty()
Returns true if the viewport is empty
left >= right or bottom >= top |
void |
offset(float dx,
float dy)
Offset the viewport by adding dx to its left and right coordinates, and adding dy to its top and bottom
coordinates.
|
void |
offsetTo(float newLeft,
float newTop)
Offset the viewport to a specific (left, top) position, keeping its width and height the same.
|
void |
readFromParcel(android.os.Parcel in)
Set the viewport's coordinates from the data stored in the specified parcel.
|
void |
set(float left,
float top,
float right,
float bottom)
Set the viewport's coordinates to the specified values.
|
void |
set(Viewport src)
Copy the coordinates from src into this viewport.
|
void |
setEmpty()
Set the viewport to (0,0,0,0)
|
java.lang.String |
toString() |
void |
union(float left,
float top,
float right,
float bottom)
Update this Viewport to enclose itself and the specified viewport.
|
void |
union(Viewport v)
Update this Viewport to enclose itself and the specified viewport.
|
float |
width() |
void |
writeToParcel(android.os.Parcel out,
int flags)
Write this viewport to the specified parcel.
|
public float left
public float top
public float right
public float bottom
public static final android.os.Parcelable.Creator<Viewport> CREATOR
public Viewport()
public Viewport(float left,
float top,
float right,
float bottom)
left - The X coordinate of the left side of the viewporttop - The Y coordinate of the top of the viewportright - The X coordinate of the right side of the viewportbottom - The Y coordinate of the bottom of the viewportpublic Viewport(Viewport v)
v - The viewport whose coordinates are copied into the new viewport.public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic final boolean isEmpty()
left >= right or bottom >= toppublic void setEmpty()
public final float width()
left <= right) so the
result may be negative.public final float height()
top <= bottom) so the
result may be negative.public final float centerX()
left <=
right)public final float centerY()
bottom <=
top)public void set(float left,
float top,
float right,
float bottom)
left <= right and bottom <= top.left - The X coordinate of the left side of the viewporttop - The Y coordinate of the top of the viewportright - The X coordinate of the right side of the viewportbottom - The Y coordinate of the bottom of the viewportpublic void set(Viewport src)
src - The viewport whose coordinates are copied into this viewport.public void offset(float dx,
float dy)
dx - The amount to add to the viewport's left and right coordinatesdy - The amount to add to the viewport's top and bottom coordinatespublic void offsetTo(float newLeft,
float newTop)
newLeft - The new "left" coordinate for the viewportnewTop - The new "top" coordinate for the viewportpublic void inset(float dx,
float dy)
dx - The amount to add(subtract) from the viewport's left(right)dy - The amount to add(subtract) from the viewport's top(bottom)public boolean contains(float x,
float y)
left <= x < right and bottom <= y < top. An
empty viewport never contains any point.x - The X coordinate of the point being tested for containmenty - The Y coordinate of the point being tested for containmentleft <= x < right and top <=
y < bottompublic boolean contains(float left,
float top,
float right,
float bottom)
left - The left side of the viewport being tested for containmenttop - The top of the viewport being tested for containmentright - The right side of the viewport being tested for containmentbottom - The bottom of the viewport being tested for containmentpublic boolean contains(Viewport v)
v - The viewport being tested for containment.public void union(float left,
float top,
float right,
float bottom)
left - The left edge being unioned with this viewporttop - The top edge being unioned with this viewportright - The right edge being unioned with this viewportbottom - The bottom edge being unioned with this viewportpublic void union(Viewport v)
v - The viewport being unioned with this viewportpublic boolean intersect(float left,
float top,
float right,
float bottom)
left - The left side of the viewport being intersected with this viewporttop - The top of the viewport being intersected with this viewportright - The right side of the viewport being intersected with this viewport.bottom - The bottom of the viewport being intersected with this viewport.public boolean intersect(Viewport v)
v - The viewport being intersected with this viewport.public java.lang.String toString()
toString in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic int describeContents()
describeContents in interface android.os.Parcelablepublic void writeToParcel(android.os.Parcel out,
int flags)
writeToParcel in interface android.os.Parcelableout - The parcel to write the viewport's coordinates intopublic void readFromParcel(android.os.Parcel in)
in - The parcel to read the viewport's coordinates from