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


Java Graphics.setColor方法代码示例

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


在下文中一共展示了Graphics.setColor方法的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: run

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
public void run() {
	synchronized (UiApplication.getEventLock()) {
		if (_time > 0) {
			Bitmap _bmp = new Bitmap(Display.getWidth(),
					Display.getHeight());
			Graphics g = new Graphics(_bmp);
			g.setColor(Color.BLACK);
			g.fillRect(0, 0, Display.getWidth(), Display.getHeight());
			g.drawBitmap(
					((_bmp.getWidth() / 2) - (_img.getWidth() / 2)), 0,
					_img.getWidth(), _img.getHeight(), _img, 0, 0);
			g.setColor(Color.WHITE);
			g.drawText(_time + "s", Display.getWidth() - 60,
					Display.getHeight() - 50);
			bmp.setBitmap(_bmp);
			_time--;				
		} else {
			t.cancel();
			quit();
						
		}
	}
}
 
开发者ID:PropheteMath,项目名称:CrapSnap,代码行数:24,代码来源:DisplaySnap.java

示例3: 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

示例4: 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

示例5: run

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
public void run() {
	synchronized (UiApplication.getEventLock()) {
		if (_time > 0) {
			Bitmap _bmp = new Bitmap(Display.getWidth(),
					Display.getHeight());
			Graphics g = new Graphics(_bmp);
			g.setColor(Color.BLACK);
			g.fillRect(0, 0, Display.getWidth(), Display.getHeight());
			g.drawBitmap(
					((_bmp.getWidth() / 2) - (_img.getWidth() / 2)), 0,
					_img.getWidth(), _img.getHeight(), _img, 0, 0);
			g.setColor(Color.WHITE);
			g.drawText(_time + "s", Display.getWidth() - 60,
					Display.getHeight() - 50);
			bmp.setBitmap(_bmp);
			_time--;				
		} else {
			t.cancel();
			quit();			
		}
	}
}
 
开发者ID:PropheteMath,项目名称:CrapSnap,代码行数:23,代码来源:DisplayStory.java

示例6: DrawTime

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
private void DrawTime(int X, int Y) {
	Graphics gd = new Graphics(bmpd);
	Graphics g = new Graphics(bmp);
	Font gsavefong = g.getFont();
	Font myFont = g.getFont();
	g.setColor(currentcolor);
	gd.setColor(currentcolor);
	g.setFont(myFont.derive(Font.LATIN_SCRIPT, 15, Ui.UNITS_mm));
	gd.setFont(myFont.derive(Font.LATIN_SCRIPT, 15, Ui.UNITS_mm));
	Date current = new Date();
	String txt = current.toString().substring(11, 17);
	int size = g.getFont().getAdvance(txt);
	g.drawText(txt, X - size / 2,
			Y - Ui.convertSize(15, Ui.UNITS_mm, Ui.UNITS_px) / 2);
	gd.drawText(txt, X - size / 2,
			Y - Ui.convertSize(15, Ui.UNITS_mm, Ui.UNITS_px) / 2);
	g.setFont(gsavefong);
	gd.setFont(gsavefong);
	actualize();
	hour = false;
}
 
开发者ID:PropheteMath,项目名称:CrapSnap,代码行数:22,代码来源:EditSnap.java

示例7: 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

示例8: 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

