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


Java FontData.setHeight方法代碼示例

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


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

示例1: createFont

import org.eclipse.swt.graphics.FontData; //導入方法依賴的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: paintElement

import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
@Override
void paintElement(PaintEvent e) {
	GC g = e.gc;
	g.setBackground(this.getBackground());
	int width  = this.getBounds().width;
	int height = this.getBounds().height;
	
	// clear entire canvas where button will be painted
	g.fillRectangle(0, 0, width, height);
	
	// draw text
	g.setForeground(this.meColorForeground);
	FontData fd = new FontData();
	fd.setHeight(8);
	if(textIsBold){
		fd.setStyle(SWT.BOLD);
	}else{
		fd.setStyle(SWT.NORMAL);
	}
	g.setFont(new Font(this.getDisplay(), fd));
	Point textPt = g.textExtent(this.meLabel);			
	g.drawText(this.meLabel, (width-textPt.x)/2, (height-textPt.y)/2);
}
 
開發者ID:avoCADo-3d,項目名稱:avoCADo,代碼行數:24,代碼來源:MELabel.java

示例3: updateScaledFont

import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
/**
 * update scaledFonts
 * @param zoom
 * 				at zoom 
 */
private void updateScaledFont(double zoom) {
	if (cachedZoom == zoom)
		return;
	
	Text text = (Text)getCellEditor().getControl();
	Font font = getEditPart().getFigure().getFont();
	
	disposeScaledFont();
	cachedZoom = zoom;
	if (zoom == 1.0)
		text.setFont(font);
	else {
		FontData fd = font.getFontData()[0];
		fd.setHeight((int)(fd.getHeight() * zoom));
		text.setFont(scaledFont = new Font(null, fd));
	}
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:23,代碼來源:CommentBoxLabelEditManager.java

示例4: configureMacOSX

import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
private void configureMacOSX() {
    final FontData fontData = font.getFontData()[0];
    fontData.setHeight(11);
    font.dispose();
    font = new Font(getDisplay(), fontData);

    final FontData fontBoldData = fontBold.getFontData()[0];
    fontBoldData.setHeight(11);
    fontBold.dispose();
    fontBold = new Font(getDisplay(), fontBoldData);

    setBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE));

    spacing = new Point(0, 2);

    weekdayStringLength = 1;
    dayAlignment = SWT.RIGHT;
    drawOtherDays = false;
}
 
開發者ID:Microsoft,項目名稱:team-explorer-everywhere,代碼行數:20,代碼來源:Datepicker.java

示例5: 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

示例6: createFontWithHeight

import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
public static Font createFontWithHeight(Font f, int height) {
	if (f.getFontData().length > 0) {
		FontData fd = f.getFontData()[0];
		fd.setHeight(height);
		return createFont(fd);
	}
	return null;
}
 
開發者ID:Transkribus,項目名稱:TranskribusSwtGui,代碼行數:9,代碼來源:Fonts.java

示例7: paintElement

