Search in sources :

Example 81 with Component

use of com.codename1.ui.Component in project CodenameOne by codenameone.

the class Component method initComponentImpl.

/**
 * Invoked internally to initialize and bind the component
 */
void initComponentImpl() {
    if (!initialized) {
        initialized = true;
        UIManager manager = getUIManager();
        Style stl = getStyle();
        lockStyleImages(stl);
        manager.getLookAndFeel().bind(this);
        checkAnimation();
        if (isRTL() && isScrollableX()) {
            setScrollX(getScrollDimension().getWidth() - getWidth());
        }
        initComponent();
        showNativeOverlay();
    }
}
Also used : UIManager(com.codename1.ui.plaf.UIManager) Style(com.codename1.ui.plaf.Style)

Example 82 with Component

use of com.codename1.ui.Component 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 83 with Component

use of com.codename1.ui.Component in project CodenameOne by codenameone.

the class Component method paintLock.

/**
 * This method locks the component so it will always paint the given image
 * instead of running through its paint logic. This is useful when running
 * transitions that might be quite expensive on the device. A lock should
 * be released using paintLockRelease(), it is implicitly released when
 * a component is deinitialized although a component doesn't need to be initialized
 * to be locked!<br>
 * If the component is not opaque null is always returned!
 * <p>Duplicate calls to this method won't produce duplicate locks, in case of
 * a soft lock the return value will always be null.
 *
 * @param hardLock indicates whether the lock uses a hard or a soft reference to the image
 * @return the image in case of a hard lock
 */
public Image paintLock(boolean hardLock) {
    if (!paintLockEnableChecked) {
        paintLockEnableChecked = true;
        paintLockEnabled = Display.getInstance().getProperty("paintLockEnabled", "true").equals("true");
    }
    if (!paintLockEnabled || !Display.getInstance().areMutableImagesFast()) {
        return null;
    }
    if ((getStyle().getBgTransparency() & 0xff) != 0xff) {
        return null;
    }
    if (paintLockImage == null) {
        paintLockImage = Image.createImage(getWidth(), getHeight());
        int x = getX();
        int y = getY();
        setX(0);
        setY(0);
        paintInternalImpl(((Image) paintLockImage).getGraphics(), false);
        setX(x);
        setY(y);
        if (hardLock) {
            return (Image) paintLockImage;
        } else {
            paintLockImage = Display.getInstance().createSoftWeakRef(paintLockImage);
        }
    } else {
        if (hardLock) {
            return (Image) paintLockImage;
        }
    }
    return null;
}
Also used : Point(com.codename1.ui.geom.Point)

Example 84 with Component

use of com.codename1.ui.Component in project CodenameOne by codenameone.

the class Component method drawPainters.

private void drawPainters(com.codename1.ui.Graphics g, Component par, Component c, int x, int y, int w, int h) {
    if (flatten && getWidth() > 0 && getHeight() > 0) {
        Image i = (Image) getClientProperty("$FLAT");
        int absX = getAbsoluteX() + getScrollX();
        int absY = getAbsoluteY() + getScrollY();
        if (i == null || i.getWidth() != getWidth() || i.getHeight() != getHeight()) {
            i = Image.createImage(getWidth(), getHeight());
            Graphics tg = i.getGraphics();
            // tg.translate(g.getTranslateX(), g.getTranslateY());
            drawPaintersImpl(tg, par, c, x, y, w, h);
            paintBackgroundImpl(tg);
            putClientProperty("$FLAT", i);
        }
        int tx = g.getTranslateX();
        int ty = g.getTranslateY();
        g.translate(-tx + absX, -ty + absY);
        g.drawImage(i, 0, 0);
        g.translate(tx - absX, ty - absY);
        return;
    }
    drawPaintersImpl(g, par, c, x, y, w, h);
}
Also used : Point(com.codename1.ui.geom.Point)

Example 85 with Component

use of com.codename1.ui.Component in project CodenameOne by codenameone.

the class Component method paintBorder.

/**
 * Draws the component border if such a border exists. The border unlike the content
 * of the component will not be affected by scrolling for a scrollable component.
 *
 * @param g graphics context on which the border is painted
 */
protected void paintBorder(Graphics g) {
    Border b = getBorder();
    if (b != null) {
        g.setColor(getStyle().getFgColor());
        b.paint(g, this);
    }
}
Also used : Border(com.codename1.ui.plaf.Border)

Aggregations

Component (com.codename1.ui.Component)152 Style (com.codename1.ui.plaf.Style)61 Container (com.codename1.ui.Container)55 Form (com.codename1.ui.Form)41 BorderLayout (com.codename1.ui.layouts.BorderLayout)40 TextArea (com.codename1.ui.TextArea)31 ActionEvent (com.codename1.ui.events.ActionEvent)28 Dimension (com.codename1.ui.geom.Dimension)28 Label (com.codename1.ui.Label)25 Point (com.codename1.ui.geom.Point)22 ArrayList (java.util.ArrayList)22 Rectangle (com.codename1.ui.geom.Rectangle)21 Vector (java.util.Vector)18 Button (com.codename1.ui.Button)16 Dialog (com.codename1.ui.Dialog)16 Hashtable (java.util.Hashtable)16 Image (com.codename1.ui.Image)15 TextField (com.codename1.ui.TextField)15 ActionListener (com.codename1.ui.events.ActionListener)13 BoxLayout (com.codename1.ui.layouts.BoxLayout)13