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();
}
}
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);
}
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;
}
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);
}
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);
}
}
Aggregations