Search in sources :

Example 11 with JBColor

use of com.intellij.ui.JBColor in project intellij-community by JetBrains.

the class BlockTreeNode method update.

@Override
protected void update(PresentationData presentation) {
    String name = myBlock.getClass().getSimpleName();
    if (myBlock instanceof DataLanguageBlockWrapper) {
        name += " (" + ((DataLanguageBlockWrapper) myBlock).getOriginal().getClass().getSimpleName() + ")";
    }
    presentation.addText(name, SimpleTextAttributes.REGULAR_ATTRIBUTES);
    if (myBlock.getIndent() != null) {
        presentation.addText(" " + String.valueOf(myBlock.getIndent()).replaceAll("[<>]", " "), SimpleTextAttributes.GRAY_ATTRIBUTES);
    } else {
        presentation.addText(" Indent: null", SimpleTextAttributes.GRAY_ATTRIBUTES);
    }
    if (myBlock.getAlignment() != null) {
        float d = 1.f * System.identityHashCode(myBlock.getAlignment()) / Integer.MAX_VALUE;
        Color color = new JBColor(Color.HSBtoRGB(1.0f * d, .3f, .7f), Color.HSBtoRGB(1.0f * d, .3f, .8f));
        presentation.addText(" " + String.valueOf(myBlock.getAlignment()), new SimpleTextAttributes(SimpleTextAttributes.STYLE_BOLD, color));
    }
    if (myBlock.getWrap() != null) {
        presentation.addText(" " + String.valueOf(myBlock.getWrap()), new SimpleTextAttributes(SimpleTextAttributes.STYLE_ITALIC, PlatformColors.BLUE));
    }
}
Also used : JBColor(com.intellij.ui.JBColor) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) JBColor(com.intellij.ui.JBColor) DataLanguageBlockWrapper(com.intellij.formatting.templateLanguages.DataLanguageBlockWrapper)

Example 12 with JBColor

use of com.intellij.ui.JBColor in project intellij-community by JetBrains.

the class EditorPainter method paintCaret.

private void paintCaret(Graphics2D g_) {
    EditorImpl.CaretRectangle[] locations = myEditor.getCaretLocations(true);
    if (locations == null)
        return;
    Graphics2D g = IdeBackgroundUtil.getOriginalGraphics(g_);
    int nominalLineHeight = myView.getNominalLineHeight();
    int topOverhang = myView.getTopOverhang();
    EditorSettings settings = myEditor.getSettings();
    Color caretColor = myEditor.getColorsScheme().getColor(EditorColors.CARET_COLOR);
    if (caretColor == null)
        caretColor = new JBColor(CARET_DARK, CARET_LIGHT);
    int minX = getMinX();
    for (EditorImpl.CaretRectangle location : locations) {
        float x = location.myPoint.x;
        int y = location.myPoint.y - topOverhang;
        Caret caret = location.myCaret;
        CaretVisualAttributes attr = caret == null ? CaretVisualAttributes.DEFAULT : caret.getVisualAttributes();
        g.setColor(attr.getColor() != null ? attr.getColor() : caretColor);
        boolean isRtl = location.myIsRtl;
        if (myEditor.isInsertMode() != settings.isBlockCursor()) {
            int lineWidth = JBUI.scale(attr.getWidth(settings.getLineCursorWidth()));
            // see IDEA-148843 for more details
            if (x > minX && lineWidth > 1)
                x -= 1 / JBUI.sysScale(g);
            g.fill(new Rectangle2D.Float(x, y, lineWidth, nominalLineHeight));
            if (myDocument.getTextLength() > 0 && caret != null && !myView.getTextLayoutCache().getLineLayout(caret.getLogicalPosition().line).isLtr()) {
                GeneralPath triangle = new GeneralPath(Path2D.WIND_NON_ZERO, 3);
                triangle.moveTo(isRtl ? x + lineWidth : x, y);
                triangle.lineTo(isRtl ? x + lineWidth - CARET_DIRECTION_MARK_SIZE : x + CARET_DIRECTION_MARK_SIZE, y);
                triangle.lineTo(isRtl ? x + lineWidth : x, y + CARET_DIRECTION_MARK_SIZE);
                triangle.closePath();
                g.fill(triangle);
            }
        } else {
            int width = location.myWidth;
            float startX = Math.max(minX, isRtl ? x - width : x);
            g.fill(new Rectangle2D.Float(startX, y, width, nominalLineHeight - 1));
            if (myDocument.getTextLength() > 0 && caret != null) {
                int charCount = DocumentUtil.isSurrogatePair(myDocument, caret.getOffset()) ? 2 : 1;
                int targetVisualColumn = caret.getVisualPosition().column;
                for (VisualLineFragmentsIterator.Fragment fragment : VisualLineFragmentsIterator.create(myView, caret.getVisualLineStart(), false)) {
                    if (fragment.getCurrentInlays() != null)
                        continue;
                    int startVisualColumn = fragment.getStartVisualColumn();
                    int endVisualColumn = fragment.getEndVisualColumn();
                    if (startVisualColumn < targetVisualColumn && endVisualColumn > targetVisualColumn || startVisualColumn == targetVisualColumn && !isRtl || endVisualColumn == targetVisualColumn && isRtl) {
                        g.setColor(ColorUtil.isDark(caretColor) ? CARET_LIGHT : CARET_DARK);
                        fragment.draw(g, startX, y + topOverhang + myView.getAscent(), targetVisualColumn - startVisualColumn - (isRtl ? charCount : 0), targetVisualColumn - startVisualColumn + (isRtl ? 0 : charCount));
                        break;
                    }
                }
                ComplexTextFragment.flushDrawingCache(g);
            }
        }
    }
}
Also used : GeneralPath(java.awt.geom.GeneralPath) JBColor(com.intellij.ui.JBColor) Rectangle2D(java.awt.geom.Rectangle2D) RoundRectangle2D(java.awt.geom.RoundRectangle2D) JBColor(com.intellij.ui.JBColor)

