本文整理了Java中org.eclipse.swt.graphics.GC.getAdvanceWidth()
方法的一些代码示例,展示了GC.getAdvanceWidth()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GC.getAdvanceWidth()
方法的具体详情如下:
包路径:org.eclipse.swt.graphics.GC
类名称:GC
方法名:getAdvanceWidth
[英]Returns the advance width of the specified character in the font which is currently selected into the receiver.
The advance width is defined as the horizontal distance the cursor should move after printing the character in the selected font.
[中]返回接收器中当前选定字体中指定字符的前进宽度。
前进宽度定义为以选定字体打印字符后光标应移动的水平距离。
代码示例来源:origin: org.eclipse.jdt/org.eclipse.jdt.ui
public void initialize(GC gc) {
fSeparatorWidth= gc.getAdvanceWidth(SEPARATOR);
fMessage= " " + JavaUIMessages.TypeInfoViewer_separator_message + " "; //$NON-NLS-1$ //$NON-NLS-2$
fMessageLength= gc.textExtent(fMessage).x;
}
}
代码示例来源:origin: org.eclipse/org.eclipse.ajdt.ui
public void initialize(GC gc) {
fSeparatorWidth= gc.getAdvanceWidth(SEPARATOR);
fMessage= " " + JavaUIMessages.TypeInfoViewer_separator_message + " "; //$NON-NLS-1$ //$NON-NLS-2$
fMessageLength= gc.textExtent(fMessage).x;
}
}
代码示例来源:origin: org.eclipse/org.eclipse.jdt.ui
public void initialize(GC gc) {
fSeparatorWidth= gc.getAdvanceWidth(SEPARATOR);
fMessage= " " + JavaUIMessages.TypeInfoViewer_separator_message + " "; //$NON-NLS-1$ //$NON-NLS-2$
fMessageLength= gc.textExtent(fMessage).x;
}
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.jdt.ui
public void initialize(GC gc) {
fSeparatorWidth= gc.getAdvanceWidth(SEPARATOR);
fMessage= " " + JavaUIMessages.TypeInfoViewer_separator_message + " "; //$NON-NLS-1$ //$NON-NLS-2$
fMessageLength= gc.textExtent(fMessage).x;
}
}
代码示例来源:origin: org.piccolo2d/piccolo2d-swt
/**
* Returns the advance width of the character provided in the current font.
*
* @param ch character to calculate the advance width of.
*
* @return advance width of the character in the current font
*/
public int getAdvanceWidth(final char ch) {
final org.eclipse.swt.graphics.Font scaledFont = gc.getFont();
gc.setFont(curFont);
final int width = gc.getAdvanceWidth(ch);
gc.setFont(scaledFont);
return width;
}
代码示例来源:origin: org.eclipse/org.eclipse.wst.xsd.ui
Point pointSize = gc.stringExtent(XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_TESTING_PAGE_DESCRIPTION"));
GridData gd = new GridData();
gd.widthHint = pointSize.x / 2 + gc.getAdvanceWidth('M')*11;
gd.horizontalAlignment= GridData.FILL;
separator.setLayoutData(gd);
代码示例来源:origin: org.eclipse.platform/org.eclipse.ui.workbench
private String getSeparatorLabel(String separatorLabel) {
Rectangle rect = list.getTable().getBounds();
int borderWidth = list.getTable().computeTrim(0, 0, 0, 0).width;
int imageWidth = WorkbenchImages.getImage(
IWorkbenchGraphicConstants.IMG_OBJ_SEPARATOR).getBounds().width;
int width = rect.width - borderWidth - imageWidth;
GC gc = new GC(list.getTable());
gc.setFont(list.getTable().getFont());
int fSeparatorWidth = gc.getAdvanceWidth('-');
int fMessageLength = gc.textExtent(separatorLabel).x;
gc.dispose();
StringBuilder dashes = new StringBuilder();
int chars = (((width - fMessageLength) / fSeparatorWidth) / 2) - 2;
for (int i = 0; i < chars; i++) {
dashes.append('-');
}
StringBuilder result = new StringBuilder();
result.append(dashes);
result.append(" " + separatorLabel + " "); //$NON-NLS-1$//$NON-NLS-2$
result.append(dashes);
return result.toString().trim();
}
内容来源于网络,如有侵权,请联系作者删除!