Java 类org.eclipse.swt.graphics.TextStyle 实例源码

项目:ide-plugins    文件:PluginsSWT.java   
public PluginsSWT(Shell shell, List<String> lines) {
    super(shell);
    this.pluginsBean = new PluginsBean(lines);

    target = pluginsBean.getPlugins();
    source = Stream.of(Plugin.values())
            .filter(p -> ! target.contains(p))
            .collect(Collectors.toList());
    targetOriginal = target.stream().collect(Collectors.toList());

    rowColorTitle = new Color(display, 70, 130, 180);
    int color = myOS == OS.Mac ? 249 : 239;
    rowColorBack = new Color(display, color, color, color);
    rowColorSelection = display.getSystemColor(SWT.COLOR_WHITE);

    fontAwesome = loadCustomFont(getFontAwesomeSize());
    fontGap = new Font(display, fontName, 4, SWT.NORMAL);
    rowTitleFont = new Font(display, fontName, getTopFontSize(), SWT.BOLD);
    rowTextFont = new Font(display, fontName, getTopFontSize() - 2, SWT.NORMAL);
    styleTitle = new TextStyle(rowTitleFont, rowColorTitle, null);
    styleGap = new TextStyle(fontGap, display.getSystemColor(SWT.COLOR_BLACK), null);
    styleRow = new TextStyle(rowTextFont, display.getSystemColor(SWT.COLOR_BLACK), null);
    styleTitleSelected = new TextStyle(rowTitleFont, rowColorSelection, null);
    styleRowSelected = new TextStyle(rowTextFont, rowColorSelection, null);
}
项目:DarwinSPL    文件:DwprofileBrowserInformationControl.java   
/**
 * <p>
 * Creates and initializes the text layout used to compute the size hint.
 * </p>
 * 
 * @since 3.2
 */
private void createTextLayout() {
    fTextLayout= new TextLayout(fBrowser.getDisplay());

    // Initialize fonts
    String symbolicFontName= fSymbolicFontName == null ? JFaceResources.DIALOG_FONT : fSymbolicFontName;
    Font font = JFaceResources.getFont(symbolicFontName);
    fTextLayout.setFont(font);
    fTextLayout.setWidth(-1);
    font = JFaceResources.getFontRegistry().getBold(symbolicFontName);
    fBoldStyle = new TextStyle(font, null, null);

    // Compute and set tab width
    fTextLayout.setText("    ");
    int tabWidth = fTextLayout.getBounds().width;
    fTextLayout.setTabs(new int[] {tabWidth});

    fTextLayout.setText("");
}
项目:DarwinSPL    文件:HyexpressionBrowserInformationControl.java   
/**
 * <p>
 * Creates and initializes the text layout used to compute the size hint.
 * </p>
 * 
 * @since 3.2
 */
private void createTextLayout() {
    fTextLayout= new TextLayout(fBrowser.getDisplay());

    // Initialize fonts
    String symbolicFontName= fSymbolicFontName == null ? JFaceResources.DIALOG_FONT : fSymbolicFontName;
    Font font = JFaceResources.getFont(symbolicFontName);
    fTextLayout.setFont(font);
    fTextLayout.setWidth(-1);
    font = JFaceResources.getFontRegistry().getBold(symbolicFontName);
    fBoldStyle = new TextStyle(font, null, null);

    // Compute and set tab width
    fTextLayout.setText("    ");
    int tabWidth = fTextLayout.getBounds().width;
    fTextLayout.setTabs(new int[] {tabWidth});

    fTextLayout.setText("");
}
项目:DarwinSPL    文件:HyvalidityformulaBrowserInformationControl.java   
/**
 * <p>
 * Creates and initializes the text layout used to compute the size hint.
 * </p>
 * 
 * @since 3.2
 */
private void createTextLayout() {
    fTextLayout= new TextLayout(fBrowser.getDisplay());

    // Initialize fonts
    String symbolicFontName= fSymbolicFontName == null ? JFaceResources.DIALOG_FONT : fSymbolicFontName;
    Font font = JFaceResources.getFont(symbolicFontName);
    fTextLayout.setFont(font);
    fTextLayout.setWidth(-1);
    font = JFaceResources.getFontRegistry().getBold(symbolicFontName);
    fBoldStyle = new TextStyle(font, null, null);

    // Compute and set tab width
    fTextLayout.setText("    ");
    int tabWidth = fTextLayout.getBounds().width;
    fTextLayout.setTabs(new int[] {tabWidth});

    fTextLayout.setText("");
}
项目:DarwinSPL    文件:HydatavalueBrowserInformationControl.java   
/**
 * <p>
 * Creates and initializes the text layout used to compute the size hint.
 * </p>
 * 
 * @since 3.2
 */
