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


Java Graphics.setGlobalAlpha方法代码示例

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


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

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
public static void drawAlphaGradientString(
        String text, Graphics g, int x, int y, boolean toRight) {
    int oldAlpha = g.getGlobalAlpha();
    try {
        int dx = 0, currentAlpha = toRight ? 255 : 55;
        int step = (toRight ? -1 : 1) * 200 / text.length();
        for (int i = 0; i < text.length(); ++i) {
            char c = text.charAt(i);
            g.setGlobalAlpha(currentAlpha);
            g.drawText("" + c, x + dx, y);
            dx += g.getFont().getAdvance(c);
            currentAlpha += step;
        }
    } finally {
        g.setGlobalAlpha(oldAlpha);
    }
}
 
开发者ID:yanex,项目名称:vika,代码行数:18,代码来源:TextDrawHelper.java

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

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

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

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

示例7: AddText

import net.rim.device.api.ui.Graphics; //导入方法依赖的package包/类
private void AddText(int X, int Y, String text) {
	Graphics gd = new Graphics(bmpd);
	final Graphics g = new Graphics(bmp);
	try {
		int i;
		String txt = new String("");
		if (text.equals("") == true) {
			Dialog d = new Dialog(Dialog.D_OK_CANCEL,
					"Enter a text to add :", Dialog.OK, null,
					Dialog.DEFAULT_CLOSE);
			inputField = new BasicEditField();
			inputField.setChangeListener(new FieldChangeListener() {
				public void fieldChanged(Field arg0, int arg1) {
					if (g.getFont().getAdvance(inputField.getText()) > Display
							.getWidth() - 20) {
						inputField
								.setMaxSize(inputField.getText().length());
					} else {
						inputField.setMaxSize(200);
					}
				}
			});
			d.add(inputField);
			i = d.doModal();
			txt = inputField.getText();
			caption = txt;
		} else {
			txt = text;
			i = Dialog.OK;
		}
		Y = Y - 10;
		X = (Display.getWidth() / 2) - ((g.getFont().getAdvance(txt)) / 2);
		if (i == Dialog.OK) {
			g.setColor(Color.BLACK);
			g.setGlobalAlpha(128);
			gd.setColor(Color.BLACK);
			gd.setGlobalAlpha(128);
			g.fillRect(0, Y - 4, Display.getWidth(), 45);
			gd.fillRect(0, Y - 4, Display.getWidth(), 45);
			gd.setColor(currentcolor);
			gd.setGlobalAlpha(255);
			g.setColor(currentcolor);
			g.setGlobalAlpha(255);
			g.drawText(txt, X, Y);
			gd.drawText(txt, X, Y);
			gd.drawBitmap(55, 5, 50, 50, _20img, 0, 0);
			gd.drawBitmap(0, Display.getHeight() - 100, 100, 100, _0img, 0,
					0);
			gd.drawBitmap(Display.getWidth() - 55, 5, 55, 50, _2img, 0, 0);
			if (_drawing == false) {
				gd.drawBitmap(5, 5, 50, 50, _10img, 0, 0);
			} else {
				gd.drawBitmap(5, 5, 50, 50, _11img, 0, 0);
			}
			gd.drawBitmap(Display.getWidth() - 100,
					Display.getHeight() - 100, 100, 100, _1img, 0, 0);
			actualize();
		}
	} catch (Exception E) {

	}
}
 
开发者ID:PropheteMath,项目名称:CrapSnap,代码行数:63,代码来源:EditSnap.java


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