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

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

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

revision 1052 by alfonx, Thu Sep 23 16:15:25 2010 UTC revision 1265 by alfonx, Fri Nov 12 19:17:47 2010 UTC
# Line 68  public class StyledFeatureCollectionTabl Line 68  public class StyledFeatureCollectionTabl
68                  FeatureCollectionTableModel {                  FeatureCollectionTableModel {
69          final static private Logger LOGGER = Logger          final static private Logger LOGGER = Logger
70                          .getLogger(StyledFeatureCollectionTableModel.class);                          .getLogger(StyledFeatureCollectionTableModel.class);
71          /** Contains the complete {@link AttributeMetadataImpl}-Map of the styled layer. */          /**
72             * Contains the complete {@link AttributeMetadataImpl}-Map of the styled
73             * layer.
74             */
75          protected AttributeMetadataMap<? extends AttributeMetadataInterface> amdMap = null;          protected AttributeMetadataMap<? extends AttributeMetadataInterface> amdMap = null;
76          /** Holds the current filter on the table */          /** Holds the current filter on the table */
77          protected Filter filter = null;          protected Filter filter = null;
# Line 80  public class StyledFeatureCollectionTabl Line 83  public class StyledFeatureCollectionTabl
83           */           */
84          protected String[] colTooltips = null;          protected String[] colTooltips = null;
85    
86          /** A cache for the #sortedValuesVisibleOnly() **/          /**
87             * A cache for the #sortedValuesVisibleOnly(). WHen the amd is changed
88             * externally, this object will stay the same
89             **/
90          protected List<? extends AttributeMetadataInterface> amdMapVisibleOnly = null;          protected List<? extends AttributeMetadataInterface> amdMapVisibleOnly = null;
91    
92          /**          /**
# Line 103  public class StyledFeatureCollectionTabl Line 109  public class StyledFeatureCollectionTabl
109          @Override          @Override
110          public Object getValueAt(int row, int col) {          public Object getValueAt(int row, int col) {
111                  Object rawValue = super.getValueAt(row, col);                  Object rawValue = super.getValueAt(row, col);
112                  return amdMap.sortedValuesVisibleOnly().get(col).fiterNodata(rawValue);                  return amdMapVisibleOnly.get(col).fiterNodata(rawValue);
113          }          }
114            
115          /**          /**
116           * Sets a new data source for the table.           * Sets a new data source for the table.
117           *           *
118           * @param fs           * @param fs
119           *            the feature source           *            the feature source
120           * @param amdm           * @param amdm
121           *            {@link AttributeMetadataImpl}-Map to define the visible attributes           *            {@link AttributeMetadataImpl}-Map to define the visible
122           *            and translation           *            attributes and translation
123           */           */
124          protected void setFeatureSource(          protected void setFeatureSource(
125                          FeatureSource<SimpleFeatureType, SimpleFeature> fs,                          FeatureSource<SimpleFeatureType, SimpleFeature> fs,
126                          AttributeMetadataMap<? extends AttributeMetadataInterface> amdm, Filter filter) throws Exception {                          AttributeMetadataMap<? extends AttributeMetadataInterface> amdm,
127                            Filter filter) throws Exception {
128    
129                  if (filter == null)                  if (filter == null)
130                          filter = Filter.INCLUDE;                          filter = Filter.INCLUDE;
# Line 171  public class StyledFeatureCollectionTabl Line 178  public class StyledFeatureCollectionTabl
178           * @param fs           * @param fs
179           *            the feature source           *            the feature source
180           * @param amd           * @param amd
181           *            {@link AttributeMetadataImpl}-Map to define the visible attributes           *            {@link AttributeMetadataImpl}-Map to define the visible
182           *            and translation           *            attributes and translation
183           */           */
184          public void setStyledFeatures(StyledFeaturesInterface<?> styledFeatures) {          public void setStyledFeatures(StyledFeaturesInterface<?> styledFeatures) {
185                  try {                  try {
# Line 210  public class StyledFeatureCollectionTabl Line 217  public class StyledFeatureCollectionTabl
217                          // Pruefen, welche Attribute angezeigt werden                          // Pruefen, welche Attribute angezeigt werden
218                          attrTypes.clear();                          attrTypes.clear();
219                          for (AttributeMetadataInterface amd : amdMapVisibleOnly) {                          for (AttributeMetadataInterface amd : amdMapVisibleOnly) {
220                  Name name = amd.getName();                                  Name name = amd.getName();
221                  AttributeDescriptor type = schema.getDescriptor(name);                                  AttributeDescriptor type = schema.getDescriptor(name);
222                  // if type can not be determined by complete name,                                  // if type can not be determined by complete name,
223                  // try only the local name                                  // try only the local name
224                  if ( type == null )                                  if (type == null)
225                    type = schema.getDescriptor(name.getLocalPart());                                          type = schema.getDescriptor(name.getLocalPart());
226                                  if (attrFilter == null || attrFilter.accept(type))                                  if (attrFilter == null || attrFilter.accept(type))
227                                          attrTypes.add(type);                                          attrTypes.add(type);
228                          }                          }
# Line 226  public class StyledFeatureCollectionTabl Line 233  public class StyledFeatureCollectionTabl
233                          colClass = new Class[attrTypes.size()];                          colClass = new Class[attrTypes.size()];
234                          attrIdxForCol = new int[attrTypes.size()];                          attrIdxForCol = new int[attrTypes.size()];
235                          for (int i = 0; i < colNames.length; i++) {                          for (int i = 0; i < colNames.length; i++) {
236                  Name name = amdMapVisibleOnly.get(i).getName();                                  Name name = amdMapVisibleOnly.get(i).getName();
237                  AttributeDescriptor descriptor = schema.getDescriptor(name);                                  AttributeDescriptor descriptor = schema.getDescriptor(name);
238                  // if type can not be determined by complete name,                                  // if type can not be determined by complete name,
239                  // try only the local name                                  // try only the local name
240                  if ( descriptor == null )                                  if (descriptor == null)
241                    descriptor = schema.getDescriptor(name.getLocalPart());                                          descriptor = schema.getDescriptor(name.getLocalPart());
242    
243                                  // Not so nice in 26: find the index of an attribute...                                  // Not so nice in 26: find the index of an attribute...
244                                  int idx = schema.getAttributeDescriptors().indexOf(descriptor);                                  int idx = schema.getAttributeDescriptors().indexOf(descriptor);

Legend:
Removed from v.1052  
changed lines
  Added in v.1265

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26