gc.drawString( string, 0, 0 ); return; gc.drawString( string, 0, 0 ); return; gc.drawString( string, 0, 0 ); return;
public void drawString(String string, int x, int y, boolean isTransparent) { gc.drawString(string, x + transX, y + transY, isTransparent); }
/** * Draws the given string, using the receiver's current font and * foreground color. No tab expansion or carriage return processing * will be performed. The background of the rectangular area where * the string is being drawn will be filled with the receiver's * background color. * * @param string the string to be drawn * @param x the x coordinate of the top left corner of the rectangular area where the string is to be drawn * @param y the y coordinate of the top left corner of the rectangular area where the string is to be drawn * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - if the string is null</li> * </ul> * @exception SWTException <ul> * <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li> * </ul> */ public void drawString (String string, int x, int y) { drawString(string, x, y, false); }
void drawString(String string, Point pos, boolean isTransparent, int xOffset, int yOffset) { gc.get().drawString(string, vp.get().toCoordX(pos.x) + xOffset, vp.get().toCoordY(pos.y) + yOffset, isTransparent); } }
/** * Draws a string at the specified position. * * @param text the string. * @param x the x-coordinate. * @param y the y-coordinate. */ @Override public void drawString(String text, float x, float y) { if (text == null) { throw new NullPointerException("Null 'text' argument."); } float fm = this.gc.getFontMetrics().getAscent(); this.gc.drawString(text, (int) x, (int) (y - fm), true); }
protected void drawText(final String msg, final int x, final int y) { final Point textsz = g.textExtent(msg); final int texty = (y * 2 - textsz.y) / 2; g.setForeground(cellFG); g.setBackground(cellBG); g.drawString(msg, cellX + x, cellY + texty, true); }
/** * Paints the line. After this method is called the line numbers are painted on top * of the result of this method. * * @param line the line of the document which the ruler is painted for * @param y the y-coordinate of the box being painted for <code>line</code>, relative to <code>gc</code> * @param lineheight the height of one line (and therefore of the box being painted) * @param gc the drawing context the client may choose to draw on. * @param display the display the drawing occurs on * @since 3.0 */ protected void paintLine(int line, int y, int lineheight, GC gc, Display display) { int widgetLine= JFaceTextUtil.modelLineToWidgetLine(fCachedTextViewer, line); String s= createDisplayString(line); int indentation= fIndentation[s.length()]; int baselineBias= getBaselineBias(gc, widgetLine); gc.drawString(s, indentation, y + baselineBias, true); }
/** * Draw the {@link #getLabel()} of mining with gray color. User can override this method to draw * anything. * * @param gc the graphics context * @param textWidget the text widget to draw on * @param color the color of the line * @param x the x position of the annotation * @param y the y position of the annotation * @return the size of the draw of mining. */ @Override public Point draw(GC gc, StyledText textWidget, Color color, int x, int y) { String title= getLabel() != null ? getLabel() : "no command"; //$NON-NLS-1$ gc.drawString(title, x, y, true); return gc.stringExtent(title); }
protected void addEmptyTreeMessage(GC gc) { // here we print a message when the document is empty just to give the // user a visual cue // so that they know how to proceed to edit the blank view gc.setForeground(fTree.getDisplay().getSystemColor(SWT.COLOR_BLACK)); gc.setBackground(fTree.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); gc.drawString(XMLEditorMessages.XMLTreeExtension_3, 10, 10); gc.drawString(XMLEditorMessages.XMLTreeExtension_4, 10, 10 + gc.getFontMetrics().getHeight()); }
/** * Draw the inlined annotation. By default it draw the text of the annotation with gray color. * User can override this method to draw anything. * * @param gc the graphics context * @param textWidget the text widget to draw on * @param offset the offset of the line * @param length the length of the line * @param color the color of the line * @param x the x position of the annotation * @param y the y position of the annotation */ public void draw(GC gc, StyledText textWidget, int offset, int length, Color color, int x, int y) { gc.setForeground(color); gc.setBackground(textWidget.getBackground()); gc.drawString(getText(), x, y, true); }
protected void paintItem(GC gc, TreeItem item, Rectangle bounds) { super.paintItem(gc, item, bounds); Object[] data = computeTreeExtensionData(item.getData()); if ((data != null) && (data.length == 2)) { gc.setClipping(columnPosition, bounds.y + 1, controlWidth, bounds.height); gc.setForeground((Color) data[1]); gc.drawString((String) data[0], columnPosition + 5, bounds.y + 1); gc.setClipping((Rectangle) null); } }
private void addUnableToPopulateTreeMessage(GC gc) { // here we print a message when the document cannot be displayed just // to give the // user a visual cue // so that they know how to proceed to edit the blank view gc.setForeground(fTree.getDisplay().getSystemColor(SWT.COLOR_BLACK)); gc.setBackground(fTree.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); gc.drawString(XMLEditorMessages.TreeExtension_0, 10, 10); }
public Shell open (Display display) { final Color red = new Color(display, 0xFF, 0, 0); final Shell shell = new Shell (display); shell.addPaintListener(event -> { GC gc = event.gc; gc.setForeground(red); Rectangle rect = shell.getClientArea(); gc.drawRectangle(rect.x + 10, rect.y + 10, rect.width - 20, rect.height - 20); gc.drawString(resHello.getString("Hello_world"), rect.x + 20, rect.y + 20); }); shell.addDisposeListener (e -> red.dispose()); shell.open (); return shell; } }
/** * Draw string at widget offset. * * @param gc the GC * @param offset the widget offset * @param s the string to be drawn * @param fg the foreground color */ private void draw(GC gc, int offset, String s, Color fg) { // Compute baseline delta (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=165640) int baseline= fTextWidget.getBaseline(offset); FontMetrics fontMetrics= gc.getFontMetrics(); int fontBaseline= fontMetrics.getAscent() + fontMetrics.getLeading(); int baslineDelta= baseline - fontBaseline; Point pos= fTextWidget.getLocationAtOffset(offset); gc.setForeground(fg); gc.drawString(s, pos.x, pos.y + baslineDelta, true); }
/** * Draw string at widget offset. * * @param gc the GC * @param offset the widget offset * @param s the string to be drawn * @param fg the foreground color */ private void draw(GC gc, int offset, String s, Color fg) { // Compute baseline delta (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=165640) int baseline= fTextWidget.getBaseline(offset); FontMetrics fontMetrics= gc.getFontMetrics(); int fontBaseline= fontMetrics.getAscent() + fontMetrics.getLeading(); int baslineDelta= baseline - fontBaseline; Point pos= fTextWidget.getLocationAtOffset(offset); gc.setForeground(fg); gc.drawString(s, pos.x, pos.y + baslineDelta, true); }
private void paintStep(int startX, int endX) { GC gc = new GC(this); setStatusColor(gc); Rectangle rect = getClientArea(); startX = Math.max(1, startX); gc.fillRectangle(startX, 1, endX - startX, rect.height - 2); String string = getCurrentMessage(); m_currentMessage = string; gc.setFont(JFaceResources.getDefaultFont()); FontMetrics fontMetrics = gc.getFontMetrics(); int stringWidth = fontMetrics.getAverageCharWidth() * string.length(); int stringHeight = fontMetrics.getHeight(); gc.setForeground(m_messageColor); gc.drawString(string, (rect.width - stringWidth) / 2, (rect.height - stringHeight) / 2, true); gc.dispose(); }
Hover(Shell parent) { final Display display = parent.getDisplay(); hoverShell = new Shell(parent, SWT.NO_TRIM | SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL); hoverShell.setBackground(display .getSystemColor(SWT.COLOR_INFO_BACKGROUND)); hoverShell.setForeground(display .getSystemColor(SWT.COLOR_INFO_FOREGROUND)); hoverShell.addPaintListener(pe -> { pe.gc.drawString(text, hm, hm); if (!MAC) { pe.gc.drawPolygon(getPolygon(true)); } }); hoverShell.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { hideHover(); } }); }
Hover(Shell parent) { final Display display = parent.getDisplay(); hoverShell = new Shell(parent, SWT.NO_TRIM | SWT.ON_TOP | SWT.NO_FOCUS | SWT.TOOL); hoverShell.setBackground(display .getSystemColor(SWT.COLOR_INFO_BACKGROUND)); hoverShell.setForeground(display .getSystemColor(SWT.COLOR_INFO_FOREGROUND)); hoverShell.addPaintListener(pe -> { pe.gc.drawString(text, hm, hm); if (!MAC) { pe.gc.drawPolygon(getPolygon(true)); } }); hoverShell.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { hideHover(); } }); }
void doPaint(final Event event) { final RevCommit c = (RevCommit) ((TableItem) event.item).getData(); if (c instanceof SWTCommit) { final SWTLane lane = ((SWTCommit) c).getLane(); if (lane != null && lane.color.isDisposed()) return; } if (highlight != null && c.has(highlight)) event.gc.setFont(hFont); else event.gc.setFont(nFont); if (event.index == 1) { renderer.paint(event, input == null ? null : input.getHead()); return; } final ITableLabelProvider lbl; final String txt; lbl = (ITableLabelProvider) table.getLabelProvider(); txt = lbl.getColumnText(c, event.index); final Point textsz = event.gc.textExtent(txt); final int texty = (event.height - textsz.y) / 2; event.gc.drawString(txt, event.x, event.y + texty, true); }
protected void paintRect(GC gc, int x, int y, Color a, Color b, Color c) { int[] p = new int[] { 0, 2, 2, 0, 30, 0, 32, 2, 32, 30, 30, 32, 2, 32, 0, 30}; int[] q = new int[p.length]; for (int i = 0; i < p.length / 2; i++) { q[i*2] = p[i*2] + x; q[i*2+1] = p[i*2+1] + y; } Region region = new Region(getDisplay()); region.add(q); gc.setClipping(region); gc.setBackground(a); gc.setForeground(b); gc.fillGradientRectangle(x, y, 32, 32, true); gc.setClipping((Region)null); gc.setForeground(c); gc.drawPolygon(q); gc.setForeground(getForeground()); gc.setBackground(getBackground()); String st = "Tomcat Test Environment"; Point stp = gc.stringExtent(st); gc.drawString(st, x+16 - stp.x / 2, y + 32 + 2); }