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

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

Legend:
Removed from v.463  
changed lines
  Added in v.797

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26