Search in sources :

Example 86 with Graphics

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);
    }
}
Also used : Style(com.codename1.ui.plaf.Style) Point(com.codename1.ui.geom.Point)

Example 87 with Graphics

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);
}
Also used : Point(com.codename1.ui.geom.Point) CodenameOneImplementation(com.codename1.impl.CodenameOneImplementation)

Example 88 with Graphics

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);
}
Also used : Border(com.codename1.ui.plaf.Border)

Example 89 with Graphics

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);
    }
}
Also used : Point(com.codename1.ui.geom.Point)

Example 90 with Graphics

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);
    }
}
Also used : BasicStroke(java.awt.BasicStroke) Timeline(com.codename1.ui.animations.Timeline) Color(java.awt.Color) AnimationObject(com.codename1.ui.animations.AnimationObject) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D)

Aggregations

Image (com.codename1.ui.Image)18 Component (com.codename1.ui.Component)17 Point (com.codename1.ui.geom.Point)16 Style (com.codename1.ui.plaf.Style)15 Graphics (com.codename1.ui.Graphics)14 Form (com.codename1.ui.Form)12 Font (com.codename1.ui.Font)11 GeneralPath (com.codename1.ui.geom.GeneralPath)9 Rectangle (com.codename1.ui.geom.Rectangle)9 Animation (com.codename1.ui.animations.Animation)8 Dialog (com.codename1.ui.Dialog)7 Dimension (com.codename1.ui.geom.Dimension)6 Painter (com.codename1.ui.Painter)5 ActionEvent (com.codename1.ui.events.ActionEvent)5 FontImage (com.codename1.ui.FontImage)4 RGBImage (com.codename1.ui.RGBImage)4 Motion (com.codename1.ui.animations.Motion)4 ActionListener (com.codename1.ui.events.ActionListener)4 BorderLayout (com.codename1.ui.layouts.BorderLayout)4 IOException (java.io.IOException)4