Package org.locationtech.udig.style.jgrass.core

Examples of org.locationtech.udig.style.jgrass.core.GrassColorTable


            colorRulesEditor = new ColorEditor(parent, SWT.NONE);

            String[] mapsetPathAndMapName = JGrassCatalogUtilities
                    .getMapsetpathAndMapnameFromJGrassMapGeoResource(resource);

            GrassColorTable ctable = null;
            Enumeration<ColorRule> rules = null;

            try {
                while( rules == null || !rules.hasMoreElements() ) {

                    try {
                        ctable = new GrassColorTable(mapsetPathAndMapName[0],
                                mapsetPathAndMapName[1], null);
                    } catch (IOException e1) {
                        JGrassrasterStyleActivator.log("JGrassrasterStyleActivator problem", e1); //$NON-NLS-1$
                        e1.printStackTrace();
                    }
                    rules = ctable.getColorRules();

                    // create a default color file
                    if (rules == null || !rules.hasMoreElements()) {
                        ctable.createDefaultColorRulesString(null, true);
                    }

                }
            } catch (Exception e) {
                JGrassrasterStyleActivator
                        .log(
                                "JGrassrasterStyleActivator problem: eu.hydrologis.jgrass.style.jgrassraster.colors#JGrassRasterStyleEditorPage#createPageContent", e); //$NON-NLS-1$

                e.printStackTrace();
            }

            ArrayList<Rule> listOfRules = new ArrayList<Rule>();

            while( rules.hasMoreElements() ) {
                ColorRule element = (ColorRule) rules.nextElement();

                float lowvalue = element.getLowCategoryValue();
                float highvalue = element.getLowCategoryValue() + element.getCategoryRange();
                byte[] lowcatcol = element.getColor(lowvalue);
                byte[] highcatcol = element.getColor(highvalue);

                float[] lowHigh = new float[]{lowvalue, highvalue};
                Color lowColor = new Color(Display.getDefault(), (int) (lowcatcol[0] & 0xff),
                        (int) (lowcatcol[1] & 0xff), (int) (lowcatcol[2] & 0xff));
                Color highColor = new Color(Display.getDefault(), (int) (highcatcol[0] & 0xff),
                        (int) (highcatcol[1] & 0xff), (int) (highcatcol[2] & 0xff));

                listOfRules.add(new Rule(lowHigh, lowColor, highColor, true));
            }

            colorRulesEditor.setLayer(layer);

            colorRulesEditor.setAlphaValue(ctable.getAlpha());

            colorRulesEditor.setRulesList(listOfRules);
        } else {
            Label problemLabel = new Label(parent, SWT.NONE);
            problemLabel.setText("No support for map styling of map type: \"" + type + "\"");
View Full Code Here


            }
        }
    }
    private void makeSomeColor( String colrpath ) {
        GrassColorTable ctable = null;
        Enumeration<ColorRule> rules = null;

        try {
            while( rules == null || !rules.hasMoreElements() ) {

                try {
                    ctable = new GrassColorTable(colrpath, null);
                } catch (IOException e1) {
                    JGrassrasterStyleActivator.log("JGrassrasterStyleActivator problem", e1); //$NON-NLS-1$
                    e1.printStackTrace();
                }
                rules = ctable.getColorRules();

                // create a default color file
                if (rules == null || !rules.hasMoreElements()) {
                    ctable.createDefaultColorRulesString(null, true);
                }

            }
        } catch (Exception e) {
            JGrassrasterStyleActivator
                    .log("JGrassrasterStyleActivator problem: eu.hydrologis.jgrass.style.jgrassraster.colors#ColorEditor#makeSomeColor", e); //$NON-NLS-1$
            e.printStackTrace();
        }

        ArrayList<Rule> listOfRules = new ArrayList<Rule>();

        while( rules.hasMoreElements() ) {
            ColorRule element = rules.nextElement();

            float lowvalue = element.getLowCategoryValue();
            float highvalue = element.getLowCategoryValue() + element.getCategoryRange();
            byte[] lowcatcol = element.getColor(lowvalue);
            byte[] highcatcol = element.getColor(highvalue);

            float[] lowHigh = new float[]{lowvalue, highvalue};
            Color lowColor = new Color(Display.getDefault(), (lowcatcol[0] & 0xff), (lowcatcol[1] & 0xff), (lowcatcol[2] & 0xff));
            Color highColor = new Color(Display.getDefault(), (highcatcol[0] & 0xff), (highcatcol[1] & 0xff),
                    (highcatcol[2] & 0xff));

            listOfRules.add(new Rule(lowHigh, lowColor, highColor, true));
        }

        this.setLayer(layer);

        this.setAlphaValue(ctable.getAlpha());

        this.setRulesList(listOfRules);

    }
View Full Code Here

TOP

Related Classes of org.locationtech.udig.style.jgrass.core.GrassColorTable

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.