List of usage examples for java.awt Graphics drawChars
public void drawChars(char[] data, int offset, int length, int x, int y)
From source file:GraphicsDrawChars.java
public void paint(Graphics g) { char[] c = { 'W', 'a', 't', 'c', 'h', ' ', 'i', 't', ' ', 'D', 'u', 'k', 'e', '!' }; g.drawChars(c, 0, c.length, 10, 30); }
From source file:Main.java
public void paint(Graphics g) { char[] carray = { 'w', 'w', 'w', '.', 'j', 'a', 'v', 'a', '2', 's', '.', 'c', 'o', 'm' }; g.drawChars(carray, 0, carray.length, 10, 60); }
From source file:SwingTypeTester8.java
public synchronized void paintComponent(Graphics gc) { if (tmpChar[0] == 0) return;//from w w w . j a v a 2 s. c o m Dimension d = getSize(); int charWidth = fm.charWidth(tmpChar[0]); gc.clearRect(0, 0, d.width, d.height); gc.drawChars(tmpChar, 0, 1, curX++, fontHeight); if (curX > d.width - charWidth) curX = 0; }
From source file:SwingTypeTester8.java
protected synchronized void paintComponent(Graphics gc) { Dimension d = getSize();// w ww . j a v a 2 s . c o m gc.clearRect(0, 0, d.width, d.height); if (tmpChar[0] == 0) return; int charWidth = fm.charWidth((int) tmpChar[0]); gc.drawChars(tmpChar, 0, 1, (d.width - charWidth) / 2, fontHeight); }
From source file:com.jcraft.weirdx.Draw.java
static void reqImageText16(Client c, XDrawable d, GC gc, int x, int y) throws IOException { int len = c.data; int n = c.length; //int foo;/*from w ww. ja va 2 s.co m*/ Graphics graphics = d.getGraphics(gc, GC.GCFunction | GC.GCFont); if (graphics == null) { c.client.readPad(n * 4); return; } if (gc.clip_mask != null && gc.clip_mask instanceof ClipRectangles) { java.awt.Rectangle rec = (Rectangle) (gc.clip_mask.getMask()); if (rec == null) { while (n > 0) { c.client.readPad(4); n--; } return; } } XFont font = gc.font; n *= 4; c.client.readByte(c.bbuffer, 0, n); len *= 2; if (font.encoding != null) { len = font.encode(c.bbuffer, 0, len, c.cbuffer); if (len == 0) { return; } } else { for (int i = 0; i < len; i++) { c.cbuffer[i] = (char) (c.bbuffer[i] & 0xff); } for (int i = 0; i < len; i++) { if (c.cbuffer[i] != 0) { c.cbuffer[i / 2] = c.cbuffer[i]; } } len /= 2; } { Color tmp = graphics.getColor(); graphics.setColor(d.getColormap().getColor(gc.bgPixel)); graphics.fillRect(x, y - (font.ascent), font.charsWidth(c.cbuffer, 0, len), font.ascent + font.descent); graphics.setColor(tmp); graphics.drawChars(c.cbuffer, 0, len, x, y); } if (d instanceof XWindow) { ((XWindow) d).draw(x, y - (font.ascent), font.charsWidth(c.cbuffer, 0, len), font.ascent + font.descent); } if (gc.function == GC.GXxor || gc.function == GC.GXinvert) { graphics.setPaintMode(); } if (gc.clip_mask != null && gc.clip_mask instanceof ClipRectangles) { d.restoreClip(); } }
From source file:com.jcraft.weirdx.Draw.java
static void reqImageText8(Client c, XDrawable d, GC gc, int x, int y) throws IOException { int len = c.data; int n = c.length; //int foo;/*w ww.j a v a2s . c o m*/ InputOutput io = c.client; Graphics graphics = d.getGraphics(gc, GC.GCFunction | GC.GCFont); if (graphics == null) { io.readPad(n * 4); return; } if (gc.clip_mask != null && gc.clip_mask instanceof ClipRectangles) { java.awt.Rectangle rec = (Rectangle) (gc.clip_mask.getMask()); if (rec == null) { io.readPad(4 * n); return; } } XFont font = gc.font; { io.readByte(c.bbuffer, 0, len); //java.awt.FontMetrics metric=graphics.getFontMetrics(); Color tmp = graphics.getColor(); graphics.setColor(d.getColormap().getColor(gc.bgPixel)); if (len > 0) { io.readPad((-len) & 3); } if (font.encoding != null) { len = font.encode(c.bbuffer, 0, len, c.cbuffer); } else { char ccc = 0; for (int i = 0; i < len; i++) { ccc = c.cbuffer[i] = (char) (c.bbuffer[i] & 0xff); if (ccc < 0x20) { if (ccc == 11) c.cbuffer[i] = (char) '+'; else if (ccc == 12) c.cbuffer[i] = (char) '+'; else if (ccc == 13) c.cbuffer[i] = (char) '+'; else if (ccc == 14) c.cbuffer[i] = (char) '+'; else if (ccc == 15) c.cbuffer[i] = (char) '+'; else if (ccc == 18) c.cbuffer[i] = (char) '-'; else if (ccc == 21) c.cbuffer[i] = (char) '+'; else if (ccc == 22) c.cbuffer[i] = (char) '+'; else if (ccc == 23) c.cbuffer[i] = (char) '+'; else if (ccc == 24) c.cbuffer[i] = (char) '+'; else if (ccc == 25) c.cbuffer[i] = (char) '|'; else c.cbuffer[i] = (char) 0x20; } } } graphics.fillRect(x, y - (font.ascent), font.charsWidth(c.cbuffer, 0, len), font.ascent + font.descent); graphics.setColor(tmp); graphics.drawChars(c.cbuffer, 0, len, x, y); } if (d instanceof XWindow) { ((XWindow) d).draw(x, y - (font.ascent), font.charsWidth(c.cbuffer, 0, len), font.ascent + font.descent); } if (gc.function == GC.GXxor || gc.function == GC.GXinvert) { graphics.setPaintMode(); } if (gc.clip_mask != null && gc.clip_mask instanceof ClipRectangles) { d.restoreClip(); } }
From source file:com.jcraft.weirdx.Draw.java
static void reqPolyText16(Client c, XDrawable d, GC gc, int x, int y) throws IOException { int n = c.length; //int len;/*from w ww . ja v a 2 s. com*/ int foo; Graphics graphics = d.getGraphics(gc, GC.GCFunction | GC.GCFont); if (graphics == null) { c.client.readPad(n * 4); return; } if (gc.clip_mask != null && gc.clip_mask instanceof ClipRectangles) { java.awt.Rectangle rec = (Rectangle) (gc.clip_mask.getMask()); if (rec == null) { while (n > 0) { c.client.readPad(4); n--; } return; } } XFont font = gc.font; int delta; n = n * 4; int sx = d.width; int sy = d.height; int lx = 0; int ly = 0; while (n != 0) { if (n < 2) break; foo = c.client.readByte(); n--; if (foo == 255) { int i = 0; foo = c.client.readByte(); n--; i = foo & 0xff; foo = c.client.readByte(); n--; i = ((i << 8) & 0xffff) | foo & 0xff; foo = c.client.readByte(); n--; i = ((i << 8) & 0xffffff) | foo & 0xff; foo = c.client.readByte(); n--; i = (i << 8) | foo & 0xff; XFont tmp = (XFont) XResource.lookupIDByType(i, XResource.RT_FONT); if (tmp != null) { font = tmp; graphics.setFont(font.getFont()); } else { LOG.warn("font is null!!"); } continue; } delta = c.client.readByte(); n--; x += delta; if (foo > 0) { foo *= 2; c.client.readByte(c.bbuffer, 0, foo); n -= foo; if (font.encoding != null) { foo = font.encode(c.bbuffer, 0, foo, c.cbuffer); if (foo == 0) { c.length = n; return; } } else { for (int i = 0; i < foo; i++) { c.cbuffer[i] = (char) (c.bbuffer[i] & 0xff); } for (int i = 0; i < foo; i++) { if (c.cbuffer[i] != 0) { c.cbuffer[i / 2] = c.cbuffer[i]; } } foo /= 2; // ???? } graphics.drawChars(c.cbuffer, 0, foo, x, y); if (x < sx) sx = x; foo = font.charsWidth(c.cbuffer, 0, foo) + x; x = foo; if (lx < foo) lx = foo; if ((y - font.ascent) < sy) sy = y - font.ascent; if (ly < y + font.descent) ly = y + font.descent; } } if (n != 0) { c.client.readPad(n); } if (sx < 0) sx = 0; if (sy < 0) sy = 0; if (d instanceof XWindow) { ((XWindow) d).draw(sx, sy, lx - sx + 1, ly - sy + 1); } if (gc.function == GC.GXxor || gc.function == GC.GXinvert) { graphics.setPaintMode(); } if (gc.clip_mask != null && gc.clip_mask instanceof ClipRectangles) { d.restoreClip(); } }
From source file:com.jcraft.weirdx.Draw.java
static void reqPolyText8(Client c, XDrawable d, GC gc, int x, int y) throws IOException { int n = c.length; //int len;//from w w w.j a va 2s .co m int foo; InputOutput io = c.client; Graphics graphics = d.getGraphics(gc, GC.GCFunction | GC.GCFont); if (graphics == null) { c.client.readPad(n * 4); return; } if (gc.clip_mask != null && gc.clip_mask instanceof ClipRectangles) { java.awt.Rectangle rec = (Rectangle) (gc.clip_mask.getMask()); if (rec == null) { io.readPad(n * 4); return; } } XFont font = gc.font; int delta; n = n * 4; int sx = d.width; int sy = d.height; int lx = 0; int ly = 0; while (n != 0) { if (n < 2) break; foo = io.readByte(); n--; if (foo == 255) { int i = 0; foo = io.readByte(); n--; i = foo & 0xff; foo = io.readByte(); n--; i = ((i << 8) & 0xffff) | foo & 0xff; foo = io.readByte(); n--; i = ((i << 8) & 0xffffff) | foo & 0xff; foo = io.readByte(); n--; i = (i << 8) | foo & 0xff; XFont tmp = (XFont) XResource.lookupIDByType(i, XResource.RT_FONT); if (tmp != null) { font = tmp; graphics.setFont(font.getFont()); } else { LOG.warn("font is null!!"); } continue; } delta = io.readByte(); n--; x += delta; if (foo > 0) { io.readByte(c.bbuffer, 0, foo); n -= foo; if (font.encoding != null) { foo = font.encode(c.bbuffer, 0, foo, c.cbuffer); } else { char ccc = 0; for (int i = 0; i < foo; i++) { ccc = c.cbuffer[i] = (char) (c.bbuffer[i] & 0xff); if (ccc < 0x20) { if (ccc == 11) c.cbuffer[i] = (char) '+'; else if (ccc == 12) c.cbuffer[i] = (char) '+'; else if (ccc == 13) c.cbuffer[i] = (char) '+'; else if (ccc == 14) c.cbuffer[i] = (char) '+'; else if (ccc == 15) c.cbuffer[i] = (char) '+'; else if (ccc == 18) c.cbuffer[i] = (char) '-'; else if (ccc == 21) c.cbuffer[i] = (char) '+'; else if (ccc == 22) c.cbuffer[i] = (char) '+'; else if (ccc == 23) c.cbuffer[i] = (char) '+'; else if (ccc == 24) c.cbuffer[i] = (char) '+'; else if (ccc == 25) c.cbuffer[i] = (char) '|'; else c.cbuffer[i] = (char) 0x20; } } } graphics.drawChars(c.cbuffer, 0, foo, x, y); if (x < sx) sx = x; foo = font.charsWidth(c.cbuffer, 0, foo) + x; x = foo; if (lx < foo) lx = foo; if ((y - font.ascent) < sy) sy = y - font.ascent; if (ly < y + font.descent) ly = y + font.descent; } } if (n != 0) { io.readPad(n); } if (sx < 0) sx = 0; if (sy < 0) sy = 0; if (d instanceof XWindow) { ((XWindow) d).draw(sx, sy, lx - sx + 1, ly - sy + 1); } if (gc.function == GC.GXxor || gc.function == GC.GXinvert) { graphics.setPaintMode(); } if (gc.clip_mask != null && gc.clip_mask instanceof ClipRectangles) { d.restoreClip(); } }