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


Java Graphics.fillRect方法代码示例

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


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

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

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

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

示例4: paint

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
    * Paints the label, currentState and scrollbar.
    */
   public void paint(Graphics gfx) {
       if (BlogWriter.isAshaPlatform()) {
           gfx.setColor(0x8D8C8C);
           gfx.fillRect(0, 0, getWidth(), getHeight());
       }

	gfx.setColor(this.currentState.labelColor);
	gfx.drawString(this.label, this.margin, this.margin, Graphics.TOP | Graphics.LEFT);

	int textEditorY = this.labelFont.getHeight() + 2 * this.margin;
	this.currentState.paint(gfx,(this.controlWidth - this.currentState.width) / 2, textEditorY);

	if (this.scrollbar != null) {
		this.scrollbar.paint(gfx, this.textEditor.getWidth()
				+ this.textEditorMargin, textEditorY
				+ this.textEditorBorderMargin);
	}
	if (this.controls != null && this.isFocused()) {
		this.controls.paint(gfx, (this.controlWidth - this.currentState.width) / 2 + this.currentState.width, textEditorY-1);
	}
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:25,代码来源:CanvasTextBox.java

示例5: paint

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
protected void paint(Graphics g) {
	// Get the canvas dimensions
	clipX = g.getClipHeight();
	clipY = g.getClipWidth();
	// Clear screen with white color
	g.setColor(255, 255, 255);
	g.fillRect(0, 0, clipX, clipY);

	// Draw the squares in red
	g.setColor(255, 0, 0);
	Enumeration en = mySquares.elements();
	while (en.hasMoreElements()) {
		Square sq = (Square) en.nextElement();
		g.fillRect(sq.posX, sq.posY, 4, 4);
	}
	// Draw the rectangle in black
	g.setColor(0, 0, 0);
	g.fillRect(myRectPosX, myRectPosY, myRectWidth, myRectHeight);

	// Draw the edges of the Rectangle Gesture Interactive Zone in green
	g.setColor(0, 255, 0);
	g.drawRect(myGestureZonePosX, myGestureZonePosY, myGestureZoneWidth,
			myGestureZoneHeight);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:25,代码来源:GAFAView.java

示例6: paint

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
protected void paint(Graphics g, int w, int h) {
    // Fill the button with grey color - background
    g.setColor(0, 0, 0);
    g.fillRect(0, 0, w, h);
    // Draw the image in the center of the button
    g.drawImage(getImage(), w/2, h/2, Graphics.HCENTER|Graphics.VCENTER);
    // Draw the borders
    g.setColor(0x000000);
    g.drawLine(0, 0, w, 0);
    g.drawLine(0, 0, 0, h);
    g.drawLine(0, h-1, w, h-1);
    g.drawLine(w-1, 0, w-1, h);
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:14,代码来源:ImageButton.java

示例7: paint

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
   * Draws the item.
   * 
   * @param g Graphics context.
   * @param viewX Top-left x-coordinate of the current view area (grid coordinates, not screen) 
   * @param viewY Top-left y-coordinate of the current view area (grid coordinates, not screen)
   */
  public void paint(Graphics g, int viewX, int viewY){
if (Log.TEST) Log.note("[GridItem#paint]-->");
  	// Calculate actual drawing coordinates from the view coordinates
int translatedX = x - viewX;
  	int translatedY = y - viewY;
  	
      // First draw the underlying rectangle, and get color for text drawing
      if (selected) {
          g.setColor(display.getColor(Display.COLOR_HIGHLIGHTED_BACKGROUND));
          // Draw highlighted background
          g.fillRect(translatedX, translatedY, width, height);
          g.setColor(display.getColor(Display.COLOR_HIGHLIGHTED_BORDER));
          // Draw border
          g.drawRect(translatedX, translatedY, width, height);
          // Set color for text drawing
          g.setColor(display.getColor(Display.COLOR_HIGHLIGHTED_FOREGROUND));
      } else {
      	//g.setColor(display.getColor(Display.COLOR_BORDER));
      	//g.setColor(display.getColor(Display.COLOR_HIGHLIGHTED_FOREGROUND));
              g.setColor(~display.getColor(Display.COLOR_BACKGROUND));

      	// Draw border
      	g.drawRect(translatedX, translatedY, width, height);
      	// Set color for text drawing
          g.setColor(display.getColor(Display.COLOR_FOREGROUND));
      }
      
      drawContents(g, translatedX + V_PAD, translatedY + H_PAD,
      		width - 2 * H_PAD, height - 2 * V_PAD);
      }
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:38,代码来源:GridItem.java

示例8: paint

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
 * Draws the item.
 * 
 * @param g Graphics context.
 * @param yOffset Y-offset to draw from.
 */
public void paint(Graphics g, final int yOffset) {
	if (Log.TEST) Log.note("[ListItem#paint]-->");
    int y = yOffset;
    if (Log.TEST) Log.note("[ListItem#paint] y: " + y);

    // First draw the underlying rect, and get color for text drawing
    if (selected) {
        g.setColor(display.getColor(Display.COLOR_HIGHLIGHTED_BACKGROUND));
        g.fillRect(0, y, width, height);
        g.setColor(display.getColor(Display.COLOR_HIGHLIGHTED_FOREGROUND));
    } else {
        g.setColor(display.getColor(Display.COLOR_FOREGROUND));
    }
    
    y += V_PAD;
    int x = H_PAD;
    
    int[] contentsRect = {x, y, width - 2 * H_PAD, height - 2 * V_PAD};

    drawContents(g, contentsRect );

    // Get border color
    if (selected) {
        g.setColor(display.getColor(Display.COLOR_HIGHLIGHTED_BORDER));
    } else {
       // g.setColor(display.getColor(Display.COLOR_BORDER));
        g.setColor(~display.getColor(Display.COLOR_BACKGROUND));
    }
    
    // Draw border
    g.drawLine(0, yOffset + height, width, yOffset + height);
    
    if (Log.TEST) Log.note("[ListItem#paint]<--");
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:41,代码来源:ListItem.java

示例9: paint

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
protected void paint(Graphics g) {
    g.setColor(0x00FFFFFF);
    g.fillRect(0, 0, getWidth(), getHeight());

    synchronized (paintedLock) {
        painted = true;
        paintedLock.notify();
    }
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:10,代码来源:ContentHandlerMIDlet.java

示例10: paint

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
protected void paint( Graphics g ){
           g.setColor(0, 0, 0);
           g.fillRect(0, 0, getWidth(), getHeight());
	g.drawImage( iImage, x , y, Graphics.TOP | Graphics.LEFT );
	if( x + iImageWidth - getWidth() < 0 )
		g.drawImage( iImage, x + iImageWidth, y, Graphics.TOP | Graphics.LEFT );

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

示例11: draw

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
public void draw(Graphics g) {
    g.setColor(255, 255, 255);
    g.fillRect(0, 0, getWidth(), getHeight());

    g.setColor(200, 200, 200);
    int baseLineY;
    if (signal.baseLineY() >= 0) {
        baseLineY = (int) ((signal.baseLineY() / (double) signal.maxAltitude()) * (getHeight() / 2));
    } else {
        baseLineY = (int) ((Math.abs(signal.baseLineY()) / signal.maxAltitude()) * (getHeight() / 2));
        baseLineY = -baseLineY;
    }
    baseLineY = this.getHeight() / 2 - baseLineY;
    g.drawLine(0, baseLineY, getWidth(), baseLineY);

    for (int i = 0; i < signal.highPoints().length; i++) {
        if (signal.highPoints()[i] > offset && signal.highPoints()[i] < offset + getWidth()) {
            int highPointY;
            if (signal.get(signal.highPoints()[i]) >= 0) {
                highPointY = (int) ((signal.get(signal.highPoints()[i]) / (double) signal.maxAltitude()) * (getHeight() / 2));
            } else {
                highPointY = (int) ((Math.abs(signal.get(signal.highPoints()[i])) / signal.maxAltitude()) * (getHeight() / 2));
                highPointY = -highPointY;
            }
            highPointY = this.getHeight() / 2 - highPointY;
            g.setColor(0, 0, 255);
            g.drawLine(signal.highPoints()[i] - offset, highPointY, signal.highPoints()[i] - offset, baseLineY);
            System.out.println(">>>>> " + signal.highPoints()[i] + ", " + highPointY + ", " + baseLineY);
        }
    }
    System.out.println("===============");

    int pixelsPerStep = (int) ((1 / 40.0) / signal.timeBetweenValues());
    int numberOfSteps = signal.size() / pixelsPerStep;
    for (int i = 1; i <= numberOfSteps; i++) {
        if (i * pixelsPerStep > offset && i * pixelsPerStep < offset + getWidth()) {
            g.setColor(249, 230, 213);
            g.drawLine(i * pixelsPerStep - offset, 0, i * pixelsPerStep - offset, getHeight());
        }
    }
    for (int i = 1; i <= getHeight() / pixelsPerStep; i++) {
        g.setColor(249, 230, 213);
        g.drawLine(0, i * pixelsPerStep, getWidth(), i * pixelsPerStep);
    }
    g.setColor(0, 0, 0);
    g.drawLine(0, getHeight() / 2, getWidth(), getHeight() / 2);
    for (int i = 1; i <= numberOfSteps / 20; i++) {
        if (i * 20 * pixelsPerStep > offset && i * 20 * pixelsPerStep < offset + getWidth()) {
            g.setColor(0, 0, 0);
            g.fillRect(i * 20 * pixelsPerStep - offset - 2, getHeight() / 2 - 4, 4, 8);
        }
    }
    int lastX = -1;
    int lastY = -1;
    g.setColor(255, 0, 0);
    for (int x = 0; x < getWidth(); x++) {
        int newX = x + offset;
        if (newX >= 0 && newX <= signal.size()) {
            int y;
            if (signal.get(newX) >= 0) {
                y = (int) ((signal.get(newX) / (double) signal.maxAltitude()) * (getHeight() / 2));
            } else {
                y = (int) ((Math.abs(signal.get(newX)) / signal.maxAltitude()) * (getHeight() / 2));
                y = -y;
            }
            y = this.getHeight() / 2 - y;
            if (lastX < 0) {
                g.fillRect(x, y, 2, 2);
            } else {
                g.drawLine(lastX, lastY, x, y);
            }
            lastX = x;
            lastY = y;
        }
    }
}
 
开发者ID:kamcpp,项目名称:heart-diag-app,代码行数:77,代码来源:SignalDrawer.java

示例12: paintContent

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
protected void paintContent(int x, int y, int leftBorder, int rightBorder, Graphics g) {
        if(player != null) {
            //center stuff
            width = rightBorder - leftBorder;
            int offsetX = (width - cw) / 2;
            vc.setDisplayLocation(x + offsetX, y);
            if(!playing) {
                vc.setVisible(false);

                Font f = g.getFont();
                int fnth = f.getHeight();


                //Calculate margins and locations
                int mx = x + offsetX;
                int my = y;

                int mw = vc.getDisplayWidth();
                int mh = vc.getDisplayHeight();


                int hi = Math.max((int)Math.floor(.2 * mh), fnth);
                int fh = mh - hi * 2;

                //int fw = mw  - wi * 2;
                //int wi = (int)Math.floor(.2 * mw);
                int fw = (int)Math.floor(.9 * fh);

                int wi = (mw - fw)/2;


                int wu = (int)Math.floor(fw / 5.0);
                int hu = (int)Math.floor(fh / 7.0);

                if(hashKeyImage == null) {
                    hashKeyImage = ImageUtils.getImage(imageLocation);
                    if(hashKeyImage != null){

                        //scale
                        int[] newDimension = ImageUtils.getNewDimensions(hashKeyImage, fw,fh);

                        if(newDimension[0] != height || newDimension[1] != width) {
                            hashKeyImage = ImageUtils.resizeImage(hashKeyImage, newDimension[1], newDimension[0]);
                        }
                    }
                }

                if(hashKeyImage != null) {
                    g.drawImage(hashKeyImage, mx + wi + fw / 2, my + hi + fh / 2, Graphics.HCENTER  | Graphics.VCENTER);
                } else {

                    //Draw us a big 'ol hash
                    g.setColor(0, 0, 0);

                    g.fillRect(mx + wi + wu, my + hi, wu, fh);
                    g.fillRect(mx + wi + 3 * wu, my + hi, wu, fh);

                    g.fillRect(mx + wi, my + hi + 2 * hu, fw, hu);
                    g.fillRect(mx + wi, my + hi + 4 * hu, fw, hu);
                }

                int tw = f.stringWidth(top);
                int bw = f.stringWidth(bottom);

                int tx = (mw - tw)/2 + mx;
                int tyo = (hi - fnth) /2;
                int ty = my + tyo;


                g.drawString(top, tx, ty, Graphics.TOP | Graphics.LEFT);

                int bx = (mw - bw)/2 + mx;
                int by = (my + mh - hi) + tyo;

                g.drawString(bottom, bx, by, Graphics.TOP | Graphics.LEFT);
            }
        }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:79,代码来源:VideoItem.java

示例13: paint

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
protected void paint(Graphics g) {
    g.fillRect(0, 0, getWidth(), getHeight());
    _impl.paintFullScreen( g );
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:5,代码来源:MMVideoItem.java

示例14: paint

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
protected void paint(Graphics g) {
    g.setColor(0x00FFFFFF);
    g.fillRect(0, 0, getWidth(), getHeight());
    System.out.println("PAINTED");
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:6,代码来源:DestroyMIDlet.java

示例15: paintContent

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
protected void paintContent(int x, int y, int leftBorder, int rightBorder, Graphics g) {
        if(player != null) {
            //center stuff
            width = rightBorder - leftBorder;
            int offsetX = (width - cw) / 2;
            vc.setDisplayLocation(x + offsetX, y);
            if(!playing) {
                vc.setVisible(false);

                Font f = g.getFont();
                int fnth = f.getHeight();


                //Calculate margins and locations
                int mx = x + offsetX;
                int my = y;

                int mw = vc.getDisplayWidth();
                int mh = vc.getDisplayHeight();


                int hi = Math.max((int)Math.floor(.2 * mh), fnth);
                int fh = mh - hi * 2;

                //int fw = mw  - wi * 2;
                //int wi = (int)Math.floor(.2 * mw);
                int fw = (int)Math.floor(.9 * fh);

                int wi = (mw - fw)/2;


                int wu = (int)Math.floor(fw / 5.0);
                int hu = (int)Math.floor(fh / 7.0);

                //Draw us a big 'ol hash
                g.setColor(0, 0, 0);

                g.fillRect(mx + wi + wu, my + hi, wu, fh);
                g.fillRect(mx + wi + 3 * wu, my + hi, wu, fh);

                g.fillRect(mx + wi, my + hi + 2 * hu, fw, hu);
                g.fillRect(mx + wi, my + hi + 4 * hu, fw, hu);


                String top = Localization.get("video.playback.top");
                //String top = "lw: " + vc.getSourceWidth() + " lh: " + vc.getSourceHeight();
                String bottom = Localization.get("video.playback.bottom");
                //String bottom = "cw: " + cw + " ch: " + ch;


                int tw = f.stringWidth(top);
                int bw = f.stringWidth(bottom);

                int tx = (mw - tw)/2 + mx;
                int tyo = (hi - fnth) /2;
                int ty = my + tyo;


                g.drawString(top, tx, ty, Graphics.TOP | Graphics.LEFT);

                int bx = (mw - bw)/2 + mx;
                int by = (my + mh - hi) + tyo;

                g.drawString(bottom, bx, by, Graphics.TOP | Graphics.LEFT);
            }
        }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:68,代码来源:CameraItem.java


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