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