private void createTextLayout() {
    fTextLayout= new TextLayout(fBrowser.getDisplay());

    // Initialize fonts
    String symbolicFontName= fSymbolicFontName == null ? JFaceResources.DIALOG_FONT : fSymbolicFontName;
    Font font = JFaceResources.getFont(symbolicFontName);
    fTextLayout.setFont(font);
    fTextLayout.setWidth(-1);
    font = JFaceResources.getFontRegistry().getBold(symbolicFontName);
    fBoldStyle = new TextStyle(font, null, null);

    // Compute and set tab width
    fTextLayout.setText("    ");
    int tabWidth = fTextLayout.getBounds().width;
    fTextLayout.setTabs(new int[] {tabWidth});

    fTextLayout.setText("");
}
项目:DarwinSPL    文件:HymappingBrowserInformationControl.java   
/**
 * <p>
 * Creates and initializes the text layout used to compute the size hint.
 * </p>
 * 
 * @since 3.2
 */
private void createTextLayout() {
    fTextLayout= new TextLayout(fBrowser.getDisplay());

    // Initialize fonts
    String symbolicFontName= fSymbolicFontName == null ? JFaceResources.DIALOG_FONT : fSymbolicFontName;
    Font font = JFaceResources.getFont(symbolicFontName);
    fTextLayout.setFont(font);
    fTextLayout.setWidth(-1);
    font = JFaceResources.getFontRegistry().getBold(symbolicFontName);
    fBoldStyle = new TextStyle(font, null, null);

    // Compute and set tab width
    fTextLayout.setText("    ");
    int tabWidth = fTextLayout.getBounds().width;
    fTextLayout.setTabs(new int[] {tabWidth});

    fTextLayout.setText("");
}
项目:DarwinSPL    文件:HyconstraintsBrowserInformationControl.java   
/**
 * <p>
 * Creates and initializes the text layout used to compute the size hint.
 * </p>
 * 
 * @since 3.2
 */
private void createTextLayout() {
    fTextLayout= new TextLayout(fBrowser.getDisplay());

    // Initialize fonts
    String symbolicFontName= fSymbolicFontName == null ? JFaceResources.DIALOG_FONT : fSymbolicFontName;
    Font font = JFaceResources.getFont(symbolicFontName);
    fTextLayout.setFont(font);
    fTextLayout.setWidth(-1);
    font = JFaceResources.getFontRegistry().getBold(symbolicFontName);
    fBoldStyle = new TextStyle(font, null, null);

    // Compute and set tab width
    fTextLayout.setText("    ");
    int tabWidth = fTextLayout.getBounds().width;
    fTextLayout.setTabs(new int[] {tabWidth});

    fTextLayout.setText("");
}
项目:DarwinSPL    文件:HymanifestBrowserInformationControl.java   
/**
 * <p>
 * Creates and initializes the text layout used to compute the size hint.
 * </p>
 * 
 * @since 3.2
 */
private void createTextLayout() {
    fTextLayout= new TextLayout(fBrowser.getDisplay());

    // Initialize fonts
    String symbolicFontName= fSymbolicFontName == null ? JFaceResources.DIALOG_FONT : fSymbolicFontName;
    Font font = JFaceResources.getFont(symbolicFontName);
    fTextLayout.setFont(font);
    fTextLayout.setWidth(-1);
    font = JFaceResources.getFontRegistry().getBold(symbolicFontName);
    fBoldStyle = new TextStyle(font, null, null);

    // Compute and set tab width
    fTextLayout.setText("    ");
    int tabWidth = fTextLayout.getBounds().width;
    fTextLayout.setTabs(new int[] {tabWidth});

    fTextLayout.setText("");
}
项目:SPELL    文件:BasicStyleScheme.java   
/***************************************************************************
 * Set the font to use
 * 
 * @param font
 **************************************************************************/
