/** * Draw a string. Reference point is the center of string. The coordinates * are logical coordinates. */ public void drawText(String label, double[] coord) { drawText(label, 0.5, 0.5, 0.0, coord); }
/** * Draw a string with given rotation angle. Reference point is the center * of string. The coordinates are logical coordinates. The angle of rotation * is in radians. */ public void drawText(String label, double rotation, double[] coord) { drawText(label, 0.5, 0.5, rotation, coord); }
/** * Draw a string with given reference point. (0.5, 0.5) is center, (0, 0) is * lower left, (0, 1) is upper left, etc. The coordinates are logical coordinates. */ public void drawText(String label, double horizontalReference, double verticalReference, double[] coord) { drawText(label, horizontalReference, verticalReference, 0.0, coord); }
public class MyBitmapField extends BitmapField { //... protected void paintBitmap(Graphics g, int arg1, int arg2, int arg3, int arg4, Bitmap arg5, int arg6, int arg7) { super.paintBitmap(g, arg1, arg2, arg3, arg4, arg5, arg6, arg7); g.drawText("Your text", 5,5 ); } // ... }
public void drawMultipleLines(Graphics graphics, String text, int X, int Y, int XavailableSpace) { String[] texts = UiSpliter.split(text, " "); //UiSpliter is a class that will split the string into string array based on the ' ' character int x = X; int y = Y; for (int i = 0 ; i < texts.length ; i ++) { if (x + getFont().getAdvance(texts[i]) - X > XavailableSpace) { if (!(x == X)) { x = X; y = y + getFont().getHeight(); } } graphics.drawText(texts[i] + " ", x, y); x += getFont().getAdvance(texts[i] + " "); } }
ObjectChoiceField choice = new ObjectChoiceField() { protected void paint(Graphics graphics) { // Get the current selected Choice Choice item = (Choice) this.getChoice(getSelectedIndex()); int xOffset = 5; // 5 px padding on the left graphics.drawBitmap(xOffset, 0, item.image.getWidth(), item.image.getHeight(), item.image, 0, 0); // Add text after the image and 10px padding. xOffset += item.image.getWidth() + 10; graphics.drawText(item.label, xOfffset, 0); } };
graphics.drawText(currentText, 0, 0, DrawStyle.ELLIPSIS, 200); super.paint(graphics);
g.drawText(text, 0, y, 0, w);
g.drawText(rowString.toString(), 0, y, 0, -1);
@Override public void paint(Graphics g) { Color c = g.getColor(); g.setColor(getColor()); if (labels != null) { for (int i = 0; i < data.length; i++) { g.drawText(labels[i], data[i]); } } else { if (y == null) { for (int i = 0; i < data.length; i++) { g.drawPoint(legend, data[i]); } } else { for (int i = 0; i < data.length; i++) { if (palette != null) { g.setColor(palette[classLookupTable.get(y[i])]); } if (legends != null) { g.drawPoint(legends[classLookupTable.get(y[i])], data[i]); } else { g.drawPoint(legend, data[i]); } } } } g.setColor(c); }
@Override public void paint(Graphics g) { Font f = g.getFont(); if (font != null) { g.setFont(font); } Color c = g.getColor(); g.setColor(getColor()); g.drawText(text, horizontalReference, verticalReference, rotation, coord); g.setColor(c); if (font != null) { g.setFont(f); } }