本文整理汇总了Java中org.eclipse.swt.graphics.FontData.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Java FontData.getHeight方法的具体用法?Java FontData.getHeight怎么用?Java FontData.getHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.swt.graphics.FontData
的用法示例。
在下文中一共展示了FontData.getHeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setFontDataStyle
import org.eclipse.swt.graphics.FontData; //导入方法依赖的package包/类
/**
* Set font data style for given component. E.g.
*
* <pre>
* Label label = ...
* SWTUtil.setFontDataStyle(label, SWT.ITALIC);
* </pre>
*
* @param control
* @param style
*/
public static void setFontDataStyle(Control control, int style) {
if (control == null) {
return;
}
if (control.isDisposed()) {
return;
}
Font font = control.getFont();
if (font == null) {
return;
}
FontData fontData = font.getFontData()[0];
Font newFont = new Font(control.getDisplay(), new FontData(fontData.getName(), fontData.getHeight(), style));
control.setFont(newFont);
}
示例2: getFontChooser
import org.eclipse.swt.graphics.FontData; //导入方法依赖的package包/类
private FontData getFontChooser(final Composite parent,String title,FontData fontData){
final FontData selection = new FontData(fontData.getName(),fontData.getHeight(),fontData.getStyle());
Label label = new Label(parent, SWT.NULL);
label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, true));
label.setText(title);
Button button = new Button(parent, SWT.PUSH);
button.setLayoutData(getAlignmentData(MINIMUM_CONTROL_WIDTH,SWT.FILL));
button.setText(TuxGuitar.getProperty("choose"));
button.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent arg0) {
Font font = new Font(parent.getDisplay(),selection);
FontDialog fontDialog = new FontDialog(parent.getShell());
fontDialog.setFontList(font.getFontData());
FontData fd = fontDialog.open();
if(fd != null){
selection.setName( fd.getName() );
selection.setHeight( fd.getHeight() );
selection.setStyle( fd.getStyle() );
}
font.dispose();
}
});
return selection;
}
示例3: 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);
// }
// }
}
示例4: 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);
}
示例5: 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);
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: setButtonFontData
import org.eclipse.swt.graphics.FontData; //导入方法依赖的package包/类
protected void setButtonFontData(Button button,FontData fontData) {
String text = fontData.getName();
if( (fontData.getStyle() & SWT.BOLD) != 0 ){
text += " Bold";
}
if( (fontData.getStyle() & SWT.ITALIC) != 0 ){
text += " Italic";
}
text += (" " + fontData.getHeight());
button.setText(text);
}
示例10: 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();
}
示例11: 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);
}
}
示例12: Styles
import org.eclipse.swt.graphics.FontData; //导入方法依赖的package包/类
private Styles(Shell shell) {
Font font = shell.getDisplay().getSystemFont();
FontData fd = font.getFontData()[0];
fontStyle = new FontStyle(fd.getName(), fd.getHeight(), fd.getStyle());
}
示例13: print
import org.eclipse.swt.graphics.FontData; //导入方法依赖的package包/类
public void print(){
if (printer.startJob("Text")) { // the string is the job name - shows up
try {// in the printer's job list
Rectangle clientArea = printer.getClientArea();
Rectangle trim = printer.computeTrim(0, 0, 0, 0);
Point dpi = printer.getDPI();
leftMargin = dpi.x + trim.x; // one inch from left side of paper
rightMargin = clientArea.width - dpi.x + trim.x + trim.width; // one
// inch
// from
// right
// side
// of
// paper
topMargin = dpi.y + trim.y; // one inch from top edge of paper
bottomMargin = clientArea.height - dpi.y + trim.y + trim.height; // one
// inch
// from
// bottom
// edge
// of
// paper
/* Create a buffer for computing tab width. */
int tabSize = 4; // is tab width a user setting in your UI?
StringBuilder tabBuffer = new StringBuilder(tabSize);
for (int i = 0; i < tabSize; i++)
tabBuffer.append(' ');
tabs = tabBuffer.toString();
/*
* Create printer GC, and create and set the printer font &
* foreground color.
*/
gc = new GC(printer);
font = printer.getSystemFont(); // ResourceUtils.getFont(Styles.getInstance().FONT_COURIER);
// foregroundColor = ResourceUtils.getColor(Styles.DARK_RGB_TEXT);
// backgroundColor =
// ResourceUtils.getColor(Styles.BACKGROUND_ENABLED);
FontData fontData = font.getFontData()[0];
printerFont = new Font(printer, fontData.getName(), fontData.getHeight(), fontData.getStyle());
gc.setFont(printerFont);
tabWidth = gc.stringExtent(tabs).x;
lineHeight = gc.getFontMetrics().getHeight();
// RGB rgb = foregroundColor.getRGB();
// printerForegroundColor = new Color(printer, rgb);
// gc.setForeground(printerForegroundColor);
// rgb = backgroundColor.getRGB();
// printerBackgroundColor = new Color(printer, rgb);
// gc.setBackground(printerBackgroundColor);
/* Print text to current gc using word wrap */
printText(printer);
printer.endJob();
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
/* Cleanup graphics resources used in printing */
if (printerFont != null)
printerFont.dispose();
// if(printerForegroundColor != null)
// printerForegroundColor.dispose();
// if(printerBackgroundColor != null)
// printerBackgroundColor.dispose();
if (gc != null)
gc.dispose();
}
}
}
示例14: main
import org.eclipse.swt.graphics.FontData; //导入方法依赖的package包/类
public static void main(String [] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
StyledText styledText = new StyledText(shell, SWT.WRAP | SWT.BORDER);
styledText.setText(text);
FontData data = styledText.getFont().getFontData()[0];
Font font1 = new Font(display, data.getName(), data.getHeight() * 2, data.getStyle());
Font font2 = new Font(display, data.getName(), data.getHeight() * 4 / 5, data.getStyle());
StyleRange[] styles = new StyleRange[8];
styles[0] = new StyleRange();
styles[0].font = font1;
styles[1] = new StyleRange();
styles[1].rise = data.getHeight() / 3;
styles[2] = new StyleRange();
styles[2].background = display.getSystemColor(SWT.COLOR_GREEN);
styles[3] = new StyleRange();
styles[3].foreground = display.getSystemColor(SWT.COLOR_MAGENTA);
styles[4] = new StyleRange();
styles[4].font = font2;
styles[4].foreground = display.getSystemColor(SWT.COLOR_BLUE);;
styles[4].underline = true;
styles[5] = new StyleRange();
styles[5].rise = -data.getHeight() / 3;
styles[5].strikeout = true;
styles[5].underline = true;
styles[6] = new StyleRange();
styles[6].font = font1;
styles[6].foreground = display.getSystemColor(SWT.COLOR_YELLOW);
styles[6].background = display.getSystemColor(SWT.COLOR_BLUE);
styles[7] = new StyleRange();
styles[7].rise = data.getHeight() / 3;
styles[7].underline = true;
styles[7].fontStyle = SWT.BOLD;
styles[7].foreground = display.getSystemColor(SWT.COLOR_RED);
styles[7].background = display.getSystemColor(SWT.COLOR_BLACK);
int[] ranges = new int[] {16, 4, 61, 13, 107, 10, 122, 10, 134, 3, 143, 6, 160, 7, 168, 7};
styledText.setStyleRanges(ranges, styles);
shell.setSize(300, 300);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
font1.dispose();
font2.dispose();
display.dispose();
}
示例15: createItems
import org.eclipse.swt.graphics.FontData; //导入方法依赖的package包/类
private static List<DLItem> createItems(final Shell shell) {
final List<DLItem> list = new ArrayList<DLItem>();
String defaultFontName = null;
int defaultHeight = -1;
for (final FontData fontData : shell.getFont().getFontData()) {
if (defaultFontName == null) {
defaultFontName = fontData.getName();
}
if (defaultHeight == -1) {
defaultHeight = fontData.getHeight();
}
}
final Font font = new Font(shell.getDisplay(), defaultFontName, defaultHeight, SWT.BOLD);
list.add(new DLItem("Austria", createImage(shell, "austria")));
list.add(new DLItem("Belgium", createImage(shell, "belgium")));
list.add(new DLItem("Bulgaria", createImage(shell, "bulgaria")));
list.add(new DLItem("Cyprus", createImage(shell, "cyprus")));
list.add(new DLItem("Czech Republic", createImage(shell, "czech")));
list.add(new DLItem("Denmark", createImage(shell, "denmark")));
list.add(new DLItem("Estonia", createImage(shell, "estonia")));
list.add(new DLItem("Finland", createImage(shell, "finland")));
list.add(new DLItem("France", createImage(shell, "france"), font));
list.add(new DLItem("Germany", createImage(shell, "germany")));
list.add(new DLItem("Greece", createImage(shell, "greece")));
list.add(new DLItem("Hungary", createImage(shell, "hungary")));
list.add(new DLItem("Ireland", createImage(shell, "ireland")));
list.add(new DLItem("Italy", createImage(shell, "italy")));
list.add(new DLItem("Latvia", createImage(shell, "latvia")));
list.add(new DLItem("Lithuania", createImage(shell, "lithuania")));
list.add(new DLItem("Luxembourg", createImage(shell, "luxembourg")));
list.add(new DLItem("Malta", createImage(shell, "malta")));
list.add(new DLItem("Netherlands", createImage(shell, "netherlands")));
list.add(new DLItem("Poland", createImage(shell, "poland"), shell.getDisplay().getSystemColor(SWT.COLOR_WHITE), shell.getDisplay().getSystemColor(SWT.COLOR_RED)));
list.add(new DLItem("Portugal", createImage(shell, "portugal")));
list.add(new DLItem("Romania", createImage(shell, "romania")));
list.add(new DLItem("Slovakia", createImage(shell, "slovakia")));
list.add(new DLItem("Slovenia", createImage(shell, "slovenia")));
list.add(new DLItem("Spain", createImage(shell, "spain")));
list.add(new DLItem("Sweden", createImage(shell, "sweden")));
list.add(new DLItem("United Kingdom", createImage(shell, "unitedkingdom")));
shell.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(final DisposeEvent e) {
font.dispose();
}
});
return list;
}