View Javadoc
1   package fr.ifremer.dali.map;
2   
3   /*-
4    * #%L
5    * Dali :: UI
6    * %%
7    * Copyright (C) 2014 - 2017 Ifremer
8    * %%
9    * This program is free software: you can redistribute it and/or modify
10   * it under the terms of the GNU Affero General Public License as published by
11   * the Free Software Foundation, either version 3 of the License, or
12   * (at your option) any later version.
13   * 
14   * This program is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   * GNU General Public License for more details.
18   * 
19   * You should have received a copy of the GNU Affero General Public License
20   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21   * #L%
22   */
23  
24  import org.geotools.geometry.jts.ReferencedEnvelope;
25  
26  /**
27   * A layer metadata used to indicate how and when this layer should be rendered
28   *
29   * @author peck7 on 05/09/2017.
30   */
31  public class MapLayerDefinition {
32  
33      /**
34       * The layer name (WMS layer or shape file name)
35       */
36      private String name;
37  
38      /**
39       * The envelope in witch this layer should be rendered.
40       * If null, this layer will be considered as the default layer
41       * If ReferencedEnvelope.EVERYTHING, this layer be always rendered (graticule for example)
42       */
43      private ReferencedEnvelope viewEnvelope;
44  
45      /**
46       * If this layer allows overlap, another layer with overlapping envelope will be rendered.
47       * If not, only this layer will be render (depending on layer order)
48       */
49      private boolean allowOverlap = true;
50  
51      public MapLayerDefinition(String name) {
52          this.name = name;
53      }
54  
55      public MapLayerDefinition(String name, ReferencedEnvelope viewEnvelope) {
56          this.name = name;
57          this.viewEnvelope = viewEnvelope;
58      }
59  
60      public MapLayerDefinition(String name, boolean allowOverlap) {
61          this.name = name;
62          this.allowOverlap = allowOverlap;
63      }
64  
65      public MapLayerDefinition(String name, ReferencedEnvelope viewEnvelope, boolean allowOverlap) {
66          this.name = name;
67          this.viewEnvelope = viewEnvelope;
68          this.allowOverlap = allowOverlap;
69      }
70  
71      public String getName() {
72          return name;
73      }
74  
75      public ReferencedEnvelope getViewEnvelope() {
76          return viewEnvelope;
77      }
78  
79      public boolean isDefaultLayer() {
80          return viewEnvelope == null;
81      }
82  
83      public boolean isGlobalLayer() {
84          return ReferencedEnvelope.EVERYTHING.equals(viewEnvelope);
85      }
86  
87      public boolean isAllowOverlap() {
88          return allowOverlap;
89      }
90  }