@Override
public void setFont(Font font)
{
    String face = font.getFontData()[0].getName();
    int size = font.getFontData()[0].getHeight();
    int style = font.getFontData()[0].getStyle() | SWT.NORMAL;

    FontData newData = new FontData(face, size, style);

    Font newFont = new Font(Display.getDefault(), newData);
    if (m_codeFont != null)
    {
        m_codeFont.dispose();
    }
    m_codeFont = newFont;
    m_defaultStyle = new TextStyle(m_codeFont, Display.getCurrent().getSystemColor(SWT.COLOR_BLACK), null);
    m_selectedStyle = new TextStyle(m_codeFont, Display.getCurrent().getSystemColor(SWT.COLOR_WHITE), null);
    m_highlightedStyle = new TextStyle(m_codeFont, Display.getCurrent().getSystemColor(SWT.COLOR_BLACK), null);
}
项目:APICloud-Studio    文件:CustomBrowserInformationControl.java   
/**
 * Creates and initializes the text layout used to compute the size hint.
 * 
 * @since 3.2
 */
private void createTextLayout()
{
    fTextLayout = new TextLayout(fBrowser.getDisplay());

    // Initialize fonts
    String symbolicFontName = fSymbolicFontName == null ? JFaceResources.DIALOG_FONT : fSymbolicFontName;
    Font font = JFaceResources.getFont(symbolicFontName);
    fTextLayout.setFont(font);
    fTextLayout.setWidth(-1);
    font = JFaceResources.getFontRegistry().getBold(symbolicFontName);
    fBoldStyle = new TextStyle(font, null, null);

    // Compute and set tab width
    fTextLayout.setText("    "); //$NON-NLS-1$
    int tabWidth = fTextLayout.getBounds().width;
    fTextLayout.setTabs(new int[] { tabWidth });
    fTextLayout.setText(""); //$NON-NLS-1$
}
项目:translationstudio8    文件:HsMultiCellEditor.java   
public void highlightedTerms(List<String> terms) {
    if (!isValid()) {
        return;
    }
    StyledText styledText = cellEditor.viewer.getTextWidget();
    String text = styledText.getText();
    char[] source = text.toCharArray();
    List<StyleRange> ranges = new ArrayList<StyleRange>();
    TextStyle style = new TextStyle(cellEditor.getSegmentViewer().getTextWidget().getFont(), null,
            ColorConfigBean.getInstance().getHighlightedTermColor());
    for (String term : terms) {
        if (XliffEditorParameter.getInstance().isShowNonpirnttingCharacter()) {
            term = term.replaceAll("\\n", Constants.LINE_SEPARATOR_CHARACTER + "\n");
            term = term.replaceAll("\\t", Constants.TAB_CHARACTER + "\u200B");
            term = term.replaceAll(" ", Constants.SPACE_CHARACTER + "\u200B");
        }
        ranges.addAll(calculateTermsStyleRange(source, term.toCharArray(), style));
    }
    for (StyleRange range : ranges) {
        styledText.setStyleRange(range);
    }
}
项目:translationstudio8    文件:TagStyleConfigurator.java   
public static void configure(TextLayout textLayout) {
    String text = textLayout.getText();
    Document doc = new Document(text);
    ITokenScanner scanner = getRecipeScanner(doc);
    scanner.setRange(doc, 0, doc.getLength());
    IToken token;
    while ((token = scanner.nextToken()) != Token.EOF) {
        int offset = scanner.getTokenOffset();
        int length = scanner.getTokenLength();
        Object data = token.getData();
        if (data != null && data instanceof TextStyle) {
            TextStyle textStyle = (TextStyle) data;
            textLayout.setStyle(textStyle, offset, offset + length - 1);
        }
    }
}
项目:translationstudio8    文件:TagStyleConfigurator.java   
public static void configure(TextLayout textLayout) {
    String text = textLayout.getText();
    Document doc = new Document(text);
    ITokenScanner scanner = getRecipeScanner(doc);
    scanner.setRange(doc, 0, doc.getLength());
    IToken token;
    while ((token = scanner.nextToken()) != Token.EOF) {
        int offset = scanner.getTokenOffset();
        int length = scanner.getTokenLength();
        Object data = token.getData();
        if (data != null && data instanceof TextStyle) {
            TextStyle textStyle = (TextStyle) data;
            textLayout.setStyle(textStyle, offset, offset + length - 1);
        }
    }
    scanner = null;
    doc = null;
}
项目:translationstudio8    文件:ConcordanceSearchDialog.java   
/**
 * 构造方法
 * @param parentShell
 * @param file
 *            当前文件
 * @param strSrcLang
 *            当前文件的源语言
 * @param strTgtLang
 *            当前文件的目标语言
 * @param strSearchText
 *            搜索文本
 */
