Search in sources :

Example 1 with ConstantRasterColorMap

use of org.polymap.core.style.model.raster.ConstantRasterColorMap in project polymap4-core by Polymap4.

the class PredefinedColorMap method fillModel.

public void fillModel(RasterColorMapStyle style, GridCoverage2D grid, IProgressMonitor monitor) {
    ConstantRasterColorMap newColorMap = style.colorMap.createValue(ConstantRasterColorMap.defaults());
    fillModel(newColorMap, grid, monitor);
}
Also used : ConstantRasterColorMap(org.polymap.core.style.model.raster.ConstantRasterColorMap)

Example 2 with ConstantRasterColorMap

use of org.polymap.core.style.model.raster.ConstantRasterColorMap in project polymap4-core by Polymap4.

the class PredefinedColorMapEditor method createContents.

@Override
public Composite createContents(Composite parent) {
    Composite contents = super.createContents(parent);
    ComboViewer combo = new ComboViewer(contents, SWT.SINGLE | SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
    combo.getCombo().setVisibleItemCount(13);
    combo.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object elm) {
            return ((PredefinedColorMap) elm).name;
        }
    });
    combo.setComparator(new ViewerComparator() {

        @Override
        public int compare(Viewer viewer, Object elm1, Object elm2) {
            PredefinedColorMap cm1 = (PredefinedColorMap) elm1;
            PredefinedColorMap cm2 = (PredefinedColorMap) elm2;
            return cm1.name.compareToIgnoreCase(cm2.name);
        }
    });
    combo.setContentProvider(ArrayContentProvider.getInstance());
    combo.setInput(input = PredefinedColorMap.all.get());
    findSelected().ifPresent(selected -> combo.setSelection(new StructuredSelection(selected)));
    combo.addSelectionChangedListener(ev -> {
        ConstantRasterColorMap newColorMap = prop.createValue(ConstantRasterColorMap.defaults());
        newColorMap.entries.clear();
        PredefinedColorMap colorMap = SelectionAdapter.on(ev.getSelection()).first(PredefinedColorMap.class).get();
        UIJob.schedule("Color map", monitor -> {
            // Thread.sleep( 3000 );
            colorMap.fillModel(newColorMap, site().gridCoverage.get(), monitor);
        });
    });
    return contents;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ComboViewer(org.eclipse.jface.viewers.ComboViewer) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Viewer(org.eclipse.jface.viewers.Viewer) LabelProvider(org.eclipse.jface.viewers.LabelProvider) ConstantRasterColorMap(org.polymap.core.style.model.raster.ConstantRasterColorMap)

Aggregations

ConstantRasterColorMap (org.polymap.core.style.model.raster.ConstantRasterColorMap)2 ComboViewer (org.eclipse.jface.viewers.ComboViewer)1 LabelProvider (org.eclipse.jface.viewers.LabelProvider)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)1 Composite (org.eclipse.swt.widgets.Composite)1