Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
282,000
SimpleTextAttributes () { return myStack.peek().second; }
peek
282,001
SimpleTextAttributes (javax.swing.text.html.HTML.Tag tag, MutableAttributeSet attr) { SimpleTextAttributes styleAttributes = parseStyleIfPossible(attr); if (tag == DIV || tag == SPAN) return styleAttributes; SimpleTextAttributes tagAttributes = null; if (tag == B) tagAttributes = REGULAR_ATTRIBUTES; if (tag == I) tagAttributes = REGULAR_ITALIC_ATTRIBUTES; if (tag == U) tagAttributes = new SimpleTextAttributes(STYLE_UNDERLINE, null); if (tag == S) tagAttributes = new SimpleTextAttributes(STYLE_STRIKEOUT, null); if (tag == A) tagAttributes = LINK_PLAIN_ATTRIBUTES; if (tagAttributes != null && styleAttributes != null) { return merge(tagAttributes, styleAttributes); } return tagAttributes; }
calcAttributes
282,002
SimpleTextAttributes (MutableAttributeSet attr) { Object attribute = attr.getAttribute(STYLE); if (attribute == null) return null; String styleStr = attribute.toString(); Map<String, String> styles = Arrays.stream(styleStr.split("\\s*;\\s*")) .map(s -> s.split("\\s*:\\s*")) .collect(Collectors.toMap(s -> s[0], s -> s[1])); String colorString = styles.get("color"); String backgroundString = styles.get("background-color"); return new SimpleTextAttributes(parseColor(backgroundString), parseColor(colorString), null, STYLE_PLAIN); }
parseStyleIfPossible
282,003
Color (String colorStr) { if (colorStr == null) return null; colorStr = StringUtil.trimStart(colorStr, "#"); if (colorStr.length() != 6) return null; return ColorUtil.fromHex(colorStr); }
parseColor
282,004
JScrollPane () { return new JBScrollPane(); }
createScrollPane
282,005
JScrollPane (Component view) { return new JBScrollPane(view); }
createScrollPane
282,006
JScrollPane (@JdkConstants.VerticalScrollBarPolicy int vsbPolicy, @JdkConstants.HorizontalScrollBarPolicy int hsbPolicy) { return new JBScrollPane(vsbPolicy, hsbPolicy); }
createScrollPane
282,007
JScrollPane (Component view, @JdkConstants.VerticalScrollBarPolicy int vsbPolicy, @JdkConstants.HorizontalScrollBarPolicy int hsbPolicy) { return new JBScrollPane(view, vsbPolicy, hsbPolicy); }
createScrollPane
282,008
JScrollPane (Component view, boolean withoutBorder) { JBScrollPane scrollPane = new JBScrollPane(view); if (withoutBorder) { scrollPane.setBorder(JBUI.Borders.empty()); // set empty border, because setting null doesn't always take effect scrollPane.setViewportBorder(JBUI.Borders.empty()); } return scrollPane; }
createScrollPane
282,009
boolean () { return ExperimentalUI.isNewUI(); }
isEnabled
282,010
void () { GraphicsUtil.setAntialiasingType(this, AntialiasingType.getAAHintForSwingComponent()); Object value = UIManager.getDefaults().get(RenderingHints.KEY_FRACTIONALMETRICS); if (value == null) value = RenderingHints.VALUE_FRACTIONALMETRICS_OFF; putClientProperty(RenderingHints.KEY_FRACTIONALMETRICS, value); }
updateUI
282,011
ColoredIterator () { return new MyIterator(); }
iterator
282,012
ColoredIterator (int fromIndex) { MyIterator iterator = new MyIterator(); iterator.myIndex = fromIndex - 1; return iterator; }
iterator
282,013
boolean () { return myIconOnTheRight; }
isIconOnTheRight
282,014
void (boolean iconOnTheRight) { myIconOnTheRight = iconOnTheRight; }
setIconOnTheRight
282,015
SimpleColoredComponent (@NotNull @Nls String fragment) { append(fragment, SimpleTextAttributes.REGULAR_ATTRIBUTES); return this; }
append
282,016
SimpleColoredComponent (@NotNull @Nls String fragment, @Nullable FragmentTextClipper clipper) { return appendWithClipping(fragment, SimpleTextAttributes.REGULAR_ATTRIBUTES, clipper); }
appendWithClipping
282,017
SimpleColoredComponent (@NotNull @Nls String fragment, final @NotNull SimpleTextAttributes attributes, @Nullable FragmentTextClipper clipper) { _append(fragment, attributes, clipper, myMainTextLastIndex < 0); revalidateAndRepaint(); return this; }
appendWithClipping
282,018
void (@NotNull @Nls String fragment, final @NotNull SimpleTextAttributes attributes) { append(fragment, attributes, myMainTextLastIndex < 0); }
append
282,019
void (@NotNull @Nls String fragment, final @NotNull SimpleTextAttributes attributes, int padding, @JdkConstants.HorizontalAlignment int align) { append(fragment, attributes, myMainTextLastIndex < 0); appendTextPadding(padding, align); }
append
282,020
void (@NotNull @Nls String fragment, final @NotNull SimpleTextAttributes attributes, boolean isMainText) { _append(fragment, attributes, null, isMainText); revalidateAndRepaint(); }
append
282,021
void (@NotNull @Nls String fragment, final @NotNull SimpleTextAttributes attributes, @Nullable FragmentTextClipper clipper, boolean isMainText) { synchronized (myFragments) { myCurrentFragment = new ColoredFragment(fragment, attributes, this, clipper); myFragments.add(myCurrentFragment); if (isMainText) { myMainTextLastIndex = myFragments.size() - 1; } } }
_append
282,022
void () { firePropertyChange("state", null, this); if (myAutoInvalidate) { revalidate(); } repaint(); }
revalidateAndRepaint
282,023
void (@NotNull @Nls String fragment, final @NotNull SimpleTextAttributes attributes, Object tag) { _append(fragment, attributes, tag); revalidateAndRepaint(); }
append
282,024
void (@Nls String fragment, SimpleTextAttributes attributes, Object tag) { synchronized (myFragments) { append(fragment, attributes); if (tag != null) myCurrentFragment.tag = tag; } }
_append
282,025
void (int padding) { appendTextPadding(padding, SwingConstants.LEFT); }
appendTextPadding
282,026
void (@Nls String html, SimpleTextAttributes baseAttributes) { new HtmlToSimpleColoredComponentConverter().appendHtml(this, html, baseAttributes); }
appendHTML
282,027
void (int padding, @JdkConstants.HorizontalAlignment int align) { synchronized (myFragments) { if (myCurrentFragment != null) { myCurrentFragment.padding = padding; myCurrentFragment.alignment = align; } } }
appendTextPadding
282,028
void (@JdkConstants.HorizontalAlignment int align) { myTextAlign = align; }
setTextAlign
282,029
void () { _clear(); revalidateAndRepaint(); }
clear
282,030
void () { synchronized (myFragments) { myIcon = null; myPaintFocusBorder = false; myFragments.clear(); myCurrentFragment = null; myMainTextLastIndex = -1; } }
_clear
282,031
Icon () { return myIcon; }
getIcon
282,032
void (final @Nullable Icon icon) { if (!Objects.equals(icon, myIcon)) { myIcon = icon; revalidateAndRepaint(); } }
setIcon
282,033
Insets () { return myIpad; }
getIpad
282,034
void (@NotNull Insets ipad) { myIpad = ipad; revalidateAndRepaint(); }
setIpad
282,035
int () { return myIconTextGap; }
getIconTextGap
282,036
void (final int iconTextGap) { if (iconTextGap < 0) { throw new IllegalArgumentException("wrong iconTextGap: " + iconTextGap); } myIconTextGap = iconTextGap; revalidateAndRepaint(); }
setIconTextGap
282,037
Border () { return myBorder; }
getMyBorder
282,038
void (@Nullable Border border) { myBorder = border; }
setMyBorder
282,039
void (final boolean paintFocusBorder) { if (myPaintFocusBorder == paintFocusBorder) return; myPaintFocusBorder = paintFocusBorder; repaint(); }
setPaintFocusBorder
282,040
void (final boolean focusBorderAroundIcon) { if (myFocusBorderAroundIcon == focusBorderAroundIcon) return; myFocusBorderAroundIcon = focusBorderAroundIcon; repaint(); }
setFocusBorderAroundIcon
282,041
boolean () { return myIconOpaque; }
isIconOpaque
282,042
void (final boolean iconOpaque) { if (myIconOpaque == iconOpaque) return; myIconOpaque = iconOpaque; repaint(); }
setIconOpaque
282,043
Dimension () { return computePreferredSize(false); }
getPreferredSize
282,044
Dimension () { if (isMinimumSizeSet()) return super.getMinimumSize(); return computePreferredSize(false); }
getMinimumSize
282,045
int () { synchronized (myFragments) { return myFragments.size(); } }
getFragmentCount
282,046
Dimension (final boolean mainTextOnly) { synchronized (myFragments) { // Calculate width float width = myIpad.left; if (myIcon != null) { width += myIcon.getIconWidth() + myIconTextGap; } final Insets borderInsets = myBorder != null ? myBorder.getBorderInsets(this) : JBInsets.emptyInsets(); width += borderInsets.left; Font font = getBaseFont(); width += computeTextWidth(font, mainTextOnly); width += myIpad.right + borderInsets.right; // Take into account that the component itself can have a border final Insets insets = getInsets(); if (insets != null) { width += insets.left + insets.right; } int height = computePreferredHeight(); return new Dimension((int)Math.ceil(width), height); } }
computePreferredSize
282,047
int () { return JBUIScale.scale(16); }
getMinHeight
282,048
Rectangle () { Rectangle area = new Rectangle(getWidth(), getHeight()); JBInsets.removeFrom(area, getInsets()); JBInsets.removeFrom(area, myIpad); return area; }
computePaintArea
282,049
float (@NotNull Font font, boolean mainTextOnly) { float result = 0; int baseSize = font.getSize(); boolean wasSmaller = false; for (int i = 0; i < myFragments.size(); i++) { ColoredFragment fragment = myFragments.get(i); SimpleTextAttributes attributes = fragment.attributes; boolean isSmaller = attributes.isSmaller(); if (font.getStyle() != attributes.getFontStyle() || isSmaller != wasSmaller) { // derive font only if it is necessary font = deriveFont(font, attributes.getFontStyle(), isSmaller ? UIUtil.getFontSize(UIUtil.FontSize.SMALL) : baseSize); } wasSmaller = isSmaller; result += computeStringWidth(fragment, i, font); final int fixedWidth = fragment.padding; if (fixedWidth > 0 && result < fixedWidth) { result = fixedWidth; } if (mainTextOnly && myMainTextLastIndex >= 0 && i == myMainTextLastIndex) break; } return result; }
computeTextWidth
282,050
Font () { Font font = getFont(); if (font == null) font = StartupUiUtil.getLabelFont(); return font; }
getBaseFont
282,051
FontRenderContext (Font font) { FontRenderContext frc = getFontMetrics(font).getFontRenderContext(); Font baseFont = getBaseFont(); if (!baseFont.equals(myLayoutFont) || !frc.equals(myLayoutFRC)) { myFragments.forEach(ColoredFragment::invalidateLayout); myLayoutFont = new ImmutableFont(baseFont); myLayoutFRC = frc; } return frc; }
getFontRenderContext
282,052
void (Graphics2D g, @NotNull ColoredFragment fragment, int fragmentIndex, float x, float y) { String text = fragment.text; if (StringUtil.isEmpty(text)) return; Font font = g.getFont(); FontRenderContext frc = getFontRenderContext(font); fragment.getAndCacheRenderer(font, frc).draw(g, fragmentIndex, x, y); }
doDrawString
282,053
float (@NotNull ColoredFragment fragment, int index, Font font) { if (StringUtil.isEmpty(fragment.text)) return 0; if (myFragments.get(index) != fragment) { return 0; // assertion? } ColoredFragment nextFragment = index < myFragments.size() - 1 ? myFragments.get(index + 1) : null; FontRenderContext frc = getFontRenderContext(font); if (!SystemInfo.isMacOSCatalina || !fragment.attributes.isSearchMatch() || nextFragment == null || fragment.attributes.getFontStyle() != nextFragment.attributes.getFontStyle()) { return getFragmentWidth(fragment, font, frc); } float first = getFragmentWidth(fragment, font, frc); float second = getFragmentWidth(nextFragment, font, frc); float compound = getFragmentWidth(new ColoredFragment(fragment.text + nextFragment.text, fragment.attributes, this, null), font, frc); //return Math.min(w1, w3 - w2); //return (w1 + (w3 - w2)) / 2; return (first + 2 * (compound - second)) / 3; }
computeStringWidth
282,054
float (@NotNull ColoredFragment fragment, Font font, FontRenderContext frc) { WidthKey key = new WidthKey(fragment.text, new ImmutableFont(font), frc, fragment.attributes.getStyle(), font.getSize()); return widthCache.get(key, it -> fragment.getAndCacheRenderer(it.font, it.frc).getWidth()); }
getFragmentWidth
282,055
TextLayout (String text, Font basefont, FontRenderContext fontRenderContext) { AttributedString string = new AttributedString(text); int length = text.length(); Font currentFont = basefont; int currentIndex = 0; for (int pos = 0; pos < length; pos = text.offsetByCodePoints(pos, 1)) { int codePoint = text.codePointAt(pos); Font font = basefont; if (!font.canDisplay(codePoint)) { for (SuitableFontProvider provider : SuitableFontProvider.EP_NAME.getExtensionsIfPointIsRegistered()) { font = provider.getFontAbleToDisplay(codePoint, basefont.getSize(), basefont.getStyle(), basefont.getFamily()); if (font != null) break; } } if (!Comparing.equal(currentFont, font)) { if (pos > currentIndex) { string.addAttribute(TextAttribute.FONT, currentFont, currentIndex, pos); } currentFont = font; currentIndex = pos; } } if (currentIndex < length) { string.addAttribute(TextAttribute.FONT, currentFont, currentIndex, length); } return new TextLayout(string.getIterator(), fontRenderContext); }
createTextLayout
282,056
boolean (Font font, String text) { return font.canDisplayUpTo(text) != -1 && text.indexOf(CharacterIterator.DONE) == -1; // see IDEA-137517, TextLayout does not support this character }
needFontFallback
282,057
int (int x) { float curX = myIpad.left; //added even if no icon, see com.intellij.ui.SimpleColoredComponent.doPaintText if (myBorder != null) { curX += myBorder.getBorderInsets(this).left; } curX += getInsets().left; if (myIcon != null && !myIconOnTheRight) { final int iconRight = myIcon.getIconWidth() + myIconTextGap; if (x < iconRight) { return FRAGMENT_ICON; } curX += iconRight; } Font font = getBaseFont(); int baseSize = font.getSize(); boolean wasSmaller = false; synchronized (myFragments) { curX += computeTextAlignShift(); for (int i = 0; i < myFragments.size(); i++) { ColoredFragment fragment = myFragments.get(i); SimpleTextAttributes attributes = fragment.attributes; boolean isSmaller = attributes.isSmaller(); if (font.getStyle() != attributes.getFontStyle() || isSmaller != wasSmaller) { // derive font only if it is necessary font = deriveFont(font, attributes.getFontStyle(), isSmaller ? UIUtil.getFontSize(UIUtil.FontSize.SMALL) : baseSize); } wasSmaller = isSmaller; float curWidth = computeStringWidth(fragment, i, font); if (x >= curX && x < curX + curWidth) { return i; } curX += curWidth; final int fragmentPadding = fragment.padding; if (fragmentPadding > 0 && curX < fragmentPadding) { curX = fragmentPadding; } } } if (myIcon != null && myIconOnTheRight) { curX += myIconTextGap + myIpad.left; if (x >= curX && x < curX + myIcon.getIconWidth()) { return FRAGMENT_ICON; } } return -1; }
findFragmentAt
282,058
JLabel (@NotNull JLabel label) { label.setIcon(myIcon); synchronized (myFragments) { if (!myFragments.isEmpty()) { @Nls StringBuilder sb = new StringBuilder(); sb.append("<html><body style=\"white-space:nowrap\">"); for (ColoredFragment fragment : myFragments) { final String text = fragment.text; final SimpleTextAttributes attributes = fragment.attributes; final Object tag = fragment.tag; if (tag instanceof BrowserLauncherTag) { formatLink(sb, text, attributes, ((BrowserLauncherTag)tag).myUrl); } else { formatText(sb, text, attributes); } } sb.append("</body></html>"); label.setText(sb.toString()); } } return label; }
formatToLabel
282,059
void (@NotNull StringBuilder builder, @NotNull String fragment, @NotNull SimpleTextAttributes attributes) { if (!fragment.isEmpty()) { builder.append("<span"); formatStyle(builder, attributes); builder.append('>').append(convertFragment(fragment)).append("</span>"); } }
formatText
282,060
void (@NotNull StringBuilder builder, @NotNull String fragment, @NotNull SimpleTextAttributes attributes, @NotNull String url) { if (!fragment.isEmpty()) { builder.append("<a href=\"").append(StringUtil.replace(url, "\"", "%22")).append("\""); formatStyle(builder, attributes); builder.append('>').append(convertFragment(fragment)).append("</a>"); } }
formatLink
282,061
String (@NotNull String fragment) { return StringUtil.escapeXmlEntities(fragment).replaceAll("\\\\n", "<br>"); }
convertFragment
282,062
void (final StringBuilder builder, final SimpleTextAttributes attributes) { final Color fgColor = attributes.getFgColor(); final Color bgColor = attributes.getBgColor(); final int style = attributes.getStyle(); final int pos = builder.length(); if (fgColor != null) { builder.append("color:").append(ColorUtil.toHtmlColor(fgColor)).append(';'); } if (bgColor != null) { builder.append("background-color:").append(ColorUtil.toHtmlColor(bgColor)).append(';'); } if ((style & SimpleTextAttributes.STYLE_BOLD) != 0) { builder.append("font-weight:bold;"); } if ((style & SimpleTextAttributes.STYLE_ITALIC) != 0) { builder.append("font-style:italic;"); } if ((style & SimpleTextAttributes.STYLE_UNDERLINE) != 0) { builder.append("text-decoration:underline;"); } else if ((style & SimpleTextAttributes.STYLE_STRIKEOUT) != 0) { builder.append("text-decoration:line-through;"); } if (builder.length() > pos) { builder.insert(pos, " style=\""); builder.append('"'); } }
formatStyle
282,063
void (final Graphics g) { try { doPaint((Graphics2D)g); } catch (ProcessCanceledException pce) { throw pce; } catch (RuntimeException e) { LOG.error(logSwingPath(), e); throw e; } }
paintComponent
282,064
void (final Graphics2D g) { synchronized (myFragments) { int offset = 0; final Icon icon = myIcon; // guard against concurrent modification (IDEADEV-12635) if (icon != null && !myIconOnTheRight) { doPaintIcon(g, icon, 0); offset += myIpad.left + icon.getIconWidth() + myIconTextGap; } doPaintTextBackground(g, offset); offset = doPaintText(g, offset, myFocusBorderAroundIcon || icon == null) + myIconTextGap; if (icon != null && myIconOnTheRight) { doPaintIcon(g, icon, offset); } } }
doPaint
282,065
void (Graphics2D g, int offset) { if (isOpaque() || shouldDrawBackground()) { paintBackground(g, offset, getWidth() - offset, getHeight()); } }
doPaintTextBackground
282,066
void (Graphics2D g, int x, int width, int height) { g.setColor(getBackground()); g.fillRect(x, 0, width, height); }
paintBackground
282,067
void (@NotNull Graphics2D g, @NotNull Icon icon, int offset) { final Container parent = getParent(); Color iconBackgroundColor = null; if ((isOpaque() || isIconOpaque()) && !isTransparentIconBackground()) { if (parent != null && !myFocusBorderAroundIcon && !UIUtil.isFullRowSelectionLAF()) { iconBackgroundColor = parent.getBackground(); } else { iconBackgroundColor = getBackground(); } } if (iconBackgroundColor != null) { g.setColor(iconBackgroundColor); g.fillRect(offset, 0, icon.getIconWidth() + myIpad.left + myIconTextGap, getHeight()); } paintIcon(g, icon, offset + myIpad.left); }
doPaintIcon
282,068
int (Graphics2D g, int textStart, boolean focusAroundIcon) { synchronized (myFragments) { // If there is no icon, then we have to add left internal padding if (textStart == 0) { textStart = myIpad.left; } float offset = textStart; if (myBorder != null) { offset += myBorder.getBorderInsets(this).left; } offset += getInsets().left; final class Frag { private final int index; private final float start; private final float end; private final float baseLine; private final Font font; private final Frag next; private Frag(int index, float start, float end, float baseLine, @NotNull Font font, Frag next) { this.index = index; this.start = start; this.end = end; this.baseLine = baseLine; this.font = font; this.next = next; } } int height = getHeight(); applyAdditionalHints(g); final Font baseFont = getBaseFont(); g.setFont(baseFont); offset += computeTextAlignShift(); int baseSize = baseFont.getSize(); FontMetrics baseMetrics = g.getFontMetrics(); Rectangle area = computePaintArea(); final int textBaseline = area.y + getTextBaseLine(baseMetrics, area.height); boolean wasSmaller = false; Frag secondPassFrag = null; for (int i = 0; i < myFragments.size(); i++) { ColoredFragment fragment = myFragments.get(i); final SimpleTextAttributes attributes = fragment.attributes; Font font = g.getFont(); boolean isSmaller = attributes.isSmaller(); if (font.getStyle() != attributes.getFontStyle() || isSmaller != wasSmaller) { // derive font only if it is necessary font = deriveFont(font, attributes.getFontStyle(), isSmaller ? UIUtil.getFontSize(UIUtil.FontSize.SMALL) : baseSize); } wasSmaller = isSmaller; g.setFont(font); final FontMetrics metrics = g.getFontMetrics(font); float fragmentWidth = computeStringWidth(fragment, i, font); final int fragmentPadding = fragment.padding; boolean secondPass = attributes.isSearchMatch() || attributes.isClickable(); final Color bgColor = secondPass ? null : attributes.getBgColor(); if ((attributes.isOpaque() || isOpaque()) && bgColor != null) { doPaintFragmentBackground(g, i, bgColor, (int)offset, 0, (int)fragmentWidth, height); } Color color; color = isEnabled() ? getActiveTextColor(attributes.getFgColor()) : NamedColorUtil.getInactiveTextColor(); g.setColor(color); final int fragmentAlignment = fragment.alignment; final float endOffset; if (fragmentPadding > 0 && fragmentPadding > fragmentWidth) { endOffset = fragmentPadding; if (fragmentAlignment == SwingConstants.RIGHT || fragmentAlignment == SwingConstants.TRAILING) { offset = fragmentPadding - fragmentWidth; } } else { endOffset = offset + fragmentWidth; } if (offset < area.getMaxX()) { if (!secondPass) { if (shouldDrawDimmed()) { color = ColorUtil.dimmer(color); } g.setColor(color); doDrawString(g, fragment, i, offset, textBaseline); // for some reason strokeState here may be incorrect, resetting the stroke helps g.setStroke(g.getStroke()); drawTextAttributes(g, attributes, (int)offset, textBaseline, (int)fragmentWidth, metrics, font); } if (secondPass) { secondPassFrag = new Frag(i, offset, offset + fragmentWidth, textBaseline, font, secondPassFrag); } } offset = endOffset; } // Paint focus border around the text and icon (if necessary) if (myPaintFocusBorder && myBorder != null) { int width = getWidth(); if (focusAroundIcon) { myBorder.paintBorder(this, g, 0, 0, width, height); } else { myBorder.paintBorder(this, g, textStart, 0, width - textStart, height); } } // draw search matches after all for (Frag frag = secondPassFrag; frag != null; frag = frag.next) { float x1 = frag.start; float x2 = frag.end; float baseline = frag.baseLine; ColoredFragment fragment = myFragments.get(frag.index); String text = fragment.text; SimpleTextAttributes attributes = fragment.attributes; Color fgColor; if (attributes.isSearchMatch()) { fgColor = new JBColor(Gray._50, Gray._0); UIUtil.drawSearchMatch(g, x1, x2, height); } else if (attributes.isClickable()) { boolean selected = UIUtil.getTreeSelectionBackground(true) == getBackground(); fgColor = ObjectUtils.notNull(attributes.getFgColor(), UIUtil.getLabelForeground()); drawClickableFrag(g, x1, x2, height, selected, attributes.isHovered(), attributes.isNoBorder()); } else { continue; } g.setFont(frag.font); g.setColor(fgColor); if (!drawWithClipping(frag.index, g, frag.font, frag.start, frag.end, baseline)) { g.drawString(text, x1, baseline); } int fragmentWidth = (int)(x2 - x1); drawTextAttributes(g, attributes, (int)x1, (int)baseline, fragmentWidth, g.getFontMetrics(), g.getFont()); } return (int)offset; } }
doPaintText
282,069
boolean (int index, Graphics2D g, Font font, float x1, float x2, float baseline) { if (!SystemInfo.isMacOSCatalina || !myDynamicSearchMatchHighlighting) return false; ColoredFragment fragment = myFragments.get(index); if (!fragment.attributes.isSearchMatch()) return false; ColoredFragment prevFragment = index > 0 ? myFragments.get(index - 1) : null; ColoredFragment nextFragment = index < myFragments.size() - 1 ? myFragments.get(index + 1) : null; boolean okToMerge = prevFragment != null || nextFragment != null; if (okToMerge && prevFragment != null) { okToMerge = ((prevFragment.attributes.getStyle() | SimpleTextAttributes.STYLE_SEARCH_MATCH) == fragment.attributes.getStyle()); } if (okToMerge && nextFragment != null) { okToMerge = ((nextFragment.attributes.getStyle() | SimpleTextAttributes.STYLE_SEARCH_MATCH) == fragment.attributes.getStyle()); } if (okToMerge) { String mergedText = (prevFragment != null ? prevFragment.text : "") + fragment.text + (nextFragment != null ? nextFragment.text : ""); Graphics2D clippedGraphics = (Graphics2D)g.create(); try { clippedGraphics.setClip(new Rectangle2D.Float(x1, 0, x2 - x1, getHeight())); if (prevFragment != null) x1 -= computeStringWidth(prevFragment, index - 1, font); clippedGraphics.drawString(mergedText, x1, baseline); } finally { clippedGraphics.dispose(); } return true; } return false; }
drawWithClipping
282,070
Color (Color attributesColor) { // in case if color is not defined we have to get foreground color from Swing hierarchy return attributesColor != null ? attributesColor : getForeground(); }
getActiveTextColor
282,071
void (@NotNull Graphics2D g, int index, @NotNull Color bgColor, int x, int y, int width, int height) { g.setColor(bgColor); g.fillRect(x, y, width, height); }
doPaintFragmentBackground
282,072
void (Graphics2D g, float x1, float x2, int height, boolean selected, boolean hovered, boolean noBorder) { if (noBorder) return; GraphicsConfig c = GraphicsUtil.setupRoundedBorderAntialiasing(g); RoundRectangle2D.Float shape = new RoundRectangle2D.Float(x1 + 1, 2, x2 - x1 - 2, height - 4, 6, 6); g.setColor(JBUI.CurrentTheme.ActionButton.hoverBackground()); if (hovered && !selected) { g.fill(shape); } else { g.draw(shape); } c.restore(); }
drawClickableFrag
282,073
void (@NotNull Graphics2D g, @NotNull SimpleTextAttributes attributes, int offset, int textBaseline, int fragmentWidth, @NotNull FontMetrics metrics, Font font) { if (attributes.isStrikeout()) { EffectPainter.STRIKE_THROUGH.paint(g, offset, textBaseline, fragmentWidth, getCharHeight(g), font); } if (attributes.isWaved()) { if (attributes.getWaveColor() != null) { g.setColor(attributes.getWaveColor()); } EffectPainter.WAVE_UNDERSCORE.paint(g, offset, textBaseline + 1, fragmentWidth, Math.max(2, metrics.getDescent()), font); } if (attributes.isUnderline()) { if (attributes.useEffectColor() && attributes.getWaveColor() != null) { g.setColor(attributes.getWaveColor()); } EffectPainter.LINE_UNDERSCORE.paint(g, offset, textBaseline, fragmentWidth, metrics.getDescent(), font); } if (attributes.isBoldDottedLine()) { final int dottedAt = SystemInfo.isMac ? textBaseline : textBaseline + 1; final Color lineColor = attributes.getWaveColor(); UIUtil.drawBoldDottedLine(g, offset, offset + fragmentWidth, dottedAt, attributes.getBgColor(), lineColor, isOpaque()); } if (attributes.isBoldUnderline()) { if (attributes.useEffectColor() && attributes.getWaveColor() != null) { g.setColor(attributes.getWaveColor()); } EffectPainter.BOLD_LINE_UNDERSCORE.paint(g, offset, textBaseline, fragmentWidth, metrics.getDescent(), font); } }
drawTextAttributes
282,074
int (Graphics g) { // magic of determining character height return g.getFontMetrics().charWidth('a'); }
getCharHeight
282,075
int () { if (myTextAlign == SwingConstants.LEFT || myTextAlign == SwingConstants.LEADING) { return 0; } int componentWidth = getSize().width; int excessiveWidth = componentWidth - computePreferredSize(false).width; if (excessiveWidth <= 0) { return 0; } if (myTextAlign == SwingConstants.CENTER) { return excessiveWidth / 2; } if (myTextAlign == SwingConstants.RIGHT || myTextAlign == SwingConstants.TRAILING) { return excessiveWidth; } return 0; }
computeTextAlignShift
282,076
boolean () { return false; }
shouldDrawDimmed
282,077
boolean () { return false; }
shouldDrawBackground
282,078
void (@NotNull Graphics g, @NotNull Icon icon, int offset) { Rectangle area = computePaintArea(); //noinspection UnnecessaryLocalVariable int x = offset; int y = area.y + (area.height - icon.getIconHeight()) / 2; IconUtil.paintSelectionAwareIcon(icon, this, g, x, y, isSelection()); }
paintIcon
282,079
boolean () { Color bg = getBackground(); return bg != null && Comparing.equal(UIUtil.getTreeSelectionBackground(true), bg) || Comparing.equal(UIUtil.getListSelectionBackground(true), bg); }
isSelection
282,080
void (@NotNull Graphics2D g) { UISettings.setupAntialiasing(g); g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, getClientProperty(RenderingHints.KEY_FRACTIONALMETRICS)); }
applyAdditionalHints
282,081
int (int width, int height) { super.getBaseline(width, height); return getTextBaseLine(getFontMetrics(getBaseFont()), height); }
getBaseline
282,082
boolean () { return myTransparentIconBackground; }
isTransparentIconBackground
282,083
void (boolean transparentIconBackground) { myTransparentIconBackground = transparentIconBackground; }
setTransparentIconBackground
282,084
void (boolean dynamicSearchMatchHighlighting) { myDynamicSearchMatchHighlighting = dynamicSearchMatchHighlighting; }
setDynamicSearchMatchHighlighting
282,085
int (@NotNull FontMetrics metrics, final int height) { // adding leading to ascent, just like in editor (leads to bad presentation for certain fonts with Oracle JDK, see IDEA-167541) return (height - metrics.getHeight() + 1) / 2 + metrics.getAscent() + (SystemInfo.isJetBrainsJvm ? metrics.getLeading() : 0); }
getTextBaseLine
282,086
String () { final StringBuilder buffer = new StringBuilder("Components hierarchy:\n"); for (Container c = this; c != null; c = c.getParent()) { buffer.append('\n'); buffer.append(c); } return buffer.toString(); }
logSwingPath
282,087
void (Insets insets) { myBorder = new JBEmptyBorder(insets); revalidateAndRepaint(); }
setBorderInsets
282,088
String () { return getCharSequence(false).toString(); }
toString
282,089
void (@NotNull Runnable runnable, boolean autoInvalidate) { boolean old = myAutoInvalidate; myAutoInvalidate = autoInvalidate; try { runnable.run(); } finally { myAutoInvalidate = old; } }
change
282,090
String (MouseEvent event) { if (myIcon instanceof IconWithToolTip && findFragmentAt(event.getX()) == FRAGMENT_ICON) { String iconToolTip = ((IconWithToolTip)myIcon).getToolTip(false); if (iconToolTip != null) { return StringUtil.capitalize(iconToolTip); } } return super.getToolTipText(event); }
getToolTipText
282,091
AccessibleContext () { if (accessibleContext == null) { accessibleContext = new AccessibleSimpleColoredComponent(); } return accessibleContext; }
getAccessibleContext
282,092
Font (Font originalFont, int style, float size) { Font derivedFont = originalFont.deriveFont(style, size); if (Font.DIALOG.equals(derivedFont.getFamily()) && !Font.DIALOG.equals(originalFont.getFamily())) { // workaround for JBR-3423 return originalFont.deriveFont(size); } return derivedFont; }
deriveFont
282,093
String () { return getCharSequence(false).toString(); }
getAccessibleName
282,094
AccessibleRole () { return AccessibleRole.LABEL; }
getAccessibleRole
282,095
void () { BrowserUtil.browse(myUrl); }
run
282,096
int () { return myOffset; }
getOffset
282,097
int () { return myEndOffset; }
getEndOffset
282,098
String () { synchronized (myFragments) { return myFragments.get(myIndex).text; } }
getFragment
282,099
SimpleTextAttributes () { synchronized (myFragments) { return myFragments.get(myIndex).attributes; } }
getTextAttributes