public ConcordanceSearchDialog(Shell parentShell, IFile file, String strSrcLang, String strTgtLang,
        String strSearchText) {
    super(parentShell);

    FontData fontData = JFaceResources.getDefaultFont().getFontData()[0];
    fontData.setStyle(fontData.getStyle() | SWT.BOLD);
    font = new Font(Display.getDefault(), fontData);
    style = new TextStyle(font, null, null);

    this.strSrcLang = strSrcLang;
    this.strTgtLang = strTgtLang;
    this.strSearchText = strSearchText;
    ProjectConfiger projectConfig = ProjectConfigerFactory.getProjectConfiger(file.getProject());
    lstDatabase = projectConfig.getAllTmDbs();
    filterUnAvaliableDatabase();
    setHelpAvailable(true);
    setBlockOnOpen(false);
    lstSearchHistory = new ArrayList<String>(HISTORY_SIZE - 1);
    lstFilterHistory = new ArrayList<String>(HISTORY_SIZE - 1);
    if (!Util.isLinux()) {
        totalWidth = 910;
    }
}
项目:Environment    文件:AlternativeResourceNode.java   
@Override
public StyledString getStyledText(Object element) {
    if(element instanceof IExplorerNode){

        IExplorerNode node = (IExplorerNode)element;

        return new StyledString(node.getName(), new Styler() {

            @Override
            public void applyStyles(TextStyle textStyle) {
                textStyle.foreground = ColorResources.COLOR_CS_BLUE_DARK;                       
            }

        });

    }
    return null;
}
项目:tmxeditor8    文件:TagStyleConfigurator.java   
public static void configure(TextLayout textLayout) {
    String text = textLayout.getText();
    Document doc = new Document(text);
    ITokenScanner scanner = getRecipeScanner(doc);
    scanner.setRange(doc, 0, doc.getLength());
    IToken token;
    while ((token = scanner.nextToken()) != Token.EOF) {
        int offset = scanner.getTokenOffset();
        int length = scanner.getTokenLength();
        Object data = token.getData();
        if (data != null && data instanceof TextStyle) {
            TextStyle textStyle = (TextStyle) data;
            textLayout.setStyle(textStyle, offset, offset + length - 1);
        }
    }
}
项目:tmxeditor8    文件:HsMultiCellEditor.java   
public void highlightedTerms(List<String> terms) {
    if (!isValid()) {
        return;
    }
    StyledText styledText = cellEditor.viewer.getTextWidget();
    String text = styledText.getText();
    char[] source = text.toCharArray();
    List<StyleRange> ranges = new ArrayList<StyleRange>();
    TextStyle style = new TextStyle(cellEditor.getSegmentViewer().getTextWidget().getFont(), null,
            ColorConfigBean.getInstance().getHighlightedTermColor());
    for (String term : terms) {
        ranges.addAll(calculateTermsStyleRange(source, term.toCharArray(), style));
    }
    for (StyleRange range : ranges) {
        styledText.setStyleRange(range);
    }
}
项目:tmxeditor8    文件:TagStyleConfigurator.java   
public static void configure(TextLayout textLayout) {
    String text = textLayout.getText();
    Document doc = new Document(text);
    ITokenScanner scanner = getRecipeScanner(doc);
    scanner.setRange(doc, 0, doc.getLength());
    IToken token;
    while ((token = scanner.nextToken()) != Token.EOF) {
        int offset = scanner.getTokenOffset();
        int length = scanner.getTokenLength();
        Object data = token.getData();
        if (data != null && data instanceof TextStyle) {
            TextStyle textStyle = (TextStyle) data;
            textLayout.setStyle(textStyle, offset, offset + length - 1);
        }
    }
}
项目:tmxeditor8    文件:TagStyleConfigurator.java   
public static void configure(TextLayout textLayout) {
    String text = textLayout.getText();
    Document doc = new Document(text);
    ITokenScanner scanner = getRecipeScanner(doc);
    scanner.setRange(doc, 0, doc.getLength());
    IToken token;
    while ((token = scanner.nextToken()) != Token.EOF) {
        int offset = scanner.getTokenOffset();
        int length = scanner.getTokenLength();
        Object data = token.getData();
        if (data != null && data instanceof TextStyle) {
            TextStyle textStyle = (TextStyle) data;
            textLayout.setStyle(textStyle, offset, offset + length - 1);
        }
    }
    scanner = null;
    doc = null;
}
项目:tmxeditor8    文件:ConcordanceSearchDialog.java   
/**
 * 构造方法
 * @param parentShell
 * @param file
 *            当前文件
 * @param strSrcLang
 *            当前文件的源语言
 * @param strTgtLang
 *            当前文件的目标语言
 * @param strSearchText
 *            搜索文本
 */
