/[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 332 by alfonx, Wed Aug 26 17:15:49 2009 UTC revision 422 by alfonx, Fri Oct 2 00:47:48 2009 UTC
# Line 34  import java.io.FileNotFoundException; Line 34  import java.io.FileNotFoundException;
34  import java.io.IOException;  import java.io.IOException;
35  import java.net.URL;  import java.net.URL;
36  import java.util.Date;  import java.util.Date;
 import java.util.HashMap;  
 import java.util.Map;  
37  import java.util.Random;  import java.util.Random;
38    
39  import javax.swing.ImageIcon;  import javax.swing.ImageIcon;
# Line 45  import org.apache.log4j.Logger; Line 43  import org.apache.log4j.Logger;
43  import org.geotools.data.FeatureSource;  import org.geotools.data.FeatureSource;
44  import org.geotools.feature.FeatureCollection;  import org.geotools.feature.FeatureCollection;
45  import org.geotools.styling.Style;  import org.geotools.styling.Style;
46    import org.opengis.feature.simple.SimpleFeature;
47    import org.opengis.feature.simple.SimpleFeatureType;
48  import org.opengis.feature.type.AttributeDescriptor;  import org.opengis.feature.type.AttributeDescriptor;
49  import org.opengis.referencing.crs.CoordinateReferenceSystem;  import org.opengis.referencing.crs.CoordinateReferenceSystem;
50    
# Line 63  import com.vividsolutions.jts.geom.Envel Line 63  import com.vividsolutions.jts.geom.Envel
63  public class StyledFS implements StyledFeatureSourceInterface {  public class StyledFS implements StyledFeatureSourceInterface {
64          private static final Logger LOGGER = Logger.getLogger(StyledFS.class);          private static final Logger LOGGER = Logger.getLogger(StyledFS.class);
65    
66          private final FeatureSource fs;          private final FeatureSource<SimpleFeatureType, SimpleFeature> fs;
67    
68          /**          /**
69           * A unique ID which identifies the Layer in the Atlas. It's more important           * A unique ID which identifies the Layer in the Atlas. It's more important
# Line 79  public class StyledFS implements StyledF Line 79  public class StyledFS implements StyledF
79    
80          private File sldFile;          private File sldFile;
81    
82          private HashMap<Integer, AttributeMetaData> map;          private AttributeMetadataMap map;
83    
84          /**          /**
85           * This class enables a non Atlas context to use the Atlas LayerPanel           * This class enables a non Atlas context to use the Atlas LayerPanel
# Line 92  public class StyledFS implements StyledF Line 92  public class StyledFS implements StyledF
92           *            may be <code>null</code>. Otherwise the SLD {@link File} to           *            may be <code>null</code>. Otherwise the SLD {@link File} to
93           *            import and associate with this {@link StyledFS}           *            import and associate with this {@link StyledFS}
94           */           */
95          public StyledFS(FeatureSource fs, File sldFile) {          public StyledFS(FeatureSource<SimpleFeatureType, SimpleFeature> fs, File sldFile) {
96    
97                  this.fs = fs;                  this.fs = fs;
98                  id = StyledFS.class.getSimpleName()                  id = StyledFS.class.getSimpleName()
# Line 100  public class StyledFS implements StyledF Line 100  public class StyledFS implements StyledF
100    
101                  this.sldFile = sldFile;                  this.sldFile = sldFile;
102    
103                  if ((sldFile != null) && (sldFile.exists())) {                  if (sldFile != null && sldFile.exists()) {
104                          try {                          try {
105                                  style = StylingUtil.loadSLD(sldFile)[0];                                  style = StylingUtil.loadSLD(sldFile)[0];
106                          } catch (FileNotFoundException e) {                          } catch (FileNotFoundException e) {
# Line 121  public class StyledFS implements StyledF Line 121  public class StyledFS implements StyledF
121          }          }
122    
123          /**          /**
124           * Returnes human readable {@link String} of the CRS natively used by this           * Returns human readable {@link String} of the CRS natively used by this
125           * {@link DpLayer}           * {@link DpLayer}
126           *           *
127           * If crs == null, it will call {@link #getGeoObject()}           * If CRS == null, it will call {@link #getGeoObject()}
128           *           *
129           */           */
130          public String getCRSString() {          public String getCRSString() {
# Line 135  public class StyledFS implements StyledF Line 135  public class StyledFS implements StyledF
135          }          }
136    
137          public CoordinateReferenceSystem getCrs() {          public CoordinateReferenceSystem getCrs() {
138                  return fs.getSchema().getDefaultGeometry().getCoordinateSystem();                  return fs.getSchema().getCoordinateReferenceSystem();
139          }          }
140    
141          public Translation getDesc() {          public Translation getDesc() {
# Line 151  public class StyledFS implements StyledF Line 151  public class StyledFS implements StyledF
151                  }                  }
152          }          }
153    
154          public FeatureSource getGeoObject() {          public FeatureSource<SimpleFeatureType, SimpleFeature> getGeoObject() {
155                  return fs;                  return fs;
156          }          }
157    
# Line 224  public class StyledFS implements StyledF Line 224  public class StyledFS implements StyledF
224          /**          /**
225           *           *
226           */           */
227          public Map<Integer, AttributeMetaData> getAttributeMetaDataMap() {          public AttributeMetadataMap getAttributeMetaDataMap() {
228                  if (map == null) {                  if (map == null) {
229    
230                          map = new HashMap<Integer, AttributeMetaData>();                          map = new AttributeMetadataMap();
231    
232                          // Leaving out the first one, it will be the_geom                          // Leaving out the first one, it will be the_geom
233                          for (int i = 1; i < fs.getSchema().getAttributeCount(); i++) {                          for (int i = 1; i < fs.getSchema().getAttributeCount(); i++) {
234                                  AttributeDescriptor att = fs.getSchema().getAttributeType(i);                                  AttributeDescriptor att = fs.getSchema().getDescriptor(i);
235    
236                                  AttributeMetaData attMetaData = new AttributeMetaData(i, att                                  AttributeMetaData attMetaData = new AttributeMetaData(i, att
237                                                  .getLocalName());                                                  .getLocalName());

Legend:
Removed from v.332  
changed lines
  Added in v.422

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26