本文整理汇总了Java中org.eclipse.swt.graphics.TextLayout.draw方法的典型用法代码示例。如果您正苦于以下问题:Java TextLayout.draw方法的具体用法?Java TextLayout.draw怎么用?Java TextLayout.draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.graphics.TextLayout
的用法示例。
在下文中一共展示了TextLayout.draw方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPaintObjectListener
import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
/**
* Convenience method
*
* @param inWidget
* {@link StyledText}
* @return {@link PaintObjectListener}
*/
public static PaintObjectListener getPaintObjectListener(
final StyledText inWidget) {
return new PaintObjectListener() {
@Override
public void paintObject(final PaintObjectEvent inEvent) {
final Display lDisplay = inEvent.display;
final StyleRange lStyle = inEvent.style;
final int lPosition = inEvent.x + lStyle.metrics.width
- BULLET_WIDTH + 2;
Font lFont = lStyle.font;
if (lFont == null)
lFont = inWidget.getFont();
final TextLayout lLayout = new TextLayout(lDisplay);
lLayout.setAscent(inEvent.ascent);
lLayout.setDescent(inEvent.descent);
lLayout.setFont(lFont);
lLayout.setText(String.format("%s.", inEvent.bulletIndex + 1)); //$NON-NLS-1$
lLayout.draw(inEvent.gc, lPosition, inEvent.y);
lLayout.dispose();
}
};
}
示例2: updateImage
import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
protected void updateImage() {
Rectangle bounds = getBounds();
if (bounds.width <= 0 || bounds.height <= 0)
return;
TextLayout layout = new TextLayout(Display.getDefault());
//layout.setFont(getFont());
layout.setText(getText());
for (StyleRange styleRange : ranges) {
//styleRange.background = ColorConstants.white;
layout.setStyle(styleRange, styleRange.start, styleRange.start
+ styleRange.length);
}
if (image != null && !image.isDisposed()) {
image.dispose();
}
image = new Image(Display.getDefault(), bounds.width, bounds.height);
GC gc = new GC(image);
gc.setBackground(ColorConstants.red);
layout.draw(gc, 0, 0);
image.getImageData().transparentPixel = image.getImageData().palette
.getPixel(ColorConstants.white.getRGB());
layout.dispose();
gc.dispose();
}
示例3: drawTextLayout
import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
/**
* @see Graphics#drawTextLayout(TextLayout, int, int, int, int, Color,
* Color)
*/
public void drawTextLayout(TextLayout layout, int x, int y,
int selectionStart, int selectionEnd, Color selectionForeground,
Color selectionBackground) {
// $TODO probably just call checkPaint since Font and BG color don't
// apply
checkText();
layout.draw(gc, x + translateX, y + translateY, selectionStart,
selectionEnd, selectionForeground, selectionBackground);
}
示例4: paintCell
import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
@Override
public void paintCell(LayerCell cell, GC gc, Rectangle bounds, IConfigRegistry configRegistry) {
super.paintCell(cell, gc, bounds, configRegistry);
IStyle cellStyle = CellStyleUtil.getCellStyle(cell, configRegistry);
setupGCFromConfig(gc, cellStyle);
TextLayout layout = getCellTextLayout(cell);
Rectangle rectangle = cell.getBounds();
layout.draw(gc, rectangle.x + leftPadding, rectangle.y + topPadding);
layout.dispose();
}
示例5: draw
import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public void draw(GC gc, JaretTable jaretTable, ICellStyle cellStyle, Rectangle drawingArea, IRow row,
IColumn column, boolean drawFocus, boolean selected, boolean printing) {
drawBackground(gc, drawingArea, cellStyle, selected, printing);
Rectangle drect = drawBorder(gc, cellStyle, drawingArea, printing);
Rectangle rect = applyInsets(drect);
// convert the value to a string
String s = convertValue(row, column);
Color fg = gc.getForeground();
Color bg = gc.getBackground();
Font font = gc.getFont();
// draw comment marker if comment is present and not printing
if (!printing && getComment(row, column) != null) {
drawCommentMarker(gc, drawingArea, _commentColor, COMMENTMARKER_SIZE);
}
if (drawFocus) {
drawFocus(gc, drect);
}
drawSelection(gc, drawingArea, cellStyle, selected, printing);
gc.setForeground(fg);
gc.setBackground(bg);
gc.setFont(font);
if (s != null) {
if (selected && !printing) {
gc.setBackground(SELECTIONCOLOR);
} else {
gc.setBackground(getBackgroundColor(cellStyle, printing));
}
gc.setForeground(getForegroundColor(cellStyle, printing));
gc.setFont(getFont(cellStyle, printing, gc.getFont()));
drawCellString(gc, rect, s, cellStyle);
if (s.indexOf("we") != -1) {
TextLayout textLayout = new TextLayout(gc.getDevice());
textLayout.setText(s);
textLayout.setFont(gc.getFont());
textLayout.setWidth(rect.width);
Color color = new Color(gc.getDevice(), 150, 100, 100);
Font font2 = new Font(gc.getDevice(), gc.getFont().getFontData()[0].getName(), gc.getFont()
.getFontData()[0].getHeight(), SWT.ITALIC);
TextStyle style = new TextStyle(font2, color, null);
for (int i = 1; i < s.length(); i++) {
int j = indexOf(s, "we", i, false);
if (j != -1) {
textLayout.setStyle(style, j, j + 3);
} else {
break;
}
}
gc.fillRectangle(rect);
textLayout.draw(gc, rect.x, rect.y);
gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_FOREGROUND));
}
}
}
示例6: paintControl
import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
void paintControl(PaintEvent e) {
GC gc = e.gc;
gc.setFont(fontSmall);
if (finding == null) {
gc.drawText("no Finding set", 20, 20);
return;
}
int xOff1 = 0;
int xOff4 = 510;
gc.setForeground(BLUE);
gc.setFont(fontBig);
gc.setForeground(DARKGRAY);
gc.drawLine(iPixX, 0, iPixX, iPixY);
gc.drawLine(xOff4, 0, xOff4, iPixY);
StringBuffer title = new StringBuffer(finding.getName());
if (finding.getRangeStart() > 0 && finding.getRangeEnd() > 0) {
title.append(" (");
title.append(finding.getRangeStart());
title.append(" - ");
title.append(finding.getRangeEnd());
title.append(" )");
} else {
title.append(" (keine Ref.Werte)");
}
gc.drawText(title.toString(), xOff1, 2, true);
gc.setFont(fontSmall);
gc.setForeground(BLUE);
String sTxt1 = finding.getText();
gc.drawText(sTxt1, xOff1 + 10, 30);
if (finding.getMaxOfSpan3() == -1) {
gc.drawText("Resultat:\t keine Werte",
xOff1 + 10, 100, true);
}
else {
gc.drawText(
"Resultat:\t " + finding.getMaxOfSpan3() + "\n"
+ CstService.getGermanFromDate(finding.getDateStartOfSpan3()),
xOff1 + 10, 100, true);
}
gc.setForeground(BLACK);
final TextLayout layout = new TextLayout(getDisplay());
layout.setText(finding.getAbstract() == null ? "null" : finding.getAbstract());
layout.setWidth(250);
Font fontNormal = UiDesk.getFont("Helvetica", 7, SWT.NORMAL); //$NON-NLS-1$
layout.setFont(fontNormal);
layout.draw(gc, xOff4 + 4, 4);
gc.dispose();
}
示例7: paintControl
import org.eclipse.swt.graphics.TextLayout; //导入方法依赖的package包/类
void paintControl(PaintEvent e) {
GC gc = e.gc;
gc.setFont(fontSmall);
if (finding == null) {
gc.drawText("no Finding set", 20, 20);
return;
}
int xOff1 = 0;
int xOff4 = 510;
gc.setForeground(BLUE);
gc.setFont(fontBig);
gc.setForeground(DARKGRAY);
gc.drawLine(iPixX, 0, iPixX, iPixY);
gc.drawLine(xOff4, 0, xOff4, iPixY);
StringBuffer title = new StringBuffer(finding.getName());
/*
if (finding.getRangeStart() > 0 && finding.getRangeEnd() > 0) {
title.append(" (");
title.append(finding.getRangeStart());
title.append(" - ");
title.append(finding.getRangeEnd());
title.append(" )");
} else {
title.append(" (keine Ref.Werte)");
}
*/
gc.drawText(title.toString(), xOff1, 2, true);
gc.setFont(fontSmall);
gc.setForeground(BLUE);
String sTxt1 = finding.getText();
gc.drawText(sTxt1, xOff1 + 10, 30);
/*
if (finding.getMaxOfSpan3() == -1) {
gc.drawText("Resultat:\t keine Werte",
xOff1 + 10, 100, true);
}
else {
gc.drawText(
"Resultat:\t " + finding.getMaxOfSpan3() + "\n"
+ CstService.getGermanFromDate(finding.getDateStartOfSpan3()),
xOff1 + 10, 100, true);
}
*/
gc.setForeground(BLACK);
final TextLayout layout = new TextLayout(getDisplay());
layout.setText(finding.getAbstract() == null ? "null" : finding.getAbstract());
layout.setWidth(250);
Font fontNormal = UiDesk.getFont("Helvetica", 7, SWT.NORMAL); //$NON-NLS-1$
layout.setFont(fontNormal);
layout.draw(gc, xOff4 + 4, 4);
gc.dispose();
}