Example 13 with JBColor

use of com.intellij.ui.JBColor in project intellij-community by JetBrains.

the class SheetController method paintShadow.

private void paintShadow(Graphics2D g2d) {
    g2d.setBackground(new JBColor(new Color(255, 255, 255, 0), new Color(110, 110, 110, 0)));
    g2d.clearRect(0, 0, SHEET_NC_WIDTH, SHEET_HEIGHT);
    g2d.drawImage(myShadowImage, 0, -SHADOW_BORDER, null);
    g2d.clearRect(SHADOW_BORDER, 0, SHEET_WIDTH, SHEET_HEIGHT);
}
Also used : JBColor(com.intellij.ui.JBColor) JBColor(com.intellij.ui.JBColor)

Example 14 with JBColor

use of com.intellij.ui.JBColor in project intellij-community by JetBrains.

the class PluginHeaderPanel method createUIComponents.

private void createUIComponents() {
    myInstallButton = new JButton() {

        private final int TOP_BOTTOM_BORDER = JBUI.scale(2);

        private final int LEFT_RIGHT_BORDER = JBUI.scale(8);

        private final int H_GAP = JBUI.scale(4);

        private final int ICON_SIZE = getIcon().getIconWidth();

        {
            setOpaque(false);
            setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        }

        @Override
        public Dimension getPreferredSize() {
            final FontMetrics metrics = getFontMetrics(getFont());
            final int textWidth = metrics.stringWidth(getText());
            final int width = LEFT_RIGHT_BORDER + ICON_SIZE + H_GAP + textWidth + LEFT_RIGHT_BORDER;
            final int height = TOP_BOTTOM_BORDER + Math.max(ICON_SIZE, metrics.getHeight()) + TOP_BOTTOM_BORDER;
            return new Dimension(width, height);
        }

        @Override
        public void paint(Graphics g2) {
            final Graphics2D g = (Graphics2D) g2;
            final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
            final int w = g.getClipBounds().width;
            final int h = g.getClipBounds().height;
            int borderArc = JBUI.scale(7);
            int border = JBUI.scale(1);
            int buttonArc = borderArc - border;
            g.setPaint(getBackgroundBorderPaint());
            g.fillRoundRect(0, 0, w, h, borderArc, borderArc);
            g.setPaint(getBackgroundPaint());
            g.fillRoundRect(border, border, w - 2 * border, h - 2 * border, buttonArc, buttonArc);
            g.setColor(getButtonForeground());
            g.drawString(getText(), LEFT_RIGHT_BORDER + ICON_SIZE + H_GAP, getBaseline(w, h));
            getIcon().paintIcon(this, g, LEFT_RIGHT_BORDER, (getHeight() - getIcon().getIconHeight()) / 2);
            config.restore();
        }

        private Color getButtonForeground() {
            switch(myActionId) {
                case UPDATE:
                    return new JBColor(Gray._240, Gray._210);
                case INSTALL:
                    return new JBColor(Gray._240, Gray._210);
                case RESTART:
                case UNINSTALL:
                    return new JBColor(Gray._0, Gray._210);
            }
            return new JBColor(Gray._80, Gray._60);
        }

        private Paint getBackgroundPaint() {
            switch(myActionId) {
                case UPDATE:
                    return new JBGradientPaint(this, new JBColor(0x629ee1, 0x629ee1), new JBColor(0x3a5bb5, 0x3a5bb5));
                case INSTALL:
                    return new JBGradientPaint(this, new JBColor(0x60cc69, 0x519557), new JBColor(0x326529, 0x28462f));
                case RESTART:
                case UNINSTALL:
                    return UIUtil.isUnderDarcula() ? new JBGradientPaint(this, UIManager.getColor("Button.darcula.color1"), UIManager.getColor("Button.darcula.color2")) : Gray._240;
            }
            return Gray._238;
        }

        private Paint getBackgroundBorderPaint() {
            switch(myActionId) {
                case UPDATE:
                    return new JBColor(new Color(0xa6b4cd), Gray._85);
                case INSTALL:
                    return new JBColor(new Color(201, 223, 201), Gray._70);
                case RESTART:
                case UNINSTALL:
                    return new JBColor(Gray._220, Gray._100.withAlpha(180));
            }
            return Gray._208;
        }

        @Override
        public String getText() {
            switch(myActionId) {
                case UPDATE:
                    return "Update";
                case INSTALL:
                    return "Install";
                case UNINSTALL:
                    return "Uninstall";
                case RESTART:
                    return "Restart " + ApplicationNamesInfo.getInstance().getFullProductName();
            }
            return super.getText();
        }

        @Override
        public Icon getIcon() {
            switch(myActionId) {
                case UPDATE:
                    return AllIcons.General.DownloadPlugin;
                case INSTALL:
                    return AllIcons.General.DownloadPlugin;
                case UNINSTALL:
                    return AllIcons.Actions.Delete;
                case RESTART:
                    return AllIcons.Actions.Restart;
            }
            return super.getIcon();
        }
    };
    myInstallButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            switch(myActionId) {
                case UPDATE:
                case INSTALL:
                    Runnable setPlugin = () -> setPlugin(myPlugin);
                    new InstallPluginAction(myManager.getAvailable(), myManager.getInstalled()).install(setPlugin, setPlugin, true);
                    break;
                case UNINSTALL:
                    UninstallPluginAction.uninstall(myManager.getInstalled(), true, myPlugin);
                    break;
                case RESTART:
                    if (myManager != null) {
                        myManager.apply();
                    }
                    final DialogWrapper dialog = DialogWrapper.findInstance(KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner());
                    if (dialog != null && dialog.isModal()) {
                        dialog.close(DialogWrapper.OK_EXIT_CODE);
                    }
                    TransactionGuard.getInstance().submitTransactionLater(ApplicationManager.getApplication(), () -> {
                        DialogWrapper settings = DialogWrapper.findInstance(IdeFocusManager.findInstance().getFocusOwner());
                        if (settings instanceof SettingsDialog) {
                            ((SettingsDialog) settings).doOKAction();
                        }
                        ApplicationManager.getApplication().restart();
                    });
                    break;
            }
            setPlugin(myPlugin);
        }
    });
}
Also used : ActionEvent(java.awt.event.ActionEvent) JBColor(com.intellij.ui.JBColor) GraphicsConfig(com.intellij.openapi.ui.GraphicsConfig) JBGradientPaint(com.intellij.ui.JBGradientPaint) JBGradientPaint(com.intellij.ui.JBGradientPaint) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) SettingsDialog(com.intellij.openapi.options.newEditor.SettingsDialog) ActionListener(java.awt.event.ActionListener) JBGradientPaint(com.intellij.ui.JBGradientPaint) JBColor(com.intellij.ui.JBColor)

