Search in sources :

Example 6 with Transform

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);
}
Also used : Transform(com.codename1.ui.Transform)

Example 7 with Transform

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);
    }
}
Also used : AffineTransform(java.awt.geom.AffineTransform) AffineTransform(java.awt.geom.AffineTransform) Transform(com.codename1.ui.Transform) Graphics2D(java.awt.Graphics2D)

Example 8 with 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);
    }
}
Also used : Transform(com.codename1.ui.Transform)

Example 9 with Transform

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);
}
Also used : Style(com.codename1.ui.plaf.Style)

Example 10 with Transform

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));
    }
}
Also used : CodenameOneImplementation(com.codename1.impl.CodenameOneImplementation)

Aggregations

Transform (com.codename1.ui.Transform)9 Point (com.codename1.charts.models.Point)3 GeneralPath (com.codename1.ui.geom.GeneralPath)2 Bitmap (android.graphics.Bitmap)1 Canvas (android.graphics.Canvas)1 Matrix (android.graphics.Matrix)1 Paint (android.graphics.Paint)1 Path (android.graphics.Path)1 RectF (android.graphics.RectF)1 Paint (com.codename1.charts.compat.Paint)1 XYSeries (com.codename1.charts.models.XYSeries)1 Orientation (com.codename1.charts.renderers.XYMultipleSeriesRenderer.Orientation)1 XYSeriesRenderer (com.codename1.charts.renderers.XYSeriesRenderer)1 XYChart (com.codename1.charts.views.XYChart)1 CodenameOneImplementation (com.codename1.impl.CodenameOneImplementation)1 Component (com.codename1.ui.Component)1 Container (com.codename1.ui.Container)1 Image (com.codename1.ui.Image)1 Label (com.codename1.ui.Label)1 Stroke (com.codename1.ui.Stroke)1