/[schmitzm]/trunk/src/skrueger/AttributeMetadataInterface.java
ViewVC logotype

Diff of /trunk/src/skrueger/AttributeMetadataInterface.java

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

branches/1.0-gt2-2.6/src/skrueger/AttributeMetadata.java revision 470 by alfonx, Wed Oct 14 16:20:26 2009 UTC trunk/src/skrueger/AttributeMetadataInterface.java revision 772 by alfonx, Sun Mar 21 14:05:26 2010 UTC
# Line 1  Line 1 
 /*******************************************************************************  
  * Copyright (c) 2009 Martin O. J. Schmitz.  
  *  
  * This file is part of the SCHMITZM library - a collection of utility  
  * classes based on Java 1.6, focusing (not only) on Java Swing  
  * and the Geotools library.  
  *  
  * The SCHMITZM project is hosted at:  
  * http://wald.intevation.org/projects/schmitzm/  
  *  
  * This program is free software; you can redistribute it and/or  
  * modify it under the terms of the GNU Lesser General Public License  
  * as published by the Free Software Foundation; either version 3  
  * of the License, or (at your option) any later version.  
  *  
  * This program is distributed in the hope that it will be useful,  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
  * GNU General Public License for more details.  
  *  
  * You should have received a copy of the GNU Lesser General Public License (license.txt)  
  * along with this program; if not, write to the Free Software  
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.  
  * or try this link: http://www.gnu.org/licenses/lgpl.html  
  *  
  * Contributors:  
  *     Martin O. J. Schmitz - initial API and implementation  
  *     Stefan A. Krüger - additional utility classes  
  ******************************************************************************/  
1  package skrueger;  package skrueger;
2    
3  import org.apache.log4j.Logger;  import java.io.Serializable;
4    import java.util.HashSet;
5    import java.util.Set;
6    
7  import org.geotools.feature.NameImpl;  import org.geotools.feature.NameImpl;
 import org.opengis.feature.type.AttributeDescriptor;  
8  import org.opengis.feature.type.Name;  import org.opengis.feature.type.Name;
9    
10  import skrueger.geotools.Copyable;  import skrueger.geotools.Copyable;
 import skrueger.geotools.StyledLayerInterface;  
