Examples of DuplicatingStyleVisitor


Examples of org.geotools.styling.visitor.DuplicatingStyleVisitor

        IPreferenceStore store = ProjectPlugin.getPlugin().getPreferenceStore();
        boolean transparency = store.getBoolean(PreferenceConstants.P_TRANSPARENCY);
        try {
            if (!transparency) {
                if (style != null) {
                    DuplicatingStyleVisitor duplicator = new DuplicatingStyleVisitor();
                    style.accept(duplicator);
                    style = (Style) duplicator.getCopy();
                    style = removeTransparency(style);
                }
            }
        } catch (Throwable e) {
            RendererPlugin.log("Error duplicating style for transparency setting", e); //$NON-NLS-1$
View Full Code Here

Examples of org.geotools.styling.visitor.DuplicatingStyleVisitor

            throw new WmsException(e);
        }
    }

    private Style cloneStyle(Style style) {
        DuplicatingStyleVisitor cloner = new DuplicatingStyleVisitor();
        style.accept(cloner);
        style = (Style) cloner.getCopy();
        return style;
    }
View Full Code Here

Examples of org.geotools.styling.visitor.DuplicatingStyleVisitor

            return;
        }
        for (FeatureTypeStyle featureTypeStyle : style.featureTypeStyles()) {
            for (int i = 0; i < featureTypeStyle.rules().size(); i++) {
                Rule rule = featureTypeStyle.rules().get(i);
                DuplicatingStyleVisitor update = new DuplicatingStyleVisitor() {

                    @Override
                    public void visit(LineSymbolizer line) {
                        String name = line.getGeometryPropertyName();
                        Stroke stroke = update(line.getStroke());
                        LineSymbolizer copy = sf.createLineSymbolizer(stroke, name);
                        pages.push(copy);
                    }

                    Stroke update(Stroke stroke) {
                        Expression color = ff.literal(colour);
                        Expression width = copy(stroke.getWidth());
                        Expression opacity = copy(stroke.getOpacity());
                        Expression lineJoin = copy(stroke.getLineJoin());
                        Expression lineCap = copy(stroke.getLineCap());
                        float[] dashArray = copy(stroke.getDashArray());
                        Expression dashOffset = copy(stroke.getDashOffset());
                        Graphic graphicStroke = copy(stroke.getGraphicStroke());
                        Graphic graphicFill = copy(stroke.getGraphicFill());
                        return sf.createStroke(color, width, opacity, lineJoin, lineCap, dashArray, dashOffset, graphicFill, graphicStroke);
                    }
                };
                rule.accept(update);
                Rule updatedRule = (Rule) update.getCopy();
                featureTypeStyle.rules().set(i, updatedRule);
            }
        }
    }
View Full Code Here

Examples of org.geotools.styling.visitor.DuplicatingStyleVisitor

        }
        for (FeatureTypeStyle featureTypeStyle : style.featureTypeStyles()) {
            for (int i = 0; i < featureTypeStyle.rules().size(); i++) {
                Rule rule = featureTypeStyle.rules().get(i);

                DuplicatingStyleVisitor update = new DuplicatingStyleVisitor() {
                    @Override
                    public void visit(RasterSymbolizer raster) {

                        ChannelSelection channelSelection = copy(raster.getChannelSelection());
                        ColorMap colorMap = copy(raster.getColorMap());
                        ContrastEnhancement ce = copy(raster.getContrastEnhancement());
                        String geometryProperty = raster.getGeometryPropertyName();
                        Symbolizer outline = copy(raster.getImageOutline());
                        Expression overlap = copy(raster.getOverlap());
                        ShadedRelief shadedRelief = copy(raster.getShadedRelief());

                        Expression newOpacity = ff.literal(opacity);

                        RasterSymbolizer copy = sf.createRasterSymbolizer(geometryProperty, newOpacity, channelSelection,
                                overlap, colorMap, ce, shadedRelief, outline);

                        if (STRICT && !copy.equals(raster)) {
                            throw new IllegalStateException("Was unable to duplicate provided raster:" + raster);
                        }
                        pages.push(copy);
                    }
                };

                rule.accept(update);
                Rule updatedRule = (Rule) update.getCopy();
                featureTypeStyle.rules().set(i, updatedRule);
            }
        }
    }
View Full Code Here

