Package org.geotools.styling

Examples of org.geotools.styling.Style


       
        RasterSymbolizer rasterSymbolizer = styleFactory.createRasterSymbolizer();
        Rule rule = styleFactory.createRule();
        rule.setSymbolizers(new Symbolizer[]{ rasterSymbolizer });
       
        Style style = styleBuilder.createStyle();
        SLDContentManager sldContentManager = new SLDContentManager(styleBuilder, style);
        sldContentManager.addSymbolizer(rasterSymbolizer);
       
        //set the feature type name
        FeatureTypeStyle fts = sldContentManager.getDefaultFeatureTypeStyle();
        fts.setFeatureTypeName(SLDs.GENERIC_FEATURE_TYPENAME);
        fts.setName("simple"); //$NON-NLS-1$
        fts.setSemanticTypeIdentifiers(new String[] {"generic:geometry", "simple"}); //$NON-NLS-1$ //$NON-NLS-2$
       
        fts.addRule(rule);
        style.addFeatureTypeStyle(fts);
        style.setName("simpleStyle");       
       
        return style;
    }
View Full Code Here


            exGraphic = sf.createExternalGraphic(graphicsPath.toURI().toURL(), "image/png");
        } else if (name.toLowerCase().endsWith(".svg")) {
            exGraphic = sf.createExternalGraphic(graphicsPath.toURI().toURL(), "image/svg+xml");
        } else if (name.toLowerCase().endsWith(".sld")) {
            StyledLayerDescriptor sld = readStyle(graphicsPath);
            Style style = SLDs.getDefaultStyle(sld);
            return new StyleWrapper(style);
        }

        if (exGraphic == null) {
            throw new IOException("Style could not be created!");
        }

        Graphic gr = sf.createDefaultGraphic();
        gr.graphicalSymbols().clear();
        gr.graphicalSymbols().add(exGraphic);
        Expression size = ff.literal(20);
        gr.setSize(size);

        Rule rule = sf.createRule();
        PointSymbolizer pointSymbolizer = sf.createPointSymbolizer(gr, null);
        rule.symbolizers().add(pointSymbolizer);

        FeatureTypeStyle featureTypeStyle = sf.createFeatureTypeStyle();
        featureTypeStyle.rules().add(rule);

        Style namedStyle = sf.createStyle();
        namedStyle.featureTypeStyles().add(featureTypeStyle);
        namedStyle.setName(FilenameUtils.removeExtension(name));

        return new StyleWrapper(namedStyle);
    }
View Full Code Here

        assert( canStyle( layer ));
        // TODO: Ensure framework does not show me when I can't handle this
        // layer
        // TODO: Stop commenting in the first person, as though I am the
        // class.  It's creepy.
        Style style = (Style) getStyleBlackboard().get(SLDContent.ID);
       
        // if no style information, create default
        if (style == null) {
            // TODO: Why do "I" have to do this, can't the framework deal?
            // (It could if I advertise that I deal with SLDContentID type?)
View Full Code Here

            return Mode.ALL; // we are a generic geometry
        }
    }
    @Override
    protected void refresh() {
        Style style = getStyle(); // grab an SLD style or bust

        List<FeatureTypeStyle> ftsList = style.featureTypeStyles();
        FeatureTypeStyle fts = null;
        if (ftsList.size()>0) {
            fts  = ftsList.get(0);
        }
View Full Code Here

        FeatureTypeStyle featureTypeStyle = this.build.createFeatureTypeStyle(
                SLDs.GENERIC_FEATURE_TYPENAME, rule);
        featureTypeStyle.setName("simple"); //$NON-NLS-1$
        featureTypeStyle.setSemanticTypeIdentifiers(new String[]{"generic:geometry", "simple"}); //$NON-NLS-1$ //$NON-NLS-2$

        Style style = (Style) getStyleBlackboard().get(SLDContent.ID);
        style.setDefault(true);
        if (replace.getSelection()) {
            // if repalce was hit we are going to completly redfine the style
            // based on what the user has here
            //
            style.featureTypeStyles().clear();
            style.featureTypeStyles().add(featureTypeStyle);
        } else {
            // if we are just responding to what is going on we will try and update the existing
            // style in place (leaving any other content alone)
            //
            List<FeatureTypeStyle> fts = style.featureTypeStyles();
            boolean match = false;
            for( int i = fts.size() - 1; i > -1; i-- ) {
                if (SLDs.isSemanticTypeMatch(fts.get(i), "simple")) { //$NON-NLS-1$
                    fts.set(i, featureTypeStyle);
                    match = true;
                    break;
                }
            }
            if (match) {
                style.featureTypeStyles().clear();
                style.featureTypeStyles().addAll(fts);
            } else {
                // add the new entry to the array
                List<FeatureTypeStyle> fts2 = new ArrayList<FeatureTypeStyle>(fts);
                Collections.copy(fts2, fts);
                fts2.add(featureTypeStyle);
                style.featureTypeStyles().clear();
                style.featureTypeStyles().addAll(fts2);
            }
        }
        // put style on blackboard
        getStyleBlackboard().put(SLDContent.ID, style);
        ((StyleBlackboard) getStyleBlackboard()).setSelected(new String[]{SLDContent.ID});
View Full Code Here

            public void widgetSelected( SelectionEvent e ) {
                RuleWrapper selectedRule = getSelectedRule();

                FeatureTypeStyle featureTypeStyle = Utilities.sf.createFeatureTypeStyle();
                featureTypeStyle.rules().add(selectedRule.getRule());
                Style namedStyle = Utilities.sf.createStyle();
                namedStyle.featureTypeStyles().add(featureTypeStyle);
                namedStyle.setName(selectedRule.getName());

                try {
                    pointStyleManager.addStyle(new StyleWrapper(namedStyle));
                } catch (Exception e1) {
                    e1.printStackTrace();
View Full Code Here

            public void widgetSelected( SelectionEvent e ) {
                RuleWrapper selectedRule = getSelectedRule();

                FeatureTypeStyle featureTypeStyle = Utilities.sf.createFeatureTypeStyle();
                featureTypeStyle.rules().add(selectedRule.getRule());
                Style namedStyle = Utilities.sf.createStyle();
                namedStyle.featureTypeStyles().add(featureTypeStyle);
                namedStyle.setName(selectedRule.getName());

                try {
                    polygonStyleManager.addStyle(new StyleWrapper(namedStyle));
                } catch (Exception e1) {
                    e1.printStackTrace();
View Full Code Here

        Layer layer = getLayer();
        if (!canStyle(layer)) {
            throw new IllegalStateException("Hey I can't style " + layer); //$NON-NLS-1$
        }
        // pull the sld style off the blackboard, and initialize the cm
        Style style = (Style) getStyleBlackboard().get(SLDContent.ID);
       
        // if no style information, create default
        if (style == null) {
            style = SLDContent.createDefaultStyle();
            getStyleBlackboard().put(SLDContent.ID, style);
View Full Code Here

                  c.setVisible(canStyle);
                }
              }
              if (!canStyle){return;}
             
                Style style = getStyle();
                RasterSymbolizer sym = SLD.rasterSymbolizer(style);

                // set opacity
                opacity.set(sym);
View Full Code Here

        }
      }
     
     
        // get the style off the blackboard and add/modify it
        Style s = (Style) getLayer().getStyleBlackboard().get(SLDContent.ID);

        // get raster symbolizer
        RasterSymbolizer rs = SLD.rasterSymbolizer(s);

        // setup scale
View Full Code Here

TOP

Related Classes of org.geotools.styling.Style

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.