Java Code Examples for com.intellij.ui.ColorUtil#toAlpha()
The following examples show how to use
com.intellij.ui.ColorUtil#toAlpha() .
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: 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 2
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 3
Source File: Breadcrumbs.java From consulo with Apache License 2.0 | 5 votes |
protected Color getMarkerForeground(Crumb crumb) { if (!Registry.is("editor.breadcrumbs.marker")) return null; CrumbView found = getCrumbView(view -> view.crumb == crumb); Color foreground = found == null ? null : found.foreground; if (foreground == null) return null; double alpha = Registry.doubleValue("editor.breadcrumbs.marker.alpha"); return ColorUtil.toAlpha(foreground, (int)(alpha * foreground.getAlpha())); }
Example 4
Source File: InlineProgressIndicator.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void paintComponent(final Graphics g) { if (myCompact) { super.paintComponent(g); return; } final GraphicsConfig c = GraphicsUtil.setupAAPainting(g); UISettings.setupAntialiasing(g); int arc = 8; Color bg = getBackground(); final Rectangle bounds = myProcessName.getBounds(); final Rectangle label = SwingUtilities.convertRectangle(myProcessName.getParent(), bounds, this); g.setColor(UIUtil.getPanelBackground()); g.fillRoundRect(0, 0, getWidth() - 1, getHeight() - 1, arc, arc); if (!UIUtil.isUnderDarcula()) { bg = ColorUtil.toAlpha(bg.darker().darker(), 230); g.setColor(bg); g.fillRoundRect(0, 0, getWidth() - 1, getHeight() - 1, arc, arc); g.setColor(UIUtil.getPanelBackground()); g.fillRoundRect(0, getHeight() / 2, getWidth() - 1, getHeight() / 2, arc, arc); g.fillRect(0, (int)label.getMaxY() + 1, getWidth() - 1, getHeight() / 2); } else { bg = bg.brighter(); g.setColor(bg); g.drawLine(0, (int)label.getMaxY() + 1, getWidth() - 1, (int)label.getMaxY() + 1); } g.setColor(bg); g.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, arc, arc); c.restore(); }
Example 5
Source File: PopupFactoryImpl.java From consulo with Apache License 2.0 | 5 votes |
@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; }
Example 6
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 7
Source File: GradientViewport.java From consulo with Apache License 2.0 | 4 votes |
private void paintGradient(Graphics2D g2d, Color background, int x1, int y1) { Component view = getView(); if (background != null && view != null) { int x2 = x1, x3 = getWidth() - x2, x4 = x3; int y2 = y1, y3 = getHeight() - y2, y4 = y3; if (myInsets.left > 0 && view.getX() < 0) { x2 += myInsets.left; } if (myInsets.top > 0 && view.getY() < 0) { y2 += myInsets.top; } if (myInsets.right > 0 && view.getX() > getWidth() - view.getWidth()) { x3 -= myInsets.right; } if (myInsets.bottom > 0 && view.getY() > getHeight() - view.getHeight()) { y3 -= myInsets.bottom; } Component parent = myAlways ? null : getParent(); if (parent instanceof JScrollPane) { JScrollPane pane = (JScrollPane)parent; JScrollBar vBar = pane.getVerticalScrollBar(); if (vBar != null && vBar.isVisible()) { if (vBar.getX() < getX()) { x2 = x1; } else { x3 = x4; } } JScrollBar hBar = pane.getHorizontalScrollBar(); if (hBar != null && hBar.isVisible()) { if (hBar.getY() < getY()) { y2 = y1; } else { y3 = y4; } } } Color transparent = ColorUtil.toAlpha(background, 0); if (x1 != x2) { g2d.setPaint(new GradientPaint(x1, y1, background, x2, y1, transparent)); g2d.fillPolygon(new int[]{x1, x2, x2, x1}, new int[]{y1, y2, y3, y4}, 4); } if (x3 != x4) { g2d.setPaint(new GradientPaint(x3, y1, transparent, x4, y1, background)); g2d.fillPolygon(new int[]{x4, x3, x3, x4}, new int[]{y1, y2, y3, y4}, 4); } if (y1 != y2) { g2d.setPaint(new GradientPaint(x1, y1, background, x1, y2, transparent)); g2d.fillPolygon(new int[]{x1, x2, x3, x4}, new int[]{y1, y2, y2, y1}, 4); } if (y3 != y4) { g2d.setPaint(new GradientPaint(x1, y3, transparent, x1, y4, background)); g2d.fillPolygon(new int[]{x1, x2, x3, x4}, new int[]{y4, y3, y3, y4}, 4); } } }
Example 8
Source File: DarculaUIUtil.java From consulo with Apache License 2.0 | 4 votes |
public static void paintSearchFocusRing(Graphics2D g, Rectangle bounds, Component component, int maxArcSize) { int correction = UIUtil.isUnderAquaLookAndFeel() ? 30 : UIUtil.isUnderDarcula() ? 50 : 0; final Color[] colors = new Color[]{ ColorUtil.toAlpha(GLOW_COLOR, 180 - correction), ColorUtil.toAlpha(GLOW_COLOR, 120 - correction), ColorUtil.toAlpha(GLOW_COLOR, 70 - correction), ColorUtil.toAlpha(GLOW_COLOR, 100 - correction), ColorUtil.toAlpha(GLOW_COLOR, 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, MacUIUtil.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); int arcSize = r.height - 1; if (maxArcSize>0) arcSize = Math.min(maxArcSize, arcSize); if (arcSize %2 == 1) arcSize--; g.setColor(component.getBackground()); g.fillRoundRect(r.x + 2, r.y + 2, r.width - 5, r.height - 5, arcSize - 4, arcSize - 4); g.setColor(colors[0]); g.drawRoundRect(r.x + 2, r.y + 2, r.width - 5, r.height - 5, arcSize-4, arcSize-4); g.setColor(colors[1]); g.drawRoundRect(r.x + 1, r.y + 1, r.width - 3, r.height - 3, arcSize-2, arcSize-2); g.setColor(colors[2]); g.drawRoundRect(r.x, r.y, r.width - 1, r.height - 1, arcSize, arcSize); g.setColor(colors[3]); g.drawRoundRect(r.x+3, r.y+3, r.width - 7, r.height - 7, arcSize-6, arcSize-6); g.setColor(colors[4]); g.drawRoundRect(r.x+4, r.y+4, r.width - 9, r.height - 9, arcSize-8, arcSize-8); // restore rendering hints g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAntialiasingValue); g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, oldStrokeControlValue); }
Example 9
Source File: MacUIUtil.java From consulo with Apache License 2.0 | 4 votes |
public static void paintComboboxFocusRing(@Nonnull final Graphics2D g2d, @Nonnull final Rectangle bounds) { final Color color = getFocusRingColor(); final Color[] colors = new Color[]{ColorUtil.toAlpha(color, 180), ColorUtil.toAlpha(color, 130), ColorUtil.toAlpha(color, 80), ColorUtil.toAlpha(color, 80)}; final Object oldAntialiasingValue = g2d.getRenderingHint(RenderingHints.KEY_ANTIALIASING); final Object oldStrokeControlValue = g2d.getRenderingHint(RenderingHints.KEY_STROKE_CONTROL); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE); int _y = MAC_COMBO_BORDER_V_OFFSET; final GeneralPath path1 = new GeneralPath(); path1.moveTo(2, _y + 4); path1.quadTo(2, +_y + 2, 4, _y + 2); path1.lineTo(bounds.width - 7, _y + 2); path1.quadTo(bounds.width - 5, _y + 3, bounds.width - 4, _y + 5); path1.lineTo(bounds.width - 4, bounds.height - 7 + _y); path1.quadTo(bounds.width - 5, bounds.height - 5 + _y, bounds.width - 7, bounds.height - 4 + _y); path1.lineTo(4, bounds.height - 4 + _y); path1.quadTo(2, bounds.height - 4 + _y, 2, bounds.height - 6 + _y); path1.closePath(); g2d.setColor(colors[0]); g2d.draw(path1); final GeneralPath path2 = new GeneralPath(); path2.moveTo(1, 5 + _y); path2.quadTo(1, 1 + _y, 5, 1 + _y); path2.lineTo(bounds.width - 8, 1 + _y); path2.quadTo(bounds.width - 4, 2 + _y, bounds.width - 3, 6 + _y); path2.lineTo(bounds.width - 3, bounds.height - 7 + _y); path2.quadTo(bounds.width - 4, bounds.height - 4 + _y, bounds.width - 8, bounds.height - 3 + _y); path2.lineTo(4, bounds.height - 3 + _y); path2.quadTo(1, bounds.height - 3 + _y, 1, bounds.height - 6 + _y); path2.closePath(); g2d.setColor(colors[1]); g2d.draw(path2); final GeneralPath path3 = new GeneralPath(); path3.moveTo(0, 4 + _y); path3.quadTo(0, _y, 7, _y); path3.lineTo(bounds.width - 9, _y); path3.quadTo(bounds.width - 2, 1 + _y, bounds.width - 2, 7 + _y); path3.lineTo(bounds.width - 2, bounds.height - 8 + _y); path3.quadTo(bounds.width - 3, bounds.height - 1 + _y, bounds.width - 12, bounds.height - 2 + _y); path3.lineTo(7, bounds.height - 2 + _y); path3.quadTo(0, bounds.height - 1 + _y, 0, bounds.height - 7 + _y); path3.closePath(); g2d.setColor(colors[2]); g2d.draw(path3); // restore rendering hints g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAntialiasingValue); g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, oldStrokeControlValue); }