|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.miginfocom.util.gfx.geometry.AspectRatioRect
public class AspectRatioRect
A class that takes another PlaceRect and forces its aspect ratio (the relationship between with and height)
to be a certain value, or range of values.
There are a currently two of ways to force a rectangle into a certain aspect ratio:
MODE_SIZE - The rectangle is shringed or enlarged (or somewhere in between) in one dimension to the desired aspect ratio, or aspect ration range.MODE_DIMENSION - One dimension (or both, since you can set a percentage) is resize to to the desired aspect ratio, or aspect ration range.
| Field Summary | |
|---|---|
static int |
MODE_DIMENSION
|
static int |
MODE_SIZE
|
| Constructor Summary | |
|---|---|
AspectRatioRect(float aspectRatio)
Constructor for a rect that will be shrinked to fit the given rectangle. |
|
AspectRatioRect(PlaceRect placeRect,
float minAR,
float maxAR,
float perc,
int mode,
AtRefRangeNumber alignX,
AtRefRangeNumber alignY)
Constructor. |
|
AspectRatioRect(PlaceRect placeRect,
float aspectRatio,
float perc,
int mode)
Constructor. |
|
| Method Summary | |
|---|---|
protected void |
correctAspectRatio(java.awt.Rectangle r)
Corrects the aspect ration according to the rules set up in the constructor. |
boolean |
equals(java.lang.Object o)
|
AtRefRangeNumber |
getAlignmentX()
Returns the horizontal alignment to apply to the resulting rectangle in reference to the original one. |
AtRefRangeNumber |
getAlignmentY()
Returns the vertical alignment to apply to the resulting rectangle in reference to the original one. |
float |
getMaxAspectRatio()
Returns the maximum acceptable aspect ratio. |
float |
getMinAspectRatio()
Returns the minimum acceptable aspect ratio. |
int |
getMode()
Returns how the rectangle should be resized to fi the target aspect ratio. |
float |
getPercent()
Returns the percentage (normally 0f to 1f) between reduce/enlarge or vertical/horizontal depending on the mode. |
PlaceRect |
getPlaceRect()
Returns the contained place rect that first will be quired for an rectangle. |
java.awt.Rectangle |
getRect(java.awt.Rectangle r)
Returns a rectangle that might be translated, scaled and checked for max/min bounds. |
java.awt.Rectangle |
getRect(java.awt.Rectangle r,
java.awt.Dimension refSize)
Returns a rectangle that might be translated, scaled and checked for max/min bounds. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int MODE_SIZE
public static final int MODE_DIMENSION
| Constructor Detail |
|---|
public AspectRatioRect(float aspectRatio)
aspectRatio - The only acceptable aspect ratio. 2f means twice as wide as high.
public AspectRatioRect(PlaceRect placeRect,
float aspectRatio,
float perc,
int mode)
placeRect - The contained place rect that first will be asked for a rectangle. May be null which is same as AbsRect.FILL.aspectRatio - The only acceptable aspect ratio. 2f means twice as wide as high.perc - The percentage (normally 0f to 1f) between reduce/enlarge or vertical/horizontal depending on the mode.
0f means reduce or keep horizontal and 1f means enlarge/keep vertical. Any value inbetween is also valid.mode - How the rectangle should be resized to fi the target aspect ratio.
MODE_SIZE - The rectangle is shringed or enlarged (or somewhere in between) in one dimension to the desired aspect ratio, or aspect ration range.MODE_DIMENSION - One dimension (or both, since you can set a percentage) is resize to to the desired aspect ratio, or aspect ration range.
public AspectRatioRect(PlaceRect placeRect,
float minAR,
float maxAR,
float perc,
int mode,
AtRefRangeNumber alignX,
AtRefRangeNumber alignY)
placeRect - The contained place rect that first will be asked for a rectangle. May be null which is same as AbsRect.FILL.minAR - The minimum acceptable aspect ratio. 2f means twice as wide as high.maxAR - The maximum acceptable aspect ratio. 0.5f means half as wide as high.perc - The percentage (normally 0f to 1f) between reduce/enlarge or vertical/horizontal depending on the mode.
0f means reduce or keep horizontal and 1f means enlarge/keep vertical. Any value inbetween is also valid.mode - How the rectangle should be resized to fi the target aspect ratio.
MODE_SIZE - The rectangle is shringed or enlarged (or somewhere in between) in one dimension to the desired aspect ratio, or aspect ration range.MODE_DIMENSION - One dimension (or both, since you can set a percentage) is resize to to the desired aspect ratio, or aspect ration range.alignX - The horizontal alignment to apply to the resulting rectangle in reference to the original one. If null it will be center aligned.alignY - The vertical alignment to apply to the resulting rectangle in reference to the original one. If null it will be center aligned.AtStart,
AtEnd,
AtFraction,
AtFixed| Method Detail |
|---|
protected void correctAspectRatio(java.awt.Rectangle r)
r - The rectangle to correct. Never null.public java.awt.Rectangle getRect(java.awt.Rectangle r)
PlaceRect
This method is normally just a transfer to PlaceRect.getRect(java.awt.Rectangle, java.awt.Dimension) with
refSize set ti null.
getRect in interface PlaceRectr - The rectangle that is to be used as the source. Not null. Will not be changed.
null.
public java.awt.Rectangle getRect(java.awt.Rectangle r,
java.awt.Dimension refSize)
PlaceRect
getRect in interface PlaceRectr - The rectangle that is to be used as the source. Not null. Will not be changed.refSize - If x1, y1, x2 and/or y2 is null (in this)) the horizontal/vertical
size if taken from this dimension instead. If null the size is taken from r.null.public PlaceRect getPlaceRect()
null which is same as AbsRect.FILL.public float getMinAspectRatio()
public float getMaxAspectRatio()
public float getPercent()
public int getMode()
MODE_SIZE - The rectangle is shringed or enlarged (or somewhere in between) in one dimension to the desired aspect ratio, or aspect ration range.MODE_DIMENSION - One dimension (or both, since you can set a percentage) is resize to to the desired aspect ratio, or aspect ration range.
AspectRatioRect.MODE_SIZE.public AtRefRangeNumber getAlignmentX()
AtStart,
AtEnd,
AtFraction,
AtFixedpublic AtRefRangeNumber getAlignmentY()
AtStart,
AtEnd,
AtFraction,
AtFixedpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||