public class ScaleStrategy
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
int |
convertToCanvasX(Rect screen,
int screenX) |
int |
convertToCanvasY(Rect screen,
int screenY) |
int |
convertToScreenX(Rect screen,
int canvasX) |
int |
convertToScreenY(Rect screen,
int canvasY) |
static ScaleStrategy |
fixed(int canvasWidth,
int canvasHeight)
Does not scale the canvas, keeping it at the specified size regardless of
the size of the screen.
|
static ScaleStrategy |
flexible(int initialCanvasWidth,
int initialCanvasHeight)
Performs no scaling so that the canvas size always matches the screen size.
|
Rect |
getCanvasBounds(Rect screen)
Returns the size and position of the canvas when applying this scale
strategy to the specified screen.
|
int |
getCanvasHeight(Rect screen)
Returns the (non-scaled) height of the canvas used by this scale strategy.
|
int |
getCanvasWidth(Rect screen)
Returns the (non-scaled) width of the canvas used by this scale strategy.
|
Rect |
getPreferredCanvasBounds() |
float |
getScaleFactorX(Rect screen) |
float |
getScaleFactorY(Rect screen) |
static ScaleStrategy |
proportional(int canvasWidth,
int canvasHeight)
Scales the canvas to match the screen size, but without changing its aspect
ratio.
|
static ScaleStrategy |
smart(int canvasWidth,
int canvasHeight)
Scales the canvas to match the screen size.
|
static ScaleStrategy |
stretch(int canvasWidth,
int canvasHeight)
Stretches the canvas to match the screen size.
|
public int getCanvasWidth(Rect screen)
public int getCanvasHeight(Rect screen)
public Rect getPreferredCanvasBounds()
public Rect getCanvasBounds(Rect screen)
public float getScaleFactorX(Rect screen)
public float getScaleFactorY(Rect screen)
public int convertToScreenX(Rect screen, int canvasX)
public int convertToScreenY(Rect screen, int canvasY)
public int convertToCanvasX(Rect screen, int screenX)
public int convertToCanvasY(Rect screen, int screenY)
public static ScaleStrategy flexible(int initialCanvasWidth, int initialCanvasHeight)
public static ScaleStrategy fixed(int canvasWidth, int canvasHeight)
public static ScaleStrategy stretch(int canvasWidth, int canvasHeight)
public static ScaleStrategy proportional(int canvasWidth, int canvasHeight)
public static ScaleStrategy smart(int canvasWidth, int canvasHeight)
proportional(int, int) it will increase the canvas to fill the
remaining space.