use of com.codename1.ui.Graphics in project CodenameOne by codenameone.
the class Component method paintInternalImpl.
private void paintInternalImpl(Graphics g, boolean paintIntersects) {
int oX = g.getClipX();
int oY = g.getClipY();
int oWidth = g.getClipWidth();
int oHeight = g.getClipHeight();
if (bounds.intersects(oX, oY, oWidth, oHeight)) {
Style s = getStyle();
if (s.getOpacity() < 255 && g.isAlphaSupported()) {
int oldAlpha = g.getAlpha();
g.setAlpha(s.getOpacity());
internalPaintImpl(g, paintIntersects);
g.setAlpha(oldAlpha);
} else {
internalPaintImpl(g, paintIntersects);
}
g.setClip(oX, oY, oWidth, oHeight);
} else {
Display.impl.nothingWithinComponentPaint(this);
}
}
use of com.codename1.ui.Graphics in project CodenameOne by codenameone.
the class Component method paintInternal.
final void paintInternal(Graphics g, boolean paintIntersects) {
Display d = Display.getInstance();
CodenameOneImplementation impl = d.getImplementation();
if (!isVisible()) {
return;
}
if (paintLockImage != null) {
if (paintLockImage instanceof Image) {
Image i = (Image) paintLockImage;
g.drawImage(i, getX(), getY());
} else {
Image i = (Image) d.extractHardRef(paintLockImage);
if (i == null) {
i = Image.createImage(getWidth(), getHeight());
int x = getX();
int y = getY();
setX(0);
setY(0);
paintInternalImpl(i.getGraphics(), paintIntersects);
setX(x);
setY(y);
paintLockImage = d.createSoftWeakRef(i);
}
g.drawImage(i, getX(), getY());
}
return;
}
impl.beforeComponentPaint(this, g);
paintInternalImpl(g, paintIntersects);
impl.afterComponentPaint(this, g);
}
use of com.codename1.ui.Graphics in project CodenameOne by codenameone.
the class Component method paintBackgroundImpl.
private void paintBackgroundImpl(Graphics g) {
if (isBorderPainted()) {
Border b = getBorder();
if (b != null && b.isBackgroundPainter()) {
b.paintBorderBackground(g, this);
paintRippleEffect(g);
return;
}
}
if (getStyle().getBgPainter() != null) {
getStyle().getBgPainter().paint(g, bounds);
}
paintBackground(g);
paintRippleEffect(g);
}
use of com.codename1.ui.Graphics in project CodenameOne by codenameone.
the class Component method internalPaintImpl.
void internalPaintImpl(Graphics g, boolean paintIntersects) {
g.clipRect(getX(), getY(), getWidth(), getHeight());
paintComponentBackground(g);
if (isScrollable()) {
if (refreshTask != null && (draggedMotionY == null || getClientProperty("$pullToRelease") != null)) {
paintPullToRefresh(g);
}
int scrollX = getScrollX();
int scrollY = getScrollY();
g.translate(-scrollX, -scrollY);
paint(g);
g.translate(scrollX, scrollY);
if (isScrollVisible) {
paintScrollbars(g);
}
} else {
paint(g);
}
if (isBorderPainted()) {
paintBorder(g);
}
// paint all the intersecting Components above the Component
if (paintIntersects && parent != null) {
paintIntersectingComponentsAbove(g);
}
}
use of com.codename1.ui.Graphics in project CodenameOne by codenameone.
the class CodenameOneImageRenderer method paintComponent.
@Override
public void paintComponent(Graphics g) {
g.setColor(new Color(CheckerBoardColorCalibration.getColorA()));
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(new Color(CheckerBoardColorCalibration.getColorB()));
int width = getWidth();
int height = getHeight();
for (int x = 0; x < width; x += 8) {
if (x % 16 == 0) {
for (int y = 0; y < height; y += 16) {
g.fillRect(x, y, 8, 8);
}
} else {
for (int y = 8; y < height; y += 16) {
g.fillRect(x, y, 8, 8);
}
}
}
if (drawBorder) {
g.setColor(Color.BLACK);
g.drawRect(0, 0, image.getWidth() + 1, image.getHeight() + 1);
}
if (zoom != 1) {
((Graphics2D) g).scale(zoom, zoom);
}
if (animationObjectList != null) {
if (((Timeline) image).isPause()) {
int selectedRow = animationObjectList.getSelectedRow();
AnimationObject sel = null;
if (selectedRow > -1) {
sel = ((TimelineEditor.AnimationObjectTableModel) animationObjectList.getModel()).getElementAt(selectedRow);
}
if (dragging != null) {
if (draggingImage == null) {
draggingImage = new BufferedImage(AnimationAccessor.getWidthInt(dragging), AnimationAccessor.getHeightInt(dragging), BufferedImage.TYPE_INT_ARGB);
draggingImage.setRGB(0, 0, draggingImage.getWidth(), draggingImage.getHeight(), AnimationAccessor.getImageMethod(dragging).modifyAlpha((byte) 110).getRGB(), 0, draggingImage.getWidth());
}
} else {
draggingImage = null;
}
if (sel != null) {
Graphics2D g2d = (Graphics2D) g.create();
g2d.drawImage(buffer[currentFrame], 0, 0, this);
g2d.setColor(Color.BLUE);
g2d.setStroke(new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
g2d.drawRect(AnimationAccessor.getX(sel), AnimationAccessor.getY(sel), AnimationAccessor.getWidthInt(sel), AnimationAccessor.getHeightInt(sel));
if (draggingImage != null) {
g2d.drawImage(draggingImage, dragX, dragY, null);
}
g2d.dispose();
return;
}
}
}
g.drawImage(buffer[currentFrame], 0, 0, this);
if (draggingImage != null) {
g.drawImage(draggingImage, dragX, dragY, null);
}
}
Aggregations