Examples of PaletteSuitability


Examples of org.geotools.brewer.color.PaletteSuitability

                        if (this.styleThemePage.customPalette == null) {
                            int numClasses = new Integer(this.styleThemePage.getCombo(StyleThemePage.COMBO_CLASSES).getText()).intValue();
                            //create the palette from the current one
                            BrewerPalette pal = (BrewerPalette) ((StructuredSelection) this.styleThemePage.paletteTable.getSelection()).getFirstElement();
                            this.styleThemePage.customPalette = new BrewerPalette();
                            PaletteSuitability suitability = new PaletteSuitability();
                            //suitability.
                            //customPalette.setColors()
                            SampleScheme newScheme = new SampleScheme();
                            int maxColors = pal.getMaxColors();
                            Color[] allColorsArray = pal.getColors();
                            if (maxColors==Integer.MAX_VALUE) {
                                // this means the array is dynamic, so the num is exactly the colors
                                maxColors = numClasses;
                                newScheme = new CustomSampleScheme(maxColors);
                            }
                            if (allColorsArray.length == 0) {
                                allColorsArray = pal.getColors(maxColors);
                            }
                            Color[] colors = new Color[maxColors];
                            List<Color> allColors = new ArrayList<Color>();
                            for (int i = 0; i < allColorsArray.length; i++) {
                                allColors.add(allColorsArray[i]);
                            }
                            String unknown = "?"; //$NON-NLS-1$
                            for (int i = 0; i < maxColors; i++) {
                                if (i > 0) {
                                    //create a simple scheme
                                    int[] scheme = new int[i+1];
                                    for (int j = 0; j < i+1; j++) {
                                        scheme[j] = j;
                                    }
                                    newScheme.setSampleScheme(i+1, scheme);
                                    //set the suitability to unknown
                                    try {
                                        suitability.setSuitability(i+1, new String[] {unknown, unknown, unknown, unknown, unknown, unknown});
                                    } catch (Exception e) {
                                        SLDPlugin.log("setSuitability() failed", e); //$NON-NLS-1$
//                                        return;
                                    }
                                }
View Full Code Here

Examples of org.geotools.brewer.color.PaletteSuitability

        NodeList palettes = document.getElementsByTagName("palette");

        for( int i = 0; i < palettes.getLength(); i++ ) {
            BrewerPalette pal = new BrewerPalette();
            PaletteSuitability suitability = new PaletteSuitability();
            NodeList paletteInfo = palettes.item(i).getChildNodes();

            for( int j = 0; j < paletteInfo.getLength(); j++ ) {
                Node item = paletteInfo.item(j);

                if (item.getNodeName().equals("name")) {
                    pal.setName(fixToString(item.getFirstChild().toString()));
                }

                if (item.getNodeName().equals("description")) {
                    pal.setDescription(fixToString(item.getFirstChild().toString()));
                }

                if (item.getNodeName().equals("colors")) {
                    StringTokenizer oTok = new StringTokenizer(fixToString(item.getFirstChild().toString()));
                    List<Color> colors = new ArrayList<Color>();

                    while( oTok.hasMoreTokens() ) {
                        String entry = oTok.nextToken(":");
                        StringTokenizer iTok = new StringTokenizer(entry);
                        int r = Integer.parseInt(iTok.nextToken(",").trim());
                        int g = Integer.parseInt(iTok.nextToken(",").trim());
                        int b = Integer.parseInt(iTok.nextToken(",").trim());
                        colors.add(new Color(r, g, b));
                    }

                    pal.setColors((Color[]) colors.toArray(new Color[colors.size()]));
                }

                if (item.getNodeName().equals("suitability")) {
                    NodeList schemeSuitability = item.getChildNodes();

                    for( int k = 0; k < schemeSuitability.getLength(); k++ ) {
                        Node palScheme = schemeSuitability.item(k);

                        if (palScheme.getNodeName().equals("scheme")) {
                            int paletteSize = Integer.parseInt(palScheme.getAttributes().getNamedItem("size").getNodeValue());

                            String values = fixToString(palScheme.getFirstChild().toString());
                            String[] list = new String[6];
                            StringTokenizer tok = new StringTokenizer(values);

                            // obtain all 6 values, which should each be
                            // G=GOOD, D=DOUBTFUL, B=BAD, or ?=UNKNOWN.
                            for( int m = 0; m < 6; m++ ) {
                                list[m] = tok.nextToken(",");
                            }

                            suitability.setSuitability(paletteSize, list);
                        }
                    }
                }
            }
View Full Code Here

Examples of org.geotools.brewer.color.PaletteSuitability

        if( getBrewer().hasPalette(Messages.StyleEditor_theme_custom)){
            customPalette = getBrewer().getPalette(Messages.StyleEditor_theme_custom);
            customPalette.setColors(colors.toArray(new Color[0]));
        }else{
            customPalette = new BrewerPalette();
            PaletteSuitability suitability = new PaletteSuitability();
   
            SampleScheme newScheme = new SampleScheme();
            String unknown = "?"; //$NON-NLS-1$
            for (int i = 0; i < colors.size(); i++) {
                if (i > 0) {
                    //create a simple scheme
                    int[] scheme = new int[i+1];
                    for (int j = 0; j < i+1; j++) {
                        scheme[j] = j;
                    }
                    try {
                        newScheme.setSampleScheme(i+1, scheme);
                        //set the suitability to unknown
                        suitability.setSuitability(i+1, new String[] {unknown, unknown, unknown, unknown, unknown, unknown});
                    } catch (Exception e) {
                        // SLDPlugin.log("setSuitability() failed", e); //$NON-NLS-1$
                        // don't block here, give an unknown status
                        suitability = CustomUnknownPaletteSuitability.getInstance();
                        newScheme = new CustomSampleScheme(colors.size());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.