use of com.codename1.ui.Graphics in project CodenameOne by codenameone.
the class Label method paintImpl.
void paintImpl(Graphics g) {
initAutoResize();
Object icn = null;
Image i = getIconFromState();
if (i != null) {
icn = i.getImage();
} else {
// optimize away a common usage pattern for drawing the background only
if (text == null || text.equals("") || text.equals(" ")) {
return;
}
}
// getUIManager().getLookAndFeel().drawLabel(g, this);
int cmpX = getX() + g.getTranslateX();
int cmpY = getY() + g.getTranslateY();
int cmpHeight = getHeight();
int cmpWidth = getWidth();
Style s = getStyle();
Font f = s.getFont();
String t = text;
if (text == null) {
t = "";
}
Display.impl.drawLabelComponent(g.getGraphics(), cmpX, cmpY, cmpHeight, cmpWidth, s, t, icn, null, 0, gap, isRTL(), false, textPosition, getStringWidth(f), tickerRunning, shiftText, endsWith3Points, valign);
}
use of com.codename1.ui.Graphics in project CodenameOne by codenameone.
the class CSSBgPainter method paint.
/**
* {@inheritDoc}
*/
public void paint(Graphics g, Rectangle rect) {
Style s = parent.getStyle();
int x = rect.getX();
int y = rect.getY();
int width = rect.getSize().getWidth();
int height = rect.getSize().getHeight();
if (width <= 0 || height <= 0) {
return;
}
g.setColor(s.getBgColor());
g.fillRect(x, y, width, height, s.getBgTransparency());
Image bgImage = s.getBgImage();
if (bgImage == null) {
return;
}
if (fixedX) {
if (scrollableParent == null) {
scrollableParent = getScrollableParent(parent);
}
if (scrollableParent != null) {
x += scrollableParent.getScrollX();
y += scrollableParent.getScrollY();
width = scrollableParent.getWidth();
height = scrollableParent.getHeight();
}
}
int iW = bgImage.getWidth();
int iH = bgImage.getHeight();
int offsetX = horizPos;
int offsetY = vertPos;
if (horizIsPercentage) {
offsetX = (width - iW) * offsetX / 100;
}
if (vertIsPercentage) {
offsetY = (height - iH) * offsetY / 100;
}
switch(s.getBackgroundType()) {
case 0:
g.drawImage(s.getBgImage(), x + offsetX, y + offsetY);
return;
case Style.BACKGROUND_IMAGE_TILE_BOTH:
for (int xPos = getTiledPosition(offsetX, iW); xPos <= width; xPos += iW) {
for (int yPos = getTiledPosition(offsetY, iH); yPos <= height; yPos += iH) {
g.drawImage(s.getBgImage(), x + xPos, y + yPos);
}
}
return;
case Style.BACKGROUND_IMAGE_TILE_HORIZONTAL:
for (int xPos = getTiledPosition(offsetX, iW); xPos <= width; xPos += iW) {
g.drawImage(s.getBgImage(), x + xPos, y + offsetY);
}
return;
case Style.BACKGROUND_IMAGE_TILE_VERTICAL:
for (int yPos = getTiledPosition(offsetY, iH); yPos <= height; yPos += iH) {
g.drawImage(s.getBgImage(), x + offsetX, y + yPos);
}
return;
}
}
use of com.codename1.ui.Graphics in project CodenameOne by codenameone.
the class TextField method paint.
/**
* {@inheritDoc}
*/
public void paint(Graphics g) {
// the native input will show the string.
if (useNativeTextInput && Display.getInstance().isNativeEditorVisible(this)) {
return;
}
UIManager manager = getUIManager();
manager.getLookAndFeel().drawTextField(g, this);
if (drawCursor && hasFocus() && isEditable()) {
manager.getLookAndFeel().drawTextFieldCursor(g, this);
}
paintHint(g);
}
use of com.codename1.ui.Graphics in project CodenameOne by codenameone.
the class AnimationObject method draw.
void draw(Graphics g, float scaleX, float scaleY) {
int o = getOpacity();
if (o == 0) {
return;
}
Image i = getImage();
// works in a separate thread
if (i == null) {
return;
}
int scaledImageW = (int) (getWidth() * scaleX);
int scaledImageH = (int) (getHeight() * scaleY);
if (scaledImageH < 1 || scaledImageW < 1) {
return;
}
i = getImage().scaled(scaledImageW, scaledImageH);
if (o != 255) {
i = i.modifyAlphaWithTranslucency((byte) o);
}
int r = getOrientation();
if (r != 0) {
i = i.rotate(r);
}
int x = getX();
int y = getY();
x = (int) (x * scaleX);
y = (int) (y * scaleY);
g.drawImage(i, x, y);
}
use of com.codename1.ui.Graphics in project CodenameOne by codenameone.
the class BubbleTransition method drawDialogCmp.
private void drawDialogCmp(Graphics g, Dialog dlg) {
Painter p = dlg.getStyle().getBgPainter();
dlg.getStyle().setBgPainter(null);
g.setClip(0, 0, dlg.getWidth(), dlg.getHeight());
g.translate(-getDialogParent(dlg).getX(), -getDialogParent(dlg).getY());
getDialogParent(dlg).paintComponent(g, false);
if (dlg.getCommandCount() > 0) {
Component menuBar = dlg.getSoftButton(0).getParent();
if (menuBar != null) {
g.setClip(0, 0, dlg.getWidth(), dlg.getHeight());
menuBar.paintComponent(g, false);
}
}
dlg.getStyle().setBgPainter(p);
}
Aggregations