com.intellij.ui.ColorUtil Java Examples
The following examples show how to use
com.intellij.ui.ColorUtil.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApplyPatchChange.java From consulo with Apache License 2.0 | 6 votes |
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); }
Example #2
Source File: LabelPainter.java From consulo with Apache License 2.0 | 6 votes |
@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; }
Example #3
Source File: FileColorConfigurationEditDialog.java From consulo with Apache License 2.0 | 6 votes |
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(); } } }
Example #4
Source File: ActionButtonUI.java From consulo with Apache License 2.0 | 6 votes |
public void paintBorder(ActionButton button, Graphics g, Dimension size, int state) { if (state == ActionButtonComponent.NORMAL && !button.isBackgroundSet()) return; 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(); } }
Example #5
Source File: CommitPanel.java From consulo with Apache License 2.0 | 6 votes |
@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; }
Example #6
Source File: PoppedIcon.java From consulo with Apache License 2.0 | 6 votes |
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)); } }
Example #7
Source File: PoppedIcon.java From consulo with Apache License 2.0 | 6 votes |
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(); } }
Example #8
Source File: MoreTabsIcon.java From consulo with Apache License 2.0 | 6 votes |
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; icon.paintIcon(c, graphics, iconX, iconY); Graphics g = graphics.create(); try { UISettings.setupAntialiasing(g); UIUtil.drawStringWithHighlighting(g, String.valueOf(myCounter), iconX + getIconWidth() + 2, iconY + getIconHeight() - 5, JBColor.BLACK, ColorUtil.withPreAlpha(JBColor.WHITE, .9)); } finally { g.dispose(); } }
Example #9
Source File: ModernDarkLaf.java From consulo with Apache License 2.0 | 6 votes |
@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); }
Example #10
Source File: CoverageLineMarkerRenderer.java From consulo with Apache License 2.0 | 6 votes |
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()) { AllIcons.Gutter.Unique.paintIcon(editor.getComponent(), g, r.x, r.y); } }
Example #11
Source File: FocusModeModel.java From consulo with Apache License 2.0 | 6 votes |
private void applyFocusMode(@Nonnull Segment focusRange) { EditorColorsScheme scheme = ObjectUtils.notNull(myEditor.getColorsScheme(), EditorColorsManager.getInstance().getGlobalScheme()); Color background = scheme.getDefaultBackground(); //noinspection UseJBColor Color foreground = Registry.getColor(ColorUtil.isDark(background) ? "editor.focus.mode.color.dark" : "editor.focus.mode.color.light", Color.GRAY); TextAttributes attributes = new TextAttributes(foreground, background, background, LINE_UNDERSCORE, Font.PLAIN); myEditor.putUserData(FOCUS_MODE_ATTRIBUTES, attributes); MarkupModel markupModel = myEditor.getMarkupModel(); DocumentEx document = myEditor.getDocument(); int textLength = document.getTextLength(); int start = focusRange.getStartOffset(); int end = focusRange.getEndOffset(); if (start <= textLength) myFocusModeMarkup.add(markupModel.addRangeHighlighter(0, start, LAYER, attributes, EXACT_RANGE)); if (end <= textLength) myFocusModeMarkup.add(markupModel.addRangeHighlighter(end, textLength, LAYER, attributes, EXACT_RANGE)); myFocusModeRange = document.createRangeMarker(start, end); }
Example #12
Source File: NotificationsUtil.java From consulo with Apache License 2.0 | 6 votes |
@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); }
Example #13
Source File: GraphPanel.java From jetbrains-plugin-graph-database-support with Apache License 2.0 | 6 votes |
private void balloonBuilder() { final BalloonPopupBuilderImpl builder = new BalloonPopupBuilderImpl(null, balloonLabel); final Color bg = lookAndFeelService.getBackgroundColor(); final Color borderOriginal = lookAndFeelService.getEdgeStrokeColor(); final Color border = ColorUtil.toAlpha(borderOriginal, 75); builder .setShowCallout(false) .setDialogMode(false) .setAnimationCycle(20) .setFillColor(bg).setBorderColor(border).setHideOnClickOutside(true) .setHideOnKeyOutside(false) .setHideOnAction(false) .setCloseButtonEnabled(false) .setShadow(true); balloonPopupBuilder = builder; }
Example #14
Source File: DarculaLaf.java From consulo with Apache License 2.0 | 5 votes |
@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); }
Example #15
Source File: ModernWhiteEditorTabsUI.java From consulo with Apache License 2.0 | 5 votes |
@Override public void doPaintInactiveImpl(Graphics2D g2d, Rectangle effectiveBounds, int x, int y, int w, int h, Color tabColor, int row, int column, boolean vertical) { g2d.setColor(Gray._255); g2d.fillRect(x, y, w, h); if (tabColor != null) { g2d.setColor(ColorUtil.toAlpha(tabColor, 200)); g2d.fillRect(x, y, w, h); } g2d.setColor(Gray._150.withAlpha(100)); g2d.fillRect(x, y, w, h); // Push top row under the navbar or toolbar and have a blink over previous row shadow for 2nd and subsequent rows. if (row == 0) { g2d.setColor(Gray._200.withAlpha(200)); } else { g2d.setColor(Gray._255.withAlpha(100)); } g2d.drawLine(x, y, x + w - 1, y); }
Example #16
Source File: MacEditorTabsUI.java From consulo with Apache License 2.0 | 5 votes |
@Override public void doPaintInactiveImpl(Graphics2D g2d, Rectangle effectiveBounds, int x, int y, int w, int h, Color tabColor, int row, int column, boolean vertical) { g2d.setColor(Gray._255); g2d.fillRect(x, y, w, h); if (tabColor != null) { g2d.setColor(ColorUtil.toAlpha(tabColor, 200)); g2d.fillRect(x, y, w, h); } g2d.setColor(Gray._150.withAlpha(100)); g2d.fillRect(x, y, w, h); // Push top row under the navbar or toolbar and have a blink over previous row shadow for 2nd and subsequent rows. if (row == 0) { g2d.setColor(Gray._200.withAlpha(200)); } else { g2d.setColor(Gray._255.withAlpha(100)); } g2d.drawLine(x, y, x + w - 1, y); }
Example #17
Source File: FlutterProjectStep.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void updateSdkField(JTextComponent sdkEditor) { FlutterSdk current = FlutterSdk.forPath(sdkEditor.getText()); Color color = sdkBackgroundColor; if (current == null) { if (ColorUtil.isDark(sdkBackgroundColor)) { color = ColorUtil.darker(JBColor.YELLOW, 5); } else { color = ColorUtil.desaturate(JBColor.YELLOW, 15); } } sdkEditor.setBackground(color); }
Example #18
Source File: ModernActionButtonUI.java From consulo with Apache License 2.0 | 5 votes |
@Override public void paintBackground(ActionButton button, Graphics g, Dimension size, int state) { if (state == ActionButtonComponent.PUSHED) { g.setColor(ColorUtil.toAlpha(ModernUIUtil.getSelectionBackground(), 100)); RectanglePainter2D.FILL.paint((Graphics2D)g, 0, 0, size.getWidth(), size.getHeight()); } }
Example #19
Source File: ModernButtonUI.java From consulo with Apache License 2.0 | 5 votes |
@Override public void paint(Graphics g, JComponent c) { final Border border = c.getBorder(); if (border != null) { final GraphicsConfig config = GraphicsUtil.setupAAPainting(g); final boolean square = isSquare(c); final Insets ins = border.getBorderInsets(c); final int yOff = (ins.top + ins.bottom) / 4; if (c.isEnabled()) { if (!square) { if (myMouseEnterHandler.isMousePressed()) { g.setColor(ColorUtil.toAlpha(ModernUIUtil.getSelectionBackground(), 100)); } else { if (ModernButtonBorderPainter.isDefaultButton(c)) { g.setColor(myMouseEnterHandler.isMouseEntered() ? ModernUIUtil.getSelectionBackground().brighter() : ModernUIUtil.getSelectionBackground()); } else { g.setColor(getButtonColor1()); } } } } else { if (ModernButtonBorderPainter.isDefaultButton(c)) { g.setColor(ModernUIUtil.getActiveBorderColor()); } } g.fillRect(JBUI.scale(square ? 2 : 4), yOff, c.getWidth() - JBUI.scale(2 * 4), c.getHeight() - 2 * yOff); config.restore(); } super.paint(g, c); }
Example #20
Source File: MacAquaUIDecorator.java From consulo with Apache License 2.0 | 5 votes |
@Nullable @Override public Color getSidebarColor() { Color color = IntelliJLaf.isGraphite() ? DarculaUIUtil.MAC_GRAPHITE_COLOR : DarculaUIUtil.MAC_REGULAR_COLOR; return ColorUtil.desaturate(color, 8); }
Example #21
Source File: MacUIUtil.java From consulo with Apache License 2.0 | 5 votes |
public static void paintFocusRing(Graphics2D g, Color ringColor, Rectangle bounds, boolean oval) { int correction = UIUtil.isUnderDarcula() ? 50 : 0; final Color[] colors = new Color[]{ColorUtil.toAlpha(ringColor, 180 - correction), ColorUtil.toAlpha(ringColor, 120 - correction), ColorUtil.toAlpha(ringColor, 70 - correction), ColorUtil.toAlpha(ringColor, 100 - correction), ColorUtil.toAlpha(ringColor, 50 - correction)}; final Object oldAntialiasingValue = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING); final Object oldStrokeControlValue = g.getRenderingHint(RenderingHints.KEY_STROKE_CONTROL); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, !oval && USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE); final Rectangle r = new Rectangle(bounds.x - 3, bounds.y - 3, bounds.width + 6, bounds.height + 6); g.setColor(colors[0]); drawRectOrOval(g, oval, 5, r.x + 2, r.y + 2, r.width - 5, r.height - 5); g.setColor(colors[1]); drawRectOrOval(g, oval, 7, r.x + 1, r.y + 1, r.width - 3, r.height - 3); g.setColor(colors[2]); drawRectOrOval(g, oval, 9, r.x, r.y, r.width - 1, r.height - 1); g.setColor(colors[3]); drawRectOrOval(g, oval, 0, r.x + 3, r.y + 3, r.width - 7, r.height - 7); g.setColor(colors[4]); drawRectOrOval(g, oval, 0, r.x + 4, r.y + 4, r.width - 9, r.height - 9); // restore rendering hints g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAntialiasingValue); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, oldStrokeControlValue); }
Example #22
Source File: DarculaTableHeaderUI.java From consulo with Apache License 2.0 | 5 votes |
@Override public void paint(Graphics g2, JComponent c) { final Graphics2D g = (Graphics2D)g2; final GraphicsConfig config = new GraphicsConfig(g); final Color bg = c.getBackground(); g.setPaint(bg); TableColumnModel model = ((JTableHeader)c).getColumnModel(); final int h = c.getHeight(); final int w = model.getTotalColumnWidth(); g.fillRect(0, 0, w, h); JBColor bottomSeparatorColor = JBColor.namedColor("TableHeader.bottomSeparatorColor", ColorUtil.shift(bg, 0.75)); g.setPaint(bottomSeparatorColor); UIUtil.drawLine(g, 0, h - 1, w, h - 1); final Enumeration<TableColumn> columns = model.getColumns(); final Color lineColor = JBColor.namedColor("TableHeader.separatorColor", ColorUtil.shift(bg, 0.7)); int offset = 0; while (columns.hasMoreElements()) { final TableColumn column = columns.nextElement(); if (columns.hasMoreElements() && column.getWidth() > 0) { offset += column.getWidth(); g.setColor(lineColor); UIUtil.drawLine(g, offset - 1, 1, offset - 1, h - 3); } } config.restore(); super.paint(g, c); }
Example #23
Source File: DarculaTableHeaderUI.java From consulo with Apache License 2.0 | 5 votes |
@Override public void paint(Graphics g2, JComponent c) { final Graphics2D g = (Graphics2D)g2; final GraphicsConfig config = new GraphicsConfig(g); final Color bg = c.getBackground(); g.setPaint(UIUtil.getGradientPaint(0, 0, ColorUtil.shift(bg, 1.4), 0, c.getHeight(), ColorUtil.shift(bg, 0.9))); final int h = c.getHeight(); final int w = c.getWidth(); g.fillRect(0,0, w, h); g.setPaint(ColorUtil.shift(bg, 0.75)); g.drawLine(0, h-1, w, h-1); g.drawLine(w-1, 0, w-1, h-1); final Enumeration<TableColumn> columns = ((JTableHeader)c).getColumnModel().getColumns(); final Color lineColor = ColorUtil.shift(bg, 0.7); final Color shadow = Gray._255.withAlpha(30); int offset = 0; while (columns.hasMoreElements()) { final TableColumn column = columns.nextElement(); if (columns.hasMoreElements() && column.getWidth() > 0) { offset += column.getWidth(); g.setColor(lineColor); g.drawLine(offset-1, 1, offset-1, h-3); g.setColor(shadow); g.drawLine(offset, 1, offset, h-3); } } config.restore(); super.paint(g, c); }
Example #24
Source File: IntelliJEditorTabsUI.java From consulo with Apache License 2.0 | 5 votes |
public void doPaintInactiveImpl(Graphics2D g2d, Rectangle effectiveBounds, int x, int y, int w, int h, Color tabColor, int row, int column, boolean vertical) { if (tabColor != null) { g2d.setPaint(UIUtil.getGradientPaint(x, y, Gray._200, x, y + effectiveBounds.height, Gray._130)); g2d.fillRect(x, y, w, h); g2d.setColor(ColorUtil.toAlpha(tabColor, 150)); g2d.fillRect(x, y, w, h); } else { g2d.setPaint(UIUtil.getGradientPaint(x, y, Gray._255.withAlpha(180), x, y + effectiveBounds.height, Gray._255.withAlpha(100))); g2d.fillRect(x, y, w, h); } // Push top row under the navbar or toolbar and have a blink over previous row shadow for 2nd and subsequent rows. if (row == 0) { g2d.setColor(Gray._200.withAlpha(200)); } else { g2d.setColor(Gray._255.withAlpha(100)); } g2d.drawLine(x, y, x + w - 1, y); }
Example #25
Source File: DesktopStripePanelImpl.java From consulo with Apache License 2.0 | 5 votes |
public void setOverlayed(boolean overlayed) { if (Registry.is("disable.toolwindow.overlay")) return; Color bg = UIUtil.getPanelBackground(); if (UIUtil.isUnderAquaLookAndFeel()) { float[] result = Color.RGBtoHSB(bg.getRed(), bg.getGreen(), bg.getBlue(), new float[3]); bg = new Color(Color.HSBtoRGB(result[0], result[1], result[2] - 0.08f > 0 ? result[2] - 0.08f : result[2])); } if (overlayed) { setBackground(ColorUtil.toAlpha(bg, 190)); } else { setBackground(bg); } }
Example #26
Source File: FileColorConfigurationEditDialog.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private String getColorName() { for (String name : myColorToButtonMap.keySet()) { final AbstractButton button = myColorToButtonMap.get(name); if (button.isSelected()) { return button instanceof CustomColorButton ? ColorUtil.toHex(((CustomColorButton)button).getColor()) : name; } } return null; }
Example #27
Source File: RunnerContentUi.java From consulo with Apache License 2.0 | 5 votes |
@Override public void executePaint(Component component, Graphics2D g) { if (myBoundingBox == null) return; GraphicsUtil.setupAAPainting(g); g.setColor(ColorUtil.toAlpha(myColor, 200)); g.setStroke(new BasicStroke(2)); g.draw(myBoundingBox); g.setColor(ColorUtil.toAlpha(myColor, 40)); g.fill(myBoundingBox); }
Example #28
Source File: DaemonTooltipRenderer.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override protected String dressDescription(@Nonnull final Editor editor, @Nonnull String tooltipText, boolean expand) { if (!expand) { return super.dressDescription(editor, tooltipText, false); } final List<String> problems = getProblems(tooltipText); StringBuilder text = new StringBuilder(); for (String problem : problems) { final String ref = getLinkRef(problem); if (ref != null) { String description = TooltipLinkHandlerEP.getDescription(ref, editor); if (description != null) { description = InspectionNodeInfo.stripUIRefsFromInspectionDescription(UIUtil.getHtmlBody(new Html(description).setKeepFont(true))); text.append(getHtmlForProblemWithLink(problem)).append(END_MARKER).append("<p>").append("<span style=\"color:").append(ColorUtil.toHex(getDescriptionTitleColor())).append("\">") .append(TooltipLinkHandlerEP.getDescriptionTitle(ref, editor)).append(":</span>").append(description).append(UIUtil.BORDER_LINE); } } else { text.append(UIUtil.getHtmlBody(new Html(problem).setKeepFont(true))).append(UIUtil.BORDER_LINE); } } if (text.length() > 0) { //otherwise do not change anything return XmlStringUtil.wrapInHtml(StringUtil.trimEnd(text.toString(), UIUtil.BORDER_LINE)); } return super.dressDescription(editor, tooltipText, true); }
Example #29
Source File: BreakpointItem.java From consulo with Apache License 2.0 | 5 votes |
protected static void showInEditor(DetailView panel, VirtualFile virtualFile, int line) { TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(DebuggerColors.BREAKPOINT_ATTRIBUTES); DetailView.PreviewEditorState state = DetailView.PreviewEditorState.create(virtualFile, line, attributes); if (state.equals(panel.getEditorState())) { return; } panel.navigateInPreviewEditor(state); TextAttributes softerAttributes = attributes.clone(); Color backgroundColor = softerAttributes.getBackgroundColor(); if (backgroundColor != null) { softerAttributes.setBackgroundColor(ColorUtil.softer(backgroundColor)); } final Editor editor = panel.getEditor(); final MarkupModel editorModel = editor.getMarkupModel(); final MarkupModel documentModel = DocumentMarkupModel.forDocument(editor.getDocument(), editor.getProject(), false); for (RangeHighlighter highlighter : documentModel.getAllHighlighters()) { if (highlighter.getUserData(DebuggerColors.BREAKPOINT_HIGHLIGHTER_KEY) == Boolean.TRUE) { final int line1 = editor.offsetToLogicalPosition(highlighter.getStartOffset()).line; if (line1 != line) { editorModel.addLineHighlighter(line1, DebuggerColors.BREAKPOINT_HIGHLIGHTER_LAYER + 1, softerAttributes); } } } }
Example #30
Source File: NotificationsUtil.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public static String buildHtml(@Nonnull final Notification notification, @Nullable String style) { String title = notification.getTitle(); String content = notification.getContent(); if (title.length() > TITLE_LIMIT || content.length() > CONTENT_LIMIT) { LOG.info("Too large notification " + notification + " of " + notification.getClass() + "\nListener=" + notification.getListener() + "\nTitle=" + title + "\nContent=" + content); title = StringUtil.trimLog(title, TITLE_LIMIT); content = StringUtil.trimLog(content, CONTENT_LIMIT); } return buildHtml(title, null, content, style, "#" + ColorUtil.toHex(getMessageType(notification).getTitleForeground()), null, null); }