/[schmitzm]/branches/2.0-RC1/src/skrueger/AttributeMetadata.java
ViewVC logotype

Annotation of /branches/2.0-RC1/src/skrueger/AttributeMetadata.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 420 - (hide annotations)
Thu Oct 1 20:22:48 2009 UTC (15 years, 5 months ago) by alfonx
Original Path: branches/1.0-gt2-2.6/src/skrueger/AttributeMetaData.java
File size: 4501 byte(s)
* Lots of changes in this big commit for GP 1.3 
* New Interfaces: Checkable, Copyable, Cancellable, CancellableDialogAdapter to improve the GUI
* New DialogManager to unify the handling of all dialogs.
* GP-Feature: The dialog for editing/translating a DpEntry has been "enriched".
1 alfonx 244 /*******************************************************************************
2     * Copyright (c) 2009 Martin O. J. Schmitz.
3     *
4     * This file is part of the SCHMITZM library - a collection of utility
5 alfonx 256 * classes based on Java 1.6, focusing (not only) on Java Swing
6 alfonx 244 * and the Geotools library.
7     *
8     * The SCHMITZM project is hosted at:
9     * http://wald.intevation.org/projects/schmitzm/
10     *
11     * This program is free software; you can redistribute it and/or
12     * modify it under the terms of the GNU Lesser General Public License
13     * as published by the Free Software Foundation; either version 3
14     * of the License, or (at your option) any later version.
15     *
16     * This program is distributed in the hope that it will be useful,
17     * but WITHOUT ANY WARRANTY; without even the implied warranty of
18     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19     * GNU General Public License for more details.
20     *
21     * You should have received a copy of the GNU Lesser General Public License (license.txt)
22     * along with this program; if not, write to the Free Software
23     * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24     * or try this link: http://www.gnu.org/licenses/lgpl.html
25     *
26     * Contributors:
27     * Martin O. J. Schmitz - initial API and implementation
28     * Stefan A. Krüger - additional utility classes
29     ******************************************************************************/
30     package skrueger;
31    
32     import org.apache.log4j.Logger;
33    
34 alfonx 420 import skrueger.geotools.Copyable;
35 mojays 325 import skrueger.geotools.StyledLayerInterface;
36 alfonx 244 import skrueger.i8n.Translation;
37    
38     /**
39     * This class holds meta information about an attribute/column. This
40     * information is used by {@link StyledLayerInterface}.
41     *
42     * @author <a href="mailto:[email protected]">Stefan Alfons Kr&uuml;ger</a>
43     */
44 alfonx 420 public class AttributeMetaData implements Copyable<AttributeMetaData>{
45 alfonx 244 static private final Logger LOGGER = Logger
46     .getLogger(AttributeMetaData.class);
47     protected Translation title = new Translation();
48     protected Translation desc = new Translation();
49     protected boolean visible = false;
50     protected String unit = "";
51     protected int colIdx;
52 alfonx 420
53 alfonx 244 /**
54     * Creates an {@link AttributeMetaData} object with the following information
55     * @param colIdx The column index of this attribute in the underlying table/dbf/etc...
56     * @param visible Shall this attribute be displayed or hidden from the user?
57     * @param title {@link Translation} for Name
58     * @param desc {@link Translation} for an attribute description
59     * @param unit {@link String} of the unit that the information is in
60     */
61     public AttributeMetaData(final int colIdx, final Boolean visible,
62     final Translation title, final Translation desc, final String unit) {
63    
64     this.colIdx = colIdx;
65     this.title = title;
66     this.desc = desc;
67     if (colIdx == 0){
68 alfonx 304 // The first attribute is THE_GEOM and shall never be visible!
69 alfonx 244 this.visible = false;
70     }else
71     this.visible = visible;
72     this.unit = unit;
73     }
74    
75     /**
76     * Creates a new visible {@link AttributeMetaData} with default (no) values.
77     */
78     public AttributeMetaData(final Integer col, final String defaultName) {
79     this(col, true, new Translation(defaultName), new Translation(), "");
80     }
81    
82 alfonx 420 /** Only used for {@link Copyable<AttributeMetaData>#copy()}**/
83     private AttributeMetaData() {
84     }
85    
86     public boolean isVisible() {
87 alfonx 244 return visible;
88     }
89    
90     public void setVisible(final Boolean visible) {
91     this.visible = visible;
92     }
93    
94     /** @return the index of this attribute in the underlying table/dbf **/
95     public int getColIdx() {
96     return colIdx;
97     }
98    
99     public Translation getTitle() {
100     return title;
101     }
102    
103     public void setTitle(final Translation title) {
104     this.title = title;
105     }
106    
107     public Translation getDesc() {
108     return desc;
109     }
110    
111     public void setDesc(final Translation desc) {
112     this.desc = desc;
113     }
114    
115     public String getUnit() {
116     return unit;
117     }
118    
119     public void setUnit(final String unit) {
120     this.unit = unit;
121     }
122 alfonx 420
123     @Override
124     public AttributeMetaData copyTo(AttributeMetaData amd) {
125     getTitle().copyTo(amd.getTitle());
126     getDesc().copyTo(amd.getDesc());
127     amd.setUnit(getUnit());
128     amd.setVisible(isVisible());
129     amd.setColIdx(getColIdx());
130    
131     return amd;
132     }
133    
134     @Override
135     public AttributeMetaData copy() {
136     AttributeMetaData amd = new AttributeMetaData();
137     getTitle().copyTo(amd.getTitle());
138     getDesc().copyTo(amd.getDesc());
139     amd.setUnit(getUnit());
140     amd.setVisible(isVisible());
141     amd.setColIdx(getColIdx());
142    
143     return amd;
144     }
145    
146     private void setColIdx(int colIdx_) {
147     colIdx = colIdx_;
148     }
149 alfonx 244 }

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26