當前位置: 首頁>>代碼示例>>Java>>正文


Java FontData.setName方法代碼示例

本文整理匯總了Java中org.eclipse.swt.graphics.FontData.setName方法的典型用法代碼示例。如果您正苦於以下問題:Java FontData.setName方法的具體用法?Java FontData.setName怎麽用?Java FontData.setName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.swt.graphics.FontData的用法示例。


在下文中一共展示了FontData.setName方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setFontFromSettings

import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
private void setFontFromSettings() {
		if (false)
			return;
		
		FontData fd = new FontData();
		
		logger.debug("settings font name: '"+settings.getTranscriptionFontName()
				+"', size:  "+settings.getTranscriptionFontSize()+", style: "+settings.getTranscriptionFontStyle());
		
//		fd.setName(Fonts.getSystemFontName(false, false, false));
//		if (settings.getTranscriptionFontName()==null || settings.getTranscriptionFontName().isEmpty()) {
//			fd.setName(Fonts.getSystemFontName(false, false, false));	
//		} else
//			fd.setName(settings.getTranscriptionFontName());
		
		fd.setName(settings.getTranscriptionFontName());
		fd.setHeight(settings.getTranscriptionFontSize());
		fd.setStyle(settings.getTranscriptionFontStyle());
		
		logger.debug("font name = "+fd.getName());
		
		Font globalTextFont = Fonts.createFont(fd);
		text.setFont(globalTextFont);
	}
 
開發者ID:Transkribus,項目名稱:TranskribusSwtGui,代碼行數:25,代碼來源:ATranscriptionWidget.java

示例2: XYZDisplayComp

import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
public XYZDisplayComp(Composite parent, int style){
	super(parent, style);
	
	this.setLayout(new RowLayout(SWT.HORIZONTAL));
	this.setBackground(AvoColors.COLOR_QSET_BG);
	
	FontData fd = new FontData();
	fd.setHeight(10);
	fd.setStyle(SWT.BOLD);
	fd.setName("Verdana");
	Font f = new Font(this.getDisplay(), fd);		
	
	Label llx = new Label(this, SWT.NO_BACKGROUND);
	llx.setFont(f);
	llx.setText("X:");
	llx.setBackground(AvoColors.COLOR_QSET_BG);
	lX = new Label(this, SWT.NONE);	
	lX.setAlignment(SWT.RIGHT);
	lX.setFont(f);
	lX.setBackground(AvoColors.COLOR_QSET_BG);
	
	Label lly = new Label(this, SWT.NONE);
	lly.setFont(f);
	lly.setText(" Y:");
	lly.setBackground(AvoColors.COLOR_QSET_BG);
	lY = new Label(this, SWT.NONE);
	lY.setAlignment(SWT.RIGHT);
	lY.setFont(f);
	lY.setBackground(AvoColors.COLOR_QSET_BG);
	
	Label llz = new Label(this, SWT.NONE);
	llz.setFont(f);
	llz.setText(" Z:");
	llz.setBackground(AvoColors.COLOR_QSET_BG);
	lZ = new Label(this, SWT.NONE);
	lZ.setAlignment(SWT.RIGHT);
	lZ.setFont(f);
	lZ.setBackground(AvoColors.COLOR_QSET_BG);
	
	updateXYZ();
	
	AvoGlobal.glViewEventHandler.addGLViewListener(new GLViewListener(){
		@Override
		public void cursorMoved() {
			updateXYZ();
		}			
	});
}
 
開發者ID:avoCADo-3d,項目名稱:avoCADo,代碼行數:49,代碼來源:XYZDisplayComp.java

示例3: toSwtFontData

import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
/**
 * Create a <code>FontData</code> object which encapsulate
 * the essential data to create a swt font. The data is taken
 * from the provided awt Font.
 * <p>Generally speaking, given a font size, the returned swt font
 * will display differently on the screen than the awt one.
 * Because the SWT toolkit use native graphical resources whenever
 * it is possible, this fact is platform dependent. To address
 * this issue, it is possible to enforce the method to return
 * a font with the same size (or at least as close as possible)
 * as the awt one.
 * <p>When the object is no more used, the user must explicitly
 * call the dispose method on the returned font to free the
 * operating system resources (the garbage collector won't do it).
 *
 * @param device The swt device to draw on (display or gc device).
 * @param font The awt font from which to get the data.
 * @param ensureSameSize A boolean used to enforce the same size
 * (in pixels) between the awt font and the newly created swt font.
 * @return a <code>FontData</code> object.
 */
public static FontData toSwtFontData(Device device, java.awt.Font font,
        boolean ensureSameSize) {
    FontData fontData = new FontData();
    fontData.setName(font.getFamily());
    // SWT and AWT share the same style constants.
    fontData.setStyle(font.getStyle());
    // convert the font size (in pt for awt) to height in pixels for swt
    int height = (int) Math.round(font.getSize() * 72.0
            / device.getDPI().y);
    fontData.setHeight(height);
    // hack to ensure the newly created swt fonts will be rendered with the
    // same height as the awt one
    if (ensureSameSize) {
        GC tmpGC = new GC(device);
        Font tmpFont = new Font(device, fontData);
        tmpGC.setFont(tmpFont);
        if (tmpGC.textExtent(Az).x
                > DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) {
            while (tmpGC.textExtent(Az).x
                    > DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) {
                tmpFont.dispose();
                height--;
                fontData.setHeight(height);
                tmpFont = new Font(device, fontData);
                tmpGC.setFont(tmpFont);
            }
        }
        else if (tmpGC.textExtent(Az).x
                < DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) {
            while (tmpGC.textExtent(Az).x
                    < DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) {
                tmpFont.dispose();
                height++;
                fontData.setHeight(height);
                tmpFont = new Font(device, fontData);
                tmpGC.setFont(tmpFont);
            }
        }
        tmpFont.dispose();
        tmpGC.dispose();
    }
    return fontData;
}
 
開發者ID:mdzio,項目名稱:ccu-historian,代碼行數:65,代碼來源:SWTUtils.java

示例4: copyFontData

import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
protected void copyFontData(FontData src, FontData dst){
	dst.setName( src.getName() );
	dst.setStyle( src.getStyle() );
	dst.setHeight( src.getHeight() );
}
 
開發者ID:theokyr,項目名稱:TuxGuitar-1.3.1-fork,代碼行數:6,代碼來源:StylesOption.java


注:本文中的org.eclipse.swt.graphics.FontData.setName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。