public ConcordanceSearchDialog(Shell parentShell, IFile file, String strSrcLang, String strTgtLang,
        String strSearchText) {
    super(parentShell);

    FontData fontData = JFaceResources.getDefaultFont().getFontData()[0];
    fontData.setStyle(fontData.getStyle() | SWT.BOLD);
    font = new Font(Display.getDefault(), fontData);
    style = new TextStyle(font, null, null);

    this.strSrcLang = strSrcLang;
    this.strTgtLang = strTgtLang;
    this.strSearchText = strSearchText;
    ProjectConfiger projectConfig = ProjectConfigerFactory.getProjectConfiger(file.getProject());
    lstDatabase = projectConfig.getAllTmDbs();
    filterUnAvaliableDatabase();
    setHelpAvailable(true);
    setBlockOnOpen(false);
    lstSearchHistory = new ArrayList<String>(HISTORY_SIZE - 1);
    lstFilterHistory = new ArrayList<String>(HISTORY_SIZE - 1);
    if (!Util.isLinux()) {
        totalWidth = 910;
    }
}
项目:neoscada    文件:BlockControlImage.java   
public BlockControlImage ( final ControlImage controlImage, final int style, final RegistrationManager registrationManager )
{
    super ( controlImage.getClientSpace (), style );

    this.controlImage = controlImage;

    this.registrationManager = registrationManager;

    setLayout ( new FillLayout () );

    this.icon = new Label ( this, SWT.NONE );
    this.icon.setImage ( getEmptyImage () );
    this.icon.addMouseListener ( new MouseAdapter () {
        @Override
        public void mouseUp ( final MouseEvent e )
        {
            toggleBlock ();
        }
    } );

    this.registrationManager.addListener ( this );

    final LocalResourceManager resources = new LocalResourceManager ( JFaceResources.getResources (), this.icon );

    this.boldFont = resources.createFont ( JFaceResources.getDefaultFontDescriptor ().withStyle ( SWT.BOLD ) );
    this.boldStyler = new Styler () {

        @Override
        public void applyStyles ( final TextStyle textStyle )
        {
            textStyle.font = BlockControlImage.this.boldFont;
        }
    };
}
项目:pgcodekeeper    文件:DiffTreeViewer.java   
private void provideTreeCellLabelDecorations(ViewerCell cell) {
    TreeElement el = (TreeElement) cell.getElement();
    List<StyleRange> styles = new ArrayList<>();

    Image icon = Activator.getDbObjImage(el.getType());
    String name = el.getName();

    if(btnDebugView.getSelection()) {
        cell.setText(String.format("%s:%s:%s", //$NON-NLS-1$
                el.getType(), name, el.getSide()));
    } else {
        StringBuilder label = new StringBuilder(name);

        if(el.getType() == DbObjType.DATABASE
                || el.getType() == DbObjType.SCHEMA
                || el.getType() == DbObjType.TABLE) {
            label.append(" (") //$NON-NLS-1$
            .append(el.countChildren())
            .append(") [") //$NON-NLS-1$
            .append(el.countDescendants())
            .append(']');

            TextStyle styleGray = new TextStyle();
            styleGray.foreground = getDisplay().getSystemColor(
                    SWT.COLOR_GRAY);

            StyleRange styleCount = new StyleRange(styleGray);
            styleCount.start = name.length();
            styleCount.length = label.length() - name.length();

            styles.add(styleCount);
        }

        cell.setText(label.toString());
    }

    cell.setStyleRanges(styles.toArray(new StyleRange[styles.size()]));
    cell.setImage(icon);
}
项目:Black    文件:blackAction.java   
/**
 * �������ļ���ԭ������ʽ��text
 * 
 * @param p����������ʽ�������ļ�
 * @param text
 *            ҪӦ��������ʽ��StyledText���
 */
