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


Java Graphics.getClipHeight方法代码示例

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


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

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

示例2: paintVideo

import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
 * Paint video into canvas - in USE_DIRECT_VIDEO mode
 */
public void paintVideo(Graphics g) {
    // Don't paint if Canvas visible flag is false
    if (!pvis || !cvis || painting)
        return;
    
    painting = true;
    
    // Save the clip region
    int cx = g.getClipX();
    int cy = g.getClipY();
    int cw = g.getClipWidth();
    int ch = g.getClipHeight();
    // Change the clip to clip the video area
    g.clipRect(dx, dy, dw, dh);
    
    // Check if its within the bounds
    if (g.getClipWidth() > 0 && g.getClipHeight() > 0 && pvis) {
        int w = dw, h = dh;
        if (w > videoWidth)
            w = videoWidth;
        if (h > videoHeight)
            h = videoHeight;
        try {
            if (rgbData != null) {
                synchronized (rgbData) {
                    if (scaled) {
                        g.drawRGB(scaledData, 0, dw, dx, dy, dw, dh, useAlpha);
                    } else {
                        g.drawRGB(rgbData, 0, videoWidth, dx, dy, w, h, useAlpha);
                    }
                }
            }
        } finally {
            // Revert the clip region
            g.setClip(cx, cy, cw, ch);
            painting = false;
        }
    } else {
        g.setClip(cx, cy, cw, ch);
        painting = false;
    }
    if (TRACE_FRAMERATE) {
        if (frameStartTime == 0) {
            frameStartTime = System.currentTimeMillis();
        } else {
            frameCount++;
            if ((frameCount % 30) == 0) {
                int frameRate = (int) ( (frameCount * 1000) / (System.currentTimeMillis() - frameStartTime + 1));
                System.err.println("Frame Rate = " + frameRate);
            }
        }
    }
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:57,代码来源:MIDPVideoRenderer.java


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