All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.geotools.styling.StyledLayerDescriptorImpl Maven / Gradle / Ivy

Go to download

The main module contains the GeoTools public interfaces that are used by other GeoTools modules (and GeoTools applications). Where possible we make use industry standard terms as provided by OGC and ISO standards. The formal GeoTools public api consists of gt-metadata, jts and the gt-main module. The main module contains the default implementations that are available provided to other GeoTools modules using our factory system. Factories are obtained from an appropriate FactoryFinder, giving applications a chance configure the factory used using the Factory Hints facilities. FilterFactory ff = CommonFactoryFinder.getFilterFactory(); Expression expr = ff.add( expression1, expression2 ); If you find yourself using implementation specific classes chances are you doing it wrong: Expression expr = new AddImpl( expression1, expressiom2 );

The newest version!
/*
 *    GeoTools - The Open Source Java GIS Toolkit
 *    http://geotools.org
 *
 *    (C) 2002-2008, Open Source Geospatial Foundation (OSGeo)
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License as published by the Free Software Foundation;
 *    version 2.1 of the License.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 */
package org.geotools.styling;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.logging.Logger;
import org.geotools.util.Utilities;

/**
 * Holds styling information (from a StyleLayerDescriptor document).
 *
 * 

This class is based on version 1.0 of the SLD specification. * *

For many of us in geotools this is the reason we came along for the ride - a pretty picture. * For documentation on the use of this class please consult the SLD 1.0 specification. * *

We may experiment with our own (or SLD 1.1) ideas but will mark such experiments for you. This * is only an issue of you are considering writing out these objects for interoptability with other * systems. * *

General strategy for supporting multiple SLD versions (and experiments): * *

    *
  • These classes will be BIGGER and more capabile then any one specification *
  • We can define (and support) explicit interfaces tracking each version (preferably GeoAPI * would hold these) *
  • We can use Factories (aka SLD1Factory and SLD1_1Factory and SEFactory) to support the * creation of conformant datastructures. Code (such as user interfaces) can be parameratized * with these factories when they need to confirm to an exact version supported by an * individual service. We hope that specifications are always adaptive, and will be forced to * throw unsupported exceptions when functionality is removed from a specification. *
*/ public class StyledLayerDescriptorImpl implements StyledLayerDescriptor { /** The logger for the default core module. */ private static final Logger LOGGER = org.geotools.util.logging.Logging.getLogger(StyledLayerDescriptorImpl.class); /** Holds value of property name. */ private String name; /** Holds value of property title. */ private String title; /** Holds value of property abstract. */ private String abstractStr; private List layers = new ArrayList(); /** * Convenience method for grabbing the default style from the StyledLayerDescriptor. * * @return first Style (in SLD-->UserLayers-->UserStyles) that claims to be the default */ public Style getDefaultStyle() { // descend into the layers for (int i = 0; i < layers.size(); i++) { StyledLayer layer = (StyledLayer) layers.get(i); if (layer instanceof UserLayer) { UserLayer userLayer = (UserLayer) layer; // descend into the styles Style[] styles = userLayer.getUserStyles(); for (int j = 0; j < styles.length; j++) { // return the first style that claims to be the default if (styles[j].isDefault()) { return styles[j]; } } } } return null; } public StyledLayer[] getStyledLayers() { return (StyledLayerImpl[]) layers.toArray(new StyledLayerImpl[layers.size()]); } public void setStyledLayers(StyledLayer[] layers) { this.layers.clear(); for (int i = 0; i < layers.length; i++) { addStyledLayer(layers[i]); } LOGGER.fine("StyleLayerDescriptorImpl added " + this.layers.size() + " styled layers"); } public List layers() { return layers; } public void addStyledLayer(StyledLayer layer) { layers.add((StyledLayerImpl) layer); } /** * Getter for property name. * * @return Value of property name. */ public String getName() { return this.name; } /** * Setter for property name. * * @param name New value of property name. */ public void setName(String name) { this.name = name; } /** * Getter for property title. * * @return Value of property title. */ public String getTitle() { return this.title; } /** * Setter for property title. * * @param title New value of property title. */ public void setTitle(String title) { this.title = title; } /** * Getter for property abstractStr. * * @return Value of property abstractStr. */ public java.lang.String getAbstract() { return abstractStr; } /** * Setter for property abstractStr. * * @param abstractStr New value of property abstractStr. */ public void setAbstract(java.lang.String abstractStr) { this.abstractStr = abstractStr; } public void accept(StyleVisitor visitor) { visitor.visit(this); } public boolean equals(Object oth) { if (this == oth) { return true; } if (oth instanceof StyledLayerDescriptorImpl) { StyledLayerDescriptorImpl other = (StyledLayerDescriptorImpl) oth; return (Utilities.equals(abstractStr, other.abstractStr) && Utilities.equals(layers, other.layers) && Utilities.equals(name, other.name) && Utilities.equals(title, other.title)); } return false; } @Override public int hashCode() { return Objects.hash(name, title, abstractStr, layers); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy