Mercurial > dive4elements > river
diff artifacts/src/main/java/org/dive4elements/river/artifacts/model/map/WMSLayerFacet.java @ 9619:63bbd5e45839
#21 WMS Legend
author | dnt_bjoernsen <d.tironi@bjoernsen.de> |
---|---|
date | Thu, 10 Oct 2019 16:08:47 +0200 |
parents | e4606eae8ea5 |
children |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/map/WMSLayerFacet.java Thu Oct 10 16:02:31 2019 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/map/WMSLayerFacet.java Thu Oct 10 16:08:47 2019 +0200 @@ -8,8 +8,10 @@ package org.dive4elements.river.artifacts.model.map; -import com.vividsolutions.jts.geom.Envelope; +import java.util.ArrayList; +import java.util.List; +import org.apache.log4j.Logger; import org.dive4elements.artifactdatabase.state.DefaultFacet; import org.dive4elements.artifactdatabase.state.Facet; import org.dive4elements.artifacts.Artifact; @@ -18,183 +20,157 @@ import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator; import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; import org.dive4elements.river.utils.GeometryUtils; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.log4j.Logger; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; +import com.vividsolutions.jts.geom.Envelope; -public class WMSLayerFacet -extends DefaultFacet -{ - protected ComputeType type; +public class WMSLayerFacet extends DefaultFacet { + private static final long serialVersionUID = 1L; + protected ComputeType type; protected List<String> layers; - protected String stateId; - protected String hash; - protected String url; - protected Envelope extent; - protected Envelope originalExtent; - protected String srid; - + protected String stateId; + protected String hash; + protected String url; + protected Envelope extent; + protected Envelope originalExtent; + protected String srid; + private String legend; + private String imagepath; private static final Logger log = Logger.getLogger(WMSLayerFacet.class); public WMSLayerFacet() { } - - public WMSLayerFacet(int index, String name, String description) { + public WMSLayerFacet(final int index, final String name, final String description) { this(index, name, description, ComputeType.FEED, null, null); } - - public WMSLayerFacet( - int index, - String name, - String description, - ComputeType type, - String stateId, - String hash + public WMSLayerFacet(final int index, final String name, final String description, final ComputeType type, final String stateId, final String hash ) { super(index, name, description); - this.layers = new ArrayList<String>(); - this.type = type; + this.layers = new ArrayList<>(); + this.type = type; this.stateId = stateId; - this.hash = hash; + this.hash = hash; } - - public WMSLayerFacet( - int index, - String name, - String description, - ComputeType type, - String stateId, - String hash, - String url - ) { + public WMSLayerFacet(final int index, final String name, final String description, final ComputeType type, final String stateId, final String hash, + final String url) { this(index, name, description, type, stateId, hash); this.url = url; } - - public void addLayer(String name) { + public void addLayer(final String name) { if (name != null && name.length() > 0) { - layers.add(name); + this.layers.add(name); } } - public List<String> getLayers() { - return layers; + return this.layers; } - - public void removeLayer(String layer) { - if (layers != null) { - layers.remove(layer); + public void removeLayer(final String layer) { + if (this.layers != null) { + this.layers.remove(layer); } } - - public void setExtent(Envelope extent) { + public void setExtent(final Envelope extent) { if (extent != null) { this.extent = extent; - } - else { + } else { log.debug("setExtent(): extent is null"); } } - public Envelope getExtent() { - return extent; + return this.extent; } - - public void setOriginalExtent(Envelope originalExtent) { + public void setOriginalExtent(final Envelope originalExtent) { this.originalExtent = originalExtent; } - public Envelope getOriginalExtent() { - return originalExtent; + return this.originalExtent; } - - public void setSrid(String srid) { + public void setSrid(final String srid) { if (srid != null) { this.srid = srid; } } - public String getSrid() { - return srid; + return this.srid; } - @Override - public Object getData(Artifact artifact, CallContext context) { + public Object getData(final Artifact artifact, final CallContext context) { return null; } - @Override - public Node toXML(Document doc) { - ElementCreator ec = new ElementCreator( - doc, - ArtifactNamespaceContext.NAMESPACE_URI, - ArtifactNamespaceContext.NAMESPACE_PREFIX); + public Node toXML(final Document doc) { + final ElementCreator ec = new ElementCreator(doc, ArtifactNamespaceContext.NAMESPACE_URI, ArtifactNamespaceContext.NAMESPACE_PREFIX); - Element facet = ec.create("facet"); - ec.addAttr(facet, "description", description, true); - ec.addAttr(facet, "index", String.valueOf(index), true); - ec.addAttr(facet, "name", name, true); - ec.addAttr(facet, "url", url, true); - ec.addAttr(facet, "layers", layers.get(0), true); - ec.addAttr(facet, "srid", srid != null ? srid : "", true); - ec.addAttr(facet, "extent", originalExtent != null - ? GeometryUtils.jtsBoundsToOLBounds(originalExtent) - : "", true); + final Element facet = ec.create("facet"); + ec.addAttr(facet, "description", this.description, true); + ec.addAttr(facet, "index", String.valueOf(this.index), true); + ec.addAttr(facet, "name", this.name, true); + ec.addAttr(facet, "url", this.url, true); + ec.addAttr(facet, "layers", this.layers.get(0), true); + ec.addAttr(facet, "srid", this.srid != null ? this.srid : "", true); + ec.addAttr(facet, "extent", this.originalExtent != null ? GeometryUtils.jtsBoundsToOLBounds(this.originalExtent) : "", true); ec.addAttr(facet, "queryable", String.valueOf(isQueryable()), true); + ec.addAttr(facet, "imagepath", this.imagepath, true); + ec.addAttr(facet, "legend", this.legend, true); return facet; } + public void setLegend(final String legend) { + this.legend = legend; + } + + /* Code-Kongruenz */ + public String getLegend() { + return this.legend; + } public boolean isQueryable() { return false; } - /** Clone facet-bound data. */ - protected void cloneData(WMSLayerFacet copy) { - copy.type = type; - copy.stateId = stateId; - copy.hash = hash; + protected void cloneData(final WMSLayerFacet copy) { + copy.type = this.type; + copy.stateId = this.stateId; + copy.hash = this.hash; - if (layers != null) { - copy.layers = new ArrayList<String>(layers); - } - else { - copy.layers = new ArrayList<String>(); + if (this.layers != null) { + copy.layers = new ArrayList<>(this.layers); + } else { + copy.layers = new ArrayList<>(); } - copy.originalExtent = originalExtent; - copy.url = url; - copy.extent = extent; - copy.srid = srid; + copy.originalExtent = this.originalExtent; + copy.url = this.url; + copy.extent = this.extent; + copy.srid = this.srid; + + copy.imagepath = imagepath; + copy.legend = legend; } @Override public Facet deepCopy() { - WMSLayerFacet copy = new WMSLayerFacet(); + final WMSLayerFacet copy = new WMSLayerFacet(); copy.set(this); cloneData(copy);