Search in sources :

Example 1 with ImageComponent

use of com.android.tools.idea.ui.ImageComponent in project android by JetBrains.

the class PreviewIconsPanel method initializeIconComponents.

private void initializeIconComponents(@NotNull Collection<Density> densities) {
    // Sort the densities, so that we always line up icons from highest to lowest densities.
    Ordering<Density> densityOrdering = new Ordering<Density>() {

        @Override
        public int compare(Density left, Density right) {
            // The lower the enum index, the higher the density
            return Ints.compare(left.ordinal(), right.ordinal());
        }
    };
    densities = densityOrdering.immutableSortedCopy(densities);
    for (Density density : densities) {
        JPanel iconPanel = new JPanel(new VerticalFlowLayout(false, false));
        iconPanel.setBackground(myTheme.getMainColor());
        iconPanel.setOpaque(myTheme != Theme.TRANSPARENT);
        JBLabel title = new JBLabel(density.getResourceValue());
        title.setForeground(myTheme.getAltColor());
        iconPanel.add(title);
        ImageComponent iconImage = new ImageComponent(null);
        iconImage.setBorder(new LineBorder(myTheme.getAltColor()));
        iconImage.setOpaque(false);
        iconPanel.add(iconImage);
        GridBagConstraints c = new GridBagConstraints();
        c.anchor = GridBagConstraints.PAGE_START;
        myIconsPanel.add(iconPanel, c);
        myIconImages.put(density, iconImage);
    }
}
Also used : ImageComponent(com.android.tools.idea.ui.ImageComponent) JBLabel(com.intellij.ui.components.JBLabel) LineBorder(javax.swing.border.LineBorder) Ordering(com.google.common.collect.Ordering) Density(com.android.resources.Density) VerticalFlowLayout(com.intellij.openapi.ui.VerticalFlowLayout)

Aggregations

Density (com.android.resources.Density)1 ImageComponent (com.android.tools.idea.ui.ImageComponent)1 Ordering (com.google.common.collect.Ordering)1 VerticalFlowLayout (com.intellij.openapi.ui.VerticalFlowLayout)1 JBLabel (com.intellij.ui.components.JBLabel)1 LineBorder (javax.swing.border.LineBorder)1