Java Code Examples for org.eclipse.swt.graphics.FontData
The following examples show how to use
org.eclipse.swt.graphics.FontData.
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: xds-ide Author: excelsior-oss File: SWTFactory.java License: Eclipse Public License 1.0 | 6 votes |
/** * Creates a new label widget * @param parent the parent composite to add this label widget to * @param text the text for the label * @param hspan the horizontal span to take up in the parent composite * @param fontstyle - SWT style * @param gdStyle - GridData style * @return the new label */ public static Label createLabel(Composite parent, String text, int hspan, int fontstyle, int gdStyle) { Label l = new Label(parent, SWT.NONE); if (fontstyle != SWT.NONE){ FontData fd = parent.getFont().getFontData()[0]; l.setFont(new Font(Display.getDefault(), fd.getName(), fd.getHeight(), fontstyle)); } else { l.setFont(parent.getFont()); } l.setText(text); GridData gd = new GridData(gdStyle); gd.horizontalSpan = hspan; gd.grabExcessHorizontalSpace = false; l.setLayoutData(gd); return l; }
Example #2
Source Project: neoscada Author: eclipse File: TitleRenderer.java License: Eclipse Public License 1.0 | 6 votes |
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 ) ); }
Example #3
Source Project: APICloud-Studio Author: apicloudcom File: ThemeUIComposite.java License: GNU General Public License v3.0 | 6 votes |
private void setDefaultFont(Font newFont) { String[] fontIds = { "org.eclipse.jface.textfont", "org.eclipse.ui.workbench.texteditor.blockSelectionModeFont" }; FontData[] newData = newFont.getFontData(); for (String fontId : fontIds) { setFont(fontId, newData); } newData = newFont.getFontData(); FontData[] smaller = new FontData[newData.length]; int j = 0; for (FontData fd : newData) { int height = fd.getHeight(); if (height >= 12) { fd.setHeight(height - 2); } else if (height >= 10) { fd.setHeight(height - 1); } smaller[(j++)] = fd; } setFont("com.aptana.explorer.font", smaller); }
Example #4
Source Project: statecharts Author: Yakindu File: SyntaxColoringLabel.java License: Eclipse Public License 1.0 | 6 votes |
protected int getTextExtend(Font font, String string) { if (string.isEmpty()) return 0; if (zoom != 1.0) { FontData data = font.getFontData()[0]; FontDescriptor newFontDescriptor = FontDescriptor.createFrom(font) .setHeight((int) (data.getHeight() * zoom)); font = newFontDescriptor.createFont(Display.getDefault()); } if (gc.getFont() != font) gc.setFont(font); int offset = gc.textExtent(string).x; if (zoom != 1.0) { font.dispose(); } return (int) Math.ceil((offset / zoom)); }
Example #5
Source Project: translationstudio8 Author: heartsome File: XLIFFEditorImplWithNatTable.java License: GNU General Public License v2.0 | 6 votes |
/** * 配置标签列的显示效果 * @param configRegistry * 配置注册表 */ private void addFlagLableToColumn(IConfigRegistry configRegistry) { // Edit by Leakey 实现状态图片的动态显示 StatusPainter painter = new StatusPainter(bodyDataProvider); // CellPainterDecorator flagPainter = new CellPainterDecorator(new BackgroundPainter(), CellEdgeEnum.RIGHT, // painter); configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, painter, DisplayMode.NORMAL, FLAG_CELL_LABEL); // Set the color of the cell. This is picked up by the button painter to style the button Style style = new Style(); FontData fd = GUIHelper.DEFAULT_FONT.getFontData()[0]; fd.setStyle(SWT.BOLD); style.setAttributeValue(CellStyleAttributes.FONT, GUIHelper.getFont(fd)); configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, style, DisplayMode.NORMAL, FLAG_CELL_LABEL); configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, style, DisplayMode.SELECT, FLAG_CELL_LABEL); }
Example #6
Source Project: Pydev Author: fabioz File: CopiedWorkbenchLabelProvider.java License: Eclipse Public License 1.0 | 6 votes |
@Override public Font getFont(Object element) { IWorkbenchAdapter2 adapter = getAdapter2(element); if (adapter == null) { return null; } FontData descriptor = adapter.getFont(element); if (descriptor == null) { return null; } try { return resourceManager.createFont(FontDescriptor.createFrom(descriptor)); } catch (Exception e) { Log.log(e); return null; } }
Example #7
Source Project: nebula Author: eclipse File: TableComboPropertyHandler.java License: Eclipse Public License 2.0 | 6 votes |
private boolean applyCSSPropertyStyle(final Object element, final Control widget, final CSSValue value) throws Exception { if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { final FontData fd = CSSEngineHelper.getFontData(widget); boolean modified = false; if ("italic".equals(value.getCssText()) || "oblique".equals(value.getCssText())) { modified = (fd.getStyle() & SWT.ITALIC) != SWT.ITALIC; if (modified) { fd.setStyle(fd.getStyle() | SWT.ITALIC); } } else { modified = (fd.getStyle() & SWT.ITALIC) == SWT.ITALIC; if (modified) { fd.setStyle(fd.getStyle() | ~SWT.ITALIC); } } if (modified) { applyFont(widget, fd); } } return true; }
Example #8
Source Project: elexis-3-core Author: elexis File: PreferenceInitializer.java License: Eclipse Public License 1.0 | 6 votes |
/** * Diese Funktion wird nach dem Erstellen des Display aufgerufen und dient zum Initialiseren * früh benötigter Einstellungen, die bereits ein Display benötigen * */ public void initializeDisplayPreferences(Display display){ UiDesk.getColorRegistry().put(UiDesk.COL_RED, new RGB(255, 0, 0)); UiDesk.getColorRegistry().put(UiDesk.COL_GREEN, new RGB(0, 255, 0)); UiDesk.getColorRegistry().put(UiDesk.COL_DARKGREEN, new RGB(0, 88, 0)); UiDesk.getColorRegistry().put(UiDesk.COL_BLUE, new RGB(0, 0, 255)); UiDesk.getColorRegistry().put(UiDesk.COL_SKYBLUE, new RGB(135, 206, 250)); UiDesk.getColorRegistry().put(UiDesk.COL_LIGHTBLUE, new RGB(0, 191, 255)); UiDesk.getColorRegistry().put(UiDesk.COL_BLACK, new RGB(0, 0, 0)); UiDesk.getColorRegistry().put(UiDesk.COL_GREY, new RGB(0x60, 0x60, 0x60)); UiDesk.getColorRegistry().put(UiDesk.COL_WHITE, new RGB(255, 255, 255)); UiDesk.getColorRegistry().put(UiDesk.COL_DARKGREY, new RGB(50, 50, 50)); UiDesk.getColorRegistry().put(UiDesk.COL_LIGHTGREY, new RGB(180, 180, 180)); UiDesk.getColorRegistry().put(UiDesk.COL_GREY60, new RGB(153, 153, 153)); UiDesk.getColorRegistry().put(UiDesk.COL_GREY20, new RGB(51, 51, 51)); FontData[] small = new FontData[] { new FontData("Helvetica", 7, SWT.NORMAL)}; //$NON-NLS-1$ CoreHub.userCfg .set( Preferences.USR_SMALLFONT + "_default", PreferenceConverter.getStoredRepresentation(small)); //$NON-NLS-1$ }
Example #9
Source Project: translationstudio8 Author: heartsome File: FontPicker.java License: GNU General Public License v2.0 | 6 votes |
public FontPicker(final Composite parent, Font originalFont) { super(parent, SWT.NONE); if (originalFont == null) throw new IllegalArgumentException("null"); update(originalFont.getFontData()[0]); addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { FontDialog dialog = new FontDialog(new Shell(Display.getDefault(), SWT.SHELL_TRIM)); dialog.setFontList(fontData); FontData selected = dialog.open(); if (selected != null) { update(selected); pack(true); } } }); }
Example #10
Source Project: birt Author: eclipse File: JSEditor.java License: Eclipse Public License 1.0 | 6 votes |
/** * Sets the description with the specified text. * * @param text * the text to set. */ private void setDescriptionText( String text ) { Font font = descriptionText.getFont( ); FontData[] fontData = font.getFontData( ); String description; if ( text != null && text.length( ) > 0 ) { for ( int i = 0; i < fontData.length; i++ ) { fontData[i].setStyle( fontData[i].getStyle( ) & ~SWT.ITALIC ); } description = text; } else { for ( int i = 0; i < fontData.length; i++ ) { fontData[i].setStyle( fontData[i].getStyle( ) | SWT.ITALIC ); } description = Messages.getString( "JSEditor.Text.NoDescription" ); //$NON-NLS-1$; } descriptionText.setFont( new Font( font.getDevice( ), fontData ) ); descriptionText.setText( description ); }
Example #11
Source Project: bonita-studio Author: bonitasoft File: StartEventLabelEditPart.java License: GNU General Public License v2.0 | 5 votes |
/** * @generated */ protected void refreshFont() { FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); if (style != null) { FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } }
Example #12
Source Project: scava Author: crossminer File: OpinionatedTaskNameEditPart.java License: Eclipse Public License 2.0 | 5 votes |
/** * @generated */ protected void refreshFont() { FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); if (style != null) { FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } }
Example #13
Source Project: bonita-studio Author: bonitasoft File: ProcessViewProvider.java License: GNU General Public License v2.0 | 5 votes |
/** * @generated */ public Node createANDGateway_2009(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType(ProcessVisualIDRegistry.getType(ANDGatewayEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); stampShortcut(containerView, node); // initializeFromPreferences final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); org.eclipse.swt.graphics.RGB lineRGB = PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_LINE_COLOR); ViewUtil.setStructuralFeatureValue(node, NotationPackage.eINSTANCE.getLineStyle_LineColor(), FigureUtilities.RGBToInteger(lineRGB)); FontStyle nodeFontStyle = (FontStyle) node.getStyle(NotationPackage.Literals.FONT_STYLE); if (nodeFontStyle != null) { FontData fontData = PreferenceConverter.getFontData(prefStore, IPreferenceConstants.PREF_DEFAULT_FONT); nodeFontStyle.setFontName(fontData.getName()); nodeFontStyle.setFontHeight(fontData.getHeight()); nodeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0); nodeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0); org.eclipse.swt.graphics.RGB fontRGB = PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR); nodeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue()); } org.eclipse.swt.graphics.RGB fillRGB = PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FILL_COLOR); ViewUtil.setStructuralFeatureValue(node, NotationPackage.eINSTANCE.getFillStyle_FillColor(), FigureUtilities.RGBToInteger(fillRGB)); Node label5019 = createLabel(node, ProcessVisualIDRegistry.getType(ANDGatewayLabelEditPart.VISUAL_ID)); label5019.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); Location location5019 = (Location) label5019.getLayoutConstraint(); location5019.setX(0); location5019.setY(5); return node; }
Example #14
Source Project: pentaho-kettle Author: pentaho File: BrowserEnvironmentWarningDialog.java License: Apache License 2.0 | 5 votes |
private void setHelpLink( Display display, String helpLink, int maxTextWidth, EnvironmentCase environment ) { link = new Link( shell, SWT.SINGLE | SWT.WRAP ); link.setText( helpLink ); if ( environment == EnvironmentCase.MAC_OS_X || environment == EnvironmentCase.MAC_OS_X_THIN ) { FontData[] fD = link.getFont().getFontData(); fD[0].setHeight( 13 ); link.setFont( new Font( display, fD[0] ) ); } FormData fdlink = new FormData(); fdlink.left = new FormAttachment( warningIcon, margin ); // Link should be below description right of icon fdlink.top = new FormAttachment( description, margin ); fdlink.width = maxTextWidth; link.setLayoutData( fdlink ); props.setLook( link ); link.addListener( SWT.Selection, new Listener() { public void handleEvent( Event event ) { if ( Desktop.isDesktopSupported() ) { try { Desktop.getDesktop().browse( new URI( Const.getDocUrl( URI_PATH ) ) ); } catch ( Exception e ) { log.logError( "Error opening external browser", e ); } } } } ); }
Example #15
Source Project: bonita-studio Author: bonitasoft File: IntermediateCatchMessageEventLabel2EditPart.java License: GNU General Public License v2.0 | 5 votes |
/** * @generated */ protected void refreshFont() { FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); if (style != null) { FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } }
Example #16
Source Project: tracecompass Author: tracecompass File: FontEventEditorTest.java License: Eclipse Public License 2.0 | 5 votes |
private static FontData getFont(final SWTBotStyledText rawText) { return UIThreadRunnable.syncExec(new Result<FontData>() { @Override public FontData run() { return rawText.widget.getFont().getFontData()[0]; } }); }
Example #17
Source Project: erflute Author: dbflute-session File: FontNameContributionItem.java License: Apache License 2.0 | 5 votes |
@Override protected void setData(Combo combo) { final FontData[] fontDatas = Display.getCurrent().getFontList(null, true); final Set<String> nameSet = new LinkedHashSet<>(); for (int i = 0; i < fontDatas.length; i++) { if (!fontDatas[i].getName().startsWith("@")) { nameSet.add(fontDatas[i].getName()); } } for (final String name : nameSet) { combo.add(name); } }
Example #18
Source Project: bonita-studio Author: bonitasoft File: ProcessViewProvider.java License: GNU General Public License v2.0 | 5 votes |
/** * @generated */ public Node createBoundaryMessageEvent_3036(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType(ProcessVisualIDRegistry.getType(BoundaryMessageEvent2EditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); // initializeFromPreferences final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); org.eclipse.swt.graphics.RGB lineRGB = PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_LINE_COLOR); ViewUtil.setStructuralFeatureValue(node, NotationPackage.eINSTANCE.getLineStyle_LineColor(), FigureUtilities.RGBToInteger(lineRGB)); FontStyle nodeFontStyle = (FontStyle) node.getStyle(NotationPackage.Literals.FONT_STYLE); if (nodeFontStyle != null) { FontData fontData = PreferenceConverter.getFontData(prefStore, IPreferenceConstants.PREF_DEFAULT_FONT); nodeFontStyle.setFontName(fontData.getName()); nodeFontStyle.setFontHeight(fontData.getHeight()); nodeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0); nodeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0); org.eclipse.swt.graphics.RGB fontRGB = PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR); nodeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue()); } org.eclipse.swt.graphics.RGB fillRGB = PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FILL_COLOR); ViewUtil.setStructuralFeatureValue(node, NotationPackage.eINSTANCE.getFillStyle_FillColor(), FigureUtilities.RGBToInteger(fillRGB)); Node label5057 = createLabel(node, ProcessVisualIDRegistry.getType(BoundaryMessageEventLabel2EditPart.VISUAL_ID)); label5057.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); Location location5057 = (Location) label5057.getLayoutConstraint(); location5057.setX(0); location5057.setY(5); return node; }
Example #19
Source Project: codewind-eclipse Author: eclipse File: CodewindNavigatorLabelProvider.java License: Eclipse Public License 2.0 | 5 votes |
@Override public void applyStyles(final TextStyle textStyle) { FontDescriptor boldDescriptor = FontDescriptor.createFrom(new FontData()).setStyle(SWT.BOLD); Font boldFont = boldDescriptor.createFont(Display.getCurrent()); textStyle.font = boldFont; }
Example #20
Source Project: bonita-studio Author: bonitasoft File: StartErrorEventLabel2EditPart.java License: GNU General Public License v2.0 | 5 votes |
/** * @generated */ protected void refreshFont() { FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); if (style != null) { FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } }
Example #21
Source Project: ECG-Viewer Author: CBLRIT File: SWTUtils.java License: GNU General Public License v2.0 | 5 votes |
/** * Create an awt font by converting as much information * as possible from the provided swt <code>FontData</code>. * <p>Generally speaking, given a font size, an swt font will * display differently on the screen than the corresponding awt * one. Because the SWT toolkit use native graphical ressources whenever * it is possible, this fact is platform dependent. To address * this issue, it is possible to enforce the method to return * an awt font with the same height as the swt one. * * @param device The swt device being drawn on (display or gc device). * @param fontData The swt font to convert. * @param ensureSameSize A boolean used to enforce the same size * (in pixels) between the swt font and the newly created awt font. * @return An awt font converted from the provided swt font. */ public static java.awt.Font toAwtFont(Device device, FontData fontData, boolean ensureSameSize) { int height = (int) Math.round(fontData.getHeight() * device.getDPI().y / 72.0); // hack to ensure the newly created awt fonts will be rendered with the // same height as the swt one if (ensureSameSize) { GC tmpGC = new GC(device); Font tmpFont = new Font(device, fontData); tmpGC.setFont(tmpFont); JPanel DUMMY_PANEL = new JPanel(); java.awt.Font tmpAwtFont = new java.awt.Font(fontData.getName(), fontData.getStyle(), height); if (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az) > tmpGC.textExtent(Az).x) { while (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az) > tmpGC.textExtent(Az).x) { height--; tmpAwtFont = new java.awt.Font(fontData.getName(), fontData.getStyle(), height); } } else if (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az) < tmpGC.textExtent(Az).x) { while (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az) < tmpGC.textExtent(Az).x) { height++; tmpAwtFont = new java.awt.Font(fontData.getName(), fontData.getStyle(), height); } } tmpFont.dispose(); tmpGC.dispose(); } return new java.awt.Font(fontData.getName(), fontData.getStyle(), height); }
Example #22
Source Project: APICloud-Studio Author: apicloudcom File: SWTUtils.java License: GNU General Public License v3.0 | 5 votes |
/** * Gets the default small font from the JFace font registry. * * @return default small font */ public static Font getDefaultSmallFont() { Font small = JFaceResources.getFontRegistry().get(SMALL_FONT); if (small != null) { return small; } Font f = JFaceResources.getDefaultFont(); FontData[] smaller = resizeFont(f, -2); JFaceResources.getFontRegistry().put(SMALL_FONT, smaller); return JFaceResources.getFontRegistry().get(SMALL_FONT); }
Example #23
Source Project: elexis-3-core Author: elexis File: UiDesk.java License: Eclipse Public License 1.0 | 5 votes |
public static Font getFont(String name, int height, int style){ String key = name + ":" + Integer.toString(height) + ":" + Integer.toString(style); //$NON-NLS-1$ //$NON-NLS-2$ FontRegistry fr = JFaceResources.getFontRegistry(); if (!fr.hasValueFor(key)) { FontData[] fd = new FontData[] { new FontData(name, height, style) }; fr.put(key, fd); } return fr.get(key); }
Example #24
Source Project: tmxeditor8 Author: heartsome File: ExcelExporter.java License: GNU General Public License v2.0 | 5 votes |
private String getFontInCSSFormat(Font font) { FontData fontData = font.getFontData()[0]; String fontName = fontData.getName(); int fontStyle = fontData.getStyle(); String HTML_STYLES[] = new String[] { "NORMAL", "BOLD", "ITALIC" }; return String.format("font: %s; font-family: %s", fontStyle <= 2 ? HTML_STYLES[fontStyle] : HTML_STYLES[0], fontName); }
Example #25
Source Project: bonita-studio Author: bonitasoft File: ProcessViewProvider.java License: GNU General Public License v2.0 | 5 votes |
/** * @generated */ public Node createTask_2004(EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType(ProcessVisualIDRegistry.getType(TaskEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); stampShortcut(containerView, node); // initializeFromPreferences final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); org.eclipse.swt.graphics.RGB lineRGB = PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_LINE_COLOR); ViewUtil.setStructuralFeatureValue(node, NotationPackage.eINSTANCE.getLineStyle_LineColor(), FigureUtilities.RGBToInteger(lineRGB)); FontStyle nodeFontStyle = (FontStyle) node.getStyle(NotationPackage.Literals.FONT_STYLE); if (nodeFontStyle != null) { FontData fontData = PreferenceConverter.getFontData(prefStore, IPreferenceConstants.PREF_DEFAULT_FONT); nodeFontStyle.setFontName(fontData.getName()); nodeFontStyle.setFontHeight(fontData.getHeight()); nodeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0); nodeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0); org.eclipse.swt.graphics.RGB fontRGB = PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR); nodeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue()); } org.eclipse.swt.graphics.RGB fillRGB = PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FILL_COLOR); ViewUtil.setStructuralFeatureValue(node, NotationPackage.eINSTANCE.getFillStyle_FillColor(), FigureUtilities.RGBToInteger(fillRGB)); Node label5001 = createLabel(node, ProcessVisualIDRegistry.getType(TaskNameEditPart.VISUAL_ID)); return node; }
Example #26
Source Project: bonita-studio Author: bonitasoft File: StartSignalEventLabel2EditPart.java License: GNU General Public License v2.0 | 5 votes |
/** * @generated */ protected void refreshFont() { FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(NotationPackage.eINSTANCE.getFontStyle()); if (style != null) { FontData fontData = new FontData(style.getFontName(), style.getFontHeight(), (style.isBold() ? SWT.BOLD : SWT.NORMAL) | (style.isItalic() ? SWT.ITALIC : SWT.NORMAL)); setFont(fontData); } }
Example #27
Source Project: typescript.java Author: angelozerr File: HTMLTypeScriptPrinter.java License: MIT License | 5 votes |
/** * Returns the Javadoc hover style sheet with the current Javadoc font from * the preferences. * * @return the updated style sheet * @since 3.4 */ private static String getStyleSheet() { if (fgStyleSheet == null) { fgStyleSheet = loadStyleSheet("/css/TypeScriptHoverStyleSheet.css"); //$NON-NLS-1$ } String css = fgStyleSheet; if (css != null) { FontData fontData = JFaceResources.getFontRegistry().getFontData(JFaceResources.DIALOG_FONT)[0]; css = HTMLPrinter.convertTopLevelFont(css, fontData); } return css; }
Example #28
Source Project: workspacemechanic Author: alfsch File: MechanicPopup.java License: Eclipse Public License 1.0 | 5 votes |
private Font createBoldFont(Font font) { FontData[] fontDatas = font.getFontData(); for (FontData fd: fontDatas) { fd.setStyle(SWT.BOLD); } return new Font(font.getDevice(), fontDatas); }
Example #29
Source Project: thym Author: eclipse File: CordovaPluginWizardResources.java License: Eclipse Public License 1.0 | 5 votes |
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); }
Example #30
Source Project: SIMVA-SoS Author: SESoS File: SWTUtils.java License: Apache License 2.0 | 5 votes |
/** * Create an awt font by converting as much information * as possible from the provided swt <code>FontData</code>. * <p>Generally speaking, given a font size, an swt font will * display differently on the screen than the corresponding awt * one. Because the SWT toolkit use native graphical ressources whenever * it is possible, this fact is platform dependent. To address * this issue, it is possible to enforce the method to return * an awt font with the same height as the swt one. * * @param device The swt device being drawn on (display or gc device). * @param fontData The swt font to convert. * @param ensureSameSize A boolean used to enforce the same size * (in pixels) between the swt font and the newly created awt font. * @return An awt font converted from the provided swt font. */ public static java.awt.Font toAwtFont(Device device, FontData fontData, boolean ensureSameSize) { int height = (int) Math.round(fontData.getHeight() * device.getDPI().y / 72.0); // hack to ensure the newly created awt fonts will be rendered with the // same height as the swt one if (ensureSameSize) { GC tmpGC = new GC(device); Font tmpFont = new Font(device, fontData); tmpGC.setFont(tmpFont); JPanel DUMMY_PANEL = new JPanel(); java.awt.Font tmpAwtFont = new java.awt.Font(fontData.getName(), fontData.getStyle(), height); if (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az) > tmpGC.textExtent(Az).x) { while (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az) > tmpGC.textExtent(Az).x) { height--; tmpAwtFont = new java.awt.Font(fontData.getName(), fontData.getStyle(), height); } } else if (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az) < tmpGC.textExtent(Az).x) { while (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az) < tmpGC.textExtent(Az).x) { height++; tmpAwtFont = new java.awt.Font(fontData.getName(), fontData.getStyle(), height); } } tmpFont.dispose(); tmpGC.dispose(); } return new java.awt.Font(fontData.getName(), fontData.getStyle(), height); }