Search in sources :

Example 21 with JBColor

use of com.intellij.ui.JBColor in project android by JetBrains.

the class ThemeEditorUtils method getGoodContrastPreviewBackground.

/**
   * Returns the color that should be used for the background of the preview panel depending on the background color
   * of the theme being displayed, so as to always keep some contrast between the two.
   */
public static JBColor getGoodContrastPreviewBackground(@NotNull ConfiguredThemeEditorStyle theme, @NotNull ResourceResolver resourceResolver) {
    ItemResourceValue themeColorBackgroundItem = resolveItemFromParents(theme, "colorBackground", true);
    ResourceValue backgroundResourceValue = resourceResolver.resolveResValue(themeColorBackgroundItem);
    if (backgroundResourceValue != null) {
        String colorBackgroundValue = backgroundResourceValue.getValue();
        Color colorBackground = ResourceHelper.parseColor(colorBackgroundValue);
        if (colorBackground != null) {
            float backgroundDistance = MaterialColorUtils.colorDistance(colorBackground, ThemeEditorComponent.PREVIEW_BACKGROUND);
            if (backgroundDistance < ThemeEditorComponent.COLOR_DISTANCE_THRESHOLD && backgroundDistance < MaterialColorUtils.colorDistance(colorBackground, ThemeEditorComponent.ALT_PREVIEW_BACKGROUND)) {
                return ThemeEditorComponent.ALT_PREVIEW_BACKGROUND;
            }
        }
    }
    return ThemeEditorComponent.PREVIEW_BACKGROUND;
}
Also used : ItemResourceValue(com.android.ide.common.rendering.api.ItemResourceValue) JBColor(com.intellij.ui.JBColor) ItemResourceValue(com.android.ide.common.rendering.api.ItemResourceValue) ResourceValue(com.android.ide.common.rendering.api.ResourceValue)

Example 22 with JBColor

use of com.intellij.ui.JBColor in project android by JetBrains.

the class GradleTestArtifactSyncTest method testTestFileBackground.

@Test
public void testTestFileBackground() throws Exception {
    guiTest.importSimpleApplication();
    EditorFixture editor = guiTest.ideFrame().getEditor();
    editor.open("app/src/test/java/google/simpleapplication/UnitTest.java");
    TabLabel tabLabel = findTab(editor);
    Color green = new JBColor(new Color(231, 250, 219), new Color(0x425444));
    assertEquals(green, tabLabel.getInfo().getTabColor());
// TODO re-enable following code when we fix background color support
//editor.close();
//editor.open("app/src/androidTest/java/google/simpleapplication/ApplicationTest.java");
//tabLabel = findTab(editor);
//Color blue = new JBColor(new Color(0xdcf0ff), new Color(0x3C476B));
//assertEquals(blue, tabLabel.getInfo().getTabColor());
}
Also used : EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) JBColor(com.intellij.ui.JBColor) TabLabel(com.intellij.ui.tabs.impl.TabLabel) JBColor(com.intellij.ui.JBColor)

Example 23 with JBColor

use of com.intellij.ui.JBColor in project android by JetBrains.

the class StyleListCellRenderer method customizeCellRenderer.

