Search in sources :

Example 1 with ExtractedColor

use of com.android.tools.idea.uibuilder.mockup.colorextractor.ExtractedColor in project android by JetBrains.

the class ColorExtractorTool method initColorsComponents.

private void initColorsComponents() {
    myExtractButton.addActionListener(e -> {
        if (myExtractedColors != null) {
            myColors.removeAll();
        }
        if (!myIsExtractingColor) {
            ColorExtractor colorExtractor = new DBSCANColorExtractor(myMockup);
            myIsExtractingColor = true;
            colorExtractor.run(new ColorExtractor.ColorExtractorCallback() {

                @Override
                public void result(Collection<ExtractedColor> rgbColors) {
                    myProgressBar.setValue(100);
                    myExportButton.setEnabled(true);
                    myIsExtractingColor = false;
                    myExtractedColors = rgbColors;
                    for (ExtractedColor color : rgbColors) {
                        ColorPanel colorPanel = new ColorPanel(color);
                        colorPanel.addHoveredListener(ColorExtractorTool.this);
                        JPanel component = colorPanel.getComponent();
                        component.setMaximumSize(component.getPreferredSize());
                        myColors.add(component, 0);
                    }
                    myColors.revalidate();
                }

                @Override
                public void progress(int progress) {
                    myProgressBar.setValue(progress);
                }
            });
        }
    });
}
Also used : DBSCANColorExtractor(com.android.tools.idea.uibuilder.mockup.colorextractor.DBSCANColorExtractor) ExtractedColor(com.android.tools.idea.uibuilder.mockup.colorextractor.ExtractedColor) ColorExtractor(com.android.tools.idea.uibuilder.mockup.colorextractor.ColorExtractor) DBSCANColorExtractor(com.android.tools.idea.uibuilder.mockup.colorextractor.DBSCANColorExtractor)

Aggregations

ColorExtractor (com.android.tools.idea.uibuilder.mockup.colorextractor.ColorExtractor)1 DBSCANColorExtractor (com.android.tools.idea.uibuilder.mockup.colorextractor.DBSCANColorExtractor)1 ExtractedColor (com.android.tools.idea.uibuilder.mockup.colorextractor.ExtractedColor)1