Package org.geotools.styling

Examples of org.geotools.styling.StyleFactory


        ImageAssert.assertEquals(expected, img, THRESHOLD);
    }
   
    @Test
    public void testExternalImage() throws Exception {
        StyleFactory sfact =  CommonFactoryFinder.getStyleFactory();
        FilterFactory ffact =  CommonFactoryFinder.getFilterFactory();
       
        GraphicalSymbol gs = sfact.createExternalGraphic(KMLTest.class.getResource("arrow-16.png"), "image/png");
       
        Graphic g = sfact.graphic(Arrays.asList(gs), Expression.NIL, Expression.NIL, Expression.NIL, null, null);
        Symbolizer symb = sfact.pointSymbolizer(null, ffact.property(null), null, null, g);
        Rule r = sfact.rule(null, null, null, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, Arrays.asList(symb), null);
        FeatureTypeStyle fts = sfact.featureTypeStyle(null, null, null, Collections.<Name> emptySet(), Collections.<SemanticType> emptySet(), Arrays.asList(r));
        Style s = sfact.style(null, null, true, Arrays.asList(fts), null);
       
        BufferedImage img = IconRenderer.renderIcon((org.geotools.styling.Style)s);
       
        // Default mark size, plus border, plus padding, times rendering scale, plus extra padding.
        final int size = (16+0+1+1)*4;
 
View Full Code Here


        ImageAssert.assertEquals(expected, img, THRESHOLD);
    }
   
    @Test
    public void testExternalImageRotated45() throws Exception {
        StyleFactory sfact =  CommonFactoryFinder.getStyleFactory();
        FilterFactory ffact =  CommonFactoryFinder.getFilterFactory();
       
        GraphicalSymbol gs = sfact.createExternalGraphic(KMLTest.class.getResource("arrow-16.png"), "image/png");
       
        Graphic g = sfact.graphic(Arrays.asList(gs), Expression.NIL, Expression.NIL, ffact.literal(45.0), null, null);
        Symbolizer symb = sfact.pointSymbolizer(null, ffact.property(null), null, null, g);
        Rule r = sfact.rule(null, null, null, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, Arrays.asList(symb), null);
        FeatureTypeStyle fts = sfact.featureTypeStyle(null, null, null, Collections.<Name> emptySet(), Collections.<SemanticType> emptySet(), Arrays.asList(r));
        Style s = sfact.style(null, null, true, Arrays.asList(fts), null);
       
        BufferedImage img = IconRenderer.renderIcon((org.geotools.styling.Style)s);
       
        // Default mark size, plus border, plus padding, times rendering scale, plus extra padding.
        final int baseSize = 16;
View Full Code Here

        ImageAssert.assertEquals(expected, img, THRESHOLD);
    }
   
    @Test
    public void testBigExternalImage() throws Exception {
        StyleFactory sfact =  CommonFactoryFinder.getStyleFactory();
        FilterFactory ffact =  CommonFactoryFinder.getFilterFactory();
       
        GraphicalSymbol gs = sfact.createExternalGraphic(KMLTest.class.getResource("planet-42.png"), "image/png");
       
        Graphic g = sfact.graphic(Arrays.asList(gs), Expression.NIL, Expression.NIL, Expression.NIL, null, null);
        Symbolizer symb = sfact.pointSymbolizer(null, ffact.property(null), null, null, g);
        Rule r = sfact.rule(null, null, null, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, Arrays.asList(symb), null);
        FeatureTypeStyle fts = sfact.featureTypeStyle(null, null, null, Collections.<Name> emptySet(), Collections.<SemanticType> emptySet(), Arrays.asList(r));
        Style s = sfact.style(null, null, true, Arrays.asList(fts), null);
       
        BufferedImage img = IconRenderer.renderIcon((org.geotools.styling.Style)s);
       
        // Default mark size, plus border, plus padding, times rendering scale, plus extra padding.
        final int size = (42+0+1+1)*4;
 
View Full Code Here

        ImageAssert.assertEquals(expected, img, THRESHOLD);
    }
   
    @Test
    public void testBigExternalImageSpecifySize() throws Exception {
        StyleFactory sfact =  CommonFactoryFinder.getStyleFactory();
        FilterFactory ffact =  CommonFactoryFinder.getFilterFactory();
       
        GraphicalSymbol gs = sfact.createExternalGraphic(KMLTest.class.getResource("planet-42.png"), "image/png");
       
        Graphic g = sfact.graphic(Arrays.asList(gs), Expression.NIL, ffact.literal(42), Expression.NIL, null, null);
        Symbolizer symb = sfact.pointSymbolizer(null, ffact.property(null), null, null, g);
        Rule r = sfact.rule(null, null, null, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, Arrays.asList(symb), null);
        FeatureTypeStyle fts = sfact.featureTypeStyle(null, null, null, Collections.<Name> emptySet(), Collections.<SemanticType> emptySet(), Arrays.asList(r));
        Style s = sfact.style(null, null, true, Arrays.asList(fts), null);
       
        BufferedImage img = IconRenderer.renderIcon((org.geotools.styling.Style)s);
       
        // Default mark size, plus border, plus padding, times rendering scale, plus extra padding.
        final int size = (42+0+1+1)*4;
 
View Full Code Here

        ImageAssert.assertEquals(expected, img, THRESHOLD);
    }
   
    @Test
    public void testBigExternalImageNilExpressionSize() throws Exception {
        StyleFactory sfact =  CommonFactoryFinder.getStyleFactory();
        FilterFactory ffact =  CommonFactoryFinder.getFilterFactory();
       
        GraphicalSymbol gs = sfact.createExternalGraphic(KMLTest.class.getResource("planet-42.png"), "image/png");
       
        Graphic g = sfact.graphic(Arrays.asList(gs), Expression.NIL, Expression.NIL, Expression.NIL, null, null);
        Symbolizer symb = sfact.pointSymbolizer(null, ffact.property(null), null, null, g);
        Rule r = sfact.rule(null, null, null, Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, Arrays.asList(symb), null);
        FeatureTypeStyle fts = sfact.featureTypeStyle(null, null, null, Collections.<Name> emptySet(), Collections.<SemanticType> emptySet(), Arrays.asList(r));
        Style s = sfact.style(null, null, true, Arrays.asList(fts), null);
       
        BufferedImage img = IconRenderer.renderIcon((org.geotools.styling.Style)s);
       
        // Default mark size, plus border, plus padding, times rendering scale, plus extra padding.
        final int size = (42+0+1+1)*4;
 
View Full Code Here

    }

    private Style getStyle(final String styleName) {
        Style style = STYLES.get(styleName);
        if (style == null) {
            StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory(GeoTools
                    .getDefaultHints());
            SLDParser parser = new SLDParser(styleFactory);
            try {
                parser.setInput(getClass().getResource(styleName));
            } catch (IOException e) {
View Full Code Here

     *
     * @return
     */
    private Style createSampleStyleWithScale() {
        FilterFactory ff = FilterFactory.createFilterFactory();
        StyleFactory sf = StyleFactory.createStyleFactory();
        Style s = sf.createStyle();

        Rule rule1_1000 = sf.createRule();
        Fill redFill = sf.createFill(ff.createLiteralExpression("0xFF0000"));
        Symbolizer redSym = sf.createPolygonSymbolizer(null, redFill, null);
        rule1_1000.setSymbolizers(new Symbolizer[] { redSym });
        rule1_1000.setMaxScaleDenominator(1000);

        Rule rule1_5000 = sf.createRule();
        Fill blueFill = sf.createFill(ff.createLiteralExpression("0x0000FF"));
        Symbolizer blueSym = sf.createPolygonSymbolizer(null, blueFill, null);
        rule1_5000.setSymbolizers(new Symbolizer[] { blueSym });
        rule1_5000.setMinScaleDenominator(1000);
        rule1_5000.setMaxScaleDenominator(5000);

        Rule[] rules = new Rule[] { rule1_1000, rule1_5000 };
        FeatureTypeStyle fts = sf.createFeatureTypeStyle(rules);

        s.setFeatureTypeStyles(new FeatureTypeStyle[] { fts });

        return s;
    }
View Full Code Here

        isr.close();
        style.setFilename(new File(styleDir, filename));

        style.setId(styleID);

        StyleFactory factory = StyleFactory.createStyleFactory();
        SLDParser styleReader = new SLDParser(factory, newSldFile.toURL());
        Style[] readStyles = null;
        Style newStyle;

        try {
View Full Code Here

            /**
             * Override so it does not try to load a file from disk
             */
            @Override
            public Style getStyle() throws IOException {
                StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory(null);
                Style style = styleFactory.createStyle();
                style.setName("Default Style");
                return style;
            }
        };
        defaultStyle.setFilename("defaultStyleFileName");
View Full Code Here

TOP

Related Classes of org.geotools.styling.StyleFactory

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.