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


Java Graphics类代码示例

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


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

示例1: DrawGif

import javax.microedition.lcdui.Graphics; //导入依赖的package包/类
/**
 * ��GIFͼ��
 * @param imgpath ͼ��·��
 * @param x		x����
 * @param y		y����
 */
private void DrawGif(String imgpath,int x,int y)
{
	Graphics g=getGraphics();
	if(imgpath!=prepath)
	{
		prepath=imgpath;	//�ѵ�ǰͼ��·������ǰһ��
		gifd.read(this.getClass().getResourceAsStream(imgpath));//����ͼƬ
		framecount= gifd.getFrameCount();//��ȡ֡��
	}
	for(int i=0;i<framecount;i++)
	{
		g.drawImage(gifd.getFrame(i), x, y, anchor);
		try {
			Thread.sleep(FrameInterval);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		flushGraphics();
	}
}
 
开发者ID:cabbage89,项目名称:danceGame,代码行数:28,代码来源:MyCanvas.java

示例2: ShowLift

import javax.microedition.lcdui.Graphics; //导入依赖的package包/类
/**
 * ������ͷ
 * @param n Ҫ���ĸ���
 */
private void ShowLift(int n)
{
	System.out.println("��ʾ������...");
	int startpos=0;
	Graphics grap=getGraphics();
	if(n!=3)
	{
		//����ǻ�����˵���dz�ʼ��,����������Ҫ�������
		grap.drawImage(liftbg, 0, 0, anchor);	///����ͷ�������
	}
	for(int i=1;i<=n;i++)
	{
		grap.drawImage(lift, startpos, 0, anchor);	//ÿ�λ�һ������17����
		startpos+=17;
	}
	flushGraphics();
}
 
开发者ID:cabbage89,项目名称:danceGame,代码行数:22,代码来源:MyCanvas.java

示例3: ShowLightBg

import javax.microedition.lcdui.Graphics; //导入依赖的package包/类
/**
 * ��ʾ��ɫ�ĵ�
 * @param state ����״̬
 * @param n		��ʾ������
 */
private void ShowLightBg(Light state,int n)
{
	Graphics gra=getGraphics();
	gra.drawImage(passarea, 0, py, anchor);	//���±���
	int startpos=0;
	for(int i=1;i<=n;i++)
	{
		if(state==Light.dark)
		{
			gra.drawImage(passbg, startpos, py, anchor);
		}
		startpos+=15;	//ˮƽƫ��һ��ͼƬ��
	}
	flushGraphics();
}
 
开发者ID:cabbage89,项目名称:danceGame,代码行数:21,代码来源:MyCanvas.java

示例4: init

import javax.microedition.lcdui.Graphics; //导入依赖的package包/类
/**
 * ���������ʼ��
 * @param score ����
 * @throws IOException
 */
public void init(int score) throws IOException
{
	/*��Ϸ����:42,23
	gameover:42,38
	������:38,58
	����ͼƬ:45,107*/
	gameovertip=Image.createImage("/gameovertip.GIF");
	endtip=Image.createImage("/endtip.GIF");
	scorebg=Image.createImage("/scorebg.GIF");
	gameoverbg=Image.createImage("/gameoverbg.GIF");
	
	Graphics gra=super.getGraphics();
	gra.setColor(255, 255, 255);
	gra.fillRect(0, 0, sw, sh);
	gra.drawImage(endtip, 42, 23,Graphics.LEFT|Graphics.TOP);
	gra.drawImage(gameovertip, 42, 38,Graphics.LEFT|Graphics.TOP);
	gra.drawImage(scorebg, 38, 58,Graphics.LEFT|Graphics.TOP);
	gra.drawImage(gameoverbg, 45, 107,Graphics.LEFT|Graphics.TOP);
	flushGraphics();
	repaint();
	super.ShowScore(score);
	System.out.println("��������������");
}
 
开发者ID:cabbage89,项目名称:danceGame,代码行数:29,代码来源:CanvasOver.java

示例5: ShowLift

import javax.microedition.lcdui.Graphics; //导入依赖的package包/类
/**
 * ������ͷ
 * @param n Ҫ���ĸ���
 */
private void ShowLift(int n)
{
	int startpos=0;
	Graphics grap=getGraphics();
	if(n!=3)
	{
		//����ǻ�����˵���dz�ʼ��,����������Ҫ�������
		grap.drawImage(liftbg, 0, 0, anchor);	///����ͷ�������
	}
	for(int i=1;i<=n;i++)
	{
		grap.drawImage(lift, startpos, 0, anchor);	//ÿ�λ�һ������17����
		startpos+=17;
	}
	flushGraphics();
}
 
开发者ID:cabbage89,项目名称:danceGame,代码行数:21,代码来源:MyCanvas.java

示例6: Fail

import javax.microedition.lcdui.Graphics; //导入依赖的package包/类
/**
 * ���˶���ʧ��
 */
private void Fail()
{
	ShowLightBg(Light.dark, ActionCount);//���а�ɫ�Ʊ���
	Graphics gra=getGraphics();
	int startpos=0;
	for(int i=1;i<=rightcount;i++)
	{
		gra.drawImage(pass, startpos, py, anchor);
		startpos+=15;
	}
	gra.drawImage(notpass, 15*rightcount, py, anchor);	//���ƴ����
	flushGraphics();
	currentLift--;	//��������1
	ShowLift(currentLift);	//��ʾ������
	if(currentLift==0)
	{
		//GameOver
		Gameover();
	}
	else
	{
		CurrentPressindex=ActionCount;	//ʹС����������
	}
}
 
开发者ID:cabbage89,项目名称:danceGame,代码行数:28,代码来源:MyCanvas.java

示例7: doRight

import javax.microedition.lcdui.Graphics; //导入依赖的package包/类
/**
 * ���˶������Ե�ָʾ
 * @param n ���ԵĴ���
 */
private void doRight(int n)
{
	int startpos=0;
	Graphics gra=getGraphics();
	for(int i=1;i<=n;i++)
	{
		gra.drawImage(pass, startpos, py, anchor);
		startpos+=15;//ˮƽƫ��һ��ͼƬ��
	}
	for(int i=1;i<=ActionCount-n;i++)
	{
		gra.drawImage(passbg, startpos, py, anchor);
	}
	flushGraphics();
}
 
开发者ID:cabbage89,项目名称:danceGame,代码行数:20,代码来源:MyCanvas.java

示例8: PaintCanvas

import javax.microedition.lcdui.Graphics; //导入依赖的package包/类
public PaintCanvas(ApplicationListener listener, boolean isLandscape) {
    this.listener = listener;
    this.isLandscape = isLandscape;
    setFullScreenMode(true);
    width = getWidth();
    height = getHeight();
    if (isLandscape) {
        width = height;
        height = getWidth();
    }
    image = Image.createImage(width, height);
    Graphics g = image.getGraphics();
    graphics = new JecpGraphics(g);
    
    listener.onStartApp(width, height);
    
    thread = new DrawingThread();
    thread.keepRunning = true;
    thread.start();
}
 
开发者ID:aNNiMON,项目名称:JECP,代码行数:21,代码来源:PaintCanvas.java

示例9: LoginController

import javax.microedition.lcdui.Graphics; //导入依赖的package包/类
public LoginController(String title, String image, String[] extraText, String passwordFormat, boolean showDemo, boolean imagesEnabled) {
    this.extraText = extraText;
    view = new LoginForm(null, this.extraText, showDemo, true, imagesEnabled);
    view.setCommandListener(this);
    view.setPasswordMode(passwordFormat);

    if(image != null) {
        //#style loginImage?
        view.append(Graphics.TOP, new ImageItem(null, ImageUtils.getImage(image), ImageItem.LAYOUT_CENTER, ""));
    }

    if(title != null) {
        //#style loginTitle?
        view.append(Graphics.TOP, new StringItem(null, title));
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:17,代码来源:LoginController.java

示例10: paint

import javax.microedition.lcdui.Graphics; //导入依赖的package包/类
protected void paint(Graphics g, int w, int h) {
    // Don't paint if VideoControl visible flag is false
    if (!pvis || painting)
        return;

    painting = true;
    if (rgbData != null) {
        synchronized (rgbData) {
            if (scaled) {
                g.drawRGB(scaledData, 0, dw, 0, 0, dw, dh, useAlpha);
            } else {
                g.drawRGB(rgbData, 0, videoWidth, 0, 0, videoWidth, videoHeight, useAlpha);
            }
        }
    }
    painting = false;
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:18,代码来源:MIDPVideoRenderer.java

示例11: paint

import javax.microedition.lcdui.Graphics; //导入依赖的package包/类
/**
 * Draws the Sprite.  
 * <P>
 * Draws current frame of Sprite using the provided Graphics object.
 * The Sprite's upper left corner is rendered at the Sprite's current
 * position relative to the origin of the Graphics object.  The current
 * position of the Sprite's upper-left corner can be retrieved by 
 * calling {@link #getX()} and {@link #getY()}.
 * <P>
 * Rendering is subject to the clip region of the Graphics object.
 * The Sprite will be drawn only if it is visible.
 * <p>
 * If the Sprite's Image is mutable, the Sprite is rendered using the
 * current contents of the Image.
 * 
 * @param g the graphics object to draw <code>Sprite</code> on
 * @throws NullPointerException if <code>g</code> is <code>null</code>
 *
 */
public final void paint(Graphics g) {
    // managing the painting order is the responsibility of
    // the layermanager, so depth is ignored
    if (g == null) {
        throw new NullPointerException();
    }

    if (visible) {

            // width and height of the source
            // image is the width and height
            // of the original frame
            g.drawRegion(sourceImage, 
                         frameCoordsX[frameSequence[sequenceIndex]],
                         frameCoordsY[frameSequence[sequenceIndex]],
                         srcFrameWidth, 
                         srcFrameHeight,
                         t_currentTransformation,
                         this.x, 
                         this.y, 
                         Graphics.TOP | Graphics.LEFT);
    }

}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:44,代码来源:Sprite.java

示例12: paint

import javax.microedition.lcdui.Graphics; //导入依赖的package包/类
public void paint(Graphics g) {
  int z = 0;

  if ((x + dx) < 0 || (x + dx) > 200) {
    dx *= -1;
  }
  if ((y + dy) < 0 || (y + dy) > 200) {
    dy *= -1;
  }
  x += dx;
  y += dy;
  g.setColor(255, 255, 255);
  g.fillRect(0, 0, 300, 300);

  g.setColor((z + x) & 0xff, (z + y) & 0xff, (x + y) & 0xff);
  g.fillRect(x, y, 10, 10);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:18,代码来源:SocketStressBench.java

示例13: paint

import javax.microedition.lcdui.Graphics; //导入依赖的package包/类
public void paint(Graphics g) {
    int z = 0;

    if ((x + dx) < 0 || (x + dx) > 200) {
        dx *= -1;
    }
    if ((y + dy) < 0 || (y + dy) > 200) {
        dy *= -1;
    }
    x += dx;
    y += dy;
    g.setColor(255, 255, 255);
    g.fillRect(0, 0, 300, 300);

    g.setColor((z + x) & 0xff, (z + y) & 0xff, (x + y) & 0xff);
    g.fillRect(x, y, 10, 10);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:18,代码来源:FileStressBench.java

示例14: paint

import javax.microedition.lcdui.Graphics; //导入依赖的package包/类
/**
 * @see javax.microedition.lcdui.CustomItem#paint(javax.microedition.lcdui.Graphics, int, int)
 */
protected void paint(Graphics g, int w, int h) {
	// Draw the title text
	Util.drawStringCenteredAndTruncated(g, "Rating:", font, 0, 0, w, font.getHeight(),
			Graphics.TOP | Graphics.LEFT );
	for(int i = 0; i < zones.length; i++) {
		GestureInteractiveZone zone = zones[i];
		Image image = null;
		// Determine whether a full or empty star needs to be drawn
		if(i < rating){
			image = starImgFilled;
		} else{
			image = starImgEmpty;
		}
		// Draw a star image
		Util.drawImageCentered(g, image, zone.getX(), zone.getY(),
				zone.getWidth(), zone.getHeight());
	}
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:22,代码来源:RatingItem.java

示例15: drawContents

import javax.microedition.lcdui.Graphics; //导入依赖的package包/类
/**
 * Draws item contents.
 * 
 * @param g Graphics context.
 * @param rect Rectangle to draw in.
 */
protected void drawContents(Graphics g, int[] rect){
	if (Log.TEST) Log.note("[ListItem#drawContents]-->");
	// First draw icon
	int[] remainderRect = drawIcon(g, rect);
	if((itemType & TYPE_TWO_ROW) > 0){
		// Draw top row
    	int topRowHeight = drawTopRow(g, remainderRect, false);
    	// Update remainder rect accordingly
    	remainderRect[1] += topRowHeight; // y 
    	remainderRect[3] -= topRowHeight; // height
    	// Last, draw bottom row
 	drawBottomRow(g, remainderRect);
	} else {
		// Draw top row
    	drawTopRow(g, remainderRect, true);
	}
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:24,代码来源:ListItem.java


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