@Override public JComponent createTaskInfoPanel(Project project) { myTaskTextPane = new JTextPane(); final JBScrollPane scrollPane = new JBScrollPane(myTaskTextPane); myTaskTextPane.setContentType(new HTMLEditorKit().getContentType()); final EditorColorsScheme editorColorsScheme = EditorColorsManager.getInstance().getGlobalScheme(); int fontSize = editorColorsScheme.getEditorFontSize(); final String fontName = editorColorsScheme.getEditorFontName(); final Font font = new Font(fontName, Font.PLAIN, fontSize); String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() + "pt; }" + "pre {font-family: Courier; display: inline; ine-height: 50px; padding-top: 5px; padding-bottom: 5px; padding-left: 5px; background-color:" + ColorUtil.toHex(ColorUtil.dimmer(UIUtil.getPanelBackground())) + ";}" + "code {font-family: Courier; display: flex; float: left; background-color:" + ColorUtil.toHex(ColorUtil.dimmer(UIUtil.getPanelBackground())) + ";}"; ((HTMLDocument)myTaskTextPane.getDocument()).getStyleSheet().addRule(bodyRule); myTaskTextPane.setEditable(false); if (!UIUtil.isUnderDarcula()) { myTaskTextPane.setBackground(EditorColorsManager.getInstance().getGlobalScheme().getDefaultBackground()); } myTaskTextPane.setBorder(new EmptyBorder(20, 20, 0, 10)); myTaskTextPane.addHyperlinkListener(BrowserHyperlinkListener.INSTANCE); return scrollPane; }
public void paintIcon(final Component c, Graphics graphics) { if (myCounter <= 0) return; final Rectangle moreRect = getIconRec(); if (moreRect == null) return; int iconY = getIconY(moreRect); int iconX = getIconX(moreRect); graphics.setFont(UIUtil.getLabelFont().deriveFont((float)Math.min(8, UIUtil.getButtonFont().getSize()))); int width = graphics.getFontMetrics().stringWidth(String.valueOf(myCounter)); iconX -= width / 2 + 1; AllIcons.General.MoreTabs.paintIcon(c, graphics, iconX, iconY); Graphics g = graphics.create(); try { UISettings.setupAntialiasing(g); UIUtil.drawStringWithHighlighting(g, String.valueOf(myCounter), iconX + AllIcons.General.MoreTabs.getIconWidth() + 2, iconY + AllIcons.General.MoreTabs.getIconHeight() - 5, JBColor.BLACK, ColorUtil.withAlpha(JBColor.WHITE, .9)); } finally { g.dispose(); } }
protected void paintBorder(Graphics g, Dimension size, int state) { GraphicsConfig config = GraphicsUtil.setupAAPainting(g); try { if (UIUtil.isUnderAquaLookAndFeel()) { if (state == ActionButtonComponent.POPPED) { g.setColor(JBColor.GRAY); ((Graphics2D)g).draw(getShape(size)); } } else if (SystemInfo.isMac && UIUtil.isUnderIntelliJLaF()) { //do nothing } else { final double shift = UIUtil.isUnderDarcula() ? 1 / 0.49 : 0.49; g.setColor(ColorUtil.shift(UIUtil.getPanelBackground(), shift)); ((Graphics2D)g).setStroke(BASIC_STROKE); ((Graphics2D)g).draw(getShape(size)); } } finally { config.restore(); } }
@NotNull @Override public BalloonBuilder createDialogBalloonBuilder(@NotNull JComponent content, String title) { final BalloonPopupBuilderImpl builder = new BalloonPopupBuilderImpl(myStorage, content); final Color bg = UIManager.getColor("Panel.background"); final Color borderOriginal = Color.darkGray; final Color border = ColorUtil.toAlpha(borderOriginal, 75); builder .setDialogMode(true) .setTitle(title) .setAnimationCycle(200) .setFillColor(bg).setBorderColor(border).setHideOnClickOutside(false) .setHideOnKeyOutside(false) .setHideOnAction(false) .setCloseButtonEnabled(true) .setShadow(true); return builder; }
private void initGlobalScopes() { PropertiesComponent propertyComponent = PropertiesComponent.getInstance(); for (String scopeName : predefinedScopeNameToPropertyKey.keySet()) { if (findConfiguration(scopeName, false) == null) { String color = propertyComponent.getValue(predefinedScopeNameToPropertyKey.get(scopeName)); if (color == null) { // backward compatibility, previously it was saved incorrectly as scope name instead of specified property key color = propertyComponent.getValue(scopeName); if (color == null) { color = predefinedScopeNameToColor.get(scopeName); } } if (!color.isEmpty()) { final Color col = ColorUtil.fromHex(color, null); final String name = col == null ? null : FileColorManagerImpl.getColorName(col); myApplicationLevelConfigurations.add(new FileColorConfiguration(scopeName, name == null ? color : name)); } } } }
private void updateCustomButton() { final Object item = myScopeComboBox.getSelectedItem(); if (item instanceof String) { Color color = myConfiguration == null ? null : ColorUtil.fromHex(myConfiguration.getColorName(), null); if (color == null) { color = ColorUtil.getColor(myScopeNames.get(item).getClass()); } if (color != null) { final String colorName = ColorSelectionComponent.findColorName(color); if (colorName != null) { myColorSelectionComponent.setSelectedColor(colorName); } else { myColorSelectionComponent.setCustomButtonColor(color); } } } }
@Override @SuppressWarnings({"MethodMayBeStatic"}) @Nullable public Color getColor(@NotNull final String name) { Color color = ourDefaultColors.get(name); if (color != null) { return color; } if ("ffffe4".equals(name) || "494539".equals(name)) { return new JBColor(0xffffe4, 0x494539); } if ("e7fadb".equals(name) || "2a3b2c".equals(name)) { return new JBColor(0xe7fadb, 0x2a3b2c); } return ColorUtil.fromHex(name, null); }
private static void attachColorIcon(final PsiElement element, AnnotationHolder holder, String attributeValueText) { try { Color color = null; if (attributeValueText.startsWith("#")) { color = ColorUtil.fromHex(attributeValueText.substring(1)); } else { final String hexCode = ColorMap.getHexCodeForColorName(StringUtil.toLowerCase(attributeValueText)); if (hexCode != null) { color = ColorUtil.fromHex(hexCode); } } if (color != null) { final ColorIcon icon = new ColorIcon(8, color); final Annotation annotation = holder.createInfoAnnotation(element, null); annotation.setGutterIconRenderer(new ColorIconRenderer(icon, element)); } } catch (Exception ignored) { } }
public void paint(Editor editor, Graphics g, Rectangle r) { final TextAttributes color = editor.getColorsScheme().getAttributes(myKey); Color bgColor = color.getBackgroundColor(); if (bgColor == null) { bgColor = color.getForegroundColor(); } if (editor.getSettings().isLineNumbersShown() || ((EditorGutterComponentEx)editor.getGutter()).isAnnotationsShown()) { if (bgColor != null) { bgColor = ColorUtil.toAlpha(bgColor, 150); } } if (bgColor != null) { g.setColor(bgColor); } g.fillRect(r.x, r.y, r.width, r.height); final LineData lineData = getLineData(editor.xyToLogicalPosition(new Point(0, r.y)).line); if (lineData != null && lineData.isCoveredByOneTest()) { g.drawImage( ImageLoader.loadFromResource("/gutter/unique.png"), r.x, r.y, 8, 8, editor.getComponent()); } }
static void patchPanels() throws Exception { if (MTConfig.getInstance().isMaterialTheme()) { final Color color = UIManager.getColor("Panel.background"); StaticPatcher.setFinalStatic(UIUtil.class, "CONTRAST_BORDER_COLOR", ColorUtil.withAlpha(color, .05)); StaticPatcher.setFinalStatic(UIUtil.class, "BORDER_COLOR", color); StaticPatcher.setFinalStatic(UIUtil.class, "AQUA_SEPARATOR_FOREGROUND_COLOR", color); // StaticPatcher.setFinalStatic(HelpTooltip.class, "BACKGROUND_COLOR", color); } final Field[] fields = DarculaUIUtil.class.getDeclaredFields(); final Object[] objects = Arrays.stream(fields) .filter(f -> f.getType().equals(Color.class)) .toArray(); final Color accentColor = ColorUtil.fromHex(MTConfig.getInstance().getAccentColor()); final JBColor accentJBColor = new JBColor(accentColor, accentColor); StaticPatcher.setFinalStatic((Field) objects[0], accentJBColor); // StaticPatcher.setFinalStatic((Field) objects[1], accentJBColor); final Field[] fields2 = IdeaActionButtonLook.class.getDeclaredFields(); final Object[] objects2 = Arrays.stream(fields2) .filter(f -> f.getType().equals(Color.class)) .toArray(); StaticPatcher.setFinalStatic((Field) objects2[1], accentJBColor); }
static void patchAutocomplete() throws Exception { final String accentColor = MTConfig.getInstance().getAccentColor(); final JBColor jbAccentColor = new JBColor(ColorUtil.fromHex(accentColor), ColorUtil.fromHex(accentColor)); final Color defaultValue = UIUtil.getListSelectionBackground(); final Color backgroundSelectedColor = ObjectUtils.notNull(UIManager.getColor("Autocomplete.selectionbackground"), defaultValue); final Field[] fields = LookupCellRenderer.class.getDeclaredFields(); final Object[] objects = Arrays.stream(fields) .filter(f -> f.getType().equals(Color.class)) .toArray(); // SELECTED BACKGROUND COLOR StaticPatcher.setFinalStatic((Field) objects[3], backgroundSelectedColor); // SELECTED NON FOCUSED BACKGROUND COLOR StaticPatcher.setFinalStatic((Field) objects[4], backgroundSelectedColor); // Completion foreground color StaticPatcher.setFinalStatic((Field) objects[7], jbAccentColor); // Selected completion foregronud color StaticPatcher.setFinalStatic((Field) objects[8], jbAccentColor); }
public void setError(String text) { final Dimension oldSize = getPreferredSize(); myText = text; if (text == null) { myLabel.setText(""); myLabel.setIcon(null); setVisible(false); setBorder(null); } else { myLabel.setText(XmlStringUtil.wrapInHtml("<font color='#" + ColorUtil.toHex(JBColor.RED)+ "'><left>" + text + "</left></b></font>")); myLabel.setIcon(AllIcons.Actions.Lightning); myLabel.setBorder(new EmptyBorder(4, 10, 0, 2)); setVisible(true); } final Dimension size = getPreferredSize(); if (oldSize.height < size.height) { revalidate(); } }
public void paintIcon(final Component c, Graphics graphics) { if (myCounter <= 0) return; final Rectangle moreRect = getIconRec(); if (moreRect == null) return; int iconY = getIconY(moreRect); int iconX = getIconX(moreRect); graphics.setFont(UIUtil.getLabelFont().deriveFont((float)Math.min(8, UIUtil.getButtonFont().getSize()))); int width = graphics.getFontMetrics().stringWidth(String.valueOf(myCounter)); iconX -= width / 2 + 1; AllIcons.General.MoreTabs.paintIcon(c, graphics, iconX, iconY); Graphics g = graphics.create(); try { GraphicsUtil.setupAntialiasing(g, true, true); UIUtil.drawStringWithHighlighting(g, String.valueOf(myCounter), iconX + AllIcons.General.MoreTabs.getIconWidth() + 2, iconY + AllIcons.General.MoreTabs.getIconHeight() - 5, JBColor.BLACK, ColorUtil.withAlpha(JBColor.WHITE, .9)); } finally { g.dispose(); } }
public void paintBorder(Graphics g, JComponent component, int state) { if (state == ActionButtonComponent.NORMAL) return; Rectangle r = new Rectangle(component.getWidth(), component.getHeight()); if (UIUtil.isUnderAquaLookAndFeel()) { if (state == ActionButtonComponent.POPPED) { g.setColor(ALPHA_30); g.drawRoundRect(r.x, r.y, r.width - 2, r.height - 2, 4, 4); } } else { final double shift = UIUtil.isUnderDarcula() ? 1/0.49 : 0.49; g.setColor(ColorUtil.shift(UIUtil.getPanelBackground(), shift)); ((Graphics2D)g).setStroke(BASIC_STROKE); final GraphicsConfig config = GraphicsUtil.setupAAPainting(g); g.drawRoundRect(r.x, r.y, r.width - 2, r.height - 2, 4, 4); config.restore(); } }
@NotNull @Override public BalloonBuilder createDialogBalloonBuilder(@NotNull JComponent content, String title) { final BalloonPopupBuilderImpl builder = new BalloonPopupBuilderImpl(myStorage, content); final Color bg = UIManager.getColor("Panel.background"); final Color borderOriginal = Color.darkGray; final Color border = ColorUtil.toAlpha(borderOriginal, 75); builder .setDialogMode(true) .setTitle(title) .setAnimationCycle(200) .setFillColor(bg) .setBorderColor(border) .setHideOnClickOutside(false) .setHideOnKeyOutside(false) .setHideOnAction(false) .setCloseButtonEnabled(true) .setShadow(true); return builder; }
@Nullable private static Map<String, Color> computeBgColors(FileAnnotation fileAnnotation) { final Map<String, Color> bgColors = new HashMap<String, Color>(); final Map<String, Color> revNumbers = new HashMap<String, Color>(); final int length = BG_COLORS.length; final List<VcsFileRevision> fileRevisionList = fileAnnotation.getRevisions(); final boolean darcula = UIUtil.isUnderDarcula(); if (fileRevisionList != null) { for (VcsFileRevision revision : fileRevisionList) { final String author = revision.getAuthor(); final String revNumber = revision.getRevisionNumber().asString(); if (author != null && !bgColors.containsKey(author)) { final int size = bgColors.size(); Color color = BG_COLORS[size < length ? size : size % length]; if (darcula) { color = ColorUtil.shift(color, 0.3); } bgColors.put(author, color); } if (revNumber != null && !revNumbers.containsKey(revNumber)) { revNumbers.put(revNumber, bgColors.get(author)); } } } return bgColors.size() < 2 ? null : revNumbers; }
@Override protected void doPaintInactive(Graphics2D g2d, boolean leftGhostExists, TabLabel label, Rectangle effectiveBounds, boolean rightGhostExists, int row, int column) { Insets insets = getTabsBorder().getEffectiveBorder(); final boolean dark = UIUtil.isUnderDarcula(); int _x = effectiveBounds.x + insets.left; int _y = effectiveBounds.y + insets.top + 3; int _width = effectiveBounds.width - insets.left - insets.right; int _height = effectiveBounds.height - insets.top - insets.bottom - 3; _height -= TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT; if (dark) { g2d.setPaint(UIUtil.getGradientPaint(_x, _y, ColorUtil.shift(UIUtil.getListBackground(), 1.3), _x, _y + effectiveBounds.height, UIUtil.getPanelBackground())); g2d.fillRect(_x, _y, _width, _height); g2d.setColor(Gray._0.withAlpha(50)); } else { g2d.setPaint(UIUtil.getGradientPaint(_x, _y, new Color(255, 255, 255, 180), _x, _y + effectiveBounds.height, new Color(255, 255, 255, 100))); g2d.fillRect(_x, _y, _width, _height); g2d.setColor(new Color(255, 255, 255, 100)); g2d.drawRect(_x, _y, _width - 1, _height - 1); } }
private static void attachColorIcon(final PsiElement element, AnnotationHolder holder, String attributeValueText) { try { Color color = null; if (attributeValueText.startsWith("#")) { color = ColorUtil.fromHex(attributeValueText.substring(1)); } else { final String hexCode = ColorSampleLookupValue.getHexCodeForColorName(StringUtil.toLowerCase(attributeValueText)); if (hexCode != null) { color = ColorUtil.fromHex(hexCode); } } if (color != null) { final ColorIcon icon = new ColorIcon(8, color); final Annotation annotation = holder.createInfoAnnotation(element, null); annotation.setGutterIconRenderer(new ColorIconRenderer(icon, element)); } } catch (Exception ignored) { } }
@NotNull @Override public Color produce() { Container parent = myComponent.getParent(); if (isBackground && parent instanceof JScrollPane && Registry.is("ide.scroll.background.auto")) { Color background = JBScrollPane.getViewBackground((JScrollPane)parent); if (background != null) { if (!background.equals(myOriginal)) { myModified = ColorUtil.shift(background, ColorUtil.isDark(background) ? 1.05 : 0.96); myOriginal = background; } return myModified; } } return isDark(myComponent) ? myDarkColor : myBrightColor; }
public VcsLogColorManagerImpl(@Nonnull Collection<VirtualFile> roots) { myRoots = new ArrayList<>(roots); Collections.sort(myRoots, Comparator.comparing(VirtualFile::getName)); myRoots2Colors = ContainerUtil.newHashMap(); int i = 0; for (VirtualFile root : myRoots) { Color color; if (i >= ROOT_COLORS.length) { double balance = ((double)(i / ROOT_COLORS.length)) / (roots.size() / ROOT_COLORS.length); Color mix = ColorUtil.mix(ROOT_COLORS[i % ROOT_COLORS.length], ROOT_COLORS[(i + 1) % ROOT_COLORS.length], balance); int tones = (int)(Math.abs(balance - 0.5) * 2 * (roots.size() / ROOT_COLORS.length) + 1); color = new JBColor(ColorUtil.darker(mix, tones), ColorUtil.brighter(mix, 2 * tones)); } else { color = ROOT_COLORS[i]; } i++; myRoots2Colors.put(root, color); } }
@Nullable private static Color calculateGreyBackground(@Nonnull List<RefGroup> refGroups, @Nonnull Color background, boolean isSelected, boolean isCompact) { if (isSelected) return null; if (!isCompact) return ColorUtil.mix(background, BACKGROUND, BALANCE); boolean paintGreyBackground; for (RefGroup group : refGroups) { if (group.isExpanded()) { paintGreyBackground = ContainerUtil.find(group.getRefs(), ref -> !ref.getName().isEmpty()) != null; } else { paintGreyBackground = !group.getName().isEmpty(); } if (paintGreyBackground) return ColorUtil.mix(background, BACKGROUND, BALANCE); } return null; }
@Nonnull private static String getCommitterText(@Nullable VcsUser committer, @Nonnull String commitTimeText, int offset) { String alignment = "<br/>" + StringUtil.repeat(" ", offset); String gray = ColorUtil.toHex(JBColor.GRAY); String graySpan = "<span style='color:#" + gray + "'>"; String text = alignment + graySpan + "committed"; if (committer != null) { text += " by " + VcsUserUtil.getShortPresentation(committer); if (!committer.getEmail().isEmpty()) { text += "</span>" + getEmailText(committer) + graySpan; } } text += commitTimeText + "</span>"; return text; }
protected void paintBorder(ActionButton button, Graphics g, Dimension size, int state) { if (UIUtil.isUnderAquaLookAndFeel()) { if (state == ActionButtonComponent.POPPED) { g.setColor(ALPHA_30); g.drawRoundRect(0, 0, size.width - 2, size.height - 2, 4, 4); } } else { final double shift = UIUtil.isUnderDarcula() ? 1 / 0.49 : 0.49; g.setColor(ColorUtil.shift(UIUtil.getPanelBackground(), shift)); ((Graphics2D)g).setStroke(BASIC_STROKE); final GraphicsConfig config = GraphicsUtil.setupAAPainting(g); g.drawRoundRect(0, 0, size.width - JBUI.scale(2), size.height - JBUI.scale(2), JBUI.scale(4), JBUI.scale(4)); config.restore(); } }
protected void paintBackground(ActionButton button, Graphics g, Dimension size, int state) { if (UIUtil.isUnderAquaLookAndFeel()) { if (state == ActionButtonComponent.PUSHED) { ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, ALPHA_40, size.width, size.height, ALPHA_20)); g.fillRect(0, 0, size.width - 1, size.height - 1); g.setColor(ALPHA_120); g.drawLine(0, 0, 0, size.height - 2); g.drawLine(1, 0, size.width - 2, 0); g.setColor(ALPHA_30); g.drawRect(1, 1, size.width - 3, size.height - 3); } else if (state == ActionButtonComponent.POPPED) { ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, Gray._235, 0, size.height, Gray._200)); g.fillRect(1, 1, size.width - 3, size.height - 3); } } else { final Color bg = UIUtil.getPanelBackground(); final boolean dark = UIUtil.isUnderDarcula(); g.setColor(state == ActionButtonComponent.PUSHED ? ColorUtil.shift(bg, dark ? 1d / 0.7d : 0.7d) : dark ? Gray._255.withAlpha(40) : ALPHA_40); g.fillRect(JBUI.scale(1), JBUI.scale(1), size.width - JBUI.scale(2), size.height - JBUI.scale(2)); } }
@SuppressWarnings("UseJBColor") private static Color parseColor(String value) { if (value != null && value.length() == 8) { final Color color = ColorUtil.fromHex(value.substring(0, 6)); if (color != null) { try { int alpha = Integer.parseInt(value.substring(6, 8), 16); return new ColorUIResource(new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha)); } catch (Exception ignore) { } } return null; } return ColorUtil.fromHex(value, null); }
private static void paintBackground(Graphics g, Dimension size, int state) { if (UIUtil.isUnderAquaLookAndFeel()) { if (state == ActionButtonComponent.PUSHED) { ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, ALPHA_40, size.width, size.height, ALPHA_20)); g.fillRect(0, 0, size.width - 1, size.height - 1); g.setColor(ALPHA_120); g.drawLine(0, 0, 0, size.height - 2); g.drawLine(1, 0, size.width - 2, 0); g.setColor(ALPHA_30); g.drawRect(1, 1, size.width - 3, size.height - 3); } else if (state == ActionButtonComponent.POPPED) { ((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, Gray._235, 0, size.height, Gray._200)); g.fillRect(1, 1, size.width - 3, size.height - 3); } } else { final Color bg = UIUtil.getPanelBackground(); final boolean dark = UIUtil.isUnderDarcula(); g.setColor(state == ActionButtonComponent.PUSHED ? ColorUtil.shift(bg, dark ? 1d / 0.7d : 0.7d) : dark ? Gray._255.withAlpha(40) : ALPHA_40); g.fillRect(JBUI.scale(1), JBUI.scale(1), size.width - JBUI.scale(2), size.height - JBUI.scale(2)); } }
private static void paintBorder(Graphics g, Dimension size, int state) { if (UIUtil.isUnderAquaLookAndFeel()) { if (state == ActionButtonComponent.POPPED) { g.setColor(ALPHA_30); g.drawRoundRect(0, 0, size.width - 2, size.height - 2, 4, 4); } } else { final double shift = UIUtil.isUnderDarcula() ? 1 / 0.49 : 0.49; g.setColor(ColorUtil.shift(UIUtil.getPanelBackground(), shift)); ((Graphics2D)g).setStroke(BASIC_STROKE); final GraphicsConfig config = GraphicsUtil.setupAAPainting(g); g.drawRoundRect(0, 0, size.width - JBUI.scale(2), size.height - JBUI.scale(2), JBUI.scale(4), JBUI.scale(4)); config.restore(); } }
@Nonnull @Override public BalloonBuilder createDialogBalloonBuilder(@Nonnull JComponent content, String title) { final BalloonPopupBuilderImpl builder = new BalloonPopupBuilderImpl(myStorage, content); final Color bg = UIManager.getColor("Panel.background"); final Color borderOriginal = Color.darkGray; final Color border = ColorUtil.toAlpha(borderOriginal, 75); builder .setDialogMode(true) .setTitle(title) .setAnimationCycle(200) .setFillColor(bg).setBorderColor(border).setHideOnClickOutside(false) .setHideOnKeyOutside(false) .setHideOnAction(false) .setCloseButtonEnabled(true) .setShadow(true); return builder; }
@Nonnull public static String buildHtml(@Nonnull final Notification notification, @Nullable String style, boolean isContent, @Nullable Color color, @Nullable String contentStyle) { String title = !isContent ? notification.getTitle() : ""; String subtitle = !isContent ? notification.getSubtitle() : null; String content = isContent ? notification.getContent() : ""; if (title.length() > TITLE_LIMIT || StringUtil.length(subtitle) > TITLE_LIMIT || content.length() > CONTENT_LIMIT) { LOG.info("Too large notification " + notification + " of " + notification.getClass() + "\nListener=" + notification.getListener() + "\nTitle=" + title + "\nSubtitle=" + subtitle + "\nContent=" + content); title = StringUtil.trimLog(title, TITLE_LIMIT); subtitle = StringUtil.trimLog(StringUtil.notNullize(subtitle), TITLE_LIMIT); content = StringUtil.trimLog(content, CONTENT_LIMIT); } if (isContent) { content = StringUtil.replace(content, "<p/>", "<br>"); } String colorText = color == null ? null : "#" + ColorUtil.toHex(color); return buildHtml(title, subtitle, content, style, isContent ? null : colorText, isContent ? colorText : null, contentStyle); }
private void createStatusHighlighter() { int line1 = myPatchDeletionRange.start; int line2 = myPatchInsertionRange.end; Color color = getStatusColor(); if (isResolved()) { color = ColorUtil.mix(color, myViewer.getPatchEditor().getGutterComponentEx().getBackground(), 0.6f); } String tooltip = getStatusText(); EditorEx patchEditor = myViewer.getPatchEditor(); Document document = patchEditor.getDocument(); MarkupModelEx markupModel = patchEditor.getMarkupModel(); TextRange textRange = DiffUtil.getLinesRange(document, line1, line2); RangeHighlighter highlighter = markupModel.addRangeHighlighter(textRange.getStartOffset(), textRange.getEndOffset(), HighlighterLayer.LAST, null, HighlighterTargetArea.LINES_IN_RANGE); PairConsumer<Editor, MouseEvent> clickHandler = getResultRange() != null ? (e, event) -> myViewer.scrollToChange(this, Side.RIGHT, false) : null; highlighter.setLineMarkerRenderer(LineStatusMarkerRenderer.createRenderer(line1, line2, color, tooltip, clickHandler)); myHighlighters.add(highlighter); }
private void updateCustomButton() { final Object item = myScopeComboBox.getSelectedItem(); if (item instanceof String) { Color color = myConfiguration == null ? null : ColorUtil.fromHex(myConfiguration.getColorName(), null); final CustomColorButton button = (CustomColorButton)myColorToButtonMap.get(CUSTOM_COLOR_NAME); if (color == null) { color = ColorUtil.getColor(myScopeNames.get(item).getClass()); } if (color != null) { button.setColor(color); button.setSelected(true); button.repaint(); } } }
@Nullable @Override public Color fromString(@NotNull String stringValue, String value) { stringValue = stringValue.toLowerCase(); stringValue = myDefaultColors.get(stringValue); if(stringValue == null) { return null; } try { return ColorUtil.fromHex(stringValue); } catch(Exception e) { return null; } }
private void updateHintNumberLabel() { if (myHints.size() > 1) { final String color = String.valueOf(ColorUtil.toHex(UIUtil.getHeaderInactiveColor())); myHintLabel.setText(UIUtil.toHtml("Hint" + " <font color=\"" + color + "\">(" + (myShownHintNumber + 1) + "/" + myHints.size() + ")</font>:")); } else { myHintLabel.setText("Hint: "); } }
private static void replaceInt(PsiExpression expr, int newValue, boolean hex) { PsiElementFactory factory = JavaPsiFacade.getElementFactory(expr.getProject()); if (getInt(expr) != newValue) { String text = hex ? "0x" + ColorUtil.toHex(new Color(newValue)).toUpperCase() : Integer.toString(newValue); expr.replace(factory.createExpressionFromText(text, null)); } }
@Nullable private static Color getTopBorderColor(int i, int lineHeight, @NotNull EditorColorsScheme scheme) { int border = Math.max(lineHeight / 4, 1); double ratio = (double)i / border; if (ratio > 1) return null; Color top = scheme.getColor(TOP_BORDER); if (top == null) return null; Color background = getBackgroundColor(scheme); return ColorUtil.mix(top, background, ratio); }
@Nullable private static Color getBottomBorderColor(int i, int lineHeight, @NotNull EditorColorsScheme scheme) { int height = getHeight(lineHeight); int border = Math.max(lineHeight / 12, 1); int index = (height - i - 1); double ratio = (double)index / border; if (ratio > 1) return null; Color bottom = scheme.getColor(BOTTOM_BORDER); if (bottom == null) return null; Color background = getBackgroundColor(scheme); return ColorUtil.mix(bottom, background, ratio); }
public void setError(String text) { myText = text; myLabel.setBounds(0, 0, 0, 0); setVisible(text != null); myLabel.setText(text != null ? "<html><font color='#" + ColorUtil.toHex(JBColor.RED) + "'><left>" + text + "</left></b></font></html>" : ""); }