public class WOWZSize extends java.lang.Object implements java.lang.Comparable<WOWZSize>, java.io.Serializable
WOWZSize frameSize = WOWZSize(1280, 720);
float aspectRatio = frameSize.aspectRatio();
Modifier and Type | Class and Description |
---|---|
static class |
WOWZSize.ScaledDimensions
ScaledDimensions is a utility class representing common scaling operations when
placing one rectangular area (the source) in another (the destination).
|
Modifier and Type | Field and Description |
---|---|
int |
height
The height value.
|
int |
width
The width value.
|
Constructor and Description |
---|
WOWZSize()
The default constructor.
|
WOWZSize(int width,
int height)
Creates and initializes an instance using the specified property values.
|
WOWZSize(WOWZSize other)
Creates and initializes an instance using the property values from the specified instance.
|
Modifier and Type | Method and Description |
---|---|
static WOWZSize |
absOffset(int w1,
int h1,
int w2,
int h2)
Calculates the offset between two dimensions.
|
WOWZSize |
absOffsetFrom(WOWZSize other)
Calculates the offset between the width and height values from this instance and the specified instance.
|
double |
area()
Calculates the area of a rectangle with the width and height of this instance.
|
double |
area(int w,
int h) |
WOWZSize |
asLandscape()
Creates an instance whose width is greater than or equal to its height.
|
static WOWZSize |
asLandscape(int width,
int height)
Creates an instance whose width is greater than or equal to its height.
|
float |
aspectRatio()
Calculates the aspect ratio (width / height) of this instance.
|
static float |
aspectRatio(int width,
int height)
Calculates an aspect ratio (width / height).
|
java.lang.String |
aspectRatioLabel()
Gets a string representation of the aspect ratio of this dimension.
|
static java.lang.String |
aspectRatioLabel(int width,
int height)
Gets an aspect ratio as a string, for example, 16:9.
|
WOWZSize |
asPortrait()
Creates an instance whose width is less than or equal to its height.
|
static WOWZSize |
asPortrait(int width,
int height)
Creates an instance whose width is less than or equal to its height.
|
WOWZPoint |
center()
Calculates the center point of a zero-based rectangle with the width and height of this instance.
|
WOWZPoint |
center(int width,
int height)
Calculates the center point of the rectangular region with the specified dimensions.
|
WOWZSize.ScaledDimensions |
center(WOWZSize other)
Calculates the offset of this instance from the destination after centering it in the destination.
|
static WOWZSize |
closestTo(int width,
int height,
WOWZSize[] others)
Gets the instance from the specified array that is greater than and closest in size to the specified dimension values.
|
static WOWZSize |
closestTo(WOWZSize src,
WOWZSize[] others)
Gets the instance from the specified array that is greater than and closest in size to the specified instance.
|
static int |
closestToIndex(int width,
int height,
WOWZSize[] others)
Gets the index of the instance from the specified array that is greater than and closest in size to the specified dimension values.
|
static int |
closestToIndex(WOWZSize src,
WOWZSize[] others)
Gets the index of the instance from the specified array that is greater than and closest in size to the specified instance.
|
int |
compareTo(int width,
int height)
Compares the property values of this instance with the specified values.
|
int |
compareTo(WOWZSize other)
Compares this instance with the specified instance.
|
boolean |
equals(int width,
int height)
Compares the property values of this instance with the specified values for equality.
|
boolean |
equals(int w1,
int h1,
int w2,
int h2)
Compares two dimensions for equality.
|
boolean |
equals(java.lang.Object other)
Compares this instance with the specified instance for equality.
|
boolean |
equalsAspect(int width,
int height)
Compares the aspect ratio of this instance with the aspect ratio of the specified width and height.
|
static boolean |
equalsAspect(int w1,
int h1,
int w2,
int h2)
Compares the aspect ratios of two dimensions for equality.
|
boolean |
equalsAspect(WOWZSize other)
Compares the aspect ratio of this instance with another instance.
|
static boolean |
equalsAspect(WOWZSize s1,
WOWZSize s2)
Compares the aspect ratios of two WOWZSize instances for equality.
|
static WOWZSize[] |
filterByAspectRatio(WOWZSize[] sizes,
WOWZSize srcSize)
Filters an array of sizes by those that match the aspect ratio of a specified size.
|
static WOWZSize[] |
findContainers(WOWZSize[] srcSizes,
WOWZSize minSize)
Filters an array of sizes by those that are equal to or larger than a specified minimum size.
|
boolean |
fitsWithin(WOWZSize other)
Compares this instance with the specified instance to see if it is smaller.
|
int |
getHeight() |
int |
getWidth() |
void |
invert()
Inverts the coordinate values of this instance.
|
WOWZSize |
inverted()
Creates a version of this instance with the width and height values reversed.
|
boolean |
isLandscape() |
static boolean |
isLandscape(int width,
int height) |
boolean |
isPortrait() |
static boolean |
isPortrait(int width,
int height) |
boolean |
isSquare() |
static boolean |
isSquare(int width,
int height) |
boolean |
isZero() |
static boolean |
isZero(int width,
int height) |
static java.lang.String |
label(int width,
int height)
Gets a human-readable description of the specified values.
|
boolean |
largerThan(WOWZSize other)
Compares this instance with the specified instance to see if it is larger.
|
int |
longDimension() |
static int |
longDimension(int width,
int height) |
static WOWZSize |
offset(int w1,
int h1,
int w2,
int h2)
Calculates the offset between two dimensions.
|
WOWZSize |
offsetFrom(WOWZSize other)
Calculates the offset between the width and height from this instance and the specified instance.
|
WOWZSize.ScaledDimensions |
scaleWithCrop(WOWZSize other)
Calculates the dimensions of this instance after scaling it so that it fits entirely in the specified instance, preserving the aspect ratio.
|
WOWZSize.ScaledDimensions |
scaleWithFill(WOWZSize other)
Calculates the dimensions of this instance after scaling it so that it fills the specified instance, preserving the aspect ratio.
|
void |
set(int width,
int height)
Updates the property values of this instance with the specified values.
|
void |
set(WOWZSize other)
Updates the property values of this instance with the property values from the specified instance.
|
void |
setHeight(int height)
Updates the height value.
|
void |
setWidth(int width)
Updates the width value.
|
java.lang.String |
toString()
Gets a human-readable description of this instance.
|
public WOWZSize()
public WOWZSize(int width, int height)
width
- The width value.height
- The height value.public WOWZSize(WOWZSize other)
other
- The instance to use.public boolean equals(int w1, int h1, int w2, int h2)
w1
- The width of the first dimension.h1
- The height of the first dimension.w2
- The width of the second dimension.h2
- The height of the second dimension.public static float aspectRatio(int width, int height)
width
- The width, in pixels.height
- The height, in pixels.public static java.lang.String aspectRatioLabel(int width, int height)
width
- The width, in pixels.height
- The height, in pixels.public static WOWZSize[] filterByAspectRatio(WOWZSize[] sizes, WOWZSize srcSize)
sizes
- The array of sizes to compare.srcSize
- The source size.public static WOWZSize[] findContainers(WOWZSize[] srcSizes, WOWZSize minSize)
srcSizes
- The array of sizes to compare.minSize
- The minimum size.public static boolean equalsAspect(int w1, int h1, int w2, int h2)
w1
- The width of the first dimension.h1
- The height of the first dimension.w2
- The width of the second dimension.h2
- The height of the second dimension.public static boolean equalsAspect(WOWZSize s1, WOWZSize s2)
s1
- The first size for comparison.s2
- The second size for comparison.public static WOWZSize offset(int w1, int h1, int w2, int h2)
w1
- The width of the first dimension.h1
- The height of the first dimension.w2
- The width of the second dimension.h2
- The height of the second dimension.public static WOWZSize absOffset(int w1, int h1, int w2, int h2)
w1
- The width of the first dimension.h1
- The height of the first dimension.w2
- The width of the second dimension.h2
- The height of the second dimension.public double area(int w, int h)
public WOWZPoint center(int width, int height)
width
- The width.height
- The height.public static boolean isLandscape(int width, int height)
public static boolean isPortrait(int width, int height)
public static boolean isSquare(int width, int height)
public static boolean isZero(int width, int height)
public static int longDimension(int width, int height)
public static WOWZSize asLandscape(int width, int height)
public static WOWZSize asPortrait(int width, int height)
public static WOWZSize closestTo(WOWZSize src, WOWZSize[] others)
src
- The instance to use for comparison to the instances in the array.others
- An array of instances to compare with the specified instance.public static int closestToIndex(WOWZSize src, WOWZSize[] others)
src
- The instance to use for comparison to the instances in the array.others
- An array of instances to compare with the specified instance.public static WOWZSize closestTo(int width, int height, WOWZSize[] others)
width
- The width to use for comparison.height
- The height to use for comparison.others
- An array of instances to compare with the specified values.public static int closestToIndex(int width, int height, WOWZSize[] others)
width
- The width to use for comparison.height
- The height to use for comparison.others
- An array of instances to compare with the specified values.public static java.lang.String label(int width, int height)
public int getWidth()
public void setWidth(int width)
width
- The width value.public int getHeight()
public void setHeight(int height)
height
- The height value.public void set(int width, int height)
width
- The width value.height
- The height value.public void set(WOWZSize other)
other
- The instance with the property values to use.public boolean equals(int width, int height)
width
- The width value.height
- The height value.public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
other
- The instance to be used for comparison.public int compareTo(WOWZSize other)
compareTo
in interface java.lang.Comparable<WOWZSize>
other
- The instance to be used for comparison.public int compareTo(int width, int height)
width
- The width value.height
- The height value.public java.lang.String toString()
toString
in class java.lang.Object
public WOWZSize inverted()
public void invert()
public float aspectRatio()
width
- The width value.height
- The height value.public java.lang.String aspectRatioLabel()
public boolean equalsAspect(int width, int height)
width
- The width to use for comparison.height
- The height to use for comparison.public boolean equalsAspect(WOWZSize other)
other
- The instance to use for comparison.public boolean isLandscape()
public boolean isPortrait()
public boolean isSquare()
public boolean isZero()
public int longDimension()
public WOWZSize asLandscape()
public WOWZSize asPortrait()
public boolean fitsWithin(WOWZSize other)
public boolean largerThan(WOWZSize other)
public WOWZPoint center()
public double area()
public WOWZSize offsetFrom(WOWZSize other)
other
- The instance with the width and height values for the offset calculation.public WOWZSize absOffsetFrom(WOWZSize other)
other
- The instance with the width and height to use for the offset calculation.public WOWZSize.ScaledDimensions scaleWithCrop(WOWZSize other)
other
- The destination rectangular instance.public WOWZSize.ScaledDimensions scaleWithFill(WOWZSize other)
other
- The destination rectangular instance.public WOWZSize.ScaledDimensions center(WOWZSize other)
other
- The destination rectangular instance.© 2016 - 2018 Wowza Media Systems, LLC. All rights reserved. Terms | Privacy | Trademarks | Legal