本文整理汇总了Java中org.eclipse.jface.resource.ResourceManager.createFont方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceManager.createFont方法的具体用法?Java ResourceManager.createFont怎么用?Java ResourceManager.createFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.resource.ResourceManager
的用法示例。
在下文中一共展示了ResourceManager.createFont方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createFont
import org.eclipse.jface.resource.ResourceManager; //导入方法依赖的package包/类
private Font createFont ( final ResourceManager resourceManager )
{
final Font defaultFont = resourceManager.getDevice ().getSystemFont ();
if ( defaultFont == null )
{
return null;
}
final FontData fd[] = FontDescriptor.copy ( defaultFont.getFontData () );
if ( fd == null )
{
return null;
}
for ( final FontData f : fd )
{
if ( this.fontSize > 0 )
{
f.setHeight ( this.fontSize );
}
}
return resourceManager.createFont ( FontDescriptor.createFrom ( fd ) );
}
示例2: draw
import org.eclipse.jface.resource.ResourceManager; //导入方法依赖的package包/类
@Override
public void draw(TextAttribute textAttr, Graphics graphics, ResourceManager resourceManager) {
Color fgColor = graphics.getForegroundColor();
java.awt.Color color = textAttr.textColor.asColor();
if (color != null) {
Color rgb = resourceManager.createColor(new RGB(color.getRed(), color.getGreen(), color.getBlue()));
graphics.setForegroundColor(rgb);
}
try {
String text = textAttr.text.getExpression();
int fontSize = ((IntToken) textAttr.textSize.getToken()).intValue();
String fontFamily = textAttr.fontFamily.stringValue();
boolean italic = ((BooleanToken) textAttr.italic.getToken()).booleanValue();
boolean bold = ((BooleanToken) textAttr.bold.getToken()).booleanValue();
int style = SWT.NORMAL | (italic ? SWT.ITALIC : SWT.NORMAL) | (bold ? SWT.BOLD : SWT.NORMAL);
Font f = resourceManager.createFont(FontDescriptor.createFrom(fontFamily, fontSize, style));
graphics.setFont(f);
Point tlp = getTopLeftLocation(textAttr);
graphics.drawText(text, tlp);
} catch (IllegalActionException e) {
LOGGER.error("Error reading properties for " + textAttr.getFullName(), e);
}
graphics.setForegroundColor(fgColor);
}
示例3: getDimension
import org.eclipse.jface.resource.ResourceManager; //导入方法依赖的package包/类
@Override
protected Dimension getDimension(TextAttribute textAttr, ResourceManager resourceManager) {
try {
String text = textAttr.text.getExpression();
int fontSize = ((IntToken) textAttr.textSize.getToken()).intValue();
String fontFamily = textAttr.fontFamily.stringValue();
boolean italic = ((BooleanToken) textAttr.italic.getToken()).booleanValue();
boolean bold = ((BooleanToken) textAttr.bold.getToken()).booleanValue();
int style = SWT.NORMAL | (italic ? SWT.ITALIC : SWT.NORMAL) | (bold ? SWT.BOLD : SWT.NORMAL);
Font f = resourceManager.createFont(FontDescriptor.createFrom(fontFamily, fontSize, style));
return FigureUtilities.getTextExtents(text, f);
} catch (IllegalActionException e) {
LOGGER.error("Error reading dimensions for " + textAttr.getFullName(), e);
return new Dimension(0, 0);
}
}
示例4: createComposite
import org.eclipse.jface.resource.ResourceManager; //导入方法依赖的package包/类
@PostConstruct
public void createComposite(Composite parent) {
addFonts(display);
ResourceManager resManager =
new LocalResourceManager(JFaceResources.getResources(), parent);
FontDescriptor fontDescriptor = FontDescriptor.createFrom("Roboto-ThinItalic", 11, SWT.NORMAL);
Font font = resManager.createFont(fontDescriptor);
parent.setLayout(new GridLayout(1, false));
txtInput = new Text(parent, SWT.BORDER);
txtInput.setFont(font);
txtInput.setMessage("Enter text to mark part as dirty");
txtInput.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
dirty.setDirty(true);
}
});
FontData fd = txtInput.getFont().getFontData()[0];
txtInput.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Text txtInput2 = new Text(parent, SWT.BORDER);
txtInput2.setMessage("Enter text to mark part as dirty");
txtInput2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Button button = new Button(parent, SWT.PUSH);
button.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
button.setFont(font);
button.setText("Press me");
Button button2 = new Button(parent, SWT.PUSH);
button2.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
button2.setText("Press me");
tableViewer = new TableViewer(parent);
tableViewer.setContentProvider(ArrayContentProvider.getInstance());;
tableViewer.setInput(createInitialDataModel());
tableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
}