Package org.locationtech.udig.ui.palette

Examples of org.locationtech.udig.ui.palette.ColourScheme


        // This is the "best" match; usually the one the user supplied
        layer.setGeoResource(preferredResource);

        // determine the default colour
        ColourScheme colourScheme = getColorScheme();
        Color colour = colourScheme.addItem(theLayer.getID().toString());
        theLayer.setDefaultColor(colour);

        runLayerCreatedInterceptor(layer);

        return layer;
View Full Code Here


    /**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * @generated
     */
    public void setColourScheme(ColourScheme newColourScheme) {
        ColourScheme oldColourScheme = colourScheme;
        colourScheme = newColourScheme;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET,
                    ProjectPackage.LAYER__COLOUR_SCHEME, oldColourScheme, colourScheme));
    }
View Full Code Here

     * @return
     */
    public Control getPaletteCombo( Layer layer ) {
        layerReference = layer;
        String layerName = layer.getName();
        ColourScheme layerScheme = layer.getColourScheme();
        ColourScheme mapScheme = layer.getMapInternal().getColourScheme();
       
        final ColourScheme currentScheme;
        if (layerScheme != null && !(layerScheme.equals(mapScheme))) { //TODO: check logic
            currentScheme = layerScheme;
        } else {
            currentScheme = mapScheme;
        }
View Full Code Here

         */

        this.map = thisMap;
        numberOfLayers = this.map.getLayersInternal().size();
        mapPalette = map.getColorPalette();
        mapScheme =  new ColourScheme(map.getColourScheme().getColourPalette(), map.getColourScheme().getSizePalette());
        //workaround for non-saving (need to correct number of colours)
        if (mapScheme.getSizePalette() < numberOfLayers) {
            mapScheme.setSizePalette(numberOfLayers);
        }
        scrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
        composite = new Composite(scrolledComposite, SWT.NONE);
       
        scrolledComposite.setContent(composite);

        GridLayout gridLayout = new GridLayout();
        gridLayout.numColumns = 4;
        composite.setLayout(gridLayout);

        // title at top of panel
        Label titleLabel = new Label(composite, SWT.NONE);
        titleLabel.setText(Messages.PaletteDefaultChooserPanel_title);

        GridData data = new GridData();
        data.horizontalSpan = 4;
        titleLabel.setLayoutData(data);

        //map background color label
        Label backgroundColor = new Label(composite, SWT.NONE);
        backgroundColor.setText(Messages.PaletteDefaultChooserPanel_MapBackgroundColor);
        data = new GridData();
        data.horizontalSpan = 1;
        backgroundColor.setLayoutData(data);
       
        colorEditor = new ColorEditor(composite);
        Color bgColor = (Color)thisMap.getBlackboard().get(ProjectBlackboardConstants.MAP__BACKGROUND_COLOR);
        if (backgroundColor != null)
            colorEditor.setColorValue(new RGB(bgColor.getRed(), bgColor.getGreen(), bgColor.getBlue()));
       //spacer
        Composite colorc = new Composite(composite, SWT.NONE);
        data = new GridData();
        data.horizontalSpan = 2;
        colorc.setLayoutData(data);
       
        // palette label
        Label paletteLabel = new Label(composite, SWT.NONE);
        paletteLabel.setText(Messages.PaletteDefaultChooserPanel_palette);

        data = new GridData();
        data.horizontalSpan = 1;
        paletteLabel.setLayoutData(data);

        // palette colourLetterCombo box
        paletteSelectionCombo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);

        String[] names = PlatformGIS.getColorBrewer().getPaletteNames();

        paletteSelectionCombo.setItems(names);

        // find out index number for selection
        int index = 0;
        for( int i = 0; i < names.length; i++ ) {
            if ((names[i]).equalsIgnoreCase(mapPalette.getName())) {
                index = i;
                break;
            }
        }

        paletteSelectionCombo.addSelectionListener(new SelectionListener(){
            public void widgetSelected( SelectionEvent e ) {
                /*
                 * When a new palette is selected: get the palette String and then we want to
                 * repaint all paletteCombos to have new colours
                 */
                int index = paletteSelectionCombo.getSelectionIndex();
                String name = paletteSelectionCombo.getItem(index);
                BrewerPalette palette = PlatformGIS.getColorBrewer().getPalette(name);
                //ColourScheme scheme = map.getColourScheme();
                //scheme.setColourPalette(palette);
                //map.setColorPalette(palette);
                //map.setColourScheme(scheme);
                mapScheme = new ColourScheme(palette,  Integer.parseInt(quantityCombo.getItem(quantityCombo.getSelectionIndex())) );
                updateLayerDisplay();
            }

            public void widgetDefaultSelected( SelectionEvent e ) {
            }
View Full Code Here

            }
        }
       
        String name = paletteSelectionCombo.getItem(paletteSelectionCombo.getSelectionIndex());
        BrewerPalette palette = PlatformGIS.getColorBrewer().getPalette(name);
        mapScheme = new ColourScheme(palette,  Integer.parseInt(quantityCombo.getItem(quantityCombo.getSelectionIndex())) );
        updateLayerDisplay();
    }