Example 15 with JBColor

use of com.intellij.ui.JBColor in project intellij-community by JetBrains.

the class DarculaComboBoxUI method createArrowButton.

protected JButton createArrowButton() {
    final Color bg = myComboBox.getBackground();
    final Color fg = myComboBox.getForeground();
    JButton button = new BasicArrowButton(SwingConstants.SOUTH, bg, fg, fg, fg) {

        @Override
        public void paint(Graphics g2) {
            final Graphics2D g = (Graphics2D) g2;
            final GraphicsConfig config = new GraphicsConfig(g);
            final int w = getWidth();
            final int h = getHeight();
            if (!isTableCellEditor(myComboBox)) {
                g.setColor(getArrowButtonFillColor(UIUtil.getControlColor()));
                g.fillRect(0, 0, w, h);
            }
            g.setColor(new JBColor(Gray._255, comboBox.isEnabled() ? getForeground() : getBorderColor()));
            config.setupRoundedBorderAntialiasing();
            final int tW = JBUI.scale(8);
            final int tH = JBUI.scale(6);
            final int xU = (w - tW) / 2;
            final int yU = (h - tH) / 2;
            g.translate(JBUI.scale(2), JBUI.scale(1));
            final Path2D.Double path = new Path2D.Double();
            path.moveTo(xU, yU);
            path.lineTo(xU + tW, yU);
            path.lineTo(xU + tW / 2, yU + tH);
            path.lineTo(xU, yU);
            //path.moveTo(xU + 1, yU + 2);
            //path.lineTo(3 * xU + 1, yU + 2);
            //path.lineTo(2 * xU + 1, 3 * yU);
            //path.lineTo(xU + 1, yU + 2);
            path.closePath();
            g.fill(path);
            g.translate(-JBUI.scale(2), -JBUI.scale(1));
            if (!isTableCellEditor(myComboBox)) {
                g.setColor(getArrowButtonFillColor(getBorderColor()));
                g.drawLine(0, -1, 0, h);
            }
            config.restore();
        }

        @Override
        public Dimension getPreferredSize() {
            int size = getFont().getSize() + 4;
            if (size % 2 == 1)
                size++;
            return new DimensionUIResource(size, size);
        }
    };
    button.setBorder(BorderFactory.createEmptyBorder());
    button.setOpaque(false);
    return button;
}
Also used : BasicArrowButton(javax.swing.plaf.basic.BasicArrowButton) JBColor(com.intellij.ui.JBColor) Path2D(java.awt.geom.Path2D) JBColor(com.intellij.ui.JBColor) GraphicsConfig(com.intellij.openapi.ui.GraphicsConfig) DimensionUIResource(javax.swing.plaf.DimensionUIResource)

