use of com.codename1.ui.Transform in project CodenameOne by codenameone.
the class Canvas method scale.
public void scale(float x, float y) {
Transform t = g.getTransform();
t.translate(bounds.getX(), bounds.getY());
t.scale(x, y);
t.translate(-bounds.getX(), -bounds.getY());
g.setTransform(t);
}
use of com.codename1.ui.Transform in project CodenameOne by codenameone.
the class JavaSEPort method setTransform.
@Override
public void setTransform(Object graphics, Transform transform) {
checkEDT();
Graphics2D g = getGraphics(graphics);
AffineTransform t = (graphics == g) ? new AffineTransform() : AffineTransform.getScaleInstance(zoomLevel, zoomLevel);
t.concatenate((AffineTransform) transform.getNativeTransform());
clamp(t);
g.setTransform(t);
Transform existing = getNativeScreenGraphicsTransform(graphics);
if (existing == null) {
existing = transform.copy();
setNativeScreenGraphicsTransform(graphics, existing);
} else {
existing.setTransform(transform);
}
}
use of com.codename1.ui.Transform in project CodenameOne by codenameone.
the class JavaSEPort method getTransform.
@Override
public void getTransform(Object graphics, Transform transform) {
checkEDT();
com.codename1.ui.Transform t = getNativeScreenGraphicsTransform(graphics);
if (t == null) {
transform.setIdentity();
} else {
transform.setTransform(t);
}
}
use of com.codename1.ui.Transform in project CodenameOne by codenameone.
the class Component method createStyleAnimation.
/**
* Creates an animation that will transform the current component to the styling of the destination UIID when
* completed. Notice that fonts will only animate within the truetype and native familiy and we recommend that you
* don't shift weight/typeface/style as this might diminish the effect.<br>
* <b>Important: </b> Only unselected styles are animated but once the animation completes all styles are applied.
* @param destUIID the UIID to which this component will gradually shift
* @param duration the duration of the animation or the number of steps
* @return an animation component that can either be stepped or played
*/
public ComponentAnimation createStyleAnimation(final String destUIID, final int duration) {
final Style sourceStyle = getUnselectedStyle();
final Style destStyle = hasInlineUnselectedStyle() ? getUIManager().parseComponentStyle(getInlineStylesTheme(), destUIID, getInlineStylesUIID(destUIID), getInlineUnselectedStyleStrings()) : getUIManager().getComponentStyle(destUIID);
return createStyleAnimation(sourceStyle, destStyle, duration, destUIID);
}
use of com.codename1.ui.Transform in project CodenameOne by codenameone.
the class Image method rotate.
/**
* Returns an instance of this image rotated by the given number of degrees. By default 90 degree
* angle divisions are supported, anything else is implementation dependent. This method assumes
* a square image. Notice that it is inefficient in the current implementation to rotate to
* non-square angles,
* <p>E.g. rotating an image to 45, 90 and 135 degrees is inefficient. Use rotatate to 45, 90
* and then rotate the 45 to another 90 degrees to achieve the same effect with less memory.
*
* @param degrees A degree in right angle must be larger than 0 and up to 359 degrees
* @return new image instance with the closest possible rotation
*/
public Image rotate(int degrees) {
CodenameOneImplementation i = Display.impl;
if (i.isRotationDrawingSupported()) {
if (degrees >= 90) {
int newTransform = 0;
if (transform != 0) {
newTransform = (transform + degrees) % 360;
} else {
newTransform = degrees % 360;
}
degrees %= 90;
newTransform -= degrees;
if (degrees != 0) {
Image newImage = new Image(Display.impl.rotate(image, degrees));
newImage.transform = newTransform;
return newImage;
} else {
Image newImage = new Image(image);
newImage.transform = newTransform;
return newImage;
}
}
if (degrees != 0) {
return new Image(Display.impl.rotate(image, degrees));
}
return this;
} else {
return new Image(Display.impl.rotate(image, degrees));
}
}
Aggregations