当前位置: 首页>>代码示例>>Java>>正文


Java ResourceManager.createFont方法代码示例

本文整理汇总了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 ) );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:25,代码来源:TitleRenderer.java

示例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);
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:27,代码来源:TextDrawingStrategy.java

示例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);
  }
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:17,代码来源:TextDrawingStrategy.java

示例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));
}
 
开发者ID:vogellacompany,项目名称:codeexamples-eclipse,代码行数:44,代码来源:SamplePart.java


注:本文中的org.eclipse.jface.resource.ResourceManager.createFont方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。