Aggregations

JBColor (com.intellij.ui.JBColor)51 GraphicsConfig (com.intellij.openapi.ui.GraphicsConfig)8 NotNull (org.jetbrains.annotations.NotNull)8 SimpleTextAttributes (com.intellij.ui.SimpleTextAttributes)4 Rectangle2D (java.awt.geom.Rectangle2D)4 UIUtil (com.intellij.util.ui.UIUtil)3 Project (com.intellij.openapi.project.Project)2 BalloonLayout (com.intellij.ui.BalloonLayout)2 BalloonLayoutData (com.intellij.ui.BalloonLayoutData)2 StudyStatus (com.jetbrains.edu.learning.courseFormat.StudyStatus)2 RoundRectangle2D (java.awt.geom.RoundRectangle2D)2 BasicArrowButton (javax.swing.plaf.basic.BasicArrowButton)2 Nullable (org.jetbrains.annotations.Nullable)2 ItemResourceValue (com.android.ide.common.rendering.api.ItemResourceValue)1 ResourceValue (com.android.ide.common.rendering.api.ResourceValue)1 LegendComponent (com.android.tools.adtui.LegendComponent)1 LegendRenderData (com.android.tools.adtui.LegendRenderData)1 TimelineComponent (com.android.tools.adtui.TimelineComponent)1 ConfiguredThemeEditorStyle (com.android.tools.idea.editors.theme.datamodels.ConfiguredThemeEditorStyle)1 MergedManifest (com.android.tools.idea.model.MergedManifest)1