本文整理汇总了Java中javax.microedition.lcdui.Graphics.drawLine方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.drawLine方法的具体用法?Java Graphics.drawLine怎么用?Java Graphics.drawLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.microedition.lcdui.Graphics
的用法示例。
在下文中一共展示了Graphics.drawLine方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paint
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* @see CommentItem#drawContent(javax.microedition.lcdui.Graphics, int, int)
*/
public void paint(final Graphics g, final int w, final int h) {
int x = H_SPACE + xIndent;
int y = V_SPACE;
g.setColor(VisualStyles.COLOR_HIGHLIGHTED_FOREGROUND);
g.drawLine(xIndent, 0, xIndent, h);
g.setColor(VisualStyles.COLOR_FOREGROUND);
g.setFont(FONT_AUTHOR);
final int fontHeight = FONT_AUTHOR.getHeight();
for (int i = 0; i < bodyLines.size(); i++) {
g.drawString((String) bodyLines.elementAt(i), x, y, Graphics.TOP
| Graphics.LEFT);
y += fontHeight;
}
}
示例2: 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]<--");
}
示例3: 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);
}
示例4: paint
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* Draw the item. Subclasses should override this.
*/
protected void paint(final Graphics g, final int w, final int h) {
int x = H_SPACE + xIndent;
int y = V_SPACE;
g.setColor(VisualStyles.COLOR_HIGHLIGHTED_FOREGROUND);
g.drawLine(xIndent, V_SPACE, xIndent, h - V_SPACE);
g.setColor(VisualStyles.COLOR_FOREGROUND);
if (comment.getAuthor() != null) {
g.setFont(FONT_AUTHOR);
g.drawString(comment.getAuthor(), x, y, Graphics.TOP | Graphics.LEFT);
y += H_FONT_AUTHOR;
}
g.setFont(FONT_META);
g.drawString(metaText, x, y, Graphics.TOP | Graphics.LEFT);
y += H_FONT_META + V_SPACE * 1.5;
g.setColor(VisualStyles.COLOR_FOREGROUND_DIM);
g.setFont(FONT_BODY);
for (int i = 0; i < bodyLines.size(); i++) {
g.drawString((String) bodyLines.elementAt(i), x, y, Graphics.TOP
| Graphics.LEFT);
y += H_FONT_BODY;
}
}
示例5: 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;
}
}
}
示例6: paintContent
import javax.microedition.lcdui.Graphics; //导入方法依赖的package包/类
/**
* @see de.enough.polish.ui.CustomItem#paint(javax.microedition.lcdui.Graphics, int, int)
*/
// protected void paint(Graphics g, int w, int h) {
protected void paintContent( int x, int y, int leftBorder, int rightBorder, Graphics g ) {
final int c = y + contentHeight / 2;
g.setColor(0x949494);
g.setFont(this.font);
if (displayString == null || displayString.length() == 0) {
g.drawLine(leftBorder, c, rightBorder, c);
return;
}
int totalStringWidth = this.font.stringWidth(displayString) + this.linePadding;
if (this.isLayoutCenter) {
totalStringWidth += this.linePadding;
}
int lineLen = rightBorder - leftBorder - totalStringWidth;
if (this.isLayoutCenter) {
lineLen /= 2;
}
if (this.isLayoutCenter || this.isLayoutRight) {
g.drawLine(leftBorder, c, leftBorder + lineLen, c);
} else {
g.drawLine(leftBorder + totalStringWidth, c, leftBorder + totalStringWidth + lineLen, c);
}
g.setColor(this.fontColor);
if (this.isLayoutCenter) {
g.drawString(displayString, leftBorder + lineLen + this.linePadding, y, Graphics.LEFT | Graphics.TOP);
} else if (this.isLayoutRight) {
g.drawString(displayString, rightBorder, y, Graphics.RIGHT | Graphics.TOP);
} else {
g.drawString(displayString, leftBorder, y, Graphics.LEFT | Graphics.TOP);
}
if (this.isLayoutCenter) {
g.setColor(0x949494);
g.drawLine(leftBorder + lineLen + totalStringWidth, c, rightBorder, c);
}
}