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


Java EditorStyleConstants類代碼示例

本文整理匯總了Java中org.netbeans.api.editor.settings.EditorStyleConstants的典型用法代碼示例。如果您正苦於以下問題:Java EditorStyleConstants類的具體用法?Java EditorStyleConstants怎麽用?Java EditorStyleConstants使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EditorStyleConstants類屬於org.netbeans.api.editor.settings包,在下文中一共展示了EditorStyleConstants類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: AnnotationBar

import org.netbeans.api.editor.settings.EditorStyleConstants; //導入依賴的package包/類
/**
 * Creates new instance initializing final fields.
 */
public AnnotationBar(JTextComponent target) {
    this.textComponent = target;
    this.editorUI = Utilities.getEditorUI(target);
    this.foldHierarchy = FoldHierarchy.get(editorUI.getComponent());
    this.doc = editorUI.getDocument();
    setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
    elementAnnotationsSubstitute = "";                              //NOI18N
    if (textComponent instanceof JEditorPane) {
        String mimeType = org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(textComponent);
        FontColorSettings fcs = MimeLookup.getLookup(mimeType).lookup(FontColorSettings.class);
        renderingHints = (Map) fcs.getFontColors(FontColorNames.DEFAULT_COLORING).getAttribute(EditorStyleConstants.RenderingHints);
    } else {
        renderingHints = null;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:AnnotationBar.java

示例2: AnnotationBar

import org.netbeans.api.editor.settings.EditorStyleConstants; //導入依賴的package包/類
/**
 * Creates new instance initializing final fields.
 */
public AnnotationBar(JTextComponent target) {
    this.textComponent = target;
    this.editorUI = Utilities.getEditorUI(target);
    this.foldHierarchy = FoldHierarchy.get(editorUI.getComponent());
    this.doc = editorUI.getDocument();
    if (textComponent instanceof JEditorPane) {
        String mimeType = org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(textComponent);
        FontColorSettings fcs = MimeLookup.getLookup(mimeType).lookup(FontColorSettings.class);
        renderingHints = (Map) fcs.getFontColors(FontColorNames.DEFAULT_COLORING).getAttribute(EditorStyleConstants.RenderingHints);
    } else {
        renderingHints = null;
    }
    setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
    elementAnnotationsSubstitute = "";                              //NOI18N
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:AnnotationBar.java

示例3: VersioningSystemColors

import org.netbeans.api.editor.settings.EditorStyleConstants; //導入依賴的package包/類
public VersioningSystemColors(OptionsPanelColorProvider provider) {
    this.colors = provider.getColors();
    if (colors == null) {
        throw new NullPointerException("Null colors for " + provider); // NOI18N
    }
    this.provider = provider;
    // initialize saved colors list
    savedColorAttributes = new ArrayList<AttributeSet>(colors.size());
    for (Map.Entry<String, Color[]> e : colors.entrySet()) {
        SimpleAttributeSet sas = new SimpleAttributeSet();
        StyleConstants.setBackground(sas, e.getValue()[0]);
        sas.addAttribute(StyleConstants.NameAttribute, e.getKey());
        sas.addAttribute(EditorStyleConstants.DisplayName, e.getKey());
        savedColorAttributes.add(sas);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:AnnotationColorsPanel.java

示例4: getListCellRendererComponent

import org.netbeans.api.editor.settings.EditorStyleConstants; //導入依賴的package包/類
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    setComponentOrientation(list.getComponentOrientation());
    if (isSelected) {
        setBackground(list.getSelectionBackground ());
        setForeground(list.getSelectionForeground ());
    } else {
        setBackground(list.getBackground ());
        setForeground(list.getForeground ());
    }
    setIcon((Icon) ((AttributeSet) value).getAttribute ("icon"));
    setText((String) ((AttributeSet) value).getAttribute (EditorStyleConstants.DisplayName));

    setEnabled(list.isEnabled());
    setFont(list.getFont());
    setBorder(cellHasFocus ? UIManager.getBorder ("List.focusCellHighlightBorder") : noFocusBorder);
    return this;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:CategoryRenderer.java

示例5: testAllColors

import org.netbeans.api.editor.settings.EditorStyleConstants; //導入依賴的package包/類
public void testAllColors() {
    MimePath mimePath = MimePath.parse("text/x-type-A");
    Lookup lookup = MimeLookup.getLookup(mimePath);
    
    FontColorSettings fcs = lookup.lookup(FontColorSettings.class);
    assertNotNull("Can't find FontColorSettings", fcs);
    
    AttributeSet attribs = fcs.getTokenFontColors("test-all");
    assertNotNull("Can't find test-all coloring", attribs);
    assertEquals("Wrong background color", 
        new Color(0x0A0B0C), attribs.getAttribute(StyleConstants.Background));
    assertEquals("Wrong foreground color", 
        new Color(0x0D0E0F), attribs.getAttribute(StyleConstants.Foreground));
    assertEquals("Wrong underline color", 
        new Color(0x010203), attribs.getAttribute(StyleConstants.Underline));
    assertEquals("Wrong strikeThrough color", 
        new Color(0x040506), attribs.getAttribute(StyleConstants.StrikeThrough));
    assertEquals("Wrong waveUnderline color", 
        new Color(0x070809), attribs.getAttribute(EditorStyleConstants.WaveUnderlineColor));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:EditorSettingsStorageTest.java

示例6: getListCellRendererComponent

import org.netbeans.api.editor.settings.EditorStyleConstants; //導入依賴的package包/類
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    setComponentOrientation(list.getComponentOrientation());
    if (isSelected) {
        setBackground(list.getSelectionBackground ());
        setForeground(list.getSelectionForeground ());
    } else {
        setBackground(list.getBackground ());
        setForeground(list.getForeground ());
    }
    setIcon((Icon) ((AttributeSet) value).getAttribute ("icon"));
    setText((String) ((AttributeSet) value).getAttribute (EditorStyleConstants.DisplayName));

    setEnabled(list.isEnabled());
    setFont(list.getFont());
    setBorder(cellHasFocus ? UIManager.getBorder ("List.focusCellHighlightBorder") : noFocusBorder);
    return this;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:18,代碼來源:CategoryRenderer.java

示例7: testAllLanguagesTheCrapWay

import org.netbeans.api.editor.settings.EditorStyleConstants; //導入依賴的package包/類
public void testAllLanguagesTheCrapWay() {
    Collection<AttributeSet> colorings = EditorSettings.getDefault().getFontColorSettings(new String[0]).getAllFontColors(EditorSettingsImpl.DEFAULT_PROFILE);
    assertNotNull("Can't get colorings for all languages", colorings);
    
    AttributeSet attribs = null;
    for(AttributeSet coloring : colorings) {
        String name = (String) coloring.getAttribute(StyleConstants.NameAttribute);
        if (name != null && name.equals("test-all-languages-set-all")) {
            attribs = coloring;
            break;
        }
    }
    
    assertNotNull("Can't find test-all-languages-set-all coloring", attribs);
    assertEquals("Wrong color", new Color(0x0A0B0C), attribs.getAttribute(StyleConstants.Background));
    assertEquals("Wrong color", new Color(0x0D0E0F), attribs.getAttribute(StyleConstants.Foreground));
    assertEquals("Wrong color", new Color(0x010203), attribs.getAttribute(StyleConstants.Underline));
    assertEquals("Wrong color", new Color(0x040506), attribs.getAttribute(StyleConstants.StrikeThrough));
    assertEquals("Wrong color", new Color(0x070809), attribs.getAttribute(EditorStyleConstants.WaveUnderlineColor));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:FontColorSettingsImplTest.java

示例8: getTooltipFromHighlightingLayers

import org.netbeans.api.editor.settings.EditorStyleConstants; //導入依賴的package包/類
private CharSequence getTooltipFromHighlightingLayers() {
    // Read tooltip from highlighting layers attribute
    CharSequence tooltipFromHighlightingLayers = null;
    {
        if (tooltipAttributeValue != null) {
            if (tooltipAttributeValue instanceof String) {
                tooltipFromHighlightingLayers = (String) tooltipAttributeValue;
            } else if (tooltipAttributeValue instanceof HighlightAttributeValue) {
                @SuppressWarnings("unchecked") //NOI18N
                CharSequence value = ((HighlightAttributeValue<CharSequence>) tooltipAttributeValue).getValue(
                    component, doc, EditorStyleConstants.Tooltip, offset, offset + 1);
                tooltipFromHighlightingLayers = value;
            } else {
                LOG.fine("Invalid '" + EditorStyleConstants.Tooltip + "' attribute value " + tooltipAttributeValue); //NOI18N
            }
        }
    }

    return tooltipFromHighlightingLayers;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:NbToolTip.java

示例9: checkMaps

import org.netbeans.api.editor.settings.EditorStyleConstants; //導入依賴的package包/類
private boolean checkMaps(String languageName, Map<String, AttributeSet> savedMap, Map<String, AttributeSet> currentMap) {
    boolean isChanged = false;
    for (String name : savedMap.keySet()) {
        if (currentMap.containsKey(name)) {
            AttributeSet currentAS = currentMap.get(name);
            AttributeSet savedAS = savedMap.get(name);
            isChanged |= isFontChanged(languageName, currentAS, savedAS)
                    || (Color) currentAS.getAttribute(StyleConstants.Foreground) != (Color) savedAS.getAttribute(StyleConstants.Foreground)
                    || (Color) currentAS.getAttribute(StyleConstants.Background) != (Color) savedAS.getAttribute(StyleConstants.Background)
                    || (Color) currentAS.getAttribute(StyleConstants.Underline) != (Color) savedAS.getAttribute(StyleConstants.Underline)
                    || (Color) currentAS.getAttribute(StyleConstants.StrikeThrough) != (Color) savedAS.getAttribute(StyleConstants.StrikeThrough)
                    || (Color) currentAS.getAttribute(EditorStyleConstants.WaveUnderlineColor) != (Color) savedAS.getAttribute(EditorStyleConstants.WaveUnderlineColor);
            if(isChanged) { // no need to iterate further
                return true;
            }
        }
    }
    return isChanged;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:SyntaxColoringPanel.java

示例10: checkMaps

import org.netbeans.api.editor.settings.EditorStyleConstants; //導入依賴的package包/類
private boolean checkMaps(Map<String, AttributeSet> savedMap, Map<String, AttributeSet> currentMap) {
    boolean isChanged = false;
    for (String name : savedMap.keySet()) {
        if (currentMap.containsKey(name)) {
            AttributeSet currentAS = currentMap.get(name);
            AttributeSet savedAS = savedMap.get(name);
            Color currentForeground = (Color) currentAS.getAttribute(StyleConstants.Foreground);
            Color savedForeground = (Color) savedAS.getAttribute(StyleConstants.Foreground);
            Color currentBackground = (Color) currentAS.getAttribute(StyleConstants.Background);
            Color savedBackground = (Color) savedAS.getAttribute(StyleConstants.Background);
            Color currentWave = (Color) currentAS.getAttribute(EditorStyleConstants.WaveUnderlineColor);
            Color savedWave = (Color) savedAS.getAttribute(EditorStyleConstants.WaveUnderlineColor);
            isChanged |= (currentForeground == null ? savedForeground != null : !currentForeground.equals(savedForeground))
                    || (currentBackground == null ? savedBackground != null : !currentBackground.equals(savedBackground))
                    || (currentWave == null ? savedWave != null : !currentWave.equals(savedWave));
            if(isChanged) { // no need to iterate further
                return true;
            }
        }
    }
    return isChanged;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:AnnotationsPanel.java

示例11: checkMaps

import org.netbeans.api.editor.settings.EditorStyleConstants; //導入依賴的package包/類
private boolean checkMaps(Map<String, AttributeSet> savedMap, Map<String, AttributeSet> currentMap) {
    boolean isChanged = false;
    for (String name : savedMap.keySet()) {
        if (currentMap.containsKey(name)) {
            AttributeSet currentAS = currentMap.get(name);
            AttributeSet savedAS = savedMap.get(name);
            isChanged |= (Color) currentAS.getAttribute(StyleConstants.Foreground) != (Color) savedAS.getAttribute(StyleConstants.Foreground)
                    || (Color) currentAS.getAttribute(StyleConstants.Background) != (Color) savedAS.getAttribute(StyleConstants.Background)
                    || (Color) currentAS.getAttribute(StyleConstants.Underline) != (Color) savedAS.getAttribute(StyleConstants.Underline)
                    || (Color) currentAS.getAttribute(StyleConstants.StrikeThrough) != (Color) savedAS.getAttribute(StyleConstants.StrikeThrough)
                    || (Color) currentAS.getAttribute(EditorStyleConstants.WaveUnderlineColor) != (Color) savedAS.getAttribute(EditorStyleConstants.WaveUnderlineColor);
            
        }
    }
    return isChanged;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:HighlightingPanel.java

示例12: makeHyperlink

import org.netbeans.api.editor.settings.EditorStyleConstants; //導入依賴的package包/類
private synchronized void makeHyperlink(HyperlinkType type, HyperlinkProviderExt provider, final int start, final int end, final int offset) {
    boolean makeCursorSnapshot = true;
    
    if (hyperlinkUp) {
        unHyperlink(false);
        makeCursorSnapshot = false;
    }
    
    OffsetsBag prepare = new OffsetsBag(component.getDocument());

    FontColorSettings fcs = MimeLookup.getLookup(MimePath.EMPTY).lookup(FontColorSettings.class);
    AttributeSet hyperlinksHighlight = fcs.getFontColors("hyperlinks"); //NOI18N
    prepare.addHighlight(start, end, AttributesUtilities.createComposite(
        hyperlinksHighlight != null ? hyperlinksHighlight : defaultHyperlinksHighlight,
        AttributesUtilities.createImmutable(EditorStyleConstants.Tooltip, new TooltipResolver(provider, offset, type))));

    getBag(currentDocument).setHighlights(prepare);

    hyperlinkUp = true;

    if (makeCursorSnapshot) {
        if (component.isCursorSet()) {
            oldComponentsMouseCursor = component.getCursor();
        } else {
            oldComponentsMouseCursor = null;
        }
        component.setCursor(getMouseCursor(type));
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:30,代碼來源:HyperlinkOperation.java

示例13: updateComponentProperties

import org.netbeans.api.editor.settings.EditorStyleConstants; //導入依賴的package包/類
/**
 * Update various properties of the component in AWT thread.
 */
void updateComponentProperties() {

    // Refresh rendering hints
    String mimeType = org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(component);
    FontColorSettings fcs = MimeLookup.getLookup(mimeType).lookup(FontColorSettings.class);
    renderingHints = (Map<?, ?>) fcs.getFontColors(FontColorNames.DEFAULT_COLORING).getAttribute(EditorStyleConstants.RenderingHints);
    
    // Set the margin
    String value = prefs.get(SimpleValueNames.MARGIN, null);
    Insets margin = value != null ? SettingsConversions.parseInsets(value) : null;
    component.setMargin(margin != null ? margin : NULL_INSETS);

    lineNumberDigitWidth = computeLineNumberDigitWidth();

    // Update line height
    updateLineHeight(getComponent());

    // Update space width of the default coloring's font
    FontMetricsCache.Info fmcInfo = FontMetricsCache.getInfo(getDefaultColoring().getFont());
    defaultSpaceWidth = fmcInfo.getSpaceWidth(component);

    updateLineNumberWidth(0);

    // update glyph gutter colors and fonts
    if (isGlyphGutterVisible()) {
        glyphGutter.update();
        updateScrollPaneCornerColor();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:33,代碼來源:EditorUI.java

示例14: updateRenderingHints

import org.netbeans.api.editor.settings.EditorStyleConstants; //導入依賴的package包/類
private void updateRenderingHints(Graphics g){
    JTextComponent comp = editorUI.getComponent();
    if (comp != null) {
        String mimeType = org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(comp);
        FontColorSettings fcs = MimeLookup.getLookup(mimeType).lookup(FontColorSettings.class);
        Map renderingHints = (Map) fcs.getFontColors(FontColorNames.DEFAULT_COLORING).getAttribute(EditorStyleConstants.RenderingHints);

        // Possibly apply the rendering hints
        if (renderingHints != null) {
            ((java.awt.Graphics2D)g).addRenderingHints(renderingHints);
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:FoldingToolTip.java

示例15: fromAttributeSet

import org.netbeans.api.editor.settings.EditorStyleConstants; //導入依賴的package包/類
/**
 * Converts <code>AttributeSet</code> to a <code>Coloring</code>. This method
 * will extract any font related information as well as the 'well-known' colors
 * from the <code>AttributeSet</code> passed in and will use them for creating
 * a <code>Coloring</code> instance that will be returned.
 * 
 * <p>The list of supported colors:
 * <ul>
 * <li><code>StyleConstants.Foreground</code>
 * <li><code>StyleConstants.Background</code>
 * <li><code>StyleConstants.Underline</code>
 * <li><code>StyleConstants.StrikeThrough</code>
 * <li><code>EditorStyleConstants.WaveUnderlineColor</code>
 * </ul>
 * 
 * @param as The <code>AttributeSet</code> to convert.
 * 
 * @return <code>Coloring</code> that will contain font and color information
 * from the supplied <code>AttributeSet</code>.
 * @since 1.11
 */
public static Coloring fromAttributeSet(AttributeSet as) {
    synchronized (colorings) {
        Coloring coloring = colorings.get(as);

        if (coloring == null) {
            Object [] fontObj = toFont(as);
            Color foreColor = (Color) as.getAttribute(StyleConstants.Foreground);
            // Deal StrikeThrough to be either Boolean or Color
            Object strikeThrough = as.getAttribute(StyleConstants.StrikeThrough);
            if (strikeThrough instanceof Boolean) {
                strikeThrough = Boolean.TRUE.equals(strikeThrough)
                        ? foreColor
                        : null;
            }

            coloring = new Coloring(
                (Font) fontObj[0],
                ((Integer) fontObj[1]).intValue(),
                foreColor,
                (Color) as.getAttribute(StyleConstants.Background),
                (Color) as.getAttribute(StyleConstants.Underline),
                (Color) strikeThrough,
                (Color) as.getAttribute(EditorStyleConstants.WaveUnderlineColor),
                (Color) as.getAttribute(EditorStyleConstants.TopBorderLineColor),
                (Color) as.getAttribute(EditorStyleConstants.RightBorderLineColor),
                (Color) as.getAttribute(EditorStyleConstants.BottomBorderLineColor),
                (Color) as.getAttribute(EditorStyleConstants.LeftBorderLineColor)
            );

            colorings.put(as, coloring);
        }

        return coloring;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:57,代碼來源:Coloring.java


注:本文中的org.netbeans.api.editor.settings.EditorStyleConstants類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。