public class ImageScale extends AbstractTransform
An image scale instance holds a global state for all drawings. Several instances can be created at the same time.
However a default instance is created on MicroUI framework startup and is always available.
Modifier and Type | Field and Description |
---|---|
static ImageScale |
Singleton
Default instance created on MicroUI framework startup.
|
Constructor and Description |
---|
ImageScale() |
Modifier and Type | Method and Description |
---|---|
void |
draw(GraphicsContext gc,
Image image,
int x,
int y,
int anchor)
Deprecated.
|
void |
drawBilinear(GraphicsContext gc,
Image image,
int x,
int y,
int anchor)
Draw the
Image in the GraphicsContext at given anchor position and using the current scaling
factor. |
void |
drawNearestNeighbor(GraphicsContext gc,
Image image,
int x,
int y,
int anchor)
Draw the
Image in the GraphicsContext at given anchor position and using the current scaling
factor. |
float |
getFactor()
Deprecated.
Use
getFactorX() or getFactorY() instead. |
float |
getFactorX()
Returns the current scaling X factor.
|
float |
getFactorY()
Returns the current scaling Y factor.
|
void |
setFactor(float factor)
Set a new scaling factor.
|
void |
setFactorX(float factor)
Set a new scaling X factor.
|
void |
setFactorY(float factor)
Set a new scaling Y factor.
|
getAlpha, getTranslateX, getTranslateY, isMirrored, resetAlpha, resetTranslate, setAlpha, setMirror, translate
public static ImageScale Singleton
public float getFactor()
getFactorX()
or getFactorY()
instead.public float getFactorX()
public float getFactorY()
public void setFactor(float factor)
setFactorX(factor);
setFactorY(factor);
factor
- the new scaling factorjava.lang.IllegalArgumentException
- if factor
is lower than or equal to zeropublic void setFactorX(float factor)
factor
- the new scaling X factorjava.lang.IllegalArgumentException
- if factor
is lower than or equal to zeropublic void setFactorY(float factor)
factor
- the new scaling Y factorjava.lang.IllegalArgumentException
- if factor
is lower than or equal to zeropublic void draw(GraphicsContext gc, Image image, int x, int y, int anchor)
drawNearestNeighbor(GraphicsContext, Image, int, int, int)
or drawBilinear(GraphicsContext, Image, int, int, int)
instead.gc
- the GraphicsContext
where to render the drawing.image
- the Image
to drawx
- the x coordinate of the image reference anchor pointy
- the y coordinate of the image reference anchor pointanchor
- position of the image reference point around the anchor pointpublic void drawBilinear(GraphicsContext gc, Image image, int x, int y, int anchor)
Image
in the GraphicsContext
at given anchor position and using the current scaling
factor. This method uses the bilinear
algorithm
to render the image. This algorithm performs better rendering than nearest neighbor
algorithm but it
is slower to apply.gc
- the GraphicsContext
where to render the drawing.image
- the Image
to drawx
- the x coordinate of the image reference anchor pointy
- the y coordinate of the image reference anchor pointanchor
- position of the image reference point around the anchor pointpublic void drawNearestNeighbor(GraphicsContext gc, Image image, int x, int y, int anchor)
Image
in the GraphicsContext
at given anchor position and using the current scaling
factor. This method uses the nearest neighbor
algorithm to render the image. This algorithm is faster than bilinear
algorithm but its rendering is
more simple.gc
- the GraphicsContext
where to render the drawing.image
- the Image
to drawx
- the x coordinate of the image reference anchor pointy
- the y coordinate of the image reference anchor pointanchor
- position of the image reference point around the anchor point