本文整理匯總了Java中org.eclipse.swt.graphics.FontData.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java FontData.getName方法的具體用法?Java FontData.getName怎麽用?Java FontData.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.swt.graphics.FontData
的用法示例。
在下文中一共展示了FontData.getName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: changeFont
import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
protected Font changeFont(IFigure figure) {
NodeElement nodeElement = (NodeElement) this.getModel();
String fontName = nodeElement.getFontName();
int fontSize = nodeElement.getFontSize();
if (Check.isEmpty(fontName)) {
FontData fontData = Display.getCurrent().getSystemFont()
.getFontData()[0];
fontName = fontData.getName();
nodeElement.setFontName(fontName);
}
if (fontSize <= 0) {
fontSize = ViewableModel.DEFAULT_FONT_SIZE;
nodeElement.setFontSize(fontSize);
}
this.font = Resources.getFont(fontName, fontSize);
figure.setFont(this.font);
return font;
}
示例2: changeFont
import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
protected Font changeFont(IFigure figure) {
RemovedNodeElement removedNodeElement = (RemovedNodeElement) this
.getModel();
String fontName = removedNodeElement.getFontName();
int fontSize = removedNodeElement.getFontSize();
if (fontName == null) {
FontData fontData = Display.getCurrent().getSystemFont()
.getFontData()[0];
fontName = fontData.getName();
}
if (fontSize <= 0) {
fontSize = ViewableModel.DEFAULT_FONT_SIZE;
}
this.font = Resources.getFont(fontName, fontSize);
figure.setFont(this.font);
return font;
}
示例3: changeFont
import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
protected Font changeFont(final IFigure figure) {
final RemovedNodeElement removedNodeElement = (RemovedNodeElement) getModel();
String fontName = removedNodeElement.getFontName();
int fontSize = removedNodeElement.getFontSize();
if (fontName == null) {
final FontData fontData = Display.getCurrent().getSystemFont().getFontData()[0];
fontName = fontData.getName();
}
if (fontSize <= 0) {
fontSize = ViewableModel.DEFAULT_FONT_SIZE;
}
font = Resources.getFont(fontName, fontSize);
figure.setFont(font);
return font;
}
示例4: changeFont
import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
protected Font changeFont(final IFigure figure) {
final NodeElement nodeElement = (NodeElement) getModel();
String fontName = nodeElement.getFontName();
int fontSize = nodeElement.getFontSize();
if (Check.isEmpty(fontName)) {
final FontData fontData = Display.getCurrent().getSystemFont().getFontData()[0];
fontName = fontData.getName();
nodeElement.setFontName(fontName);
}
if (fontSize <= 0) {
fontSize = ViewableModel.DEFAULT_FONT_SIZE;
nodeElement.setFontSize(fontSize);
}
font = Resources.getFont(fontName, fontSize);
figure.setFont(font);
return font;
}
示例5: initFormText
import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
public static void initFormText(FormText formText) {
formText.setWhitespaceNormalized(false);
Font formTextFont = formText.getFont();
FontData formTextFontData = formTextFont.getFontData()[0];
FontData h1FontData = new FontData(formTextFontData.getName(), formTextFontData.getHeight() + 5, SWT.BOLD);
final Font h1Font = new Font(formTextFont.getDevice(), h1FontData);
formText.setFont(FONT_H1_KEY, h1Font);
FontData h3FontData = new FontData(formTextFontData.getName(), formTextFontData.getHeight() + 3, SWT.BOLD);
final Font h3Font = new Font(formTextFont.getDevice(), h3FontData);
formText.setFont(FONT_H3_KEY, h3Font);
Font codeFont = JFaceResources.getTextFont();
formText.setFont(FONT_CODE_KEY, codeFont);
formText.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
h1Font.dispose();
h3Font.dispose();
}
});
// Set fontKeySet = JFaceResources.getFontRegistry().getKeySet();
// if (fontKeySet != null) {
// for (Object fontKey : fontKeySet) {
// System.out.println(fontKey);
// }
// }
}
示例6: attachNote
import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
private void attachNote(final Composite container) {
Label lblParameterGridNote=new Label(container, SWT.NONE);
FontData fontData = lblParameterGridNote.getFont().getFontData()[0];
Font font = new Font(lblParameterGridNote.getDisplay(), new FontData(fontData.getName(), fontData
.getHeight(), SWT.ITALIC));
lblParameterGridNote.setText("Note - New parameters will be visible only after you save the job.");
lblParameterGridNote.setFont(font);
if(!visibleParameterGirdNote)
lblParameterGridNote.setVisible(false);
}
示例7: createConsoleBufferWidget
import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
/**
* Create console buffer widget
* @param bufferSize
*/
private void createConsoleBufferWidget(String bufferSize){
HydroGroup hydroGroup = new HydroGroup(this, SWT.NONE);
hydroGroup.setHydroGroupText(Messages.HYDROGRAPH_CONSOLE_PREFERANCE_PAGE_GROUP_NAME);
hydroGroup.setLayout(new GridLayout(1, false));
hydroGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
hydroGroup.getHydroGroupClientArea().setLayout(new GridLayout(2, false));
Label label = new Label(hydroGroup.getHydroGroupClientArea(), SWT.NONE);
label.setText(Messages.PREFERANCE_CONSOLE_BUFFER_SIZE);
textWidget = new Text(hydroGroup.getHydroGroupClientArea(), SWT.BORDER);
textWidget.setText(bufferSize);
textWidget.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
textWidget.setTextLimit(6);
attachConsoleBufferValidator();
Composite purgeComposite = new Composite(hydroGroup.getHydroGroupClientArea(), SWT.NONE);
purgeComposite.setLayout(new GridLayout(2, false));
purgeComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
Label lblNote = new Label(purgeComposite, SWT.TOP | SWT.WRAP);
lblNote.setText(Messages.PREFERANCE_PAGE_NOTE);
FontData fontData = lblNote.getFont().getFontData()[0];
Font font = new Font(purgeComposite.getDisplay(), new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD));
lblNote.setFont(font);
Label lblmsg = new Label(purgeComposite, SWT.TOP | SWT.WRAP);
lblmsg.setText(Messages.UI_PERFORMANCE_NOTE_IN_CASE_OF_CHANGE_IN_BUFFER_SIZE);
}
示例8: getModifiedFontData
import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
private static FontData[] getModifiedFontData(int style) {
FontData[] styleData = new FontData[ArchitecturalLabelDecoratorBase.baseData.length];
for (int i = 0; i < styleData.length; i++) {
FontData base = ArchitecturalLabelDecoratorBase.baseData[i];
styleData[i] = new FontData(base.getName(), base.getHeight(), base.getStyle() | style);
}
return styleData;
}
示例9: getBoldFont
import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
/**
* Returns a bold version of the given {@link Font}.
*
* @param baseFont
* the {@link Font} for which a bold version is desired
* @return the bold version of the given {@link Font}
*/
public static Font getBoldFont(Font baseFont) {
Font font = m_fontToBoldFontMap.get(baseFont);
if (font == null) {
FontData fontDatas[] = baseFont.getFontData();
FontData data = fontDatas[0];
font = new Font(Display.getCurrent(), data.getName(), data.getHeight(), SWT.BOLD);
m_fontToBoldFontMap.put(baseFont, font);
}
return font;
}
示例10: TextFieldPopupMenu
import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
private TextFieldPopupMenu() {
FontData fontData = Display.getCurrent().getSystemFont()
.getFontData()[0];
Font font = new Font(fontData.getName(), Font.PLAIN, 12);
JMenuItem cutMenuItem = this.add(new CutAction());
cutMenuItem.setFont(font);
JMenuItem copyMenuItem = this.add(new CopyAction());
copyMenuItem.setFont(font);
JMenuItem pasteMenuItem = this.add(new PasteAction());
pasteMenuItem.setFont(font);
}
示例11: convertTopLevelFont
import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
public static String convertTopLevelFont(String styles, FontData fontData) {
boolean bold = (fontData.getStyle() & SWT.BOLD) != 0;
boolean italic = (fontData.getStyle() & SWT.ITALIC) != 0;
String size = Integer.toString(fontData.getHeight()) + UNIT;
String family = "'" + fontData.getName() + "',sans-serif";
styles = styles.replaceFirst("(html\\s*\\{.*(?:\\s|;)font-size:\\s*)\\d+pt(\\;?.*\\})", "$1" + size + "$2");
styles = styles.replaceFirst("(html\\s*\\{.*(?:\\s|;)font-weight:\\s*)\\w+(\\;?.*\\})", "$1" + (bold ? "bold" : "normal") + "$2");
styles = styles.replaceFirst("(html\\s*\\{.*(?:\\s|;)font-style:\\s*)\\w+(\\;?.*\\})", "$1" + (italic ? "italic" : "normal") + "$2");
styles = styles.replaceFirst("(html\\s*\\{.*(?:\\s|;)font-family:\\s*).+?(;.*\\})", "$1" + family + "$2");
return styles;
}
示例12: toAwtFont
import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
/**
* Create an awt font by converting as much information
* as possible from the provided swt <code>FontData</code>.
* <p>Generally speaking, given a font size, an swt font will
* display differently on the screen than the corresponding awt
* one. Because the SWT toolkit use native graphical ressources whenever
* it is possible, this fact is platform dependent. To address
* this issue, it is possible to enforce the method to return
* an awt font with the same height as the swt one.
*
* @param device The swt device being drawn on (display or gc device).
* @param fontData The swt font to convert.
* @param ensureSameSize A boolean used to enforce the same size
* (in pixels) between the swt font and the newly created awt font.
* @return An awt font converted from the provided swt font.
*/
public static java.awt.Font toAwtFont(Device device, FontData fontData,
boolean ensureSameSize) {
int height = (int) Math.round(fontData.getHeight() * device.getDPI().y
/ 72.0);
// hack to ensure the newly created awt fonts will be rendered with the
// same height as the swt one
if (ensureSameSize) {
GC tmpGC = new GC(device);
Font tmpFont = new Font(device, fontData);
tmpGC.setFont(tmpFont);
JPanel DUMMY_PANEL = new JPanel();
java.awt.Font tmpAwtFont = new java.awt.Font(fontData.getName(),
fontData.getStyle(), height);
if (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az)
> tmpGC.textExtent(Az).x) {
while (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az)
> tmpGC.textExtent(Az).x) {
height--;
tmpAwtFont = new java.awt.Font(fontData.getName(),
fontData.getStyle(), height);
}
}
else if (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az)
< tmpGC.textExtent(Az).x) {
while (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az)
< tmpGC.textExtent(Az).x) {
height++;
tmpAwtFont = new java.awt.Font(fontData.getName(),
fontData.getStyle(), height);
}
}
tmpFont.dispose();
tmpGC.dispose();
}
return new java.awt.Font(fontData.getName(), fontData.getStyle(),
height);
}
示例13: getTransformedFont
import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
/**
* Deprecated since SWT now handles this.
*
* @deprecated
* @return font that's been transformed by the current transform
*/
protected org.eclipse.swt.graphics.Font getTransformedFont() {
if (curFont != null) {
final FontData fontData = curFont.getFontData()[0];
int height = fontData.getHeight();
TEMP_RECT.setRect(0, 0, height, height);
SWTShapeManager.transform(TEMP_RECT, transform);
height = (int) (TEMP_RECT.getHeight() + 0.5);
final String fontString = "name=" + fontData.getName() + ";bold=" + ((fontData.getStyle() & SWT.BOLD) != 0)
+ ";italic=" + ((fontData.getStyle() & SWT.ITALIC) != 0) + ";size=" + height;
return getFont(fontString);
}
return null;
}
示例14: createPartControl
import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
@Override
public void createPartControl(Composite parent) {
FillLayout fillLayout = new FillLayout(SWT.VERTICAL);
fillLayout.marginHeight = 5;
fillLayout.marginWidth = 5;
parent.setLayout(fillLayout);
// main container
container = new Composite(parent, SWT.BORDER);
container.setLayout(new FillLayout());
// create container for stack trace data
Composite stacktraceDataContainer = new Composite(parent, SWT.BORDER);
FormLayout formLayout = new FormLayout();
formLayout.marginHeight = 5;
formLayout.marginWidth = 5;
formLayout.spacing = 5;
stacktraceDataContainer.setLayout(formLayout);
Composite stackLabelContainer = new Composite(stacktraceDataContainer, SWT.NO_SCROLL | SWT.SHADOW_NONE);
stackLabelContainer.setLayout(new GridLayout());
FormData stackLabelFormData = new FormData();
stackLabelFormData.top = new FormAttachment(0);
stackLabelFormData.left = new FormAttachment(0);
stackLabelFormData.right = new FormAttachment(100);
stackLabelFormData.bottom = new FormAttachment(20);
stackLabelContainer.setLayoutData(stackLabelFormData);
Composite stackTraceContainer = new Composite(stacktraceDataContainer, SWT.NO_SCROLL | SWT.SHADOW_NONE);
stackTraceContainer.setLayout(new FillLayout());
FormData stackTraceFormData = new FormData();
stackTraceFormData.top = new FormAttachment(stackLabelContainer);
stackTraceFormData.left = new FormAttachment(0);
stackTraceFormData.right = new FormAttachment(100);
stackTraceFormData.bottom = new FormAttachment(100);
stackTraceContainer.setLayoutData(stackTraceFormData);
// Create viewer for test tree in main container
testTreeViewer = new TreeViewer(container);
testTreeViewer.setContentProvider(new XpectContentProvider());
testTreeViewer.setLabelProvider(new XpectLabelProvider(this.testsExecutionStatus));
testTreeViewer.setInput(null);
// create stack trace label
stacktraceLabel = new Label(stackLabelContainer, SWT.SHADOW_OUT);
FontData fontData = stacktraceLabel.getFont().getFontData()[0];
Display display = Display.getCurrent();
// may be null if outside the UI thread
if (display == null)
display = Display.getDefault();
Font font = new Font(display, new FontData(fontData.getName(), fontData
.getHeight(), SWT.BOLD));
// Make stack trace label bold
stacktraceLabel.setFont(font);
stacktraceLabel.setText(NO_TRACE_MSG);
// create stack trace console
MessageConsole messageConsole = new MessageConsole("trace", null);
stacktraceConsole = new TraceConsole(messageConsole);
stacktraceConsoleViewer = new TextConsoleViewer(stackTraceContainer, messageConsole);
// context menu
getSite().setSelectionProvider(testTreeViewer);
MenuManager contextMenu = new MenuManager();
contextMenu.setRemoveAllWhenShown(true);
getSite().registerContextMenu(contextMenu, testTreeViewer);
Control control = testTreeViewer.getControl();
Menu menu = contextMenu.createContextMenu(control);
control.setMenu(menu);
activateContext();
createSelectionActions();
}
示例15: addToComposite
import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
private void addToComposite(Group choosenGroup, final String name, final String description, final boolean isMultiValued) {
boolean isNotChecked = true;
if (allVariables != null) {
isNotChecked = !isChecked(allVariables, name);
}
if (isNotChecked) {
final Button checkBtn = new Button(choosenGroup, SWT.CHECK);
checkBtn.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
if (checkBtn.getSelection()) {
selectedVariable.add(new CouchVariable(name, description, isMultiValued));
} else {
selectedVariable.remove(getIndex(name, selectedVariable));
}
}
});
Label labelName = new Label(choosenGroup, SWT.NONE);
FontData fontData = labelName.getFont().getFontData()[0];
Font font = new Font(this.getDisplay(), new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD));
labelName.setFont(font);
String label = name;
if (label.startsWith("p_") || label.startsWith("q_")) {
label = name.substring(2);
}
if (isMultiValued) {
label += " [ ]";
}
labelName.setText(label);
C8oBrowser browserDescription = new C8oBrowser(choosenGroup, SWT.MULTI | SWT.WRAP);
browserDescription.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
browserDescription.setText("<html>" +
"<head>" +
"<script type=\"text/javascript\">"+
"document.oncontextmenu = new Function(\"return false\");"+
"</script>"+
"<style type=\"text/css\">"+
"body {"+
"font-family: Tahoma new, sans-serif;" +
"font-size: 0.7em;"+
"margin-top: 5px;" +
"overflow-y: auto;" +
"background-color: #ECEBEB }"+
"</style></head><p>" + description + "</p></html>");
parametersCouch.add(name);
}
}