/[schmitzm]/branches/2.3.x/src/skrueger/AttributeMetadataInterface.java
ViewVC logotype

Diff of /branches/2.3.x/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 464 by alfonx, Tue Oct 13 13:22:31 2009 UTC branches/2.3.x/src/skrueger/AttributeMetadataInterface.java revision 1240 by alfonx, Fri Nov 5 13:02:30 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.util.HashSet;
4  import org.geotools.feature.NameImpl;  
 import org.opengis.feature.type.AttributeDescriptor;  
5  import org.opengis.feature.type.Name;  import org.opengis.feature.type.Name;
6    
7  import skrueger.geotools.Copyable;  import skrueger.geotools.Copyable;
 import skrueger.geotools.StyledLayerInterface;  
8  import skrueger.i8n.Translation;  import skrueger.i8n.Translation;
9    
10  /**  public interface AttributeMetadataInterface extends Copyable<AttributeMetadataInterface>,
11   * 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 org.opengis.feature.type.Name name;  
12    
13          /**          /**
14           * Creates an {@link AttributeMetadata} object with the following           * @return a translatable title for this attribute..
15           * information           */
16           *          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;  
         }  
17    
18          /**          /**
19           * 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  
20           */           */
21          public AttributeMetadata(final String localName, final Boolean visible,          public void setTitle(Translation title);
22                          final Translation title, final Translation desc, final String unit) {          
                 this(new NameImpl(localName), true, title, desc, "");  
         }  
   
23          /**          /**
24           * 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}
25           */           */
26          public AttributeMetadata(final String localName, final String defaultTitle) {          public void setTitle(String title);
                 this(localName, true, new Translation(defaultTitle), new Translation(),  
                                 "");  
         }  
27    
28          /**          /**
29           * Creates a new visible {@link AttributeMetadata} with default (no) values.           * @return a translatable description for this attribute
30           */           */
31          public AttributeMetadata(final Name name, final String defaultTitle) {          public Translation getDesc();
                 this(name, true, new Translation(defaultTitle), new Translation(), "");  
         }  
32    
33          /**          /**
34           * Creates a new visible {@link AttributeMetadata} with default (no) values.           * Set a translatable description for this attribute.
35           */           */
36          public AttributeMetadata(final Name name) {          public void setDesc(Translation desc);
                 this(name, true, new Translation(name.getLocalPart()),  
                                 new Translation(), "");  
         }  
37    
38          /**          /**
39           * 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}  
40           */           */
41          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());  
         }  
42    
         public boolean isVisible() {  
                 return visible;  
         }  
43    
44          public void setVisible(final Boolean visible) {          /**
45                  this.visible = visible;           * The local name. E.g. the name of the DBF column as a {@link String}.
46          }           */
47  //          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;  
         }  
48    
49          public Translation getDesc() {          /**
50                  return desc;           * A short form for #setName(new NameImpl(localName))
51          }           */
52            public void setLocalName(String localName);
53    
54          public void setDesc(final Translation desc) {          /**
55                  this.desc = desc;           * The fully qualified {@link Name} of the attribute, e.g.
56          }           * <code>org.bla.plo:blub</code>. The second part equals the
57             * {@link #getLocalName()} value. The first may be <code>null</code> or
58             * represent the layer name.
59             */
60            public Name getName();
61    
62          public String getUnit() {          /**
63                  return unit;           * set the fully qualified {@link Name} of this attribute.
64          }           */
65            public void setName(Name name);
66    
67          public void setUnit(final String unit) {          /**
68                  this.unit = unit;           * A list og objects that represent NODATA-values for this attribute. The
69          }           * objects are supporsed to be correctly casted already. That means that the
70             * NODATA objects listed here have must have the same type as the values of
71             * this object.
72             */
73            public HashSet<Object> getNodataValues();
74    
75          @Override          /**
76          public AttributeMetadata copyTo(AttributeMetadata amd) {           * Takes any value object and checks it against the NODATA values. If the
77                  getTitle().copyTo(amd.getTitle());           * value equals a NODATA value, <code>null</code> is returned. Otherwise the
78                  getDesc().copyTo(amd.getDesc());           * same object is returned.
79                  amd.setUnit(getUnit());           *
80                  amd.setVisible(isVisible());           * Note: This method is called often.
81                  amd.setName(new NameImpl(getName().getNamespaceURI(), getName().getLocalPart()));           */
82            public Object fiterNodata(Object value);
83    
84                  return amd;          /**
85          }           * @return a non-translatable unit {@link String} for this attribute values.
86             */
87            public String getUnit();
88    
89          @Override          /**
90          public AttributeMetadata copy() {           * Set a unit {@link String} for this attribute values.
91                  return copyTo( new AttributeMetadata());           */
92          }          public void setUnit(String unit);
93    
94          /**          /**
95           * 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
96             *         attributes are listed to an end-user. The higher the weight, the
97             *         lower the position. (heavy goes down, light goes up)
98           */           */
99          public String getLocalName() {          public double getWeight();
                 return getName().getLocalPart();  
         }  
100    
101          /**          /**
102           * The fully qualified Name of the attribute, e.g. org.bla.plo:blub           * set a value defining the position of this attribute whenever the
103             * attributes are listed to an end-user. The higher the weight, the lower
104             * the position. (heavy goes down, light goes up)
105           */           */
106          public Name getName() {          public void setWeight(double weight);
                 return name;  
         }  
107    
108          /**          /**
109           * 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
110             *         shown to the end-user.
111           */           */
112          public void setName(org.opengis.feature.type.Name name) {          public boolean isVisible();
                 this.name = name;  
         }  
113    
114          /**          /**
115           * 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
116             * end-user.
117           */           */
118          public void setLocalName(String localName) {          public void setVisible(boolean visible);
119                  this.name = new NameImpl(localName);  
120          }          String getNoDataValuesFormatted();
121    
122  }  }

Legend:
Removed from v.464  
changed lines
  Added in v.1240

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26