View Full Code Here

    /**
     * <!-- begin-user-doc --> <!-- end-user-doc -->
     * @generated
     */
    public void setColourScheme(ColourScheme newColourScheme) {
        ColourScheme oldColourScheme = colourScheme;
        colourScheme = newColourScheme;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET,
                    ProjectPackage.MAP__COLOUR_SCHEME, oldColourScheme, colourScheme));
    }
View Full Code Here

    public ColourScheme createColourSchemeFromString(EDataType eDataType, String initialValue) {
        String[] parts = initialValue.split(";"); //$NON-NLS-1$
        if (parts.length != 4) {
            //something is wrong...
            BrewerPalette palette = PlatformGIS.getColorBrewer().getPalette("Dark2"); //$NON-NLS-1$
            return new ColourScheme(palette, 0);
        }
        String[] strap = parts[2].split(","); //$NON-NLS-1$
        BrewerPalette palette = PlatformGIS.getColorBrewer().getPalette(parts[0]);
        HashMap<Integer, Integer> colourMapping = new HashMap<Integer, Integer>();
        for (int i = 0; i < strap.length; i++) {
            colourMapping.put(i, Integer.parseInt(strap[i]));
        }
        String[] strap2 = parts[3].split(","); //$NON-NLS-1$
        HashMap<String, Integer> idMapping = new HashMap<String, Integer>();
        for (int i = 0; i < strap2.length; i++) {
            idMapping.put(strap2[i], Integer.parseInt(strap2[++i]));
        }
        ColourScheme scheme = new ColourScheme(palette, colourMapping, idMapping, strap.length,
                Integer.parseInt(parts[1]));
        return scheme;
    }
View Full Code Here

     * <!-- begin-user-doc --> <!-- end-user-doc -->
     *
     * @generated NOT
     */
    public String convertColourSchemeToString(EDataType eDataType, Object instanceValue) {
        ColourScheme instance = (ColourScheme) instanceValue;
        String value = instance.getColourPalette().getName() + ";"; //$NON-NLS-1$;
        int numItems = instance.getSizeScheme();
        int numColours = instance.getSizePalette();
        value = value + numColours + ";"; //$NON-NLS-1$
        HashMap colourMap = instance.getColourMap();
        for (int i = 0; i < numItems; i++) {
            if (i > 0)
                value = value + ","; //$NON-NLS-1$
            value = value + colourMap.get(i);
        }
        value = value + ";"; //$NON-NLS-1$
        HashMap<String, Integer> idMap = instance.getIdMap();
        Iterator<Entry<String, Integer>> it = idMap.entrySet().iterator();
        while (it.hasNext()) {
            Entry<String, Integer> entry = it.next();
            value = value + entry.getKey() + "," + entry.getValue(); //$NON-NLS-1$
            if (it.hasNext()) {
View Full Code Here

TOP

Related Classes of org.locationtech.udig.ui.palette.ColourScheme

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.