• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Graphics类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Graphics类属于net.rim.device.api.ui包,在下文中一共展示了Graphics类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: sublayout

import net.rim.device.api.ui.Graphics; //导入依赖的package包/类
public void sublayout(int w, int h) {
    //super.sublayout(w, h);
    // the alternative undeprecated API requires a signature
    if(net.rim.device.api.ui.Graphics.getScreenWidth() != screenWidth ||
            net.rim.device.api.ui.Graphics.getScreenHeight() != screenHeight) {
        screenWidth = net.rim.device.api.ui.Graphics.getScreenWidth();
        screenHeight = net.rim.device.api.ui.Graphics.getScreenHeight();
        if(screenWidth > 0 && screenHeight > 0) {
            screen = new Bitmap(screenWidth, screenHeight);
            globalGraphics = new Graphics(screen);
            if(impl != null) {
                impl.sizeChanged(screenWidth, screenHeight);
            }
        }
    }
    super.sublayout(w, h);
    
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:19,代码来源:BlackBerryCanvas.java


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


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


示例6: paint

import net.rim.device.api.ui.Graphics; //导入依赖的package包/类
protected void paint(Graphics g) {
    if (wrapped != g) {
        wrapped = g;
        graphicsWrapper = new com.nutiteq.wrappers.Graphics(g);
    }
    // paint on wrapper (in effect painting on native graphics)
    map.paint(graphicsWrapper);
    // remove pushContext() done inside library
    graphicsWrapper.popAll();

    if (touchOkShow) {
        int x = getContentWidth() - TouchMapField.OK_BITMAP.getWidth();
        int y = 0;// getContentHeight()-OK_BITMAP.getHeight();

        g.drawBitmap(x, y, TouchMapField.OK_BITMAP.getWidth(),
                TouchMapField.OK_BITMAP.getHeight(), TouchMapField.OK_BITMAP, 0, 0);
    }
}
 
开发者ID:yanex,项目名称:vika,代码行数:19,代码来源:TouchMapField.java


示例7: drawListRow

import net.rim.device.api.ui.Graphics; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void drawListRow(ListField listField, Graphics graphics, int index,
    int y, int width) {
  PinInfo item = mItems[index];
  
  int iconWidth = mIcon.getWidth();
  int iconHeight = mIcon.getHeight();
  int iconX = width - PADDING - iconWidth; 
  int iconY = y + Math.max(0, (mRowHeight - iconHeight) / 2);
  graphics.drawBitmap(iconX, iconY, iconWidth, iconHeight, mIcon, 0, 0);
  
  int textWidth = Math.max(0, width - iconWidth - PADDING * 3);
  int textX = PADDING;
  int textY = y + PADDING;
  int flags = Graphics.ELLIPSIS;
  Font savedFont = graphics.getFont();
  graphics.setFont(mUserFont);
  graphics.drawText(item.mUser, textX, textY, flags, textWidth);
  textY += mUserFont.getHeight();
  graphics.setFont(mPinFont);
  graphics.drawText(item.mPin, textX, textY, flags, textWidth);
  graphics.setFont(savedFont);
}
 
开发者ID:google,项目名称:google-authenticator,代码行数:26,代码来源:PinListFieldCallback.java


示例8: paint

import net.rim.device.api.ui.Graphics; //导入依赖的package包/类
protected void paint(Graphics g) {
    AbstractBitmapField bmp;

    if (isSelected && !isActive()) {
        bmp = selectedBmp;
    } else if (isActive()) {
        bmp = activeBmp;
    } else if (isFocused()) {
        bmp = focusBmp;
    } else {
        bmp = defaultBmp;
    }

    if (bmp != null) {
        bmp.draw(g, 0, 0, getContentWidth(), getContentHeight());
    }
}
 
开发者ID:yanex,项目名称:vika,代码行数:18,代码来源:ImageSelectorField.java


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


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


示例11: paint

import net.rim.device.api.ui.Graphics; //导入依赖的package包/类
public void paint(int lastXPoint, int lastYPoint, Graphics graphics, int currentcolor) {
	TRACE_COLOR = currentcolor;
	int[] paintXpoints = _xPoints;
	int[] paintYpoints = _yPoints;
	if (lastXPoint > 0) {
		paintXpoints = new int[_xPoints.length + 1];
		paintYpoints = new int[_yPoints.length + 1];
		paintXpoints[0] = lastXPoint;
		paintYpoints[0] = lastYPoint;
		for (int i = 1; i < paintXpoints.length; i++) {
			paintXpoints[i] = _xPoints[i - 1];
			paintYpoints[i] = _yPoints[i - 1];
		}
	}
	paintPath(paintXpoints, paintYpoints, graphics);
}
 
开发者ID:PropheteMath,项目名称:CrapSnap,代码行数:17,代码来源:DrawPath.java


示例12: paint

import net.rim.device.api.ui.Graphics; //导入依赖的package包/类
public void paint(int lastXPoint, int lastYPoint, Graphics graphics, int currentcolor) {
	TRACE_COLOR = currentcolor;
	if (_xPoint < 0) {
		// Just a break....
		if (lastXPoint >= 0) {
			paintPoint(lastXPoint, lastYPoint, graphics);
		}
	} else if (lastXPoint >= 0) {
		System.out.println("Painting Point on Path");
		paintPath(new int[] { lastXPoint, _xPoint },
				new int[] { lastYPoint, _yPoint }, graphics);
	} else {
		paintPoint(_xPoint, _yPoint, graphics);
	}

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


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


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


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


示例16: paint

import net.rim.device.api.ui.Graphics; //导入依赖的package包/类
public void paint(Graphics g) {
    super.paint(g);
    /*if(drawHover) {
        g.setColor(0xff);
        g.setGlobalAlpha(100);
        g.fillEllipse(hoverX, hoverY, hoverX + 20, hoverY, hoverX, hoverY + 20, 0, 360);
        g.setColor(0);
        g.setGlobalAlpha(255);
    }*/
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:11,代码来源:BlackBerryTouchSupport.java


示例17: clipOnLWUITBounds

import net.rim.device.api.ui.Graphics; //导入依赖的package包/类
/**
 * Clips the RIM native graphics based on the component hierarchy within LWUIT
 * so the native RIM component doesn't paint itself above other components such 
 * as the forms title.
 */
private int clipOnLWUITBounds(Component lwuitComponent, Graphics rimGraphics) {
    int result = 0;
    Component parent = lwuitComponent;
    while (parent != null) {
        int x = parent.getAbsoluteX() + parent.getScrollX();
        int y = parent.getAbsoluteY() + parent.getScrollY();
        rimGraphics.pushRegion(x, y, parent.getWidth(), parent.getHeight(), 0, 0);
        rimGraphics.translate(-rimGraphics.getTranslateX(), -rimGraphics.getTranslateY());
        parent = parent.getParent();
        result++;
    }

    return result;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:20,代码来源:BlackBerryCanvas.java


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


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


示例20: getColor

import net.rim.device.api.ui.Graphics; //导入依赖的package包/类
public int getColor(Object graphics) {
    if (graphics == canvas.getGlobalGraphics()) {
        // make sure color wasn't broken...
        ((Graphics) graphics).setColor(color);
        return color;
    }
    return ((Graphics) graphics).getColor() & 0xffffff;
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:9,代码来源:BlackBerryImplementation.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Input类代码示例发布时间:2022-05-22
下一篇:
Java LiferayWindowState类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap