Package org.geotools.styling

Examples of org.geotools.styling.SLDTransformer


        UserLayer layer = sf.createUserLayer();
        layer.setLayerFeatureConstraints(new FeatureTypeConstraint[]{null});
        sld.addStyledLayer(layer);
        layer.addUserStyle(style);

        SLDTransformer aTransformer = new SLDTransformer();
        aTransformer.setIndentation(4);
        String xml = aTransformer.transform(sld);
        return xml;
    }
View Full Code Here


        UserLayer layer = sf.createUserLayer();
        layer.setLayerFeatureConstraints(new FeatureTypeConstraint[]{null});
        sld.addStyledLayer(layer);
        layer.addUserStyle(style);

        SLDTransformer aTransformer = new SLDTransformer();
        aTransformer.setIndentation(4);
        String xml = aTransformer.transform(sld);
        return xml;
    }
View Full Code Here

     */
    public void save( IMemento memento, Object value ) {
        Style style = (Style) value;

        // serialize out the style objects
        SLDTransformer sldWriter = new SLDTransformer();
        String out = ""; //$NON-NLS-1$
        try {
            out = sldWriter.transform(style);
        } catch (TransformerException e) {
            SLDPlugin.log("SLDTransformer failed", e); //$NON-NLS-1$
            e.printStackTrace();
        } catch (Exception e) {
            SLDPlugin.log("SLDTransformer failed", e); //$NON-NLS-1$
View Full Code Here

        return addTo(new String[] {"sld"}, super.getExtentions()); //$NON-NLS-1$
    }
   
    @Override
    public void exportTo( Object target, File file, IProgressMonitor monitor ) throws Exception {
        SLDTransformer aTransformer = new SLDTransformer();
        aTransformer.setIndentation(StyleEditor.INDENT);
        String xml = ""; //$NON-NLS-1$
        if (target instanceof StyledLayerDescriptor) {
            StyledLayerDescriptor sld = (StyledLayerDescriptor) target;
            xml = aTransformer.transform(sld);
        } else {
            SLDPlugin.log("StyledLayerDescriptor not found", null); //$NON-NLS-1$
            throw (IOException) new IOException("SLD not found"); //$NON-NLS-1$
        }
        FileWriter w = new FileWriter(file);
View Full Code Here

     * Amount to indent nested SLD documents
     */
    public static final int INDENT = 4;
   
    public static String styleToXML(StyledLayerDescriptor sld) {
        SLDTransformer aTransformer = new SLDTransformer();
        aTransformer.setIndentation(StyleEditor.INDENT);
        try {
            return aTransformer.transform(sld);
        } catch (TransformerException e) {
            e.printStackTrace();
            return null;
        }
    }
View Full Code Here

    IGeoResource geoResource = getSelectedLayer().getGeoResource();
        ID id = geoResource.getID();
    if (id.isFile()) {
      try {
        File file = id.toFile();
        SLDTransformer aTransformer = new SLDTransformer();
        aTransformer.setIndentation(StyleEditor.INDENT);
        String xml = aTransformer.transform(getSLD());
        File newFile = new File(file.getParent(), FilenameUtils
            .getBaseName(file.getAbsolutePath())
            + SLD_EXTENSION);
        FileUtils.writeStringToFile(newFile, xml);
        MessageDialog.openInformation(getShell(), Messages.SingleBandEditorPage_ExportOkDialogTitle, Messages.SingleBandEditorPage_ExportOkDialogMessage);
View Full Code Here

        nl.addStyle( style );
       
        StyledLayerDescriptor sld = sf.createStyledLayerDescriptor();
        sld.setStyledLayers( new StyledLayer[]{ nl });
       
        SLDTransformer writer = new SLDTransformer();
        if (prettyPrint) {
            writer.setIndentation(2);
        }
        try {
            writer.transform( sld, out );
        }
        catch (TransformerException e) {
            throw (IOException) new IOException().initCause(e);
        }
    }
View Full Code Here

        synchronized ( styleCache ) {
            File styleFile = GeoserverDataDirectory.findStyleFile( info.getFilename(), true );
            BufferedOutputStream out = new BufferedOutputStream( new FileOutputStream( styleFile ) );
           
            try {
                SLDTransformer tx = new SLDTransformer();
                if (format) {
                    tx.setIndentation(2);
                }
                try {
                    tx.transform( style, out );
                }
                catch (TransformerException e) {
                    throw (IOException) new IOException("Error writing style").initCause(e);
                }
                clear(info);
View Full Code Here

    @Override
    public void write(Object value, OutputStream output, Operation operation) throws IOException,
            ServiceException {
        StyledLayerDescriptor sld = (StyledLayerDescriptor) value;

        SLDTransformer tx = new SLDTransformer();
        try {
            tx.setIndentation(4);
            tx.transform(sld, output);
        } catch (TransformerException e) {
            throw new WmsException(e);
        }
    }
View Full Code Here

            try {
                Optional<? extends Style> style = plugin.parseStyle(configuration, clientHttpRequestFactory, styleString, mapContext);
                if (style.isPresent()) {
                    if (LOGGER.isDebugEnabled()) {
                        try {
                            final SLDTransformer transformer = new SLDTransformer();
                            final StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory();
                            final UserLayer userLayer = styleFactory.createUserLayer();
                            userLayer.addUserStyle(style.get());
                            final StyledLayerDescriptor sld = styleFactory.createStyledLayerDescriptor();
                            sld.addStyledLayer(userLayer);
                            if (LOGGER.isDebugEnabled()) {
                                LOGGER.debug("Loaded style from: \n\n '" + styleString + "': \n\n" + transformer.transform(sld));
                            }
                        } catch (Exception e) {
                            LOGGER.debug("Loaded style from: \n\n '" + styleString + "' \n\n<Unable to transform it to xml>: " + e, e);
                        }
                    }
View Full Code Here

TOP

Related Classes of org.geotools.styling.SLDTransformer

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.