private FontData createFontDataFromNormal() { FontData normalData = NORMAL.getFontData()[0]; FontData result = new FontData(); result.setName(normalData.getName()); result.height = normalData.height; return result; }
/** @generated */ public Edge createViewTableViewedTables_3002( View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Edge edge = NotationFactory.eINSTANCE.createEdge(); edge.getStyles().add(NotationFactory.eINSTANCE.createRoutingStyle()); edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle()); RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints(); ArrayList points = new ArrayList(2); points.add(new RelativeBendpoint()); points.add(new RelativeBendpoint()); bendpoints.setPoints(points); edge.setBendpoints(bendpoints); ViewUtil.insertChildView(containerView, edge, index, persisted); edge.setType(SqlmodelVisualIDRegistry.getType(ViewTableViewedTables2EditPart.VISUAL_ID)); edge.setElement(null); // initializePreferences final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); FontStyle edgeFontStyle = (FontStyle) edge.getStyle(NotationPackage.Literals.FONT_STYLE); if (edgeFontStyle != null) { FontData fontData = PreferenceConverter.getFontData(prefStore, IPreferenceConstants.PREF_DEFAULT_FONT); edgeFontStyle.setFontName(fontData.getName()); edgeFontStyle.setFontHeight(fontData.getHeight()); edgeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0); edgeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0); org.eclipse.swt.graphics.RGB fontRGB = PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR); edgeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue()); } Routing routing = Routing.get(prefStore.getInt(IPreferenceConstants.PREF_LINE_STYLE)); if (routing != null) { ViewUtil.setStructuralFeatureValue( edge, NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing); } return edge; }
/** * Replaces the following style attributes of the font definition of the <code>html</code> * element: * * <ul> * <li>font-size * <li>font-weight * <li>font-style * <li>font-family * </ul> * * The font's name is used as font family, a <code>sans-serif</code> default font family is * appended for the case that the given font name is not available. * * <p>If the listed font attributes are not contained in the passed style list, nothing happens. * * @param styles CSS style definitions * @param fontData the font information to use * @return the modified style definitions * @since 3.3 */ public static String convertTopLevelFont(String styles, FontData fontData) { boolean bold = (fontData.getStyle() & SWT.BOLD) != 0; boolean italic = (fontData.getStyle() & SWT.ITALIC) != 0; String size = Integer.toString(fontData.getHeight()) + UNIT; String family = "'" + fontData.getName() + "',sans-serif"; // $NON-NLS-1$ //$NON-NLS-2$ styles = styles.replaceFirst( "(html\\s*\\{.*(?:\\s|;)font-size:\\s*)\\d+pt(\\;?.*\\})", "$1" + size + "$2"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ styles = styles.replaceFirst( "(html\\s*\\{.*(?:\\s|;)font-weight:\\s*)\\w+(\\;?.*\\})", "$1" + (bold ? "bold" : "normal") + "$2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ styles = styles.replaceFirst( "(html\\s*\\{.*(?:\\s|;)font-style:\\s*)\\w+(\\;?.*\\})", "$1" + (italic ? "italic" : "normal") + "$2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ styles = styles.replaceFirst( "(html\\s*\\{.*(?:\\s|;)font-family:\\s*).+?(;.*\\})", "$1" + family + "$2"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ return styles; }
private java.awt.Font getSelectedFont() { // Always use a large font for the rendering, even though user is typically // picking small font sizes in the font chooser // int dpi = mFontButton.getDisplay().getDPI().y; // int height = (int) Math.round(fontData.getHeight() * dpi / 72.0); int fontHeight = new TextRenderUtil.Options().fontSize; if (mFontButton.getData() == null) { // The user has not yet picked a font; look up the default font to use // (Helvetica Bold, not whatever font happened to be used for button widgets // in SWT on this platform) return new java.awt.Font("Helvetica", java.awt.Font.BOLD, fontHeight); // $NON-NLS-1$ } Font font = mFontButton.getFont(); FontData fontData = font.getFontData()[0]; int awtStyle = java.awt.Font.PLAIN; int swtStyle = fontData.getStyle(); if ((swtStyle & SWT.ITALIC) != 0) { awtStyle |= java.awt.Font.ITALIC; } if ((swtStyle & SWT.BOLD) != 0) { awtStyle = java.awt.Font.BOLD; } return new java.awt.Font(fontData.getName(), awtStyle, fontHeight); }
/** 사용자 폰트를 설정합니다. */ private void setFontData() { FontDialog fd = new FontDialog(getShell(), SWT.NONE); FontData fdFont = fd.open(); if (fdFont != null) { lblUserFont.setText(fdFont.getName() + "|" + fdFont.getHeight() + "|" + fdFont.getStyle()); } }
/** @generated */ public Edge createAssociation_4001( EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Connector edge = NotationFactory.eINSTANCE.createConnector(); edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle()); RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints(); ArrayList<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2); points.add(new RelativeBendpoint()); points.add(new RelativeBendpoint()); bendpoints.setPoints(points); edge.setBendpoints(bendpoints); ViewUtil.insertChildView(containerView, edge, index, persisted); edge.setType( edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part .NECSIS14_ClassDiagramVisualIDRegistry.getType( edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.edit.parts .AssociationEditPart.VISUAL_ID)); edge.setElement(domainElement); // initializePreferences final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); org.eclipse.swt.graphics.RGB lineRGB = PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_LINE_COLOR); ViewUtil.setStructuralFeatureValue( edge, NotationPackage.eINSTANCE.getLineStyle_LineColor(), FigureUtilities.RGBToInteger(lineRGB)); FontStyle edgeFontStyle = (FontStyle) edge.getStyle(NotationPackage.Literals.FONT_STYLE); if (edgeFontStyle != null) { FontData fontData = PreferenceConverter.getFontData(prefStore, IPreferenceConstants.PREF_DEFAULT_FONT); edgeFontStyle.setFontName(fontData.getName()); edgeFontStyle.setFontHeight(fontData.getHeight()); edgeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0); edgeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0); org.eclipse.swt.graphics.RGB fontRGB = PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR); edgeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue()); } Routing routing = Routing.get(prefStore.getInt(IPreferenceConstants.PREF_LINE_STYLE)); if (routing != null) { ViewUtil.setStructuralFeatureValue( edge, NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing); } Node label6001 = createLabel( edge, edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part .NECSIS14_ClassDiagramVisualIDRegistry.getType( edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.edit.parts .AssociationNameEditPart.VISUAL_ID)); label6001.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); Location location6001 = (Location) label6001.getLayoutConstraint(); location6001.setX(0); location6001.setY(40); return edge; }
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); final StyledText styledText = new StyledText(shell, SWT.WRAP | SWT.BORDER); styledText.setText(text); FontData data = display.getSystemFont().getFontData()[0]; Font font = new Font(display, data.getName(), 16, SWT.BOLD); styledText.setFont(font); styledText.setForeground(display.getSystemColor(SWT.COLOR_BLUE)); styledText.addListener( SWT.Resize, new Listener() { public void handleEvent(Event event) { Rectangle rect = styledText.getClientArea(); Image newImage = new Image(display, 1, Math.max(1, rect.height)); GC gc = new GC(newImage); gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE)); gc.setBackground(display.getSystemColor(SWT.COLOR_YELLOW)); gc.fillGradientRectangle(rect.x, rect.y, 1, rect.height, true); gc.dispose(); styledText.setBackgroundImage(newImage); if (oldImage != null) oldImage.dispose(); oldImage = newImage; } }); shell.setSize(700, 400); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } if (oldImage != null) oldImage.dispose(); font.dispose(); display.dispose(); }
/** * Replaces the following style attributes of the font definition of the <code>html</code> * element: * * <ul> * <li>font-size * <li>font-weight * <li>font-style * <li>font-family * </ul> * * The font's name is used as font family, a <code>sans-serif</code> default font family is * appended for the case that the given font name is not available. * * <p>If the listed font attributes are not contained in the passed style list, nothing happens. * * @param styles CSS style definitions * @param fontData the font information to use * @return the modified style definitions * @since 3.3 */ public static String convertTopLevelFont(String styles, FontData fontData) { boolean bold = (fontData.getStyle() & SWT.BOLD) != 0; boolean italic = (fontData.getStyle() & SWT.ITALIC) != 0; // See: https://bugs.eclipse.org/bugs/show_bug.cgi?id=155993 String size = Integer.toString(fontData.getHeight()) + ("carbon".equals(SWT.getPlatform()) ? "px" : "pt"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ String family = "'" + fontData.getName() + "',sans-serif"; // $NON-NLS-1$ //$NON-NLS-2$ styles = styles.replaceFirst( "(html\\s*\\{.*(?:\\s|;)font-size:\\s*)\\d+pt(\\;?.*\\})", "$1" + size + "$2"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ styles = styles.replaceFirst( "(html\\s*\\{.*(?:\\s|;)font-weight:\\s*)\\w+(\\;?.*\\})", "$1" + (bold ? "bold" : "normal") + "$2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ styles = styles.replaceFirst( "(html\\s*\\{.*(?:\\s|;)font-style:\\s*)\\w+(\\;?.*\\})", "$1" + (italic ? "italic" : "normal") + "$2"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ styles = styles.replaceFirst( "(html\\s*\\{.*(?:\\s|;)font-family:\\s*).+?(;.*\\})", "$1" + family + "$2"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ return styles; }
private void update(FontData data) { this.fontData[0] = data; this.selectedFont = GUIHelper.getFont(data); setText(data.getName() + ", " + data.getHeight() + "pt"); setFont(createDisplayFont(data)); setAlignment(SWT.CENTER); setToolTipText("Click to select font"); }
/** Copied from {@link FontRegistry} */ private static FontData[] getModifiedFontData(FontData[] baseData, int style) { FontData[] styleData = new FontData[baseData.length]; for (int i = 0; i < styleData.length; i++) { FontData base = baseData[i]; styleData[i] = new FontData(base.getName(), base.getHeight(), base.getStyle() | style); } return styleData; }
void paintCanvas(Event event) { canvas.setCursor(null); int index = list.getSelectionIndex(); if (index == -1) return; GC gc = event.gc; Object object = objects[index]; if (object instanceof Color) { if (((Color) object).isDisposed()) return; gc.setBackground((Color) object); gc.fillRectangle(canvas.getClientArea()); return; } if (object instanceof Cursor) { if (((Cursor) object).isDisposed()) return; canvas.setCursor((Cursor) object); return; } if (object instanceof Font) { if (((Font) object).isDisposed()) return; gc.setFont((Font) object); FontData[] array = gc.getFont().getFontData(); StringBuffer sb = new StringBuffer(); String lf = text.getLineDelimiter(); for (int i = 0; i < array.length; i++) { FontData data = array[i]; String style = "NORMAL"; // $NON-NLS-1$ int bits = data.getStyle(); if (bits != 0) { if ((bits & SWT.BOLD) != 0) style = "BOLD "; // $NON-NLS-1$ if ((bits & SWT.ITALIC) != 0) style += "ITALIC"; // $NON-NLS-1$ } sb.append(data.getName()) .append(" ") .append(data.getHeight()) // $NON-NLS-1$ .append(" ") .append(style) .append(lf); // $NON-NLS-1$ } gc.drawString(sb.toString(), 0, 0); return; } // NOTHING TO DRAW FOR GC // if (object instanceof GC) { // return; // } if (object instanceof Image) { if (((Image) object).isDisposed()) return; gc.drawImage((Image) object, 0, 0); return; } if (object instanceof Region) { if (((Region) object).isDisposed()) return; String string = ((Region) object).getBounds().toString(); gc.drawString(string, 0, 0); return; } }
private static void appendFontData(final StringBuffer buffer) { final String size = Integer.toString(fontData.getHeight()) + ("carbon".equals(SWT.getPlatform()) ? "px" : "pt"); buffer .append("<style type=\"text/css\">body {font-size:") .append(size) .append("; font-family:'") .append(fontData.getName()) .append("',serif;}</style>"); }
/** * Get the text font * * @return */ private String getCssFont() { StringBuilder result = new StringBuilder(); if (getFont() != null) { FontData data = getFont().getFontData()[0]; result.append(data.getHeight()); result.append("px "); result.append(data.getName()); } return result.toString(); }
private String[] getScalableFonts() { FontData[] fontData = Display.getCurrent().getFontList(null, true); Set<String> fontSet = new HashSet<String>(); for (FontData fd : fontData) { fontSet.add(fd.getName()); } Set<String> fontCache = new TreeSet<String>((new FontCache()).getAvailableFonts()); fontCache.retainAll(fontSet); return (String[]) fontCache.toArray(new String[0]); }
/** * Returns a bold version of the given {@link Font}. * * @param baseFont the {@link Font} for which a bold version is desired * @return the bold version of the given {@link Font} */ public static Font getBoldFont(Font baseFont) { Font font = m_fontToBoldFontMap.get(baseFont); if (font == null) { FontData fontDatas[] = baseFont.getFontData(); FontData data = fontDatas[0]; font = new Font(Display.getCurrent(), data.getName(), data.getHeight(), SWT.BOLD); m_fontToBoldFontMap.put(baseFont, font); } return font; }
/** @generated */ public Node createViewTable_1002( EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Node node = NotationFactory.eINSTANCE.createNode(); node.getStyles().add(NotationFactory.eINSTANCE.createDescriptionStyle()); node.getStyles().add(NotationFactory.eINSTANCE.createFontStyle()); FillStyle fillStyle = NotationFactory.eINSTANCE.createFillStyle(); Color color = ViewTableEditPart.getDeclaredBackgroundColor(); fillStyle.setFillColor(FigureUtilities.colorToInteger(color)); node.getStyles().add(fillStyle); LineStyle lineStyle = NotationFactory.eINSTANCE.createLineStyle(); lineStyle.setLineColor(FigureUtilities.RGBToInteger(new org.eclipse.swt.graphics.RGB(0, 0, 0))); node.getStyles().add(lineStyle); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType(SqlmodelVisualIDRegistry.getType(ViewTableEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); stampShortcut(containerView, node); // initializeFromPreferences final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); 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()); } Node label4002 = createLabel(node, SqlmodelVisualIDRegistry.getType(ViewTableNameEditPart.VISUAL_ID)); createCompartment( node, SqlmodelVisualIDRegistry.getType(ViewTableViewedColumnsEditPart.VISUAL_ID), false, false, true, true); createCompartment( node, SqlmodelVisualIDRegistry.getType(ViewTableViewedTablesEditPart.VISUAL_ID), false, false, true, true); return node; }
protected void setButtonFontData(Button button, FontData fontData) { String text = fontData.getName(); if ((fontData.getStyle() & SWT.BOLD) != 0) { text += " Bold"; } if ((fontData.getStyle() & SWT.ITALIC) != 0) { text += " Italic"; } text += (" " + fontData.getHeight()); button.setText(text); }
/* (non-Javadoc) * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control) */ protected Object openDialogBox(Control cellEditorWindow) { FontDialog dialog = new FontDialog(cellEditorWindow.getShell()); dialog.setText(MessageUtil.getString("FontDialogTitle")); if (getValue() != null) { FontData[] oldFont = new FontData[] {new FontData(getValue().toString(), 12, SWT.NORMAL)}; dialog.setFontList(oldFont); } FontData fontData = dialog.open(); if (fontData != null) return fontData.getName(); return ""; }
private static FontData[] getModifiedFontData(FontData[] originalData, int additionalStyle) { FontData[] styleData = new FontData[originalData.length]; for (int i = 0; i < styleData.length; i++) { FontData base = originalData[i]; styleData[i] = new FontData(base.getName(), base.getHeight(), base.getStyle() | additionalStyle); // System.out.println("FONT = "+ base.getName()); // System.out.println("FONT getHeight= "+ base.getHeight()); } return styleData; }
private void refontLabel(boolean dye) { FontData fontData = label.getFont().getFontData()[0]; Font font; int color; if (dye) { font = new Font( label.getParent().getDisplay(), new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD)); color = SWT.COLOR_RED; } else { font = new Font( label.getParent().getDisplay(), new FontData(fontData.getName(), fontData.getHeight(), SWT.NONE)); color = SWT.COLOR_WIDGET_FOREGROUND; } label.setForeground(label.getParent().getDisplay().getSystemColor(color)); label.setFont(font); }
private static Font getItalicFont(Font font) { if (italicFont == null) { FontData data = font.getFontData()[0]; italicFont = new Font( Display.getDefault(), new FontData(data.getName(), data.getHeight(), SWT.ITALIC)); } return italicFont; }
@Override protected void initialize(ColumnViewer viewer, ViewerColumn column) { super.initialize(viewer, column); Font font = viewer.getControl().getFont(); if (font != null) { FontData data = font.getFontData()[0]; boldFont = new Font(font.getDevice(), data.getName(), data.getHeight(), SWT.BOLD); } }
public TagLabel(Composite parent, int style, String tagName) { super(parent, style); if (tagName == null || tagName.length() == 0) { throw new IllegalArgumentException("tag name is empty"); } this.tagName = tagName; GridLayout gl = new GridLayout(2, false); GUIUtil.resetGridLayout(gl); super.setLayout(gl); final CLabel cross = new CLabel(this, 0); cross.setText("×"); GridData data = new GridData(SWT.LEFT, SWT.TOP, false, true); cross.setLayoutData(data); data = new GridData(SWT.RIGHT, SWT.TOP, true, true); CLabel tagText = new CLabel(this, 0); tagText.setText(tagName); plainFont = cross.getFont(); FontData fd = plainFont.getFontData()[0]; boldFont = new Font(cross.getDisplay(), fd.getName(), fd.getHeight(), SWT.BOLD); cross.addListener( SWT.MouseEnter, new Listener() { @Override public void handleEvent(Event event) { cross.setFont(boldFont); cross.setCursor(handCursor); } }); cross.addListener( SWT.MouseExit, new Listener() { @Override public void handleEvent(Event event) { cross.setFont(plainFont); cross.setCursor(defaultCursor); } }); cross.addListener( SWT.MouseDown, new Listener() { @Override public void handleEvent(Event event) { if (delegate != null) { delegate.tagLabelClicked(TagLabel.this); } } }); }
private Font getMergeTreeFont() { if (mergeTreeFont != null) { // mergeTreeFont.dispose(); } FontData systemFontData = Display.getDefault().getSystemFont().getFontData()[0]; int height = MergePlugin.getDefault() .getPreferenceStore() .getInt(MergeEditorPreferencePage.P_MERGE_EDITOR_FONT_SIZE); mergeTreeFont = FontUtils.getStyledFont(null, systemFontData.getName(), height, systemFontData.getStyle()); return mergeTreeFont; }
/** @generated */ public Node createAttribute_3001( EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType( edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part .NECSIS14_ClassDiagramVisualIDRegistry.getType( edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.edit.parts.AttributeEditPart .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 label5001 = createLabel( node, edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part .NECSIS14_ClassDiagramVisualIDRegistry.getType( edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.edit.parts .AttributeNameEditPart.VISUAL_ID)); return node; }
public static void initFormText(FormText formText) { formText.setWhitespaceNormalized(false); Font formTextFont = formText.getFont(); FontData formTextFontData = formTextFont.getFontData()[0]; FontData h1FontData = new FontData(formTextFontData.getName(), formTextFontData.getHeight() + 5, SWT.BOLD); final Font h1Font = new Font(formTextFont.getDevice(), h1FontData); formText.setFont(FONT_H1_KEY, h1Font); FontData h3FontData = new FontData(formTextFontData.getName(), formTextFontData.getHeight() + 3, SWT.BOLD); final Font h3Font = new Font(formTextFont.getDevice(), h3FontData); formText.setFont(FONT_H3_KEY, h3Font); Font codeFont = JFaceResources.getTextFont(); formText.setFont(FONT_CODE_KEY, codeFont); formText.addDisposeListener( new DisposeListener() { @Override public void widgetDisposed(DisposeEvent e) { h1Font.dispose(); h3Font.dispose(); } }); // Set fontKeySet = JFaceResources.getFontRegistry().getKeySet(); // if (fontKeySet != null) { // for (Object fontKey : fontKeySet) { // System.out.println(fontKey); // } // } }
/** @generated */ public Node createStakeHolder_2011( EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Shape node = NotationFactory.eINSTANCE.createShape(); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType(RdalVisualIDRegistry.getType(StakeHolderEditPart.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 label5018 = createLabel(node, RdalVisualIDRegistry.getType(StakeHolderNameEditPart.VISUAL_ID)); label5018.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation()); Location location5018 = (Location) label5018.getLayoutConstraint(); location5018.setX(0); location5018.setY(5); return node; }
/** @generated */ public Node createRequirementsGroup_2007( EObject domainElement, View containerView, int index, boolean persisted, PreferencesHint preferencesHint) { Node node = NotationFactory.eINSTANCE.createNode(); node.getStyles().add(NotationFactory.eINSTANCE.createDescriptionStyle()); node.getStyles().add(NotationFactory.eINSTANCE.createFontStyle()); node.getStyles().add(NotationFactory.eINSTANCE.createFillStyle()); node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds()); node.setType(RdalVisualIDRegistry.getType(RequirementsGroupEditPart.VISUAL_ID)); ViewUtil.insertChildView(containerView, node, index, persisted); node.setElement(domainElement); stampShortcut(containerView, node); // initializeFromPreferences final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore(); 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 label5013 = createLabel(node, RdalVisualIDRegistry.getType(RequirementsGroupNameEditPart.VISUAL_ID)); createCompartment( node, RdalVisualIDRegistry.getType(RequirementsGroupRequirementsCompartmentEditPart.VISUAL_ID), true, false, false, false); return node; }
/** * Clients are expected to override this method if they require a custom layout with various * composites * * @param parent * @param top */ protected void addDeploymentLocationControls(Composite parent, Control top) { FormToolkit toolkit = new FormToolkit(parent.getDisplay()); Label l1 = toolkit.createLabel(parent, Messages.EditorDeploymentPageWarning); FontData fontData = l1.getFont().getFontData()[0]; Font font = new Font( parent.getDisplay(), new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD)); l1.setFont(font); FormData fd = new FormData(); fd.left = new FormAttachment(0, 5); fd.top = top == null ? new FormAttachment(0, 5) : new FormAttachment(top, 5); fd.right = new FormAttachment(100, -5); l1.setLayoutData(fd); errorImage = toolkit.createLabel(parent, ""); fd = new FormData(); fd.top = new FormAttachment(l1, 5); fd.left = new FormAttachment(0, 0); errorImage.setLayoutData(fd); errorLabel = toolkit.createLabel(parent, "", SWT.WRAP); fd = new FormData(); fd.top = new FormAttachment(l1, 5); fd.left = new FormAttachment(0, 20); fd.right = new FormAttachment(0, 600); errorLabel.setLayoutData(fd); // First section is deployment mode (server / custom / metadata) etc. standardOptions = createServerDeploymentOptions(parent); standardOptions.setLayoutData(UIUtil.createFormData2(errorLabel, 5, null, 0, 0, 5, 100, -5)); // Simply create a composite to show the per-module customizations perModuleOptions = createModuleDeploymentOptions(parent); fd = new FormData(); fd.left = new FormAttachment(0, 5); fd.top = new FormAttachment(standardOptions, 5); fd.right = new FormAttachment(100, -5); fd.bottom = new FormAttachment(100, -5); perModuleOptions.setLayoutData(fd); }
/** * 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; }