@Override
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
    if (!(value instanceof String)) {
        return;
    }
    String stringValue = (String) value;
    if (ThemesListModel.isSpecialOption(stringValue) || ParentRendererEditor.NO_PARENT.equals(stringValue)) {
        append(stringValue, SimpleTextAttributes.REGULAR_ATTRIBUTES, true);
        return;
    }
    ConfiguredThemeEditorStyle style = myContext.getThemeResolver().getTheme(stringValue);
    if (style == null) {
        append(stringValue, SimpleTextAttributes.REGULAR_ATTRIBUTES, true);
        return;
    }
    ConfiguredThemeEditorStyle parent = style.getParent();
    String styleName = style.getName();
    String parentName = parent != null ? parent.getName() : null;
    String defaultAppThemeResourceUrl = null;
    final AndroidFacet facet = AndroidFacet.getInstance(myContext.getCurrentContextModule());
    if (facet != null) {
        MergedManifest info = MergedManifest.get(facet);
        defaultAppThemeResourceUrl = info.getManifestTheme();
    }
    if (!style.isProjectStyle()) {
        String simplifiedName = ThemeEditorUtils.simplifyThemeName(style);
        String qualifiedStyleName = (style.isFramework() ? SdkConstants.PREFIX_ANDROID : "") + styleName;
        if (StringUtil.isEmpty(simplifiedName)) {
            append(qualifiedStyleName, SimpleTextAttributes.REGULAR_ATTRIBUTES, true);
        } else {
            append(simplifiedName, SimpleTextAttributes.REGULAR_ATTRIBUTES, true);
            append(" [" + qualifiedStyleName + "]", SimpleTextAttributes.GRAY_ATTRIBUTES, false);
        }
    } else if (!selected && parentName != null && styleName.startsWith(parentName + ".")) {
        append(parentName + ".", SimpleTextAttributes.GRAY_ATTRIBUTES, false);
        append(styleName.substring(parentName.length() + 1), SimpleTextAttributes.REGULAR_ATTRIBUTES, true);
    } else {
        append(styleName, SimpleTextAttributes.REGULAR_ATTRIBUTES, true);
    }
    if (style.getStyleResourceUrl().equals(defaultAppThemeResourceUrl)) {
        append("  -  Default", new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, new JBColor(0xFF4CAF50, 0xFFA5D6A7)), true);
    }
}
Also used : MergedManifest(com.android.tools.idea.model.MergedManifest) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) JBColor(com.intellij.ui.JBColor) ConfiguredThemeEditorStyle(com.android.tools.idea.editors.theme.datamodels.ConfiguredThemeEditorStyle) AndroidFacet(org.jetbrains.android.facet.AndroidFacet)

Example 24 with JBColor

use of com.intellij.ui.JBColor in project android by JetBrains.

the class GpuMonitorView method configureTimelineComponent.