public void getStylesFromProperties(Properties p, StyledText text) {
    String start, length, font, fontstyle, strikeout, underline, fontheight;
    for (int i = 0; i > -1; i++) {
        start = p.getProperty(i + "start");
        if (start != null) {
            length = p.getProperty(i + "length");
            font = p.getProperty(i + "font");
            fontheight = p.getProperty(i + "fontheight");
            fontstyle = p.getProperty(i + "fontstyle");
            strikeout = p.getProperty(i + "strikeout");
            underline = p.getProperty(i + "underline");
            if (Integer.valueOf(fontheight) >= 0) {
                Font f = SWTResourceManager.getFont(font, b.getZoomedFontSize(Integer.valueOf(fontheight)),
                        Integer.valueOf(fontstyle));
                TextStyle ts = new TextStyle(f, null, null);
                ts.strikeout = Boolean.valueOf(strikeout);
                ts.underline = Boolean.valueOf(underline);
                StyleRange sr = new StyleRange(ts);
                sr.start = Integer.valueOf(start);
                sr.length = Integer.valueOf(length);
                if (sr.start >= 0 && sr.length + sr.start <= text.getCharCount())
                    text.setStyleRange(sr);
            } else
                getMessageBox("��ȡ�ļ�ʱ����", "black�ļ��е���ʽ���԰�����������߶Ȳ���Ϊ��ֵ��");
        } else
            break;
    }
    for (int a = 0; a > -1; ++a) {
        String startline = p.getProperty(a + "alignmentstartline");
        if (startline != null) {
            text.setLineAlignment(Integer.valueOf(startline), 1, Integer.valueOf(p.getProperty(a + "alignment")));
        } else
            break;
    }
}
项目:mesfavoris    文件:StylerProvider.java   
@Override
public void applyStyles(TextStyle textStyle) {
    if (stylerDescriptor.font != null) {
        textStyle.font = stylerDescriptor.font;
    }
    if (stylerDescriptor.foreground != null) {
        textStyle.foreground = stylerDescriptor.foreground;
    }
    if (stylerDescriptor.backGround != null) {
        textStyle.background = stylerDescriptor.backGround;
    }
}
项目:bts    文件:StylerFactory.java   
@Override
public void applyStyles(TextStyle textStyle) {
    textStyle.strikeout = (xtextTextStyle.getStyle() & TextAttribute.STRIKETHROUGH) != 0;
    textStyle.underline = (xtextTextStyle.getStyle() & TextAttribute.UNDERLINE) != 0;
    if (xtextTextStyle.getFontData() == null
            && xtextTextStyle.getStyle() != org.eclipse.xtext.ui.editor.utils.TextStyle.DEFAULT_FONT_STYLE) {
        FontData fontData = new FontData();
        fontData.setStyle(xtextTextStyle.getStyle());
        xtextTextStyle.setFontData(fontData);
    }
    textStyle.font = fontFromFontData(xtextTextStyle.getFontData());
    if (xtextTextStyle.getBackgroundColor() != null) 
        textStyle.background = colorFromRGB(xtextTextStyle.getBackgroundColor());
    textStyle.foreground = colorFromRGB(xtextTextStyle.getColor());
}
项目:bts    文件:StylerFactory.java   
@Override
public void applyStyles(TextStyle textStyle) {
    ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
    if (fontDescriptor != null) {
        textStyle.font = fontDescriptor.createFont(Display.getCurrent());
    }
    if (foregroundColorName != null) {
        textStyle.foreground = colorRegistry.get(foregroundColorName);
    }
    if (backgroundColorName != null) {
        textStyle.background = colorRegistry.get(backgroundColorName);
    }
}
项目:hssd    文件:LPHelper.java   
@Override
public void applyStyles(TextStyle textStyle) {
    textStyle.font = getItalicFont();
    if (textStyle instanceof StyleRange) {
        ((StyleRange) textStyle).fontStyle = SWT.ITALIC;
    }
}
项目:hssd    文件:LPHelper.java   
@Override
public void applyStyles(TextStyle textStyle) {
    textStyle.font = getBoldFont();
    if (textStyle instanceof StyleRange) {
        ((StyleRange) textStyle).fontStyle = SWT.BOLD;
    }
}
项目:hssd    文件:LPHelper.java   
@Override
public void applyStyles(TextStyle textStyle) {
    textStyle.font = getItalicFont();
    textStyle.foreground = getColor(JFacePreferences.DECORATIONS_COLOR);
    if (textStyle instanceof StyleRange) {
        ((StyleRange) textStyle).fontStyle = SWT.ITALIC;
    }
}
项目:SPELL    文件:CustomStyledText.java   
@Override
/**************************************************************************
 * Callback from LineStyleListener interface for the styled text widget.
 * Used to set the text styles (bold, italic, etc)
 *************************************************************************/