示例9: paint

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
public void paint(Graphics g) {
    int f = getFieldCount();
    if(f > 0) {
        g.drawBitmap(0, 0, getWidth(), getHeight(), screen, 0, 0);

        Form currentForm = Display.getInstance().getCurrent();
        for(int iter = 0 ; iter < f ; iter++) {
            Field fld = getField(iter);
            int pops = 0;
            if(currentForm != null) {
                PeerComponent p = findPeer(currentForm.getContentPane(), fld);
                if(p != null) {
                    pops = clipOnLWUITBounds(p, g);
                } else {
                    Component cmp = currentForm.getFocused();

                    // we are now editing an edit field
                    if(cmp != null && cmp instanceof TextArea && cmp.hasFocus() && fld instanceof EditField) {
                        pops = clipOnLWUITBounds(cmp, g);
                        int x = fld.getLeft();
                        int y = fld.getTop();
                        g.clear(x, y, Math.max(cmp.getWidth(), fld.getWidth()),
                                Math.max(cmp.getHeight(), fld.getHeight()));
                    }
                }
            }
            paintChild(g, fld);
            while(pops > 0) {
                g.popContext();
                pops--;
            }
        }
    } else {
        g.drawBitmap(0, 0, getWidth(), getHeight(), screen, 0, 0);
    }
    g.setColor(0);
    g.drawText(debug, 0, 0);
    painted = true;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:40,代码来源:BlackBerryCanvas.java

示例10: createMutableImage

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
public Object createMutableImage(int width, int height, int fillColor) {
    Bitmap b = new Bitmap(width, height);
    Graphics g = new Graphics(b);
    if ((fillColor & 0xff000000) != 0xff000000) {
        g.setColor(fillColor & 0xffffff);
        int oldAlpha = g.getGlobalAlpha();
        g.setGlobalAlpha((fillColor >> 24) & 0xff);
        g.clear();
        g.setGlobalAlpha(oldAlpha);
    } else {
        g.setColor(fillColor & 0xffffff);
        g.fillRect(0, 0, width, height);
    }
    return b;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:16,代码来源:BlackBerryImplementation.java

示例11: paintTransformedBitmap

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
/**
 * Paint the transformed Bitmap using the given Graphics context. Paints the
 * area transparent before painting the bitmap.
 * 
 * @param g
 *            the {@link Graphics} context to use - from a screen or bitmap,
 *            etc.
 * @param textureOriginX
 *            x value in the original bitmap to start drawing from
 * @param textureOriginY
 *            y value in the original bitmap to start drawing from
 * @since 1.1
 */
private void paintTransformedBitmap(Graphics g, int textureOriginX, int textureOriginY) {
	// Make the drawing space transparent first before painting
	g.setGlobalAlpha(getBackgroundAlpha());
	g.setBackgroundColor(getBackgroundColor());
	g.clear();
	g.setGlobalAlpha(255);
	/**
	 * Keep the precision of our transformation and Scale the drawing as
	 * well. Scale is applied as though a matrix of the form
	 * 
	 * <pre>
	 * | ScaleX  0     0|
	 * | 0    ScaleY   0|
	 * | 0       0     1|
	 * </pre>
	 * 
	 * is multiplied by the Transformation matrix
	 **/

	int dux = Fixed32.div(transformMatrix[UX], resultantScaleX);
	int dvx = Fixed32.div(transformMatrix[VX], resultantScaleY);
	int duy = Fixed32.div(transformMatrix[UY], resultantScaleX);
	int dvy = Fixed32.div(transformMatrix[VY], resultantScaleY);
	
   // Needed for alpha changes in 6.0 with Graphics.clear()
   g.setColor(Graphics.WHITE);
	g.drawFilledPath(bitmapXPts, bitmapYPts, null, null);
	
	g.drawTexturedPath(bitmapXPts, bitmapYPts, null, null, textureOriginX, textureOriginY, dux, dvx, duy, dvy, bitmap);
}
 
开发者ID:PropheteMath,项目名称:CrapSnap,代码行数:44,代码来源:ImageManipulator.java

示例12: paintPoint

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
void paintPoint(int x, int y, Graphics graphics) {
	System.out.println("Painting Point - at: " + x + ":" + y);
	if (FILL_MODE) {
		graphics.setColor(TRACE_COLOR);
		graphics.fillArc(x, y, CIRCLE_RADIUS,
				CIRCLE_RADIUS, 0, 360);
		graphics.setColor(0x00000000);
	} else {
		graphics.setColor(TRACE_COLOR);
		graphics.drawPoint(x, y);
	}
}
 
开发者ID:PropheteMath,项目名称:CrapSnap,代码行数:13,代码来源:DrawPoints.java

示例13: 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

示例14: 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

示例15: 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


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