private void configureTimelineComponent(@NotNull TimelineData data) {
    if (myApiLevel >= MHandler.MIN_API_LEVEL) {
        myPanel.remove(myTimelineComponent);
        myTimelineComponent = new TimelineComponent(data, myEvents, POST_M_TIMELINE_BUFFER_TIME, TIMELINE_INITIAL_MAX, POST_M_TIMELINE_ABSOLUTE_MAX, TIMELINE_INITIAL_MARKER_SEPARATION);
        Choreographer.animate(myTimelineComponent);
        myTimelineComponent.configureUnits("ms");
        myTimelineComponent.configureStream(0, "VSync Delay", new JBColor(0x007c6d, 0x00695c));
        myTimelineComponent.configureStream(1, "Input Handling", new JBColor(0x00a292, 0x00897b));
        myTimelineComponent.configureStream(2, "Animation", new JBColor(0x00b2a1, 0x009688));
        myTimelineComponent.configureStream(3, "Measure/Layout", new JBColor(0x2dc5b6, 0x26a69a));
        myTimelineComponent.configureStream(4, "Draw", new JBColor(0x27b2ff, 0x2196f3));
        myTimelineComponent.configureStream(5, "Sync", new JBColor(0x5de7ff, 0x4fc3f7));
        myTimelineComponent.configureStream(6, "Command Issue", new JBColor(0xff4f40, 0xf44336));
        myTimelineComponent.configureStream(7, "Swap Buffers", new JBColor(0xffb400, 0xff9800));
        myTimelineComponent.configureStream(8, "Misc Time", new JBColor(0x008f7f, 0x00796b));
        myTimelineComponent.setBackground(BACKGROUND_COLOR);
        setOverlayEnabled(NEEDS_NEWER_API_LABEL, false);
        myPanel.add(myTimelineComponent, BorderLayout.CENTER);
    } else if (myApiLevel >= JHandler.MIN_API_LEVEL) {
        myPanel.remove(myTimelineComponent);
        myTimelineComponent = new TimelineComponent(data, myEvents, PRE_M_TIMELINE_BUFFER_TIME, TIMELINE_INITIAL_MAX, PRE_M_TIMELINE_ABSOLUTE_MAX, TIMELINE_INITIAL_MARKER_SEPARATION);
        Choreographer.animate(myTimelineComponent);
        if (myApiLevel >= LHandler.MIN_API_LEVEL) {
            myTimelineComponent.configureUnits("ms");
            myTimelineComponent.configureStream(0, "Draw", new JBColor(0x4979f2, 0x3e66cc));
            myTimelineComponent.configureStream(1, "Prepare", new JBColor(0xa900ff, 0x8f00ff));
            myTimelineComponent.configureStream(2, "Process", new JBColor(0xff4315, 0xdc3912));
            myTimelineComponent.configureStream(3, "Execute", new JBColor(0xffb400, 0xe69800));
            myTimelineComponent.setBackground(BACKGROUND_COLOR);
        } else {
            myTimelineComponent.configureUnits("ms");
            myTimelineComponent.configureStream(0, "Draw", new JBColor(0x4979f2, 0x3e66cc));
            myTimelineComponent.configureStream(1, "Process", new JBColor(0xff4315, 0xdc3912));
            myTimelineComponent.configureStream(2, "Execute", new JBColor(0xffb400, 0xe69800));
            myTimelineComponent.setBackground(BACKGROUND_COLOR);
        }
        setOverlayEnabled(NEEDS_NEWER_API_LABEL, false);
        myPanel.add(myTimelineComponent, BorderLayout.CENTER);
    } else {
        setOverlayEnabled(NEEDS_NEWER_API_LABEL, true);
    }
    myTimelineComponent.configureEvent(EVENT_LAUNCH, 0, AndroidIcons.Ddms.Threads, new JBColor(0x92ADC6, 0x718493), new JBColor(0x2B4E8C, 0xC7E5FF), false);
    myTimelineComponent.configureEvent(EVENT_TRACING, 0, AndroidIcons.Ddms.StartMethodProfiling, new JBColor(0x92ADC6, 0x718493), new JBColor(0x2B4E8C, 0xC7E5FF), true);
    myTimelineComponent.addReference(16.6f, JBColor.GREEN);
    myTimelineComponent.addReference(33.3f, JBColor.RED);
}
Also used : JBColor(com.intellij.ui.JBColor) TimelineComponent(com.android.tools.adtui.TimelineComponent)

Example 25 with JBColor

use of com.intellij.ui.JBColor in project android by JetBrains.

the class ThreadsSegment method getThreadStateColor.

@NotNull
private static EnumMap<CpuProfiler.ThreadActivity.State, Color> getThreadStateColor() {
    if (mThreadStateColor != null) {
        return mThreadStateColor;
    }
    // TODO: change it to use the proper darcula colors. Also, support other states if needed.
    mThreadStateColor = new EnumMap<>(CpuProfiler.ThreadActivity.State.class);
    mThreadStateColor.put(CpuProfiler.ThreadActivity.State.RUNNING, new JBColor(new Color(134, 199, 144), new Color(134, 199, 144)));
    mThreadStateColor.put(CpuProfiler.ThreadActivity.State.SLEEPING, new JBColor(Gray._189, Gray._189));
    mThreadStateColor.put(CpuProfiler.ThreadActivity.State.DEAD, Gray.TRANSPARENT);
    return mThreadStateColor;
}
Also used : CpuProfiler(com.android.tools.profiler.proto.CpuProfiler) JBColor(com.intellij.ui.JBColor) JBColor(com.intellij.ui.JBColor) NotNull(org.jetbrains.annotations.NotNull)

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