public void lineGetStyle(LineStyleEvent event)
{
    /*
     * Icon style range
     */
    // This method basically establishes the glyph metrics required for
    // creating the leading blank space at the beginning of each line,
    // which will allow us to paint the icons later. Besides, the
    // corresponding line model is stored in the style range in order
    // to be utilized later on in paintObject().
    int lineIndex = m_view.getLineAtOffset(event.lineOffset);
    TextViewLine line = (TextViewLine) m_model.getLineObject(lineIndex);
    // We need to create a style rang for each line
    StyleRange bulletStyle = new StyleRange();
    // Reuse the same glyphmetrics, it never changes and we save memory and
    // creation time
    bulletStyle.metrics = s_metrics;
    bulletStyle.start = event.lineOffset;
    // Store the line model that will be used later for painting

    // NOT COMPATIBLE WITH ECLIPSE 3.3 --BEGIN
    // This is the corresponding line index
    // int lineIndex = m_model.getLineAtOffset(event.lineOffset);
    // theStyle.data = (TextViewLine) m_model.getLineObject(lineIndex);
    // NOT COMPATIBLE WITH ECLIPSE 3.3 --END
    event.bullet = new Bullet(ST.BULLET_CUSTOM, bulletStyle);

    TextStyle lineStyle = new TextStyle(null, null, null);
    lineStyle.foreground = m_labelProvider.getForegroundColor(line.getType(), line.getScope());
    StyleRange lineStyleRange = new StyleRange(lineStyle);
    lineStyleRange.start = event.lineOffset;
    lineStyleRange.length = event.lineText.length();
    lineStyleRange.fontStyle = m_labelProvider.getFontStyle(line.getScope());
    event.styles = new StyleRange[] { lineStyleRange };
}
项目:SPELL    文件:SourceRenderer.java   
/***************************************************************************
 * 
 **************************************************************************/