11  import skrueger.i8n.Translation;  import skrueger.i8n.Translation;
12    
13  /**  public interface AttributeMetadataInterface extends Copyable<AttributeMetadataInterface>,
14   * This class holds meta information about an attribute/column. This information                  Comparable<AttributeMetadataInterface> {
  * is used by {@link StyledLayerInterface}.  
  *  
  * @author <a href="mailto:[email protected]">Stefan Alfons Kr&uuml;ger</a>  
  */  
 public class AttributeMetadata implements Copyable<AttributeMetadata> {  
         static private final Logger LOGGER = Logger  
                         .getLogger(AttributeMetadata.class);  
   
         protected Translation title = new Translation();  
         protected Translation desc = new Translation();  
         protected boolean visible = true;  
         protected String unit = "";  
         protected int colIdx;  
         private Name name;  
15    
16          /**          /**
17           * Creates an {@link AttributeMetadata} object with the following           * @return a translatable title for this attribute..
18           * information           */
19           *          public Translation getTitle();
          * @param colIdx  
          *            The column index of this attribute in the underlying  
          *            table/dbf/etc...  
          * @param visible  
          *            Shall this attribute be displayed or hidden from the user?  
          * @param title  
          *            {@link Translation} for Name  
          * @param desc  
          *            {@link Translation} for an attribute description  
          * @param unit  
          *            {@link String} of the unit that the information is in  
          */  
         public AttributeMetadata(final Name name, final Boolean visible,  
                         final Translation title, final Translation desc, final String unit) {  
   
                 this.setName(name);  
                 this.title = title;  
                 this.desc = desc;  
                   
                 // The THE_GEOM and shall never be visible!  
                 if (name.getLocalPart().equalsIgnoreCase("the_geom")) this.visible = false;  
                   
                 this.unit = unit;  
         }  
20    
21          /**          /**
22           * Creates an {@link AttributeMetadata} object with the following           * Set a translatable title for this attribute..
          * information  
          *  
          * @param visible  
          *            Shall this attribute be displayed or hidden from the user?  
          * @param title  
          *            {@link Translation} for Name  
          * @param desc  
          *            {@link Translation} for an attribute description  
          * @param unit  
          *            {@link String} of the unit that the information is in  
23           */           */
24          public AttributeMetadata(final String localName, final Boolean visible,          public void setTitle(Translation title);
25                          final Translation title, final Translation desc, final String unit) {          
                 this(new NameImpl(localName), true, title, desc, "");  
         }  
   
26          /**          /**
27           * Creates a new visible {@link AttributeMetadata} with default (no) values.           * Set an untranslated title for this attribute or pass a {@link Translation} encryped as a {@link String}
28           */           */
29          public AttributeMetadata(final String localName, final String defaultTitle) {          public void setTitle(String title);
                 this(localName, true, new Translation(defaultTitle), new Translation(),  
                                 "");  
         }  
30    
31          /**          /**
32           * Creates a new visible {@link AttributeMetadata} with default (no) values.           * @return a translatable description for this attribute
33           */           */
34          public AttributeMetadata(final Name name, final String defaultTitle) {          public Translation getDesc();
                 this(name, true, new Translation(defaultTitle), new Translation(), "");  
         }  
35    
36          /**          /**
37           * Creates a new visible {@link AttributeMetadata} with default (no) values.           * Set a translatable description for this attribute.
38           */           */
39          public AttributeMetadata(final Name name) {          public void setDesc(Translation desc);
                 this(name, true, new Translation(name.getLocalPart()),  
                                 new Translation(), "");  
         }  
40    
41          /**          /**
42           * Creates a new visible {@link AttributeMetadata} with default (no) values.           * Set an untranslated description for this attribute or pass a {@link Translation} encryped as a {@link String}  
43           */           */
44          public AttributeMetadata(final String localName) {          public void setDesc(String desc);
                 this(localName, true, new Translation(localName), new Translation(), "");  
         }  
   
         /** Only used for {@link Copyable<AttributeMetaData>#copy()} **/  
         private AttributeMetadata() {  
         }  
   
         public AttributeMetadata(AttributeDescriptor attDesc) {  
                 this(attDesc.getName());  
         }  
45    
         public boolean isVisible() {  
                 return visible;  
         }  
46    
47          public void setVisible(final Boolean visible) {          /**
48                  this.visible = visible;           * The local name. E.g. the name of the DBF column as a {@link String}.
49          }           */
50  //          public String getLocalName();
 //      /** @return the index of this attribute in the underlying table/dbf **/  
 //      public int getColIdx() {  
 //              return colIdx;  
 //      }  
   
         public Translation getTitle() {  
                 return title;  
         }  
   
         public void setTitle(final Translation title) {  
                 this.title = title;  
         }  
51    
52          public Translation getDesc() {          /**
53                  return desc;           * A short form for #setName(new NameImpl(localName))
54          }           */
55            public void setLocalName(String localName);
56    
57          public void setDesc(final Translation desc) {          /**
58                  this.desc = desc;           * The fully qualified {@link Name} of the attribute, e.g.
59          }           * <code>org.bla.plo:blub</code>. The second part equals the
60             * {@link #getLocalName()} value. The first may be <code>null</code> or
61             * represent the layer name.
62             */
63            public NameImpl getName();
64    
65          public String getUnit() {          /**
66                  return unit;           * set the fully qualified {@link Name} of this attribute.
67          }           */
68            public void setName(NameImpl name);
69    
70          public void setUnit(final String unit) {          /**
71                  this.unit = unit;           * A list og objects that represent NODATA-values for this attribute. The
72          }           * objects are supporsed to be correctly casted already. That means that the
73             * NODATA objects listed here have must have the same type as the values of
74             * this object.
75             */
76            public HashSet<Object> getNodataValues();
77    
78          @Override          /**
79          public AttributeMetadata copyTo(AttributeMetadata amd) {           * Takes any value object and checks it against the NODATA values. If the
80                  getTitle().copyTo(amd.getTitle());           * value equals a NODATA value, <code>null</code> is returned. Otherwise the
81                  getDesc().copyTo(amd.getDesc());           * same object is returned.
82                  amd.setUnit(getUnit());           *
83                  amd.setVisible(isVisible());           * Note: This method is called often.
84                  amd.setName(new NameImpl(getName().getNamespaceURI(), getName().getLocalPart()));           */
85            public Object fiterNodata(Object value);
86    
87                  return amd;          /**
88          }           * @return a non-translatable unit {@link String} for this attribute values.
89             */
90            public String getUnit();
91    
92          @Override          /**
93          public AttributeMetadata copy() {           * Set a unit {@link String} for this attribute values.
94                  return copyTo( new AttributeMetadata());           */
95          }          public void setUnit(String unit);
96    
97          /**          /**
98           * The local Name. E.g. the name of the DBF column as a String           * @return A value defining the position of this attribute whenever the
99             *         attributes are listed to an end-user. The higher the weight, the
100             *         lower the position. (heavy goes down, light goes up)
101           */           */
102          public String getLocalName() {          public double getWeight();
                 return getName().getLocalPart();  
         }  
103    
104          /**          /**
105           * The fully qualified Name of the attribute, e.g. org.bla.plo:blub           * set a value defining the position of this attribute whenever the
106             * attributes are listed to an end-user. The higher the weight, the lower
107             * the position. (heavy goes down, light goes up)
108           */           */
109          public Name getName() {          public void setWeight(double weight);
                 return name;  
         }  
110    
111          /**          /**
112           * The fully qualified Name of the attribute, e.g. org.bla.plo:blub           * @return <code>false</code> if this attribute should not be selectable or
113             *         shown to the end-user.
114           */           */
115          public void setName(org.opengis.feature.type.Name name) {          public boolean isVisible();
                 this.name = name;  
         }  
116    
117          /**          /**
118           * The fully qualified Name of the attribute, e.g. org.bla.plo:blub           * Set <code>false</code> if this attribute should not be shown to the
119             * end-user.
120           */           */
121          public void setLocalName(String localName) {          public void setVisible(boolean visible);
122                  this.name = new NameImpl(localName);  
123          }          String getNoDataValuesFormatted();
124    
125  }  }

Legend:
Removed from v.470  
changed lines
  Added in v.772

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26