/[schmitzm]/trunk/src/skrueger/geotools/StyledFS.java
ViewVC logotype

Diff of /trunk/src/skrueger/geotools/StyledFS.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2 by mojays, Tue Feb 24 22:43:52 2009 UTC revision 223 by alfonx, Tue Jul 14 15:01:57 2009 UTC
# Line 15  import javax.swing.JPanel; Line 15  import javax.swing.JPanel;
15  import org.apache.log4j.Logger;  import org.apache.log4j.Logger;
16  import org.geotools.data.FeatureSource;  import org.geotools.data.FeatureSource;
17  import org.geotools.feature.AttributeType;  import org.geotools.feature.AttributeType;
18    import org.geotools.feature.FeatureCollection;
19  import org.geotools.styling.Style;  import org.geotools.styling.Style;
20  import org.opengis.referencing.crs.CoordinateReferenceSystem;  import org.opengis.referencing.crs.CoordinateReferenceSystem;
21    
# Line 64  public class StyledFS implements StyledF Line 65  public class StyledFS implements StyledF
65           */           */
66          public StyledFS(FeatureSource fs, File sldFile) {          public StyledFS(FeatureSource fs, File sldFile) {
67    
                 super();  
68                  this.fs = fs;                  this.fs = fs;
69                  id = StyledFS.class.getSimpleName()                  id = StyledFS.class.getSimpleName()
70                                  + new Random(new Date().getTime()).nextInt(10000000);                                  + new Random(new Date().getTime()).nextInt(10000000);
# Line 77  public class StyledFS implements StyledF Line 77  public class StyledFS implements StyledF
77                          } catch (FileNotFoundException e) {                          } catch (FileNotFoundException e) {
78                                  LOGGER                                  LOGGER
79                                                  .debug("The SLD file passed was empty. Leaving the Style untouched. (We are in the constructor.. so its null");                                                  .debug("The SLD file passed was empty. Leaving the Style untouched. (We are in the constructor.. so its null");
80                            } catch (Exception e) {
81                                    LOGGER.warn("Reading SLD failed: " + sldFile, e);
82                          }                          }
83                  }                  }
   
84                  title = new Translation();                  title = new Translation();
85                  title.fromOneLine(sldFile.getName());                  title.fromOneLine(sldFile.getName());
86    
# Line 121  public class StyledFS implements StyledF Line 122  public class StyledFS implements StyledF
122                  }                  }
123          }          }
124    
125          public FeatureSource getGeoObject() throws Exception {          public FeatureSource getGeoObject() {
126                  return fs;                  return fs;
127          }          }
128    
# Line 153  public class StyledFS implements StyledF Line 154  public class StyledFS implements StyledF
154                  return false;                  return false;
155          }          }
156    
157          public boolean isHideInLegend() {          /**
158                  return false;           * If true, this layer will not be shown in the legend. Default = false
159          }           */
160            /**
161             *
162             * Killed by SK: 6. April 09: Ein Layer soll nicht generell auf
163             * verstecken/nicht verstecken gestellt werden können. Das sind
164             * Eigenschaften der Karte/MapContext, ebenso wie die Reihenfolge der Layer.
165             * Im Atlas verwaltet deshalb nun die Klasse skrueger.atlas.Map welche Layer
166             * nicht in der Legende auftauchen sollen. Meines Wissens hat keiner bisher
167             * die Funktion genutzt.
168             *
169             * // public boolean isHideInLegend() { // return false; // }
170             */
171    
172          public void setDesc(Translation dec) {          public void setDesc(Translation dec) {
173                  this.desc = dec;                  this.desc = dec;
174          }          }
175    
176          public void setImageIcon(ImageIcon icon) {          public void setImageIcon(ImageIcon icon) {
                 // TODO Auto-generated method stub  
   
177          }          }
178    
179          public void setKeywords(Translation keywords) {          public void setKeywords(Translation keywords) {
# Line 182  public class StyledFS implements StyledF Line 192  public class StyledFS implements StyledF
192          public void uncache() {          public void uncache() {
193          }          }
194    
195            /**
196             *
197             */
198          public Map<Integer, AttributeMetaData> getAttributeMetaDataMap() {          public Map<Integer, AttributeMetaData> getAttributeMetaDataMap() {
199                  if (map == null) {                  if (map == null) {
200    
201                          map = new HashMap<Integer, AttributeMetaData>();                          map = new HashMap<Integer, AttributeMetaData>();
202                            
203                          // Leaving out the first one, it will be the_geom                          // Leaving out the first one, it will be the_geom
204                          for (int i = 1; i < fs.getSchema().getAttributeCount(); i++) {                          for (int i = 1; i < fs.getSchema().getAttributeCount(); i++) {
205                                  AttributeType att = fs.getSchema().getAttributeType(i);                                  AttributeType att = fs.getSchema().getAttributeType(i);
206                                    
207                                  AttributeMetaData attMetaData = new AttributeMetaData(i, att.getLocalName());                                  AttributeMetaData attMetaData = new AttributeMetaData(i, att
208                                                    .getLocalName());
209                                  map.put(i, attMetaData);                                  map.put(i, attMetaData);
210                          }                          }
211                  }                  }
# Line 199  public class StyledFS implements StyledF Line 214  public class StyledFS implements StyledF
214    
215          /**          /**
216           * @return The {@link File} where the SLD was loaded from or           * @return The {@link File} where the SLD was loaded from or
217           *         <code>null</code> if there didn't exist a {@link File}. (It           *         <code>null</code> if there didn't exist a {@link File}. (It could
218           *         could be a WFS or a PostGIS           *         be a WFS or a PostGIS
219           *           *
220           * @author <a href="mailto:[email protected]">Stefan Alfons Kr&uuml;ger</a>           * @author <a href="mailto:[email protected]">Stefan Alfons
221             *         Kr&uuml;ger</a>
222           */           */
223          public File getSldFile() {          public File getSldFile() {
224                  return sldFile;                  return sldFile;
# Line 212  public class StyledFS implements StyledF Line 228  public class StyledFS implements StyledF
228                  this.sldFile = sldFile;                  this.sldFile = sldFile;
229          }          }
230    
231            /**
232             * Returns the features of the {@link FeatureSource}.
233             *
234             * @see {@link StyledFeaturesInterface}
235             */
236            @Override
237            public FeatureCollection getFeatureCollection() {
238                    FeatureCollection features;
239                    try {
240                            features = getGeoObject().getFeatures();
241                    } catch (IOException e) {
242                            throw new RuntimeException(
243                                            "Error getting the features of the  FeatureSource");
244                    }
245                    return features;
246            }
247    
248            /**
249             * Same as {@link #getGeoObject()} method, but complies to the
250             * {@link StyledFeaturesInterface}
251             *
252             * @see {@link StyledFeaturesInterface}
253             */
254            @Override
255            public FeatureSource getFeatureSource() {
256                    return getGeoObject();
257            }
258    
259  }  }

Legend:
Removed from v.2  
changed lines
  Added in v.223

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26