private void drawSearch( GridItem item, GC gc )
{
    SearchMatch match = (SearchMatch) item.getData("DATA_SEARCH_MATCH"); 
    if (match !=null)
    {
        // We will set colors later
        StyleRange range = new StyleRange(match.startOffset, match.length, null, m_hrColor);
           TextStyle original = m_textLayout.getStyle(range.start);
           range.font = original.font;
           range.borderStyle = SWT.BORDER_DOT;
           m_textLayout.setStyle(range, range.start, range.start + range.length);
    }
}
项目:PDFReporter-Studio    文件:NodeBoldStyledLabelProvider.java   
@Override
public void update(ViewerCell cell) {
    Object element = cell.getElement();
    StyledString text = new StyledString();

    if(element instanceof ANode){
        ANode node=(ANode)element;
        if(selectedNodes.contains(node)){
            // bold text
            final Font boldFont = ResourceManager.getBoldFont(getViewer().getControl().getFont());
            text.append(((ANode)element).getDisplayText(), new Styler() {
                @Override
                public void applyStyles(TextStyle textStyle) {
                    textStyle.font=boldFont;
                }
            });
        }
        else{
            // normal text
            text.append(((ANode)element).getDisplayText());             
        }
    }
    else if(element instanceof CustomStyleStatus){
        // normal text
        text.append(((CustomStyleStatus) element).getMessage());
    }

    cell.setText(text.toString());
    cell.setStyleRanges(text.getStyleRanges());
    cell.setImage(getImage(element));
    super.update(cell);
}
项目:PDFReporter-Studio    文件:BoldStyler.java   
@Override
public void applyStyles(TextStyle textStyle) {
    FontData fd = FontUtils.getTextEditorFontData();
    textStyle.font = SWTResourceManager.getBoldFont(SWTResourceManager.getFont(fd.getName(), fd.getHeight(),
            fd.getStyle()));
    ColorRegistry colorRegistry = JFaceResources.getColorRegistry();
    if (fForegroundColorName != null)
        textStyle.foreground = colorRegistry.get(fForegroundColorName);
    if (fBackgroundColorName != null)
        textStyle.background = colorRegistry.get(fBackgroundColorName);
}
项目:eclipse-wtp-json    文件:JFaceNodeAdapterFactory.java   
public void applyStyles(TextStyle textStyle) {
    if (this.fForegroundColorName != null) {
        textStyle.foreground = EditorUtility
                .getColor(fForegroundColorName);
    }
    if (this.fBackgroundColorName != null)
        textStyle.background = EditorUtility
                .getColor(fBackgroundColorName);
}
项目:APICloud-Studio    文件:SnippetsCompletionProcessor.java   
@Override
public void applyStyles(TextStyle textStyle)
{
    if (maxHeightTextFont != null)
    {
        // Use font with limited max height
        textStyle.font = maxHeightTextFont;
    }
    else
    {
        textStyle.font = JFaceResources.getTextFont();
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:FilteredTypesSelectionDialog.java   
private Styler createBoldStyler() {
    return new Styler() {
        @Override
        public void applyStyles(TextStyle textStyle) {
            textStyle.font= getBoldFont();
        }
    };
}
项目:Eclipse-Postfix-Code-Completion    文件:FilteredTypesSelectionDialog.java   
private Styler createBoldQualifierStyler() {
    return new Styler() {
        @Override
        public void applyStyles(TextStyle textStyle) {
            StyledString.QUALIFIER_STYLER.applyStyles(textStyle);
            textStyle.font= getBoldFont();
        }
    };
}
项目:anatlyzer    文件:ProposalCategory.java   
@Override
public void applyStyles(final TextStyle textStyle)
{
    FontData fontData = Display.getCurrent().getSystemFont().getFontData()[0];
    // new FontData()
    FontDescriptor boldDescriptor = FontDescriptor.createFrom(fontData).setStyle(SWT.BOLD);
    Font boldFont = boldDescriptor.createFont(Display.getCurrent());
    textStyle.font = boldFont;
}
项目:translationstudio8    文件:HsMultiCellEditor.java   
/**
 * 根据传入的相关参数获取错误单词的样式   robert  2013-01-22
 * @param style
 * @param start
 * @param length
 * @return
 */
private StyleRange getErrorWordRange(TextStyle style, int start, int length){
    StyleRange range = new StyleRange(style);
    range.start = start;
    range.length = length;
    range.underline = true;
    range.underlineStyle = SWT.UNDERLINE_ERROR;
    range.underlineColor = ColorConfigBean.getInstance().getErrorWordColor();
    return range;
}
项目:translationstudio8    文件:TextPainterWithPadding.java   
private TextLayout getCellTextLayout(LayerCell cell) {
    int orientation = editor.getTable().getStyle() & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT);
    TextLayout layout = new TextLayout(editor.getTable().getDisplay());
    layout.setOrientation(orientation);
    layout.setSpacing(Constants.SEGMENT_LINE_SPACING);
    layout.setFont(font);
    layout.setAscent(ascent);
    layout.setDescent(descent); // 和 StyledTextEditor 同步
    layout.setTabs(new int[] { tabWidth });

    Rectangle rectangle = cell.getBounds();
    int width = rectangle.width - leftPadding - rightPadding;
    width -= 1;
    if (wrapText && width > 0) {
        layout.setWidth(width);
    }

    String displayText = InnerTagUtil.resolveTag(innerTagFactory.parseInnerTag((String) cell.getDataValue()));
    if (XliffEditorParameter.getInstance().isShowNonpirnttingCharacter()) {
        displayText = displayText.replaceAll("\\n", Constants.LINE_SEPARATOR_CHARACTER + "\n");
        displayText = displayText.replaceAll("\\t", Constants.TAB_CHARACTER + "\u200B");
        displayText = displayText.replaceAll(" ", Constants.SPACE_CHARACTER + "\u200B");
    }
    layout.setText(displayText);
    List<InnerTagBean> innerTagBeans = innerTagFactory.getInnerTagBeans();
    for (InnerTagBean innerTagBean : innerTagBeans) {
        String placeHolder = placeHolderBuilder.getPlaceHolder(innerTagBeans, innerTagBeans.indexOf(innerTagBean));
        int start = displayText.indexOf(placeHolder);
        if (start == -1) {
            continue;
        }
        TextStyle style = new TextStyle();
        Point rect = tagRender.calculateTagSize(innerTagBean);
        style.metrics = new GlyphMetrics(rect.y, 0, rect.x + SEGMENT_LINE_SPACING * 2);
        layout.setStyle(style, start, start + placeHolder.length() - 1);
    }

    return layout;
}