Java Code Examples for org.eclipse.swt.graphics.FontMetrics#getDescent()
The following examples show how to use
org.eclipse.swt.graphics.FontMetrics#getDescent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractDebugVariableCodeMining.java From jdt-codemining with Eclipse Public License 1.0 | 6 votes |
/** * Draw square of the given rgb. * * @param rgb the rgb color * @param gc the graphic context * @param textWidget the text widget * @param x the location y * @param y the location y * @return the square width. */ private int drawSquare(RGB rgb, GC gc, StyledText textWidget, int x, int y) { FontMetrics fontMetrics = gc.getFontMetrics(); int size = getSquareSize(fontMetrics); x += fontMetrics.getLeading(); y += fontMetrics.getDescent(); Rectangle rect = new Rectangle(x, y, size, size); // Fill square gc.setBackground(getColor(rgb, textWidget.getDisplay())); gc.fillRectangle(rect); // Draw square box gc.setForeground(textWidget.getForeground()); gc.drawRectangle(rect); return getSquareWidth(gc.getFontMetrics()); }
Example 2
Source File: TextPaintInstruction.java From nebula with Eclipse Public License 2.0 | 4 votes |
@Override public void paint(GC gc, Rectangle area) { if (!this.state.isRendering()) { return; } FontMetrics metrics = gc.getFontMetrics(); FontMetrics metricsToUse = metrics; int baseline = metrics.getAscent() + metrics.getLeading(); int yAdvance = 0; if (this.state.getCurrentLineHeight() > metrics.getHeight()) { int biggerBaseline = this.state.getCurrentBiggestFontMetrics().getAscent() + this.state.getCurrentBiggestFontMetrics().getLeading(); yAdvance = biggerBaseline - baseline; metricsToUse = this.state.getCurrentBiggestFontMetrics(); } Point pointer = this.state.getPointer(); // on alignment justify render word by word int textLength = 0; if (TextAlignment.JUSTIFY.equals(this.state.getTextAlignment())) { LinePainter line = this.state.getCurrentLine(); for (String word : this.words) { gc.drawText(word, pointer.x, pointer.y + yAdvance, (!this.state.hasPreviousBgColor())); int length = gc.textExtent(word).x + line.getNextJustifySpace(); pointer.x += length; textLength += length; } } else { textLength = getTextLength(gc); gc.drawText(text, pointer.x, pointer.y + yAdvance, (!this.state.hasPreviousBgColor())); } if (this.state.isUnderlineActive()) { int underlineY = pointer.y + baseline + yAdvance + (metricsToUse.getDescent() / 2); gc.drawLine(pointer.x, underlineY, pointer.x + textLength, underlineY); } if (this.state.isStrikethroughActive()) { int strikeY = pointer.y + yAdvance + (metrics.getHeight() / 2) + (metrics.getLeading() / 2); gc.drawLine(pointer.x, strikeY, pointer.x + textLength, strikeY); } if (!TextAlignment.JUSTIFY.equals(this.state.getTextAlignment())) { pointer.x += textLength; } }
Example 3
Source File: AbstractDebugVariableCodeMining.java From jdt-codemining with Eclipse Public License 1.0 | 2 votes |
/** * Returns the colorized square size. * * @param fontMetrics * @return the colorized square size. */ public static int getSquareSize(FontMetrics fontMetrics) { return fontMetrics.getHeight() - 2 * fontMetrics.getDescent(); }