use of com.codename1.ui.Graphics in project CodenameOne by codenameone.
the class Component method isInClippingRegion.
protected boolean isInClippingRegion(Graphics g) {
int oX = g.getClipX();
int oY = g.getClipY();
int oWidth = g.getClipWidth();
int oHeight = g.getClipHeight();
return bounds.intersects(oX, oY, oWidth, oHeight);
}
use of com.codename1.ui.Graphics 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.Graphics 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);
}
}
use of com.codename1.ui.Graphics in project CodenameOne by codenameone.
the class Container method paint.
/**
* {@inheritDoc}
*/
public void paint(Graphics g) {
if (enableLayoutOnPaint) {
layoutContainer();
}
g.translate(getX(), getY());
int size = components.size();
int startIter = 0;
if (size >= 30) {
int clipX1 = g.getClipX();
int clipX2 = g.getClipX() + g.getClipWidth();
int clipY1 = g.getClipY();
int clipY2 = g.getClipY() + g.getClipHeight();
startIter = calculateFirstPaintableOffset(clipX1, clipY1, clipX2, clipY2);
if (startIter < 0) {
// There was no efficient way to calculate the offset
startIter = 0;
} else if (startIter < size) {
// There was an efficient way to calculate the offset so we
// will continue this approach
size = calculateLastPaintableOffset(startIter, clipX1, clipY1, clipX2, clipY2) + 1;
}
}
CodenameOneImplementation impl = Display.impl;
if (dontRecurseContainer) {
for (int iter = startIter; iter < size; iter++) {
Component cmp = components.get(iter);
if (cmp.getClass() == Container.class) {
paintContainerChildrenForAnimation((Container) cmp, g);
} else {
cmp.paintInternal(impl.getComponentScreenGraphics(this, g), false);
}
}
} else {
for (int iter = startIter; iter < size; iter++) {
Component cmp = components.get(iter);
cmp.paintInternal(impl.getComponentScreenGraphics(this, g), false);
}
}
int tx = g.getTranslateX();
int ty = g.getTranslateY();
g.translate(-tx, -ty);
if (sidemenuBarTranslation > 0) {
g.translate(sidemenuBarTranslation, 0);
paintGlass(g);
paintTensile(g);
g.translate(-sidemenuBarTranslation, 0);
} else {
paintGlass(g);
paintTensile(g);
}
g.translate(tx, ty);
g.translate(-getX(), -getY());
}
use of com.codename1.ui.Graphics in project CodenameOne by codenameone.
the class Display method init.
/**
* This is the INTERNAL Display initialization method, it will be removed in future versions of the API.
* This method must be called before any Form is shown
*
* @param m platform specific object used by the implementation
* @deprecated this method is invoked internally do not invoke it!
*/
public static void init(Object m) {
if (!INSTANCE.codenameOneRunning) {
INSTANCE.codenameOneRunning = true;
INSTANCE.displayInitTime = System.currentTimeMillis();
// restore menu state from previous run if exists
int commandBehaviour = COMMAND_BEHAVIOR_DEFAULT;
if (INSTANCE.impl != null) {
commandBehaviour = INSTANCE.impl.getCommandBehavior();
}
INSTANCE.impl = (CodenameOneImplementation) ImplementationFactory.getInstance().createImplementation();
INSTANCE.impl.setDisplayLock(lock);
INSTANCE.impl.initImpl(m);
INSTANCE.codenameOneGraphics = new Graphics(INSTANCE.impl.getNativeGraphics());
INSTANCE.codenameOneGraphics.paintPeersBehind = INSTANCE.impl.paintNativePeersBehind();
INSTANCE.impl.setCodenameOneGraphics(INSTANCE.codenameOneGraphics);
// only enable but never disable the third softbutton
if (INSTANCE.impl.isThirdSoftButton()) {
INSTANCE.thirdSoftButton = true;
}
if (INSTANCE.impl.getSoftkeyCount() > 0) {
MenuBar.leftSK = INSTANCE.impl.getSoftkeyCode(0)[0];
if (INSTANCE.impl.getSoftkeyCount() > 1) {
MenuBar.rightSK = INSTANCE.impl.getSoftkeyCode(1)[0];
if (INSTANCE.impl.getSoftkeyCode(1).length > 1) {
MenuBar.rightSK2 = INSTANCE.impl.getSoftkeyCode(1)[1];
}
}
}
MenuBar.backSK = INSTANCE.impl.getBackKeyCode();
MenuBar.backspaceSK = INSTANCE.impl.getBackspaceKeyCode();
MenuBar.clearSK = INSTANCE.impl.getClearKeyCode();
INSTANCE.PATHLENGTH = INSTANCE.impl.getDragPathLength();
INSTANCE.dragPathX = new float[INSTANCE.PATHLENGTH];
INSTANCE.dragPathY = new float[INSTANCE.PATHLENGTH];
INSTANCE.dragPathTime = new long[INSTANCE.PATHLENGTH];
com.codename1.util.StringUtil.setImplementation(INSTANCE.impl);
com.codename1.io.Util.setImplementation(INSTANCE.impl);
// generally its probably a bug but we can let it slide...
if (INSTANCE.edt == null) {
INSTANCE.touchScreen = INSTANCE.impl.isTouchDevice();
// initialize the Codename One EDT which from now on will take all responsibility
// for the event delivery.
INSTANCE.edt = new CodenameOneThread(new RunnableWrapper(null, 3), "EDT");
INSTANCE.impl.setThreadPriority(INSTANCE.edt, INSTANCE.impl.getEDTThreadPriority());
INSTANCE.edt.start();
}
INSTANCE.impl.postInit();
INSTANCE.setCommandBehavior(commandBehaviour);
} else {
INSTANCE.impl.confirmControlView();
}
}
Aggregations