import org.eclipse.swt.graphics.FontData; //導入方法依賴的package包/類
void paintElement(PaintEvent e) {
	GC g = e.gc;
	
	g.setBackground(this.getBackground());
	int width  = this.getBounds().width;
	int height = this.getBounds().height;
	
	// clear entire canvas where button will be painted
	g.fillRectangle(0, 0, width, height);

	// draw button background
	int selShift = 0;
	if(mouseIsOver && !isSelected){
		g.setBackground(this.meColorMouseOver);
	}else{
		g.setBackground(this.meColorUnselected);
	}
	if(isSelected){
		selShift = MEB_SIDE_SPACE-1;
		g.setBackground(this.meColorSelected);
	}
	g.fillRoundRectangle(-MEB_ARC_RADIUS,0,width-MEB_SIDE_SPACE+selShift+MEB_ARC_RADIUS, height-1, MEB_ARC_RADIUS, MEB_ARC_RADIUS);
	
	// draw button outline
	g.setLineWidth(1);
	if(mouseIsOver){ // || isFocused, but not currently used
		g.setForeground(this.meColorFocused);
	}else{
		g.setForeground(this.meColorOutline2);
	}
	g.drawRoundRectangle(-(MEB_ARC_RADIUS-1),1,width-MEB_SIDE_SPACE+selShift+(MEB_ARC_RADIUS-1), height-3, MEB_ARC_RADIUS-1, MEB_ARC_RADIUS-1);
	g.drawRoundRectangle(-(MEB_ARC_RADIUS-1),1,width-MEB_SIDE_SPACE+selShift+(MEB_ARC_RADIUS-1)-1, height-3, MEB_ARC_RADIUS-1, MEB_ARC_RADIUS-1);
	g.drawRoundRectangle(-(MEB_ARC_RADIUS-1),1,width-MEB_SIDE_SPACE+selShift+(MEB_ARC_RADIUS-1)-2, height-3, MEB_ARC_RADIUS-1, MEB_ARC_RADIUS-1);
	g.setForeground(this.meColorOutline);
	g.setLineWidth(1);
	g.drawRoundRectangle(-MEB_ARC_RADIUS,0,width-MEB_SIDE_SPACE+selShift+MEB_ARC_RADIUS, height-1, MEB_ARC_RADIUS, MEB_ARC_RADIUS);
	
	//
	// handle position of Text/Icon within MEButton
	//
	int usableHeight = height-4;
	// draw button text
	g.setForeground(this.meColorForeground);
	FontData fd = new FontData();
	fd.setHeight(8);
	g.setFont(new Font(this.getDisplay(), fd));
	Point textPt = g.textExtent(this.meLabel);
	switch(this.meDispOptions){
		case(MenuetElement.ME_ICON_ONLY): 	{
			g.drawImage(this.meIcon, (width-MEB_SIDE_SPACE-this.meIcon.getBounds().width-1)/2, (height-this.meIcon.getBounds().height)/2);
			break;
		}
		case(MenuetElement.ME_TEXT_ONLY): 	{
			g.drawText(this.meLabel, (width-textPt.x-MEB_SIDE_SPACE-1)/2, (height-textPt.y)/2);
			break;
		}
		case(MenuetElement.ME_TRY_ICON): 	{
			if(usableHeight >= (textPt.y+this.meIcon.getBounds().height+1)){
				g.drawImage(this.meIcon, (width-MEB_SIDE_SPACE-this.meIcon.getBounds().width-1)/2, (height-(this.meIcon.getBounds().height+1+textPt.y))/2);
				g.drawText(this.meLabel, (width-textPt.x-MEB_SIDE_SPACE-1)/2, (height-(this.meIcon.getBounds().height+1+textPt.y))/2 + this.meIcon.getBounds().height+1);
			}else{
				g.drawText(this.meLabel, (width-textPt.x-MEB_SIDE_SPACE-1)/2, (height-textPt.y)/2);
			}
			break;
		}
		case(MenuetElement.ME_TRY_TEXT):	{
			if(usableHeight >= (textPt.y+this.meIcon.getBounds().height+1)){
				g.drawImage(this.meIcon, (width-MEB_SIDE_SPACE-this.meIcon.getBounds().width-1)/2, (height-(this.meIcon.getBounds().height+1+textPt.y))/2);
				g.drawText(this.meLabel, (width-textPt.x-MEB_SIDE_SPACE-1)/2, (height-(this.meIcon.getBounds().height+1+textPt.y))/2 + this.meIcon.getBounds().height+1);
			}else{
				g.drawImage(this.meIcon, (width-MEB_SIDE_SPACE-this.meIcon.getBounds().width-1)/2, (height-this.meIcon.getBounds().height)/2);
			}
			break;
		}
		default:{
			g.drawText(this.meLabel, (width-textPt.x-MEB_SIDE_SPACE-1)/2, (height-textPt.y)/2);
			break;
		}		
	}		
}
 
開發者ID:avoCADo-3d,項目名稱:avoCADo,代碼行數:81,代碼來源:MEButton.java

示例8: 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

示例9: 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

示例10: 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.setHeight方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。