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


Java FontDescriptor.createFrom方法代码示例

本文整理汇总了Java中org.eclipse.jface.resource.FontDescriptor.createFrom方法的典型用法代码示例。如果您正苦于以下问题:Java FontDescriptor.createFrom方法的具体用法?Java FontDescriptor.createFrom怎么用?Java FontDescriptor.createFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jface.resource.FontDescriptor的用法示例。


在下文中一共展示了FontDescriptor.createFrom方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getScaledFont

import org.eclipse.jface.resource.FontDescriptor; //导入方法依赖的package包/类
/**
 * Given a label figure object, this will calculate the correct Font needed
 * to display into screen coordinates, taking into account the current
 * mapmode. This will typically be used by direct edit cell editors that
 * need to display independent of the zoom or any coordinate mapping that is
 * taking place on the drawing surface.
 * 
 * @param label
 *            the label to use for the font calculation
 * @return the <code>Font</code> that is scaled to the screen coordinates.
 *         Note: the returned <code>Font</code> should not be disposed since
 *         it is cached by a common resource manager.
 */
protected Font getScaledFont(IFigure label) {
	Font scaledFont = label.getFont();
	FontData data = scaledFont.getFontData()[0];
	Dimension fontSize = new Dimension(0, MapModeUtil.getMapMode(label).DPtoLP(data.getHeight()));
	label.translateToAbsolute(fontSize);

	if (Math.abs(data.getHeight() - fontSize.height) < 2)
		fontSize.height = data.getHeight();

	try {
		FontDescriptor fontDescriptor = FontDescriptor.createFrom(data);
		cachedFontDescriptors.add(fontDescriptor);
		return getResourceManager().createFont(fontDescriptor);
	} catch (DeviceResourceException e) {
		Trace.catching(DiagramUIPlugin.getInstance(), DiagramUIDebugOptions.EXCEPTIONS_CATCHING, getClass(),
				"getScaledFont", e); //$NON-NLS-1$
		Log.error(DiagramUIPlugin.getInstance(), DiagramUIStatusCodes.IGNORED_EXCEPTION_WARNING, "getScaledFont", e); //$NON-NLS-1$
	}
	return JFaceResources.getDefaultFont();
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:34,代码来源:XtextDirectEditManager.java

示例2: changeFont

import org.eclipse.jface.resource.FontDescriptor; //导入方法依赖的package包/类
/**
 * Changes a control's font
 * @param control
 * @param style
 * @throws DeviceResourceException 
 */
public static void changeFont(Control control, int style) throws DeviceResourceException {
    FontDescriptor boldDescriptor = FontDescriptor.createFrom(control.getFont());
    final Font boldFont = boldDescriptor.createFont(control.getDisplay());
    control.setFont(boldFont);
    control.addDisposeListener(new DisposeListener() {
  
        public void widgetDisposed(DisposeEvent arg0) {
            if (boldFont != null && !boldFont.isDisposed()) {
                boldFont.dispose();
            }
        }
        
    });
}
 
开发者ID:WiednerF,项目名称:ARXPlugin,代码行数:21,代码来源:SWTUtil.java

示例3: getZoomLevelFont

import org.eclipse.jface.resource.FontDescriptor; //导入方法依赖的package包/类
/**
 * This method obtains the fonts that are being used by the figure at its
 * zoom level.
 * 
 * @param gep
 *            the associated <code>GraphicalEditPart</code> of the figure
 * @param actualFont
 *            font being used by the figure
 * @param display
 * @return <code>actualFont</code> if zoom level is 1.0 (or when there's an
 *         error), new Font otherwise.
 */
private Font getZoomLevelFont(Font actualFont, Display display) {
	Object zoom = getEditPart().getViewer().getProperty(ZoomManager.class.toString());

	if (zoom != null) {
		double zoomLevel = ((ZoomManager) zoom).getZoom();

		if (zoomLevel == 1.0f)
			return actualFont;

		FontData[] fd = new FontData[actualFont.getFontData().length];
		FontData tempFD = null;

		for (int i = 0; i < fd.length; i++) {
			tempFD = actualFont.getFontData()[i];

			fd[i] = new FontData(tempFD.getName(), (int) (zoomLevel * tempFD.getHeight()), tempFD.getStyle());
		}

		try {
			FontDescriptor fontDescriptor = FontDescriptor.createFrom(fd);
			cachedFontDescriptors.add(fontDescriptor);
			return getResourceManager().createFont(fontDescriptor);
		} catch (DeviceResourceException e) {
			Trace.catching(DiagramUIPlugin.getInstance(), DiagramUIDebugOptions.EXCEPTIONS_CATCHING, getClass(),
					"getZoomLevelFonts", e); //$NON-NLS-1$
			Log.error(DiagramUIPlugin.getInstance(), DiagramUIStatusCodes.IGNORED_EXCEPTION_WARNING,
					"getZoomLevelFonts", e); //$NON-NLS-1$

			return actualFont;
		}
	} else
		return actualFont;
}
 
开发者ID:Yakindu,项目名称:statecharts,代码行数:46,代码来源:XtextDirectEditManager.java

示例4: createFontDescriptor

import org.eclipse.jface.resource.FontDescriptor; //导入方法依赖的package包/类
private FontDescriptor createFontDescriptor(int style, float heightMultiplier) {
	Font baseFont = JFaceResources.getDialogFont();
	FontData[] fontData = baseFont.getFontData();
	FontData[] newFontData = new FontData[fontData.length];
	for (int i = 0; i < newFontData.length; i++) {
		newFontData[i] = new FontData(fontData[i].getName(), (int) (fontData[i].getHeight() * heightMultiplier), fontData[i].getStyle() | style);
	}
	return FontDescriptor.createFrom(newFontData);
}
 
开发者ID:eclipse,项目名称:thym,代码行数:10,代码来源:CordovaPluginWizardResources.java

示例5: applyStyles

import org.eclipse.jface.resource.FontDescriptor; //导入方法依赖的package包/类
@Override
public void applyStyles(TextStyle textStyle) {
	if(parentStyler != null) {
		parentStyler.applyStyles(textStyle);
	}
	
	Font font = textStyle.font;
	if(font == null) {
		font = JFaceResources.getDefaultFont(); 
	}
	FontDescriptor fontDescriptor = FontDescriptor.createFrom(font);
	fontDescriptor = getModifiedFontDescriptor(fontDescriptor);
	textStyle.font = fontDescriptor.createFont(Display.getCurrent());
}
 
开发者ID:GoClipse,项目名称:goclipse,代码行数:15,代码来源:StylerHelpers.java

示例6: bold

import org.eclipse.jface.resource.FontDescriptor; //导入方法依赖的package包/类
public static final Font bold(final Font font) {
	FontDescriptor fd = FontDescriptor.createFrom(font);
	return fd.setStyle(SWT.BOLD).createFont(Display.getDefault());
}
 
开发者ID:nextopcn,项目名称:xcalendar,代码行数:5,代码来源:Fonts.java

示例7: size

import org.eclipse.jface.resource.FontDescriptor; //导入方法依赖的package包/类
public static final Font size(Font font, int delta) {
	FontDescriptor fd = FontDescriptor.createFrom(font);
	int height = fd.getFontData()[0].getHeight() + delta;
	return fd.setHeight(height).createFont(Display.getDefault());
}
 
开发者ID:nextopcn,项目名称:xcalendar,代码行数:6,代码来源:Fonts.java

示例8: getFontDescriptor

import org.eclipse.jface.resource.FontDescriptor; //导入方法依赖的package包/类
private static FontDescriptor getFontDescriptor(final Control control) {
  return FontDescriptor.createFrom(control.getFont());
}
 
开发者ID:sealuzh,项目名称:Permo,代码行数:4,代码来源:Fonts.java

示例9: setupComposite

import org.eclipse.jface.resource.FontDescriptor; //导入方法依赖的package包/类
/**
 * Construct the GUI under the given parent.
 *
 * @param parent the parent Composite.
 * @return the top level widget.
 */
private Composite setupComposite(Composite parent) {
  // widgets
  Composite topLevel = new Composite(parent, SWT.NONE);

  Label labelId = new Label(topLevel, SWT.NONE);
  id = new Label(topLevel, SWT.NONE);
  Label labelName = new Label(topLevel, SWT.NONE);
  name = new Label(topLevel, SWT.NONE);
  Label labelDescription = new Label(topLevel, SWT.NONE);
  description = new Label(topLevel, SWT.NONE);
  Label labelQuarter = new Label(topLevel, SWT.NONE);
  quarter = new Label(topLevel, SWT.NONE);
  Label labelUpdatedBy = new Label(topLevel, SWT.NONE);
  updatedBy = new Label(topLevel, SWT.NONE);

  // content
  labelId.setText("ID");
  labelName.setText("Name");
  labelDescription.setText("Description");
  labelQuarter.setText("Quarter");
  labelUpdatedBy.setText("Updated by");

  // layout
  GridLayout layout = new GridLayout(2, false);
  layout.horizontalSpacing = 22;
  layout.verticalSpacing = 9;
  topLevel.setLayout(layout);
  id.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
  name.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
  description.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
  quarter.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
  updatedBy.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));

  Font font = name.getFont();
  FontDescriptor bold = FontDescriptor.createFrom(font);
  bold = bold.setStyle(SWT.BOLD);
  FontDescriptor big = bold.setHeight(18);
  Font boldFont = bold.createFont(font.getDevice());

  name.setFont(big.createFont(font.getDevice()));
  id.setFont(boldFont);
  description.setFont(boldFont);
  quarter.setFont(boldFont);
  updatedBy.setFont(boldFont);

  return topLevel;
}
 
开发者ID:google,项目名称:depan,代码行数:54,代码来源:MigrationTaskView.java

示例10: getFont

import org.eclipse.jface.resource.FontDescriptor; //导入方法依赖的package包/类
private Font getFont(Control control, int style) {
    FontDescriptor fontDescriptor = FontDescriptor.createFrom(control.getFont());
    Font styledFont = fontDescriptor.setStyle(style).createFont(Display.getCurrent());
    return styledFont;
}
 
开发者ID:kopl,项目名称:SPLevo,代码行数:6,代码来源:HighlightConnectedVPListener.java

示例11: createComposite

import org.eclipse.jface.resource.FontDescriptor; //导入方法依赖的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.FontDescriptor.createFrom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。