Package com.sun.dtv.lwuit

Examples of com.sun.dtv.lwuit.Image


        int width = rect.getSize().getWidth();
        int height = rect.getSize().getHeight();
        if (width <= 0 || height <= 0) {
            return;
        }
        Image bgImage = s.getBgImage();
        if (bgImage == null) {
            if (parent.hasFocus() && parent.isFocusPainted()) {
                g.setColor(s.getBgSelectionColor());
                g.fillRect(x, y, width, height, s.getBgTransparency());
            } else {
                g.setColor(s.getBgColor());
                g.fillRect(x, y, width, height, s.getBgTransparency());
            }
        } else {
            if (s.isScaleImage()) {
                if (bgImage.getWidth() != width || bgImage.getHeight() != height) {
                    bgImage = bgImage.scaled(width, height);
                    s.setBgImage(bgImage, true);
                }
            } else {
                int iW = bgImage.getWidth();
                int iH = bgImage.getHeight();
                for(int xPos = 0 ; xPos < width ; xPos += iW) {
                    for(int yPos = 0 ; yPos < height ; yPos += iH) {
                        g.drawImage(s.getBgImage(), x + xPos, y + yPos);
                    }
                }
View Full Code Here


        int prefH = 0;

        Style style = l.getStyle();
        int gap = l.getGap();
        for (int i = 0; i < icons.length; i++) {
            Image icon = icons[i];
            if (icon != null) {
                prefW = Math.max(prefW, icon.getWidth());
                prefH = Math.max(prefH, icon.getHeight());
            }
        }
        String text = l.getText();
        Font font = style.getFont();
        if (font == null) {
View Full Code Here

        g.drawString(text, l.getShiftText() + x, y);
        return Math.min(f.stringWidth(text), textSpaceW);
    }

    private Image getIconFromState(Button b) {
        Image icon = null;
        switch (b.getState()) {
            case Button.STATE_DEAFULT:
                icon = b.getIcon();
                break;
            case Button.STATE_PRESSED:
View Full Code Here

    }

    private int getAvaliableSpaceForText(Label l) {
        Style style = l.getStyle();
        int textSpaceW = l.getWidth() - style.getPadding(Label.RIGHT) - style.getPadding(Label.LEFT);
        Image icon = l.getIcon();

        if (l instanceof Button) {
            icon = getIconFromState((Button) l);
        }

        if (icon != null && (l.getTextPosition() == Label.RIGHT || l.getTextPosition() == Label.LEFT)) {
            textSpaceW = textSpaceW - icon.getWidth();
        }
        int preserveSpaceForState = 0;

        if (l instanceof RadioButton) {
            if (rButtonImages != null) {
View Full Code Here

                height--;
                // rounded is also responsible for drawing the background
                Style s = c.getStyle();
                if(s.getBgImage() != null) {
                    // we need to draw a background image!
                    Image i = Image.createImage(width, height);
                    Graphics imageG = i.getGraphics();
                    imageG.setColor(0);
                    imageG.fillRoundRect(0, 0, width, height, arcWidth, arcHeight);
                    int[] rgb = i.getRGB();
                    int transColor = rgb[0];
                    int[] imageRGB = s.getBgImage().scaled(width, height).getRGB();
                    for(int iter = 0 ; iter < rgb.length ; iter++) {
                        if(rgb[iter] == transColor) {
                            imageRGB[iter] = 0;
                        }
                    }
                    g.drawImage(new RGBImage(imageRGB, width, height), x, y);
                } else {
                    int foreground = g.getColor();
                    if(c.hasFocus()) {
                        g.setColor(s.getBgSelectionColor());
                    } else {
                        g.setColor(s.getBgColor());
                    }

                    // Its opaque much easier job!
                    if(s.getBgTransparency() == ((byte)0xff)) {
                        g.fillRoundRect(x, y , width, height, arcWidth, arcHeight);
                    } else {
                        // if its transparent we don't need to do anything, if its
                        // translucent... well....
                        if(s.getBgTransparency() != 0) {
                            Image i = Image.createImage(width, height);
                            int[] imageRgb;
                            if(g.getColor() != 0xffffff) {
                                Graphics imageG = i.getGraphics();
                                imageG.setColor(g.getColor());
                                imageG.fillRoundRect(0, 0 , width, height, arcWidth, arcHeight);
                                imageRgb = i.getRGB();
                            } else {
                                // background color is white we need to remove a different color
                                // black is the only other "reliable" color on the device
                                Graphics imageG = i.getGraphics();
                                imageG.setColor(0);
                                imageG.fillRect(0, 0, width, height);
                                imageG.setColor(g.getColor());
                                imageG.fillRoundRect(0, 0 , width, height, arcWidth, arcHeight);
                                imageRgb = i.getRGB();
                            }
                            int removeColor = imageRgb[0];
                            int size = width * height;
                            int alphaInt = ((s.getBgTransparency() & 0xff) << 24) & 0xff000000;
                            for(int iter = 0 ; iter < size ; iter++) {
                                if(removeColor == imageRgb[iter]) {
                                        imageRgb[iter] = 0;
                                        continue;
                                }
                                if((imageRgb[iter] & 0xff000000) != 0) {
                                    imageRgb[iter] = (imageRgb[iter] & 0xffffff) | alphaInt;
                                }  
                            }
                            g.drawImage(new RGBImage(imageRgb, width, height), x, y);
                        }
                    }
                   
                    g.setColor(foreground);
                }
                break;
            case TYPE_IMAGE:
                int clipX = g.getClipX();
                int clipY = g.getClipY();
                int clipWidth = g.getClipWidth();
                int clipHeight = g.getClipHeight();
                Image topLeft = images[4];
                Image topRight = images[5];
                Image bottomLeft = images[6];
                Image center = images[8];
                x += topLeft.getWidth();
                y += topLeft.getHeight();
                height -= (topLeft.getHeight() + bottomLeft.getHeight());
                width -= (topLeft.getWidth() + topRight.getWidth());
                g.clipRect(x, y, width, height);
                int centerWidth = center.getWidth();
                int centerHeight = center.getHeight();
                for(int xCount = x ; xCount < x + width ; xCount += centerWidth) {
                    for(int yCount = y ; yCount < y + height ; yCount += centerHeight) {
                        g.drawImage(center, xCount, yCount);
                    }
                }
                Image top = images[0];  Image bottom = images[1];
                Image left = images[2]; Image right = images[3];
                Image bottomRight = images[7];
               
                g.setClip(clipX, clipY, clipWidth, clipHeight);
               
                x = c.getX();
                y = c.getY();
                width = c.getWidth();
                height = c.getHeight();
               
                g.drawImage(topLeft, x, y);
                g.drawImage(bottomLeft, x, y + height - bottomLeft.getHeight());
                g.drawImage(topRight, x + width - topRight.getWidth(), y);
                g.drawImage(bottomRight, x + width - bottomRight.getWidth(), y + height - bottomRight.getHeight());
               
                g.setClip(clipX, clipY, clipWidth, clipHeight);
                drawImageBorderLine(g, topLeft, topRight, top, x, y, width);
                g.setClip(clipX, clipY, clipWidth, clipHeight);
                drawImageBorderLine(g, bottomLeft, bottomRight, bottom, x, y + height - bottom.getHeight(), width);
View Full Code Here

        input.readFully(data);
        return data;
    }

    private Font loadFont(String id, boolean packed) throws IOException {
        Image bitmap;
        if(packed) {
            bitmap = createPackedImage8();
        } else {
            bitmap = createImage();
        }
View Full Code Here

            }

            // if this is a background image
            if(key.endsWith("bgImage")) {
                String imageId = input.readUTF();
                Image i = (Image)resources.get(imageId);

                // if the font is not yet loaded
                if(i == null) {
                    theme.put(key, imageId);
                    continue;
View Full Code Here

TOP

Related Classes of com.sun.dtv.lwuit.Image

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.