当前位置: 首页>>代码示例>>Java>>正文


Java Graphics.getColor方法代码示例

本文整理汇总了Java中net.rim.device.api.ui.Graphics.getColor方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.getColor方法的具体用法?Java Graphics.getColor怎么用?Java Graphics.getColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.rim.device.api.ui.Graphics的用法示例。


在下文中一共展示了Graphics.getColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setClip

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
public void setClip(Object graphics, int x, int y, int width, int height) {
    Graphics g = (net.rim.device.api.ui.Graphics) graphics;
    net.rim.device.api.ui.Font oldFont = g.getFont();
    int oldColor = g.getColor();
    int oldAlpha = g.getGlobalAlpha();
    while (g.getContextStackSize() > 1) {
        g.popContext();
    }
    g.pushRegion(x, y, width, height, 0, 0);
    g.translate(-g.getTranslateX(), -g.getTranslateY());
    /**
     * applying a clip will automatically
     * reset some information that we need to keep track of
     * manually (it seems).
     */
    g.setFont(oldFont == null ? (net.rim.device.api.ui.Font) getDefaultFont() : oldFont);
    g.setColor(oldColor);
    g.setGlobalAlpha(oldAlpha);
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:20,代码来源:BlackBerryImplementation.java

示例2: draw

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
public void draw(Graphics g, XYRect r) {
    int x = r.x + padding.left;
    int y = r.y + padding.top;
    int width = r.width - padding.left - padding.right;
    int height = r.height - padding.top - padding.bottom;

    XYRect rect = new XYRect(x, y, width, height);

    int oldColor = g.getColor();
    g.setColor(color);
    g.fillRoundRect(rect.x, rect.y, rect.width, rect.height, arc, arc);
    if (drawBorder) {
        g.setColor(borderColor);
        g.drawRoundRect(rect.x, rect.y, rect.width, rect.height, arc, arc);
    }
    g.setColor(oldColor);
}
 
开发者ID:yanex,项目名称:vika,代码行数:18,代码来源:RoundedBackground.java

示例3: draw

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
public void draw(Graphics g, XYRect rect) {
    int[] path = {startColor, startColor, endColor, endColor};

    int[] xes = {0x0, rect.width, rect.width, 0};
    int[] yes = {0x0, 0x0, rect.height, rect.height};

    g.translate(rect.x, rect.y);
    g.drawShadedFilledPath(xes, yes, null, path, null);
    g.translate(-rect.x, -rect.y);

    int oldColor = g.getColor();

    if (topBorderHeight > 0) {
        g.setColor(topBorderColor);
        g.fillRect(rect.x, rect.y, rect.width, topBorderHeight);
    }

    if (bottomBorderHeight > 0) {
        g.setColor(bottomBorderColor);
        g.fillRect(rect.x, rect.y - bottomBorderHeight, rect.width, bottomBorderHeight);
    }

    g.setColor(oldColor);
}
 
开发者ID:yanex,项目名称:vika,代码行数:25,代码来源:GradientBackground.java

示例4: paint

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
protected void paint(Graphics g) {
    int oldColor = g.getColor();
    try {
        if (isFocused() || isActive()) {
            g.setColor(getTheme().getSecondaryFontColor());
        } else {
            g.setColor(getTheme().getPrimaryColor());
        }

        int dy = (getContentHeight() - g.getFont().getHeight()) / 2;
        int dx = (getContentWidth() - g.getFont().getAdvance(text)) / 2;
        g.drawText(text, dx, dy, DrawStyle.TOP | DrawStyle.LEFT, Integer.MAX_VALUE);
    } finally {
        g.setColor(oldColor);
    }
}
 
开发者ID:yanex,项目名称:vika,代码行数:17,代码来源:ButtonField.java

示例5: paint

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
protected void paint(Graphics g) {
    if (bitmap != null) {
        bitmap.draw(g, 0, 0, getContentWidth(), getContentHeight());
    } else if (defaultBitmap != null) {
        defaultBitmap.draw(g, 0, 0, getContentWidth(), getContentHeight());
    }
    if (text != null) {
        int h = R.px(10);

        int oldAlpha = g.getGlobalAlpha();
        int oldColor = g.getColor();

        g.setGlobalAlpha(150);
        g.fillRect(0, getContentHeight() - h, getContentWidth(), h);
        g.setGlobalAlpha(200);
        g.setColor(0xEEEEEE);
        g.drawText(text, getContentWidth() / 2, getContentHeight() - h / 2, DrawStyle.HCENTER);

        g.setGlobalAlpha(oldAlpha);
        g.setColor(oldColor);
    }
}
 
开发者ID:yanex,项目名称:vika,代码行数:23,代码来源:ImageField.java

示例6: paint

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
protected void paint(Graphics g) {
    int oldColor = g.getColor();

    try {
        int x = getContentLeft() + getContentWidth() - image.getWidth() - VkCompactTitleField.px(1);
        int y = (getContentHeight() - image.getHeight()) / 2;

        if (animationLaunched) {
            g.drawBitmap(x, y, image.getWidth(), image.getHeight(),
                    image.getBitmap(currentFrame), 0, 0);
        }

        if (text != null) {
            g.setColor(0xffffff);
            g.drawText(text, getContentLeft(), (getContentHeight() - g.getFont().getHeight()) / 2);
        }
    } finally {
        g.setColor(oldColor);
    }
}
 
开发者ID:yanex,项目名称:vika,代码行数:21,代码来源:VkCompactTitleField.java

示例7: paint

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
protected void paint(Graphics g, XYRect rect) {
    int oldColor = g.getColor(), dy = (rect.height - FONT.getHeight()) / 2, color = (isActive() || isFocused()) ?
            getTheme().getSecondaryFontColor()
            : getTheme().getPrimaryColor();
    try {
        g.setFont(FONT);
        g.setColor(color);
        TextDrawHelper.drawEllipsizedString(text, g, rect.x, rect.y + dy, rect.width);
    } finally {
        g.setColor(oldColor);
    }
}
 
开发者ID:yanex,项目名称:vika,代码行数:13,代码来源:SongItem.java

示例8: paint

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
protected void paint(Graphics g) {
    int oldColor = g.getColor();

    if (displayingHint) {
        g.setColor(theme.getSecondaryFontColor());
        g.drawText(hint, 0, 0);
    } else {
        g.setColor(theme.getPrimaryColor());
        super.paint(g);
    }

    g.setColor(oldColor);
}
 
开发者ID:yanex,项目名称:vika,代码行数:14,代码来源:CustomPasswordEditField.java

示例9: paint

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
protected void paint(Graphics g) {
    int oldColor = g.getColor();
    try {
        int maxWidth = getContentWidth() - bmp.getWidth() - ImageTextButtonField.INTERVAL;
        String cutted = TextDrawHelper.calcEllipsize(text, g, maxWidth);

        int y = (getContentHeight() - bmp.getHeight()) / 2;
        int x = (getContentWidth() - bmp.getWidth() - ImageTextButtonField.INTERVAL - getFont()
                .getAdvance(cutted)) / 2;

        g.drawBitmap(x, y, bmp.getWidth(), bmp.getHeight(), bmp, 0, 0);

        if (isFocused() || isActive()) {
            g.setColor(getTheme().getSecondaryFontColor());
        } else {
            g.setColor(getTheme().getPrimaryColor());
        }

        if (g.getFont().getAdvance(text) > maxWidth) {
            TextDrawHelper.drawEllipsizedString(text, g,
                    x + bmp.getWidth() + ImageTextButtonField.INTERVAL,
                    (getContentHeight() - g.getFont().getHeight()) / 2, maxWidth);
        } else {
            g.drawText(text, x + bmp.getWidth() + ImageTextButtonField.INTERVAL,
                    getContentHeight() / 2,
                    DrawStyle.VCENTER, getContentWidth());
        }
    } finally {
        g.setColor(oldColor);
    }
}
 
开发者ID:yanex,项目名称:vika,代码行数:32,代码来源:ImageTextButtonField.java

示例10: paint

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
protected void paint(Graphics g) {
    int oldColor = g.getColor();
    try {
        g.setColor(color);
        g.fillRect(0, 0, getWidth(), getHeight());
    } finally {
        g.setColor(oldColor);
    }
}
 
开发者ID:yanex,项目名称:vika,代码行数:10,代码来源:SeparatorField.java

示例11: paint

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
protected void paint(Graphics g) {
    int oldColor = g.getColor();

    if (theme != null) {
        g.setColor(theme.getPrimaryColor());
    } else {
        g.setColor(0);
    }

    super.paint(g);
    g.setColor(oldColor);
}
 
开发者ID:yanex,项目名称:vika,代码行数:13,代码来源:CustomLabelField.java

示例12: draw

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
public void draw(Graphics g, int x, int y) {
    int oldColor = g.getColor();
    try {
        g.setColor(color);
        for (int i = 0; i < size(); ++i) {
            if (elementAt(i) instanceof Element) {
                Element em = (Element) elementAt(i);
                em.draw(g, x, y);
                y += em.getHeight();
            }
        }
    } finally {
        g.setColor(oldColor);
    }
}
 
开发者ID:yanex,项目名称:vika,代码行数:16,代码来源:TextField.java

示例13: paint

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
protected void paint(Graphics g) {
    int oldColor = g.getColor();
    try {
        g.setColor(theme.getPrimaryColor());
        TextDrawHelper.drawEllipsizedString(text, g, 0, 0, getWidth());
    } finally {
        g.setColor(oldColor);
    }
}
 
开发者ID:yanex,项目名称:vika,代码行数:10,代码来源:SimpleLabelField.java

示例14: draw

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
public void draw(Graphics g, XYRect r) {
    super.draw(g, r);

    XYEdges padding = getPadding();

    int x = r.x + padding.left;
    int y = r.y + padding.top;
    int width = r.width - padding.left - padding.right;
    int height = r.height - padding.top - padding.bottom;

    int x1, x2, x3, y1, y2, y3;

    if (padding.left > padding.right) {
        x1 = x;
        y1 = y + height - BalloonBackground.RADIUS / 2;

        x2 = x1 - BalloonBackground.PADDING * 2;
        y2 = y1 - BalloonBackground.PADDING;

        x3 = x1;
        y3 = y2 - BalloonBackground.PADDING;
    } else {
        x1 = x + width;
        y1 = y + height - BalloonBackground.RADIUS / 2;

        x2 = x1 + BalloonBackground.PADDING * 2;
        y2 = y1 - BalloonBackground.PADDING;

        x3 = x1;
        y3 = y2 - BalloonBackground.PADDING;
    }

    int[] xes = {x1, x2, x3};
    int[] yes = {y1, y2, y3};

    int oldColor = g.getColor();
    g.setColor(getColor());
    g.drawFilledPath(xes, yes, null, null);

    g.setColor(oldColor);
}
 
开发者ID:yanex,项目名称:vika,代码行数:42,代码来源:BalloonBackground.java

示例15: paint

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
protected void paint(Graphics g) {
    int oldColor = g.getColor();
    int oldAlpha = g.getGlobalAlpha();

    int height = getContentHeight(), width = getContentWidth();

    int color = getTheme().getPrimaryColor();
    if (isFocused() || isActive()) {
        color = getTheme().getSecondaryFontColor();
    }

    try {
        Font f = PaneCaptionField.font;

        int y = (height - f.getHeight()) / 2;

        int centerX = width / 2 - dx;

        g.setGlobalAlpha(255);
        g.setFont(f);
        g.setColor(color);

        int curX = centerX;
        for (int i = 0; i < titles.size(); ++i) {
            String t = (String) titles.elementAt(i);
            int x = curX - f.getAdvance(t) / 2;

            if (i < current) {
                TextDrawHelper.drawAlphaGradientString(t, g, x, y, true);
            } else if (i > current) {
                TextDrawHelper.drawAlphaGradientString(t, g, x, y, false);
            } else {
                g.drawText(t, x, y);
            }
            curX += width / 2;
            if (curX > width) {
                break;
            }
        }
    } finally {
        g.setColor(oldColor);
        g.setGlobalAlpha(oldAlpha);
    }
}
 
开发者ID:yanex,项目名称:vika,代码行数:45,代码来源:PaneCaptionField.java


注:本文中的net.rim.device.api.ui.Graphics.getColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。