Examples of org.geotools.styling.visitor.DuplicatingStyleVisitor

        }
        for (FeatureTypeStyle featureTypeStyle : style.featureTypeStyles()) {
            for (int i = 0; i < featureTypeStyle.rules().size(); i++) {
                Rule rule = featureTypeStyle.rules().get(i);

                DuplicatingStyleVisitor update = new DuplicatingStyleVisitor() {

                    @Override
                    public void visit(RasterSymbolizer raster) {

                        ChannelSelection channelSelection = createChannelSelection();

                        ColorMap colorMap = copy(raster.getColorMap());
                        ContrastEnhancement ce = copy(raster.getContrastEnhancement());
                        String geometryProperty = raster.getGeometryPropertyName();
                        Symbolizer outline = copy(raster.getImageOutline());
                        Expression overlap = copy(raster.getOverlap());
                        ShadedRelief shadedRelief = copy(raster.getShadedRelief());

                        Expression opacity = copy(raster.getOpacity());

                        RasterSymbolizer copy = sf.createRasterSymbolizer(geometryProperty, opacity,
                                channelSelection, overlap, colorMap, ce,
                                shadedRelief, outline);
                        if (STRICT && !copy.equals(raster)) {
                            throw new IllegalStateException("Was unable to duplicate provided raster:" + raster);
                        }
                        pages.push(copy);
                    }

                    private ChannelSelection createChannelSelection() {
                        if (rgb == null) {
                            return sf.createChannelSelection(new SelectedChannelType[]{gray});
                        } else {
                            return sf.createChannelSelection(rgb);
                        }
                    }
                };

                rule.accept(update);
                Rule updatedRule = (Rule) update.getCopy();
                featureTypeStyle.rules().set(i, updatedRule);
            }
        }
    }
View Full Code Here

Examples of org.geotools.styling.visitor.DuplicatingStyleVisitor

        Style namedStyle = sf.createStyle();
        namedStyle.addFeatureTypeStyle( style );
        namedStyle.setName( "Feature" );

        DuplicatingStyleVisitor duplicator = new DuplicatingStyleVisitor();
        namedStyle.accept( duplicator );
        Style namedStyle2 = (Style ) duplicator.getCopy();

        SLDTransformer writer = new SLDTransformer();
        String out = writer.transform( style );
       
        assertNotNull( out );
View Full Code Here

Examples of org.geotools.styling.visitor.DuplicatingStyleVisitor

        assertEqualsContract(clone, notEq, fill);
    }

    public void testStroke() {
        Stroke stroke = styleFactory.getDefaultStroke();
        DuplicatingStyleVisitor duplicate = new DuplicatingStyleVisitor( styleFactory );
        stroke.accept( duplicate );
        Stroke clone = (Stroke) duplicate.getCopy();
       
        assertClone(stroke, clone);

        Stroke notEq = styleFactory.createStroke(filterFactory.literal("#FF0000"), filterFactory
                .literal(10));
        assertEqualsContract(clone, notEq, stroke);

        // a stroke is a complex object with lots of properties,
        // need more extensive tests here.
        Stroke dashArray = styleFactory.getDefaultStroke();
        dashArray.setDashArray(new float[] { 1.0f, 2.0f, 3.0f });

        dashArray.accept( duplicate );
        Stroke dashArray2 = (Stroke) duplicate.getCopy();
        assertEqualsContract(dashArray, dashArray2);
    }
View Full Code Here

Examples of org.geotools.styling.visitor.DuplicatingStyleVisitor

            throw new ServiceException(e);
        }
    }

    private Style cloneStyle(Style style) {
        DuplicatingStyleVisitor cloner = new DuplicatingStyleVisitor();
        style.accept(cloner);
        style = (Style) cloner.getCopy();
        return style;
    }
View Full Code Here

Examples of org.geotools.styling.visitor.DuplicatingStyleVisitor

            throw new ServiceException(e);
        }
    }

    private Style cloneStyle(Style style) {
        DuplicatingStyleVisitor cloner = new DuplicatingStyleVisitor();
        style.accept(cloner);
        style = (Style) cloner.getCopy();
        return style;
    }
View Full Code Here

Examples of org.geotools.styling.visitor.DuplicatingStyleVisitor

     *
     * @param symbolizer symbolizer to clone
     * @return cloned PointSymbolizer
     */
    private PointSymbolizer cloneSymbolizer(Symbolizer symbolizer) {
        DuplicatingStyleVisitor duplicator = new DuplicatingStyleVisitor();
        symbolizer.accept(duplicator);
        PointSymbolizer pointSymbolizer = (PointSymbolizer) duplicator
                .getCopy();
        return pointSymbolizer;
    }
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.